blob: c94c37d6964c8b573564ee6a37a8ba2fc5d75f0a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Masti, Narayanraddie1892a52015-12-15 15:01:01 +05302 * Copyright (c) 2012-2016 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"
Sushant Kaushik084f6592015-09-10 13:11:56 +053098#include "qwlan_version.h"
c_manjeecfd1efb2015-09-25 19:32:34 +053099#include "wlan_logging_sock_svc.h"
Agrawal Ashishcfe83282016-09-29 13:03:45 +0530100#include "wlan_hdd_misc.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +0530101
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103#define g_mode_rates_size (12)
104#define a_mode_rates_size (8)
105#define FREQ_BASE_80211G (2407)
106#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700107#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530108#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800110 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700111
112#define HDD2GHZCHAN(freq, chan, flag) { \
113 .band = IEEE80211_BAND_2GHZ, \
114 .center_freq = (freq), \
115 .hw_value = (chan),\
116 .flags = (flag), \
117 .max_antenna_gain = 0 ,\
118 .max_power = 30, \
119}
120
121#define HDD5GHZCHAN(freq, chan, flag) { \
122 .band = IEEE80211_BAND_5GHZ, \
123 .center_freq = (freq), \
124 .hw_value = (chan),\
125 .flags = (flag), \
126 .max_antenna_gain = 0 ,\
127 .max_power = 30, \
128}
129
130#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
131{\
132 .bitrate = rate, \
133 .hw_value = rate_id, \
134 .flags = flag, \
135}
136
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530137#ifdef WLAN_FEATURE_VOWIFI_11R
138#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
139#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
140#endif
141
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530142#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530143#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144
Sunil Duttc69bccb2014-05-26 21:30:20 +0530145#ifdef WLAN_FEATURE_LINK_LAYER_STATS
146/*
147 * Used to allocate the size of 4096 for the link layer stats.
148 * The size of 4096 is considered assuming that all data per
149 * respective event fit with in the limit.Please take a call
150 * on the limit based on the data requirements on link layer
151 * statistics.
152 */
153#define LL_STATS_EVENT_BUF_SIZE 4096
154#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530155#ifdef WLAN_FEATURE_EXTSCAN
156/*
157 * Used to allocate the size of 4096 for the EXTScan NL data.
158 * The size of 4096 is considered assuming that all data per
159 * respective event fit with in the limit.Please take a call
160 * on the limit based on the data requirements.
161 */
162
163#define EXTSCAN_EVENT_BUF_SIZE 4096
164#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
165#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530166
Atul Mittal115287b2014-07-08 13:26:33 +0530167/*EXT TDLS*/
168/*
169 * Used to allocate the size of 4096 for the TDLS.
170 * The size of 4096 is considered assuming that all data per
171 * respective event fit with in the limit.Please take a call
172 * on the limit based on the data requirements on link layer
173 * statistics.
174 */
175#define EXTTDLS_EVENT_BUF_SIZE 4096
176
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530177/*
178 * Values for Mac spoofing feature
179 *
180 */
181#define MAC_ADDR_SPOOFING_FW_HOST_DISABLE 0
182#define MAC_ADDR_SPOOFING_FW_HOST_ENABLE 1
183#define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE 2
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +0530184#define MAC_ADDR_SPOOFING_DEFER_INTERVAL 10 //in ms
185
Anurag Chouhan343af7e2016-12-16 13:11:19 +0530186/*
187 * max_sched_scan_plans defined to 10
188 */
189#define MAX_SCHED_SCAN_PLANS 10
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530190
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530191static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700192{
193 WLAN_CIPHER_SUITE_WEP40,
194 WLAN_CIPHER_SUITE_WEP104,
195 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800196#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700197#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
198 WLAN_CIPHER_SUITE_KRK,
199 WLAN_CIPHER_SUITE_CCMP,
200#else
201 WLAN_CIPHER_SUITE_CCMP,
202#endif
203#ifdef FEATURE_WLAN_WAPI
204 WLAN_CIPHER_SUITE_SMS4,
205#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700206#ifdef WLAN_FEATURE_11W
207 WLAN_CIPHER_SUITE_AES_CMAC,
208#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700209};
210
211static inline int is_broadcast_ether_addr(const u8 *addr)
212{
213 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
214 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
215}
216
Agrawal Ashish97dec502015-11-26 20:20:58 +0530217const static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530218{
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2417, 2, 0) ,
221 HDD2GHZCHAN(2422, 3, 0) ,
222 HDD2GHZCHAN(2427, 4, 0) ,
223 HDD2GHZCHAN(2432, 5, 0) ,
224 HDD2GHZCHAN(2437, 6, 0) ,
225 HDD2GHZCHAN(2442, 7, 0) ,
226 HDD2GHZCHAN(2447, 8, 0) ,
227 HDD2GHZCHAN(2452, 9, 0) ,
228 HDD2GHZCHAN(2457, 10, 0) ,
229 HDD2GHZCHAN(2462, 11, 0) ,
230 HDD2GHZCHAN(2467, 12, 0) ,
231 HDD2GHZCHAN(2472, 13, 0) ,
232 HDD2GHZCHAN(2484, 14, 0) ,
233};
234
Agrawal Ashish97dec502015-11-26 20:20:58 +0530235const static struct ieee80211_channel hdd_channels_5_GHZ[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700236{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700237 HDD5GHZCHAN(4920, 240, 0) ,
238 HDD5GHZCHAN(4940, 244, 0) ,
239 HDD5GHZCHAN(4960, 248, 0) ,
240 HDD5GHZCHAN(4980, 252, 0) ,
241 HDD5GHZCHAN(5040, 208, 0) ,
242 HDD5GHZCHAN(5060, 212, 0) ,
243 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 HDD5GHZCHAN(5180, 36, 0) ,
245 HDD5GHZCHAN(5200, 40, 0) ,
246 HDD5GHZCHAN(5220, 44, 0) ,
247 HDD5GHZCHAN(5240, 48, 0) ,
248 HDD5GHZCHAN(5260, 52, 0) ,
249 HDD5GHZCHAN(5280, 56, 0) ,
250 HDD5GHZCHAN(5300, 60, 0) ,
251 HDD5GHZCHAN(5320, 64, 0) ,
252 HDD5GHZCHAN(5500,100, 0) ,
253 HDD5GHZCHAN(5520,104, 0) ,
254 HDD5GHZCHAN(5540,108, 0) ,
255 HDD5GHZCHAN(5560,112, 0) ,
256 HDD5GHZCHAN(5580,116, 0) ,
257 HDD5GHZCHAN(5600,120, 0) ,
258 HDD5GHZCHAN(5620,124, 0) ,
259 HDD5GHZCHAN(5640,128, 0) ,
260 HDD5GHZCHAN(5660,132, 0) ,
261 HDD5GHZCHAN(5680,136, 0) ,
262 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800263#ifdef FEATURE_WLAN_CH144
264 HDD5GHZCHAN(5720,144, 0) ,
265#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 HDD5GHZCHAN(5745,149, 0) ,
267 HDD5GHZCHAN(5765,153, 0) ,
268 HDD5GHZCHAN(5785,157, 0) ,
269 HDD5GHZCHAN(5805,161, 0) ,
270 HDD5GHZCHAN(5825,165, 0) ,
271};
272
273static struct ieee80211_rate g_mode_rates[] =
274{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530275 HDD_G_MODE_RATETAB(10, 0x1, 0),
276 HDD_G_MODE_RATETAB(20, 0x2, 0),
277 HDD_G_MODE_RATETAB(55, 0x4, 0),
278 HDD_G_MODE_RATETAB(110, 0x8, 0),
279 HDD_G_MODE_RATETAB(60, 0x10, 0),
280 HDD_G_MODE_RATETAB(90, 0x20, 0),
281 HDD_G_MODE_RATETAB(120, 0x40, 0),
282 HDD_G_MODE_RATETAB(180, 0x80, 0),
283 HDD_G_MODE_RATETAB(240, 0x100, 0),
284 HDD_G_MODE_RATETAB(360, 0x200, 0),
285 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530287};
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289static struct ieee80211_rate a_mode_rates[] =
290{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530291 HDD_G_MODE_RATETAB(60, 0x10, 0),
292 HDD_G_MODE_RATETAB(90, 0x20, 0),
293 HDD_G_MODE_RATETAB(120, 0x40, 0),
294 HDD_G_MODE_RATETAB(180, 0x80, 0),
295 HDD_G_MODE_RATETAB(240, 0x100, 0),
296 HDD_G_MODE_RATETAB(360, 0x200, 0),
297 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 HDD_G_MODE_RATETAB(540, 0x800, 0),
299};
300
301static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
302{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530303 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
305 .band = IEEE80211_BAND_2GHZ,
306 .bitrates = g_mode_rates,
307 .n_bitrates = g_mode_rates_size,
308 .ht_cap.ht_supported = 1,
309 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
310 | IEEE80211_HT_CAP_GRN_FLD
311 | IEEE80211_HT_CAP_DSSSCCK40
312 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
313 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
314 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
315 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
316 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
317 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
318};
319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
321{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530322 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
324 .band = IEEE80211_BAND_5GHZ,
325 .bitrates = a_mode_rates,
326 .n_bitrates = a_mode_rates_size,
327 .ht_cap.ht_supported = 1,
328 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
329 | IEEE80211_HT_CAP_GRN_FLD
330 | IEEE80211_HT_CAP_DSSSCCK40
331 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
332 | IEEE80211_HT_CAP_SGI_40
333 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
334 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
335 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
336 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
337 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
338 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
339};
340
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530341/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 TX/RX direction for each kind of interface */
343static const struct ieee80211_txrx_stypes
344wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
345 [NL80211_IFTYPE_STATION] = {
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ACTION) |
348 BIT(SIR_MAC_MGMT_PROBE_REQ),
349 },
350 [NL80211_IFTYPE_AP] = {
351 .tx = 0xffff,
352 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
353 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
354 BIT(SIR_MAC_MGMT_PROBE_REQ) |
355 BIT(SIR_MAC_MGMT_DISASSOC) |
356 BIT(SIR_MAC_MGMT_AUTH) |
357 BIT(SIR_MAC_MGMT_DEAUTH) |
358 BIT(SIR_MAC_MGMT_ACTION),
359 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700360 [NL80211_IFTYPE_ADHOC] = {
361 .tx = 0xffff,
362 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
363 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
364 BIT(SIR_MAC_MGMT_PROBE_REQ) |
365 BIT(SIR_MAC_MGMT_DISASSOC) |
366 BIT(SIR_MAC_MGMT_AUTH) |
367 BIT(SIR_MAC_MGMT_DEAUTH) |
368 BIT(SIR_MAC_MGMT_ACTION),
369 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700370 [NL80211_IFTYPE_P2P_CLIENT] = {
371 .tx = 0xffff,
372 .rx = BIT(SIR_MAC_MGMT_ACTION) |
373 BIT(SIR_MAC_MGMT_PROBE_REQ),
374 },
375 [NL80211_IFTYPE_P2P_GO] = {
376 /* This is also same as for SoftAP */
377 .tx = 0xffff,
378 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
379 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
380 BIT(SIR_MAC_MGMT_PROBE_REQ) |
381 BIT(SIR_MAC_MGMT_DISASSOC) |
382 BIT(SIR_MAC_MGMT_AUTH) |
383 BIT(SIR_MAC_MGMT_DEAUTH) |
384 BIT(SIR_MAC_MGMT_ACTION),
385 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700386};
387
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800388#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800389static const struct ieee80211_iface_limit
390wlan_hdd_iface_limit[] = {
391 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800392 /* max = 3 ; Our driver create two interfaces during driver init
393 * wlan0 and p2p0 interfaces. p2p0 is considered as station
394 * interface until a group is formed. In JB architecture, once the
395 * group is formed, interface type of p2p0 is changed to P2P GO or
396 * Client.
397 * When supplicant remove the group, it first issue a set interface
398 * cmd to change the mode back to Station. In JB this works fine as
399 * we advertize two station type interface during driver init.
400 * Some vendors create separate interface for P2P GO/Client,
401 * after group formation(Third one). But while group remove
402 * supplicant first tries to change the mode(3rd interface) to STATION
403 * But as we advertized only two sta type interfaces nl80211 was
404 * returning error for the third one which was leading to failure in
405 * delete interface. Ideally while removing the group, supplicant
406 * should not try to change the 3rd interface mode to Station type.
407 * Till we get a fix in wpa_supplicant, we advertize max STA
408 * interface type to 3
409 */
410 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800411 .types = BIT(NL80211_IFTYPE_STATION),
412 },
413 {
414 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700415 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800416 },
417 {
418 .max = 1,
419 .types = BIT(NL80211_IFTYPE_P2P_GO) |
420 BIT(NL80211_IFTYPE_P2P_CLIENT),
421 },
422};
423
424/* By default, only single channel concurrency is allowed */
425static struct ieee80211_iface_combination
426wlan_hdd_iface_combination = {
427 .limits = wlan_hdd_iface_limit,
428 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800429 /*
430 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
431 * and p2p0 interfaces during driver init
432 * Some vendors create separate interface for P2P operations.
433 * wlan0: STA interface
434 * p2p0: P2P Device interface, action frames goes
435 * through this interface.
436 * p2p-xx: P2P interface, After GO negotiation this interface is
437 * created for p2p operations(GO/CLIENT interface).
438 */
439 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800440 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
441 .beacon_int_infra_match = false,
442};
443#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445static struct cfg80211_ops wlan_hdd_cfg80211_ops;
446
447/* Data rate 100KBPS based on IE Index */
448struct index_data_rate_type
449{
450 v_U8_t beacon_rate_index;
451 v_U16_t supported_rate[4];
452};
453
454/* 11B, 11G Rate table include Basic rate and Extended rate
455 The IDX field is the rate index
456 The HI field is the rate when RSSI is strong or being ignored
457 (in this case we report actual rate)
458 The MID field is the rate when RSSI is moderate
459 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
460 The LO field is the rate when RSSI is low
461 (in this case we don't report rates, actual current rate used)
462 */
463static const struct
464{
465 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700466 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700467} supported_data_rate[] =
468{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700469/* IDX HI HM LM LO (RSSI-based index */
470 {2, { 10, 10, 10, 0}},
471 {4, { 20, 20, 10, 0}},
472 {11, { 55, 20, 10, 0}},
473 {12, { 60, 55, 20, 0}},
474 {18, { 90, 55, 20, 0}},
475 {22, {110, 55, 20, 0}},
476 {24, {120, 90, 60, 0}},
477 {36, {180, 120, 60, 0}},
478 {44, {220, 180, 60, 0}},
479 {48, {240, 180, 90, 0}},
480 {66, {330, 180, 90, 0}},
481 {72, {360, 240, 90, 0}},
482 {96, {480, 240, 120, 0}},
483 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700484};
485
486/* MCS Based rate table */
487static struct index_data_rate_type supported_mcs_rate[] =
488{
489/* MCS L20 L40 S20 S40 */
490 {0, {65, 135, 72, 150}},
491 {1, {130, 270, 144, 300}},
492 {2, {195, 405, 217, 450}},
493 {3, {260, 540, 289, 600}},
494 {4, {390, 810, 433, 900}},
495 {5, {520, 1080, 578, 1200}},
496 {6, {585, 1215, 650, 1350}},
497 {7, {650, 1350, 722, 1500}}
498};
499
Leo Chang6f8870f2013-03-26 18:11:36 -0700500#ifdef WLAN_FEATURE_11AC
501
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530502#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700503
504struct index_vht_data_rate_type
505{
506 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530507 v_U16_t supported_VHT80_rate[2];
508 v_U16_t supported_VHT40_rate[2];
509 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700510};
511
512typedef enum
513{
514 DATA_RATE_11AC_MAX_MCS_7,
515 DATA_RATE_11AC_MAX_MCS_8,
516 DATA_RATE_11AC_MAX_MCS_9,
517 DATA_RATE_11AC_MAX_MCS_NA
518} eDataRate11ACMaxMcs;
519
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530520/* SSID broadcast type */
521typedef enum eSSIDBcastType
522{
523 eBCAST_UNKNOWN = 0,
524 eBCAST_NORMAL = 1,
525 eBCAST_HIDDEN = 2,
526} tSSIDBcastType;
527
Leo Chang6f8870f2013-03-26 18:11:36 -0700528/* MCS Based VHT rate table */
529static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
530{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530531/* MCS L80 S80 L40 S40 L20 S40*/
532 {0, {293, 325}, {135, 150}, {65, 72}},
533 {1, {585, 650}, {270, 300}, {130, 144}},
534 {2, {878, 975}, {405, 450}, {195, 217}},
535 {3, {1170, 1300}, {540, 600}, {260, 289}},
536 {4, {1755, 1950}, {810, 900}, {390, 433}},
537 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
538 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
539 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
540 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
541 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700542};
543#endif /* WLAN_FEATURE_11AC */
544
c_hpothu79aab322014-07-14 21:11:01 +0530545/*array index points to MCS and array value points respective rssi*/
546static int rssiMcsTbl[][10] =
547{
548/*MCS 0 1 2 3 4 5 6 7 8 9*/
549 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
550 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
551 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
552};
553
Jeff Johnson295189b2012-06-20 16:38:30 -0700554extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530555#ifdef FEATURE_WLAN_SCAN_PNO
556static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700558
Leo Chang9056f462013-08-01 19:21:11 -0700559#ifdef WLAN_NL80211_TESTMODE
560enum wlan_hdd_tm_attr
561{
562 WLAN_HDD_TM_ATTR_INVALID = 0,
563 WLAN_HDD_TM_ATTR_CMD = 1,
564 WLAN_HDD_TM_ATTR_DATA = 2,
565 WLAN_HDD_TM_ATTR_TYPE = 3,
566 /* keep last */
567 WLAN_HDD_TM_ATTR_AFTER_LAST,
568 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
569};
570
571enum wlan_hdd_tm_cmd
572{
573 WLAN_HDD_TM_CMD_WLAN_HB = 1,
574};
575
576#define WLAN_HDD_TM_DATA_MAX_LEN 5000
577
578static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
579{
580 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
581 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
582 .len = WLAN_HDD_TM_DATA_MAX_LEN },
583};
584#endif /* WLAN_NL80211_TESTMODE */
585
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800586#ifdef FEATURE_WLAN_CH_AVOID
587/*
588 * FUNCTION: wlan_hdd_send_avoid_freq_event
589 * This is called when wlan driver needs to send vendor specific
590 * avoid frequency range event to userspace
591 */
592int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
593 tHddAvoidFreqList *pAvoidFreqList)
594{
595 struct sk_buff *vendor_event;
596
597 ENTER();
598
599 if (!pHddCtx)
600 {
601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
602 "%s: HDD context is null", __func__);
603 return -1;
604 }
605
606 if (!pAvoidFreqList)
607 {
608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
609 "%s: pAvoidFreqList is null", __func__);
610 return -1;
611 }
612
613 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530614#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
615 NULL,
616#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800617 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530618 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800619 GFP_KERNEL);
620 if (!vendor_event)
621 {
622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
623 "%s: cfg80211_vendor_event_alloc failed", __func__);
624 return -1;
625 }
626
627 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
628 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
629
630 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
631
632 EXIT();
633 return 0;
634}
635#endif /* FEATURE_WLAN_CH_AVOID */
636
Srinivas Dasari030bad32015-02-18 23:23:54 +0530637/*
638 * FUNCTION: __wlan_hdd_cfg80211_nan_request
639 * This is called when wlan driver needs to send vendor specific
640 * nan request event.
641 */
642static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
643 struct wireless_dev *wdev,
644 const void *data, int data_len)
645{
646 tNanRequestReq nan_req;
647 VOS_STATUS status;
648 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530649 struct net_device *dev = wdev->netdev;
650 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
651 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530652 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
653
654 if (0 == data_len)
655 {
656 hddLog(VOS_TRACE_LEVEL_ERROR,
657 FL("NAN - Invalid Request, length = 0"));
658 return ret_val;
659 }
660
661 if (NULL == data)
662 {
663 hddLog(VOS_TRACE_LEVEL_ERROR,
664 FL("NAN - Invalid Request, data is NULL"));
665 return ret_val;
666 }
667
668 status = wlan_hdd_validate_context(pHddCtx);
669 if (0 != status)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("HDD context is not valid"));
673 return -EINVAL;
674 }
675
676 hddLog(LOG1, FL("Received NAN command"));
677 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
678 (tANI_U8 *)data, data_len);
679
680 /* check the NAN Capability */
681 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
682 {
683 hddLog(VOS_TRACE_LEVEL_ERROR,
684 FL("NAN is not supported by Firmware"));
685 return -EINVAL;
686 }
687
688 nan_req.request_data_len = data_len;
689 nan_req.request_data = data;
690
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530691 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530692 if (VOS_STATUS_SUCCESS == status)
693 {
694 ret_val = 0;
695 }
696 return ret_val;
697}
698
699/*
700 * FUNCTION: wlan_hdd_cfg80211_nan_request
701 * Wrapper to protect the nan vendor command from ssr
702 */
703static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
704 struct wireless_dev *wdev,
705 const void *data, int data_len)
706{
707 int ret;
708
709 vos_ssr_protect(__func__);
710 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
711 vos_ssr_unprotect(__func__);
712
713 return ret;
714}
715
716/*
717 * FUNCTION: wlan_hdd_cfg80211_nan_callback
718 * This is a callback function and it gets called
719 * when we need to report nan response event to
720 * upper layers.
721 */
722static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
723{
724 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
725 struct sk_buff *vendor_event;
726 int status;
727 tSirNanEvent *data;
728
729 ENTER();
730 if (NULL == msg)
731 {
732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
733 FL(" msg received here is null"));
734 return;
735 }
736 data = msg;
737
738 status = wlan_hdd_validate_context(pHddCtx);
739
740 if (0 != status)
741 {
742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
743 FL("HDD context is not valid"));
744 return;
745 }
746
747 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530748#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
749 NULL,
750#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530751 data->event_data_len +
752 NLMSG_HDRLEN,
753 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
754 GFP_KERNEL);
755
756 if (!vendor_event)
757 {
758 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
759 FL("cfg80211_vendor_event_alloc failed"));
760 return;
761 }
762 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
763 data->event_data_len, data->event_data))
764 {
765 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
766 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
767 kfree_skb(vendor_event);
768 return;
769 }
770 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
771 EXIT();
772}
773
774/*
775 * FUNCTION: wlan_hdd_cfg80211_nan_init
776 * This function is called to register the callback to sme layer
777 */
778inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
779{
780 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
781}
782
783
Sunil Duttc69bccb2014-05-26 21:30:20 +0530784#ifdef WLAN_FEATURE_LINK_LAYER_STATS
785
786static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
787 struct sk_buff *vendor_event)
788{
789 if (nla_put_u8(vendor_event,
790 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
791 stats->rate.preamble) ||
792 nla_put_u8(vendor_event,
793 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
794 stats->rate.nss) ||
795 nla_put_u8(vendor_event,
796 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
797 stats->rate.bw) ||
798 nla_put_u8(vendor_event,
799 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
800 stats->rate.rateMcsIdx) ||
801 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
802 stats->rate.bitrate ) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
804 stats->txMpdu ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
806 stats->rxMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
808 stats->mpduLost ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
810 stats->retries) ||
811 nla_put_u32(vendor_event,
812 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
813 stats->retriesShort ) ||
814 nla_put_u32(vendor_event,
815 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
816 stats->retriesLong))
817 {
818 hddLog(VOS_TRACE_LEVEL_ERROR,
819 FL("QCA_WLAN_VENDOR_ATTR put fail"));
820 return FALSE;
821 }
822 return TRUE;
823}
824
825static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
826 struct sk_buff *vendor_event)
827{
828 u32 i = 0;
829 struct nlattr *rateInfo;
830 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
831 stats->type) ||
832 nla_put(vendor_event,
833 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
834 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
835 nla_put_u32(vendor_event,
836 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
837 stats->capabilities) ||
838 nla_put_u32(vendor_event,
839 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
840 stats->numRate))
841 {
842 hddLog(VOS_TRACE_LEVEL_ERROR,
843 FL("QCA_WLAN_VENDOR_ATTR put fail"));
844 goto error;
845 }
846
847 rateInfo = nla_nest_start(vendor_event,
848 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530849 if(!rateInfo)
850 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530851 for (i = 0; i < stats->numRate; i++)
852 {
853 struct nlattr *rates;
854 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
855 stats->rateStats +
856 (i * sizeof(tSirWifiRateStat)));
857 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530858 if(!rates)
859 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530860
861 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
862 {
863 hddLog(VOS_TRACE_LEVEL_ERROR,
864 FL("QCA_WLAN_VENDOR_ATTR put fail"));
865 return FALSE;
866 }
867 nla_nest_end(vendor_event, rates);
868 }
869 nla_nest_end(vendor_event, rateInfo);
870
871 return TRUE;
872error:
873 return FALSE;
874}
875
876static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
877 struct sk_buff *vendor_event)
878{
879 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
880 stats->ac ) ||
881 nla_put_u32(vendor_event,
882 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
883 stats->txMpdu ) ||
884 nla_put_u32(vendor_event,
885 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
886 stats->rxMpdu ) ||
887 nla_put_u32(vendor_event,
888 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
889 stats->txMcast ) ||
890 nla_put_u32(vendor_event,
891 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
892 stats->rxMcast ) ||
893 nla_put_u32(vendor_event,
894 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
895 stats->rxAmpdu ) ||
896 nla_put_u32(vendor_event,
897 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
898 stats->txAmpdu ) ||
899 nla_put_u32(vendor_event,
900 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
901 stats->mpduLost )||
902 nla_put_u32(vendor_event,
903 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
904 stats->retries ) ||
905 nla_put_u32(vendor_event,
906 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
907 stats->retriesShort ) ||
908 nla_put_u32(vendor_event,
909 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
910 stats->retriesLong ) ||
911 nla_put_u32(vendor_event,
912 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
913 stats->contentionTimeMin ) ||
914 nla_put_u32(vendor_event,
915 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
916 stats->contentionTimeMax ) ||
917 nla_put_u32(vendor_event,
918 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
919 stats->contentionTimeAvg ) ||
920 nla_put_u32(vendor_event,
921 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
922 stats->contentionNumSamples ))
923 {
924 hddLog(VOS_TRACE_LEVEL_ERROR,
925 FL("QCA_WLAN_VENDOR_ATTR put fail") );
926 return FALSE;
927 }
928 return TRUE;
929}
930
931static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
932 struct sk_buff *vendor_event)
933{
Dino Myclec8f3f332014-07-21 16:48:27 +0530934 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530935 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
936 nla_put(vendor_event,
937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
938 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
939 nla_put_u32(vendor_event,
940 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
941 stats->state ) ||
942 nla_put_u32(vendor_event,
943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
944 stats->roaming ) ||
945 nla_put_u32(vendor_event,
946 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
947 stats->capabilities ) ||
948 nla_put(vendor_event,
949 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
950 strlen(stats->ssid), stats->ssid) ||
951 nla_put(vendor_event,
952 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
953 WNI_CFG_BSSID_LEN, stats->bssid) ||
954 nla_put(vendor_event,
955 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
956 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
957 nla_put(vendor_event,
958 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
959 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
960 )
961 {
962 hddLog(VOS_TRACE_LEVEL_ERROR,
963 FL("QCA_WLAN_VENDOR_ATTR put fail") );
964 return FALSE;
965 }
966 return TRUE;
967}
968
Dino Mycle3b9536d2014-07-09 22:05:24 +0530969static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
970 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530971 struct sk_buff *vendor_event)
972{
973 int i = 0;
974 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530975 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
976 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530977 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530978
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 if (FALSE == put_wifi_interface_info(
980 &pWifiIfaceStat->info,
981 vendor_event))
982 {
983 hddLog(VOS_TRACE_LEVEL_ERROR,
984 FL("QCA_WLAN_VENDOR_ATTR put fail") );
985 return FALSE;
986
987 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530988 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
989 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
990 if (NULL == pWifiIfaceStatTL)
991 {
992 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
993 return FALSE;
994 }
995
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530996 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
997 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
998 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1000
1001 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1002 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1003 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301005
1006 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1007 {
1008 if (VOS_STATUS_SUCCESS ==
1009 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1010 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1011 {
1012 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1013 * obtained from TL structure
1014 */
1015
1016 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1017 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301018 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1019
Srinivas Dasari98947432014-11-07 19:41:24 +05301020 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1021 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301028
Srinivas Dasari98947432014-11-07 19:41:24 +05301029 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1030 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301037
Srinivas Dasari98947432014-11-07 19:41:24 +05301038 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1039 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301046 }
1047 else
1048 {
1049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1050 }
1051
Dino Mycle3b9536d2014-07-09 22:05:24 +05301052 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1053 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1060 }
1061 else
1062 {
1063 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1064 }
1065
1066
Sunil Duttc69bccb2014-05-26 21:30:20 +05301067
1068 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301069 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1070 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1071 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301072 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1073 pWifiIfaceStat->beaconRx) ||
1074 nla_put_u32(vendor_event,
1075 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1076 pWifiIfaceStat->mgmtRx) ||
1077 nla_put_u32(vendor_event,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1079 pWifiIfaceStat->mgmtActionRx) ||
1080 nla_put_u32(vendor_event,
1081 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1082 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301083 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301084 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1085 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301086 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301087 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1088 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301089 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301090 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1091 pWifiIfaceStat->rssiAck))
1092 {
1093 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301094 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1095 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301096 return FALSE;
1097 }
1098
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301099#ifdef FEATURE_EXT_LL_STAT
1100 /*
1101 * Ensure when EXT_LL_STAT is supported by both host and fwr,
1102 * then host should send Leaky AP stats to upper layer,
1103 * otherwise no need to send these stats.
1104 */
1105 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
1106 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
1107 )
1108 {
1109 hddLog(VOS_TRACE_LEVEL_INFO,
1110 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
1111 pWifiIfaceStat->leakyApStat.is_leaky_ap,
1112 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
1113 pWifiIfaceStat->leakyApStat.rx_leak_window,
1114 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
1115 if (nla_put_u32(vendor_event,
1116 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
1117 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
1118 nla_put_u32(vendor_event,
1119 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
1120 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
1121 nla_put_u32(vendor_event,
1122 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
1123 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
1124 nla_put_u64(vendor_event,
1125 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
1126 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
1127 {
1128 hddLog(VOS_TRACE_LEVEL_ERROR,
1129 FL("EXT_LL_STAT put fail"));
1130 vos_mem_free(pWifiIfaceStatTL);
1131 return FALSE;
1132 }
1133 }
1134#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301135 wmmInfo = nla_nest_start(vendor_event,
1136 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301137 if(!wmmInfo)
1138 {
1139 vos_mem_free(pWifiIfaceStatTL);
1140 return FALSE;
1141 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301142 for (i = 0; i < WIFI_AC_MAX; i++)
1143 {
1144 struct nlattr *wmmStats;
1145 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301146 if(!wmmStats)
1147 {
1148 vos_mem_free(pWifiIfaceStatTL);
1149 return FALSE;
1150 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301151 if (FALSE == put_wifi_wmm_ac_stat(
1152 &pWifiIfaceStat->AccessclassStats[i],
1153 vendor_event))
1154 {
1155 hddLog(VOS_TRACE_LEVEL_ERROR,
1156 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301157 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301158 return FALSE;
1159 }
1160
1161 nla_nest_end(vendor_event, wmmStats);
1162 }
1163 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301164 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301165 return TRUE;
1166}
1167
1168static tSirWifiInterfaceMode
1169 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1170{
1171 switch (deviceMode)
1172 {
1173 case WLAN_HDD_INFRA_STATION:
1174 return WIFI_INTERFACE_STA;
1175 case WLAN_HDD_SOFTAP:
1176 return WIFI_INTERFACE_SOFTAP;
1177 case WLAN_HDD_P2P_CLIENT:
1178 return WIFI_INTERFACE_P2P_CLIENT;
1179 case WLAN_HDD_P2P_GO:
1180 return WIFI_INTERFACE_P2P_GO;
1181 case WLAN_HDD_IBSS:
1182 return WIFI_INTERFACE_IBSS;
1183 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301184 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301185 }
1186}
1187
1188static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1189 tpSirWifiInterfaceInfo pInfo)
1190{
1191 v_U8_t *staMac = NULL;
1192 hdd_station_ctx_t *pHddStaCtx;
1193 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1194 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1195
1196 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1197
1198 vos_mem_copy(pInfo->macAddr,
1199 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1200
1201 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1202 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1203 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1204 {
1205 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1206 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1207 {
1208 pInfo->state = WIFI_DISCONNECTED;
1209 }
1210 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1211 {
1212 hddLog(VOS_TRACE_LEVEL_ERROR,
1213 "%s: Session ID %d, Connection is in progress", __func__,
1214 pAdapter->sessionId);
1215 pInfo->state = WIFI_ASSOCIATING;
1216 }
1217 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1218 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1219 {
1220 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1221 hddLog(VOS_TRACE_LEVEL_ERROR,
1222 "%s: client " MAC_ADDRESS_STR
1223 " is in the middle of WPS/EAPOL exchange.", __func__,
1224 MAC_ADDR_ARRAY(staMac));
1225 pInfo->state = WIFI_AUTHENTICATING;
1226 }
1227 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1228 {
1229 pInfo->state = WIFI_ASSOCIATED;
1230 vos_mem_copy(pInfo->bssid,
1231 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1232 vos_mem_copy(pInfo->ssid,
1233 pHddStaCtx->conn_info.SSID.SSID.ssId,
1234 pHddStaCtx->conn_info.SSID.SSID.length);
1235 //NULL Terminate the string.
1236 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1237 }
1238 }
1239 vos_mem_copy(pInfo->countryStr,
1240 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1241
1242 vos_mem_copy(pInfo->apCountryStr,
1243 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1244
1245 return TRUE;
1246}
1247
1248/*
1249 * hdd_link_layer_process_peer_stats () - This function is called after
1250 * receiving Link Layer Peer statistics from FW.This function converts
1251 * the firmware data to the NL data and sends the same to the kernel/upper
1252 * layers.
1253 */
1254static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1255 v_VOID_t *pData)
1256{
1257 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301258 tpSirWifiPeerStat pWifiPeerStat;
1259 tpSirWifiPeerInfo pWifiPeerInfo;
1260 struct nlattr *peerInfo;
1261 struct sk_buff *vendor_event;
1262 int status, i;
1263
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301264 ENTER();
1265
Sunil Duttc69bccb2014-05-26 21:30:20 +05301266 status = wlan_hdd_validate_context(pHddCtx);
1267 if (0 != status)
1268 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301269 return;
1270 }
1271
1272 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 "LL_STATS_PEER_ALL : numPeers %u",
1276 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301277 /*
1278 * Allocate a size of 4096 for the peer stats comprising
1279 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1280 * sizeof (tSirWifiRateStat).Each field is put with an
1281 * NL attribute.The size of 4096 is considered assuming
1282 * that number of rates shall not exceed beyond 50 with
1283 * the sizeof (tSirWifiRateStat) being 32.
1284 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301285 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1286 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301287 if (!vendor_event)
1288 {
1289 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301290 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301291 __func__);
1292 return;
1293 }
1294 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301295 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1296 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1297 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301298 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1299 pWifiPeerStat->numPeers))
1300 {
1301 hddLog(VOS_TRACE_LEVEL_ERROR,
1302 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1303 kfree_skb(vendor_event);
1304 return;
1305 }
1306
1307 peerInfo = nla_nest_start(vendor_event,
1308 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301309 if(!peerInfo)
1310 {
1311 hddLog(VOS_TRACE_LEVEL_ERROR,
1312 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1313 __func__);
1314 kfree_skb(vendor_event);
1315 return;
1316 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301317
1318 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1319 pWifiPeerStat->peerInfo);
1320
1321 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1322 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301323 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301324 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301325
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301326 if(!peers)
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: peer stats put fail",
1330 __func__);
1331 kfree_skb(vendor_event);
1332 return;
1333 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301334 if (FALSE == put_wifi_peer_info(
1335 pWifiPeerInfo, vendor_event))
1336 {
1337 hddLog(VOS_TRACE_LEVEL_ERROR,
1338 "%s: put_wifi_peer_info put fail", __func__);
1339 kfree_skb(vendor_event);
1340 return;
1341 }
1342
1343 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1344 pWifiPeerStat->peerInfo +
1345 (i * sizeof(tSirWifiPeerInfo)) +
1346 (numRate * sizeof (tSirWifiRateStat)));
1347 nla_nest_end(vendor_event, peers);
1348 }
1349 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301350 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301351 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352}
1353
1354/*
1355 * hdd_link_layer_process_iface_stats () - This function is called after
1356 * receiving Link Layer Interface statistics from FW.This function converts
1357 * the firmware data to the NL data and sends the same to the kernel/upper
1358 * layers.
1359 */
1360static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1361 v_VOID_t *pData)
1362{
1363 tpSirWifiIfaceStat pWifiIfaceStat;
1364 struct sk_buff *vendor_event;
1365 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1366 int status;
1367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301368 ENTER();
1369
Sunil Duttc69bccb2014-05-26 21:30:20 +05301370 status = wlan_hdd_validate_context(pHddCtx);
1371 if (0 != status)
1372 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301373 return;
1374 }
1375 /*
1376 * Allocate a size of 4096 for the interface stats comprising
1377 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1378 * assuming that all these fit with in the limit.Please take
1379 * a call on the limit based on the data requirements on
1380 * interface statistics.
1381 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301382 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1383 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301384 if (!vendor_event)
1385 {
1386 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301388 return;
1389 }
1390
1391 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1392
Dino Mycle3b9536d2014-07-09 22:05:24 +05301393
1394 if (FALSE == hdd_get_interface_info( pAdapter,
1395 &pWifiIfaceStat->info))
1396 {
1397 hddLog(VOS_TRACE_LEVEL_ERROR,
1398 FL("hdd_get_interface_info get fail") );
1399 kfree_skb(vendor_event);
1400 return;
1401 }
1402
1403 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1404 vendor_event))
1405 {
1406 hddLog(VOS_TRACE_LEVEL_ERROR,
1407 FL("put_wifi_iface_stats fail") );
1408 kfree_skb(vendor_event);
1409 return;
1410 }
1411
Sunil Duttc69bccb2014-05-26 21:30:20 +05301412 hddLog(VOS_TRACE_LEVEL_INFO,
1413 "WMI_LINK_STATS_IFACE Data");
1414
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301415 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301416
1417 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301418}
1419
1420/*
1421 * hdd_link_layer_process_radio_stats () - This function is called after
1422 * receiving Link Layer Radio statistics from FW.This function converts
1423 * the firmware data to the NL data and sends the same to the kernel/upper
1424 * layers.
1425 */
1426static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1427 v_VOID_t *pData)
1428{
1429 int status, i;
1430 tpSirWifiRadioStat pWifiRadioStat;
1431 tpSirWifiChannelStats pWifiChannelStats;
1432 struct sk_buff *vendor_event;
1433 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1434 struct nlattr *chList;
1435
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301436 ENTER();
1437
Sunil Duttc69bccb2014-05-26 21:30:20 +05301438 status = wlan_hdd_validate_context(pHddCtx);
1439 if (0 != status)
1440 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301441 return;
1442 }
1443 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_RADIO"
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301447 " number of radios = %u"
Sunil Duttc69bccb2014-05-26 21:30:20 +05301448 " radio is %d onTime is %u "
1449 " txTime is %u rxTime is %u "
1450 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301451 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301452 " onTimePnoScan is %u onTimeHs20 is %u "
1453 " numChannels is %u",
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301454 NUM_RADIOS,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301455 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1456 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1457 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301458 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301459 pWifiRadioStat->onTimeRoamScan,
1460 pWifiRadioStat->onTimePnoScan,
1461 pWifiRadioStat->onTimeHs20,
1462 pWifiRadioStat->numChannels);
1463 /*
1464 * Allocate a size of 4096 for the Radio stats comprising
1465 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1466 * (tSirWifiChannelStats).Each channel data is put with an
1467 * NL attribute.The size of 4096 is considered assuming that
1468 * number of channels shall not exceed beyond 60 with the
1469 * sizeof (tSirWifiChannelStats) being 24 bytes.
1470 */
1471
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301472 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1473 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301474 if (!vendor_event)
1475 {
1476 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301477 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301478 return;
1479 }
1480
1481 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301482 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1483 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1484 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301485 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1486 pWifiRadioStat->radio) ||
1487 nla_put_u32(vendor_event,
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301488 QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS,
1489 NUM_RADIOS) ||
1490 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301491 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1492 pWifiRadioStat->onTime) ||
1493 nla_put_u32(vendor_event,
1494 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1495 pWifiRadioStat->txTime) ||
1496 nla_put_u32(vendor_event,
1497 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1498 pWifiRadioStat->rxTime) ||
1499 nla_put_u32(vendor_event,
1500 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1501 pWifiRadioStat->onTimeScan) ||
1502 nla_put_u32(vendor_event,
1503 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1504 pWifiRadioStat->onTimeNbd) ||
1505 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301506 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1507 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301508 nla_put_u32(vendor_event,
1509 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1510 pWifiRadioStat->onTimeRoamScan) ||
1511 nla_put_u32(vendor_event,
1512 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1513 pWifiRadioStat->onTimePnoScan) ||
1514 nla_put_u32(vendor_event,
1515 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1516 pWifiRadioStat->onTimeHs20) ||
1517 nla_put_u32(vendor_event,
1518 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1519 pWifiRadioStat->numChannels))
1520 {
1521 hddLog(VOS_TRACE_LEVEL_ERROR,
1522 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1523 kfree_skb(vendor_event);
1524 return ;
1525 }
1526
1527 chList = nla_nest_start(vendor_event,
1528 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301529 if(!chList)
1530 {
1531 hddLog(VOS_TRACE_LEVEL_ERROR,
1532 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1533 __func__);
1534 kfree_skb(vendor_event);
1535 return;
1536 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301537 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1538 {
1539 struct nlattr *chInfo;
1540
1541 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1542 pWifiRadioStat->channels +
1543 (i * sizeof(tSirWifiChannelStats)));
1544
Sunil Duttc69bccb2014-05-26 21:30:20 +05301545 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301546 if(!chInfo)
1547 {
1548 hddLog(VOS_TRACE_LEVEL_ERROR,
1549 "%s: failed to put chInfo",
1550 __func__);
1551 kfree_skb(vendor_event);
1552 return;
1553 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301554
1555 if (nla_put_u32(vendor_event,
1556 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1557 pWifiChannelStats->channel.width) ||
1558 nla_put_u32(vendor_event,
1559 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1560 pWifiChannelStats->channel.centerFreq) ||
1561 nla_put_u32(vendor_event,
1562 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1563 pWifiChannelStats->channel.centerFreq0) ||
1564 nla_put_u32(vendor_event,
1565 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1566 pWifiChannelStats->channel.centerFreq1) ||
1567 nla_put_u32(vendor_event,
1568 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1569 pWifiChannelStats->onTime) ||
1570 nla_put_u32(vendor_event,
1571 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1572 pWifiChannelStats->ccaBusyTime))
1573 {
1574 hddLog(VOS_TRACE_LEVEL_ERROR,
1575 FL("cfg80211_vendor_event_alloc failed") );
1576 kfree_skb(vendor_event);
1577 return ;
1578 }
1579 nla_nest_end(vendor_event, chInfo);
1580 }
1581 nla_nest_end(vendor_event, chList);
1582
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301583 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301584
1585 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301586 return;
1587}
1588
1589/*
1590 * hdd_link_layer_stats_ind_callback () - This function is called after
1591 * receiving Link Layer indications from FW.This callback converts the firmware
1592 * data to the NL data and send the same to the kernel/upper layers.
1593 */
1594static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1595 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301596 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301597{
Dino Mycled3d50022014-07-07 12:58:25 +05301598 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1599 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301600 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301601 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301602 int status;
1603
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301604 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301605
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301606 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 if (0 != status)
1608 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301609 return;
1610 }
1611
Dino Mycled3d50022014-07-07 12:58:25 +05301612 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1613 if (NULL == pAdapter)
1614 {
1615 hddLog(VOS_TRACE_LEVEL_ERROR,
1616 FL(" MAC address %pM does not exist with host"),
1617 macAddr);
1618 return;
1619 }
1620
Sunil Duttc69bccb2014-05-26 21:30:20 +05301621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301622 "%s: Interface: %s LLStats indType: %d", __func__,
1623 pAdapter->dev->name, indType);
1624
Sunil Duttc69bccb2014-05-26 21:30:20 +05301625 switch (indType)
1626 {
1627 case SIR_HAL_LL_STATS_RESULTS_RSP:
1628 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301629 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301630 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
1631 "respId = %u, moreResultToFollow = %u",
1632 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
1633 macAddr, linkLayerStatsResults->respId,
1634 linkLayerStatsResults->moreResultToFollow);
1635
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301636 spin_lock(&hdd_context_lock);
1637 context = &pHddCtx->ll_stats_context;
1638 /* validate response received from target */
1639 if ((context->request_id != linkLayerStatsResults->respId) ||
1640 !(context->request_bitmap & linkLayerStatsResults->paramId))
1641 {
1642 spin_unlock(&hdd_context_lock);
1643 hddLog(LOGE,
1644 FL("Error : Request id %d response id %d request bitmap 0x%x"
1645 "response bitmap 0x%x"),
1646 context->request_id, linkLayerStatsResults->respId,
1647 context->request_bitmap, linkLayerStatsResults->paramId);
1648 return;
1649 }
1650 spin_unlock(&hdd_context_lock);
1651
Sunil Duttc69bccb2014-05-26 21:30:20 +05301652 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1653 {
1654 hdd_link_layer_process_radio_stats(pAdapter,
1655 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301656 spin_lock(&hdd_context_lock);
1657 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1658 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301659 }
1660 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1661 {
1662 hdd_link_layer_process_iface_stats(pAdapter,
1663 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301664 spin_lock(&hdd_context_lock);
1665 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1666 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301667 }
1668 else if ( linkLayerStatsResults->paramId &
1669 WMI_LINK_STATS_ALL_PEER )
1670 {
1671 hdd_link_layer_process_peer_stats(pAdapter,
1672 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301673 spin_lock(&hdd_context_lock);
1674 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1675 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301676 } /* WMI_LINK_STATS_ALL_PEER */
1677 else
1678 {
1679 hddLog(VOS_TRACE_LEVEL_ERROR,
1680 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1681 }
1682
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301683 spin_lock(&hdd_context_lock);
1684 /* complete response event if all requests are completed */
1685 if (0 == context->request_bitmap)
1686 complete(&context->response_event);
1687 spin_unlock(&hdd_context_lock);
1688
Sunil Duttc69bccb2014-05-26 21:30:20 +05301689 break;
1690 }
1691 default:
1692 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1693 break;
1694 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301695
1696 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301697 return;
1698}
1699
1700const struct
1701nla_policy
1702qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1703{
1704 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1705 { .type = NLA_U32 },
1706 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1707 { .type = NLA_U32 },
1708};
1709
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301710static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1711 struct wireless_dev *wdev,
1712 const void *data,
1713 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301714{
1715 int status;
1716 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301717 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301718 struct net_device *dev = wdev->netdev;
1719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1720 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301722 ENTER();
1723
Sunil Duttc69bccb2014-05-26 21:30:20 +05301724 status = wlan_hdd_validate_context(pHddCtx);
1725 if (0 != status)
1726 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301727 return -EINVAL;
1728 }
1729
1730 if (NULL == pAdapter)
1731 {
1732 hddLog(VOS_TRACE_LEVEL_ERROR,
1733 FL("HDD adapter is Null"));
1734 return -ENODEV;
1735 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301736 /* check the LLStats Capability */
1737 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1738 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1739 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05301740 hddLog(VOS_TRACE_LEVEL_WARN,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301741 FL("Link Layer Statistics not supported by Firmware"));
1742 return -EINVAL;
1743 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301744
1745 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1746 (struct nlattr *)data,
1747 data_len, qca_wlan_vendor_ll_set_policy))
1748 {
1749 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1750 return -EINVAL;
1751 }
1752 if (!tb_vendor
1753 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1754 {
1755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1756 return -EINVAL;
1757 }
1758 if (!tb_vendor[
1759 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1760 {
1761 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1762 return -EINVAL;
1763 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301764 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301765 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301766
Dino Mycledf0a5d92014-07-04 09:41:55 +05301767 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301768 nla_get_u32(
1769 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1770
Dino Mycledf0a5d92014-07-04 09:41:55 +05301771 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301772 nla_get_u32(
1773 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1774
Dino Mycled3d50022014-07-07 12:58:25 +05301775 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1776 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301777
1778
1779 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301780 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
1781 "Statistics Gathering = %d ",
1782 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
1783 linkLayerStatsSetReq.mpduSizeThreshold,
1784 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301785
1786 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1787 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301788 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301789 {
1790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1791 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301792 return -EINVAL;
1793
1794 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301795
Sunil Duttc69bccb2014-05-26 21:30:20 +05301796 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301797 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 {
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1800 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301801 return -EINVAL;
1802 }
1803
1804 pAdapter->isLinkLayerStatsSet = 1;
1805
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301806 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301807 return 0;
1808}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301809static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1810 struct wireless_dev *wdev,
1811 const void *data,
1812 int data_len)
1813{
1814 int ret = 0;
1815
1816 vos_ssr_protect(__func__);
1817 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1818 vos_ssr_unprotect(__func__);
1819
1820 return ret;
1821}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822
1823const struct
1824nla_policy
1825qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1826{
1827 /* Unsigned 32bit value provided by the caller issuing the GET stats
1828 * command. When reporting
1829 * the stats results, the driver uses the same value to indicate
1830 * which GET request the results
1831 * correspond to.
1832 */
1833 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1834
1835 /* Unsigned 32bit value . bit mask to identify what statistics are
1836 requested for retrieval */
1837 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1838};
1839
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301840static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1841 struct wireless_dev *wdev,
1842 const void *data,
1843 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301844{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301845 unsigned long rc;
1846 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301847 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1848 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301849 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301850 struct net_device *dev = wdev->netdev;
1851 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05301852 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301853 int status;
1854
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301855 ENTER();
1856
Sunil Duttc69bccb2014-05-26 21:30:20 +05301857 status = wlan_hdd_validate_context(pHddCtx);
1858 if (0 != status)
1859 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860 return -EINVAL ;
1861 }
1862
1863 if (NULL == pAdapter)
1864 {
1865 hddLog(VOS_TRACE_LEVEL_FATAL,
1866 "%s: HDD adapter is Null", __func__);
1867 return -ENODEV;
1868 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05301869
1870 if (pHddStaCtx == NULL)
1871 {
1872 hddLog(VOS_TRACE_LEVEL_FATAL,
1873 "%s: HddStaCtx is Null", __func__);
1874 return -ENODEV;
1875 }
1876
Dino Mycledf0a5d92014-07-04 09:41:55 +05301877 /* check the LLStats Capability */
1878 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1879 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1880 {
1881 hddLog(VOS_TRACE_LEVEL_ERROR,
1882 FL("Link Layer Statistics not supported by Firmware"));
1883 return -EINVAL;
1884 }
1885
Sunil Duttc69bccb2014-05-26 21:30:20 +05301886
1887 if (!pAdapter->isLinkLayerStatsSet)
1888 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05301889 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890 "%s: isLinkLayerStatsSet : %d",
1891 __func__, pAdapter->isLinkLayerStatsSet);
1892 return -EINVAL;
1893 }
1894
Mukul Sharma10313ba2015-07-29 19:14:39 +05301895 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1896 {
1897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1898 "%s: Roaming in progress, so unable to proceed this request", __func__);
1899 return -EBUSY;
1900 }
1901
Sunil Duttc69bccb2014-05-26 21:30:20 +05301902 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1903 (struct nlattr *)data,
1904 data_len, qca_wlan_vendor_ll_get_policy))
1905 {
1906 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1907 return -EINVAL;
1908 }
1909
1910 if (!tb_vendor
1911 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1914 return -EINVAL;
1915 }
1916
1917 if (!tb_vendor
1918 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1919 {
1920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1921 return -EINVAL;
1922 }
1923
Sunil Duttc69bccb2014-05-26 21:30:20 +05301924
Dino Mycledf0a5d92014-07-04 09:41:55 +05301925 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301926 nla_get_u32( tb_vendor[
1927 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301928 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 nla_get_u32( tb_vendor[
1930 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1931
Dino Mycled3d50022014-07-07 12:58:25 +05301932 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1933 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301934
1935 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301936 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
1937 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301938 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301940 spin_lock(&hdd_context_lock);
1941 context = &pHddCtx->ll_stats_context;
1942 context->request_id = linkLayerStatsGetReq.reqId;
1943 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
1944 INIT_COMPLETION(context->response_event);
1945 spin_unlock(&hdd_context_lock);
1946
Sunil Duttc69bccb2014-05-26 21:30:20 +05301947 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301948 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301949 {
1950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1951 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301952 return -EINVAL;
1953 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301954
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301955 rc = wait_for_completion_timeout(&context->response_event,
1956 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
1957 if (!rc)
1958 {
1959 hddLog(LOGE,
1960 FL("Target response timed out request id %d request bitmap 0x%x"),
1961 context->request_id, context->request_bitmap);
1962 return -ETIMEDOUT;
1963 }
1964
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301965 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301966 return 0;
1967}
1968
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301969static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1970 struct wireless_dev *wdev,
1971 const void *data,
1972 int data_len)
1973{
1974 int ret = 0;
1975
1976 vos_ssr_protect(__func__);
1977 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
1978 vos_ssr_unprotect(__func__);
1979
1980 return ret;
1981}
1982
Sunil Duttc69bccb2014-05-26 21:30:20 +05301983const struct
1984nla_policy
1985qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1986{
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1988 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1989 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1990 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1991};
1992
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301993static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1994 struct wireless_dev *wdev,
1995 const void *data,
1996 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997{
1998 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1999 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302000 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302001 struct net_device *dev = wdev->netdev;
2002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2003 u32 statsClearReqMask;
2004 u8 stopReq;
2005 int status;
2006
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302007 ENTER();
2008
Sunil Duttc69bccb2014-05-26 21:30:20 +05302009 status = wlan_hdd_validate_context(pHddCtx);
2010 if (0 != status)
2011 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302012 return -EINVAL;
2013 }
2014
2015 if (NULL == pAdapter)
2016 {
2017 hddLog(VOS_TRACE_LEVEL_FATAL,
2018 "%s: HDD adapter is Null", __func__);
2019 return -ENODEV;
2020 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302021 /* check the LLStats Capability */
2022 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2023 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2024 {
2025 hddLog(VOS_TRACE_LEVEL_ERROR,
2026 FL("Enable LLStats Capability"));
2027 return -EINVAL;
2028 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302029
2030 if (!pAdapter->isLinkLayerStatsSet)
2031 {
2032 hddLog(VOS_TRACE_LEVEL_FATAL,
2033 "%s: isLinkLayerStatsSet : %d",
2034 __func__, pAdapter->isLinkLayerStatsSet);
2035 return -EINVAL;
2036 }
2037
2038 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2039 (struct nlattr *)data,
2040 data_len, qca_wlan_vendor_ll_clr_policy))
2041 {
2042 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2043 return -EINVAL;
2044 }
2045
2046 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2047
2048 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2051 return -EINVAL;
2052
2053 }
2054
Sunil Duttc69bccb2014-05-26 21:30:20 +05302055
Dino Mycledf0a5d92014-07-04 09:41:55 +05302056 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302057 nla_get_u32(
2058 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2059
Dino Mycledf0a5d92014-07-04 09:41:55 +05302060 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302061 nla_get_u8(
2062 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2063
2064 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302065 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302066
Dino Mycled3d50022014-07-07 12:58:25 +05302067 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2068 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302069
2070 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302071 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
2072 "statsClearReqMask = 0x%X, stopReq = %d",
2073 linkLayerStatsClearReq.reqId,
2074 linkLayerStatsClearReq.macAddr,
2075 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302076 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302077
2078 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302079 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302080 {
2081 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302082 hdd_station_ctx_t *pHddStaCtx;
2083
2084 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2085 if (VOS_STATUS_SUCCESS !=
2086 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2087 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2088 {
2089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2090 "WLANTL_ClearInterfaceStats Failed", __func__);
2091 return -EINVAL;
2092 }
2093 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2094 (statsClearReqMask & WIFI_STATS_IFACE)) {
2095 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2096 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2097 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2098 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2099 }
2100
Sunil Duttc69bccb2014-05-26 21:30:20 +05302101 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2102 2 * sizeof(u32) +
2103 NLMSG_HDRLEN);
2104
2105 if (temp_skbuff != NULL)
2106 {
2107
2108 if (nla_put_u32(temp_skbuff,
2109 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2110 statsClearReqMask) ||
2111 nla_put_u32(temp_skbuff,
2112 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2113 stopReq))
2114 {
2115 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2116 kfree_skb(temp_skbuff);
2117 return -EINVAL;
2118 }
2119 /* If the ask is to stop the stats collection as part of clear
2120 * (stopReq = 1) , ensure that no further requests of get
2121 * go to the firmware by having isLinkLayerStatsSet set to 0.
2122 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302123 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302124 * case the firmware is just asked to clear the statistics.
2125 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302126 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302127 pAdapter->isLinkLayerStatsSet = 0;
2128 return cfg80211_vendor_cmd_reply(temp_skbuff);
2129 }
2130 return -ENOMEM;
2131 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302132
2133 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302134 return -EINVAL;
2135}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302136static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2137 struct wireless_dev *wdev,
2138 const void *data,
2139 int data_len)
2140{
2141 int ret = 0;
2142
2143 vos_ssr_protect(__func__);
2144 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2145 vos_ssr_unprotect(__func__);
2146
2147 return ret;
2148
2149
2150}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302151#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2152
Dino Mycle6fb96c12014-06-10 11:52:40 +05302153#ifdef WLAN_FEATURE_EXTSCAN
2154static const struct nla_policy
2155wlan_hdd_extscan_config_policy
2156 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2157{
2158 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2159 { .type = NLA_U32 },
2160 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2161 { .type = NLA_U32 },
2162 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2163 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2164 { .type = NLA_U32 },
2165 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2166 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2167
2168 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2169 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2170 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2171 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2172 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302173 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2174 { .type = NLA_U32 },
2175 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2176 { .type = NLA_U32 },
2177 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2178 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302179 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2180 { .type = NLA_U32 },
2181 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2182 { .type = NLA_U32 },
2183 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2184 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302185 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2186 { .type = NLA_U8 },
2187 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302188 { .type = NLA_U8 },
2189 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2190 { .type = NLA_U8 },
2191 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2192 { .type = NLA_U8 },
2193
2194 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2195 { .type = NLA_U32 },
2196 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2197 { .type = NLA_UNSPEC },
2198 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2199 { .type = NLA_S32 },
2200 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2201 { .type = NLA_S32 },
2202 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2203 { .type = NLA_U32 },
2204 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2205 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302206 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2207 { .type = NLA_U32 },
2208 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2209 { .type = NLA_BINARY,
2210 .len = IEEE80211_MAX_SSID_LEN + 1 },
2211 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302212 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302213 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2214 { .type = NLA_U32 },
2215 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2216 { .type = NLA_U8 },
2217 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2218 { .type = NLA_S32 },
2219 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2220 { .type = NLA_S32 },
2221 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2222 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302223};
2224
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302225/**
2226 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2227 * @ctx: hdd global context
2228 * @data: capabilities data
2229 *
2230 * Return: none
2231 */
2232static void
2233wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302234{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302235 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302236 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302237 tSirEXTScanCapabilitiesEvent *data =
2238 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302240 ENTER();
2241
2242 if (wlan_hdd_validate_context(pHddCtx))
2243 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302244 return;
2245 }
2246
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302247 if (!pMsg)
2248 {
2249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2250 return;
2251 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302252
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302253 vos_spin_lock_acquire(&hdd_context_lock);
2254
2255 context = &pHddCtx->ext_scan_context;
2256 /* validate response received from target*/
2257 if (context->request_id != data->requestId)
2258 {
2259 vos_spin_lock_release(&hdd_context_lock);
2260 hddLog(LOGE,
2261 FL("Target response id did not match: request_id %d resposne_id %d"),
2262 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302263 return;
2264 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302265 else
2266 {
2267 context->capability_response = *data;
2268 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302269 }
2270
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302271 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302272
Dino Mycle6fb96c12014-06-10 11:52:40 +05302273 return;
2274}
2275
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302276/*
2277 * define short names for the global vendor params
2278 * used by wlan_hdd_send_ext_scan_capability()
2279 */
2280#define PARAM_REQUEST_ID \
2281 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2282#define PARAM_STATUS \
2283 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2284#define MAX_SCAN_CACHE_SIZE \
2285 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2286#define MAX_SCAN_BUCKETS \
2287 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2288#define MAX_AP_CACHE_PER_SCAN \
2289 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2290#define MAX_RSSI_SAMPLE_SIZE \
2291 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2292#define MAX_SCAN_RPT_THRHOLD \
2293 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2294#define MAX_HOTLIST_BSSIDS \
2295 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2296#define MAX_BSSID_HISTORY_ENTRIES \
2297 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2298#define MAX_HOTLIST_SSIDS \
2299 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302300#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2301 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302302
2303static int wlan_hdd_send_ext_scan_capability(void *ctx)
2304{
2305 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2306 struct sk_buff *skb = NULL;
2307 int ret;
2308 tSirEXTScanCapabilitiesEvent *data;
2309 tANI_U32 nl_buf_len;
2310
2311 ret = wlan_hdd_validate_context(pHddCtx);
2312 if (0 != ret)
2313 {
2314 return ret;
2315 }
2316
2317 data = &(pHddCtx->ext_scan_context.capability_response);
2318
2319 nl_buf_len = NLMSG_HDRLEN;
2320 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2321 (sizeof(data->status) + NLA_HDRLEN) +
2322 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2323 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2324 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2325 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2326 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2327 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2328 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2329 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2330
2331 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2332
2333 if (!skb)
2334 {
2335 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2336 return -ENOMEM;
2337 }
2338
2339 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2340 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2341 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2342 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2343 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2344 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2345 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2346 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2347
2348 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2349 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2350 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2351 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2352 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2353 data->maxApPerScan) ||
2354 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2355 data->maxRssiSampleSize) ||
2356 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2357 data->maxScanReportingThreshold) ||
2358 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2359 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2360 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302361 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2362 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302363 {
2364 hddLog(LOGE, FL("nla put fail"));
2365 goto nla_put_failure;
2366 }
2367
2368 cfg80211_vendor_cmd_reply(skb);
2369 return 0;
2370
2371nla_put_failure:
2372 kfree_skb(skb);
2373 return -EINVAL;;
2374}
2375
2376/*
2377 * done with short names for the global vendor params
2378 * used by wlan_hdd_send_ext_scan_capability()
2379 */
2380#undef PARAM_REQUEST_ID
2381#undef PARAM_STATUS
2382#undef MAX_SCAN_CACHE_SIZE
2383#undef MAX_SCAN_BUCKETS
2384#undef MAX_AP_CACHE_PER_SCAN
2385#undef MAX_RSSI_SAMPLE_SIZE
2386#undef MAX_SCAN_RPT_THRHOLD
2387#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302388#undef MAX_BSSID_HISTORY_ENTRIES
2389#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302390
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;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302395 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302396 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302398 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302399
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302400 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302401 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302406 return;
2407 }
2408
Dino Mycle6fb96c12014-06-10 11:52:40 +05302409 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2410 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2411
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302412 context = &pHddCtx->ext_scan_context;
2413 spin_lock(&hdd_context_lock);
2414 if (context->request_id == pData->requestId) {
2415 context->response_status = pData->status ? -EINVAL : 0;
2416 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302417 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302418 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302419
2420 /*
2421 * Store the Request ID for comparing with the requestID obtained
2422 * in other requests.HDD shall return a failure is the extscan_stop
2423 * request is issued with a different requestId as that of the
2424 * extscan_start request. Also, This requestId shall be used while
2425 * indicating the full scan results to the upper layers.
2426 * The requestId is stored with the assumption that the firmware
2427 * shall return the ext scan start request's requestId in ext scan
2428 * start response.
2429 */
2430 if (pData->status == 0)
2431 pMac->sme.extScanStartReqId = pData->requestId;
2432
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302433 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302434 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302435}
2436
2437
2438static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2439{
2440 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2441 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302442 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302443
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302444 ENTER();
2445
2446 if (wlan_hdd_validate_context(pHddCtx)){
2447 return;
2448 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302450 if (!pMsg)
2451 {
2452 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302453 return;
2454 }
2455
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302456 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2457 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302458
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302459 context = &pHddCtx->ext_scan_context;
2460 spin_lock(&hdd_context_lock);
2461 if (context->request_id == pData->requestId) {
2462 context->response_status = pData->status ? -EINVAL : 0;
2463 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302464 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302465 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302467 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302468 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302469}
2470
Dino Mycle6fb96c12014-06-10 11:52:40 +05302471static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2472 void *pMsg)
2473{
2474 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302475 tpSirEXTScanSetBssidHotListRspParams pData =
2476 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302477 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302478
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302479 ENTER();
2480
2481 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302482 return;
2483 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302485 if (!pMsg)
2486 {
2487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2488 return;
2489 }
2490
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302491 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2492 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302493
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302494 context = &pHddCtx->ext_scan_context;
2495 spin_lock(&hdd_context_lock);
2496 if (context->request_id == pData->requestId) {
2497 context->response_status = pData->status ? -EINVAL : 0;
2498 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302499 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302500 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302501
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302502 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302503 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302504}
2505
2506static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2507 void *pMsg)
2508{
2509 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302510 tpSirEXTScanResetBssidHotlistRspParams pData =
2511 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302512 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302513
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302514 ENTER();
2515
2516 if (wlan_hdd_validate_context(pHddCtx)) {
2517 return;
2518 }
2519 if (!pMsg)
2520 {
2521 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302522 return;
2523 }
2524
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302525 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2526 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302527
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302528 context = &pHddCtx->ext_scan_context;
2529 spin_lock(&hdd_context_lock);
2530 if (context->request_id == pData->requestId) {
2531 context->response_status = pData->status ? -EINVAL : 0;
2532 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302533 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302534 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302535
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302536 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302537 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302538}
2539
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05302540static void wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(void *ctx,
2541 void *pMsg)
2542{
2543 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2544 tpSirEXTScanSetSsidHotListRspParams pData =
2545 (tpSirEXTScanSetSsidHotListRspParams) pMsg;
2546 struct hdd_ext_scan_context *context;
2547
2548 if (wlan_hdd_validate_context(pHddCtx)){
2549 return;
2550 }
2551
2552 if (!pMsg)
2553 {
2554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2555 return;
2556 }
2557
2558 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2559 pData->status);
2560
2561 context = &pHddCtx->ext_scan_context;
2562 spin_lock(&hdd_context_lock);
2563 if (context->request_id == pData->requestId) {
2564 context->response_status = pData->status ? -EINVAL : 0;
2565 complete(&context->response_event);
2566 }
2567 spin_unlock(&hdd_context_lock);
2568
2569 return;
2570}
2571
2572static void wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(void *ctx,
2573 void *pMsg)
2574{
2575 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2576 tpSirEXTScanResetSsidHotlistRspParams pData =
2577 (tpSirEXTScanResetSsidHotlistRspParams) pMsg;
2578 struct hdd_ext_scan_context *context;
2579
2580 if (wlan_hdd_validate_context(pHddCtx)) {
2581 return;
2582 }
2583 if (!pMsg)
2584 {
2585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2586 return;
2587 }
2588
2589 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2590 pData->status);
2591
2592 context = &pHddCtx->ext_scan_context;
2593 spin_lock(&hdd_context_lock);
2594 if (context->request_id == pData->requestId) {
2595 context->response_status = pData->status ? -EINVAL : 0;
2596 complete(&context->response_event);
2597 }
2598 spin_unlock(&hdd_context_lock);
2599
2600 return;
2601}
2602
2603
Dino Mycle6fb96c12014-06-10 11:52:40 +05302604static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2605 void *pMsg)
2606{
2607 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2608 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302609 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302610 tANI_S32 totalResults;
2611 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302612 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
2613 struct hdd_ext_scan_context *context;
2614 bool ignore_cached_results = false;
2615 tExtscanCachedScanResult *result;
2616 struct nlattr *nla_results;
2617 tANI_U16 ieLength= 0;
2618 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302619
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302620 ENTER();
2621
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302622 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302623 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302624
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302625 if (!pMsg)
2626 {
2627 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2628 return;
2629 }
2630
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302631 spin_lock(&hdd_context_lock);
2632 context = &pHddCtx->ext_scan_context;
2633 ignore_cached_results = context->ignore_cached_results;
2634 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302635
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302636 if (ignore_cached_results) {
2637 hddLog(LOGE,
2638 FL("Ignore the cached results received after timeout"));
2639 return;
2640 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302641
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302642 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
2643 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302644
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302645 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302646
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302647 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
2648 scan_id_index++) {
2649 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302650
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302651 totalResults = result->num_results;
2652 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
2653 result->scan_id, result->flags, totalResults);
2654 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302655
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302656 do{
2657 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2658 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2659 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302660
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302661 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2662 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
2663
2664 if (!skb) {
2665 hddLog(VOS_TRACE_LEVEL_ERROR,
2666 FL("cfg80211_vendor_event_alloc failed"));
2667 return;
2668 }
2669
2670 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2671
2672 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2673 pData->requestId) ||
2674 nla_put_u32(skb,
2675 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2676 resultsPerEvent)) {
2677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2678 goto fail;
2679 }
2680 if (nla_put_u8(skb,
2681 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2682 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302683 {
2684 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2685 goto fail;
2686 }
2687
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302688 if (nla_put_u32(skb,
2689 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2690 result->scan_id)) {
2691 hddLog(LOGE, FL("put fail"));
2692 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302693 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302694
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302695 nla_results = nla_nest_start(skb,
2696 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
2697 if (!nla_results)
2698 goto fail;
2699
2700 if (resultsPerEvent) {
2701 struct nlattr *aps;
2702 struct nlattr *nla_result;
2703
2704 nla_result = nla_nest_start(skb, scan_id_index);
2705 if(!nla_result)
2706 goto fail;
2707
2708 if (nla_put_u32(skb,
2709 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2710 result->scan_id) ||
2711 nla_put_u32(skb,
2712 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
2713 result->flags) ||
2714 nla_put_u32(skb,
2715 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2716 totalResults)) {
2717 hddLog(LOGE, FL("put fail"));
2718 goto fail;
2719 }
2720
2721 aps = nla_nest_start(skb,
2722 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2723 if (!aps)
2724 {
2725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2726 goto fail;
2727 }
2728
2729 head_ptr = (tpSirWifiScanResult) &(result->ap);
2730
2731 for (j = 0; j < resultsPerEvent; j++, i++) {
2732 struct nlattr *ap;
2733 pSirWifiScanResult = head_ptr + i;
2734
2735 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05302736 * Firmware returns timestamp from extscan_start till
2737 * BSSID was cached (in micro seconds). Add this with
2738 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302739 * to derive the time since boot when the
2740 * BSSID was cached.
2741 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05302742 pSirWifiScanResult->ts +=
2743 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302744 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2745 "Ssid (%s)"
2746 "Bssid: %pM "
2747 "Channel (%u)"
2748 "Rssi (%d)"
2749 "RTT (%u)"
2750 "RTT_SD (%u)"
2751 "Beacon Period %u"
2752 "Capability 0x%x "
2753 "Ie length %d",
2754 i,
2755 pSirWifiScanResult->ts,
2756 pSirWifiScanResult->ssid,
2757 pSirWifiScanResult->bssid,
2758 pSirWifiScanResult->channel,
2759 pSirWifiScanResult->rssi,
2760 pSirWifiScanResult->rtt,
2761 pSirWifiScanResult->rtt_sd,
2762 pSirWifiScanResult->beaconPeriod,
2763 pSirWifiScanResult->capability,
2764 ieLength);
2765
2766 ap = nla_nest_start(skb, j + 1);
2767 if (!ap)
2768 {
2769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2770 goto fail;
2771 }
2772
2773 if (nla_put_u64(skb,
2774 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2775 pSirWifiScanResult->ts) )
2776 {
2777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2778 goto fail;
2779 }
2780 if (nla_put(skb,
2781 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2782 sizeof(pSirWifiScanResult->ssid),
2783 pSirWifiScanResult->ssid) )
2784 {
2785 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2786 goto fail;
2787 }
2788 if (nla_put(skb,
2789 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2790 sizeof(pSirWifiScanResult->bssid),
2791 pSirWifiScanResult->bssid) )
2792 {
2793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2794 goto fail;
2795 }
2796 if (nla_put_u32(skb,
2797 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2798 pSirWifiScanResult->channel) )
2799 {
2800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2801 goto fail;
2802 }
2803 if (nla_put_s32(skb,
2804 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2805 pSirWifiScanResult->rssi) )
2806 {
2807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2808 goto fail;
2809 }
2810 if (nla_put_u32(skb,
2811 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2812 pSirWifiScanResult->rtt) )
2813 {
2814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2815 goto fail;
2816 }
2817 if (nla_put_u32(skb,
2818 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2819 pSirWifiScanResult->rtt_sd))
2820 {
2821 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2822 goto fail;
2823 }
2824 if (nla_put_u32(skb,
2825 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2826 pSirWifiScanResult->beaconPeriod))
2827 {
2828 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2829 goto fail;
2830 }
2831 if (nla_put_u32(skb,
2832 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2833 pSirWifiScanResult->capability))
2834 {
2835 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2836 goto fail;
2837 }
2838 if (nla_put_u32(skb,
2839 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2840 ieLength))
2841 {
2842 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2843 goto fail;
2844 }
2845
2846 if (ieLength)
2847 if (nla_put(skb,
2848 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2849 ieLength, ie)) {
2850 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2851 goto fail;
2852 }
2853
2854 nla_nest_end(skb, ap);
2855 }
2856 nla_nest_end(skb, aps);
2857 nla_nest_end(skb, nla_result);
2858 }
2859
2860 nla_nest_end(skb, nla_results);
2861
2862 cfg80211_vendor_cmd_reply(skb);
2863
2864 } while (totalResults > 0);
2865 }
2866
2867 if (!pData->moreData) {
2868 spin_lock(&hdd_context_lock);
2869 context->response_status = 0;
2870 complete(&context->response_event);
2871 spin_unlock(&hdd_context_lock);
2872 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302874 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302875 return;
2876fail:
2877 kfree_skb(skb);
2878 return;
2879}
2880
2881static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2882 void *pMsg)
2883{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302884 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302885 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2886 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302887 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302888
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302889 ENTER();
2890
2891 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302892 hddLog(LOGE,
2893 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302894 return;
2895 }
2896 if (!pMsg)
2897 {
2898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302899 return;
2900 }
2901
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302902 if (pData->bss_found)
2903 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2904 else
2905 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2906
Dino Mycle6fb96c12014-06-10 11:52:40 +05302907 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302908#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2909 NULL,
2910#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302911 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302912 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302913
2914 if (!skb) {
2915 hddLog(VOS_TRACE_LEVEL_ERROR,
2916 FL("cfg80211_vendor_event_alloc failed"));
2917 return;
2918 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302919
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302920 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2921 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2922 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2923 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2924
2925 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302926 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2927 "Ssid (%s) "
2928 "Bssid (" MAC_ADDRESS_STR ") "
2929 "Channel (%u) "
2930 "Rssi (%d) "
2931 "RTT (%u) "
2932 "RTT_SD (%u) ",
2933 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302934 pData->bssHotlist[i].ts,
2935 pData->bssHotlist[i].ssid,
2936 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2937 pData->bssHotlist[i].channel,
2938 pData->bssHotlist[i].rssi,
2939 pData->bssHotlist[i].rtt,
2940 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302941 }
2942
2943 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2944 pData->requestId) ||
2945 nla_put_u32(skb,
2946 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302947 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302948 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2949 goto fail;
2950 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302951 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302952 struct nlattr *aps;
2953
2954 aps = nla_nest_start(skb,
2955 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2956 if (!aps)
2957 goto fail;
2958
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302959 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302960 struct nlattr *ap;
2961
2962 ap = nla_nest_start(skb, i + 1);
2963 if (!ap)
2964 goto fail;
2965
2966 if (nla_put_u64(skb,
2967 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302968 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 nla_put(skb,
2970 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302971 sizeof(pData->bssHotlist[i].ssid),
2972 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302973 nla_put(skb,
2974 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302975 sizeof(pData->bssHotlist[i].bssid),
2976 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302977 nla_put_u32(skb,
2978 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302979 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302980 nla_put_s32(skb,
2981 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302982 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302983 nla_put_u32(skb,
2984 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302985 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302986 nla_put_u32(skb,
2987 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302988 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302989 goto fail;
2990
2991 nla_nest_end(skb, ap);
2992 }
2993 nla_nest_end(skb, aps);
2994
2995 if (nla_put_u8(skb,
2996 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2997 pData->moreData))
2998 goto fail;
2999 }
3000
3001 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303002 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303003 return;
3004
3005fail:
3006 kfree_skb(skb);
3007 return;
3008
3009}
Dino Mycle6fb96c12014-06-10 11:52:40 +05303010
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303011/**
3012 * wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind() -
3013 * Handle an SSID hotlist match event
3014 * @ctx: HDD context registered with SME
3015 * @event: The SSID hotlist match event
3016 *
3017 * This function will take an SSID match event that was generated by
3018 * firmware and will convert it into a cfg80211 vendor event which is
3019 * sent to userspace.
3020 *
3021 * Return: none
3022 */
3023static void
3024wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(void *ctx,
3025 void *pMsg)
3026{
3027 hdd_context_t *hdd_ctx = ctx;
3028 struct sk_buff *skb;
3029 tANI_U32 i, index;
3030 tpSirEXTScanSsidHotlistMatch pData = (tpSirEXTScanSsidHotlistMatch) pMsg;
3031
3032 ENTER();
3033
3034 if (wlan_hdd_validate_context(hdd_ctx)) {
3035 hddLog(LOGE,
3036 FL("HDD context is not valid or response"));
3037 return;
3038 }
3039 if (!pMsg)
3040 {
3041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3042 return;
3043 }
3044
3045 if (pData->ssid_found) {
3046 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX;
3047 hddLog(LOG1, "SSID hotlist found");
3048 } else {
3049 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX;
3050 hddLog(LOG1, "SSID hotlist lost");
3051 }
3052
3053 skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
3054#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3055 NULL,
3056#endif
3057 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3058 index, GFP_KERNEL);
3059
3060 if (!skb) {
3061 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
3062 return;
3063 }
3064 hddLog(LOG1, "Req Id %u, Num of SSIDs %u, More Data (%u)",
3065 pData->requestId, pData->numHotlistSsid, pData->moreData);
3066
3067 for (i = 0; i < pData->numHotlistSsid; i++) {
3068 hddLog(LOG1, "[i=%d] Timestamp %llu "
3069 "Ssid: %s "
3070 "Bssid (" MAC_ADDRESS_STR ") "
3071 "Channel %u "
3072 "Rssi %d "
3073 "RTT %u "
3074 "RTT_SD %u",
3075 i,
3076 pData->ssidHotlist[i].ts,
3077 pData->ssidHotlist[i].ssid,
3078 MAC_ADDR_ARRAY(pData->ssidHotlist[i].bssid),
3079 pData->ssidHotlist[i].channel,
3080 pData->ssidHotlist[i].rssi,
3081 pData->ssidHotlist[i].rtt,
3082 pData->ssidHotlist[i].rtt_sd);
3083 }
3084
3085 if (nla_put_u32(skb,
3086 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3087 pData->requestId) ||
3088 nla_put_u32(skb,
3089 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3090 pData->numHotlistSsid)) {
3091 hddLog(LOGE, FL("put fail"));
3092 goto fail;
3093 }
3094
3095 if (pData->numHotlistSsid) {
3096 struct nlattr *aps;
3097 aps = nla_nest_start(skb,
3098 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3099 if (!aps) {
3100 hddLog(LOGE, FL("nest fail"));
3101 goto fail;
3102 }
3103
3104 for (i = 0; i < pData->numHotlistSsid; i++) {
3105 struct nlattr *ap;
3106
3107 ap = nla_nest_start(skb, i);
3108 if (!ap) {
3109 hddLog(LOGE, FL("nest fail"));
3110 goto fail;
3111 }
3112
3113 if (nla_put_u64(skb,
3114 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3115 pData->ssidHotlist[i].ts) ||
3116 nla_put(skb,
3117 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3118 sizeof(pData->ssidHotlist[i].ssid),
3119 pData->ssidHotlist[i].ssid) ||
3120 nla_put(skb,
3121 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3122 sizeof(pData->ssidHotlist[i].bssid),
3123 pData->ssidHotlist[i].bssid) ||
3124 nla_put_u32(skb,
3125 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3126 pData->ssidHotlist[i].channel) ||
3127 nla_put_s32(skb,
3128 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3129 pData->ssidHotlist[i].rssi) ||
3130 nla_put_u32(skb,
3131 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3132 pData->ssidHotlist[i].rtt) ||
3133 nla_put_u32(skb,
3134 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3135 pData->ssidHotlist[i].rtt_sd)) {
3136 hddLog(LOGE, FL("put fail"));
3137 goto fail;
3138 }
3139 nla_nest_end(skb, ap);
3140 }
3141 nla_nest_end(skb, aps);
3142
3143 if (nla_put_u8(skb,
3144 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3145 pData->moreData)) {
3146 hddLog(LOGE, FL("put fail"));
3147 goto fail;
3148 }
3149 }
3150
3151 cfg80211_vendor_event(skb, GFP_KERNEL);
3152 return;
3153
3154fail:
3155 kfree_skb(skb);
3156 return;
3157
3158}
3159
3160
Dino Mycle6fb96c12014-06-10 11:52:40 +05303161static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3162 void *pMsg)
3163{
3164 struct sk_buff *skb;
3165 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3166 tpSirWifiFullScanResultEvent pData =
3167 (tpSirWifiFullScanResultEvent) (pMsg);
3168
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303169 ENTER();
3170
3171 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303172 hddLog(LOGE,
3173 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303174 return;
3175 }
3176 if (!pMsg)
3177 {
3178 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303179 return;
3180 }
3181
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303182 /*
3183 * If the full scan result including IE data exceeds NL 4K size
3184 * limitation, drop that beacon/probe rsp frame.
3185 */
3186 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
3187 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
3188 return;
3189 }
3190
Dino Mycle6fb96c12014-06-10 11:52:40 +05303191 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303192#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3193 NULL,
3194#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303195 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3196 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3197 GFP_KERNEL);
3198
3199 if (!skb) {
3200 hddLog(VOS_TRACE_LEVEL_ERROR,
3201 FL("cfg80211_vendor_event_alloc failed"));
3202 return;
3203 }
3204
Dino Mycle6fb96c12014-06-10 11:52:40 +05303205 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3206 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3207 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3208 "Ssid (%s)"
3209 "Bssid (" MAC_ADDRESS_STR ")"
3210 "Channel (%u)"
3211 "Rssi (%d)"
3212 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303213 "RTT_SD (%u)"
3214 "Bcn Period %d"
3215 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303216 pData->ap.ts,
3217 pData->ap.ssid,
3218 MAC_ADDR_ARRAY(pData->ap.bssid),
3219 pData->ap.channel,
3220 pData->ap.rssi,
3221 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303222 pData->ap.rtt_sd,
3223 pData->ap.beaconPeriod,
3224 pData->ap.capability);
3225
Dino Mycle6fb96c12014-06-10 11:52:40 +05303226 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3227 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3228 pData->requestId) ||
3229 nla_put_u64(skb,
3230 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3231 pData->ap.ts) ||
3232 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3233 sizeof(pData->ap.ssid),
3234 pData->ap.ssid) ||
3235 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3236 WNI_CFG_BSSID_LEN,
3237 pData->ap.bssid) ||
3238 nla_put_u32(skb,
3239 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3240 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303241 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303242 pData->ap.rssi) ||
3243 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3244 pData->ap.rtt) ||
3245 nla_put_u32(skb,
3246 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3247 pData->ap.rtt_sd) ||
3248 nla_put_u16(skb,
3249 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3250 pData->ap.beaconPeriod) ||
3251 nla_put_u16(skb,
3252 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3253 pData->ap.capability) ||
3254 nla_put_u32(skb,
3255 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303256 pData->ieLength) ||
3257 nla_put_u8(skb,
3258 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3259 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303260 {
3261 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3262 goto nla_put_failure;
3263 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303264
3265 if (pData->ieLength) {
3266 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3267 pData->ieLength,
3268 pData->ie))
3269 {
3270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3271 goto nla_put_failure;
3272 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303273 }
3274
3275 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303276 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303277 return;
3278
3279nla_put_failure:
3280 kfree_skb(skb);
3281 return;
3282}
3283
3284static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3285 void *pMsg)
3286{
3287 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3288 struct sk_buff *skb = NULL;
3289 tpSirEXTScanResultsAvailableIndParams pData =
3290 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3291
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303292 ENTER();
3293
3294 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303295 hddLog(LOGE,
3296 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303297 return;
3298 }
3299 if (!pMsg)
3300 {
3301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303302 return;
3303 }
3304
3305 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303306#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3307 NULL,
3308#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303309 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3310 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3311 GFP_KERNEL);
3312
3313 if (!skb) {
3314 hddLog(VOS_TRACE_LEVEL_ERROR,
3315 FL("cfg80211_vendor_event_alloc failed"));
3316 return;
3317 }
3318
Dino Mycle6fb96c12014-06-10 11:52:40 +05303319 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3320 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3321 pData->numResultsAvailable);
3322 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3323 pData->requestId) ||
3324 nla_put_u32(skb,
3325 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3326 pData->numResultsAvailable)) {
3327 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3328 goto nla_put_failure;
3329 }
3330
3331 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303332 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303333 return;
3334
3335nla_put_failure:
3336 kfree_skb(skb);
3337 return;
3338}
3339
3340static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3341{
3342 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3343 struct sk_buff *skb = NULL;
3344 tpSirEXTScanProgressIndParams pData =
3345 (tpSirEXTScanProgressIndParams) pMsg;
3346
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303347 ENTER();
3348
3349 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303350 hddLog(LOGE,
3351 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303352 return;
3353 }
3354 if (!pMsg)
3355 {
3356 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303357 return;
3358 }
3359
3360 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303361#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3362 NULL,
3363#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3365 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3366 GFP_KERNEL);
3367
3368 if (!skb) {
3369 hddLog(VOS_TRACE_LEVEL_ERROR,
3370 FL("cfg80211_vendor_event_alloc failed"));
3371 return;
3372 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303373 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303374 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3375 pData->extScanEventType);
3376 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3377 pData->status);
3378
3379 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3380 pData->extScanEventType) ||
3381 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303382 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3383 pData->requestId) ||
3384 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303385 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3386 pData->status)) {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3388 goto nla_put_failure;
3389 }
3390
3391 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303392 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303393 return;
3394
3395nla_put_failure:
3396 kfree_skb(skb);
3397 return;
3398}
3399
3400void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3401 void *pMsg)
3402{
3403 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303405 ENTER();
3406
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303408 return;
3409 }
3410
3411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3412
3413
3414 switch(evType) {
3415 case SIR_HAL_EXTSCAN_START_RSP:
3416 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3417 break;
3418
3419 case SIR_HAL_EXTSCAN_STOP_RSP:
3420 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3421 break;
3422 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3423 /* There is no need to send this response to upper layer
3424 Just log the message */
3425 hddLog(VOS_TRACE_LEVEL_INFO,
3426 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3427 break;
3428 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3429 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3430 break;
3431
3432 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3433 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3434 break;
3435
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303436 case SIR_HAL_EXTSCAN_SET_SSID_HOTLIST_RSP:
3437 wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(ctx, pMsg);
3438 break;
3439
3440 case SIR_HAL_EXTSCAN_RESET_SSID_HOTLIST_RSP:
3441 wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(ctx, pMsg);
3442 break;
3443
Dino Mycle6fb96c12014-06-10 11:52:40 +05303444 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303445 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303446 break;
3447 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3448 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3449 break;
3450 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3451 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3452 break;
3453 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3454 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3455 break;
3456 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3457 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3458 break;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303459 case SIR_HAL_EXTSCAN_SSID_HOTLIST_MATCH_IND:
3460 wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(ctx, pMsg);
3461 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303462 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3463 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3464 break;
3465 default:
3466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3467 break;
3468 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303469 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303470}
3471
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303472static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3473 struct wireless_dev *wdev,
3474 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475{
Dino Myclee8843b32014-07-04 14:21:45 +05303476 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477 struct net_device *dev = wdev->netdev;
3478 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3479 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3480 struct nlattr
3481 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3482 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303483 struct hdd_ext_scan_context *context;
3484 unsigned long rc;
3485 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303486
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303487 ENTER();
3488
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489 status = wlan_hdd_validate_context(pHddCtx);
3490 if (0 != status)
3491 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 return -EINVAL;
3493 }
Dino Myclee8843b32014-07-04 14:21:45 +05303494 /* check the EXTScan Capability */
3495 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303496 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3497 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303498 {
3499 hddLog(VOS_TRACE_LEVEL_ERROR,
3500 FL("EXTScan not enabled/supported by Firmware"));
3501 return -EINVAL;
3502 }
3503
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3505 data, dataLen,
3506 wlan_hdd_extscan_config_policy)) {
3507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3508 return -EINVAL;
3509 }
3510
3511 /* Parse and fetch request Id */
3512 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3513 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3514 return -EINVAL;
3515 }
3516
Dino Myclee8843b32014-07-04 14:21:45 +05303517 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303518 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303519 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303520
Dino Myclee8843b32014-07-04 14:21:45 +05303521 reqMsg.sessionId = pAdapter->sessionId;
3522 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303523
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303524 vos_spin_lock_acquire(&hdd_context_lock);
3525 context = &pHddCtx->ext_scan_context;
3526 context->request_id = reqMsg.requestId;
3527 INIT_COMPLETION(context->response_event);
3528 vos_spin_lock_release(&hdd_context_lock);
3529
Dino Myclee8843b32014-07-04 14:21:45 +05303530 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303531 if (!HAL_STATUS_SUCCESS(status)) {
3532 hddLog(VOS_TRACE_LEVEL_ERROR,
3533 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303534 return -EINVAL;
3535 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303536
3537 rc = wait_for_completion_timeout(&context->response_event,
3538 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3539 if (!rc) {
3540 hddLog(LOGE, FL("Target response timed out"));
3541 return -ETIMEDOUT;
3542 }
3543
3544 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3545 if (ret)
3546 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3547
3548 return ret;
3549
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303550 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303551 return 0;
3552}
3553
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303554static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3555 struct wireless_dev *wdev,
3556 const void *data, int dataLen)
3557{
3558 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303559
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303560 vos_ssr_protect(__func__);
3561 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3562 vos_ssr_unprotect(__func__);
3563
3564 return ret;
3565}
3566
3567static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3568 struct wireless_dev *wdev,
3569 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303570{
Dino Myclee8843b32014-07-04 14:21:45 +05303571 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303572 struct net_device *dev = wdev->netdev;
3573 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3574 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3575 struct nlattr
3576 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3577 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303578 struct hdd_ext_scan_context *context;
3579 unsigned long rc;
3580 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303581
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303582 ENTER();
3583
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303584 if (VOS_FTM_MODE == hdd_get_conparam()) {
3585 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3586 return -EINVAL;
3587 }
3588
Dino Mycle6fb96c12014-06-10 11:52:40 +05303589 status = wlan_hdd_validate_context(pHddCtx);
3590 if (0 != status)
3591 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592 return -EINVAL;
3593 }
Dino Myclee8843b32014-07-04 14:21:45 +05303594 /* check the EXTScan Capability */
3595 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303596 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3597 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303598 {
3599 hddLog(VOS_TRACE_LEVEL_ERROR,
3600 FL("EXTScan not enabled/supported by Firmware"));
3601 return -EINVAL;
3602 }
3603
Dino Mycle6fb96c12014-06-10 11:52:40 +05303604 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3605 data, dataLen,
3606 wlan_hdd_extscan_config_policy)) {
3607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3608 return -EINVAL;
3609 }
3610 /* Parse and fetch request Id */
3611 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3612 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3613 return -EINVAL;
3614 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303615
Dino Myclee8843b32014-07-04 14:21:45 +05303616 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303617 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3618
Dino Myclee8843b32014-07-04 14:21:45 +05303619 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303620
Dino Myclee8843b32014-07-04 14:21:45 +05303621 reqMsg.sessionId = pAdapter->sessionId;
3622 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303623
3624 /* Parse and fetch flush parameter */
3625 if (!tb
3626 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3627 {
3628 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3629 goto failed;
3630 }
Dino Myclee8843b32014-07-04 14:21:45 +05303631 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303632 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3633
Dino Myclee8843b32014-07-04 14:21:45 +05303634 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303635
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303636 spin_lock(&hdd_context_lock);
3637 context = &pHddCtx->ext_scan_context;
3638 context->request_id = reqMsg.requestId;
3639 context->ignore_cached_results = false;
3640 INIT_COMPLETION(context->response_event);
3641 spin_unlock(&hdd_context_lock);
3642
Dino Myclee8843b32014-07-04 14:21:45 +05303643 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303644 if (!HAL_STATUS_SUCCESS(status)) {
3645 hddLog(VOS_TRACE_LEVEL_ERROR,
3646 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303647 return -EINVAL;
3648 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303649
3650 rc = wait_for_completion_timeout(&context->response_event,
3651 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3652 if (!rc) {
3653 hddLog(LOGE, FL("Target response timed out"));
3654 retval = -ETIMEDOUT;
3655 spin_lock(&hdd_context_lock);
3656 context->ignore_cached_results = true;
3657 spin_unlock(&hdd_context_lock);
3658 } else {
3659 spin_lock(&hdd_context_lock);
3660 retval = context->response_status;
3661 spin_unlock(&hdd_context_lock);
3662 }
3663
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303664 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303665 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303666
3667failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303668 return -EINVAL;
3669}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303670static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3671 struct wireless_dev *wdev,
3672 const void *data, int dataLen)
3673{
3674 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303675
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303676 vos_ssr_protect(__func__);
3677 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3678 vos_ssr_unprotect(__func__);
3679
3680 return ret;
3681}
3682
3683static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303684 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303685 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303686{
3687 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3688 struct net_device *dev = wdev->netdev;
3689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3690 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3691 struct nlattr
3692 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3693 struct nlattr
3694 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3695 struct nlattr *apTh;
3696 eHalStatus status;
3697 tANI_U8 i = 0;
3698 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303699 struct hdd_ext_scan_context *context;
3700 tANI_U32 request_id;
3701 unsigned long rc;
3702 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303703
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303704 ENTER();
3705
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303706 if (VOS_FTM_MODE == hdd_get_conparam()) {
3707 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3708 return -EINVAL;
3709 }
3710
Dino Mycle6fb96c12014-06-10 11:52:40 +05303711 status = wlan_hdd_validate_context(pHddCtx);
3712 if (0 != status)
3713 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303714 return -EINVAL;
3715 }
Dino Myclee8843b32014-07-04 14:21:45 +05303716 /* check the EXTScan Capability */
3717 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303718 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3719 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303720 {
3721 hddLog(VOS_TRACE_LEVEL_ERROR,
3722 FL("EXTScan not enabled/supported by Firmware"));
3723 return -EINVAL;
3724 }
3725
Dino Mycle6fb96c12014-06-10 11:52:40 +05303726 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3727 data, dataLen,
3728 wlan_hdd_extscan_config_policy)) {
3729 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3730 return -EINVAL;
3731 }
3732
3733 /* Parse and fetch request Id */
3734 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3735 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3736 return -EINVAL;
3737 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303738 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3739 vos_mem_malloc(sizeof(*pReqMsg));
3740 if (!pReqMsg) {
3741 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3742 return -ENOMEM;
3743 }
3744
Dino Myclee8843b32014-07-04 14:21:45 +05303745
Dino Mycle6fb96c12014-06-10 11:52:40 +05303746 pReqMsg->requestId = nla_get_u32(
3747 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3748 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3749
3750 /* Parse and fetch number of APs */
3751 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3752 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3753 goto fail;
3754 }
3755
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303756 /* Parse and fetch lost ap sample size */
3757 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3758 hddLog(LOGE, FL("attr lost ap sample size failed"));
3759 goto fail;
3760 }
3761
3762 pReqMsg->lostBssidSampleSize = nla_get_u32(
3763 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3764 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3765
Dino Mycle6fb96c12014-06-10 11:52:40 +05303766 pReqMsg->sessionId = pAdapter->sessionId;
3767 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3768
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303769 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303770 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303771 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303772
3773 nla_for_each_nested(apTh,
3774 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3775 if(nla_parse(tb2, 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 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3791
3792 /* Parse and fetch low RSSI */
3793 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3795 goto fail;
3796 }
3797 pReqMsg->ap[i].low = nla_get_s32(
3798 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3799 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3800
3801 /* Parse and fetch high RSSI */
3802 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3804 goto fail;
3805 }
3806 pReqMsg->ap[i].high = nla_get_s32(
3807 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3808 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3809 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303810 i++;
3811 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303812
3813 context = &pHddCtx->ext_scan_context;
3814 spin_lock(&hdd_context_lock);
3815 INIT_COMPLETION(context->response_event);
3816 context->request_id = request_id = pReqMsg->requestId;
3817 spin_unlock(&hdd_context_lock);
3818
Dino Mycle6fb96c12014-06-10 11:52:40 +05303819 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3820 if (!HAL_STATUS_SUCCESS(status)) {
3821 hddLog(VOS_TRACE_LEVEL_ERROR,
3822 FL("sme_SetBssHotlist failed(err=%d)"), status);
3823 vos_mem_free(pReqMsg);
3824 return -EINVAL;
3825 }
3826
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303827 /* request was sent -- wait for the response */
3828 rc = wait_for_completion_timeout(&context->response_event,
3829 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3830
3831 if (!rc) {
3832 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3833 retval = -ETIMEDOUT;
3834 } else {
3835 spin_lock(&hdd_context_lock);
3836 if (context->request_id == request_id)
3837 retval = context->response_status;
3838 else
3839 retval = -EINVAL;
3840 spin_unlock(&hdd_context_lock);
3841 }
3842
Dino Myclee8843b32014-07-04 14:21:45 +05303843 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303844 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303845 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303846
3847fail:
3848 vos_mem_free(pReqMsg);
3849 return -EINVAL;
3850}
3851
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303852static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3853 struct wireless_dev *wdev,
3854 const void *data, int dataLen)
3855{
3856 int ret = 0;
3857
3858 vos_ssr_protect(__func__);
3859 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3860 dataLen);
3861 vos_ssr_unprotect(__func__);
3862
3863 return ret;
3864}
3865
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303866/*
3867 * define short names for the global vendor params
3868 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3869 */
3870#define PARAM_MAX \
3871QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3872#define PARAM_REQUEST_ID \
3873QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3874#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3875QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3876#define PARAMS_NUM_SSID \
3877QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3878#define THRESHOLD_PARAM \
3879QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3880#define PARAM_SSID \
3881QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3882#define PARAM_BAND \
3883QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3884#define PARAM_RSSI_LOW \
3885QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3886#define PARAM_RSSI_HIGH \
3887QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3888
3889/**
3890 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3891 * @wiphy: Pointer to wireless phy
3892 * @wdev: Pointer to wireless device
3893 * @data: Pointer to data
3894 * @data_len: Data length
3895 *
3896 * Return: 0 on success, negative errno on failure
3897 */
3898static int
3899__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3900 struct wireless_dev *wdev,
3901 const void *data,
3902 int data_len)
3903{
3904 tSirEXTScanSetSsidHotListReqParams *request;
3905 struct net_device *dev = wdev->netdev;
3906 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3907 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3908 struct nlattr *tb[PARAM_MAX + 1];
3909 struct nlattr *tb2[PARAM_MAX + 1];
3910 struct nlattr *ssids;
3911 struct hdd_ext_scan_context *context;
3912 uint32_t request_id;
3913 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3914 int ssid_len;
Anurag Chouhand64d5232016-08-29 17:01:38 +05303915 int ssid_length;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303916 eHalStatus status;
3917 int i, rem, retval;
3918 unsigned long rc;
3919
3920 ENTER();
3921
3922 if (VOS_FTM_MODE == hdd_get_conparam()) {
3923 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3924 return -EINVAL;
3925 }
3926
3927 retval = wlan_hdd_validate_context(hdd_ctx);
3928 if (0 != retval) {
3929 hddLog(LOGE, FL("HDD context is not valid"));
3930 return -EINVAL;
3931 }
3932
3933 /* check the EXTScan Capability */
3934 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303935 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3936 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303937 {
3938 hddLog(VOS_TRACE_LEVEL_ERROR,
3939 FL("EXTScan not enabled/supported by Firmware"));
3940 return -EINVAL;
3941 }
3942
3943 if (nla_parse(tb, PARAM_MAX,
3944 data, data_len,
3945 wlan_hdd_extscan_config_policy)) {
3946 hddLog(LOGE, FL("Invalid ATTR"));
3947 return -EINVAL;
3948 }
3949
3950 request = vos_mem_malloc(sizeof(*request));
3951 if (!request) {
3952 hddLog(LOGE, FL("vos_mem_malloc failed"));
3953 return -ENOMEM;
3954 }
3955
3956 /* Parse and fetch request Id */
3957 if (!tb[PARAM_REQUEST_ID]) {
3958 hddLog(LOGE, FL("attr request id failed"));
3959 goto fail;
3960 }
3961
3962 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3963 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3964
3965 /* Parse and fetch lost SSID sample size */
3966 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3967 hddLog(LOGE, FL("attr number of Ssid failed"));
3968 goto fail;
3969 }
3970 request->lost_ssid_sample_size =
3971 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3972 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3973 request->lost_ssid_sample_size);
3974
3975 /* Parse and fetch number of hotlist SSID */
3976 if (!tb[PARAMS_NUM_SSID]) {
3977 hddLog(LOGE, FL("attr number of Ssid failed"));
3978 goto fail;
3979 }
3980 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3981 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3982
3983 request->session_id = adapter->sessionId;
3984 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
3985
3986 i = 0;
3987 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
3988 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
3989 hddLog(LOGE,
3990 FL("Too Many SSIDs, %d exceeds %d"),
3991 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
3992 break;
3993 }
3994 if (nla_parse(tb2, PARAM_MAX,
3995 nla_data(ssids), nla_len(ssids),
3996 wlan_hdd_extscan_config_policy)) {
3997 hddLog(LOGE, FL("nla_parse failed"));
3998 goto fail;
3999 }
4000
4001 /* Parse and fetch SSID */
4002 if (!tb2[PARAM_SSID]) {
4003 hddLog(LOGE, FL("attr ssid failed"));
4004 goto fail;
4005 }
Anurag Chouhand64d5232016-08-29 17:01:38 +05304006 ssid_length = nla_strlcpy(ssid_string, tb2[PARAM_SSID],
4007 sizeof(ssid_string));
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304008 hddLog(LOG1, FL("SSID %s"),
4009 ssid_string);
4010 ssid_len = strlen(ssid_string);
Anurag Chouhand64d5232016-08-29 17:01:38 +05304011 if (ssid_length > SIR_MAC_MAX_SSID_LENGTH) {
4012 hddLog(LOGE, FL("Invalid ssid length"));
4013 goto fail;
4014 }
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304015 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
4016 request->ssid[i].ssid.length = ssid_len;
4017 request->ssid[i].ssid.ssId[ssid_len] = '\0';
4018 hddLog(LOG1, FL("After copying SSID %s"),
4019 request->ssid[i].ssid.ssId);
4020 hddLog(LOG1, FL("After copying length: %d"),
4021 ssid_len);
4022
4023 /* Parse and fetch low RSSI */
4024 if (!tb2[PARAM_BAND]) {
4025 hddLog(LOGE, FL("attr band failed"));
4026 goto fail;
4027 }
4028 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
4029 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
4030
4031 /* Parse and fetch low RSSI */
4032 if (!tb2[PARAM_RSSI_LOW]) {
4033 hddLog(LOGE, FL("attr low RSSI failed"));
4034 goto fail;
4035 }
4036 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
4037 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
4038
4039 /* Parse and fetch high RSSI */
4040 if (!tb2[PARAM_RSSI_HIGH]) {
4041 hddLog(LOGE, FL("attr high RSSI failed"));
4042 goto fail;
4043 }
4044 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4045 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4046 i++;
4047 }
4048
4049 context = &hdd_ctx->ext_scan_context;
4050 spin_lock(&hdd_context_lock);
4051 INIT_COMPLETION(context->response_event);
4052 context->request_id = request_id = request->request_id;
4053 spin_unlock(&hdd_context_lock);
4054
4055 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4056 if (!HAL_STATUS_SUCCESS(status)) {
4057 hddLog(LOGE,
4058 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4059 goto fail;
4060 }
4061
4062 vos_mem_free(request);
4063
4064 /* request was sent -- wait for the response */
4065 rc = wait_for_completion_timeout(&context->response_event,
4066 msecs_to_jiffies
4067 (WLAN_WAIT_TIME_EXTSCAN));
4068 if (!rc) {
4069 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4070 retval = -ETIMEDOUT;
4071 } else {
4072 spin_lock(&hdd_context_lock);
4073 if (context->request_id == request_id)
4074 retval = context->response_status;
4075 else
4076 retval = -EINVAL;
4077 spin_unlock(&hdd_context_lock);
4078 }
4079
4080 return retval;
4081
4082fail:
4083 vos_mem_free(request);
4084 return -EINVAL;
4085}
4086
4087/*
4088 * done with short names for the global vendor params
4089 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4090 */
4091#undef PARAM_MAX
4092#undef PARAM_REQUEST_ID
4093#undef PARAMS_NUM_SSID
4094#undef THRESHOLD_PARAM
4095#undef PARAM_SSID
4096#undef PARAM_BAND
4097#undef PARAM_RSSI_LOW
4098#undef PARAM_RSSI_HIGH
4099
4100static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4101 struct wireless_dev *wdev,
4102 const void *data, int dataLen)
4103{
4104 int ret = 0;
4105
4106 vos_ssr_protect(__func__);
4107 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4108 dataLen);
4109 vos_ssr_unprotect(__func__);
4110
4111 return ret;
4112}
4113
4114static int
4115__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4116 struct wireless_dev *wdev,
4117 const void *data,
4118 int data_len)
4119{
4120 tSirEXTScanResetSsidHotlistReqParams request;
4121 struct net_device *dev = wdev->netdev;
4122 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4123 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4124 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4125 struct hdd_ext_scan_context *context;
4126 uint32_t request_id;
4127 eHalStatus status;
4128 int retval;
4129 unsigned long rc;
4130
4131 ENTER();
4132
4133 if (VOS_FTM_MODE == hdd_get_conparam()) {
4134 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4135 return -EINVAL;
4136 }
4137
4138 retval = wlan_hdd_validate_context(hdd_ctx);
4139 if (0 != retval) {
4140 hddLog(LOGE, FL("HDD context is not valid"));
4141 return -EINVAL;
4142 }
4143
4144 /* check the EXTScan Capability */
4145 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304146 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4147 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304148 {
4149 hddLog(LOGE,
4150 FL("EXTScan not enabled/supported by Firmware"));
4151 return -EINVAL;
4152 }
4153
4154 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4155 data, data_len,
4156 wlan_hdd_extscan_config_policy)) {
4157 hddLog(LOGE, FL("Invalid ATTR"));
4158 return -EINVAL;
4159 }
4160
4161 /* Parse and fetch request Id */
4162 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4163 hddLog(LOGE, FL("attr request id failed"));
4164 return -EINVAL;
4165 }
4166
4167 request.requestId = nla_get_u32(
4168 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4169 request.sessionId = adapter->sessionId;
4170 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4171 request.sessionId);
4172
4173 context = &hdd_ctx->ext_scan_context;
4174 spin_lock(&hdd_context_lock);
4175 INIT_COMPLETION(context->response_event);
4176 context->request_id = request_id = request.requestId;
4177 spin_unlock(&hdd_context_lock);
4178
4179 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4180 if (!HAL_STATUS_SUCCESS(status)) {
4181 hddLog(LOGE,
4182 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4183 return -EINVAL;
4184 }
4185
4186 /* request was sent -- wait for the response */
4187 rc = wait_for_completion_timeout(&context->response_event,
4188 msecs_to_jiffies
4189 (WLAN_WAIT_TIME_EXTSCAN));
4190 if (!rc) {
4191 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4192 retval = -ETIMEDOUT;
4193 } else {
4194 spin_lock(&hdd_context_lock);
4195 if (context->request_id == request_id)
4196 retval = context->response_status;
4197 else
4198 retval = -EINVAL;
4199 spin_unlock(&hdd_context_lock);
4200 }
4201
4202 return retval;
4203}
4204
4205static int
4206wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4207 struct wireless_dev *wdev,
4208 const void *data,
4209 int data_len)
4210{
4211 int ret;
4212
4213 vos_ssr_protect(__func__);
4214 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4215 data, data_len);
4216 vos_ssr_unprotect(__func__);
4217
4218 return ret;
4219}
4220
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304221static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304222 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304223 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304224{
Agrawal Ashish16abf782016-08-18 22:42:59 +05304225 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4226 struct net_device *dev = wdev->netdev;
4227 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4228 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4229 uint8_t num_channels = 0;
4230 uint8_t num_chan_new = 0;
4231 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05304232 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304233 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304234 tWifiBand wifiBand;
4235 eHalStatus status;
4236 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05304237 tANI_U8 i,j,k;
4238 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304240 ENTER();
4241
Dino Mycle6fb96c12014-06-10 11:52:40 +05304242 status = wlan_hdd_validate_context(pHddCtx);
4243 if (0 != status)
4244 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304245 return -EINVAL;
4246 }
Dino Myclee8843b32014-07-04 14:21:45 +05304247
Dino Mycle6fb96c12014-06-10 11:52:40 +05304248 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4249 data, dataLen,
4250 wlan_hdd_extscan_config_policy)) {
4251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4252 return -EINVAL;
4253 }
4254
4255 /* Parse and fetch request Id */
4256 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4258 return -EINVAL;
4259 }
4260 requestId = nla_get_u32(
4261 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4262 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4263
4264 /* Parse and fetch wifi band */
4265 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4266 {
4267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4268 return -EINVAL;
4269 }
4270 wifiBand = nla_get_u32(
4271 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4272 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4273
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304274 /* Parse and fetch max channels */
4275 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4276 {
4277 hddLog(LOGE, FL("attr max channels failed"));
4278 return -EINVAL;
4279 }
4280 maxChannels = nla_get_u32(
4281 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4282 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4283
Dino Mycle6fb96c12014-06-10 11:52:40 +05304284 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05304285 wifiBand, chan_list,
4286 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287 if (eHAL_STATUS_SUCCESS != status) {
4288 hddLog(VOS_TRACE_LEVEL_ERROR,
4289 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4290 return -EINVAL;
4291 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304292
Agrawal Ashish16abf782016-08-18 22:42:59 +05304293 num_channels = VOS_MIN(num_channels, maxChannels);
4294 num_chan_new = num_channels;
4295 /* remove the indoor only channels if iface is SAP */
4296 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
4297 {
4298 num_chan_new = 0;
4299 for (i = 0; i < num_channels; i++)
4300 for (j = 0; j < IEEE80211_NUM_BANDS; j++) {
4301 if (wiphy->bands[j] == NULL)
4302 continue;
4303 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
4304 if ((chan_list[i] ==
4305 wiphy->bands[j]->channels[k].center_freq) &&
4306 (!(wiphy->bands[j]->channels[k].flags &
4307 IEEE80211_CHAN_INDOOR_ONLY))) {
4308 chan_list[num_chan_new] = chan_list[i];
4309 num_chan_new++;
4310 }
4311 }
4312 }
4313 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304314
Agrawal Ashish16abf782016-08-18 22:42:59 +05304315 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
4316 for (i = 0; i < num_chan_new; i++)
4317 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
4318 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304319
4320 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05304321 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05304322 NLMSG_HDRLEN);
4323
4324 if (!replySkb) {
4325 hddLog(VOS_TRACE_LEVEL_ERROR,
4326 FL("valid channels: buffer alloc fail"));
4327 return -EINVAL;
4328 }
4329 if (nla_put_u32(replySkb,
4330 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304331 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304332 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304333 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304334
4335 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4336 kfree_skb(replySkb);
4337 return -EINVAL;
4338 }
4339
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304340 ret = cfg80211_vendor_cmd_reply(replySkb);
4341
4342 EXIT();
4343 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304344}
4345
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304346static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4347 struct wireless_dev *wdev,
4348 const void *data, int dataLen)
4349{
4350 int ret = 0;
4351
4352 vos_ssr_protect(__func__);
4353 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4354 dataLen);
4355 vos_ssr_unprotect(__func__);
4356
4357 return ret;
4358}
4359
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304360static int hdd_extscan_start_fill_bucket_channel_spec(
4361 hdd_context_t *pHddCtx,
4362 tpSirEXTScanStartReqParams pReqMsg,
4363 struct nlattr **tb)
4364{
4365 struct nlattr *bucket[
4366 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4367 struct nlattr *channel[
4368 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4369 struct nlattr *buckets;
4370 struct nlattr *channels;
4371 int rem1, rem2;
4372 eHalStatus status;
4373 tANI_U8 bktIndex, j, numChannels;
4374 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4375 tANI_U32 passive_max_chn_time, active_max_chn_time;
4376
4377 bktIndex = 0;
4378
4379 nla_for_each_nested(buckets,
4380 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4381 if (nla_parse(bucket,
4382 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4383 nla_data(buckets), nla_len(buckets), NULL)) {
4384 hddLog(LOGE, FL("nla_parse failed"));
4385 return -EINVAL;
4386 }
4387
4388 /* Parse and fetch bucket spec */
4389 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4390 hddLog(LOGE, FL("attr bucket index failed"));
4391 return -EINVAL;
4392 }
4393 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4394 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4395 hddLog(LOG1, FL("Bucket spec Index %d"),
4396 pReqMsg->buckets[bktIndex].bucket);
4397
4398 /* Parse and fetch wifi band */
4399 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4400 hddLog(LOGE, FL("attr wifi band failed"));
4401 return -EINVAL;
4402 }
4403 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4404 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4405 hddLog(LOG1, FL("Wifi band %d"),
4406 pReqMsg->buckets[bktIndex].band);
4407
4408 /* Parse and fetch period */
4409 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4410 hddLog(LOGE, FL("attr period failed"));
4411 return -EINVAL;
4412 }
4413 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4414 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4415 hddLog(LOG1, FL("period %d"),
4416 pReqMsg->buckets[bktIndex].period);
4417
4418 /* Parse and fetch report events */
4419 if (!bucket[
4420 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4421 hddLog(LOGE, FL("attr report events failed"));
4422 return -EINVAL;
4423 }
4424 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4425 bucket[
4426 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4427 hddLog(LOG1, FL("report events %d"),
4428 pReqMsg->buckets[bktIndex].reportEvents);
4429
4430 /* Parse and fetch max period */
4431 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4432 hddLog(LOGE, FL("attr max period failed"));
4433 return -EINVAL;
4434 }
4435 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4436 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4437 hddLog(LOG1, FL("max period %u"),
4438 pReqMsg->buckets[bktIndex].max_period);
4439
4440 /* Parse and fetch exponent */
4441 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4442 hddLog(LOGE, FL("attr exponent failed"));
4443 return -EINVAL;
4444 }
4445 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4446 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4447 hddLog(LOG1, FL("exponent %u"),
4448 pReqMsg->buckets[bktIndex].exponent);
4449
4450 /* Parse and fetch step count */
4451 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4452 hddLog(LOGE, FL("attr step count failed"));
4453 return -EINVAL;
4454 }
4455 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4456 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4457 hddLog(LOG1, FL("Step count %u"),
4458 pReqMsg->buckets[bktIndex].step_count);
4459
4460 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4461 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4462
4463 /* Framework shall pass the channel list if the input WiFi band is
4464 * WIFI_BAND_UNSPECIFIED.
4465 * If the input WiFi band is specified (any value other than
4466 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4467 */
4468 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4469 numChannels = 0;
4470 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4471 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4472 pReqMsg->buckets[bktIndex].band,
4473 chanList, &numChannels);
4474 if (!HAL_STATUS_SUCCESS(status)) {
4475 hddLog(LOGE,
4476 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4477 status);
4478 return -EINVAL;
4479 }
4480
4481 pReqMsg->buckets[bktIndex].numChannels =
4482 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4483 hddLog(LOG1, FL("Num channels %d"),
4484 pReqMsg->buckets[bktIndex].numChannels);
4485
4486 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4487 j++) {
4488 pReqMsg->buckets[bktIndex].channels[j].channel =
4489 chanList[j];
4490 pReqMsg->buckets[bktIndex].channels[j].
4491 chnlClass = 0;
4492 if (CSR_IS_CHANNEL_DFS(
4493 vos_freq_to_chan(chanList[j]))) {
4494 pReqMsg->buckets[bktIndex].channels[j].
4495 passive = 1;
4496 pReqMsg->buckets[bktIndex].channels[j].
4497 dwellTimeMs = passive_max_chn_time;
4498 } else {
4499 pReqMsg->buckets[bktIndex].channels[j].
4500 passive = 0;
4501 pReqMsg->buckets[bktIndex].channels[j].
4502 dwellTimeMs = active_max_chn_time;
4503 }
4504
4505 hddLog(LOG1,
4506 "Channel %u Passive %u Dwell time %u ms",
4507 pReqMsg->buckets[bktIndex].channels[j].channel,
4508 pReqMsg->buckets[bktIndex].channels[j].passive,
4509 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4510 }
4511
4512 bktIndex++;
4513 continue;
4514 }
4515
4516 /* Parse and fetch number of channels */
4517 if (!bucket[
4518 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4519 hddLog(LOGE, FL("attr num channels failed"));
4520 return -EINVAL;
4521 }
4522
4523 pReqMsg->buckets[bktIndex].numChannels =
4524 nla_get_u32(bucket[
4525 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4526 hddLog(LOG1, FL("num channels %d"),
4527 pReqMsg->buckets[bktIndex].numChannels);
4528
4529 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4530 hddLog(LOGE, FL("attr channel spec failed"));
4531 return -EINVAL;
4532 }
4533
4534 j = 0;
4535 nla_for_each_nested(channels,
4536 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4537 if (nla_parse(channel,
4538 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4539 nla_data(channels), nla_len(channels),
4540 wlan_hdd_extscan_config_policy)) {
4541 hddLog(LOGE, FL("nla_parse failed"));
4542 return -EINVAL;
4543 }
4544
4545 /* Parse and fetch channel */
4546 if (!channel[
4547 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4548 hddLog(LOGE, FL("attr channel failed"));
4549 return -EINVAL;
4550 }
4551 pReqMsg->buckets[bktIndex].channels[j].channel =
4552 nla_get_u32(channel[
4553 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4554 hddLog(LOG1, FL("channel %u"),
4555 pReqMsg->buckets[bktIndex].channels[j].channel);
4556
4557 /* Parse and fetch dwell time */
4558 if (!channel[
4559 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4560 hddLog(LOGE, FL("attr dwelltime failed"));
4561 return -EINVAL;
4562 }
4563 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4564 nla_get_u32(channel[
4565 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4566
4567 hddLog(LOG1, FL("Dwell time (%u ms)"),
4568 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4569
4570
4571 /* Parse and fetch channel spec passive */
4572 if (!channel[
4573 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4574 hddLog(LOGE,
4575 FL("attr channel spec passive failed"));
4576 return -EINVAL;
4577 }
4578 pReqMsg->buckets[bktIndex].channels[j].passive =
4579 nla_get_u8(channel[
4580 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4581 hddLog(LOG1, FL("Chnl spec passive %u"),
4582 pReqMsg->buckets[bktIndex].channels[j].passive);
4583
4584 j++;
4585 }
4586
4587 bktIndex++;
4588 }
4589
4590 return 0;
4591}
4592
4593
4594/*
4595 * define short names for the global vendor params
4596 * used by wlan_hdd_cfg80211_extscan_start()
4597 */
4598#define PARAM_MAX \
4599QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4600#define PARAM_REQUEST_ID \
4601QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4602#define PARAM_BASE_PERIOD \
4603QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4604#define PARAM_MAX_AP_PER_SCAN \
4605QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4606#define PARAM_RPT_THRHLD_PERCENT \
4607QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4608#define PARAM_RPT_THRHLD_NUM_SCANS \
4609QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4610#define PARAM_NUM_BUCKETS \
4611QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4612
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304613static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304614 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304615 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304616{
Dino Myclee8843b32014-07-04 14:21:45 +05304617 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304618 struct net_device *dev = wdev->netdev;
4619 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4620 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4621 struct nlattr *tb[PARAM_MAX + 1];
4622 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304623 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304624 tANI_U32 request_id;
4625 struct hdd_ext_scan_context *context;
4626 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304628 ENTER();
4629
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304630 if (VOS_FTM_MODE == hdd_get_conparam()) {
4631 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4632 return -EINVAL;
4633 }
4634
Dino Mycle6fb96c12014-06-10 11:52:40 +05304635 status = wlan_hdd_validate_context(pHddCtx);
4636 if (0 != status)
4637 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304638 return -EINVAL;
4639 }
Dino Myclee8843b32014-07-04 14:21:45 +05304640 /* check the EXTScan Capability */
4641 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304642 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4643 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304644 {
4645 hddLog(VOS_TRACE_LEVEL_ERROR,
4646 FL("EXTScan not enabled/supported by Firmware"));
4647 return -EINVAL;
4648 }
4649
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304650 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304651 data, dataLen,
4652 wlan_hdd_extscan_config_policy)) {
4653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4654 return -EINVAL;
4655 }
4656
4657 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304658 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4660 return -EINVAL;
4661 }
4662
Dino Myclee8843b32014-07-04 14:21:45 +05304663 pReqMsg = (tpSirEXTScanStartReqParams)
4664 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304665 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4667 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304668 }
4669
4670 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304671 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304672 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4673
4674 pReqMsg->sessionId = pAdapter->sessionId;
4675 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4676
4677 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304678 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304679 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4680 goto fail;
4681 }
4682 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304683 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304684 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4685 pReqMsg->basePeriod);
4686
4687 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304688 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304689 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4690 goto fail;
4691 }
4692 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304693 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304694 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4695 pReqMsg->maxAPperScan);
4696
4697 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304698 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4700 goto fail;
4701 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304702 pReqMsg->reportThresholdPercent = nla_get_u8(
4703 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304704 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304705 pReqMsg->reportThresholdPercent);
4706
4707 /* Parse and fetch report threshold num scans */
4708 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4709 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4710 goto fail;
4711 }
4712 pReqMsg->reportThresholdNumScans = nla_get_u8(
4713 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4714 hddLog(LOG1, FL("Report Threshold num scans %d"),
4715 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304716
4717 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304718 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4720 goto fail;
4721 }
4722 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304723 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304724 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4725 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4726 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4727 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4728 }
4729 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4730 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304731
Dino Mycle6fb96c12014-06-10 11:52:40 +05304732 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4733 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4734 goto fail;
4735 }
4736
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304737 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304738
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304739 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4740 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304741
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304742 context = &pHddCtx->ext_scan_context;
4743 spin_lock(&hdd_context_lock);
4744 INIT_COMPLETION(context->response_event);
4745 context->request_id = request_id = pReqMsg->requestId;
4746 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304747
Dino Mycle6fb96c12014-06-10 11:52:40 +05304748 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4749 if (!HAL_STATUS_SUCCESS(status)) {
4750 hddLog(VOS_TRACE_LEVEL_ERROR,
4751 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304752 goto fail;
4753 }
4754
Srinivas Dasari91727c12016-03-23 17:59:06 +05304755 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
4756
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304757 /* request was sent -- wait for the response */
4758 rc = wait_for_completion_timeout(&context->response_event,
4759 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4760
4761 if (!rc) {
4762 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4763 retval = -ETIMEDOUT;
4764 } else {
4765 spin_lock(&hdd_context_lock);
4766 if (context->request_id == request_id)
4767 retval = context->response_status;
4768 else
4769 retval = -EINVAL;
4770 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304771 }
4772
Dino Myclee8843b32014-07-04 14:21:45 +05304773 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304774 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304775 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304776
4777fail:
4778 vos_mem_free(pReqMsg);
4779 return -EINVAL;
4780}
4781
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304782/*
4783 * done with short names for the global vendor params
4784 * used by wlan_hdd_cfg80211_extscan_start()
4785 */
4786#undef PARAM_MAX
4787#undef PARAM_REQUEST_ID
4788#undef PARAM_BASE_PERIOD
4789#undef PARAMS_MAX_AP_PER_SCAN
4790#undef PARAMS_RPT_THRHLD_PERCENT
4791#undef PARAMS_RPT_THRHLD_NUM_SCANS
4792#undef PARAMS_NUM_BUCKETS
4793
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304794static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4795 struct wireless_dev *wdev,
4796 const void *data, int dataLen)
4797{
4798 int ret = 0;
4799
4800 vos_ssr_protect(__func__);
4801 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4802 vos_ssr_unprotect(__func__);
4803
4804 return ret;
4805}
4806
4807static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304808 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304809 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304810{
Dino Myclee8843b32014-07-04 14:21:45 +05304811 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304812 struct net_device *dev = wdev->netdev;
4813 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4814 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4815 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4816 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304817 int retval;
4818 unsigned long rc;
4819 struct hdd_ext_scan_context *context;
4820 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304821
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304822 ENTER();
4823
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304824 if (VOS_FTM_MODE == hdd_get_conparam()) {
4825 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4826 return -EINVAL;
4827 }
4828
Dino Mycle6fb96c12014-06-10 11:52:40 +05304829 status = wlan_hdd_validate_context(pHddCtx);
4830 if (0 != status)
4831 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304832 return -EINVAL;
4833 }
Dino Myclee8843b32014-07-04 14:21:45 +05304834 /* check the EXTScan Capability */
4835 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304836 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4837 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304838 {
4839 hddLog(VOS_TRACE_LEVEL_ERROR,
4840 FL("EXTScan not enabled/supported by Firmware"));
4841 return -EINVAL;
4842 }
4843
Dino Mycle6fb96c12014-06-10 11:52:40 +05304844 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4845 data, dataLen,
4846 wlan_hdd_extscan_config_policy)) {
4847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4848 return -EINVAL;
4849 }
4850
4851 /* Parse and fetch request Id */
4852 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4853 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4854 return -EINVAL;
4855 }
4856
Dino Myclee8843b32014-07-04 14:21:45 +05304857 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304858 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304859 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304860
Dino Myclee8843b32014-07-04 14:21:45 +05304861 reqMsg.sessionId = pAdapter->sessionId;
4862 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304863
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304864 context = &pHddCtx->ext_scan_context;
4865 spin_lock(&hdd_context_lock);
4866 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05304867 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304868 spin_unlock(&hdd_context_lock);
4869
Dino Myclee8843b32014-07-04 14:21:45 +05304870 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304871 if (!HAL_STATUS_SUCCESS(status)) {
4872 hddLog(VOS_TRACE_LEVEL_ERROR,
4873 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304874 return -EINVAL;
4875 }
4876
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304877 /* request was sent -- wait for the response */
4878 rc = wait_for_completion_timeout(&context->response_event,
4879 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4880
4881 if (!rc) {
4882 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4883 retval = -ETIMEDOUT;
4884 } else {
4885 spin_lock(&hdd_context_lock);
4886 if (context->request_id == request_id)
4887 retval = context->response_status;
4888 else
4889 retval = -EINVAL;
4890 spin_unlock(&hdd_context_lock);
4891 }
4892
4893 return retval;
4894
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304895 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304896 return 0;
4897}
4898
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304899static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4900 struct wireless_dev *wdev,
4901 const void *data, int dataLen)
4902{
4903 int ret = 0;
4904
4905 vos_ssr_protect(__func__);
4906 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4907 vos_ssr_unprotect(__func__);
4908
4909 return ret;
4910}
4911
4912static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304913 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304914 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304915{
Dino Myclee8843b32014-07-04 14:21:45 +05304916 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304917 struct net_device *dev = wdev->netdev;
4918 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4919 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4920 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4921 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304922 struct hdd_ext_scan_context *context;
4923 tANI_U32 request_id;
4924 unsigned long rc;
4925 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304926
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304927 ENTER();
4928
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304929 if (VOS_FTM_MODE == hdd_get_conparam()) {
4930 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4931 return -EINVAL;
4932 }
4933
Dino Mycle6fb96c12014-06-10 11:52:40 +05304934 status = wlan_hdd_validate_context(pHddCtx);
4935 if (0 != status)
4936 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304937 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304938 return -EINVAL;
4939 }
Dino Myclee8843b32014-07-04 14:21:45 +05304940 /* check the EXTScan Capability */
4941 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304942 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4943 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304944 {
4945 hddLog(VOS_TRACE_LEVEL_ERROR,
4946 FL("EXTScan not enabled/supported by Firmware"));
4947 return -EINVAL;
4948 }
4949
Dino Mycle6fb96c12014-06-10 11:52:40 +05304950 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4951 data, dataLen,
4952 wlan_hdd_extscan_config_policy)) {
4953 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4954 return -EINVAL;
4955 }
4956
4957 /* Parse and fetch request Id */
4958 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4959 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4960 return -EINVAL;
4961 }
4962
Dino Myclee8843b32014-07-04 14:21:45 +05304963 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304964 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304965 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304966
Dino Myclee8843b32014-07-04 14:21:45 +05304967 reqMsg.sessionId = pAdapter->sessionId;
4968 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304969
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304970 context = &pHddCtx->ext_scan_context;
4971 spin_lock(&hdd_context_lock);
4972 INIT_COMPLETION(context->response_event);
4973 context->request_id = request_id = reqMsg.requestId;
4974 spin_unlock(&hdd_context_lock);
4975
Dino Myclee8843b32014-07-04 14:21:45 +05304976 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304977 if (!HAL_STATUS_SUCCESS(status)) {
4978 hddLog(VOS_TRACE_LEVEL_ERROR,
4979 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304980 return -EINVAL;
4981 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304982
4983 /* request was sent -- wait for the response */
4984 rc = wait_for_completion_timeout(&context->response_event,
4985 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4986 if (!rc) {
4987 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4988 retval = -ETIMEDOUT;
4989 } else {
4990 spin_lock(&hdd_context_lock);
4991 if (context->request_id == request_id)
4992 retval = context->response_status;
4993 else
4994 retval = -EINVAL;
4995 spin_unlock(&hdd_context_lock);
4996 }
4997
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304998 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304999 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305000}
5001
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305002static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
5003 struct wireless_dev *wdev,
5004 const void *data, int dataLen)
5005{
5006 int ret = 0;
5007
5008 vos_ssr_protect(__func__);
5009 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
5010 vos_ssr_unprotect(__func__);
5011
5012 return ret;
5013}
Dino Mycle6fb96c12014-06-10 11:52:40 +05305014#endif /* WLAN_FEATURE_EXTSCAN */
5015
Atul Mittal115287b2014-07-08 13:26:33 +05305016/*EXT TDLS*/
5017static const struct nla_policy
5018wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
5019{
5020 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
5021 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
5022 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
5023 {.type = NLA_S32 },
5024 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
5025 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
5026
5027};
5028
5029static const struct nla_policy
5030wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
5031{
5032 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
5033
5034};
5035
5036static const struct nla_policy
5037wlan_hdd_tdls_config_state_change_policy[
5038 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5039{
5040 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
5041 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5042 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305043 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5044 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5045 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305046
5047};
5048
5049static const struct nla_policy
5050wlan_hdd_tdls_config_get_status_policy[
5051 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5052{
5053 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
5054 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5055 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305056 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5057 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5058 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305059
5060};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305061
5062static const struct nla_policy
5063wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5064{
5065 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
5066};
5067
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305068static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305069 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305070 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305071 int data_len)
5072{
5073
5074 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5075 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305077 ENTER();
5078
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305079 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305080 return -EINVAL;
5081 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305082 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305083 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305084 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305085 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305086 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305087 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305088 return -ENOTSUPP;
5089 }
5090
5091 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5092 data, data_len, wlan_hdd_mac_config)) {
5093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5094 return -EINVAL;
5095 }
5096
5097 /* Parse and fetch mac address */
5098 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5099 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5100 return -EINVAL;
5101 }
5102
5103 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5104 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5105 VOS_MAC_ADDR_LAST_3_BYTES);
5106
Siddharth Bhal76972212014-10-15 16:22:51 +05305107 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5108
5109 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305110 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5111 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305112 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5113 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5114 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5115 {
5116 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5117 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5118 VOS_MAC_ADDRESS_LEN);
5119 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305120 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305121
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305122 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5123 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305124
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305125 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305126 return 0;
5127}
5128
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305129static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5130 struct wireless_dev *wdev,
5131 const void *data,
5132 int data_len)
5133{
5134 int ret = 0;
5135
5136 vos_ssr_protect(__func__);
5137 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5138 vos_ssr_unprotect(__func__);
5139
5140 return ret;
5141}
5142
5143static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305144 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305145 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305146 int data_len)
5147{
5148 u8 peer[6] = {0};
5149 struct net_device *dev = wdev->netdev;
5150 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5152 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5153 eHalStatus ret;
5154 tANI_S32 state;
5155 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305156 tANI_S32 global_operating_class = 0;
5157 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305158 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305159 int retVal;
5160
5161 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305162
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305163 if (!pAdapter) {
5164 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5165 return -EINVAL;
5166 }
5167
Atul Mittal115287b2014-07-08 13:26:33 +05305168 ret = wlan_hdd_validate_context(pHddCtx);
5169 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305171 return -EINVAL;
5172 }
5173 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305175 return -ENOTSUPP;
5176 }
5177 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5178 data, data_len,
5179 wlan_hdd_tdls_config_get_status_policy)) {
5180 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5181 return -EINVAL;
5182 }
5183
5184 /* Parse and fetch mac address */
5185 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5186 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5187 return -EINVAL;
5188 }
5189
5190 memcpy(peer, nla_data(
5191 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5192 sizeof(peer));
5193 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5194
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305195 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305196
Atul Mittal115287b2014-07-08 13:26:33 +05305197 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305198 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305199 NLMSG_HDRLEN);
5200
5201 if (!skb) {
5202 hddLog(VOS_TRACE_LEVEL_ERROR,
5203 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5204 return -EINVAL;
5205 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305206 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 +05305207 reason,
5208 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305209 global_operating_class,
5210 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305211 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305212 if (nla_put_s32(skb,
5213 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5214 state) ||
5215 nla_put_s32(skb,
5216 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5217 reason) ||
5218 nla_put_s32(skb,
5219 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5220 global_operating_class) ||
5221 nla_put_s32(skb,
5222 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5223 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305224
5225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5226 goto nla_put_failure;
5227 }
5228
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305229 retVal = cfg80211_vendor_cmd_reply(skb);
5230 EXIT();
5231 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305232
5233nla_put_failure:
5234 kfree_skb(skb);
5235 return -EINVAL;
5236}
5237
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305238static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5239 struct wireless_dev *wdev,
5240 const void *data,
5241 int data_len)
5242{
5243 int ret = 0;
5244
5245 vos_ssr_protect(__func__);
5246 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5247 vos_ssr_unprotect(__func__);
5248
5249 return ret;
5250}
5251
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305252static int wlan_hdd_cfg80211_exttdls_callback(
5253#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5254 const tANI_U8* mac,
5255#else
5256 tANI_U8* mac,
5257#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305258 tANI_S32 state,
5259 tANI_S32 reason,
5260 void *ctx)
5261{
5262 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305263 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305264 tANI_S32 global_operating_class = 0;
5265 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305266 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305267
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305268 ENTER();
5269
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305270 if (!pAdapter) {
5271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5272 return -EINVAL;
5273 }
5274
5275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305276 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305277 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305278 return -EINVAL;
5279 }
5280
5281 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305283 return -ENOTSUPP;
5284 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305285 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5286#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5287 NULL,
5288#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305289 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5290 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5291 GFP_KERNEL);
5292
5293 if (!skb) {
5294 hddLog(VOS_TRACE_LEVEL_ERROR,
5295 FL("cfg80211_vendor_event_alloc failed"));
5296 return -EINVAL;
5297 }
5298 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305299 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5300 reason,
5301 state,
5302 global_operating_class,
5303 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305304 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5305 MAC_ADDR_ARRAY(mac));
5306
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305307 if (nla_put(skb,
5308 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5309 VOS_MAC_ADDR_SIZE, mac) ||
5310 nla_put_s32(skb,
5311 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5312 state) ||
5313 nla_put_s32(skb,
5314 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5315 reason) ||
5316 nla_put_s32(skb,
5317 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5318 channel) ||
5319 nla_put_s32(skb,
5320 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5321 global_operating_class)
5322 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305323 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5324 goto nla_put_failure;
5325 }
5326
5327 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305328 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305329 return (0);
5330
5331nla_put_failure:
5332 kfree_skb(skb);
5333 return -EINVAL;
5334}
5335
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305336static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305337 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305338 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305339 int data_len)
5340{
5341 u8 peer[6] = {0};
5342 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305343 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5344 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5345 eHalStatus status;
5346 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305347 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305348 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305349
5350 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305351
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305352 if (!dev) {
5353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5354 return -EINVAL;
5355 }
5356
5357 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5358 if (!pAdapter) {
5359 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5360 return -EINVAL;
5361 }
5362
Atul Mittal115287b2014-07-08 13:26:33 +05305363 status = wlan_hdd_validate_context(pHddCtx);
5364 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305365 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305366 return -EINVAL;
5367 }
5368 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305370 return -ENOTSUPP;
5371 }
5372 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5373 data, data_len,
5374 wlan_hdd_tdls_config_enable_policy)) {
5375 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5376 return -EINVAL;
5377 }
5378
5379 /* Parse and fetch mac address */
5380 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5381 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5382 return -EINVAL;
5383 }
5384
5385 memcpy(peer, nla_data(
5386 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5387 sizeof(peer));
5388 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5389
5390 /* Parse and fetch channel */
5391 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5392 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5393 return -EINVAL;
5394 }
5395 pReqMsg.channel = nla_get_s32(
5396 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5397 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5398
5399 /* Parse and fetch global operating class */
5400 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5402 return -EINVAL;
5403 }
5404 pReqMsg.global_operating_class = nla_get_s32(
5405 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5406 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5407 pReqMsg.global_operating_class);
5408
5409 /* Parse and fetch latency ms */
5410 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5411 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5412 return -EINVAL;
5413 }
5414 pReqMsg.max_latency_ms = nla_get_s32(
5415 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5416 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5417 pReqMsg.max_latency_ms);
5418
5419 /* Parse and fetch required bandwidth kbps */
5420 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5422 return -EINVAL;
5423 }
5424
5425 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5426 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5427 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5428 pReqMsg.min_bandwidth_kbps);
5429
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305430 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305431 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305432 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305433 wlan_hdd_cfg80211_exttdls_callback);
5434
5435 EXIT();
5436 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305437}
5438
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305439static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5440 struct wireless_dev *wdev,
5441 const void *data,
5442 int data_len)
5443{
5444 int ret = 0;
5445
5446 vos_ssr_protect(__func__);
5447 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5448 vos_ssr_unprotect(__func__);
5449
5450 return ret;
5451}
5452
5453static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305454 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305455 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305456 int data_len)
5457{
5458 u8 peer[6] = {0};
5459 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305460 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5461 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5462 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305463 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305464 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305465
5466 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305467
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305468 if (!dev) {
5469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5470 return -EINVAL;
5471 }
5472
5473 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5474 if (!pAdapter) {
5475 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5476 return -EINVAL;
5477 }
5478
Atul Mittal115287b2014-07-08 13:26:33 +05305479 status = wlan_hdd_validate_context(pHddCtx);
5480 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305482 return -EINVAL;
5483 }
5484 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305485 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305486 return -ENOTSUPP;
5487 }
5488 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5489 data, data_len,
5490 wlan_hdd_tdls_config_disable_policy)) {
5491 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5492 return -EINVAL;
5493 }
5494 /* Parse and fetch mac address */
5495 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5496 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5497 return -EINVAL;
5498 }
5499
5500 memcpy(peer, nla_data(
5501 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5502 sizeof(peer));
5503 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5504
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305505 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5506
5507 EXIT();
5508 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305509}
5510
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305511static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5512 struct wireless_dev *wdev,
5513 const void *data,
5514 int data_len)
5515{
5516 int ret = 0;
5517
5518 vos_ssr_protect(__func__);
5519 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5520 vos_ssr_unprotect(__func__);
5521
5522 return ret;
5523}
5524
Dasari Srinivas7875a302014-09-26 17:50:57 +05305525static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305526__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305527 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305528 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305529{
5530 struct net_device *dev = wdev->netdev;
5531 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5532 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5533 struct sk_buff *skb = NULL;
5534 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305535 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305536
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305537 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305538
5539 ret = wlan_hdd_validate_context(pHddCtx);
5540 if (0 != ret)
5541 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305542 return ret;
5543 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305544 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5545 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5546 fset |= WIFI_FEATURE_INFRA;
5547 }
5548
5549 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5550 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5551 fset |= WIFI_FEATURE_INFRA_5G;
5552 }
5553
5554#ifdef WLAN_FEATURE_P2P
5555 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5556 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5557 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5558 fset |= WIFI_FEATURE_P2P;
5559 }
5560#endif
5561
5562 /* Soft-AP is supported currently by default */
5563 fset |= WIFI_FEATURE_SOFT_AP;
5564
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305565 /* HOTSPOT is a supplicant feature, enable it by default */
5566 fset |= WIFI_FEATURE_HOTSPOT;
5567
Dasari Srinivas7875a302014-09-26 17:50:57 +05305568#ifdef WLAN_FEATURE_EXTSCAN
5569 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305570 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5571 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5572 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305573 fset |= WIFI_FEATURE_EXTSCAN;
5574 }
5575#endif
5576
Dasari Srinivas7875a302014-09-26 17:50:57 +05305577 if (sme_IsFeatureSupportedByFW(NAN)) {
5578 hddLog(LOG1, FL("NAN is supported by firmware"));
5579 fset |= WIFI_FEATURE_NAN;
5580 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305581
5582 /* D2D RTT is not supported currently by default */
5583 if (sme_IsFeatureSupportedByFW(RTT)) {
5584 hddLog(LOG1, FL("RTT is supported by firmware"));
5585 fset |= WIFI_FEATURE_D2AP_RTT;
5586 }
5587
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305588 if (sme_IsFeatureSupportedByFW(RTT3)) {
5589 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5590 fset |= WIFI_FEATURE_RTT3;
5591 }
5592
Dasari Srinivas7875a302014-09-26 17:50:57 +05305593#ifdef FEATURE_WLAN_BATCH_SCAN
5594 if (fset & WIFI_FEATURE_EXTSCAN) {
5595 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5596 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5597 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5598 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5599 fset |= WIFI_FEATURE_BATCH_SCAN;
5600 }
5601#endif
5602
5603#ifdef FEATURE_WLAN_SCAN_PNO
5604 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5605 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5606 hddLog(LOG1, FL("PNO is supported by firmware"));
5607 fset |= WIFI_FEATURE_PNO;
5608 }
5609#endif
5610
5611 /* STA+STA is supported currently by default */
5612 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5613
5614#ifdef FEATURE_WLAN_TDLS
5615 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5616 sme_IsFeatureSupportedByFW(TDLS)) {
5617 hddLog(LOG1, FL("TDLS is supported by firmware"));
5618 fset |= WIFI_FEATURE_TDLS;
5619 }
5620
5621 /* TDLS_OFFCHANNEL is not supported currently by default */
5622#endif
5623
5624#ifdef WLAN_AP_STA_CONCURRENCY
5625 /* AP+STA concurrency is supported currently by default */
5626 fset |= WIFI_FEATURE_AP_STA;
5627#endif
5628
Mukul Sharma5add0532015-08-17 15:57:47 +05305629#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5630 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5631 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5632#endif
5633
Dasari Srinivas7875a302014-09-26 17:50:57 +05305634 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5635 NLMSG_HDRLEN);
5636
5637 if (!skb) {
5638 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5639 return -EINVAL;
5640 }
5641 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5642
5643 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5644 hddLog(LOGE, FL("nla put fail"));
5645 goto nla_put_failure;
5646 }
5647
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305648 ret = cfg80211_vendor_cmd_reply(skb);
5649 EXIT();
5650 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305651
5652nla_put_failure:
5653 kfree_skb(skb);
5654 return -EINVAL;
5655}
5656
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305657static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305658wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5659 struct wireless_dev *wdev,
5660 const void *data, int data_len)
5661{
5662 int ret = 0;
5663
5664 vos_ssr_protect(__func__);
5665 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5666 vos_ssr_unprotect(__func__);
5667
5668 return ret;
5669}
5670
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305671
5672static const struct
5673nla_policy
5674qca_wlan_vendor_wifi_logger_get_ring_data_policy
5675[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5676 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5677 = {.type = NLA_U32 },
5678};
5679
5680static int
5681 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5682 struct wireless_dev *wdev,
5683 const void *data,
5684 int data_len)
5685{
5686 int ret;
5687 VOS_STATUS status;
5688 uint32_t ring_id;
5689 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5690 struct nlattr *tb
5691 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5692
5693 ENTER();
5694
5695 ret = wlan_hdd_validate_context(hdd_ctx);
5696 if (0 != ret) {
5697 return ret;
5698 }
5699
5700 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5701 data, data_len,
5702 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5703 hddLog(LOGE, FL("Invalid attribute"));
5704 return -EINVAL;
5705 }
5706
5707 /* Parse and fetch ring id */
5708 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5709 hddLog(LOGE, FL("attr ATTR failed"));
5710 return -EINVAL;
5711 }
5712
5713 ring_id = nla_get_u32(
5714 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5715
5716 hddLog(LOG1, FL("Bug report triggered by framework"));
5717
5718 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5719 WLAN_LOG_INDICATOR_FRAMEWORK,
5720 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305721 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305722 );
5723 if (VOS_STATUS_SUCCESS != status) {
5724 hddLog(LOGE, FL("Failed to trigger bug report"));
5725
5726 return -EINVAL;
5727 }
5728
5729 return 0;
5730
5731
5732}
5733
5734
5735static int
5736 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5737 struct wireless_dev *wdev,
5738 const void *data,
5739 int data_len)
5740{
5741 int ret = 0;
5742
5743 vos_ssr_protect(__func__);
5744 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5745 wdev, data, data_len);
5746 vos_ssr_unprotect(__func__);
5747
5748 return ret;
5749
5750}
5751
5752
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305753static int
5754__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305755 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305756 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305757{
5758 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5759 uint8_t i, feature_sets, max_feature_sets;
5760 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5761 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305762 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5763 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305764
5765 ENTER();
5766
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305767 ret = wlan_hdd_validate_context(pHddCtx);
5768 if (0 != ret)
5769 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305770 return ret;
5771 }
5772
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305773 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5774 data, data_len, NULL)) {
5775 hddLog(LOGE, FL("Invalid ATTR"));
5776 return -EINVAL;
5777 }
5778
5779 /* Parse and fetch max feature set */
5780 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5781 hddLog(LOGE, FL("Attr max feature set size failed"));
5782 return -EINVAL;
5783 }
5784 max_feature_sets = nla_get_u32(
5785 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5786 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5787
5788 /* Fill feature combination matrix */
5789 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305790 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5791 WIFI_FEATURE_P2P;
5792
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305793 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5794 WIFI_FEATURE_SOFT_AP;
5795
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305796 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5797 WIFI_FEATURE_SOFT_AP;
5798
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305799 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5800 WIFI_FEATURE_SOFT_AP |
5801 WIFI_FEATURE_P2P;
5802
5803 /* Add more feature combinations here */
5804
5805 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5806 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5807 hddLog(LOG1, "Feature set matrix");
5808 for (i = 0; i < feature_sets; i++)
5809 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5810
5811 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5812 sizeof(u32) * feature_sets +
5813 NLMSG_HDRLEN);
5814
5815 if (reply_skb) {
5816 if (nla_put_u32(reply_skb,
5817 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5818 feature_sets) ||
5819 nla_put(reply_skb,
5820 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5821 sizeof(u32) * feature_sets, feature_set_matrix)) {
5822 hddLog(LOGE, FL("nla put fail"));
5823 kfree_skb(reply_skb);
5824 return -EINVAL;
5825 }
5826
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305827 ret = cfg80211_vendor_cmd_reply(reply_skb);
5828 EXIT();
5829 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305830 }
5831 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5832 return -ENOMEM;
5833
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305834}
5835
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305836static int
5837wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5838 struct wireless_dev *wdev,
5839 const void *data, int data_len)
5840{
5841 int ret = 0;
5842
5843 vos_ssr_protect(__func__);
5844 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5845 data_len);
5846 vos_ssr_unprotect(__func__);
5847
5848 return ret;
5849}
5850
c_manjeecfd1efb2015-09-25 19:32:34 +05305851
5852static int
5853__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5854 struct wireless_dev *wdev,
5855 const void *data, int data_len)
5856{
5857 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5858 int ret;
5859 ENTER();
5860
5861 ret = wlan_hdd_validate_context(pHddCtx);
5862 if (0 != ret)
5863 {
5864 return ret;
5865 }
5866
5867 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5868 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5869 {
5870 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5871 return -EINVAL;
5872 }
5873 /*call common API for FW mem dump req*/
5874 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5875
Abhishek Singhc783fa72015-12-09 18:07:34 +05305876 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305877 {
5878 /*indicate to userspace the status of fw mem dump */
5879 wlan_indicate_mem_dump_complete(true);
5880 }
5881 else
5882 {
5883 /*else send failure to userspace */
5884 wlan_indicate_mem_dump_complete(false);
5885 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305886 EXIT();
5887 return ret;
5888}
5889
5890/**
5891 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5892 * @wiphy: pointer to wireless wiphy structure.
5893 * @wdev: pointer to wireless_dev structure.
5894 * @data: Pointer to the NL data.
5895 * @data_len:Length of @data
5896 *
5897 * This is called when wlan driver needs to get the firmware memory dump
5898 * via vendor specific command.
5899 *
5900 * Return: 0 on success, error number otherwise.
5901 */
5902
5903static int
5904wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5905 struct wireless_dev *wdev,
5906 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305907{
5908 int ret = 0;
5909 vos_ssr_protect(__func__);
5910 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5911 data_len);
5912 vos_ssr_unprotect(__func__);
5913 return ret;
5914}
c_manjeecfd1efb2015-09-25 19:32:34 +05305915
Sushant Kaushik8e644982015-09-23 12:18:54 +05305916static const struct
5917nla_policy
5918qca_wlan_vendor_wifi_logger_start_policy
5919[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5920 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5921 = {.type = NLA_U32 },
5922 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5923 = {.type = NLA_U32 },
5924 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5925 = {.type = NLA_U32 },
5926};
5927
5928/**
5929 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5930 * or disable the collection of packet statistics from the firmware
5931 * @wiphy: WIPHY structure pointer
5932 * @wdev: Wireless device structure pointer
5933 * @data: Pointer to the data received
5934 * @data_len: Length of the data received
5935 *
5936 * This function is used to enable or disable the collection of packet
5937 * statistics from the firmware
5938 *
5939 * Return: 0 on success and errno on failure
5940 */
5941static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5942 struct wireless_dev *wdev,
5943 const void *data,
5944 int data_len)
5945{
5946 eHalStatus status;
5947 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5948 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5949 tAniWifiStartLog start_log;
5950
5951 status = wlan_hdd_validate_context(hdd_ctx);
5952 if (0 != status) {
5953 return -EINVAL;
5954 }
5955
5956 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5957 data, data_len,
5958 qca_wlan_vendor_wifi_logger_start_policy)) {
5959 hddLog(LOGE, FL("Invalid attribute"));
5960 return -EINVAL;
5961 }
5962
5963 /* Parse and fetch ring id */
5964 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5965 hddLog(LOGE, FL("attr ATTR failed"));
5966 return -EINVAL;
5967 }
5968 start_log.ringId = nla_get_u32(
5969 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5970 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5971
5972 /* Parse and fetch verbose level */
5973 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5974 hddLog(LOGE, FL("attr verbose_level failed"));
5975 return -EINVAL;
5976 }
5977 start_log.verboseLevel = nla_get_u32(
5978 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5979 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5980
5981 /* Parse and fetch flag */
5982 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5983 hddLog(LOGE, FL("attr flag failed"));
5984 return -EINVAL;
5985 }
5986 start_log.flag = nla_get_u32(
5987 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5988 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5989
5990 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305991 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5992 !vos_isPktStatsEnabled()))
5993
Sushant Kaushik8e644982015-09-23 12:18:54 +05305994 {
5995 hddLog(LOGE, FL("per pkt stats not enabled"));
5996 return -EINVAL;
5997 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305998
Sushant Kaushik33200572015-08-05 16:46:20 +05305999 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306000 return 0;
6001}
6002
6003/**
6004 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6005 * or disable the collection of packet statistics from the firmware
6006 * @wiphy: WIPHY structure pointer
6007 * @wdev: Wireless device structure pointer
6008 * @data: Pointer to the data received
6009 * @data_len: Length of the data received
6010 *
6011 * This function is used to enable or disable the collection of packet
6012 * statistics from the firmware
6013 *
6014 * Return: 0 on success and errno on failure
6015 */
6016static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6017 struct wireless_dev *wdev,
6018 const void *data,
6019 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306020{
6021 int ret = 0;
6022
6023 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306024
6025 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6026 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306027 vos_ssr_unprotect(__func__);
6028
6029 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306030}
6031
6032
Agarwal Ashish738843c2014-09-25 12:27:56 +05306033static const struct nla_policy
6034wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6035 +1] =
6036{
6037 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6038};
6039
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306040static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306041 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306042 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306043 int data_len)
6044{
6045 struct net_device *dev = wdev->netdev;
6046 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6047 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6048 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6049 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6050 eHalStatus status;
6051 u32 dfsFlag = 0;
6052
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306053 ENTER();
6054
Agarwal Ashish738843c2014-09-25 12:27:56 +05306055 status = wlan_hdd_validate_context(pHddCtx);
6056 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306057 return -EINVAL;
6058 }
6059 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6060 data, data_len,
6061 wlan_hdd_set_no_dfs_flag_config_policy)) {
6062 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6063 return -EINVAL;
6064 }
6065
6066 /* Parse and fetch required bandwidth kbps */
6067 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6068 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6069 return -EINVAL;
6070 }
6071
6072 dfsFlag = nla_get_u32(
6073 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6074 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6075 dfsFlag);
6076
6077 pHddCtx->disable_dfs_flag = dfsFlag;
6078
6079 sme_disable_dfs_channel(hHal, dfsFlag);
6080 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306081
6082 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306083 return 0;
6084}
Atul Mittal115287b2014-07-08 13:26:33 +05306085
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306086static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6087 struct wireless_dev *wdev,
6088 const void *data,
6089 int data_len)
6090{
6091 int ret = 0;
6092
6093 vos_ssr_protect(__func__);
6094 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6095 vos_ssr_unprotect(__func__);
6096
6097 return ret;
6098
6099}
6100
Mukul Sharma2a271632014-10-13 14:59:01 +05306101const struct
6102nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6103{
6104 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6105 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6106};
6107
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306108static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306109 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306110{
6111
6112 u8 bssid[6] = {0};
6113 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6114 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6115 eHalStatus status = eHAL_STATUS_SUCCESS;
6116 v_U32_t isFwrRoamEnabled = FALSE;
6117 int ret;
6118
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306119 ENTER();
6120
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306121 ret = wlan_hdd_validate_context(pHddCtx);
6122 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306123 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306124 }
6125
6126 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6127 data, data_len,
6128 qca_wlan_vendor_attr);
6129 if (ret){
6130 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6131 return -EINVAL;
6132 }
6133
6134 /* Parse and fetch Enable flag */
6135 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6137 return -EINVAL;
6138 }
6139
6140 isFwrRoamEnabled = nla_get_u32(
6141 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6142
6143 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6144
6145 /* Parse and fetch bssid */
6146 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6148 return -EINVAL;
6149 }
6150
6151 memcpy(bssid, nla_data(
6152 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6153 sizeof(bssid));
6154 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6155
6156 //Update roaming
6157 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306158 if (!HAL_STATUS_SUCCESS(status)) {
6159 hddLog(LOGE,
6160 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6161 return -EINVAL;
6162 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306163 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306164 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306165}
6166
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306167static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6168 struct wireless_dev *wdev, const void *data, int data_len)
6169{
6170 int ret = 0;
6171
6172 vos_ssr_protect(__func__);
6173 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6174 vos_ssr_unprotect(__func__);
6175
6176 return ret;
6177}
6178
Sushant Kaushik847890c2015-09-28 16:05:17 +05306179static const struct
6180nla_policy
6181qca_wlan_vendor_get_wifi_info_policy[
6182 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6183 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6184 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6185};
6186
6187
6188/**
6189 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6190 * @wiphy: pointer to wireless wiphy structure.
6191 * @wdev: pointer to wireless_dev structure.
6192 * @data: Pointer to the data to be passed via vendor interface
6193 * @data_len:Length of the data to be passed
6194 *
6195 * This is called when wlan driver needs to send wifi driver related info
6196 * (driver/fw version) to the user space application upon request.
6197 *
6198 * Return: Return the Success or Failure code.
6199 */
6200static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6201 struct wireless_dev *wdev,
6202 const void *data, int data_len)
6203{
6204 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6205 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6206 tSirVersionString version;
6207 uint32 version_len;
6208 uint8 attr;
6209 int status;
6210 struct sk_buff *reply_skb = NULL;
6211
6212 if (VOS_FTM_MODE == hdd_get_conparam()) {
6213 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6214 return -EINVAL;
6215 }
6216
6217 status = wlan_hdd_validate_context(hdd_ctx);
6218 if (0 != status) {
6219 hddLog(LOGE, FL("HDD context is not valid"));
6220 return -EINVAL;
6221 }
6222
6223 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6224 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6225 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6226 return -EINVAL;
6227 }
6228
6229 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6230 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6231 QWLAN_VERSIONSTR);
6232 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6233 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6234 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6235 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6236 hdd_ctx->fw_Version);
6237 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6238 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6239 } else {
6240 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6241 return -EINVAL;
6242 }
6243
6244 version_len = strlen(version);
6245 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6246 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6247 if (!reply_skb) {
6248 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6249 return -ENOMEM;
6250 }
6251
6252 if (nla_put(reply_skb, attr, version_len, version)) {
6253 hddLog(LOGE, FL("nla put fail"));
6254 kfree_skb(reply_skb);
6255 return -EINVAL;
6256 }
6257
6258 return cfg80211_vendor_cmd_reply(reply_skb);
6259}
6260
6261/**
6262 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6263 * @wiphy: pointer to wireless wiphy structure.
6264 * @wdev: pointer to wireless_dev structure.
6265 * @data: Pointer to the data to be passed via vendor interface
6266 * @data_len:Length of the data to be passed
6267 * @data_len: Length of the data received
6268 *
6269 * This function is used to enable or disable the collection of packet
6270 * statistics from the firmware
6271 *
6272 * Return: 0 on success and errno on failure
6273 */
6274
6275static int
6276wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6277 struct wireless_dev *wdev,
6278 const void *data, int data_len)
6279
6280
6281{
6282 int ret = 0;
6283
6284 vos_ssr_protect(__func__);
6285 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6286 wdev, data, data_len);
6287 vos_ssr_unprotect(__func__);
6288
6289 return ret;
6290}
6291
6292
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306293/*
6294 * define short names for the global vendor params
6295 * used by __wlan_hdd_cfg80211_monitor_rssi()
6296 */
6297#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6298#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6299#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6300#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6301#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6302
6303/**---------------------------------------------------------------------------
6304
6305 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6306 monitor start is completed successfully.
6307
6308 \return - None
6309
6310 --------------------------------------------------------------------------*/
6311void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6312{
6313 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6314
6315 if (NULL == pHddCtx)
6316 {
6317 hddLog(VOS_TRACE_LEVEL_ERROR,
6318 "%s: HDD context is NULL",__func__);
6319 return;
6320 }
6321
6322 if (VOS_STATUS_SUCCESS == status)
6323 {
6324 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6325 }
6326 else
6327 {
6328 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6329 }
6330
6331 return;
6332}
6333
6334/**---------------------------------------------------------------------------
6335
6336 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6337 stop is completed successfully.
6338
6339 \return - None
6340
6341 --------------------------------------------------------------------------*/
6342void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6343{
6344 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6345
6346 if (NULL == pHddCtx)
6347 {
6348 hddLog(VOS_TRACE_LEVEL_ERROR,
6349 "%s: HDD context is NULL",__func__);
6350 return;
6351 }
6352
6353 if (VOS_STATUS_SUCCESS == status)
6354 {
6355 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6356 }
6357 else
6358 {
6359 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6360 }
6361
6362 return;
6363}
6364
6365/**
6366 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6367 * @wiphy: Pointer to wireless phy
6368 * @wdev: Pointer to wireless device
6369 * @data: Pointer to data
6370 * @data_len: Data length
6371 *
6372 * Return: 0 on success, negative errno on failure
6373 */
6374
6375static int
6376__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6377 struct wireless_dev *wdev,
6378 const void *data,
6379 int data_len)
6380{
6381 struct net_device *dev = wdev->netdev;
6382 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6383 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6384 hdd_station_ctx_t *pHddStaCtx;
6385 struct nlattr *tb[PARAM_MAX + 1];
6386 tpSirRssiMonitorReq pReq;
6387 eHalStatus status;
6388 int ret;
6389 uint32_t control;
6390 static const struct nla_policy policy[PARAM_MAX + 1] = {
6391 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6392 [PARAM_CONTROL] = { .type = NLA_U32 },
6393 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6394 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6395 };
6396
6397 ENTER();
6398
6399 ret = wlan_hdd_validate_context(hdd_ctx);
6400 if (0 != ret) {
6401 return -EINVAL;
6402 }
6403
6404 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6405 hddLog(LOGE, FL("Not in Connected state!"));
6406 return -ENOTSUPP;
6407 }
6408
6409 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6410 hddLog(LOGE, FL("Invalid ATTR"));
6411 return -EINVAL;
6412 }
6413
6414 if (!tb[PARAM_REQUEST_ID]) {
6415 hddLog(LOGE, FL("attr request id failed"));
6416 return -EINVAL;
6417 }
6418
6419 if (!tb[PARAM_CONTROL]) {
6420 hddLog(LOGE, FL("attr control failed"));
6421 return -EINVAL;
6422 }
6423
6424 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6425
6426 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6427 if(NULL == pReq)
6428 {
6429 hddLog(LOGE,
6430 FL("vos_mem_alloc failed "));
6431 return eHAL_STATUS_FAILED_ALLOC;
6432 }
6433 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6434
6435 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6436 pReq->sessionId = pAdapter->sessionId;
6437 pReq->rssiMonitorCbContext = hdd_ctx;
6438 control = nla_get_u32(tb[PARAM_CONTROL]);
6439 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6440
6441 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6442 pReq->requestId, pReq->sessionId, control);
6443
6444 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6445 if (!tb[PARAM_MIN_RSSI]) {
6446 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306447 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306448 }
6449
6450 if (!tb[PARAM_MAX_RSSI]) {
6451 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306452 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306453 }
6454
6455 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6456 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6457 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6458
6459 if (!(pReq->minRssi < pReq->maxRssi)) {
6460 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6461 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306462 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306463 }
6464 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6465 pReq->minRssi, pReq->maxRssi);
6466 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6467
6468 }
6469 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6470 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6471 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6472 }
6473 else {
6474 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306475 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306476 }
6477
6478 if (!HAL_STATUS_SUCCESS(status)) {
6479 hddLog(LOGE,
6480 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306481 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306482 }
6483
6484 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306485fail:
6486 vos_mem_free(pReq);
6487 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306488}
6489
6490/*
6491 * done with short names for the global vendor params
6492 * used by __wlan_hdd_cfg80211_monitor_rssi()
6493 */
6494#undef PARAM_MAX
6495#undef PARAM_CONTROL
6496#undef PARAM_REQUEST_ID
6497#undef PARAM_MAX_RSSI
6498#undef PARAM_MIN_RSSI
6499
6500/**
6501 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6502 * @wiphy: wiphy structure pointer
6503 * @wdev: Wireless device structure pointer
6504 * @data: Pointer to the data received
6505 * @data_len: Length of @data
6506 *
6507 * Return: 0 on success; errno on failure
6508 */
6509static int
6510wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6511 const void *data, int data_len)
6512{
6513 int ret;
6514
6515 vos_ssr_protect(__func__);
6516 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6517 vos_ssr_unprotect(__func__);
6518
6519 return ret;
6520}
6521
6522/**
6523 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6524 * @hddctx: HDD context
6525 * @data: rssi breached event data
6526 *
6527 * This function reads the rssi breached event %data and fill in the skb with
6528 * NL attributes and send up the NL event.
6529 * This callback execute in atomic context and must not invoke any
6530 * blocking calls.
6531 *
6532 * Return: none
6533 */
6534void hdd_rssi_threshold_breached_cb(void *hddctx,
6535 struct rssi_breach_event *data)
6536{
6537 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6538 int status;
6539 struct sk_buff *skb;
6540
6541 ENTER();
6542 status = wlan_hdd_validate_context(pHddCtx);
6543
6544 if (0 != status) {
6545 return;
6546 }
6547
6548 if (!data) {
6549 hddLog(LOGE, FL("data is null"));
6550 return;
6551 }
6552
6553 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6554#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6555 NULL,
6556#endif
6557 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6558 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6559 GFP_KERNEL);
6560
6561 if (!skb) {
6562 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6563 return;
6564 }
6565
6566 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6567 data->request_id, data->curr_rssi);
6568 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6569 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6570
6571 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6572 data->request_id) ||
6573 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6574 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6575 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6576 data->curr_rssi)) {
6577 hddLog(LOGE, FL("nla put fail"));
6578 goto fail;
6579 }
6580
6581 cfg80211_vendor_event(skb, GFP_KERNEL);
6582 return;
6583
6584fail:
6585 kfree_skb(skb);
6586 return;
6587}
6588
6589
6590
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306591/**
6592 * __wlan_hdd_cfg80211_setband() - set band
6593 * @wiphy: Pointer to wireless phy
6594 * @wdev: Pointer to wireless device
6595 * @data: Pointer to data
6596 * @data_len: Data length
6597 *
6598 * Return: 0 on success, negative errno on failure
6599 */
6600static int
6601__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6602 struct wireless_dev *wdev,
6603 const void *data,
6604 int data_len)
6605{
6606 struct net_device *dev = wdev->netdev;
6607 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6608 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6609 int ret;
6610 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6611 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6612
6613 ENTER();
6614
6615 ret = wlan_hdd_validate_context(hdd_ctx);
6616 if (0 != ret) {
6617 hddLog(LOGE, FL("HDD context is not valid"));
6618 return ret;
6619 }
6620
6621 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6622 policy)) {
6623 hddLog(LOGE, FL("Invalid ATTR"));
6624 return -EINVAL;
6625 }
6626
6627 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6628 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6629 return -EINVAL;
6630 }
6631
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306632 hdd_ctx->isSetBandByNL = TRUE;
6633 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306634 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306635 hdd_ctx->isSetBandByNL = FALSE;
6636
6637 EXIT();
6638 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306639}
6640
6641/**
6642 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6643 * @wiphy: wiphy structure pointer
6644 * @wdev: Wireless device structure pointer
6645 * @data: Pointer to the data received
6646 * @data_len: Length of @data
6647 *
6648 * Return: 0 on success; errno on failure
6649 */
6650static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6651 struct wireless_dev *wdev,
6652 const void *data,
6653 int data_len)
6654{
6655 int ret = 0;
6656
6657 vos_ssr_protect(__func__);
6658 ret = __wlan_hdd_cfg80211_setband(wiphy,
6659 wdev, data, data_len);
6660 vos_ssr_unprotect(__func__);
6661
6662 return ret;
6663}
6664
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306665#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6666/**
6667 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6668 * @hdd_ctx: HDD context
6669 * @request_id: [input] request id
6670 * @pattern_id: [output] pattern id
6671 *
6672 * This function loops through request id to pattern id array
6673 * if the slot is available, store the request id and return pattern id
6674 * if entry exists, return the pattern id
6675 *
6676 * Return: 0 on success and errno on failure
6677 */
6678static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6679 uint32_t request_id,
6680 uint8_t *pattern_id)
6681{
6682 uint32_t i;
6683
6684 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6685 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6686 {
6687 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6688 {
6689 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6690 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6691 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6692 return 0;
6693 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6694 request_id) {
6695 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6696 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6697 return 0;
6698 }
6699 }
6700 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6701 return -EINVAL;
6702}
6703
6704/**
6705 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6706 * @hdd_ctx: HDD context
6707 * @request_id: [input] request id
6708 * @pattern_id: [output] pattern id
6709 *
6710 * This function loops through request id to pattern id array
6711 * reset request id to 0 (slot available again) and
6712 * return pattern id
6713 *
6714 * Return: 0 on success and errno on failure
6715 */
6716static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6717 uint32_t request_id,
6718 uint8_t *pattern_id)
6719{
6720 uint32_t i;
6721
6722 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6723 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6724 {
6725 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6726 {
6727 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6728 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6729 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6730 return 0;
6731 }
6732 }
6733 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6734 return -EINVAL;
6735}
6736
6737
6738/*
6739 * define short names for the global vendor params
6740 * used by __wlan_hdd_cfg80211_offloaded_packets()
6741 */
6742#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6743#define PARAM_REQUEST_ID \
6744 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6745#define PARAM_CONTROL \
6746 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6747#define PARAM_IP_PACKET \
6748 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6749#define PARAM_SRC_MAC_ADDR \
6750 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6751#define PARAM_DST_MAC_ADDR \
6752 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6753#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6754
6755/**
6756 * wlan_hdd_add_tx_ptrn() - add tx pattern
6757 * @adapter: adapter pointer
6758 * @hdd_ctx: hdd context
6759 * @tb: nl attributes
6760 *
6761 * This function reads the NL attributes and forms a AddTxPtrn message
6762 * posts it to SME.
6763 *
6764 */
6765static int
6766wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6767 struct nlattr **tb)
6768{
6769 struct sSirAddPeriodicTxPtrn *add_req;
6770 eHalStatus status;
6771 uint32_t request_id, ret, len;
6772 uint8_t pattern_id = 0;
6773 v_MACADDR_t dst_addr;
6774 uint16_t eth_type = htons(ETH_P_IP);
6775
6776 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6777 {
6778 hddLog(LOGE, FL("Not in Connected state!"));
6779 return -ENOTSUPP;
6780 }
6781
6782 add_req = vos_mem_malloc(sizeof(*add_req));
6783 if (!add_req)
6784 {
6785 hddLog(LOGE, FL("memory allocation failed"));
6786 return -ENOMEM;
6787 }
6788
6789 /* Parse and fetch request Id */
6790 if (!tb[PARAM_REQUEST_ID])
6791 {
6792 hddLog(LOGE, FL("attr request id failed"));
6793 goto fail;
6794 }
6795
6796 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6797 hddLog(LOG1, FL("Request Id: %u"), request_id);
6798 if (request_id == 0)
6799 {
6800 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306801 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306802 }
6803
6804 if (!tb[PARAM_PERIOD])
6805 {
6806 hddLog(LOGE, FL("attr period failed"));
6807 goto fail;
6808 }
6809 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6810 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6811 if (add_req->usPtrnIntervalMs == 0)
6812 {
6813 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6814 goto fail;
6815 }
6816
6817 if (!tb[PARAM_SRC_MAC_ADDR])
6818 {
6819 hddLog(LOGE, FL("attr source mac address failed"));
6820 goto fail;
6821 }
6822 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6823 VOS_MAC_ADDR_SIZE);
6824 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6825 MAC_ADDR_ARRAY(add_req->macAddress));
6826
6827 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6828 VOS_MAC_ADDR_SIZE))
6829 {
6830 hddLog(LOGE,
6831 FL("input src mac address and connected ap bssid are different"));
6832 goto fail;
6833 }
6834
6835 if (!tb[PARAM_DST_MAC_ADDR])
6836 {
6837 hddLog(LOGE, FL("attr dst mac address failed"));
6838 goto fail;
6839 }
6840 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6841 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6842 MAC_ADDR_ARRAY(dst_addr.bytes));
6843
6844 if (!tb[PARAM_IP_PACKET])
6845 {
6846 hddLog(LOGE, FL("attr ip packet failed"));
6847 goto fail;
6848 }
6849 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6850 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6851
6852 if (add_req->ucPtrnSize < 0 ||
6853 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6854 HDD_ETH_HEADER_LEN))
6855 {
6856 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6857 add_req->ucPtrnSize);
6858 goto fail;
6859 }
6860
6861 len = 0;
6862 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6863 len += VOS_MAC_ADDR_SIZE;
6864 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6865 VOS_MAC_ADDR_SIZE);
6866 len += VOS_MAC_ADDR_SIZE;
6867 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6868 len += 2;
6869
6870 /*
6871 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6872 * ------------------------------------------------------------
6873 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6874 * ------------------------------------------------------------
6875 */
6876 vos_mem_copy(&add_req->ucPattern[len],
6877 nla_data(tb[PARAM_IP_PACKET]),
6878 add_req->ucPtrnSize);
6879 add_req->ucPtrnSize += len;
6880
6881 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6882 add_req->ucPattern, add_req->ucPtrnSize);
6883
6884 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6885 if (ret)
6886 {
6887 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6888 goto fail;
6889 }
6890 add_req->ucPtrnId = pattern_id;
6891 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6892
6893 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6894 if (!HAL_STATUS_SUCCESS(status))
6895 {
6896 hddLog(LOGE,
6897 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6898 goto fail;
6899 }
6900
6901 EXIT();
6902 vos_mem_free(add_req);
6903 return 0;
6904
6905fail:
6906 vos_mem_free(add_req);
6907 return -EINVAL;
6908}
6909
6910/**
6911 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6912 * @adapter: adapter pointer
6913 * @hdd_ctx: hdd context
6914 * @tb: nl attributes
6915 *
6916 * This function reads the NL attributes and forms a DelTxPtrn message
6917 * posts it to SME.
6918 *
6919 */
6920static int
6921wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6922 struct nlattr **tb)
6923{
6924 struct sSirDelPeriodicTxPtrn *del_req;
6925 eHalStatus status;
6926 uint32_t request_id, ret;
6927 uint8_t pattern_id = 0;
6928
6929 /* Parse and fetch request Id */
6930 if (!tb[PARAM_REQUEST_ID])
6931 {
6932 hddLog(LOGE, FL("attr request id failed"));
6933 return -EINVAL;
6934 }
6935 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6936 if (request_id == 0)
6937 {
6938 hddLog(LOGE, FL("request_id cannot be zero"));
6939 return -EINVAL;
6940 }
6941
6942 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6943 if (ret)
6944 {
6945 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6946 return -EINVAL;
6947 }
6948
6949 del_req = vos_mem_malloc(sizeof(*del_req));
6950 if (!del_req)
6951 {
6952 hddLog(LOGE, FL("memory allocation failed"));
6953 return -ENOMEM;
6954 }
6955
6956 vos_mem_set(del_req, sizeof(*del_req), 0);
6957 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6958 VOS_MAC_ADDR_SIZE);
6959 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6960 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6961 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6962 request_id, pattern_id, del_req->ucPatternIdBitmap);
6963
6964 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6965 if (!HAL_STATUS_SUCCESS(status))
6966 {
6967 hddLog(LOGE,
6968 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6969 goto fail;
6970 }
6971
6972 EXIT();
6973 vos_mem_free(del_req);
6974 return 0;
6975
6976fail:
6977 vos_mem_free(del_req);
6978 return -EINVAL;
6979}
6980
6981
6982/**
6983 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6984 * @wiphy: Pointer to wireless phy
6985 * @wdev: Pointer to wireless device
6986 * @data: Pointer to data
6987 * @data_len: Data length
6988 *
6989 * Return: 0 on success, negative errno on failure
6990 */
6991static int
6992__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6993 struct wireless_dev *wdev,
6994 const void *data,
6995 int data_len)
6996{
6997 struct net_device *dev = wdev->netdev;
6998 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6999 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7000 struct nlattr *tb[PARAM_MAX + 1];
7001 uint8_t control;
7002 int ret;
7003 static const struct nla_policy policy[PARAM_MAX + 1] =
7004 {
7005 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7006 [PARAM_CONTROL] = { .type = NLA_U32 },
7007 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7008 .len = VOS_MAC_ADDR_SIZE },
7009 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7010 .len = VOS_MAC_ADDR_SIZE },
7011 [PARAM_PERIOD] = { .type = NLA_U32 },
7012 };
7013
7014 ENTER();
7015
7016 ret = wlan_hdd_validate_context(hdd_ctx);
7017 if (0 != ret)
7018 {
7019 hddLog(LOGE, FL("HDD context is not valid"));
7020 return ret;
7021 }
7022
7023 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7024 {
7025 hddLog(LOGE,
7026 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7027 return -ENOTSUPP;
7028 }
7029
7030 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7031 {
7032 hddLog(LOGE, FL("Invalid ATTR"));
7033 return -EINVAL;
7034 }
7035
7036 if (!tb[PARAM_CONTROL])
7037 {
7038 hddLog(LOGE, FL("attr control failed"));
7039 return -EINVAL;
7040 }
7041 control = nla_get_u32(tb[PARAM_CONTROL]);
7042 hddLog(LOG1, FL("Control: %d"), control);
7043
7044 if (control == WLAN_START_OFFLOADED_PACKETS)
7045 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7046 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7047 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7048 else
7049 {
7050 hddLog(LOGE, FL("Invalid control: %d"), control);
7051 return -EINVAL;
7052 }
7053}
7054
7055/*
7056 * done with short names for the global vendor params
7057 * used by __wlan_hdd_cfg80211_offloaded_packets()
7058 */
7059#undef PARAM_MAX
7060#undef PARAM_REQUEST_ID
7061#undef PARAM_CONTROL
7062#undef PARAM_IP_PACKET
7063#undef PARAM_SRC_MAC_ADDR
7064#undef PARAM_DST_MAC_ADDR
7065#undef PARAM_PERIOD
7066
7067/**
7068 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7069 * @wiphy: wiphy structure pointer
7070 * @wdev: Wireless device structure pointer
7071 * @data: Pointer to the data received
7072 * @data_len: Length of @data
7073 *
7074 * Return: 0 on success; errno on failure
7075 */
7076static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7077 struct wireless_dev *wdev,
7078 const void *data,
7079 int data_len)
7080{
7081 int ret = 0;
7082
7083 vos_ssr_protect(__func__);
7084 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7085 wdev, data, data_len);
7086 vos_ssr_unprotect(__func__);
7087
7088 return ret;
7089}
7090#endif
7091
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307092static const struct
7093nla_policy
7094qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
7095 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
7096};
7097
7098/**
7099 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7100 * get link properties like nss, rate flags and operating frequency for
7101 * the connection with the given peer.
7102 * @wiphy: WIPHY structure pointer
7103 * @wdev: Wireless device structure pointer
7104 * @data: Pointer to the data received
7105 * @data_len: Length of the data received
7106 *
7107 * This function return the above link properties on success.
7108 *
7109 * Return: 0 on success and errno on failure
7110 */
7111static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7112 struct wireless_dev *wdev,
7113 const void *data,
7114 int data_len)
7115{
7116 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7117 struct net_device *dev = wdev->netdev;
7118 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7119 hdd_station_ctx_t *hdd_sta_ctx;
7120 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7121 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7122 uint32_t sta_id;
7123 struct sk_buff *reply_skb;
7124 uint32_t rate_flags = 0;
7125 uint8_t nss;
7126 uint8_t final_rate_flags = 0;
7127 uint32_t freq;
7128 v_CONTEXT_t pVosContext = NULL;
7129 ptSapContext pSapCtx = NULL;
7130
7131 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7133 return -EINVAL;
7134 }
7135
7136 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7137 qca_wlan_vendor_attr_policy)) {
7138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7139 return -EINVAL;
7140 }
7141
7142 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7143 hddLog(VOS_TRACE_LEVEL_ERROR,
7144 FL("Attribute peerMac not provided for mode=%d"),
7145 adapter->device_mode);
7146 return -EINVAL;
7147 }
7148
7149 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7150 sizeof(peer_mac));
7151 hddLog(VOS_TRACE_LEVEL_INFO,
7152 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7153 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7154
7155 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7156 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7157 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7158 if ((hdd_sta_ctx->conn_info.connState !=
7159 eConnectionState_Associated) ||
7160 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7161 VOS_MAC_ADDRESS_LEN)) {
7162 hddLog(VOS_TRACE_LEVEL_ERROR,
7163 FL("Not Associated to mac "MAC_ADDRESS_STR),
7164 MAC_ADDR_ARRAY(peer_mac));
7165 return -EINVAL;
7166 }
7167
7168 nss = 1; //pronto supports only one spatial stream
7169 freq = vos_chan_to_freq(
7170 hdd_sta_ctx->conn_info.operationChannel);
7171 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7172
7173 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7174 adapter->device_mode == WLAN_HDD_SOFTAP) {
7175
7176 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7177 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7178 if(pSapCtx == NULL){
7179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7180 FL("psapCtx is NULL"));
7181 return -ENOENT;
7182 }
7183
7184
7185 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7186 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7187 !vos_is_macaddr_broadcast(
7188 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7189 vos_mem_compare(
7190 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7191 peer_mac, VOS_MAC_ADDRESS_LEN))
7192 break;
7193 }
7194
7195 if (WLAN_MAX_STA_COUNT == sta_id) {
7196 hddLog(VOS_TRACE_LEVEL_ERROR,
7197 FL("No active peer with mac="MAC_ADDRESS_STR),
7198 MAC_ADDR_ARRAY(peer_mac));
7199 return -EINVAL;
7200 }
7201
7202 nss = 1; //pronto supports only one spatial stream
7203 freq = vos_chan_to_freq(
7204 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7205 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7206 } else {
7207 hddLog(VOS_TRACE_LEVEL_ERROR,
7208 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7209 MAC_ADDR_ARRAY(peer_mac));
7210 return -EINVAL;
7211 }
7212
7213 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7214 if (rate_flags & eHAL_TX_RATE_VHT80) {
7215 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7216 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7217 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7218 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7219 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7220 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7221 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7222 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7223 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7224 if (rate_flags & eHAL_TX_RATE_HT40)
7225 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7226 }
7227
7228 if (rate_flags & eHAL_TX_RATE_SGI) {
7229 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7230 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7231 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7232 }
7233 }
7234
7235 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7236 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7237
7238 if (NULL == reply_skb) {
7239 hddLog(VOS_TRACE_LEVEL_ERROR,
7240 FL("getLinkProperties: skb alloc failed"));
7241 return -EINVAL;
7242 }
7243
7244 if (nla_put_u8(reply_skb,
7245 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7246 nss) ||
7247 nla_put_u8(reply_skb,
7248 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7249 final_rate_flags) ||
7250 nla_put_u32(reply_skb,
7251 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7252 freq)) {
7253 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7254 kfree_skb(reply_skb);
7255 return -EINVAL;
7256 }
7257
7258 return cfg80211_vendor_cmd_reply(reply_skb);
7259}
7260
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307261#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7262#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7263#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7264#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307265#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7266 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307267
7268/**
7269 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7270 * vendor command
7271 *
7272 * @wiphy: wiphy device pointer
7273 * @wdev: wireless device pointer
7274 * @data: Vendor command data buffer
7275 * @data_len: Buffer length
7276 *
7277 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7278 *
7279 * Return: EOK or other error codes.
7280 */
7281
7282static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7283 struct wireless_dev *wdev,
7284 const void *data,
7285 int data_len)
7286{
7287 struct net_device *dev = wdev->netdev;
7288 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7289 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7290 hdd_station_ctx_t *pHddStaCtx;
7291 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7292 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307293 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307294 eHalStatus status;
7295 int ret_val;
7296 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7297 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7298 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307299 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7300 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7301 { .type = NLA_U32},
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307302 };
7303
7304 ENTER();
7305
7306 if (VOS_FTM_MODE == hdd_get_conparam()) {
7307 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7308 return -EINVAL;
7309 }
7310
7311 ret_val = wlan_hdd_validate_context(pHddCtx);
7312 if (ret_val) {
7313 return ret_val;
7314 }
7315
7316 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7317
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307318 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7319 hddLog(LOGE, FL("Invalid ATTR"));
7320 return -EINVAL;
7321 }
7322
7323 /* check the Wifi Capability */
7324 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7325 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7326 {
7327 hddLog(VOS_TRACE_LEVEL_ERROR,
7328 FL("WIFICONFIG not supported by Firmware"));
7329 return -EINVAL;
7330 }
7331
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307332 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7333 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7334 modifyRoamParamsReq.value =
7335 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7336
7337 if (eHAL_STATUS_SUCCESS !=
7338 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7339 {
7340 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7341 ret_val = -EINVAL;
7342 }
7343 return ret_val;
7344 }
7345
7346 /* Moved this down in order to provide provision to set beacon
7347 * miss penalty count irrespective of connection state.
7348 */
7349 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7350 hddLog(LOGE, FL("Not in Connected state!"));
7351 return -ENOTSUPP;
7352 }
7353
7354 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307355
7356 if (!pReq) {
7357 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7358 "%s: Not able to allocate memory for tSetWifiConfigParams",
7359 __func__);
7360 return eHAL_STATUS_E_MALLOC_FAILED;
7361 }
7362
7363 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7364
7365 pReq->sessionId = pAdapter->sessionId;
7366 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7367
7368 if (tb[PARAM_MODULATED_DTIM]) {
7369 pReq->paramValue = nla_get_u32(
7370 tb[PARAM_MODULATED_DTIM]);
7371 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7372 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307373 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307374 hdd_set_pwrparams(pHddCtx);
7375 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7376 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7377
7378 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7379 iw_full_power_cbfn, pAdapter,
7380 eSME_FULL_PWR_NEEDED_BY_HDD);
7381 }
7382 else
7383 {
7384 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7385 }
7386 }
7387
7388 if (tb[PARAM_STATS_AVG_FACTOR]) {
7389 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7390 pReq->paramValue = nla_get_u16(
7391 tb[PARAM_STATS_AVG_FACTOR]);
7392 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7393 pReq->paramType, pReq->paramValue);
7394 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7395
7396 if (eHAL_STATUS_SUCCESS != status)
7397 {
7398 vos_mem_free(pReq);
7399 pReq = NULL;
7400 ret_val = -EPERM;
7401 return ret_val;
7402 }
7403 }
7404
7405
7406 if (tb[PARAM_GUARD_TIME]) {
7407 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7408 pReq->paramValue = nla_get_u32(
7409 tb[PARAM_GUARD_TIME]);
7410 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7411 pReq->paramType, pReq->paramValue);
7412 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7413
7414 if (eHAL_STATUS_SUCCESS != status)
7415 {
7416 vos_mem_free(pReq);
7417 pReq = NULL;
7418 ret_val = -EPERM;
7419 return ret_val;
7420 }
7421
7422 }
7423
7424 EXIT();
7425 return ret_val;
7426}
7427
7428/**
7429 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7430 * vendor command
7431 *
7432 * @wiphy: wiphy device pointer
7433 * @wdev: wireless device pointer
7434 * @data: Vendor command data buffer
7435 * @data_len: Buffer length
7436 *
7437 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7438 *
7439 * Return: EOK or other error codes.
7440 */
7441static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7442 struct wireless_dev *wdev,
7443 const void *data,
7444 int data_len)
7445{
7446 int ret;
7447
7448 vos_ssr_protect(__func__);
7449 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
7450 data, data_len);
7451 vos_ssr_unprotect(__func__);
7452
7453 return ret;
7454}
Sunil Duttc69bccb2014-05-26 21:30:20 +05307455const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7456{
Mukul Sharma2a271632014-10-13 14:59:01 +05307457 {
7458 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7459 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7460 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7461 WIPHY_VENDOR_CMD_NEED_NETDEV |
7462 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307463 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307464 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307465
7466 {
7467 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7468 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7469 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7470 WIPHY_VENDOR_CMD_NEED_NETDEV |
7471 WIPHY_VENDOR_CMD_NEED_RUNNING,
7472 .doit = wlan_hdd_cfg80211_nan_request
7473 },
7474
Sunil Duttc69bccb2014-05-26 21:30:20 +05307475#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7476 {
7477 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7478 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7479 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7480 WIPHY_VENDOR_CMD_NEED_NETDEV |
7481 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307482 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307483 },
7484
7485 {
7486 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7487 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7488 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7489 WIPHY_VENDOR_CMD_NEED_NETDEV |
7490 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307491 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307492 },
7493
7494 {
7495 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7496 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7497 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7498 WIPHY_VENDOR_CMD_NEED_NETDEV |
7499 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307500 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307501 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307502#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307503#ifdef WLAN_FEATURE_EXTSCAN
7504 {
7505 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7506 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7507 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7508 WIPHY_VENDOR_CMD_NEED_NETDEV |
7509 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307510 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307511 },
7512 {
7513 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7514 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7515 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7516 WIPHY_VENDOR_CMD_NEED_NETDEV |
7517 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307518 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307519 },
7520 {
7521 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7522 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7523 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7524 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307525 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307526 },
7527 {
7528 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7529 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7530 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7531 WIPHY_VENDOR_CMD_NEED_NETDEV |
7532 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307533 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307534 },
7535 {
7536 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7537 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7538 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7539 WIPHY_VENDOR_CMD_NEED_NETDEV |
7540 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307541 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307542 },
7543 {
7544 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7545 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7546 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7547 WIPHY_VENDOR_CMD_NEED_NETDEV |
7548 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307549 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307550 },
7551 {
7552 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7553 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7554 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7555 WIPHY_VENDOR_CMD_NEED_NETDEV |
7556 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307557 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307558 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307559 {
7560 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7561 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
7562 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7563 WIPHY_VENDOR_CMD_NEED_NETDEV |
7564 WIPHY_VENDOR_CMD_NEED_RUNNING,
7565 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
7566 },
7567 {
7568 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7569 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
7570 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7571 WIPHY_VENDOR_CMD_NEED_NETDEV |
7572 WIPHY_VENDOR_CMD_NEED_RUNNING,
7573 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
7574 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307575#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307576/*EXT TDLS*/
7577 {
7578 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7579 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7580 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7581 WIPHY_VENDOR_CMD_NEED_NETDEV |
7582 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307583 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307584 },
7585 {
7586 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7587 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7588 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7589 WIPHY_VENDOR_CMD_NEED_NETDEV |
7590 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307591 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307592 },
7593 {
7594 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7595 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7596 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7597 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307598 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307599 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307600 {
7601 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7602 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7603 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7604 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307605 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307606 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307607 {
7608 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7609 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7610 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7611 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307612 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307613 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307614 {
7615 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7616 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7617 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7618 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307619 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307620 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307621 {
7622 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7623 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7624 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7625 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307626 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307627 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307628 {
7629 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307630 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7631 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7632 WIPHY_VENDOR_CMD_NEED_NETDEV |
7633 WIPHY_VENDOR_CMD_NEED_RUNNING,
7634 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7635 },
7636 {
7637 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307638 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7639 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7640 WIPHY_VENDOR_CMD_NEED_NETDEV |
7641 WIPHY_VENDOR_CMD_NEED_RUNNING,
7642 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307643 },
7644 {
7645 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7646 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7647 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7648 WIPHY_VENDOR_CMD_NEED_NETDEV,
7649 .doit = wlan_hdd_cfg80211_wifi_logger_start
7650 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307651 {
7652 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7653 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7654 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7655 WIPHY_VENDOR_CMD_NEED_NETDEV|
7656 WIPHY_VENDOR_CMD_NEED_RUNNING,
7657 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307658 },
7659 {
7660 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7661 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7662 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7663 WIPHY_VENDOR_CMD_NEED_NETDEV |
7664 WIPHY_VENDOR_CMD_NEED_RUNNING,
7665 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307666 },
7667 {
7668 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7669 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7670 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7671 WIPHY_VENDOR_CMD_NEED_NETDEV |
7672 WIPHY_VENDOR_CMD_NEED_RUNNING,
7673 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307674 },
7675#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7676 {
7677 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7678 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7679 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7680 WIPHY_VENDOR_CMD_NEED_NETDEV |
7681 WIPHY_VENDOR_CMD_NEED_RUNNING,
7682 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307683 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307684#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307685 {
7686 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7687 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7688 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7689 WIPHY_VENDOR_CMD_NEED_NETDEV |
7690 WIPHY_VENDOR_CMD_NEED_RUNNING,
7691 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307692 },
7693 {
7694 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7695 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
7696 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7697 WIPHY_VENDOR_CMD_NEED_NETDEV |
7698 WIPHY_VENDOR_CMD_NEED_RUNNING,
7699 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307700 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05307701};
7702
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007703/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307704static const
7705struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007706{
7707#ifdef FEATURE_WLAN_CH_AVOID
7708 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307709 .vendor_id = QCA_NL80211_VENDOR_ID,
7710 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007711 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307712#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7713#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7714 {
7715 /* Index = 1*/
7716 .vendor_id = QCA_NL80211_VENDOR_ID,
7717 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7718 },
7719 {
7720 /* Index = 2*/
7721 .vendor_id = QCA_NL80211_VENDOR_ID,
7722 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7723 },
7724 {
7725 /* Index = 3*/
7726 .vendor_id = QCA_NL80211_VENDOR_ID,
7727 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7728 },
7729 {
7730 /* Index = 4*/
7731 .vendor_id = QCA_NL80211_VENDOR_ID,
7732 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7733 },
7734 {
7735 /* Index = 5*/
7736 .vendor_id = QCA_NL80211_VENDOR_ID,
7737 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7738 },
7739 {
7740 /* Index = 6*/
7741 .vendor_id = QCA_NL80211_VENDOR_ID,
7742 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7743 },
7744#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307745#ifdef WLAN_FEATURE_EXTSCAN
7746 {
7747 .vendor_id = QCA_NL80211_VENDOR_ID,
7748 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7749 },
7750 {
7751 .vendor_id = QCA_NL80211_VENDOR_ID,
7752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7753 },
7754 {
7755 .vendor_id = QCA_NL80211_VENDOR_ID,
7756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7757 },
7758 {
7759 .vendor_id = QCA_NL80211_VENDOR_ID,
7760 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7761 },
7762 {
7763 .vendor_id = QCA_NL80211_VENDOR_ID,
7764 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7765 },
7766 {
7767 .vendor_id = QCA_NL80211_VENDOR_ID,
7768 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7769 },
7770 {
7771 .vendor_id = QCA_NL80211_VENDOR_ID,
7772 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7773 },
7774 {
7775 .vendor_id = QCA_NL80211_VENDOR_ID,
7776 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7777 },
7778 {
7779 .vendor_id = QCA_NL80211_VENDOR_ID,
7780 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7781 },
7782 {
7783 .vendor_id = QCA_NL80211_VENDOR_ID,
7784 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7785 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307786 {
7787 .vendor_id = QCA_NL80211_VENDOR_ID,
7788 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
7789 },
7790 {
7791 .vendor_id = QCA_NL80211_VENDOR_ID,
7792 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
7793 },
7794 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
7795 .vendor_id = QCA_NL80211_VENDOR_ID,
7796 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
7797 },
7798 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
7799 .vendor_id = QCA_NL80211_VENDOR_ID,
7800 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
7801 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307802#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307803/*EXT TDLS*/
7804 {
7805 .vendor_id = QCA_NL80211_VENDOR_ID,
7806 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7807 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307808 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7809 .vendor_id = QCA_NL80211_VENDOR_ID,
7810 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7811 },
7812
Srinivas Dasari030bad32015-02-18 23:23:54 +05307813
7814 {
7815 .vendor_id = QCA_NL80211_VENDOR_ID,
7816 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7817 },
7818
Sushant Kaushik084f6592015-09-10 13:11:56 +05307819 {
7820 .vendor_id = QCA_NL80211_VENDOR_ID,
7821 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307822 },
7823 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7824 .vendor_id = QCA_NL80211_VENDOR_ID,
7825 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7826 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05307827 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
7828 .vendor_id = QCA_NL80211_VENDOR_ID,
7829 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
7830 },
Sushant Kaushik084f6592015-09-10 13:11:56 +05307831
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007832};
7833
Jeff Johnson295189b2012-06-20 16:38:30 -07007834/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307835 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307836 * This function is called by hdd_wlan_startup()
7837 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307838 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307840struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007841{
7842 struct wiphy *wiphy;
7843 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307844 /*
7845 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 */
7847 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7848
7849 if (!wiphy)
7850 {
7851 /* Print error and jump into err label and free the memory */
7852 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7853 return NULL;
7854 }
7855
Sunil Duttc69bccb2014-05-26 21:30:20 +05307856
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 return wiphy;
7858}
7859
Anurag Chouhan343af7e2016-12-16 13:11:19 +05307860#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
7861 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
7862/**
7863 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
7864 * @wiphy: pointer to wiphy
7865 * @config: pointer to config
7866 *
7867 * Return: None
7868 */
7869static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
7870 hdd_config_t *config)
7871{
7872 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
7873 if (config->max_sched_scan_plan_interval)
7874 wiphy->max_sched_scan_plan_interval =
7875 config->max_sched_scan_plan_interval;
7876 if (config->max_sched_scan_plan_iterations)
7877 wiphy->max_sched_scan_plan_iterations =
7878 config->max_sched_scan_plan_iterations;
7879}
7880#else
7881static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
7882 hdd_config_t *config)
7883{
7884}
7885#endif
7886
Jeff Johnson295189b2012-06-20 16:38:30 -07007887/*
7888 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307889 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 * private ioctl to change the band value
7891 */
7892int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7893{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307894 int i, j;
7895 eNVChannelEnabledType channelEnabledState;
7896
Jeff Johnsone7245742012-09-05 17:12:55 -07007897 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307898
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307899 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307901
7902 if (NULL == wiphy->bands[i])
7903 {
7904 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7905 __func__, i);
7906 continue;
7907 }
7908
7909 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7910 {
7911 struct ieee80211_supported_band *band = wiphy->bands[i];
7912
7913 channelEnabledState = vos_nv_getChannelEnabledState(
7914 band->channels[j].hw_value);
7915
7916 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7917 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307918 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307919 continue;
7920 }
7921 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7922 {
7923 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7924 continue;
7925 }
7926
7927 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7928 NV_CHANNEL_INVALID == channelEnabledState)
7929 {
7930 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7931 }
7932 else if (NV_CHANNEL_DFS == channelEnabledState)
7933 {
7934 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7935 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7936 }
7937 else
7938 {
7939 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7940 |IEEE80211_CHAN_RADAR);
7941 }
7942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 }
7944 return 0;
7945}
7946/*
7947 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307948 * This function is called by hdd_wlan_startup()
7949 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 * This function is used to initialize and register wiphy structure.
7951 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307952int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 struct wiphy *wiphy,
7954 hdd_config_t *pCfg
7955 )
7956{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307957 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307958 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7959
Jeff Johnsone7245742012-09-05 17:12:55 -07007960 ENTER();
7961
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 /* Now bind the underlying wlan device with wiphy */
7963 set_wiphy_dev(wiphy, dev);
7964
7965 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007966
Kiet Lam6c583332013-10-14 05:37:09 +05307967#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007968 /* the flag for the other case would be initialzed in
7969 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05307970#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7971 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
7972#else
Amar Singhal0a402232013-10-11 20:57:16 -07007973 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307974#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05307975#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007976
Amar Singhalfddc28c2013-09-05 13:03:40 -07007977 /* This will disable updating of NL channels from passive to
7978 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307979#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7980 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7981#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007982 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307983#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007984
Amar Singhala49cbc52013-10-08 18:37:44 -07007985
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007986#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007987 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7988 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7989 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007990 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307991#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05307992 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307993#else
7994 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7995#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007996#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007997
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007998#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007999 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08008000#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008001 || pCfg->isFastRoamIniFeatureEnabled
8002#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008003#ifdef FEATURE_WLAN_ESE
8004 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008005#endif
8006 )
8007 {
8008 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
8009 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08008010#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008011#ifdef FEATURE_WLAN_TDLS
8012 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
8013 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
8014#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308015#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05308016 if (pCfg->configPNOScanSupport)
8017 {
8018 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
8019 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
8020 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
8021 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
8022 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308023#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008024
Abhishek Singh10d85972015-04-17 10:27:23 +05308025#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8026 wiphy->features |= NL80211_FEATURE_HT_IBSS;
8027#endif
8028
Amar Singhalfddc28c2013-09-05 13:03:40 -07008029#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008030 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
8031 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07008032 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008033 driver need to determine what to do with both
8034 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07008035
8036 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07008037#else
8038 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07008039#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008040
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308041 wiphy->max_scan_ssids = MAX_SCAN_SSID;
8042
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05308043 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07008044
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308045 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
8046
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05308048 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
8049 | BIT(NL80211_IFTYPE_ADHOC)
8050 | BIT(NL80211_IFTYPE_P2P_CLIENT)
8051 | BIT(NL80211_IFTYPE_P2P_GO)
8052 | BIT(NL80211_IFTYPE_AP);
8053
8054 if (VOS_MONITOR_MODE == hdd_get_conparam())
8055 {
8056 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
8057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008058
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308059 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008060 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308061#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8062 if( pCfg->enableMCC )
8063 {
8064 /* Currently, supports up to two channels */
8065 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008066
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308067 if( !pCfg->allowMCCGODiffBI )
8068 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008069
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308070 }
8071 wiphy->iface_combinations = &wlan_hdd_iface_combination;
8072 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008073#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308074 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008075
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 /* Before registering we need to update the ht capabilitied based
8077 * on ini values*/
8078 if( !pCfg->ShortGI20MhzEnable )
8079 {
8080 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8081 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 }
8083
8084 if( !pCfg->ShortGI40MhzEnable )
8085 {
8086 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8087 }
8088
8089 if( !pCfg->nChannelBondingMode5GHz )
8090 {
8091 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8092 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308093 /*
8094 * In case of static linked driver at the time of driver unload,
8095 * module exit doesn't happens. Module cleanup helps in cleaning
8096 * of static memory.
8097 * If driver load happens statically, at the time of driver unload,
8098 * wiphy flags don't get reset because of static memory.
8099 * It's better not to store channel in static memory.
8100 */
8101 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8102 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8103 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8104 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8105 {
8106 hddLog(VOS_TRACE_LEVEL_ERROR,
8107 FL("Not enough memory to allocate channels"));
8108 return -ENOMEM;
8109 }
8110 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8111 &hdd_channels_2_4_GHZ[0],
8112 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008113
Agrawal Ashish97dec502015-11-26 20:20:58 +05308114 if (true == hdd_is_5g_supported(pHddCtx))
8115 {
8116 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8117 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8118 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8119 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8120 {
8121 hddLog(VOS_TRACE_LEVEL_ERROR,
8122 FL("Not enough memory to allocate channels"));
8123 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8124 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8125 return -ENOMEM;
8126 }
8127 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8128 &hdd_channels_5_GHZ[0],
8129 sizeof(hdd_channels_5_GHZ));
8130 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308131
8132 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8133 {
8134
8135 if (NULL == wiphy->bands[i])
8136 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308137 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308138 __func__, i);
8139 continue;
8140 }
8141
8142 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8143 {
8144 struct ieee80211_supported_band *band = wiphy->bands[i];
8145
8146 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8147 {
8148 // Enable social channels for P2P
8149 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8150 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8151 else
8152 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8153 continue;
8154 }
8155 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8156 {
8157 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8158 continue;
8159 }
8160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 }
8162 /*Initialise the supported cipher suite details*/
8163 wiphy->cipher_suites = hdd_cipher_suites;
8164 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8165
8166 /*signal strength in mBm (100*dBm) */
8167 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8168
8169#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308170 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008171#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008172
Sunil Duttc69bccb2014-05-26 21:30:20 +05308173 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8174 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008175 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8176 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8177
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308178 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
8179
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308180 EXIT();
8181 return 0;
8182}
8183
8184/* In this function we are registering wiphy. */
8185int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8186{
8187 ENTER();
8188 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 if (0 > wiphy_register(wiphy))
8190 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308191 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008192 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8193 return -EIO;
8194 }
8195
8196 EXIT();
8197 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308198}
Jeff Johnson295189b2012-06-20 16:38:30 -07008199
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308200/* In this function we are updating channel list when,
8201 regulatory domain is FCC and country code is US.
8202 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8203 As per FCC smart phone is not a indoor device.
8204 GO should not opeate on indoor channels */
8205void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8206{
8207 int j;
8208 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8209 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8210 //Default counrtycode from NV at the time of wiphy initialization.
8211 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8212 &defaultCountryCode[0]))
8213 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008214 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308215 }
8216 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8217 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308218 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8219 {
8220 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8221 return;
8222 }
8223 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8224 {
8225 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8226 // Mark UNII -1 band channel as passive
8227 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8228 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8229 }
8230 }
8231}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308232/* This function registers for all frame which supplicant is interested in */
8233void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008234{
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8236 /* Register for all P2P action, public action etc frames */
8237 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008238 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308239 /* Register frame indication call back */
8240 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 /* Right now we are registering these frame when driver is getting
8242 initialized. Once we will move to 2.6.37 kernel, in which we have
8243 frame register ops, we will move this code as a part of that */
8244 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308245 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8247
8248 /* GAS Initial Response */
8249 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8250 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308251
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 /* GAS Comeback Request */
8253 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8254 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8255
8256 /* GAS Comeback Response */
8257 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8258 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8259
8260 /* P2P Public Action */
8261 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308262 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 P2P_PUBLIC_ACTION_FRAME_SIZE );
8264
8265 /* P2P Action */
8266 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8267 (v_U8_t*)P2P_ACTION_FRAME,
8268 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008269
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308270 /* WNM BSS Transition Request frame */
8271 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8272 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8273 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008274
8275 /* WNM-Notification */
8276 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8277 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8278 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008279}
8280
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308281void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008282{
Jeff Johnson295189b2012-06-20 16:38:30 -07008283 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8284 /* Register for all P2P action, public action etc frames */
8285 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8286
Jeff Johnsone7245742012-09-05 17:12:55 -07008287 ENTER();
8288
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 /* Right now we are registering these frame when driver is getting
8290 initialized. Once we will move to 2.6.37 kernel, in which we have
8291 frame register ops, we will move this code as a part of that */
8292 /* GAS Initial Request */
8293
8294 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8295 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8296
8297 /* GAS Initial Response */
8298 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8299 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308300
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 /* GAS Comeback Request */
8302 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8303 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8304
8305 /* GAS Comeback Response */
8306 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8307 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8308
8309 /* P2P Public Action */
8310 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308311 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 P2P_PUBLIC_ACTION_FRAME_SIZE );
8313
8314 /* P2P Action */
8315 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8316 (v_U8_t*)P2P_ACTION_FRAME,
8317 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008318 /* WNM-Notification */
8319 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8320 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8321 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008322}
8323
8324#ifdef FEATURE_WLAN_WAPI
8325void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308326 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008327{
8328 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8329 tCsrRoamSetKey setKey;
8330 v_BOOL_t isConnected = TRUE;
8331 int status = 0;
8332 v_U32_t roamId= 0xFF;
8333 tANI_U8 *pKeyPtr = NULL;
8334 int n = 0;
8335
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308336 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8337 __func__, hdd_device_modetoString(pAdapter->device_mode),
8338 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008339
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308340 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 setKey.keyId = key_index; // Store Key ID
8342 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8343 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8344 setKey.paeRole = 0 ; // the PAE role
8345 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8346 {
8347 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8348 }
8349 else
8350 {
8351 isConnected = hdd_connIsConnected(pHddStaCtx);
8352 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8353 }
8354 setKey.keyLength = key_Len;
8355 pKeyPtr = setKey.Key;
8356 memcpy( pKeyPtr, key, key_Len);
8357
Arif Hussain6d2a3322013-11-17 19:50:10 -08008358 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 __func__, key_Len);
8360 for (n = 0 ; n < key_Len; n++)
8361 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8362 __func__,n,setKey.Key[n]);
8363
8364 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8365 if ( isConnected )
8366 {
8367 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8368 pAdapter->sessionId, &setKey, &roamId );
8369 }
8370 if ( status != 0 )
8371 {
8372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8373 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8374 __LINE__, status );
8375 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8376 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308377 /* Need to clear any trace of key value in the memory.
8378 * Thus zero out the memory even though it is local
8379 * variable.
8380 */
8381 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008382}
8383#endif /* FEATURE_WLAN_WAPI*/
8384
8385#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308386int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 beacon_data_t **ppBeacon,
8388 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008389#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308390int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008391 beacon_data_t **ppBeacon,
8392 struct cfg80211_beacon_data *params,
8393 int dtim_period)
8394#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308395{
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 int size;
8397 beacon_data_t *beacon = NULL;
8398 beacon_data_t *old = NULL;
8399 int head_len,tail_len;
8400
Jeff Johnsone7245742012-09-05 17:12:55 -07008401 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308403 {
8404 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8405 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008408
8409 old = pAdapter->sessionCtx.ap.beacon;
8410
8411 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308412 {
8413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8414 FL("session(%d) old and new heads points to NULL"),
8415 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308417 }
8418
8419 if (params->tail && !params->tail_len)
8420 {
8421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8422 FL("tail_len is zero but tail is not NULL"));
8423 return -EINVAL;
8424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008425
Jeff Johnson295189b2012-06-20 16:38:30 -07008426#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8427 /* Kernel 3.0 is not updating dtim_period for set beacon */
8428 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308429 {
8430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8431 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008434#endif
8435
8436 if(params->head)
8437 head_len = params->head_len;
8438 else
8439 head_len = old->head_len;
8440
8441 if(params->tail || !old)
8442 tail_len = params->tail_len;
8443 else
8444 tail_len = old->tail_len;
8445
8446 size = sizeof(beacon_data_t) + head_len + tail_len;
8447
8448 beacon = kzalloc(size, GFP_KERNEL);
8449
8450 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308451 {
8452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8453 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008456
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008457#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 if(params->dtim_period || !old )
8459 beacon->dtim_period = params->dtim_period;
8460 else
8461 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008462#else
8463 if(dtim_period || !old )
8464 beacon->dtim_period = dtim_period;
8465 else
8466 beacon->dtim_period = old->dtim_period;
8467#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308468
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8470 beacon->tail = beacon->head + head_len;
8471 beacon->head_len = head_len;
8472 beacon->tail_len = tail_len;
8473
8474 if(params->head) {
8475 memcpy (beacon->head,params->head,beacon->head_len);
8476 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308477 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 if(old)
8479 memcpy (beacon->head,old->head,beacon->head_len);
8480 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308481
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 if(params->tail) {
8483 memcpy (beacon->tail,params->tail,beacon->tail_len);
8484 }
8485 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308486 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 memcpy (beacon->tail,old->tail,beacon->tail_len);
8488 }
8489
8490 *ppBeacon = beacon;
8491
8492 kfree(old);
8493
8494 return 0;
8495
8496}
Jeff Johnson295189b2012-06-20 16:38:30 -07008497
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308498v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8499#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8500 const v_U8_t *pIes,
8501#else
8502 v_U8_t *pIes,
8503#endif
8504 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008505{
8506 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308507 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308509
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308511 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 elem_id = ptr[0];
8513 elem_len = ptr[1];
8514 left -= 2;
8515 if(elem_len > left)
8516 {
8517 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008518 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 eid,elem_len,left);
8520 return NULL;
8521 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308522 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 {
8524 return ptr;
8525 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308526
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 left -= elem_len;
8528 ptr += (elem_len + 2);
8529 }
8530 return NULL;
8531}
8532
Jeff Johnson295189b2012-06-20 16:38:30 -07008533/* Check if rate is 11g rate or not */
8534static int wlan_hdd_rate_is_11g(u8 rate)
8535{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008536 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 u8 i;
8538 for (i = 0; i < 8; i++)
8539 {
8540 if(rate == gRateArray[i])
8541 return TRUE;
8542 }
8543 return FALSE;
8544}
8545
8546/* Check for 11g rate and set proper 11g only mode */
8547static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8548 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8549{
8550 u8 i, num_rates = pIe[0];
8551
8552 pIe += 1;
8553 for ( i = 0; i < num_rates; i++)
8554 {
8555 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8556 {
8557 /* If rate set have 11g rate than change the mode to 11G */
8558 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8559 if (pIe[i] & BASIC_RATE_MASK)
8560 {
8561 /* If we have 11g rate as basic rate, it means mode
8562 is 11g only mode.
8563 */
8564 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8565 *pCheckRatesfor11g = FALSE;
8566 }
8567 }
8568 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8569 {
8570 *require_ht = TRUE;
8571 }
8572 }
8573 return;
8574}
8575
8576static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8577{
8578 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8579 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8580 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8581 u8 checkRatesfor11g = TRUE;
8582 u8 require_ht = FALSE;
8583 u8 *pIe=NULL;
8584
8585 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8586
8587 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8588 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8589 if (pIe != NULL)
8590 {
8591 pIe += 1;
8592 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8593 &pConfig->SapHw_mode);
8594 }
8595
8596 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8597 WLAN_EID_EXT_SUPP_RATES);
8598 if (pIe != NULL)
8599 {
8600
8601 pIe += 1;
8602 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8603 &pConfig->SapHw_mode);
8604 }
8605
8606 if( pConfig->channel > 14 )
8607 {
8608 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8609 }
8610
8611 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8612 WLAN_EID_HT_CAPABILITY);
8613
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308614 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 {
8616 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8617 if(require_ht)
8618 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8619 }
8620}
8621
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308622static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8623 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8624{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008625 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308626 v_U8_t *pIe = NULL;
8627 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8628
8629 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8630 pBeacon->tail, pBeacon->tail_len);
8631
8632 if (pIe)
8633 {
8634 ielen = pIe[1] + 2;
8635 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8636 {
8637 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8638 }
8639 else
8640 {
8641 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8642 return -EINVAL;
8643 }
8644 *total_ielen += ielen;
8645 }
8646 return 0;
8647}
8648
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008649static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8650 v_U8_t *genie, v_U8_t *total_ielen)
8651{
8652 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8653 int left = pBeacon->tail_len;
8654 v_U8_t *ptr = pBeacon->tail;
8655 v_U8_t elem_id, elem_len;
8656 v_U16_t ielen = 0;
8657
8658 if ( NULL == ptr || 0 == left )
8659 return;
8660
8661 while (left >= 2)
8662 {
8663 elem_id = ptr[0];
8664 elem_len = ptr[1];
8665 left -= 2;
8666 if (elem_len > left)
8667 {
8668 hddLog( VOS_TRACE_LEVEL_ERROR,
8669 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8670 elem_id, elem_len, left);
8671 return;
8672 }
8673 if (IE_EID_VENDOR == elem_id)
8674 {
8675 /* skipping the VSIE's which we don't want to include or
8676 * it will be included by existing code
8677 */
8678 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8679#ifdef WLAN_FEATURE_WFD
8680 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8681#endif
8682 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8683 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8684 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8685 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8686 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8687 {
8688 ielen = ptr[1] + 2;
8689 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8690 {
8691 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8692 *total_ielen += ielen;
8693 }
8694 else
8695 {
8696 hddLog( VOS_TRACE_LEVEL_ERROR,
8697 "IE Length is too big "
8698 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8699 elem_id, elem_len, *total_ielen);
8700 }
8701 }
8702 }
8703
8704 left -= elem_len;
8705 ptr += (elem_len + 2);
8706 }
8707 return;
8708}
8709
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008710#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008711static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8712 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008713#else
8714static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8715 struct cfg80211_beacon_data *params)
8716#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008717{
8718 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308719 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008721 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008722
8723 genie = vos_mem_malloc(MAX_GENIE_LEN);
8724
8725 if(genie == NULL) {
8726
8727 return -ENOMEM;
8728 }
8729
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308730 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8731 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308733 hddLog(LOGE,
8734 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308735 ret = -EINVAL;
8736 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 }
8738
8739#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308740 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8741 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8742 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308743 hddLog(LOGE,
8744 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308745 ret = -EINVAL;
8746 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 }
8748#endif
8749
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308750 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8751 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308753 hddLog(LOGE,
8754 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308755 ret = -EINVAL;
8756 goto done;
8757 }
8758
8759 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8760 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008761 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008763
8764 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8765 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8766 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8767 {
8768 hddLog(LOGE,
8769 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008770 ret = -EINVAL;
8771 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 }
8773
8774 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8775 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8776 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8777 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8778 ==eHAL_STATUS_FAILURE)
8779 {
8780 hddLog(LOGE,
8781 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008782 ret = -EINVAL;
8783 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 }
8785
8786 // Added for ProResp IE
8787 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
8788 {
8789 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
8790 u8 probe_rsp_ie_len[3] = {0};
8791 u8 counter = 0;
8792 /* Check Probe Resp Length if it is greater then 255 then Store
8793 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8794 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8795 Store More then 255 bytes into One Variable.
8796 */
8797 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8798 {
8799 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8800 {
8801 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8802 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8803 }
8804 else
8805 {
8806 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8807 rem_probe_resp_ie_len = 0;
8808 }
8809 }
8810
8811 rem_probe_resp_ie_len = 0;
8812
8813 if (probe_rsp_ie_len[0] > 0)
8814 {
8815 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8816 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
8817 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8818 probe_rsp_ie_len[0], NULL,
8819 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8820 {
8821 hddLog(LOGE,
8822 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008823 ret = -EINVAL;
8824 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 }
8826 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8827 }
8828
8829 if (probe_rsp_ie_len[1] > 0)
8830 {
8831 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8832 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
8833 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8834 probe_rsp_ie_len[1], NULL,
8835 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8836 {
8837 hddLog(LOGE,
8838 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008839 ret = -EINVAL;
8840 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 }
8842 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8843 }
8844
8845 if (probe_rsp_ie_len[2] > 0)
8846 {
8847 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8848 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
8849 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8850 probe_rsp_ie_len[2], NULL,
8851 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8852 {
8853 hddLog(LOGE,
8854 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008855 ret = -EINVAL;
8856 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 }
8858 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8859 }
8860
8861 if (probe_rsp_ie_len[1] == 0 )
8862 {
8863 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8864 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8865 eANI_BOOLEAN_FALSE) )
8866 {
8867 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008868 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 }
8870 }
8871
8872 if (probe_rsp_ie_len[2] == 0 )
8873 {
8874 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8875 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8876 eANI_BOOLEAN_FALSE) )
8877 {
8878 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008879 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 }
8881 }
8882
8883 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8884 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8885 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8886 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8887 == eHAL_STATUS_FAILURE)
8888 {
8889 hddLog(LOGE,
8890 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008891 ret = -EINVAL;
8892 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 }
8894 }
8895 else
8896 {
8897 // Reset WNI_CFG_PROBE_RSP Flags
8898 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8899
8900 hddLog(VOS_TRACE_LEVEL_INFO,
8901 "%s: No Probe Response IE received in set beacon",
8902 __func__);
8903 }
8904
8905 // Added for AssocResp IE
8906 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
8907 {
8908 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8909 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
8910 params->assocresp_ies_len, NULL,
8911 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8912 {
8913 hddLog(LOGE,
8914 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008915 ret = -EINVAL;
8916 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 }
8918
8919 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8920 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8921 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8922 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8923 == eHAL_STATUS_FAILURE)
8924 {
8925 hddLog(LOGE,
8926 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008927 ret = -EINVAL;
8928 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 }
8930 }
8931 else
8932 {
8933 hddLog(VOS_TRACE_LEVEL_INFO,
8934 "%s: No Assoc Response IE received in set beacon",
8935 __func__);
8936
8937 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8938 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8939 eANI_BOOLEAN_FALSE) )
8940 {
8941 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008942 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 }
8944 }
8945
Jeff Johnsone7245742012-09-05 17:12:55 -07008946done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308948 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008949}
Jeff Johnson295189b2012-06-20 16:38:30 -07008950
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308951/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008952 * FUNCTION: wlan_hdd_validate_operation_channel
8953 * called by wlan_hdd_cfg80211_start_bss() and
8954 * wlan_hdd_cfg80211_set_channel()
8955 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308956 * channel list.
8957 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008958VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008959{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308960
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 v_U32_t num_ch = 0;
8962 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8963 u32 indx = 0;
8964 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308965 v_U8_t fValidChannel = FALSE, count = 0;
8966 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308967
Jeff Johnson295189b2012-06-20 16:38:30 -07008968 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8969
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308970 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008971 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308972 /* Validate the channel */
8973 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308975 if ( channel == rfChannels[count].channelNum )
8976 {
8977 fValidChannel = TRUE;
8978 break;
8979 }
8980 }
8981 if (fValidChannel != TRUE)
8982 {
8983 hddLog(VOS_TRACE_LEVEL_ERROR,
8984 "%s: Invalid Channel [%d]", __func__, channel);
8985 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 }
8987 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308988 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308990 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8991 valid_ch, &num_ch))
8992 {
8993 hddLog(VOS_TRACE_LEVEL_ERROR,
8994 "%s: failed to get valid channel list", __func__);
8995 return VOS_STATUS_E_FAILURE;
8996 }
8997 for (indx = 0; indx < num_ch; indx++)
8998 {
8999 if (channel == valid_ch[indx])
9000 {
9001 break;
9002 }
9003 }
9004
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309005 if (indx >= num_ch)
9006 {
9007 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9008 {
9009 eCsrBand band;
9010 unsigned int freq;
9011
9012 sme_GetFreqBand(hHal, &band);
9013
9014 if (eCSR_BAND_5G == band)
9015 {
9016#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9017 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9018 {
9019 freq = ieee80211_channel_to_frequency(channel,
9020 IEEE80211_BAND_2GHZ);
9021 }
9022 else
9023 {
9024 freq = ieee80211_channel_to_frequency(channel,
9025 IEEE80211_BAND_5GHZ);
9026 }
9027#else
9028 freq = ieee80211_channel_to_frequency(channel);
9029#endif
9030 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
9031 return VOS_STATUS_SUCCESS;
9032 }
9033 }
9034
9035 hddLog(VOS_TRACE_LEVEL_ERROR,
9036 "%s: Invalid Channel [%d]", __func__, channel);
9037 return VOS_STATUS_E_FAILURE;
9038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309040
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309042
Jeff Johnson295189b2012-06-20 16:38:30 -07009043}
9044
Viral Modi3a32cc52013-02-08 11:14:52 -08009045/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309046 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08009047 * This function is used to set the channel number
9048 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309049static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08009050 struct ieee80211_channel *chan,
9051 enum nl80211_channel_type channel_type
9052 )
9053{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309054 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08009055 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07009056 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08009057 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309058 hdd_context_t *pHddCtx;
9059 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009060
9061 ENTER();
9062
9063 if( NULL == dev )
9064 {
9065 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009066 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009067 return -ENODEV;
9068 }
9069 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309070
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309071 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9072 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9073 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009074 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309075 "%s: device_mode = %s (%d) freq = %d", __func__,
9076 hdd_device_modetoString(pAdapter->device_mode),
9077 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309078
9079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9080 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309081 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009082 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309083 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009084 }
9085
9086 /*
9087 * Do freq to chan conversion
9088 * TODO: for 11a
9089 */
9090
9091 channel = ieee80211_frequency_to_channel(freq);
9092
9093 /* Check freq range */
9094 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9095 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9096 {
9097 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009098 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009099 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9100 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9101 return -EINVAL;
9102 }
9103
9104 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9105
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309106 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9107 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009108 {
9109 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9110 {
9111 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009112 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009113 return -EINVAL;
9114 }
9115 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9116 "%s: set channel to [%d] for device mode =%d",
9117 __func__, channel,pAdapter->device_mode);
9118 }
9119 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009120 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009121 )
9122 {
9123 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9124 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9125 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9126
9127 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9128 {
9129 /* Link is up then return cant set channel*/
9130 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009131 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009132 return -EINVAL;
9133 }
9134
9135 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9136 pHddStaCtx->conn_info.operationChannel = channel;
9137 pRoamProfile->ChannelInfo.ChannelList =
9138 &pHddStaCtx->conn_info.operationChannel;
9139 }
9140 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009141 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009142 )
9143 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309144 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9145 {
9146 if(VOS_STATUS_SUCCESS !=
9147 wlan_hdd_validate_operation_channel(pAdapter,channel))
9148 {
9149 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009150 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309151 return -EINVAL;
9152 }
9153 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9154 }
9155 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009156 {
9157 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9158
9159 /* If auto channel selection is configured as enable/ 1 then ignore
9160 channel set by supplicant
9161 */
9162 if ( cfg_param->apAutoChannelSelection )
9163 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309164 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9165 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009166 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309167 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9168 __func__, hdd_device_modetoString(pAdapter->device_mode),
9169 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009170 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309171 else
9172 {
9173 if(VOS_STATUS_SUCCESS !=
9174 wlan_hdd_validate_operation_channel(pAdapter,channel))
9175 {
9176 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009177 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309178 return -EINVAL;
9179 }
9180 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9181 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009182 }
9183 }
9184 else
9185 {
9186 hddLog(VOS_TRACE_LEVEL_FATAL,
9187 "%s: Invalid device mode failed to set valid channel", __func__);
9188 return -EINVAL;
9189 }
9190 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309191 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009192}
9193
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309194static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9195 struct net_device *dev,
9196 struct ieee80211_channel *chan,
9197 enum nl80211_channel_type channel_type
9198 )
9199{
9200 int ret;
9201
9202 vos_ssr_protect(__func__);
9203 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9204 vos_ssr_unprotect(__func__);
9205
9206 return ret;
9207}
9208
Anurag Chouhan83026002016-12-13 22:46:21 +05309209#ifdef DHCP_SERVER_OFFLOAD
9210void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
9211 VOS_STATUS status)
9212{
9213 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
9214
9215 ENTER();
9216
9217 if (NULL == adapter)
9218 {
9219 hddLog(VOS_TRACE_LEVEL_ERROR,
9220 "%s: adapter is NULL",__func__);
9221 return;
9222 }
9223
9224 adapter->dhcp_status.dhcp_offload_status = status;
9225 vos_event_set(&adapter->dhcp_status.vos_event);
9226 return;
9227}
9228
9229/**
9230 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
9231 * @hostapd_adapter: pointer to hostapd adapter.
9232 *
9233 * Return: None
9234 */
9235static VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter)
9236{
9237 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
9238 sir_dhcp_srv_offload_info dhcp_srv_info;
9239 tANI_U8 num_entries = 0;
9240 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
9241 tANI_U8 num;
9242 tANI_U32 temp;
9243 VOS_STATUS ret;
9244
9245 ENTER();
9246
9247 ret = wlan_hdd_validate_context(hdd_ctx);
9248 if (0 != ret)
9249 return VOS_STATUS_E_INVAL;
9250
9251 /* Prepare the request to send to SME */
9252 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
9253 if (NULL == dhcp_srv_info) {
9254 hddLog(VOS_TRACE_LEVEL_ERROR,
9255 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
9256 return VOS_STATUS_E_NOMEM;
9257 }
9258
9259 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
9260
9261 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
9262 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
9263 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
9264 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
9265 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
9266 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
9267
9268 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
9269 srv_ip,
9270 &num_entries,
Anurag Chouhanac145c22016-11-22 16:51:47 +05309271 IPADDR_NUM_ENTRIES, ".");
Anurag Chouhan83026002016-12-13 22:46:21 +05309272 if (num_entries != IPADDR_NUM_ENTRIES) {
9273 hddLog(VOS_TRACE_LEVEL_ERROR,
9274 "%s: incorrect IP address (%s) assigned for DHCP server!",
9275 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9276 vos_mem_free(dhcp_srv_info);
9277 return VOS_STATUS_E_FAILURE;
9278 }
9279
9280 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
9281 hddLog(VOS_TRACE_LEVEL_ERROR,
9282 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
9283 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9284 vos_mem_free(dhcp_srv_info);
9285 return VOS_STATUS_E_FAILURE;
9286 }
9287
9288 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
9289 hddLog(VOS_TRACE_LEVEL_ERROR,
9290 "%s: invalid IP address (%s)! The last field must be less than 100!",
9291 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9292 vos_mem_free(dhcp_srv_info);
9293 return VOS_STATUS_E_FAILURE;
9294 }
9295
9296 for (num = 0; num < num_entries; num++) {
9297 temp = srv_ip[num];
9298 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
9299 }
9300
9301 if (eHAL_STATUS_SUCCESS !=
9302 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
9303 hddLog(VOS_TRACE_LEVEL_ERROR,
9304 "%s: sme_set_dhcp_srv_offload fail!", __func__);
9305 vos_mem_free(dhcp_srv_info);
9306 return VOS_STATUS_E_FAILURE;
9307 }
9308
9309 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9310 "%s: enable DHCP Server offload successfully!", __func__);
9311
9312 vos_mem_free(dhcp_srv_info);
9313 return 0;
9314}
9315#endif /* DHCP_SERVER_OFFLOAD */
9316
Jeff Johnson295189b2012-06-20 16:38:30 -07009317#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9318static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9319 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009320#else
9321static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9322 struct cfg80211_beacon_data *params,
9323 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309324 enum nl80211_hidden_ssid hidden_ssid,
9325 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009326#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009327{
9328 tsap_Config_t *pConfig;
9329 beacon_data_t *pBeacon = NULL;
9330 struct ieee80211_mgmt *pMgmt_frame;
9331 v_U8_t *pIe=NULL;
9332 v_U16_t capab_info;
9333 eCsrAuthType RSNAuthType;
9334 eCsrEncryptionType RSNEncryptType;
9335 eCsrEncryptionType mcRSNEncryptType;
9336 int status = VOS_STATUS_SUCCESS;
9337 tpWLAN_SAPEventCB pSapEventCallback;
9338 hdd_hostapd_state_t *pHostapdState;
9339 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
9340 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309341 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309343 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009345 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309346 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009347 v_BOOL_t MFPCapable = VOS_FALSE;
9348 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309349 v_BOOL_t sapEnable11AC =
9350 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 ENTER();
9352
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309353 iniConfig = pHddCtx->cfg_ini;
9354
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9356
9357 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9358
9359 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9360
9361 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9362
9363 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9364
9365 //channel is already set in the set_channel Call back
9366 //pConfig->channel = pCommitConfig->channel;
9367
9368 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309369 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9371
9372 pConfig->dtim_period = pBeacon->dtim_period;
9373
Arif Hussain6d2a3322013-11-17 19:50:10 -08009374 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 pConfig->dtim_period);
9376
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009377 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009378 {
9379 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309381 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9382 {
9383 tANI_BOOLEAN restartNeeded;
9384 pConfig->ieee80211d = 1;
9385 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9386 sme_setRegInfo(hHal, pConfig->countryCode);
9387 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9388 }
9389 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009390 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009391 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009392 pConfig->ieee80211d = 1;
9393 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9394 sme_setRegInfo(hHal, pConfig->countryCode);
9395 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009396 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009397 else
9398 {
9399 pConfig->ieee80211d = 0;
9400 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309401 /*
9402 * If auto channel is configured i.e. channel is 0,
9403 * so skip channel validation.
9404 */
9405 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9406 {
9407 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9408 {
9409 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009410 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309411 return -EINVAL;
9412 }
9413 }
9414 else
9415 {
9416 if(1 != pHddCtx->is_dynamic_channel_range_set)
9417 {
9418 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9419 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9420 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9421 }
9422 pHddCtx->is_dynamic_channel_range_set = 0;
9423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009425 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 {
9427 pConfig->ieee80211d = 0;
9428 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309429
9430#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9431 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9432 pConfig->authType = eSAP_OPEN_SYSTEM;
9433 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9434 pConfig->authType = eSAP_SHARED_KEY;
9435 else
9436 pConfig->authType = eSAP_AUTO_SWITCH;
9437#else
9438 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9439 pConfig->authType = eSAP_OPEN_SYSTEM;
9440 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9441 pConfig->authType = eSAP_SHARED_KEY;
9442 else
9443 pConfig->authType = eSAP_AUTO_SWITCH;
9444#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009445
9446 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309447
9448 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05309450#ifdef SAP_AUTH_OFFLOAD
9451 /* In case of sap offload, hostapd.conf is configuted with open mode and
9452 * security is configured from ini file. Due to open mode in hostapd.conf
9453 * privacy bit is set to false which will result in not sending,
9454 * data packets as encrypted.
9455 * If enable_sap_auth_offload is enabled in ini and
9456 * sap_auth_offload_sec_type is type of WPA2-PSK,
9457 * driver will set privacy bit to 1.
9458 */
9459 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
9460 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
9461 pConfig->privacy = VOS_TRUE;
9462#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009463
9464 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9465
9466 /*Set wps station to configured*/
9467 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9468
9469 if(pIe)
9470 {
9471 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9472 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009473 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 return -EINVAL;
9475 }
9476 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9477 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009478 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 /* Check 15 bit of WPS IE as it contain information for wps state
9480 * WPS state
9481 */
9482 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9483 {
9484 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9485 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9486 {
9487 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9488 }
9489 }
9490 }
9491 else
9492 {
9493 pConfig->wps_state = SAP_WPS_DISABLED;
9494 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309495 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009496
c_hpothufe599e92014-06-16 11:38:55 +05309497 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9498 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9499 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9500 eCSR_ENCRYPT_TYPE_NONE;
9501
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 pConfig->RSNWPAReqIELength = 0;
9503 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309504 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 WLAN_EID_RSN);
9506 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309507 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009508 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9509 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9510 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309511 /* The actual processing may eventually be more extensive than
9512 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 * by the app.
9514 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309515 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9517 &RSNEncryptType,
9518 &mcRSNEncryptType,
9519 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009520 &MFPCapable,
9521 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 pConfig->pRSNWPAReqIE[1]+2,
9523 pConfig->pRSNWPAReqIE );
9524
9525 if( VOS_STATUS_SUCCESS == status )
9526 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309527 /* Now copy over all the security attributes you have
9528 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 * */
9530 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9531 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9532 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9533 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309534 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009535 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9537 }
9538 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309539
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9541 pBeacon->tail, pBeacon->tail_len);
9542
9543 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9544 {
9545 if (pConfig->pRSNWPAReqIE)
9546 {
9547 /*Mixed mode WPA/WPA2*/
9548 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
9549 pConfig->RSNWPAReqIELength += pIe[1] + 2;
9550 }
9551 else
9552 {
9553 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9554 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9555 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309556 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9558 &RSNEncryptType,
9559 &mcRSNEncryptType,
9560 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009561 &MFPCapable,
9562 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 pConfig->pRSNWPAReqIE[1]+2,
9564 pConfig->pRSNWPAReqIE );
9565
9566 if( VOS_STATUS_SUCCESS == status )
9567 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309568 /* Now copy over all the security attributes you have
9569 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 * */
9571 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9572 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9573 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9574 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309575 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009576 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9578 }
9579 }
9580 }
9581
Jeff Johnson4416a782013-03-25 14:17:50 -07009582 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
9583 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9584 return -EINVAL;
9585 }
9586
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9588
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009589#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 if (params->ssid != NULL)
9591 {
9592 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9593 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9594 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9595 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9596 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009597#else
9598 if (ssid != NULL)
9599 {
9600 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9601 pConfig->SSIDinfo.ssid.length = ssid_len;
9602 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9603 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9604 }
9605#endif
9606
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309607 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009608 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309609
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 /* default value */
9611 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9612 pConfig->num_accept_mac = 0;
9613 pConfig->num_deny_mac = 0;
9614
9615 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9616 pBeacon->tail, pBeacon->tail_len);
9617
9618 /* pIe for black list is following form:
9619 type : 1 byte
9620 length : 1 byte
9621 OUI : 4 bytes
9622 acl type : 1 byte
9623 no of mac addr in black list: 1 byte
9624 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309625 */
9626 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 {
9628 pConfig->SapMacaddr_acl = pIe[6];
9629 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009630 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009631 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309632 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9633 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9635 for (i = 0; i < pConfig->num_deny_mac; i++)
9636 {
9637 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9638 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 }
9641 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9642 pBeacon->tail, pBeacon->tail_len);
9643
9644 /* pIe for white list is following form:
9645 type : 1 byte
9646 length : 1 byte
9647 OUI : 4 bytes
9648 acl type : 1 byte
9649 no of mac addr in white list: 1 byte
9650 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309651 */
9652 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 {
9654 pConfig->SapMacaddr_acl = pIe[6];
9655 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009656 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309658 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9659 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9661 for (i = 0; i < pConfig->num_accept_mac; i++)
9662 {
9663 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9664 acl_entry++;
9665 }
9666 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309667
Jeff Johnson295189b2012-06-20 16:38:30 -07009668 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9669
Jeff Johnsone7245742012-09-05 17:12:55 -07009670#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009671 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309672 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9673 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309674 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9675 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009676 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9677 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309678 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9679 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009680 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309681 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009682 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309683 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009684
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309685 /* If ACS disable and selected channel <= 14
9686 * OR
9687 * ACS enabled and ACS operating band is choosen as 2.4
9688 * AND
9689 * VHT in 2.4G Disabled
9690 * THEN
9691 * Fallback to 11N mode
9692 */
9693 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9694 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309695 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309696 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009697 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309698 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9699 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009700 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9701 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009702 }
9703#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309704
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 // ht_capab is not what the name conveys,this is used for protection bitmap
9706 pConfig->ht_capab =
9707 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9708
9709 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9710 {
9711 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9712 return -EINVAL;
9713 }
9714
9715 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309716 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9718 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309719 pConfig->obssProtEnabled =
9720 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009721
Chet Lanctot8cecea22014-02-11 19:09:36 -08009722#ifdef WLAN_FEATURE_11W
9723 pConfig->mfpCapable = MFPCapable;
9724 pConfig->mfpRequired = MFPRequired;
9725 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9726 pConfig->mfpCapable, pConfig->mfpRequired);
9727#endif
9728
Arif Hussain6d2a3322013-11-17 19:50:10 -08009729 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009731 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9732 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9733 (int)pConfig->channel);
9734 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9735 pConfig->SapHw_mode, pConfig->privacy,
9736 pConfig->authType);
9737 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9738 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9739 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9740 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009741
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309742 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 {
9744 //Bss already started. just return.
9745 //TODO Probably it should update some beacon params.
9746 hddLog( LOGE, "Bss Already started...Ignore the request");
9747 EXIT();
9748 return 0;
9749 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309750
Agarwal Ashish51325b52014-06-16 16:50:49 +05309751 if (vos_max_concurrent_connections_reached()) {
9752 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9753 return -EINVAL;
9754 }
9755
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 pConfig->persona = pHostapdAdapter->device_mode;
9757
Peng Xu2446a892014-09-05 17:21:18 +05309758 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9759 if ( NULL != psmeConfig)
9760 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309761 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309762 sme_GetConfigParam(hHal, psmeConfig);
9763 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309764#ifdef WLAN_FEATURE_AP_HT40_24G
9765 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9766 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9767 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9768 {
9769 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9770 sme_UpdateConfig (hHal, psmeConfig);
9771 }
9772#endif
Peng Xu2446a892014-09-05 17:21:18 +05309773 vos_mem_free(psmeConfig);
9774 }
Peng Xuafc34e32014-09-25 13:23:55 +05309775 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309776
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 pSapEventCallback = hdd_hostapd_SAPEventCB;
9778 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9779 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9780 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009781 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 return -EINVAL;
9783 }
9784
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309785 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9787
9788 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309789
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309791 {
9792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009793 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009794 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 VOS_ASSERT(0);
9796 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309797
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309799 /* Initialize WMM configuation */
9800 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309801 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009802
Anurag Chouhan83026002016-12-13 22:46:21 +05309803#ifdef DHCP_SERVER_OFFLOAD
9804 /* set dhcp server offload */
9805 if (iniConfig->enable_dhcp_srv_offload &&
9806 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
9807 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter);
9808 if (!VOS_IS_STATUS_SUCCESS(status))
9809 {
9810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9811 ("HDD DHCP Server Offload Failed!!"));
9812 return -EINVAL;
9813 }
9814 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
9815 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
9816 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
9817 {
9818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9819 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
9820 pHostapdAdapter->dhcp_status.dhcp_offload_status);
9821 return -EINVAL;
9822 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +05309823#ifdef MDNS_OFFLOAD
9824 if (iniConfig->enable_mdns_offload) {
9825 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
9826 if (VOS_IS_STATUS_SUCCESS(status))
9827 {
9828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9829 ("HDD MDNS Server Offload Failed!!"));
9830 return -EINVAL;
9831 }
9832 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
9833 status = vos_wait_single_event(&pHostapdAdapter->
9834 mdns_status.vos_event, 2000);
9835 if (!VOS_IS_STATUS_SUCCESS(status) ||
9836 pHostapdAdapter->mdns_status.mdns_enable_status ||
9837 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
9838 pHostapdAdapter->mdns_status.mdns_resp_status)
9839 {
9840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9841 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
9842 pHostapdAdapter->mdns_status.mdns_enable_status,
9843 pHostapdAdapter->mdns_status.mdns_fqdn_status,
9844 pHostapdAdapter->mdns_status.mdns_resp_status);
9845 return -EINVAL;
9846 }
9847 }
9848#endif /* MDNS_OFFLOAD */
9849 } else {
9850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9851 ("DHCP Disabled ini %d, FW %d"),
9852 iniConfig->enable_dhcp_srv_offload,
9853 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +05309854 }
9855#endif /* DHCP_SERVER_OFFLOAD */
9856
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009857#ifdef WLAN_FEATURE_P2P_DEBUG
9858 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9859 {
9860 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9861 {
9862 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9863 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009864 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009865 }
9866 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9867 {
9868 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9869 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009870 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009871 }
9872 }
9873#endif
9874
Jeff Johnson295189b2012-06-20 16:38:30 -07009875 pHostapdState->bCommit = TRUE;
9876 EXIT();
9877
9878 return 0;
9879}
9880
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009881#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309882static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309883 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 struct beacon_parameters *params)
9885{
9886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309887 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309888 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009889
9890 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309891
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309892 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9893 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9894 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309895 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9896 hdd_device_modetoString(pAdapter->device_mode),
9897 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009898
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9900 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309901 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009902 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309903 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009904 }
9905
Agarwal Ashish51325b52014-06-16 16:50:49 +05309906 if (vos_max_concurrent_connections_reached()) {
9907 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9908 return -EINVAL;
9909 }
9910
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309911 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 )
9914 {
9915 beacon_data_t *old,*new;
9916
9917 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309918
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309920 {
9921 hddLog(VOS_TRACE_LEVEL_WARN,
9922 FL("already beacon info added to session(%d)"),
9923 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009926
9927 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9928
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309929 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 {
9931 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009932 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 return -EINVAL;
9934 }
9935
9936 pAdapter->sessionCtx.ap.beacon = new;
9937
9938 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9939 }
9940
9941 EXIT();
9942 return status;
9943}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309944
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309945static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9946 struct net_device *dev,
9947 struct beacon_parameters *params)
9948{
9949 int ret;
9950
9951 vos_ssr_protect(__func__);
9952 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9953 vos_ssr_unprotect(__func__);
9954
9955 return ret;
9956}
9957
9958static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 struct net_device *dev,
9960 struct beacon_parameters *params)
9961{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309962 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309963 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9964 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309965 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009966
9967 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309968
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309969 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9970 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9971 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9972 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9973 __func__, hdd_device_modetoString(pAdapter->device_mode),
9974 pAdapter->device_mode);
9975
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309976 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9977 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309978 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009979 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309980 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009981 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309982
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309983 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009984 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309985 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009986 {
9987 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309988
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309990
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309992 {
9993 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9994 FL("session(%d) old and new heads points to NULL"),
9995 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009998
9999 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10000
10001 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010002 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010003 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 return -EINVAL;
10005 }
10006
10007 pAdapter->sessionCtx.ap.beacon = new;
10008
10009 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10010 }
10011
10012 EXIT();
10013 return status;
10014}
10015
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010016static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
10017 struct net_device *dev,
10018 struct beacon_parameters *params)
10019{
10020 int ret;
10021
10022 vos_ssr_protect(__func__);
10023 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
10024 vos_ssr_unprotect(__func__);
10025
10026 return ret;
10027}
10028
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010029#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10030
10031#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010032static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010034#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010035static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010036 struct net_device *dev)
10037#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010038{
10039 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -070010040 hdd_context_t *pHddCtx = NULL;
10041 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010042 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010043 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010044
10045 ENTER();
10046
10047 if (NULL == pAdapter)
10048 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010050 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 return -ENODEV;
10052 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010053
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010054 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10055 TRACE_CODE_HDD_CFG80211_STOP_AP,
10056 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010057 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10058 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010059 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010060 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010061 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070010062 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010063
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010064 pScanInfo = &pHddCtx->scan_info;
10065
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010066 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10067 __func__, hdd_device_modetoString(pAdapter->device_mode),
10068 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010069
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010070 ret = wlan_hdd_scan_abort(pAdapter);
10071
Girish Gowli4bf7a632014-06-12 13:42:11 +053010072 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070010073 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10075 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010076
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010077 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070010078 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10080 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080010081
Jeff Johnsone7245742012-09-05 17:12:55 -070010082 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010083 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070010084 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010085 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010086 }
10087
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010088 /* Delete all associated STAs before stopping AP/P2P GO */
10089 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053010090 hdd_hostapd_stop(dev);
10091
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 )
10095 {
10096 beacon_data_t *old;
10097
10098 old = pAdapter->sessionCtx.ap.beacon;
10099
10100 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010101 {
10102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10103 FL("session(%d) beacon data points to NULL"),
10104 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010107
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010109
10110 mutex_lock(&pHddCtx->sap_lock);
10111 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10112 {
Jeff Johnson4416a782013-03-25 14:17:50 -070010113 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010114 {
10115 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
10116
10117 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
10118
10119 if (!VOS_IS_STATUS_SUCCESS(status))
10120 {
10121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010122 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010124 }
10125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010127 /* BSS stopped, clear the active sessions for this device mode */
10128 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 }
10130 mutex_unlock(&pHddCtx->sap_lock);
10131
10132 if(status != VOS_STATUS_SUCCESS)
10133 {
10134 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010135 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 return -EINVAL;
10137 }
10138
Jeff Johnson4416a782013-03-25 14:17:50 -070010139 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
10141 ==eHAL_STATUS_FAILURE)
10142 {
10143 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010144 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 }
10146
Jeff Johnson4416a782013-03-25 14:17:50 -070010147 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10149 eANI_BOOLEAN_FALSE) )
10150 {
10151 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010152 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 }
10154
10155 // Reset WNI_CFG_PROBE_RSP Flags
10156 wlan_hdd_reset_prob_rspies(pAdapter);
10157
10158 pAdapter->sessionCtx.ap.beacon = NULL;
10159 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010160#ifdef WLAN_FEATURE_P2P_DEBUG
10161 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
10162 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
10163 {
10164 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
10165 "GO got removed");
10166 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
10167 }
10168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 }
10170 EXIT();
10171 return status;
10172}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010173
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010174#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10175static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
10176 struct net_device *dev)
10177{
10178 int ret;
10179
10180 vos_ssr_protect(__func__);
10181 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
10182 vos_ssr_unprotect(__func__);
10183
10184 return ret;
10185}
10186#else
10187static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
10188 struct net_device *dev)
10189{
10190 int ret;
10191
10192 vos_ssr_protect(__func__);
10193 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
10194 vos_ssr_unprotect(__func__);
10195
10196 return ret;
10197}
10198#endif
10199
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010200#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
10201
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010202static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010203 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010204 struct cfg80211_ap_settings *params)
10205{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010206 hdd_adapter_t *pAdapter;
10207 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010208 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010209
10210 ENTER();
10211
Girish Gowlib143d7a2015-02-18 19:39:55 +053010212 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010213 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010214 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010215 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010216 return -ENODEV;
10217 }
10218
10219 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10220 if (NULL == pAdapter)
10221 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010222 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010223 "%s: HDD adapter is Null", __func__);
10224 return -ENODEV;
10225 }
10226
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010227 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10228 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10229 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010230 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10231 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010233 "%s: HDD adapter magic is invalid", __func__);
10234 return -ENODEV;
10235 }
10236
10237 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010238 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010239 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010240 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010241 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010242 }
10243
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010244 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10245 __func__, hdd_device_modetoString(pAdapter->device_mode),
10246 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010247
10248 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010249 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010250 )
10251 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010252 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010253
10254 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010255
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010256 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010257 {
10258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10259 FL("already beacon info added to session(%d)"),
10260 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010261 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010262 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010263
Girish Gowlib143d7a2015-02-18 19:39:55 +053010264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10265 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10266 &new,
10267 &params->beacon);
10268#else
10269 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10270 &new,
10271 &params->beacon,
10272 params->dtim_period);
10273#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010274
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010275 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010276 {
10277 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010278 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010279 return -EINVAL;
10280 }
10281 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010283 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10284#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10285 params->channel, params->channel_type);
10286#else
10287 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10288#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010289#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010290 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010291 params->ssid_len, params->hidden_ssid,
10292 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010293 }
10294
10295 EXIT();
10296 return status;
10297}
10298
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010299static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10300 struct net_device *dev,
10301 struct cfg80211_ap_settings *params)
10302{
10303 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010304
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010305 vos_ssr_protect(__func__);
10306 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10307 vos_ssr_unprotect(__func__);
10308
10309 return ret;
10310}
10311
10312static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010313 struct net_device *dev,
10314 struct cfg80211_beacon_data *params)
10315{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010316 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010317 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010318 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010319
10320 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010321
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010322 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10323 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10324 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010325 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010326 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010327
10328 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10329 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010330 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010331 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010332 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010333 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010334
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010335 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010336 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010337 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010338 {
10339 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010340
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010341 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010342
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010343 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010344 {
10345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10346 FL("session(%d) beacon data points to NULL"),
10347 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010348 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010349 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010350
10351 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10352
10353 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010354 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010355 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010356 return -EINVAL;
10357 }
10358
10359 pAdapter->sessionCtx.ap.beacon = new;
10360
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010361 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10362 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010363 }
10364
10365 EXIT();
10366 return status;
10367}
10368
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010369static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10370 struct net_device *dev,
10371 struct cfg80211_beacon_data *params)
10372{
10373 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010374
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010375 vos_ssr_protect(__func__);
10376 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10377 vos_ssr_unprotect(__func__);
10378
10379 return ret;
10380}
10381
10382#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010383
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010384static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 struct net_device *dev,
10386 struct bss_parameters *params)
10387{
10388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010389 hdd_context_t *pHddCtx;
10390 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010391
10392 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010393
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010394 if (NULL == pAdapter)
10395 {
10396 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10397 "%s: HDD adapter is Null", __func__);
10398 return -ENODEV;
10399 }
10400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010401 ret = wlan_hdd_validate_context(pHddCtx);
10402 if (0 != ret)
10403 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010404 return ret;
10405 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010406 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10407 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10408 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010409 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10410 __func__, hdd_device_modetoString(pAdapter->device_mode),
10411 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010412
10413 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010415 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 {
10417 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10418 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010419 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 {
10421 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010423 }
10424
10425 EXIT();
10426 return 0;
10427}
10428
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010429static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10430 struct net_device *dev,
10431 struct bss_parameters *params)
10432{
10433 int ret;
10434
10435 vos_ssr_protect(__func__);
10436 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10437 vos_ssr_unprotect(__func__);
10438
10439 return ret;
10440}
Kiet Lam10841362013-11-01 11:36:50 +053010441/* FUNCTION: wlan_hdd_change_country_code_cd
10442* to wait for contry code completion
10443*/
10444void* wlan_hdd_change_country_code_cb(void *pAdapter)
10445{
10446 hdd_adapter_t *call_back_pAdapter = pAdapter;
10447 complete(&call_back_pAdapter->change_country_code);
10448 return NULL;
10449}
10450
Jeff Johnson295189b2012-06-20 16:38:30 -070010451/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010452 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10454 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010455int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010456 struct net_device *ndev,
10457 enum nl80211_iftype type,
10458 u32 *flags,
10459 struct vif_params *params
10460 )
10461{
10462 struct wireless_dev *wdev;
10463 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010464 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010465 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 tCsrRoamProfile *pRoamProfile = NULL;
10467 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010468 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 eMib_dot11DesiredBssType connectedBssType;
10470 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010471 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010472
10473 ENTER();
10474
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010475 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010476 {
10477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10478 "%s: Adapter context is null", __func__);
10479 return VOS_STATUS_E_FAILURE;
10480 }
10481
10482 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10483 if (!pHddCtx)
10484 {
10485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10486 "%s: HDD context is null", __func__);
10487 return VOS_STATUS_E_FAILURE;
10488 }
10489
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010490 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10491 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10492 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010493 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010494 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010496 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 }
10498
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010499 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10500 __func__, hdd_device_modetoString(pAdapter->device_mode),
10501 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010502
Agarwal Ashish51325b52014-06-16 16:50:49 +053010503 if (vos_max_concurrent_connections_reached()) {
10504 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10505 return -EINVAL;
10506 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010507 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 wdev = ndev->ieee80211_ptr;
10509
10510#ifdef WLAN_BTAMP_FEATURE
10511 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10512 (NL80211_IFTYPE_ADHOC == type)||
10513 (NL80211_IFTYPE_AP == type)||
10514 (NL80211_IFTYPE_P2P_GO == type))
10515 {
10516 pHddCtx->isAmpAllowed = VOS_FALSE;
10517 // stop AMP traffic
10518 status = WLANBAP_StopAmp();
10519 if(VOS_STATUS_SUCCESS != status )
10520 {
10521 pHddCtx->isAmpAllowed = VOS_TRUE;
10522 hddLog(VOS_TRACE_LEVEL_FATAL,
10523 "%s: Failed to stop AMP", __func__);
10524 return -EINVAL;
10525 }
10526 }
10527#endif //WLAN_BTAMP_FEATURE
10528 /* Reset the current device mode bit mask*/
10529 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10530
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010531 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10532 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10533 (type == NL80211_IFTYPE_P2P_GO)))
10534 {
10535 /* Notify Mode change in case of concurrency.
10536 * Below function invokes TDLS teardown Functionality Since TDLS is
10537 * not Supported in case of concurrency i.e Once P2P session
10538 * is detected disable offchannel and teardown TDLS links
10539 */
10540 hddLog(LOG1,
10541 FL("Device mode = %d Interface type = %d"),
10542 pAdapter->device_mode, type);
10543 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10544 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010545
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010548 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 )
10550 {
10551 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010552 if (!pWextState)
10553 {
10554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10555 "%s: pWextState is null", __func__);
10556 return VOS_STATUS_E_FAILURE;
10557 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 pRoamProfile = &pWextState->roamProfile;
10559 LastBSSType = pRoamProfile->BSSType;
10560
10561 switch (type)
10562 {
10563 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 hddLog(VOS_TRACE_LEVEL_INFO,
10566 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10567 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010568#ifdef WLAN_FEATURE_11AC
10569 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10570 {
10571 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10572 }
10573#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010574 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010575 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010577 //Check for sub-string p2p to confirm its a p2p interface
10578 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010579 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010580#ifdef FEATURE_WLAN_TDLS
10581 mutex_lock(&pHddCtx->tdls_lock);
10582 wlan_hdd_tdls_exit(pAdapter, TRUE);
10583 mutex_unlock(&pHddCtx->tdls_lock);
10584#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010585 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10586 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10587 }
10588 else
10589 {
10590 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010594
Jeff Johnson295189b2012-06-20 16:38:30 -070010595 case NL80211_IFTYPE_ADHOC:
10596 hddLog(VOS_TRACE_LEVEL_INFO,
10597 "%s: setting interface Type to ADHOC", __func__);
10598 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10599 pRoamProfile->phyMode =
10600 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010601 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010602 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010603 hdd_set_ibss_ops( pAdapter );
10604 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010605
10606 status = hdd_sta_id_hash_attach(pAdapter);
10607 if (VOS_STATUS_SUCCESS != status) {
10608 hddLog(VOS_TRACE_LEVEL_ERROR,
10609 FL("Failed to initialize hash for IBSS"));
10610 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 break;
10612
10613 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 {
10616 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10617 "%s: setting interface Type to %s", __func__,
10618 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10619
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010620 //Cancel any remain on channel for GO mode
10621 if (NL80211_IFTYPE_P2P_GO == type)
10622 {
10623 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10624 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010625 if (NL80211_IFTYPE_AP == type)
10626 {
10627 /* As Loading WLAN Driver one interface being created for p2p device
10628 * address. This will take one HW STA and the max number of clients
10629 * that can connect to softAP will be reduced by one. so while changing
10630 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10631 * interface as it is not required in SoftAP mode.
10632 */
10633
10634 // Get P2P Adapter
10635 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10636
10637 if (pP2pAdapter)
10638 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010639 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010640 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010641 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10642 }
10643 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010644 //Disable IMPS & BMPS for SAP/GO
10645 if(VOS_STATUS_E_FAILURE ==
10646 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10647 {
10648 //Fail to Exit BMPS
10649 VOS_ASSERT(0);
10650 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010651
10652 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10653
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010654#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010655
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010656 /* A Mutex Lock is introduced while changing the mode to
10657 * protect the concurrent access for the Adapters by TDLS
10658 * module.
10659 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010660 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010661#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010662 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010663 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010664 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10666 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010667#ifdef FEATURE_WLAN_TDLS
10668 mutex_unlock(&pHddCtx->tdls_lock);
10669#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010670 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10671 (pConfig->apRandomBssidEnabled))
10672 {
10673 /* To meet Android requirements create a randomized
10674 MAC address of the form 02:1A:11:Fx:xx:xx */
10675 get_random_bytes(&ndev->dev_addr[3], 3);
10676 ndev->dev_addr[0] = 0x02;
10677 ndev->dev_addr[1] = 0x1A;
10678 ndev->dev_addr[2] = 0x11;
10679 ndev->dev_addr[3] |= 0xF0;
10680 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10681 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010682 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10683 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010684 }
10685
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 hdd_set_ap_ops( pAdapter->dev );
10687
Kiet Lam10841362013-11-01 11:36:50 +053010688 /* This is for only SAP mode where users can
10689 * control country through ini.
10690 * P2P GO follows station country code
10691 * acquired during the STA scanning. */
10692 if((NL80211_IFTYPE_AP == type) &&
10693 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10694 {
10695 int status = 0;
10696 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10697 "%s: setting country code from INI ", __func__);
10698 init_completion(&pAdapter->change_country_code);
10699 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10700 (void *)(tSmeChangeCountryCallback)
10701 wlan_hdd_change_country_code_cb,
10702 pConfig->apCntryCode, pAdapter,
10703 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010704 eSIR_FALSE,
10705 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010706 if (eHAL_STATUS_SUCCESS == status)
10707 {
10708 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010709 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010710 &pAdapter->change_country_code,
10711 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010712 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010713 {
10714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010715 FL("SME Timed out while setting country code %ld"),
10716 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010717
10718 if (pHddCtx->isLogpInProgress)
10719 {
10720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10721 "%s: LOGP in Progress. Ignore!!!", __func__);
10722 return -EAGAIN;
10723 }
Kiet Lam10841362013-11-01 11:36:50 +053010724 }
10725 }
10726 else
10727 {
10728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010729 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010730 return -EINVAL;
10731 }
10732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 status = hdd_init_ap_mode(pAdapter);
10734 if(status != VOS_STATUS_SUCCESS)
10735 {
10736 hddLog(VOS_TRACE_LEVEL_FATAL,
10737 "%s: Error initializing the ap mode", __func__);
10738 return -EINVAL;
10739 }
10740 hdd_set_conparam(1);
10741
Nirav Shah7e3c8132015-06-22 23:51:42 +053010742 status = hdd_sta_id_hash_attach(pAdapter);
10743 if (VOS_STATUS_SUCCESS != status)
10744 {
10745 hddLog(VOS_TRACE_LEVEL_ERROR,
10746 FL("Failed to initialize hash for AP"));
10747 return -EINVAL;
10748 }
10749
Jeff Johnson295189b2012-06-20 16:38:30 -070010750 /*interface type changed update in wiphy structure*/
10751 if(wdev)
10752 {
10753 wdev->iftype = type;
10754 pHddCtx->change_iface = type;
10755 }
10756 else
10757 {
10758 hddLog(VOS_TRACE_LEVEL_ERROR,
10759 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10760 return -EINVAL;
10761 }
10762 goto done;
10763 }
10764
10765 default:
10766 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10767 __func__);
10768 return -EOPNOTSUPP;
10769 }
10770 }
10771 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 )
10774 {
10775 switch(type)
10776 {
10777 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010780
10781 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010782#ifdef FEATURE_WLAN_TDLS
10783
10784 /* A Mutex Lock is introduced while changing the mode to
10785 * protect the concurrent access for the Adapters by TDLS
10786 * module.
10787 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010788 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010789#endif
c_hpothu002231a2015-02-05 14:58:51 +053010790 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010792 //Check for sub-string p2p to confirm its a p2p interface
10793 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010794 {
10795 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10796 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10797 }
10798 else
10799 {
10800 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010802 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053010803
10804 /* set con_mode to STA only when no SAP concurrency mode */
10805 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
10806 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10809 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010810#ifdef FEATURE_WLAN_TDLS
10811 mutex_unlock(&pHddCtx->tdls_lock);
10812#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010813 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 if( VOS_STATUS_SUCCESS != status )
10815 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010816 /* In case of JB, for P2P-GO, only change interface will be called,
10817 * This is the right place to enable back bmps_imps()
10818 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010819 if (pHddCtx->hdd_wlan_suspended)
10820 {
10821 hdd_set_pwrparams(pHddCtx);
10822 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010823 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010824 goto done;
10825 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010826 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10829 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 goto done;
10831 default:
10832 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10833 __func__);
10834 return -EOPNOTSUPP;
10835
10836 }
10837
10838 }
10839 else
10840 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010841 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10842 __func__, hdd_device_modetoString(pAdapter->device_mode),
10843 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 return -EOPNOTSUPP;
10845 }
10846
10847
10848 if(pRoamProfile)
10849 {
10850 if ( LastBSSType != pRoamProfile->BSSType )
10851 {
10852 /*interface type changed update in wiphy structure*/
10853 wdev->iftype = type;
10854
10855 /*the BSS mode changed, We need to issue disconnect
10856 if connected or in IBSS disconnect state*/
10857 if ( hdd_connGetConnectedBssType(
10858 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10859 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10860 {
10861 /*need to issue a disconnect to CSR.*/
10862 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10863 if( eHAL_STATUS_SUCCESS ==
10864 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10865 pAdapter->sessionId,
10866 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10867 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010868 ret = wait_for_completion_interruptible_timeout(
10869 &pAdapter->disconnect_comp_var,
10870 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10871 if (ret <= 0)
10872 {
10873 hddLog(VOS_TRACE_LEVEL_ERROR,
10874 FL("wait on disconnect_comp_var failed %ld"), ret);
10875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 }
10877 }
10878 }
10879 }
10880
10881done:
10882 /*set bitmask based on updated value*/
10883 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010884
10885 /* Only STA mode support TM now
10886 * all other mode, TM feature should be disabled */
10887 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10888 (~VOS_STA & pHddCtx->concurrency_mode) )
10889 {
10890 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10891 }
10892
Jeff Johnson295189b2012-06-20 16:38:30 -070010893#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010894 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010895 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010896 {
10897 //we are ok to do AMP
10898 pHddCtx->isAmpAllowed = VOS_TRUE;
10899 }
10900#endif //WLAN_BTAMP_FEATURE
10901 EXIT();
10902 return 0;
10903}
10904
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010905/*
10906 * FUNCTION: wlan_hdd_cfg80211_change_iface
10907 * wrapper function to protect the actual implementation from SSR.
10908 */
10909int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10910 struct net_device *ndev,
10911 enum nl80211_iftype type,
10912 u32 *flags,
10913 struct vif_params *params
10914 )
10915{
10916 int ret;
10917
10918 vos_ssr_protect(__func__);
10919 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10920 vos_ssr_unprotect(__func__);
10921
10922 return ret;
10923}
10924
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010925#ifdef FEATURE_WLAN_TDLS
10926static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010927 struct net_device *dev,
10928#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10929 const u8 *mac,
10930#else
10931 u8 *mac,
10932#endif
10933 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010934{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010935 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010936 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010937 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010938 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010939 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010940 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010941
10942 ENTER();
10943
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010944 if (!dev) {
10945 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10946 return -EINVAL;
10947 }
10948
10949 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10950 if (!pAdapter) {
10951 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10952 return -EINVAL;
10953 }
10954
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010955 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010956 {
10957 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10958 "Invalid arguments");
10959 return -EINVAL;
10960 }
Hoonki Lee27511902013-03-14 18:19:06 -070010961
10962 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10963 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10964 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010966 "%s: TDLS mode is disabled OR not enabled in FW."
10967 MAC_ADDRESS_STR " Request declined.",
10968 __func__, MAC_ADDR_ARRAY(mac));
10969 return -ENOTSUPP;
10970 }
10971
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010972 if (pHddCtx->isLogpInProgress)
10973 {
10974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10975 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010976 wlan_hdd_tdls_set_link_status(pAdapter,
10977 mac,
10978 eTDLS_LINK_IDLE,
10979 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010980 return -EBUSY;
10981 }
10982
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010983 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010984 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010985
10986 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010987 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010988 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10989 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010990 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010991 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010992 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010993
10994 /* in add station, we accept existing valid staId if there is */
10995 if ((0 == update) &&
10996 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10997 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010998 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011000 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011001 " link_status %d. staId %d. add station ignored.",
11002 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011003 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011004 return 0;
11005 }
11006 /* in change station, we accept only when staId is valid */
11007 if ((1 == update) &&
11008 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
11009 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
11010 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011011 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011013 "%s: " MAC_ADDRESS_STR
11014 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011015 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
11016 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
11017 mutex_unlock(&pHddCtx->tdls_lock);
11018 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011019 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011020 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011021
11022 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053011023 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011024 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11026 "%s: " MAC_ADDRESS_STR
11027 " TDLS setup is ongoing. Request declined.",
11028 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070011029 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011030 }
11031
11032 /* first to check if we reached to maximum supported TDLS peer.
11033 TODO: for now, return -EPERM looks working fine,
11034 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011035 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
11036 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011037 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11039 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011040 " TDLS Max peer already connected. Request declined."
11041 " Num of peers (%d), Max allowed (%d).",
11042 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
11043 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011044 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011045 }
11046 else
11047 {
11048 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011049 mutex_lock(&pHddCtx->tdls_lock);
11050 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011051 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011052 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011053 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011054 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11055 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
11056 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011057 return -EPERM;
11058 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011059 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011060 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011061 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053011062 wlan_hdd_tdls_set_link_status(pAdapter,
11063 mac,
11064 eTDLS_LINK_CONNECTING,
11065 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011066
Jeff Johnsond75fe012013-04-06 10:53:06 -070011067 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011068 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011069 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011071 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011072 if(StaParams->htcap_present)
11073 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011075 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011077 "ht_capa->extended_capabilities: %0x",
11078 StaParams->HTCap.extendedHtCapInfo);
11079 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011081 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011083 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011084 if(StaParams->vhtcap_present)
11085 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011087 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
11088 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
11089 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
11090 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011091 {
11092 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011094 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011096 "[%d]: %x ", i, StaParams->supported_rates[i]);
11097 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070011098 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011099 else if ((1 == update) && (NULL == StaParams))
11100 {
11101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11102 "%s : update is true, but staParams is NULL. Error!", __func__);
11103 return -EPERM;
11104 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011105
11106 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
11107
11108 if (!update)
11109 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011110 /*Before adding sta make sure that device exited from BMPS*/
11111 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
11112 {
11113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11114 "%s: Adding tdls peer sta. Disable BMPS", __func__);
11115 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
11116 if (status != VOS_STATUS_SUCCESS) {
11117 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
11118 }
11119 }
11120
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011121 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011122 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011123 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011124 hddLog(VOS_TRACE_LEVEL_ERROR,
11125 FL("Failed to add TDLS peer STA. Enable Bmps"));
11126 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011127 return -EPERM;
11128 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011129 }
11130 else
11131 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011132 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011133 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011134 if (ret != eHAL_STATUS_SUCCESS) {
11135 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
11136 return -EPERM;
11137 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011138 }
11139
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011140 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011141 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
11142
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011143 mutex_lock(&pHddCtx->tdls_lock);
11144 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
11145
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011146 if ((pTdlsPeer != NULL) &&
11147 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011148 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011149 hddLog(VOS_TRACE_LEVEL_ERROR,
11150 FL("peer link status %u"), pTdlsPeer->link_status);
11151 mutex_unlock(&pHddCtx->tdls_lock);
11152 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011153 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011154 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011155
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011156 if (ret <= 0)
11157 {
11158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11159 "%s: timeout waiting for tdls add station indication %ld",
11160 __func__, ret);
11161 goto error;
11162 }
11163
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011164 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
11165 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011167 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011168 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011169 }
11170
11171 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070011172
11173error:
Atul Mittal115287b2014-07-08 13:26:33 +053011174 wlan_hdd_tdls_set_link_status(pAdapter,
11175 mac,
11176 eTDLS_LINK_IDLE,
11177 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011178 return -EPERM;
11179
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011180}
11181#endif
11182
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011183static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011185#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11186 const u8 *mac,
11187#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011188 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011189#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 struct station_parameters *params)
11191{
11192 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011193 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011194 hdd_context_t *pHddCtx;
11195 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011197 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011198#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011199 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011200 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011201 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011202 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011203#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011204
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011205 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011206
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011207 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011208 if ((NULL == pAdapter))
11209 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011211 "invalid adapter ");
11212 return -EINVAL;
11213 }
11214
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011215 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11216 TRACE_CODE_HDD_CHANGE_STATION,
11217 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011218 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011219
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011220 ret = wlan_hdd_validate_context(pHddCtx);
11221 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011222 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011223 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011224 }
11225
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011226 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11227
11228 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011229 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11231 "invalid HDD station context");
11232 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11235
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011236 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11237 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011239 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011241 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 WLANTL_STA_AUTHENTICATED);
11243
Gopichand Nakkala29149562013-05-10 21:43:41 +053011244 if (status != VOS_STATUS_SUCCESS)
11245 {
11246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11247 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11248 return -EINVAL;
11249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 }
11251 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011252 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11253 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011254#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011255 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11256 StaParams.capability = params->capability;
11257 StaParams.uapsd_queues = params->uapsd_queues;
11258 StaParams.max_sp = params->max_sp;
11259
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011260 /* Convert (first channel , number of channels) tuple to
11261 * the total list of channels. This goes with the assumption
11262 * that if the first channel is < 14, then the next channels
11263 * are an incremental of 1 else an incremental of 4 till the number
11264 * of channels.
11265 */
11266 if (0 != params->supported_channels_len) {
11267 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11268 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11269 {
11270 int wifi_chan_index;
11271 StaParams.supported_channels[j] = params->supported_channels[i];
11272 wifi_chan_index =
11273 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11274 no_of_channels = params->supported_channels[i+1];
11275 for(k=1; k <= no_of_channels; k++)
11276 {
11277 StaParams.supported_channels[j+1] =
11278 StaParams.supported_channels[j] + wifi_chan_index;
11279 j+=1;
11280 }
11281 }
11282 StaParams.supported_channels_len = j;
11283 }
11284 vos_mem_copy(StaParams.supported_oper_classes,
11285 params->supported_oper_classes,
11286 params->supported_oper_classes_len);
11287 StaParams.supported_oper_classes_len =
11288 params->supported_oper_classes_len;
11289
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011290 if (0 != params->ext_capab_len)
11291 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
11292 sizeof(StaParams.extn_capability));
11293
11294 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011295 {
11296 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011297 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011298 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011299
11300 StaParams.supported_rates_len = params->supported_rates_len;
11301
11302 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11303 * The supported_rates array , for all the structures propogating till Add Sta
11304 * to the firmware has to be modified , if the supplicant (ieee80211) is
11305 * modified to send more rates.
11306 */
11307
11308 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11309 */
11310 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11311 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11312
11313 if (0 != StaParams.supported_rates_len) {
11314 int i = 0;
11315 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11316 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011317 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011318 "Supported Rates with Length %d", StaParams.supported_rates_len);
11319 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011320 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011321 "[%d]: %0x", i, StaParams.supported_rates[i]);
11322 }
11323
11324 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011325 {
11326 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011327 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011328 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011329
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011330 if (0 != params->ext_capab_len ) {
11331 /*Define A Macro : TODO Sunil*/
11332 if ((1<<4) & StaParams.extn_capability[3]) {
11333 isBufSta = 1;
11334 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011335 /* TDLS Channel Switching Support */
11336 if ((1<<6) & StaParams.extn_capability[3]) {
11337 isOffChannelSupported = 1;
11338 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011339 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011340
11341 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011342 (params->ht_capa || params->vht_capa ||
11343 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011344 /* TDLS Peer is WME/QoS capable */
11345 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011346
11347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11348 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11349 __func__, isQosWmmSta, StaParams.htcap_present);
11350
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011351 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11352 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011353 isOffChannelSupported,
11354 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011355
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011356 if (VOS_STATUS_SUCCESS != status) {
11357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11358 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11359 return -EINVAL;
11360 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011361 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11362
11363 if (VOS_STATUS_SUCCESS != status) {
11364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11365 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11366 return -EINVAL;
11367 }
11368 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011369#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011370 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011371 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 return status;
11373}
11374
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011375#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11376static int wlan_hdd_change_station(struct wiphy *wiphy,
11377 struct net_device *dev,
11378 const u8 *mac,
11379 struct station_parameters *params)
11380#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011381static int wlan_hdd_change_station(struct wiphy *wiphy,
11382 struct net_device *dev,
11383 u8 *mac,
11384 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011385#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011386{
11387 int ret;
11388
11389 vos_ssr_protect(__func__);
11390 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11391 vos_ssr_unprotect(__func__);
11392
11393 return ret;
11394}
11395
Jeff Johnson295189b2012-06-20 16:38:30 -070011396/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011397 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 * This function is used to initialize the key information
11399 */
11400#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011401static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 struct net_device *ndev,
11403 u8 key_index, bool pairwise,
11404 const u8 *mac_addr,
11405 struct key_params *params
11406 )
11407#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011408static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 struct net_device *ndev,
11410 u8 key_index, const u8 *mac_addr,
11411 struct key_params *params
11412 )
11413#endif
11414{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011415 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011416 tCsrRoamSetKey setKey;
11417 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011418 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011419 v_U32_t roamId= 0xFF;
11420 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 hdd_hostapd_state_t *pHostapdState;
11422 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011423 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011424 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011425
11426 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011427
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011428 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11429 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11430 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011431 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11432 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011433 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011434 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011435 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011436 }
11437
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011438 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11439 __func__, hdd_device_modetoString(pAdapter->device_mode),
11440 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011441
11442 if (CSR_MAX_NUM_KEY <= key_index)
11443 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011444 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 key_index);
11446
11447 return -EINVAL;
11448 }
11449
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011450 if (CSR_MAX_KEY_LEN < params->key_len)
11451 {
11452 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11453 params->key_len);
11454
11455 return -EINVAL;
11456 }
11457
11458 hddLog(VOS_TRACE_LEVEL_INFO,
11459 "%s: called with key index = %d & key length %d",
11460 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011461
11462 /*extract key idx, key len and key*/
11463 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11464 setKey.keyId = key_index;
11465 setKey.keyLength = params->key_len;
11466 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11467
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011468 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 {
11470 case WLAN_CIPHER_SUITE_WEP40:
11471 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11472 break;
11473
11474 case WLAN_CIPHER_SUITE_WEP104:
11475 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11476 break;
11477
11478 case WLAN_CIPHER_SUITE_TKIP:
11479 {
11480 u8 *pKey = &setKey.Key[0];
11481 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11482
11483 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11484
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011485 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011486
11487 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011488 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 |--------------|----------|----------|
11490 <---16bytes---><--8bytes--><--8bytes-->
11491
11492 */
11493 /*Sme expects the 32 bytes key to be in the below order
11494
11495 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011496 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 |--------------|----------|----------|
11498 <---16bytes---><--8bytes--><--8bytes-->
11499 */
11500 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011501 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011502
11503 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011504 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011505
11506 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011507 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011508
11509
11510 break;
11511 }
11512
11513 case WLAN_CIPHER_SUITE_CCMP:
11514 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11515 break;
11516
11517#ifdef FEATURE_WLAN_WAPI
11518 case WLAN_CIPHER_SUITE_SMS4:
11519 {
11520 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11521 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11522 params->key, params->key_len);
11523 return 0;
11524 }
11525#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011526
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011527#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 case WLAN_CIPHER_SUITE_KRK:
11529 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11530 break;
11531#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011532
11533#ifdef WLAN_FEATURE_11W
11534 case WLAN_CIPHER_SUITE_AES_CMAC:
11535 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011536 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011537#endif
11538
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011540 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011542 status = -EOPNOTSUPP;
11543 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 }
11545
11546 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11547 __func__, setKey.encType);
11548
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011549 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011550#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11551 (!pairwise)
11552#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011553 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011554#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011555 )
11556 {
11557 /* set group key*/
11558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11559 "%s- %d: setting Broadcast key",
11560 __func__, __LINE__);
11561 setKey.keyDirection = eSIR_RX_ONLY;
11562 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11563 }
11564 else
11565 {
11566 /* set pairwise key*/
11567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11568 "%s- %d: setting pairwise key",
11569 __func__, __LINE__);
11570 setKey.keyDirection = eSIR_TX_RX;
11571 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11572 }
11573 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11574 {
11575 setKey.keyDirection = eSIR_TX_RX;
11576 /*Set the group key*/
11577 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11578 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011579
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011580 if ( 0 != status )
11581 {
11582 hddLog(VOS_TRACE_LEVEL_ERROR,
11583 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011584 status = -EINVAL;
11585 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011586 }
11587 /*Save the keys here and call sme_RoamSetKey for setting
11588 the PTK after peer joins the IBSS network*/
11589 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11590 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011591 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011592 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011593 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11594 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11595 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011597 if( pHostapdState->bssState == BSS_START )
11598 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011599 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11600 vos_status = wlan_hdd_check_ula_done(pAdapter);
11601
11602 if ( vos_status != VOS_STATUS_SUCCESS )
11603 {
11604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11605 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11606 __LINE__, vos_status );
11607
11608 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11609
11610 status = -EINVAL;
11611 goto end;
11612 }
11613
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11615
11616 if ( status != eHAL_STATUS_SUCCESS )
11617 {
11618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11619 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11620 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011621 status = -EINVAL;
11622 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 }
11624 }
11625
11626 /* Saving WEP keys */
11627 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11628 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11629 {
11630 //Save the wep key in ap context. Issue setkey after the BSS is started.
11631 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11632 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11633 }
11634 else
11635 {
11636 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011637 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11639 }
11640 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011641 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11642 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 {
11644 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11645 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11646
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011647#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11648 if (!pairwise)
11649#else
11650 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11651#endif
11652 {
11653 /* set group key*/
11654 if (pHddStaCtx->roam_info.deferKeyComplete)
11655 {
11656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11657 "%s- %d: Perform Set key Complete",
11658 __func__, __LINE__);
11659 hdd_PerformRoamSetKeyComplete(pAdapter);
11660 }
11661 }
11662
Jeff Johnson295189b2012-06-20 16:38:30 -070011663 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11664
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011665 pWextState->roamProfile.Keys.defaultIndex = key_index;
11666
11667
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011668 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 params->key, params->key_len);
11670
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011671
Jeff Johnson295189b2012-06-20 16:38:30 -070011672 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11673
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011674 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011676 __func__, setKey.peerMac[0], setKey.peerMac[1],
11677 setKey.peerMac[2], setKey.peerMac[3],
11678 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 setKey.keyDirection);
11680
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011681 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011682
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011683 if ( vos_status != VOS_STATUS_SUCCESS )
11684 {
11685 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11687 __LINE__, vos_status );
11688
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011689 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011690
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011691 status = -EINVAL;
11692 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011693
11694 }
11695
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011696#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011697 /* The supplicant may attempt to set the PTK once pre-authentication
11698 is done. Save the key in the UMAC and include it in the ADD BSS
11699 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011700 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011701 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011702 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011703 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11704 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011705 status = 0;
11706 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011707 }
11708 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11709 {
11710 hddLog(VOS_TRACE_LEVEL_ERROR,
11711 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011712 status = -EINVAL;
11713 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011714 }
11715#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011716
11717 /* issue set key request to SME*/
11718 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11719 pAdapter->sessionId, &setKey, &roamId );
11720
11721 if ( 0 != status )
11722 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011723 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11725 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011726 status = -EINVAL;
11727 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011728 }
11729
11730
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011731 /* in case of IBSS as there was no information available about WEP keys during
11732 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011734 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11735 !( ( IW_AUTH_KEY_MGMT_802_1X
11736 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11738 )
11739 &&
11740 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11741 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11742 )
11743 )
11744 {
11745 setKey.keyDirection = eSIR_RX_ONLY;
11746 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11747
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011748 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011750 __func__, setKey.peerMac[0], setKey.peerMac[1],
11751 setKey.peerMac[2], setKey.peerMac[3],
11752 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 setKey.keyDirection);
11754
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011755 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pAdapter->sessionId, &setKey, &roamId );
11757
11758 if ( 0 != status )
11759 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011760 hddLog(VOS_TRACE_LEVEL_ERROR,
11761 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 __func__, status);
11763 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011764 status = -EINVAL;
11765 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 }
11767 }
11768 }
11769
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011770end:
11771 /* Need to clear any trace of key value in the memory.
11772 * Thus zero out the memory even though it is local
11773 * variable.
11774 */
11775 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011776 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011777 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011778}
11779
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011780#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11781static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11782 struct net_device *ndev,
11783 u8 key_index, bool pairwise,
11784 const u8 *mac_addr,
11785 struct key_params *params
11786 )
11787#else
11788static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11789 struct net_device *ndev,
11790 u8 key_index, const u8 *mac_addr,
11791 struct key_params *params
11792 )
11793#endif
11794{
11795 int ret;
11796 vos_ssr_protect(__func__);
11797#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11798 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11799 mac_addr, params);
11800#else
11801 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11802 params);
11803#endif
11804 vos_ssr_unprotect(__func__);
11805
11806 return ret;
11807}
11808
Jeff Johnson295189b2012-06-20 16:38:30 -070011809/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011810 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 * This function is used to get the key information
11812 */
11813#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011814static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011815 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011817 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 const u8 *mac_addr, void *cookie,
11819 void (*callback)(void *cookie, struct key_params*)
11820 )
11821#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011822static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011823 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 struct net_device *ndev,
11825 u8 key_index, const u8 *mac_addr, void *cookie,
11826 void (*callback)(void *cookie, struct key_params*)
11827 )
11828#endif
11829{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011830 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011831 hdd_wext_state_t *pWextState = NULL;
11832 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011834 hdd_context_t *pHddCtx;
11835 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011836
11837 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011838
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011839 if (NULL == pAdapter)
11840 {
11841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11842 "%s: HDD adapter is Null", __func__);
11843 return -ENODEV;
11844 }
11845
11846 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11847 ret = wlan_hdd_validate_context(pHddCtx);
11848 if (0 != ret)
11849 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011850 return ret;
11851 }
11852
11853 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11854 pRoamProfile = &(pWextState->roamProfile);
11855
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011856 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11857 __func__, hdd_device_modetoString(pAdapter->device_mode),
11858 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011859
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 memset(&params, 0, sizeof(params));
11861
11862 if (CSR_MAX_NUM_KEY <= key_index)
11863 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011864 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011867
11868 switch(pRoamProfile->EncryptionType.encryptionType[0])
11869 {
11870 case eCSR_ENCRYPT_TYPE_NONE:
11871 params.cipher = IW_AUTH_CIPHER_NONE;
11872 break;
11873
11874 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11875 case eCSR_ENCRYPT_TYPE_WEP40:
11876 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11877 break;
11878
11879 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11880 case eCSR_ENCRYPT_TYPE_WEP104:
11881 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11882 break;
11883
11884 case eCSR_ENCRYPT_TYPE_TKIP:
11885 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11886 break;
11887
11888 case eCSR_ENCRYPT_TYPE_AES:
11889 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11890 break;
11891
11892 default:
11893 params.cipher = IW_AUTH_CIPHER_NONE;
11894 break;
11895 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011896
c_hpothuaaf19692014-05-17 17:01:48 +053011897 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11898 TRACE_CODE_HDD_CFG80211_GET_KEY,
11899 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011900
Jeff Johnson295189b2012-06-20 16:38:30 -070011901 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11902 params.seq_len = 0;
11903 params.seq = NULL;
11904 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11905 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011906 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 return 0;
11908}
11909
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011910#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11911static int wlan_hdd_cfg80211_get_key(
11912 struct wiphy *wiphy,
11913 struct net_device *ndev,
11914 u8 key_index, bool pairwise,
11915 const u8 *mac_addr, void *cookie,
11916 void (*callback)(void *cookie, struct key_params*)
11917 )
11918#else
11919static int wlan_hdd_cfg80211_get_key(
11920 struct wiphy *wiphy,
11921 struct net_device *ndev,
11922 u8 key_index, const u8 *mac_addr, void *cookie,
11923 void (*callback)(void *cookie, struct key_params*)
11924 )
11925#endif
11926{
11927 int ret;
11928
11929 vos_ssr_protect(__func__);
11930#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11931 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11932 mac_addr, cookie, callback);
11933#else
11934 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11935 callback);
11936#endif
11937 vos_ssr_unprotect(__func__);
11938
11939 return ret;
11940}
11941
Jeff Johnson295189b2012-06-20 16:38:30 -070011942/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011943 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 * This function is used to delete the key information
11945 */
11946#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011947static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011949 u8 key_index,
11950 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011951 const u8 *mac_addr
11952 )
11953#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011954static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 struct net_device *ndev,
11956 u8 key_index,
11957 const u8 *mac_addr
11958 )
11959#endif
11960{
11961 int status = 0;
11962
11963 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011964 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 //it is observed that this is invalidating peer
11966 //key index whenever re-key is done. This is affecting data link.
11967 //It should be ok to ignore del_key.
11968#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011969 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11970 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11972 tCsrRoamSetKey setKey;
11973 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011974
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 ENTER();
11976
11977 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11978 __func__,pAdapter->device_mode);
11979
11980 if (CSR_MAX_NUM_KEY <= key_index)
11981 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011982 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 key_index);
11984
11985 return -EINVAL;
11986 }
11987
11988 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11989 setKey.keyId = key_index;
11990
11991 if (mac_addr)
11992 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11993 else
11994 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11995
11996 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11997
11998 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012000 )
12001 {
12002
12003 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
12005 if( pHostapdState->bssState == BSS_START)
12006 {
12007 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012008
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 if ( status != eHAL_STATUS_SUCCESS )
12010 {
12011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12012 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12013 __LINE__, status );
12014 }
12015 }
12016 }
12017 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012018 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 )
12020 {
12021 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12022
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012023 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12024
12025 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012027 __func__, setKey.peerMac[0], setKey.peerMac[1],
12028 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012030 if(pAdapter->sessionCtx.station.conn_info.connState ==
12031 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012033 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012035
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 if ( 0 != status )
12037 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012038 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 "%s: sme_RoamSetKey failure, returned %d",
12040 __func__, status);
12041 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12042 return -EINVAL;
12043 }
12044 }
12045 }
12046#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012047 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012048 return status;
12049}
12050
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012051#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12052static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12053 struct net_device *ndev,
12054 u8 key_index,
12055 bool pairwise,
12056 const u8 *mac_addr
12057 )
12058#else
12059static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12060 struct net_device *ndev,
12061 u8 key_index,
12062 const u8 *mac_addr
12063 )
12064#endif
12065{
12066 int ret;
12067
12068 vos_ssr_protect(__func__);
12069#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12070 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
12071 mac_addr);
12072#else
12073 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
12074#endif
12075 vos_ssr_unprotect(__func__);
12076
12077 return ret;
12078}
12079
Jeff Johnson295189b2012-06-20 16:38:30 -070012080/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012081 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 * This function is used to set the default tx key index
12083 */
12084#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012085static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 struct net_device *ndev,
12087 u8 key_index,
12088 bool unicast, bool multicast)
12089#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012090static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012091 struct net_device *ndev,
12092 u8 key_index)
12093#endif
12094{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012095 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012096 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053012097 hdd_wext_state_t *pWextState;
12098 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012099 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012100
12101 ENTER();
12102
Gopichand Nakkala29149562013-05-10 21:43:41 +053012103 if ((NULL == pAdapter))
12104 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053012106 "invalid adapter");
12107 return -EINVAL;
12108 }
12109
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12111 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
12112 pAdapter->sessionId, key_index));
12113
Gopichand Nakkala29149562013-05-10 21:43:41 +053012114 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12115 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12116
12117 if ((NULL == pWextState) || (NULL == pHddStaCtx))
12118 {
12119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12120 "invalid Wext state or HDD context");
12121 return -EINVAL;
12122 }
12123
Arif Hussain6d2a3322013-11-17 19:50:10 -080012124 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012125 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012126
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 if (CSR_MAX_NUM_KEY <= key_index)
12128 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012129 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 key_index);
12131
12132 return -EINVAL;
12133 }
12134
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12136 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012137 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012138 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012139 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012140 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012141
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012144 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053012146 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080012147 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012148 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080012149 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012151 {
12152 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012154
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 tCsrRoamSetKey setKey;
12156 v_U32_t roamId= 0xFF;
12157 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012158
12159 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012161
Jeff Johnson295189b2012-06-20 16:38:30 -070012162 Keys->defaultIndex = (u8)key_index;
12163 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12164 setKey.keyId = key_index;
12165 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012166
12167 vos_mem_copy(&setKey.Key[0],
12168 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012169 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012170
Gopichand Nakkala29149562013-05-10 21:43:41 +053012171 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012172
12173 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 &pHddStaCtx->conn_info.bssId[0],
12175 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012176
Gopichand Nakkala29149562013-05-10 21:43:41 +053012177 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
12178 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
12179 eCSR_ENCRYPT_TYPE_WEP104)
12180 {
12181 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
12182 even though ap is configured for WEP-40 encryption. In this canse the key length
12183 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
12184 type(104) and switching encryption type to 40*/
12185 pWextState->roamProfile.EncryptionType.encryptionType[0] =
12186 eCSR_ENCRYPT_TYPE_WEP40;
12187 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
12188 eCSR_ENCRYPT_TYPE_WEP40;
12189 }
12190
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012191 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012193
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012195 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012197
Jeff Johnson295189b2012-06-20 16:38:30 -070012198 if ( 0 != status )
12199 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012200 hddLog(VOS_TRACE_LEVEL_ERROR,
12201 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 status);
12203 return -EINVAL;
12204 }
12205 }
12206 }
12207
12208 /* In SoftAp mode setting key direction for default mode */
12209 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12210 {
12211 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12212 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12213 (eCSR_ENCRYPT_TYPE_AES !=
12214 pWextState->roamProfile.EncryptionType.encryptionType[0])
12215 )
12216 {
12217 /* Saving key direction for default key index to TX default */
12218 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12219 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12220 }
12221 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012222 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 return status;
12224}
12225
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012226#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12227static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12228 struct net_device *ndev,
12229 u8 key_index,
12230 bool unicast, bool multicast)
12231#else
12232static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12233 struct net_device *ndev,
12234 u8 key_index)
12235#endif
12236{
12237 int ret;
12238 vos_ssr_protect(__func__);
12239#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12240 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12241 multicast);
12242#else
12243 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12244#endif
12245 vos_ssr_unprotect(__func__);
12246
12247 return ret;
12248}
12249
Jeff Johnson295189b2012-06-20 16:38:30 -070012250/*
12251 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12252 * This function is used to inform the BSS details to nl80211 interface.
12253 */
12254static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12255 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12256{
12257 struct net_device *dev = pAdapter->dev;
12258 struct wireless_dev *wdev = dev->ieee80211_ptr;
12259 struct wiphy *wiphy = wdev->wiphy;
12260 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12261 int chan_no;
12262 int ie_length;
12263 const char *ie;
12264 unsigned int freq;
12265 struct ieee80211_channel *chan;
12266 int rssi = 0;
12267 struct cfg80211_bss *bss = NULL;
12268
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 if( NULL == pBssDesc )
12270 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012271 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 return bss;
12273 }
12274
12275 chan_no = pBssDesc->channelId;
12276 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12277 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12278
12279 if( NULL == ie )
12280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012281 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012282 return bss;
12283 }
12284
12285#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12286 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12287 {
12288 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12289 }
12290 else
12291 {
12292 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12293 }
12294#else
12295 freq = ieee80211_channel_to_frequency(chan_no);
12296#endif
12297
12298 chan = __ieee80211_get_channel(wiphy, freq);
12299
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012300 if (!chan) {
12301 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12302 return NULL;
12303 }
12304
Abhishek Singhaee43942014-06-16 18:55:47 +053012305 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012306
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012307 return cfg80211_inform_bss(wiphy, chan,
12308#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12309 CFG80211_BSS_FTYPE_UNKNOWN,
12310#endif
12311 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012312 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 pBssDesc->capabilityInfo,
12314 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012315 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012316}
12317
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012318/*
12319 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12320 * interface that BSS might have been lost.
12321 * @pAdapter: adaptor
12322 * @bssid: bssid which might have been lost
12323 *
12324 * Return: bss which is unlinked from kernel cache
12325 */
12326struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12327 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12328{
12329 struct net_device *dev = pAdapter->dev;
12330 struct wireless_dev *wdev = dev->ieee80211_ptr;
12331 struct wiphy *wiphy = wdev->wiphy;
12332 struct cfg80211_bss *bss = NULL;
12333
Abhishek Singh5a597e62016-12-05 15:16:30 +053012334 bss = hdd_get_bss_entry(wiphy,
12335 NULL, bssid,
12336 NULL, 0);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012337 if (bss == NULL) {
12338 hddLog(LOGE, FL("BSS not present"));
12339 } else {
12340 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12341 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12342 cfg80211_unlink_bss(wiphy, bss);
12343 }
12344 return bss;
12345}
Jeff Johnson295189b2012-06-20 16:38:30 -070012346
12347
12348/*
12349 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12350 * This function is used to inform the BSS details to nl80211 interface.
12351 */
12352struct cfg80211_bss*
12353wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12354 tSirBssDescription *bss_desc
12355 )
12356{
12357 /*
12358 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12359 already exists in bss data base of cfg80211 for that particular BSS ID.
12360 Using cfg80211_inform_bss_frame to update the bss entry instead of
12361 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12362 now there is no possibility to get the mgmt(probe response) frame from PE,
12363 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12364 cfg80211_inform_bss_frame.
12365 */
12366 struct net_device *dev = pAdapter->dev;
12367 struct wireless_dev *wdev = dev->ieee80211_ptr;
12368 struct wiphy *wiphy = wdev->wiphy;
12369 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012370#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12371 qcom_ie_age *qie_age = NULL;
12372 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12373#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012375#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 const char *ie =
12377 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12378 unsigned int freq;
12379 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012380 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 struct cfg80211_bss *bss_status = NULL;
12382 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12383 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012384 hdd_context_t *pHddCtx;
12385 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012386#ifdef WLAN_OPEN_SOURCE
12387 struct timespec ts;
12388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012389
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012390
Wilson Yangf80a0542013-10-07 13:02:37 -070012391 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12392 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012393 if (0 != status)
12394 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012395 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012396 }
12397
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012398 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012399 if (!mgmt)
12400 {
12401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12402 "%s: memory allocation failed ", __func__);
12403 return NULL;
12404 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012405
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012407
12408#ifdef WLAN_OPEN_SOURCE
12409 /* Android does not want the timestamp from the frame.
12410 Instead it wants a monotonic increasing value */
12411 get_monotonic_boottime(&ts);
12412 mgmt->u.probe_resp.timestamp =
12413 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12414#else
12415 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012416 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12417 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012418
12419#endif
12420
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12422 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012423
12424#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12425 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12426 /* Assuming this is the last IE, copy at the end */
12427 ie_length -=sizeof(qcom_ie_age);
12428 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12429 qie_age->element_id = QCOM_VENDOR_IE_ID;
12430 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12431 qie_age->oui_1 = QCOM_OUI1;
12432 qie_age->oui_2 = QCOM_OUI2;
12433 qie_age->oui_3 = QCOM_OUI3;
12434 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053012435 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
12436 * bss related timestamp is in units of ms. Due to this when scan results
12437 * are sent to lowi the scan age is high.To address this, send age in units
12438 * of 1/10 ms.
12439 */
12440 qie_age->age = (vos_timer_get_system_time() -
12441 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012442#endif
12443
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012445 if (bss_desc->fProbeRsp)
12446 {
12447 mgmt->frame_control |=
12448 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12449 }
12450 else
12451 {
12452 mgmt->frame_control |=
12453 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012455
12456#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012457 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12459 {
12460 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12461 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012462 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12464
12465 {
12466 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12467 }
12468 else
12469 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12471 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 kfree(mgmt);
12473 return NULL;
12474 }
12475#else
12476 freq = ieee80211_channel_to_frequency(chan_no);
12477#endif
12478 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012479 /*when the band is changed on the fly using the GUI, three things are done
12480 * 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)
12481 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12482 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12483 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12484 * and discards the channels correponding to previous band and calls back with zero bss results.
12485 * 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
12486 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12487 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12488 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12489 * So drop the bss and continue to next bss.
12490 */
12491 if(chan == NULL)
12492 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053012493 hddLog(VOS_TRACE_LEVEL_ERROR,
12494 FL("chan pointer is NULL, chan_no: %d freq: %d"),
12495 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070012496 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012497 return NULL;
12498 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012499 /*To keep the rssi icon of the connected AP in the scan window
12500 *and the rssi icon of the wireless networks in sync
12501 * */
12502 if (( eConnectionState_Associated ==
12503 pAdapter->sessionCtx.station.conn_info.connState ) &&
12504 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12505 pAdapter->sessionCtx.station.conn_info.bssId,
12506 WNI_CFG_BSSID_LEN)) &&
12507 (pHddCtx->hdd_wlan_suspended == FALSE))
12508 {
12509 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12510 rssi = (pAdapter->rssi * 100);
12511 }
12512 else
12513 {
12514 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012516
Nirav Shah20ac06f2013-12-12 18:14:06 +053012517 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012518 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12519 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012520
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12522 frame_len, rssi, GFP_KERNEL);
12523 kfree(mgmt);
12524 return bss_status;
12525}
12526
12527/*
12528 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12529 * This function is used to update the BSS data base of CFG8011
12530 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012531struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 tCsrRoamInfo *pRoamInfo
12533 )
12534{
12535 tCsrRoamConnectedProfile roamProfile;
12536 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12537 struct cfg80211_bss *bss = NULL;
12538
12539 ENTER();
12540
12541 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12542 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12543
12544 if (NULL != roamProfile.pBssDesc)
12545 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012546 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12547 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012548
12549 if (NULL == bss)
12550 {
12551 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12552 __func__);
12553 }
12554
12555 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12556 }
12557 else
12558 {
12559 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12560 __func__);
12561 }
12562 return bss;
12563}
12564
12565/*
12566 * FUNCTION: wlan_hdd_cfg80211_update_bss
12567 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012568static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12569 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012571{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012572 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 tCsrScanResultInfo *pScanResult;
12574 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012575 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 tScanResultHandle pResult;
12577 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012578 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012579 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012581
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012582 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12583 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12584 NO_SESSION, pAdapter->sessionId));
12585
Wilson Yangf80a0542013-10-07 13:02:37 -070012586 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012587 ret = wlan_hdd_validate_context(pHddCtx);
12588 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012590 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070012591 }
12592
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012593 if (pAdapter->request != NULL)
12594 {
12595 if ((pAdapter->request->n_ssids == 1)
12596 && (pAdapter->request->ssids != NULL)
12597 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12598 is_p2p_scan = true;
12599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 /*
12601 * start getting scan results and populate cgf80211 BSS database
12602 */
12603 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12604
12605 /* no scan results */
12606 if (NULL == pResult)
12607 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012608 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12609 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012610 wlan_hdd_get_frame_logs(pAdapter,
12611 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 return status;
12613 }
12614
12615 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12616
12617 while (pScanResult)
12618 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012619 /*
12620 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12621 * entry already exists in bss data base of cfg80211 for that
12622 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12623 * bss entry instead of cfg80211_inform_bss, But this call expects
12624 * mgmt packet as input. As of now there is no possibility to get
12625 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 * ieee80211_mgmt(probe response) and passing to c
12627 * fg80211_inform_bss_frame.
12628 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012629 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12630 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12631 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012632 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12633 continue; //Skip the non p2p bss entries
12634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12636 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012637
Jeff Johnson295189b2012-06-20 16:38:30 -070012638
12639 if (NULL == bss_status)
12640 {
12641 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012642 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 }
12644 else
12645 {
Yue Maf49ba872013-08-19 12:04:25 -070012646 cfg80211_put_bss(
12647#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12648 wiphy,
12649#endif
12650 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 }
12652
12653 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12654 }
12655
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012656 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012657 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012658 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012659}
12660
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012661void
12662hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12663{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012664 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012665 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012666} /****** end hddPrintMacAddr() ******/
12667
12668void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012669hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012670{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012671 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012672 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012673 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12674 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12675 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012676} /****** end hddPrintPmkId() ******/
12677
12678//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12679//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12680
12681//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12682//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12683
12684#define dump_bssid(bssid) \
12685 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012686 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12687 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012688 }
12689
12690#define dump_pmkid(pMac, pmkid) \
12691 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012692 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12693 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012694 }
12695
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012696#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012697/*
12698 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12699 * This function is used to notify the supplicant of a new PMKSA candidate.
12700 */
12701int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012702 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012703 int index, bool preauth )
12704{
Jeff Johnsone7245742012-09-05 17:12:55 -070012705#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012706 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012707 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012708
12709 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012710 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012711
12712 if( NULL == pRoamInfo )
12713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012714 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012715 return -EINVAL;
12716 }
12717
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012718 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12719 {
12720 dump_bssid(pRoamInfo->bssid);
12721 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012722 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012723 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012724#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012725 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012726}
12727#endif //FEATURE_WLAN_LFR
12728
Yue Maef608272013-04-08 23:09:17 -070012729#ifdef FEATURE_WLAN_LFR_METRICS
12730/*
12731 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12732 * 802.11r/LFR metrics reporting function to report preauth initiation
12733 *
12734 */
12735#define MAX_LFR_METRICS_EVENT_LENGTH 100
12736VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12737 tCsrRoamInfo *pRoamInfo)
12738{
12739 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12740 union iwreq_data wrqu;
12741
12742 ENTER();
12743
12744 if (NULL == pAdapter)
12745 {
12746 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12747 return VOS_STATUS_E_FAILURE;
12748 }
12749
12750 /* create the event */
12751 memset(&wrqu, 0, sizeof(wrqu));
12752 memset(metrics_notification, 0, sizeof(metrics_notification));
12753
12754 wrqu.data.pointer = metrics_notification;
12755 wrqu.data.length = scnprintf(metrics_notification,
12756 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12757 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12758
12759 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12760
12761 EXIT();
12762
12763 return VOS_STATUS_SUCCESS;
12764}
12765
12766/*
12767 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12768 * 802.11r/LFR metrics reporting function to report preauth completion
12769 * or failure
12770 */
12771VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12772 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12773{
12774 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12775 union iwreq_data wrqu;
12776
12777 ENTER();
12778
12779 if (NULL == pAdapter)
12780 {
12781 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12782 return VOS_STATUS_E_FAILURE;
12783 }
12784
12785 /* create the event */
12786 memset(&wrqu, 0, sizeof(wrqu));
12787 memset(metrics_notification, 0, sizeof(metrics_notification));
12788
12789 scnprintf(metrics_notification, sizeof(metrics_notification),
12790 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12791 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12792
12793 if (1 == preauth_status)
12794 strncat(metrics_notification, " TRUE", 5);
12795 else
12796 strncat(metrics_notification, " FALSE", 6);
12797
12798 wrqu.data.pointer = metrics_notification;
12799 wrqu.data.length = strlen(metrics_notification);
12800
12801 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12802
12803 EXIT();
12804
12805 return VOS_STATUS_SUCCESS;
12806}
12807
12808/*
12809 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12810 * 802.11r/LFR metrics reporting function to report handover initiation
12811 *
12812 */
12813VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12814 tCsrRoamInfo *pRoamInfo)
12815{
12816 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12817 union iwreq_data wrqu;
12818
12819 ENTER();
12820
12821 if (NULL == pAdapter)
12822 {
12823 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12824 return VOS_STATUS_E_FAILURE;
12825 }
12826
12827 /* create the event */
12828 memset(&wrqu, 0, sizeof(wrqu));
12829 memset(metrics_notification, 0, sizeof(metrics_notification));
12830
12831 wrqu.data.pointer = metrics_notification;
12832 wrqu.data.length = scnprintf(metrics_notification,
12833 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12834 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12835
12836 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12837
12838 EXIT();
12839
12840 return VOS_STATUS_SUCCESS;
12841}
12842#endif
12843
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012844
12845/**
12846 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
12847 * @scan_req: scan request to be checked
12848 *
12849 * Return: true or false
12850 */
12851#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
12852static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12853 cfg80211_scan_request
12854 *scan_req)
12855{
12856 if (!scan_req || !scan_req->wiphy) {
12857 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12858 return false;
12859 }
12860 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
12861 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
12862 return false;
12863 }
12864 return true;
12865}
12866#else
12867static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12868 cfg80211_scan_request
12869 *scan_req)
12870{
12871 if (!scan_req || !scan_req->wiphy) {
12872 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12873 return false;
12874 }
12875 return true;
12876}
12877#endif
12878
12879
Jeff Johnson295189b2012-06-20 16:38:30 -070012880/*
12881 * FUNCTION: hdd_cfg80211_scan_done_callback
12882 * scanning callback function, called after finishing scan
12883 *
12884 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012885static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12887{
12888 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012889 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012891 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 struct cfg80211_scan_request *req = NULL;
12893 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012894 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012895#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12896 bool iface_down = false;
12897#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012898 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012899 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012900 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901
12902 ENTER();
12903
c_manjee1b4ab9a2016-10-26 11:36:55 +053012904 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
12905 !pAdapter->dev) {
12906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
12907 return 0;
12908 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012909 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012910 if (NULL == pHddCtx) {
12911 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012912 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012913 }
12914
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012915#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12916 if (!(pAdapter->dev->flags & IFF_UP))
12917 {
12918 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012919 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012920 }
12921#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012922 pScanInfo = &pHddCtx->scan_info;
12923
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 hddLog(VOS_TRACE_LEVEL_INFO,
12925 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012926 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 __func__, halHandle, pContext, (int) scanId, (int) status);
12928
Kiet Lamac06e2c2013-10-23 16:25:07 +053012929 pScanInfo->mScanPendingCounter = 0;
12930
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012932 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 &pScanInfo->scan_req_completion_event,
12934 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012935 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012937 hddLog(VOS_TRACE_LEVEL_ERROR,
12938 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012940 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012941 }
12942
Yue Maef608272013-04-08 23:09:17 -070012943 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 {
12945 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012946 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 }
12948
12949 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012950 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 {
12952 hddLog(VOS_TRACE_LEVEL_INFO,
12953 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012954 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 (int) scanId);
12956 }
12957
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012958#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012959 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012960#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012961 {
12962 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
12963 pAdapter);
12964 if (0 > ret)
12965 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012967
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 /* If any client wait scan result through WEXT
12969 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012970 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 {
12972 /* The other scan request waiting for current scan finish
12973 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012974 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012975 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012976 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 }
12978 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012979 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 {
12981 struct net_device *dev = pAdapter->dev;
12982 union iwreq_data wrqu;
12983 int we_event;
12984 char *msg;
12985
12986 memset(&wrqu, '\0', sizeof(wrqu));
12987 we_event = SIOCGIWSCAN;
12988 msg = NULL;
12989 wireless_send_event(dev, we_event, &wrqu, msg);
12990 }
12991 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012992 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012993
12994 /* Get the Scan Req */
12995 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053012996 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012997
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012998 /* Scan is no longer pending */
12999 pScanInfo->mScanPending = VOS_FALSE;
13000
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013001 if (!wlan_hdd_cfg80211_validate_scan_req(req))
Jeff Johnson295189b2012-06-20 16:38:30 -070013002 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013003#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
13005 iface_down ? "up" : "down");
13006#endif
13007
13008 if (pAdapter->dev) {
13009 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
13010 pAdapter->dev->name);
13011 }
mukul sharmae7041822015-12-03 15:09:21 +053013012 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070013013 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 }
13015
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013016 /* last_scan_timestamp is used to decide if new scan
13017 * is needed or not on station interface. If last station
13018 * scan time and new station scan time is less then
13019 * last_scan_timestamp ; driver will return cached scan.
13020 */
13021 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
13022 {
13023 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
13024
13025 if ( req->n_channels )
13026 {
13027 for (i = 0; i < req->n_channels ; i++ )
13028 {
13029 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
13030 }
13031 /* store no of channel scanned */
13032 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
13033 }
13034
13035 }
13036
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070013037 /*
13038 * cfg80211_scan_done informing NL80211 about completion
13039 * of scanning
13040 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013041 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
13042 {
13043 aborted = true;
13044 }
mukul sharmae7041822015-12-03 15:09:21 +053013045
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013046#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13047 if (!iface_down)
13048#endif
13049 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053013050
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080013051 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070013052
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013053allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013054 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
13055 ) && (pHddCtx->spoofMacAddr.isEnabled
13056 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053013057 /* Generate new random mac addr for next scan */
13058 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053013059
13060 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
13061 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053013062 }
13063
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013064 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013065 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013066
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013067 /* Acquire wakelock to handle the case where APP's tries to suspend
13068 * immediatly after the driver gets connect request(i.e after scan)
13069 * from supplicant, this result in app's is suspending and not able
13070 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013071 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013072
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013073#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13074 if (!iface_down)
13075#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013076#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013077 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013078#endif
13079
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 EXIT();
13081 return 0;
13082}
13083
13084/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053013085 * FUNCTION: hdd_isConnectionInProgress
13086 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013087 *
13088 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013089v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
13090 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013091{
13092 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13093 hdd_station_ctx_t *pHddStaCtx = NULL;
13094 hdd_adapter_t *pAdapter = NULL;
13095 VOS_STATUS status = 0;
13096 v_U8_t staId = 0;
13097 v_U8_t *staMac = NULL;
13098
13099 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
13100
13101 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
13102 {
13103 pAdapter = pAdapterNode->pAdapter;
13104
13105 if( pAdapter )
13106 {
13107 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013108 "%s: Adapter with device mode %s (%d) exists",
13109 __func__, hdd_device_modetoString(pAdapter->device_mode),
13110 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013111 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053013112 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13113 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
13114 (eConnectionState_Connecting ==
13115 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13116 {
13117 hddLog(VOS_TRACE_LEVEL_ERROR,
13118 "%s: %p(%d) Connection is in progress", __func__,
13119 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013120 if (session_id && reason)
13121 {
13122 *session_id = pAdapter->sessionId;
13123 *reason = eHDD_CONNECTION_IN_PROGRESS;
13124 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013125 return VOS_TRUE;
13126 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013127 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013128 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013129 {
13130 hddLog(VOS_TRACE_LEVEL_ERROR,
13131 "%s: %p(%d) Reassociation is in progress", __func__,
13132 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013133 if (session_id && reason)
13134 {
13135 *session_id = pAdapter->sessionId;
13136 *reason = eHDD_REASSOC_IN_PROGRESS;
13137 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013138 return VOS_TRUE;
13139 }
13140 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013141 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13142 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013143 {
13144 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13145 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013146 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013147 {
13148 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
13149 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013150 "%s: client " MAC_ADDRESS_STR
13151 " is in the middle of WPS/EAPOL exchange.", __func__,
13152 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013153 if (session_id && reason)
13154 {
13155 *session_id = pAdapter->sessionId;
13156 *reason = eHDD_EAPOL_IN_PROGRESS;
13157 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013158 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013159 }
13160 }
13161 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
13162 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
13163 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013164 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13165 ptSapContext pSapCtx = NULL;
13166 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13167 if(pSapCtx == NULL){
13168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13169 FL("psapCtx is NULL"));
13170 return VOS_FALSE;
13171 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013172 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
13173 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013174 if ((pSapCtx->aStaInfo[staId].isUsed) &&
13175 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013176 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013177 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013178
13179 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013180 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
13181 "middle of WPS/EAPOL exchange.", __func__,
13182 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013183 if (session_id && reason)
13184 {
13185 *session_id = pAdapter->sessionId;
13186 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
13187 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013188 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013189 }
13190 }
13191 }
13192 }
13193 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13194 pAdapterNode = pNext;
13195 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013196 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013197}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013198
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013199/**
13200 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
13201 * to the Scan request
13202 * @scanRequest: Pointer to the csr scan request
13203 * @request: Pointer to the scan request from supplicant
13204 *
13205 * Return: None
13206 */
13207#ifdef CFG80211_SCAN_BSSID
13208static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13209 struct cfg80211_scan_request *request)
13210{
13211 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13212}
13213#else
13214static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13215 struct cfg80211_scan_request *request)
13216{
13217}
13218#endif
13219
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013220/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013221 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 * this scan respond to scan trigger and update cfg80211 scan database
13223 * later, scan dump command can be used to recieve scan results
13224 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013225int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013226#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13227 struct net_device *dev,
13228#endif
13229 struct cfg80211_scan_request *request)
13230{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013231 hdd_adapter_t *pAdapter = NULL;
13232 hdd_context_t *pHddCtx = NULL;
13233 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013234 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 tCsrScanRequest scanRequest;
13236 tANI_U8 *channelList = NULL, i;
13237 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013238 int status;
13239 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013241 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013242 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013243 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013244 v_U8_t curr_session_id;
13245 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013246
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013247#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13248 struct net_device *dev = NULL;
13249 if (NULL == request)
13250 {
13251 hddLog(VOS_TRACE_LEVEL_ERROR,
13252 "%s: scan req param null", __func__);
13253 return -EINVAL;
13254 }
13255 dev = request->wdev->netdev;
13256#endif
13257
13258 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13259 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13260 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13261
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 ENTER();
13263
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13265 __func__, hdd_device_modetoString(pAdapter->device_mode),
13266 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013267
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013268 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013269 if (0 != status)
13270 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013271 return status;
13272 }
13273
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013274 if (NULL == pwextBuf)
13275 {
13276 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13277 __func__);
13278 return -EIO;
13279 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013280 cfg_param = pHddCtx->cfg_ini;
13281 pScanInfo = &pHddCtx->scan_info;
13282
Jeff Johnson295189b2012-06-20 16:38:30 -070013283#ifdef WLAN_BTAMP_FEATURE
13284 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013285 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013287 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013288 "%s: No scanning when AMP is on", __func__);
13289 return -EOPNOTSUPP;
13290 }
13291#endif
13292 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013293 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013295 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013296 "%s: Not scanning on device_mode = %s (%d)",
13297 __func__, hdd_device_modetoString(pAdapter->device_mode),
13298 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 return -EOPNOTSUPP;
13300 }
13301
13302 if (TRUE == pScanInfo->mScanPending)
13303 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013304 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13305 {
13306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13307 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013308 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 }
13310
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013311 // Don't allow scan if PNO scan is going on.
13312 if (pHddCtx->isPnoEnable)
13313 {
13314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13315 FL("pno scan in progress"));
13316 return -EBUSY;
13317 }
13318
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013319 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013320 //Channel and action frame is pending
13321 //Otherwise Cancel Remain On Channel and allow Scan
13322 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013323 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013324 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013325 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013326 return -EBUSY;
13327 }
13328
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13330 {
13331 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013332 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13336 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013337 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 "%s: MAX TM Level Scan not allowed", __func__);
13339 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013340 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 }
13342 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13343
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013344 /* Check if scan is allowed at this point of time.
13345 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013346 if (TRUE == pHddCtx->btCoexModeSet)
13347 {
13348 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13349 FL("BTCoex Mode operation in progress"));
13350 return -EBUSY;
13351 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013352 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013353 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013354 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013355 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
13356 pHddCtx->last_scan_reject_reason != curr_reason ||
13357 !pHddCtx->last_scan_reject_timestamp)
13358 {
13359 pHddCtx->last_scan_reject_session_id = curr_session_id;
13360 pHddCtx->last_scan_reject_reason = curr_reason;
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053013361 pHddCtx->last_scan_reject_timestamp = jiffies_to_msecs(jiffies);
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013362 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013363 else {
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053013364 if ((jiffies_to_msecs(jiffies) -
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013365 pHddCtx->last_scan_reject_timestamp) >=
13366 SCAN_REJECT_THRESHOLD_TIME)
13367 {
13368 pHddCtx->last_scan_reject_timestamp = 0;
13369 if (pHddCtx->cfg_ini->enableFatalEvent)
13370 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
13371 WLAN_LOG_INDICATOR_HOST_DRIVER,
13372 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
13373 FALSE, FALSE);
13374 else
13375 {
13376 hddLog(LOGE, FL("Triggering SSR"));
13377 vos_wlanRestart();
13378 }
13379 }
13380 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013381 return -EBUSY;
13382 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013383 pHddCtx->last_scan_reject_timestamp = 0;
13384 pHddCtx->last_scan_reject_session_id = 0xFF;
13385 pHddCtx->last_scan_reject_reason = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013386
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 vos_mem_zero( &scanRequest, sizeof(scanRequest));
13388
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013389 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
13390 * Becasue of this, driver is assuming that this is not wildcard scan and so
13391 * is not aging out the scan results.
13392 */
13393 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070013394 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013395 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013397
13398 if ((request->ssids) && (0 < request->n_ssids))
13399 {
13400 tCsrSSIDInfo *SsidInfo;
13401 int j;
13402 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
13403 /* Allocate num_ssid tCsrSSIDInfo structure */
13404 SsidInfo = scanRequest.SSIDs.SSIDList =
13405 ( tCsrSSIDInfo *)vos_mem_malloc(
13406 request->n_ssids*sizeof(tCsrSSIDInfo));
13407
13408 if(NULL == scanRequest.SSIDs.SSIDList)
13409 {
13410 hddLog(VOS_TRACE_LEVEL_ERROR,
13411 "%s: memory alloc failed SSIDInfo buffer", __func__);
13412 return -ENOMEM;
13413 }
13414
13415 /* copy all the ssid's and their length */
13416 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
13417 {
13418 /* get the ssid length */
13419 SsidInfo->SSID.length = request->ssids[j].ssid_len;
13420 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
13421 SsidInfo->SSID.length);
13422 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
13423 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
13424 j, SsidInfo->SSID.ssId);
13425 }
13426 /* set the scan type to active */
13427 scanRequest.scanType = eSIR_ACTIVE_SCAN;
13428 }
13429 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013431 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13432 TRACE_CODE_HDD_CFG80211_SCAN,
13433 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070013434 /* set the scan type to active */
13435 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070013436 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013437 else
13438 {
13439 /*Set the scan type to default type, in this case it is ACTIVE*/
13440 scanRequest.scanType = pScanInfo->scan_mode;
13441 }
13442 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13443 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013444
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013445 csr_scan_request_assign_bssid(&scanRequest, request);
13446
Jeff Johnson295189b2012-06-20 16:38:30 -070013447 /* set BSSType to default type */
13448 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13449
13450 /*TODO: scan the requested channels only*/
13451
13452 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013453 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013455 hddLog(VOS_TRACE_LEVEL_WARN,
13456 "No of Scan Channels exceeded limit: %d", request->n_channels);
13457 request->n_channels = MAX_CHANNEL;
13458 }
13459
13460 hddLog(VOS_TRACE_LEVEL_INFO,
13461 "No of Scan Channels: %d", request->n_channels);
13462
13463
13464 if( request->n_channels )
13465 {
13466 char chList [(request->n_channels*5)+1];
13467 int len;
13468 channelList = vos_mem_malloc( request->n_channels );
13469 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013470 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013471 hddLog(VOS_TRACE_LEVEL_ERROR,
13472 "%s: memory alloc failed channelList", __func__);
13473 status = -ENOMEM;
13474 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013475 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013476
13477 for( i = 0, len = 0; i < request->n_channels ; i++ )
13478 {
13479 channelList[i] = request->channels[i]->hw_value;
13480 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13481 }
13482
Nirav Shah20ac06f2013-12-12 18:14:06 +053013483 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013484 "Channel-List: %s ", chList);
13485 }
c_hpothu53512302014-04-15 18:49:53 +053013486
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013487 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13488 scanRequest.ChannelInfo.ChannelList = channelList;
13489
13490 /* set requestType to full scan */
13491 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13492
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013493 /* if there is back to back scan happening in driver with in
13494 * nDeferScanTimeInterval interval driver should defer new scan request
13495 * and should provide last cached scan results instead of new channel list.
13496 * This rule is not applicable if scan is p2p scan.
13497 * This condition will work only in case when last request no of channels
13498 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013499 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013500 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013501 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013502
Sushant Kaushik86592172015-04-27 16:35:03 +053013503 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13504 /* if wps ie is NULL , then only defer scan */
13505 if ( pWpsIe == NULL &&
13506 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013507 {
13508 if ( pScanInfo->last_scan_timestamp !=0 &&
13509 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13510 {
13511 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13512 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13513 vos_mem_compare(pScanInfo->last_scan_channelList,
13514 channelList, pScanInfo->last_scan_numChannels))
13515 {
13516 hddLog(VOS_TRACE_LEVEL_WARN,
13517 " New and old station scan time differ is less then %u",
13518 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13519
13520 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013521 pAdapter);
13522
Agarwal Ashish57e84372014-12-05 18:26:53 +053013523 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013524 "Return old cached scan as all channels and no of channels are same");
13525
Agarwal Ashish57e84372014-12-05 18:26:53 +053013526 if (0 > ret)
13527 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013528
Agarwal Ashish57e84372014-12-05 18:26:53 +053013529 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013530
13531 status = eHAL_STATUS_SUCCESS;
13532 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013533 }
13534 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013535 }
13536
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013537 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13538 * search (Flush on both full scan and social scan but not on single
13539 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13540 */
13541
13542 /* Supplicant does single channel scan after 8-way handshake
13543 * and in that case driver shoudnt flush scan results. If
13544 * driver flushes the scan results here and unfortunately if
13545 * the AP doesnt respond to our probe req then association
13546 * fails which is not desired
13547 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013548 if ((request->n_ssids == 1)
13549 && (request->ssids != NULL)
13550 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13551 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013552
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013553 if( is_p2p_scan ||
13554 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013555 {
13556 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13557 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13558 pAdapter->sessionId );
13559 }
13560
13561 if( request->ie_len )
13562 {
13563 /* save this for future association (join requires this) */
13564 /*TODO: Array needs to be converted to dynamic allocation,
13565 * as multiple ie.s can be sent in cfg80211_scan_request structure
13566 * CR 597966
13567 */
13568 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13569 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13570 pScanInfo->scanAddIE.length = request->ie_len;
13571
13572 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13573 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13574 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013576 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013578 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13579 memcpy( pwextBuf->roamProfile.addIEScan,
13580 request->ie, request->ie_len);
13581 }
13582 else
13583 {
13584 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13585 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013586 }
13587
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013588 }
13589 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13590 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13591
13592 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13593 request->ie_len);
13594 if (pP2pIe != NULL)
13595 {
13596#ifdef WLAN_FEATURE_P2P_DEBUG
13597 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13598 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13599 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013600 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013601 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13602 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13603 "Go nego completed to Connection is started");
13604 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13605 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013606 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013607 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13608 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013610 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13611 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13612 "Disconnected state to Connection is started");
13613 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13614 "for 4way Handshake");
13615 }
13616#endif
13617
13618 /* no_cck will be set during p2p find to disable 11b rates */
13619 if(TRUE == request->no_cck)
13620 {
13621 hddLog(VOS_TRACE_LEVEL_INFO,
13622 "%s: This is a P2P Search", __func__);
13623 scanRequest.p2pSearch = 1;
13624
13625 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013626 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013627 /* set requestType to P2P Discovery */
13628 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13629 }
13630
13631 /*
13632 Skip Dfs Channel in case of P2P Search
13633 if it is set in ini file
13634 */
13635 if(cfg_param->skipDfsChnlInP2pSearch)
13636 {
13637 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013638 }
13639 else
13640 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013641 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013643
Agarwal Ashish4f616132013-12-30 23:32:50 +053013644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 }
13646 }
13647
13648 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13649
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013650#ifdef FEATURE_WLAN_TDLS
13651 /* if tdls disagree scan right now, return immediately.
13652 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13653 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13654 */
13655 status = wlan_hdd_tdls_scan_callback (pAdapter,
13656 wiphy,
13657#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13658 dev,
13659#endif
13660 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013661 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013662 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053013663 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13665 "scan rejected %d", __func__, status);
13666 else
13667 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13668 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013669 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053013670 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013671 }
13672#endif
13673
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013674 /* acquire the wakelock to avoid the apps suspend during the scan. To
13675 * address the following issues.
13676 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13677 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13678 * for long time, this result in apps running at full power for long time.
13679 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13680 * be stuck in full power because of resume BMPS
13681 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013682 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013683
Nirav Shah20ac06f2013-12-12 18:14:06 +053013684 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13685 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013686 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13687 scanRequest.requestType, scanRequest.scanType,
13688 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013689 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13690
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013691 if (pHddCtx->spoofMacAddr.isEnabled &&
13692 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013693 {
13694 hddLog(VOS_TRACE_LEVEL_INFO,
13695 "%s: MAC Spoofing enabled for current scan", __func__);
13696 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13697 * to fill TxBds for probe request during current scan
13698 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013699 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013700 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013701
13702 if(status != VOS_STATUS_SUCCESS)
13703 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013704 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013705 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013706#ifdef FEATURE_WLAN_TDLS
13707 wlan_hdd_tdls_scan_done_callback(pAdapter);
13708#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013709 goto free_mem;
13710 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013711 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013712 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013713 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 pAdapter->sessionId, &scanRequest, &scanId,
13715 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013716
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 if (eHAL_STATUS_SUCCESS != status)
13718 {
13719 hddLog(VOS_TRACE_LEVEL_ERROR,
13720 "%s: sme_ScanRequest returned error %d", __func__, status);
13721 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013722 if(eHAL_STATUS_RESOURCES == status)
13723 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013724 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13725 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013726 status = -EBUSY;
13727 } else {
13728 status = -EIO;
13729 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013730 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013731
13732#ifdef FEATURE_WLAN_TDLS
13733 wlan_hdd_tdls_scan_done_callback(pAdapter);
13734#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 goto free_mem;
13736 }
13737
13738 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013739 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 pAdapter->request = request;
13741 pScanInfo->scanId = scanId;
13742
13743 complete(&pScanInfo->scan_req_completion_event);
13744
13745free_mem:
13746 if( scanRequest.SSIDs.SSIDList )
13747 {
13748 vos_mem_free(scanRequest.SSIDs.SSIDList);
13749 }
13750
13751 if( channelList )
13752 vos_mem_free( channelList );
13753
13754 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 return status;
13756}
13757
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013758int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13759#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13760 struct net_device *dev,
13761#endif
13762 struct cfg80211_scan_request *request)
13763{
13764 int ret;
13765
13766 vos_ssr_protect(__func__);
13767 ret = __wlan_hdd_cfg80211_scan(wiphy,
13768#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13769 dev,
13770#endif
13771 request);
13772 vos_ssr_unprotect(__func__);
13773
13774 return ret;
13775}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013776
13777void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13778{
13779 v_U8_t iniDot11Mode =
13780 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13781 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13782
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013783 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13784 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013785 switch ( iniDot11Mode )
13786 {
13787 case eHDD_DOT11_MODE_AUTO:
13788 case eHDD_DOT11_MODE_11ac:
13789 case eHDD_DOT11_MODE_11ac_ONLY:
13790#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013791 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13792 sme_IsFeatureSupportedByFW(DOT11AC) )
13793 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13794 else
13795 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013796#else
13797 hddDot11Mode = eHDD_DOT11_MODE_11n;
13798#endif
13799 break;
13800 case eHDD_DOT11_MODE_11n:
13801 case eHDD_DOT11_MODE_11n_ONLY:
13802 hddDot11Mode = eHDD_DOT11_MODE_11n;
13803 break;
13804 default:
13805 hddDot11Mode = iniDot11Mode;
13806 break;
13807 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013808#ifdef WLAN_FEATURE_AP_HT40_24G
13809 if (operationChannel > SIR_11B_CHANNEL_END)
13810#endif
13811 {
13812 /* This call decides required channel bonding mode */
13813 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013814 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13815 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013816 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013817}
13818
Jeff Johnson295189b2012-06-20 16:38:30 -070013819/*
13820 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013821 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013823int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013824 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13825 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013826{
13827 int status = 0;
13828 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013829 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 v_U32_t roamId;
13831 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013833 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013834
13835 ENTER();
13836
13837 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013838 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13839
13840 status = wlan_hdd_validate_context(pHddCtx);
13841 if (status)
13842 {
Yue Mae36e3552014-03-05 17:06:20 -080013843 return status;
13844 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013845
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13847 {
13848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13849 return -EINVAL;
13850 }
13851
13852 pRoamProfile = &pWextState->roamProfile;
13853
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013854 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013856 hdd_station_ctx_t *pHddStaCtx;
13857 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013858
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013859 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13860
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013861 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13863 {
13864 /*QoS not enabled in cfg file*/
13865 pRoamProfile->uapsd_mask = 0;
13866 }
13867 else
13868 {
13869 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013870 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13872 }
13873
13874 pRoamProfile->SSIDs.numOfSSIDs = 1;
13875 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13876 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013877 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13879 ssid, ssid_len);
13880
13881 if (bssid)
13882 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013883 pValidBssid = bssid;
13884 }
13885 else if (bssid_hint)
13886 {
13887 pValidBssid = bssid_hint;
13888 }
13889 if (pValidBssid)
13890 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013892 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013894 /* Save BSSID in seperate variable as well, as RoamProfile
13895 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 case of join failure we should send valid BSSID to supplicant
13897 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013898 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 WNI_CFG_BSSID_LEN);
13900 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070013901 else
13902 {
13903 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
13904 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013905
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013906 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13907 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13909 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013910 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 /*set gen ie*/
13912 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13913 /*set auth*/
13914 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013916#ifdef FEATURE_WLAN_WAPI
13917 if (pAdapter->wapi_info.nWapiMode)
13918 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013919 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 switch (pAdapter->wapi_info.wapiAuthMode)
13921 {
13922 case WAPI_AUTH_MODE_PSK:
13923 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013924 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 pAdapter->wapi_info.wapiAuthMode);
13926 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13927 break;
13928 }
13929 case WAPI_AUTH_MODE_CERT:
13930 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013931 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 pAdapter->wapi_info.wapiAuthMode);
13933 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13934 break;
13935 }
13936 } // End of switch
13937 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13938 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13939 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013940 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 pRoamProfile->AuthType.numEntries = 1;
13942 pRoamProfile->EncryptionType.numEntries = 1;
13943 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13944 pRoamProfile->mcEncryptionType.numEntries = 1;
13945 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13946 }
13947 }
13948#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013949#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013950 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013951 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13952 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13953 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013954 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13955 sizeof (tSirGtkOffloadParams));
13956 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013957 }
13958#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 pRoamProfile->csrPersona = pAdapter->device_mode;
13960
Jeff Johnson32d95a32012-09-10 13:15:23 -070013961 if( operatingChannel )
13962 {
13963 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13964 pRoamProfile->ChannelInfo.numOfChannels = 1;
13965 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013966 else
13967 {
13968 pRoamProfile->ChannelInfo.ChannelList = NULL;
13969 pRoamProfile->ChannelInfo.numOfChannels = 0;
13970 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013971 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13972 {
13973 hdd_select_cbmode(pAdapter,operatingChannel);
13974 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013975
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013976 /*
13977 * Change conn_state to connecting before sme_RoamConnect(),
13978 * because sme_RoamConnect() has a direct path to call
13979 * hdd_smeRoamCallback(), which will change the conn_state
13980 * If direct path, conn_state will be accordingly changed
13981 * to NotConnected or Associated by either
13982 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13983 * in sme_RoamCallback()
13984 * if sme_RomConnect is to be queued,
13985 * Connecting state will remain until it is completed.
13986 * If connection state is not changed,
13987 * connection state will remain in eConnectionState_NotConnected state.
13988 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13989 * if conn state is eConnectionState_NotConnected.
13990 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13991 * informed of connect result indication which is an issue.
13992 */
13993
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013994 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13995 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013996 {
13997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013998 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013999 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
14000 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053014001 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014002 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 pAdapter->sessionId, pRoamProfile, &roamId);
14004
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014005 if ((eHAL_STATUS_SUCCESS != status) &&
14006 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14007 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014008
14009 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014010 hddLog(VOS_TRACE_LEVEL_ERROR,
14011 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
14012 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014013 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014014 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014015 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014016 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014017
14018 pRoamProfile->ChannelInfo.ChannelList = NULL;
14019 pRoamProfile->ChannelInfo.numOfChannels = 0;
14020
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 }
14022 else
14023 {
14024 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
14025 return -EINVAL;
14026 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080014027 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 return status;
14029}
14030
14031/*
14032 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
14033 * This function is used to set the authentication type (OPEN/SHARED).
14034 *
14035 */
14036static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
14037 enum nl80211_auth_type auth_type)
14038{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014039 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14041
14042 ENTER();
14043
14044 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014045 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014048 hddLog(VOS_TRACE_LEVEL_INFO,
14049 "%s: set authentication type to AUTOSWITCH", __func__);
14050 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
14051 break;
14052
14053 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014054#ifdef WLAN_FEATURE_VOWIFI_11R
14055 case NL80211_AUTHTYPE_FT:
14056#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014057 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014058 "%s: set authentication type to OPEN", __func__);
14059 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14060 break;
14061
14062 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014063 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 "%s: set authentication type to SHARED", __func__);
14065 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
14066 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014067#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014069 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 "%s: set authentication type to CCKM WPA", __func__);
14071 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
14072 break;
14073#endif
14074
14075
14076 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014077 hddLog(VOS_TRACE_LEVEL_ERROR,
14078 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 auth_type);
14080 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
14081 return -EINVAL;
14082 }
14083
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014084 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 pHddStaCtx->conn_info.authType;
14086 return 0;
14087}
14088
14089/*
14090 * FUNCTION: wlan_hdd_set_akm_suite
14091 * This function is used to set the key mgmt type(PSK/8021x).
14092 *
14093 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014094static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 u32 key_mgmt
14096 )
14097{
14098 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14099 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053014100 /* Should be in ieee802_11_defs.h */
14101#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
14102#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 /*set key mgmt type*/
14104 switch(key_mgmt)
14105 {
14106 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053014107 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014108#ifdef WLAN_FEATURE_VOWIFI_11R
14109 case WLAN_AKM_SUITE_FT_PSK:
14110#endif
14111 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 __func__);
14113 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
14114 break;
14115
14116 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053014117 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014118#ifdef WLAN_FEATURE_VOWIFI_11R
14119 case WLAN_AKM_SUITE_FT_8021X:
14120#endif
14121 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 __func__);
14123 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14124 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014125#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014126#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
14127#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
14128 case WLAN_AKM_SUITE_CCKM:
14129 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
14130 __func__);
14131 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
14132 break;
14133#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070014134#ifndef WLAN_AKM_SUITE_OSEN
14135#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
14136 case WLAN_AKM_SUITE_OSEN:
14137 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
14138 __func__);
14139 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14140 break;
14141#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014142
14143 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014144 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 __func__, key_mgmt);
14146 return -EINVAL;
14147
14148 }
14149 return 0;
14150}
14151
14152/*
14153 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014154 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 * (NONE/WEP40/WEP104/TKIP/CCMP).
14156 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014157static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
14158 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 bool ucast
14160 )
14161{
14162 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014163 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14165
14166 ENTER();
14167
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014168 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053014170 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 __func__, cipher);
14172 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14173 }
14174 else
14175 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014176
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014178 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014179 {
14180 case IW_AUTH_CIPHER_NONE:
14181 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14182 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014183
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014185 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014187
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014189 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014191
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 case WLAN_CIPHER_SUITE_TKIP:
14193 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
14194 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014195
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 case WLAN_CIPHER_SUITE_CCMP:
14197 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14198 break;
14199#ifdef FEATURE_WLAN_WAPI
14200 case WLAN_CIPHER_SUITE_SMS4:
14201 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14202 break;
14203#endif
14204
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014205#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014206 case WLAN_CIPHER_SUITE_KRK:
14207 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14208 break;
14209#endif
14210 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014211 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 __func__, cipher);
14213 return -EOPNOTSUPP;
14214 }
14215 }
14216
14217 if (ucast)
14218 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014219 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 __func__, encryptionType);
14221 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14222 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014223 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 encryptionType;
14225 }
14226 else
14227 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014228 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 __func__, encryptionType);
14230 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14231 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14232 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14233 }
14234
14235 return 0;
14236}
14237
14238
14239/*
14240 * FUNCTION: wlan_hdd_cfg80211_set_ie
14241 * This function is used to parse WPA/RSN IE's.
14242 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014243int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014244#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14245 const u8 *ie,
14246#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014247 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014248#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 size_t ie_len
14250 )
14251{
14252 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014253#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14254 const u8 *genie = ie;
14255#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014257#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 v_U16_t remLen = ie_len;
14259#ifdef FEATURE_WLAN_WAPI
14260 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14261 u16 *tmp;
14262 v_U16_t akmsuiteCount;
14263 int *akmlist;
14264#endif
14265 ENTER();
14266
14267 /* clear previous assocAddIE */
14268 pWextState->assocAddIE.length = 0;
14269 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014270 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014271
14272 while (remLen >= 2)
14273 {
14274 v_U16_t eLen = 0;
14275 v_U8_t elementId;
14276 elementId = *genie++;
14277 eLen = *genie++;
14278 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014279
Arif Hussain6d2a3322013-11-17 19:50:10 -080014280 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014282
14283 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014285 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014286 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 -070014287 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014288 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 "%s: Invalid WPA IE", __func__);
14290 return -EINVAL;
14291 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014292 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014293 {
14294 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014295 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014297
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014298 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014299 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014300 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14301 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 VOS_ASSERT(0);
14303 return -ENOMEM;
14304 }
14305 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14306 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14307 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014308
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14310 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14311 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14312 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014313 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14314 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14316 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14317 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14318 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14319 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14320 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014321 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014322 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 {
14324 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014325 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014327
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014328 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014330 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14331 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 VOS_ASSERT(0);
14333 return -ENOMEM;
14334 }
14335 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14336 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14337 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014338
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14340 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014342#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014343 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
14344 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014345 /*Consider WFD IE, only for P2P Client */
14346 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
14347 {
14348 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014349 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014351
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014352 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014353 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014354 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14355 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014356 VOS_ASSERT(0);
14357 return -ENOMEM;
14358 }
14359 // WFD IE is saved to Additional IE ; it should be accumulated to handle
14360 // WPS IE + P2P IE + WFD IE
14361 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14362 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014363
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14365 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14366 }
14367#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014368 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014369 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014370 HS20_OUI_TYPE_SIZE)) )
14371 {
14372 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014373 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014374 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014375
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014376 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014377 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014378 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14379 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014380 VOS_ASSERT(0);
14381 return -ENOMEM;
14382 }
14383 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14384 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014385
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014386 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14387 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14388 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014389 /* Appending OSEN Information Element in Assiciation Request */
14390 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
14391 OSEN_OUI_TYPE_SIZE)) )
14392 {
14393 v_U16_t curAddIELen = pWextState->assocAddIE.length;
14394 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
14395 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014396
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014397 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014398 {
14399 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14400 "Need bigger buffer space");
14401 VOS_ASSERT(0);
14402 return -ENOMEM;
14403 }
14404 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14405 pWextState->assocAddIE.length += eLen + 2;
14406
14407 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
14408 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14409 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14410 }
14411
Abhishek Singh4322e622015-06-10 15:42:54 +053014412 /* Update only for WPA IE */
14413 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
14414 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014415
14416 /* populating as ADDIE in beacon frames */
14417 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014418 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014419 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
14420 {
14421 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14422 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
14423 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14424 {
14425 hddLog(LOGE,
14426 "Coldn't pass "
14427 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
14428 }
14429 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
14430 else
14431 hddLog(LOGE,
14432 "Could not pass on "
14433 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
14434
14435 /* IBSS mode doesn't contain params->proberesp_ies still
14436 beaconIE's need to be populated in probe response frames */
14437 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
14438 {
14439 u16 rem_probe_resp_ie_len = eLen + 2;
14440 u8 probe_rsp_ie_len[3] = {0};
14441 u8 counter = 0;
14442
14443 /* Check Probe Resp Length if it is greater then 255 then
14444 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14445 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14446 not able Store More then 255 bytes into One Variable */
14447
14448 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14449 {
14450 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14451 {
14452 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14453 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14454 }
14455 else
14456 {
14457 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14458 rem_probe_resp_ie_len = 0;
14459 }
14460 }
14461
14462 rem_probe_resp_ie_len = 0;
14463
14464 if (probe_rsp_ie_len[0] > 0)
14465 {
14466 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14467 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14468 (tANI_U8*)(genie - 2),
14469 probe_rsp_ie_len[0], NULL,
14470 eANI_BOOLEAN_FALSE)
14471 == eHAL_STATUS_FAILURE)
14472 {
14473 hddLog(LOGE,
14474 "Could not pass"
14475 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14476 }
14477 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14478 }
14479
14480 if (probe_rsp_ie_len[1] > 0)
14481 {
14482 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14483 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14484 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14485 probe_rsp_ie_len[1], NULL,
14486 eANI_BOOLEAN_FALSE)
14487 == eHAL_STATUS_FAILURE)
14488 {
14489 hddLog(LOGE,
14490 "Could not pass"
14491 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14492 }
14493 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14494 }
14495
14496 if (probe_rsp_ie_len[2] > 0)
14497 {
14498 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14499 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14500 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14501 probe_rsp_ie_len[2], NULL,
14502 eANI_BOOLEAN_FALSE)
14503 == eHAL_STATUS_FAILURE)
14504 {
14505 hddLog(LOGE,
14506 "Could not pass"
14507 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14508 }
14509 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14510 }
14511
14512 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14513 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14514 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14515 {
14516 hddLog(LOGE,
14517 "Could not pass"
14518 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14519 }
14520 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014521 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 break;
14523 case DOT11F_EID_RSN:
14524 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14525 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14526 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14527 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14528 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14529 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014530
Abhishek Singhb16f3562016-01-20 11:08:32 +053014531 /* Appending extended capabilities with Interworking or
14532 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053014533 *
14534 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053014535 * interworkingService or bsstransition bit is set to 1.
14536 * Driver is only interested in interworkingService and
14537 * bsstransition capability from supplicant.
14538 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053014539 * required from supplicat, it needs to be handled while
14540 * sending Assoc Req in LIM.
14541 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014542 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014543 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014544 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014545 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014546 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014547
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014548 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014549 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014550 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14551 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014552 VOS_ASSERT(0);
14553 return -ENOMEM;
14554 }
14555 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14556 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014557
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014558 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14559 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14560 break;
14561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014562#ifdef FEATURE_WLAN_WAPI
14563 case WLAN_EID_WAPI:
14564 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014565 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 pAdapter->wapi_info.nWapiMode);
14567 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014568 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014569 akmsuiteCount = WPA_GET_LE16(tmp);
14570 tmp = tmp + 1;
14571 akmlist = (int *)(tmp);
14572 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14573 {
14574 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14575 }
14576 else
14577 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014578 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 VOS_ASSERT(0);
14580 return -EINVAL;
14581 }
14582
14583 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14584 {
14585 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014586 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014587 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014590 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014592 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014593 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14594 }
14595 break;
14596#endif
14597 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014598 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014600 /* when Unknown IE is received we should break and continue
14601 * to the next IE in the buffer instead we were returning
14602 * so changing this to break */
14603 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014604 }
14605 genie += eLen;
14606 remLen -= eLen;
14607 }
14608 EXIT();
14609 return 0;
14610}
14611
14612/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014613 * FUNCTION: hdd_isWPAIEPresent
14614 * Parse the received IE to find the WPA IE
14615 *
14616 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014617static bool hdd_isWPAIEPresent(
14618#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14619 const u8 *ie,
14620#else
14621 u8 *ie,
14622#endif
14623 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014624{
14625 v_U8_t eLen = 0;
14626 v_U16_t remLen = ie_len;
14627 v_U8_t elementId = 0;
14628
14629 while (remLen >= 2)
14630 {
14631 elementId = *ie++;
14632 eLen = *ie++;
14633 remLen -= 2;
14634 if (eLen > remLen)
14635 {
14636 hddLog(VOS_TRACE_LEVEL_ERROR,
14637 "%s: IE length is wrong %d", __func__, eLen);
14638 return FALSE;
14639 }
14640 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14641 {
14642 /* OUI - 0x00 0X50 0XF2
14643 WPA Information Element - 0x01
14644 WPA version - 0x01*/
14645 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14646 return TRUE;
14647 }
14648 ie += eLen;
14649 remLen -= eLen;
14650 }
14651 return FALSE;
14652}
14653
14654/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014656 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014657 * parameters during connect operation.
14658 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014659int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014660 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014661 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014662{
14663 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014664 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014665 ENTER();
14666
14667 /*set wpa version*/
14668 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14669
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014670 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014671 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014672 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014673 {
14674 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14675 }
14676 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14677 {
14678 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14679 }
14680 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014681
14682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 pWextState->wpaVersion);
14684
14685 /*set authentication type*/
14686 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14687
14688 if (0 > status)
14689 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014690 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 "%s: failed to set authentication type ", __func__);
14692 return status;
14693 }
14694
14695 /*set key mgmt type*/
14696 if (req->crypto.n_akm_suites)
14697 {
14698 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14699 if (0 > status)
14700 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014701 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014702 __func__);
14703 return status;
14704 }
14705 }
14706
14707 /*set pairwise cipher type*/
14708 if (req->crypto.n_ciphers_pairwise)
14709 {
14710 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14711 req->crypto.ciphers_pairwise[0], true);
14712 if (0 > status)
14713 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014714 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014715 "%s: failed to set unicast cipher type", __func__);
14716 return status;
14717 }
14718 }
14719 else
14720 {
14721 /*Reset previous cipher suite to none*/
14722 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14723 if (0 > status)
14724 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014725 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 "%s: failed to set unicast cipher type", __func__);
14727 return status;
14728 }
14729 }
14730
14731 /*set group cipher type*/
14732 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14733 false);
14734
14735 if (0 > status)
14736 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014737 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 __func__);
14739 return status;
14740 }
14741
Chet Lanctot186b5732013-03-18 10:26:30 -070014742#ifdef WLAN_FEATURE_11W
14743 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14744#endif
14745
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14747 if (req->ie_len)
14748 {
14749 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14750 if ( 0 > status)
14751 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014752 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 __func__);
14754 return status;
14755 }
14756 }
14757
14758 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014759 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 {
14761 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14762 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14763 )
14764 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014765 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014766 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14767 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 __func__);
14770 return -EOPNOTSUPP;
14771 }
14772 else
14773 {
14774 u8 key_len = req->key_len;
14775 u8 key_idx = req->key_idx;
14776
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014777 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 && (CSR_MAX_NUM_KEY > key_idx)
14779 )
14780 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014781 hddLog(VOS_TRACE_LEVEL_INFO,
14782 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 __func__, key_idx, key_len);
14784 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014785 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014787 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014788 (u8)key_len;
14789 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14790 }
14791 }
14792 }
14793 }
14794
14795 return status;
14796}
14797
14798/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014799 * FUNCTION: wlan_hdd_try_disconnect
14800 * This function is used to disconnect from previous
14801 * connection
14802 */
14803static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
14804{
14805 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014806 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014807 hdd_station_ctx_t *pHddStaCtx;
14808 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014809 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014810
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014811 ret = wlan_hdd_validate_context(pHddCtx);
14812 if (0 != ret)
14813 {
14814 return ret;
14815 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014816 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14817
14818 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14819
14820 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14821 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014822 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014823 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14824 {
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014825 spin_lock_bh(&pAdapter->lock_for_active_session);
14826 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14827 {
14828 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14829 }
14830 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014831 hdd_connSetConnectionState(pHddStaCtx,
14832 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014833 /* Issue disconnect to CSR */
14834 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014835 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014836 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014837 eCSR_DISCONNECT_REASON_UNSPECIFIED);
14838 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
14839 hddLog(LOG1,
14840 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
14841 } else if ( 0 != status ) {
14842 hddLog(LOGE,
14843 FL("csrRoamDisconnect failure, returned %d"),
14844 (int)status );
14845 result = -EINVAL;
14846 goto disconnected;
14847 }
14848 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014849 &pAdapter->disconnect_comp_var,
14850 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014851 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
14852 hddLog(LOGE,
14853 "%s: Failed to disconnect, timed out", __func__);
14854 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014855 }
14856 }
14857 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14858 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014859 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014860 &pAdapter->disconnect_comp_var,
14861 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014862 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014863 {
14864 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014865 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014866 }
14867 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014868disconnected:
14869 hddLog(LOG1,
14870 FL("Set HDD connState to eConnectionState_NotConnected"));
14871 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14872 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014873}
14874
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014875/**
14876 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
14877 * @adapter: Pointer to the HDD adapter
14878 * @req: Pointer to the structure cfg_connect_params receieved from user space
14879 *
14880 * This function will start reassociation if bssid hint, channel hint and
14881 * previous bssid parameters are present in the connect request
14882 *
14883 * Return: success if reassociation is happening
14884 * Error code if reassociation is not permitted or not happening
14885 */
14886#ifdef CFG80211_CONNECT_PREV_BSSID
14887static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14888 struct cfg80211_connect_params *req)
14889{
14890 int status = -EPERM;
14891 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
14892 hddLog(VOS_TRACE_LEVEL_INFO,
14893 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
14894 req->channel_hint->hw_value,
14895 MAC_ADDR_ARRAY(req->bssid_hint));
14896 status = hdd_reassoc(adapter, req->bssid_hint,
14897 req->channel_hint->hw_value,
14898 CONNECT_CMD_USERSPACE);
14899 }
14900 return status;
14901}
14902#else
14903static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14904 struct cfg80211_connect_params *req)
14905{
14906 return -EPERM;
14907}
14908#endif
14909
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014910/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053014911 * FUNCTION: __wlan_hdd_cfg80211_connect
14912 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014914static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 struct net_device *ndev,
14916 struct cfg80211_connect_params *req
14917 )
14918{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014919 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014920 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053014921#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
14922 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014923 const u8 *bssid_hint = req->bssid_hint;
14924#else
14925 const u8 *bssid_hint = NULL;
14926#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014927 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053014929 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014930
14931 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014932
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014933 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14934 TRACE_CODE_HDD_CFG80211_CONNECT,
14935 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014936 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014937 "%s: device_mode = %s (%d)", __func__,
14938 hdd_device_modetoString(pAdapter->device_mode),
14939 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014940
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014942 if (!pHddCtx)
14943 {
14944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14945 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053014946 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014947 }
14948
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014949 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014950 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014952 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 }
14954
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014955 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
14956 if (0 == status)
14957 return status;
14958
Agarwal Ashish51325b52014-06-16 16:50:49 +053014959
Jeff Johnson295189b2012-06-20 16:38:30 -070014960#ifdef WLAN_BTAMP_FEATURE
14961 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014962 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014964 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080014966 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 }
14968#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014969
14970 //If Device Mode is Station Concurrent Sessions Exit BMps
14971 //P2P Mode will be taken care in Open/close adapter
14972 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053014973 (vos_concurrent_open_sessions_running())) {
14974 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14975 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014976 }
14977
14978 /*Try disconnecting if already in connected state*/
14979 status = wlan_hdd_try_disconnect(pAdapter);
14980 if ( 0 > status)
14981 {
14982 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14983 " connection"));
14984 return -EALREADY;
14985 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053014986 /* Check for max concurrent connections after doing disconnect if any*/
14987 if (vos_max_concurrent_connections_reached()) {
14988 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14989 return -ECONNREFUSED;
14990 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014991
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014993 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014994
14995 if ( 0 > status)
14996 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014997 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 __func__);
14999 return status;
15000 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053015001
15002 if (pHddCtx->spoofMacAddr.isEnabled)
15003 {
15004 hddLog(VOS_TRACE_LEVEL_INFO,
15005 "%s: MAC Spoofing enabled ", __func__);
15006 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15007 * to fill TxBds for probe request during SSID scan which may happen
15008 * as part of connect command
15009 */
15010 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
15011 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
15012 if (status != VOS_STATUS_SUCCESS)
15013 return -ECONNREFUSED;
15014 }
15015
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015016 if (req->channel)
15017 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070015018 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015019 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053015020
15021 /* Abort if any scan is going on */
15022 status = wlan_hdd_scan_abort(pAdapter);
15023 if (0 != status)
15024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
15025
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015026 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
15027 req->ssid_len, req->bssid,
15028 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015029
Sushant Kaushikd7083982015-03-18 14:33:24 +053015030 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 {
15032 //ReEnable BMPS if disabled
15033 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
15034 (NULL != pHddCtx))
15035 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053015036 if (pHddCtx->hdd_wlan_suspended)
15037 {
15038 hdd_set_pwrparams(pHddCtx);
15039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015040 //ReEnable Bmps and Imps back
15041 hdd_enable_bmps_imps(pHddCtx);
15042 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053015043 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015044 return status;
15045 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015046 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015047 EXIT();
15048 return status;
15049}
15050
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015051static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
15052 struct net_device *ndev,
15053 struct cfg80211_connect_params *req)
15054{
15055 int ret;
15056 vos_ssr_protect(__func__);
15057 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
15058 vos_ssr_unprotect(__func__);
15059
15060 return ret;
15061}
Jeff Johnson295189b2012-06-20 16:38:30 -070015062
15063/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015064 * FUNCTION: wlan_hdd_disconnect
15065 * This function is used to issue a disconnect request to SME
15066 */
15067int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
15068{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015069 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015070 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015071 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015072 long ret;
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015073 eConnectionState prev_conn_state;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015074
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015075 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015077 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015078 if (0 != status)
15079 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015080 return status;
15081 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053015082 /* Indicate sme of disconnect so that in progress connection or preauth
15083 * can be aborted
15084 */
15085 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053015086 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015087 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015088
Agarwal Ashish47d18112014-08-04 19:55:07 +053015089 /* Need to apply spin lock before decreasing active sessions
15090 * as there can be chance for double decrement if context switch
15091 * Calls hdd_DisConnectHandler.
15092 */
15093
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015094 prev_conn_state = pHddStaCtx->conn_info.connState;
15095
Agarwal Ashish47d18112014-08-04 19:55:07 +053015096 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015097 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15098 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015099 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15100 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053015101 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
15102 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015103
Abhishek Singhf4669da2014-05-26 15:07:49 +053015104 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053015105 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
15106
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015107 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015108
Mihir Shete182a0b22014-08-18 16:08:48 +053015109 /*
15110 * stop tx queues before deleting STA/BSS context from the firmware.
15111 * tx has to be disabled because the firmware can get busy dropping
15112 * the tx frames after BSS/STA has been deleted and will not send
15113 * back a response resulting in WDI timeout
15114 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053015115 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053015116 netif_tx_disable(pAdapter->dev);
15117 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015118
Mihir Shete182a0b22014-08-18 16:08:48 +053015119 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015120 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
15121 pAdapter->sessionId, reason);
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015122 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
15123 prev_conn_state != eConnectionState_Connecting)
15124 {
15125 hddLog(LOG1,
15126 FL("status = %d, already disconnected"), status);
15127 result = 0;
15128 goto disconnected;
15129 }
15130 /*
15131 * Wait here instead of returning directly, this will block the next
15132 * connect command and allow processing of the scan for ssid and
15133 * the previous connect command in CSR. Else we might hit some
15134 * race conditions leading to SME and HDD out of sync.
15135 */
15136 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015137 {
15138 hddLog(LOG1,
15139 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015140 }
15141 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015142 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015143 hddLog(LOGE,
15144 FL("csrRoamDisconnect failure, returned %d"),
15145 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015146 result = -EINVAL;
15147 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015148 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015149 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015150 &pAdapter->disconnect_comp_var,
15151 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015152 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015153 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015154 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015155 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015156 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015157 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015158disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015159 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015160 FL("Set HDD connState to eConnectionState_NotConnected"));
15161 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015162#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
15163 /* Sending disconnect event to userspace for kernel version < 3.11
15164 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
15165 */
15166 hddLog(LOG1, FL("Send disconnected event to userspace"));
15167
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053015168 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015169 WLAN_REASON_UNSPECIFIED);
15170#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015171
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015172 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015173 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015174}
15175
15176
15177/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015178 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 * This function is used to issue a disconnect request to SME
15180 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015181static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 struct net_device *dev,
15183 u16 reason
15184 )
15185{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015186 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015187 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015188 tCsrRoamProfile *pRoamProfile;
15189 hdd_station_ctx_t *pHddStaCtx;
15190 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015191#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015192 tANI_U8 staIdx;
15193#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015194
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015196
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015197 if (!pAdapter) {
15198 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15199 return -EINVAL;
15200 }
15201
15202 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15203 if (!pHddStaCtx) {
15204 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
15205 return -EINVAL;
15206 }
15207
15208 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15209 status = wlan_hdd_validate_context(pHddCtx);
15210 if (0 != status)
15211 {
15212 return status;
15213 }
15214
15215 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
15216
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015217 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15218 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15219 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015220 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15221 __func__, hdd_device_modetoString(pAdapter->device_mode),
15222 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015223
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015224 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15225 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015226
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 if (NULL != pRoamProfile)
15228 {
15229 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015230 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15231 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015233 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015235 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 switch(reason)
15237 {
15238 case WLAN_REASON_MIC_FAILURE:
15239 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15240 break;
15241
15242 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15243 case WLAN_REASON_DISASSOC_AP_BUSY:
15244 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15245 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15246 break;
15247
15248 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15249 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015250 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15252 break;
15253
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 default:
15255 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15256 break;
15257 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015258 pScanInfo = &pHddCtx->scan_info;
15259 if (pScanInfo->mScanPending)
15260 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015261 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015262 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015263 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015264 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015265 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015266 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015267#ifdef FEATURE_WLAN_TDLS
15268 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015269 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015270 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015271 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15272 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015273 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015274 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015275 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015277 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015278 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015279 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015280 status = sme_DeleteTdlsPeerSta(
15281 WLAN_HDD_GET_HAL_CTX(pAdapter),
15282 pAdapter->sessionId,
15283 mac);
15284 if (status != eHAL_STATUS_SUCCESS) {
15285 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15286 return -EPERM;
15287 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015288 }
15289 }
15290#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015291
15292 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
15293 reasonCode,
15294 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015295 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15296 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 {
15298 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015299 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015300 __func__, (int)status );
15301 return -EINVAL;
15302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015304 else
15305 {
15306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15307 "called while in %d state", __func__,
15308 pHddStaCtx->conn_info.connState);
15309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 }
15311 else
15312 {
15313 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15314 }
15315
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015316 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 return status;
15318}
15319
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015320static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15321 struct net_device *dev,
15322 u16 reason
15323 )
15324{
15325 int ret;
15326 vos_ssr_protect(__func__);
15327 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15328 vos_ssr_unprotect(__func__);
15329
15330 return ret;
15331}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015332
Jeff Johnson295189b2012-06-20 16:38:30 -070015333/*
15334 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015335 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 * settings in IBSS mode.
15337 */
15338static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015339 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 struct cfg80211_ibss_params *params
15341 )
15342{
15343 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015344 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
15346 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015347
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 ENTER();
15349
15350 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070015351 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070015352
15353 if (params->ie_len && ( NULL != params->ie) )
15354 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015355 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15356 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 {
15358 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15359 encryptionType = eCSR_ENCRYPT_TYPE_AES;
15360 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015361 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015363 tDot11fIEWPA dot11WPAIE;
15364 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015365 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015366
Wilson Yang00256342013-10-10 23:13:38 -070015367 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015368 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15369 params->ie_len, DOT11F_EID_WPA);
15370 if ( NULL != ie )
15371 {
15372 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15373 // Unpack the WPA IE
15374 //Skip past the EID byte and length byte - and four byte WiFi OUI
15375 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
15376 &ie[2+4],
15377 ie[1] - 4,
15378 &dot11WPAIE);
15379 /*Extract the multicast cipher, the encType for unicast
15380 cipher for wpa-none is none*/
15381 encryptionType =
15382 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
15383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015384 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015385
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
15387
15388 if (0 > status)
15389 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015390 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 __func__);
15392 return status;
15393 }
15394 }
15395
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015396 pWextState->roamProfile.AuthType.authType[0] =
15397 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 eCSR_AUTH_TYPE_OPEN_SYSTEM;
15399
15400 if (params->privacy)
15401 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015402 /* Security enabled IBSS, At this time there is no information available
15403 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015405 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015407 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 *enable privacy bit in beacons */
15409
15410 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
15411 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015412 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
15413 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
15415 pWextState->roamProfile.EncryptionType.numEntries = 1;
15416 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 return status;
15418}
15419
15420/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015421 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015422 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015424static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 struct net_device *dev,
15426 struct cfg80211_ibss_params *params
15427 )
15428{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15431 tCsrRoamProfile *pRoamProfile;
15432 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015433 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15434 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015435 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070015436
15437 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015438
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015439 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15440 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
15441 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015442 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015443 "%s: device_mode = %s (%d)", __func__,
15444 hdd_device_modetoString(pAdapter->device_mode),
15445 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015446
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015447 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015448 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015450 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 }
15452
15453 if (NULL == pWextState)
15454 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015455 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 __func__);
15457 return -EIO;
15458 }
15459
Agarwal Ashish51325b52014-06-16 16:50:49 +053015460 if (vos_max_concurrent_connections_reached()) {
15461 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15462 return -ECONNREFUSED;
15463 }
15464
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015465 /*Try disconnecting if already in connected state*/
15466 status = wlan_hdd_try_disconnect(pAdapter);
15467 if ( 0 > status)
15468 {
15469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15470 " IBSS connection"));
15471 return -EALREADY;
15472 }
15473
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 pRoamProfile = &pWextState->roamProfile;
15475
15476 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
15477 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015478 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015479 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015480 return -EINVAL;
15481 }
15482
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015483 /* BSSID is provided by upper layers hence no need to AUTO generate */
15484 if (NULL != params->bssid) {
15485 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15486 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
15487 hddLog (VOS_TRACE_LEVEL_ERROR,
15488 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15489 return -EIO;
15490 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015491 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015492 }
krunal sonie9002db2013-11-25 14:24:17 -080015493 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
15494 {
15495 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15496 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
15497 {
15498 hddLog (VOS_TRACE_LEVEL_ERROR,
15499 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15500 return -EIO;
15501 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015502
15503 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080015504 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015505 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080015506 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015507
Jeff Johnson295189b2012-06-20 16:38:30 -070015508 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070015509 if (NULL !=
15510#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15511 params->chandef.chan)
15512#else
15513 params->channel)
15514#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 {
15516 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015517 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
15518 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
15519 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15520 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015521
15522 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015523 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070015524 ieee80211_frequency_to_channel(
15525#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15526 params->chandef.chan->center_freq);
15527#else
15528 params->channel->center_freq);
15529#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015530
15531 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15532 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015533 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015534 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15535 __func__);
15536 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015537 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015538
15539 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015541 if (channelNum == validChan[indx])
15542 {
15543 break;
15544 }
15545 }
15546 if (indx >= numChans)
15547 {
15548 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 __func__, channelNum);
15550 return -EINVAL;
15551 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015552 /* Set the Operational Channel */
15553 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15554 channelNum);
15555 pRoamProfile->ChannelInfo.numOfChannels = 1;
15556 pHddStaCtx->conn_info.operationChannel = channelNum;
15557 pRoamProfile->ChannelInfo.ChannelList =
15558 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 }
15560
15561 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015562 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015563 if (status < 0)
15564 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015565 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015566 __func__);
15567 return status;
15568 }
15569
15570 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015571 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015572 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015573 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015574
15575 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015576 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015577
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015578 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015579 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015580}
15581
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015582static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15583 struct net_device *dev,
15584 struct cfg80211_ibss_params *params
15585 )
15586{
15587 int ret = 0;
15588
15589 vos_ssr_protect(__func__);
15590 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15591 vos_ssr_unprotect(__func__);
15592
15593 return ret;
15594}
15595
Jeff Johnson295189b2012-06-20 16:38:30 -070015596/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015597 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015598 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015599 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015600static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 struct net_device *dev
15602 )
15603{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015604 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015605 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15606 tCsrRoamProfile *pRoamProfile;
15607 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015608 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053015609 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015610#ifdef WLAN_FEATURE_RMC
15611 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
15612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015613
15614 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015615
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015616 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15617 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15618 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015619 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015620 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015621 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015622 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015623 }
15624
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015625 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15626 hdd_device_modetoString(pAdapter->device_mode),
15627 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015628 if (NULL == pWextState)
15629 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015630 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 __func__);
15632 return -EIO;
15633 }
15634
15635 pRoamProfile = &pWextState->roamProfile;
15636
15637 /* Issue disconnect only if interface type is set to IBSS */
15638 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15639 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015640 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 __func__);
15642 return -EINVAL;
15643 }
15644
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015645#ifdef WLAN_FEATURE_RMC
15646 /* Clearing add IE of beacon */
15647 if (ccmCfgSetStr(pHddCtx->hHal,
15648 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
15649 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
15650 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15651 {
15652 hddLog (VOS_TRACE_LEVEL_ERROR,
15653 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
15654 return -EINVAL;
15655 }
15656 if (ccmCfgSetInt(pHddCtx->hHal,
15657 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
15658 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15659 {
15660 hddLog (VOS_TRACE_LEVEL_ERROR,
15661 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
15662 __func__);
15663 return -EINVAL;
15664 }
15665
15666 // Reset WNI_CFG_PROBE_RSP Flags
15667 wlan_hdd_reset_prob_rspies(pAdapter);
15668
15669 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15670 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
15671 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15672 {
15673 hddLog (VOS_TRACE_LEVEL_ERROR,
15674 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
15675 __func__);
15676 return -EINVAL;
15677 }
15678#endif
15679
Jeff Johnson295189b2012-06-20 16:38:30 -070015680 /* Issue Disconnect request */
15681 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053015682 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
15683 pAdapter->sessionId,
15684 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15685 if (!HAL_STATUS_SUCCESS(hal_status)) {
15686 hddLog(LOGE,
15687 FL("sme_RoamDisconnect failed hal_status(%d)"),
15688 hal_status);
15689 return -EAGAIN;
15690 }
15691 status = wait_for_completion_timeout(
15692 &pAdapter->disconnect_comp_var,
15693 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
15694 if (!status) {
15695 hddLog(LOGE,
15696 FL("wait on disconnect_comp_var failed"));
15697 return -ETIMEDOUT;
15698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015699
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015700 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 return 0;
15702}
15703
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015704static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15705 struct net_device *dev
15706 )
15707{
15708 int ret = 0;
15709
15710 vos_ssr_protect(__func__);
15711 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15712 vos_ssr_unprotect(__func__);
15713
15714 return ret;
15715}
15716
Jeff Johnson295189b2012-06-20 16:38:30 -070015717/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015718 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015719 * This function is used to set the phy parameters
15720 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15721 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015722static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015723 u32 changed)
15724{
15725 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15726 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015727 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015728
15729 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015730
15731 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015732 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15733 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015734
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015735 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015736 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015737 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015738 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015739 }
15740
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15742 {
15743 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15744 WNI_CFG_RTS_THRESHOLD_STAMAX :
15745 wiphy->rts_threshold;
15746
15747 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015748 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015749 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015750 hddLog(VOS_TRACE_LEVEL_ERROR,
15751 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015752 __func__, rts_threshold);
15753 return -EINVAL;
15754 }
15755
15756 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15757 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015758 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015759 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015760 hddLog(VOS_TRACE_LEVEL_ERROR,
15761 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015762 __func__, rts_threshold);
15763 return -EIO;
15764 }
15765
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015766 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015767 rts_threshold);
15768 }
15769
15770 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15771 {
15772 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15773 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15774 wiphy->frag_threshold;
15775
15776 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015777 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015778 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015779 hddLog(VOS_TRACE_LEVEL_ERROR,
15780 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 frag_threshold);
15782 return -EINVAL;
15783 }
15784
15785 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15786 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015787 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015788 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015789 hddLog(VOS_TRACE_LEVEL_ERROR,
15790 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 __func__, frag_threshold);
15792 return -EIO;
15793 }
15794
15795 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15796 frag_threshold);
15797 }
15798
15799 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15800 || (changed & WIPHY_PARAM_RETRY_LONG))
15801 {
15802 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15803 wiphy->retry_short :
15804 wiphy->retry_long;
15805
15806 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15807 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15808 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015809 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 __func__, retry_value);
15811 return -EINVAL;
15812 }
15813
15814 if (changed & WIPHY_PARAM_RETRY_SHORT)
15815 {
15816 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15817 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015818 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015819 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015820 hddLog(VOS_TRACE_LEVEL_ERROR,
15821 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015822 __func__, retry_value);
15823 return -EIO;
15824 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015825 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015826 __func__, retry_value);
15827 }
15828 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15829 {
15830 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15831 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015832 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015834 hddLog(VOS_TRACE_LEVEL_ERROR,
15835 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 __func__, retry_value);
15837 return -EIO;
15838 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015839 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015840 __func__, retry_value);
15841 }
15842 }
15843
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015844 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015845 return 0;
15846}
15847
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015848static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15849 u32 changed)
15850{
15851 int ret;
15852
15853 vos_ssr_protect(__func__);
15854 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15855 vos_ssr_unprotect(__func__);
15856
15857 return ret;
15858}
15859
Jeff Johnson295189b2012-06-20 16:38:30 -070015860/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015861 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015862 * This function is used to set the txpower
15863 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015864static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015865#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15866 struct wireless_dev *wdev,
15867#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015868#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015869 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015870#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015871 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015872#endif
15873 int dbm)
15874{
15875 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015876 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015877 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15878 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015879 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015880
15881 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015882
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015883 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15884 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15885 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015886 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015887 if (0 != status)
15888 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015889 return status;
15890 }
15891
15892 hHal = pHddCtx->hHal;
15893
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015894 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15895 dbm, ccmCfgSetCallback,
15896 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015897 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015898 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015899 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15900 return -EIO;
15901 }
15902
15903 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15904 dbm);
15905
15906 switch(type)
15907 {
15908 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
15909 /* Fall through */
15910 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
15911 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
15912 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
15914 __func__);
15915 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 }
15917 break;
15918 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015919 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015920 __func__);
15921 return -EOPNOTSUPP;
15922 break;
15923 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015924 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
15925 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070015926 return -EIO;
15927 }
15928
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015929 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 return 0;
15931}
15932
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015933static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
15934#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15935 struct wireless_dev *wdev,
15936#endif
15937#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15938 enum tx_power_setting type,
15939#else
15940 enum nl80211_tx_power_setting type,
15941#endif
15942 int dbm)
15943{
15944 int ret;
15945 vos_ssr_protect(__func__);
15946 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
15947#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15948 wdev,
15949#endif
15950#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15951 type,
15952#else
15953 type,
15954#endif
15955 dbm);
15956 vos_ssr_unprotect(__func__);
15957
15958 return ret;
15959}
15960
Jeff Johnson295189b2012-06-20 16:38:30 -070015961/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015962 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015963 * This function is used to read the txpower
15964 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015965static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015966#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15967 struct wireless_dev *wdev,
15968#endif
15969 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070015970{
15971
15972 hdd_adapter_t *pAdapter;
15973 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015974 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015975
Jeff Johnsone7245742012-09-05 17:12:55 -070015976 ENTER();
15977
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015978 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015979 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015980 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015981 *dbm = 0;
15982 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015983 }
15984
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
15986 if (NULL == pAdapter)
15987 {
15988 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
15989 return -ENOENT;
15990 }
15991
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015992 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15993 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
15994 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 wlan_hdd_get_classAstats(pAdapter);
15996 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
15997
Jeff Johnsone7245742012-09-05 17:12:55 -070015998 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015999 return 0;
16000}
16001
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016002static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
16003#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16004 struct wireless_dev *wdev,
16005#endif
16006 int *dbm)
16007{
16008 int ret;
16009
16010 vos_ssr_protect(__func__);
16011 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
16012#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16013 wdev,
16014#endif
16015 dbm);
16016 vos_ssr_unprotect(__func__);
16017
16018 return ret;
16019}
16020
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016021static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016022#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16023 const u8* mac,
16024#else
16025 u8* mac,
16026#endif
16027 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070016028{
16029 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
16030 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16031 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053016032 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016033
16034 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
16035 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070016036
16037 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
16038 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
16039 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
16040 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
16041 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
16042 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
16043 tANI_U16 maxRate = 0;
16044 tANI_U16 myRate;
16045 tANI_U16 currentRate = 0;
16046 tANI_U8 maxSpeedMCS = 0;
16047 tANI_U8 maxMCSIdx = 0;
16048 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053016049 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070016050 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016051 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016052
Leo Chang6f8870f2013-03-26 18:11:36 -070016053#ifdef WLAN_FEATURE_11AC
16054 tANI_U32 vht_mcs_map;
16055 eDataRate11ACMaxMcs vhtMaxMcs;
16056#endif /* WLAN_FEATURE_11AC */
16057
Jeff Johnsone7245742012-09-05 17:12:55 -070016058 ENTER();
16059
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16061 (0 == ssidlen))
16062 {
16063 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
16064 " Invalid ssidlen, %d", __func__, ssidlen);
16065 /*To keep GUI happy*/
16066 return 0;
16067 }
16068
Mukul Sharma811205f2014-07-09 21:07:30 +053016069 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16070 {
16071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16072 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053016073 /* return a cached value */
16074 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053016075 return 0;
16076 }
16077
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016078 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016079 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016080 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016081 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016082 }
16083
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053016084 wlan_hdd_get_station_stats(pAdapter);
16085 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016086
Kiet Lam3b17fc82013-09-27 05:24:08 +053016087 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
16088 sinfo->filled |= STATION_INFO_SIGNAL;
16089
c_hpothu09f19542014-05-30 21:53:31 +053016090 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053016091 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
16092 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053016093 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053016094 {
16095 rate_flags = pAdapter->maxRateFlags;
16096 }
c_hpothu44ff4e02014-05-08 00:13:57 +053016097
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 //convert to the UI units of 100kbps
16099 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
16100
16101#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070016102 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 -070016103 sinfo->signal,
16104 pCfg->reportMaxLinkSpeed,
16105 myRate,
16106 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016107 (int) pCfg->linkSpeedRssiMid,
16108 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070016109 (int) rate_flags,
16110 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070016111#endif //LINKSPEED_DEBUG_ENABLED
16112
16113 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
16114 {
16115 // we do not want to necessarily report the current speed
16116 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
16117 {
16118 // report the max possible speed
16119 rssidx = 0;
16120 }
16121 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
16122 {
16123 // report the max possible speed with RSSI scaling
16124 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
16125 {
16126 // report the max possible speed
16127 rssidx = 0;
16128 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016129 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016130 {
16131 // report middle speed
16132 rssidx = 1;
16133 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016134 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
16135 {
16136 // report middle speed
16137 rssidx = 2;
16138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016139 else
16140 {
16141 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016142 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070016143 }
16144 }
16145 else
16146 {
16147 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
16148 hddLog(VOS_TRACE_LEVEL_ERROR,
16149 "%s: Invalid value for reportMaxLinkSpeed: %u",
16150 __func__, pCfg->reportMaxLinkSpeed);
16151 rssidx = 0;
16152 }
16153
16154 maxRate = 0;
16155
16156 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016157 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
16158 OperationalRates, &ORLeng))
16159 {
16160 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16161 /*To keep GUI happy*/
16162 return 0;
16163 }
16164
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 for (i = 0; i < ORLeng; i++)
16166 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016167 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016168 {
16169 /* Validate Rate Set */
16170 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
16171 {
16172 currentRate = supported_data_rate[j].supported_rate[rssidx];
16173 break;
16174 }
16175 }
16176 /* Update MAX rate */
16177 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16178 }
16179
16180 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016181 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
16182 ExtendedRates, &ERLeng))
16183 {
16184 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16185 /*To keep GUI happy*/
16186 return 0;
16187 }
16188
Jeff Johnson295189b2012-06-20 16:38:30 -070016189 for (i = 0; i < ERLeng; i++)
16190 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016191 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016192 {
16193 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
16194 {
16195 currentRate = supported_data_rate[j].supported_rate[rssidx];
16196 break;
16197 }
16198 }
16199 /* Update MAX rate */
16200 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16201 }
c_hpothu79aab322014-07-14 21:11:01 +053016202
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016203 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053016204 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016205 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053016206 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070016207 {
c_hpothu79aab322014-07-14 21:11:01 +053016208 if (rate_flags & eHAL_TX_RATE_VHT80)
16209 mode = 2;
16210 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
16211 mode = 1;
16212 else
16213 mode = 0;
16214
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016215 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
16216 MCSRates, &MCSLeng))
16217 {
16218 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16219 /*To keep GUI happy*/
16220 return 0;
16221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016222 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070016223#ifdef WLAN_FEATURE_11AC
16224 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016225 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070016226 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016227 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016228 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070016229 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070016230 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016231 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016232 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016233 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070016234 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016235 maxMCSIdx = 7;
16236 }
16237 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16238 {
16239 maxMCSIdx = 8;
16240 }
16241 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16242 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016243 //VHT20 is supporting 0~8
16244 if (rate_flags & eHAL_TX_RATE_VHT20)
16245 maxMCSIdx = 8;
16246 else
16247 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016248 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016249
c_hpothu79aab322014-07-14 21:11:01 +053016250 if (0 != rssidx)/*check for scaled */
16251 {
16252 //get middle rate MCS index if rssi=1/2
16253 for (i=0; i <= maxMCSIdx; i++)
16254 {
16255 if (sinfo->signal <= rssiMcsTbl[mode][i])
16256 {
16257 maxMCSIdx = i;
16258 break;
16259 }
16260 }
16261 }
16262
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016263 if (rate_flags & eHAL_TX_RATE_VHT80)
16264 {
16265 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16266 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16267 }
16268 else if (rate_flags & eHAL_TX_RATE_VHT40)
16269 {
16270 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
16271 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
16272 }
16273 else if (rate_flags & eHAL_TX_RATE_VHT20)
16274 {
16275 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
16276 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
16277 }
16278
Leo Chang6f8870f2013-03-26 18:11:36 -070016279 maxSpeedMCS = 1;
16280 if (currentRate > maxRate)
16281 {
16282 maxRate = currentRate;
16283 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016284
Leo Chang6f8870f2013-03-26 18:11:36 -070016285 }
16286 else
16287#endif /* WLAN_FEATURE_11AC */
16288 {
16289 if (rate_flags & eHAL_TX_RATE_HT40)
16290 {
16291 rateFlag |= 1;
16292 }
16293 if (rate_flags & eHAL_TX_RATE_SGI)
16294 {
16295 rateFlag |= 2;
16296 }
16297
Girish Gowli01abcee2014-07-31 20:18:55 +053016298 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053016299 if (rssidx == 1 || rssidx == 2)
16300 {
16301 //get middle rate MCS index if rssi=1/2
16302 for (i=0; i <= 7; i++)
16303 {
16304 if (sinfo->signal <= rssiMcsTbl[mode][i])
16305 {
16306 temp = i+1;
16307 break;
16308 }
16309 }
16310 }
c_hpothu79aab322014-07-14 21:11:01 +053016311
16312 for (i = 0; i < MCSLeng; i++)
16313 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016314 for (j = 0; j < temp; j++)
16315 {
16316 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
16317 {
16318 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016319 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016320 break;
16321 }
16322 }
16323 if ((j < temp) && (currentRate > maxRate))
16324 {
16325 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070016326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016328 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016329 }
16330 }
16331
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016332 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
16333 {
16334 maxRate = myRate;
16335 maxSpeedMCS = 1;
16336 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053016339 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070016340 {
16341 maxRate = myRate;
16342 if (rate_flags & eHAL_TX_RATE_LEGACY)
16343 {
16344 maxSpeedMCS = 0;
16345 }
16346 else
16347 {
16348 maxSpeedMCS = 1;
16349 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16350 }
16351 }
16352
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016353 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 {
16355 sinfo->txrate.legacy = maxRate;
16356#ifdef LINKSPEED_DEBUG_ENABLED
16357 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
16358#endif //LINKSPEED_DEBUG_ENABLED
16359 }
16360 else
16361 {
16362 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070016363#ifdef WLAN_FEATURE_11AC
16364 sinfo->txrate.nss = 1;
16365 if (rate_flags & eHAL_TX_RATE_VHT80)
16366 {
16367 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016368 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070016369 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016370 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070016371 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016372 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16373 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16374 }
16375 else if (rate_flags & eHAL_TX_RATE_VHT20)
16376 {
16377 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16378 }
16379#endif /* WLAN_FEATURE_11AC */
16380 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
16381 {
16382 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16383 if (rate_flags & eHAL_TX_RATE_HT40)
16384 {
16385 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16386 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016388 if (rate_flags & eHAL_TX_RATE_SGI)
16389 {
16390 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16391 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016392
Jeff Johnson295189b2012-06-20 16:38:30 -070016393#ifdef LINKSPEED_DEBUG_ENABLED
16394 pr_info("Reporting MCS rate %d flags %x\n",
16395 sinfo->txrate.mcs,
16396 sinfo->txrate.flags );
16397#endif //LINKSPEED_DEBUG_ENABLED
16398 }
16399 }
16400 else
16401 {
16402 // report current rate instead of max rate
16403
16404 if (rate_flags & eHAL_TX_RATE_LEGACY)
16405 {
16406 //provide to the UI in units of 100kbps
16407 sinfo->txrate.legacy = myRate;
16408#ifdef LINKSPEED_DEBUG_ENABLED
16409 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
16410#endif //LINKSPEED_DEBUG_ENABLED
16411 }
16412 else
16413 {
16414 //must be MCS
16415 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016416#ifdef WLAN_FEATURE_11AC
16417 sinfo->txrate.nss = 1;
16418 if (rate_flags & eHAL_TX_RATE_VHT80)
16419 {
16420 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16421 }
16422 else
16423#endif /* WLAN_FEATURE_11AC */
16424 {
16425 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 if (rate_flags & eHAL_TX_RATE_SGI)
16428 {
16429 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16430 }
16431 if (rate_flags & eHAL_TX_RATE_HT40)
16432 {
16433 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16434 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016435#ifdef WLAN_FEATURE_11AC
16436 else if (rate_flags & eHAL_TX_RATE_VHT80)
16437 {
16438 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
16439 }
16440#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070016441#ifdef LINKSPEED_DEBUG_ENABLED
16442 pr_info("Reporting actual MCS rate %d flags %x\n",
16443 sinfo->txrate.mcs,
16444 sinfo->txrate.flags );
16445#endif //LINKSPEED_DEBUG_ENABLED
16446 }
16447 }
16448 sinfo->filled |= STATION_INFO_TX_BITRATE;
16449
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016450 sinfo->tx_packets =
16451 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
16452 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
16453 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
16454 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
16455
16456 sinfo->tx_retries =
16457 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
16458 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
16459 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
16460 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
16461
16462 sinfo->tx_failed =
16463 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
16464 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
16465 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
16466 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
16467
16468 sinfo->filled |=
16469 STATION_INFO_TX_PACKETS |
16470 STATION_INFO_TX_RETRIES |
16471 STATION_INFO_TX_FAILED;
16472
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053016473 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
16474 sinfo->filled |= STATION_INFO_RX_PACKETS;
16475
16476 if (rate_flags & eHAL_TX_RATE_LEGACY)
16477 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
16478 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
16479 sinfo->rx_packets);
16480 else
16481 hddLog(LOG1,
16482 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
16483 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
16484 sinfo->tx_packets, sinfo->rx_packets);
16485
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016486 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16487 TRACE_CODE_HDD_CFG80211_GET_STA,
16488 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016489 EXIT();
16490 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016491}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016492#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16493static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16494 const u8* mac, struct station_info *sinfo)
16495#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016496static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16497 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016498#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016499{
16500 int ret;
16501
16502 vos_ssr_protect(__func__);
16503 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
16504 vos_ssr_unprotect(__func__);
16505
16506 return ret;
16507}
16508
16509static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070016510 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070016511{
16512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016513 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016515 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016516
Jeff Johnsone7245742012-09-05 17:12:55 -070016517 ENTER();
16518
Jeff Johnson295189b2012-06-20 16:38:30 -070016519 if (NULL == pAdapter)
16520 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016521 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016522 return -ENODEV;
16523 }
16524
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016525 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16526 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
16527 pAdapter->sessionId, timeout));
16528
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016529 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016530 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016531 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016532 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016533 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016534 }
16535
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016536 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
16537 (TRUE == pHddCtx->hdd_wlan_suspended) &&
16538 (pHddCtx->cfg_ini->fhostArpOffload) &&
16539 (eConnectionState_Associated ==
16540 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
16541 {
Amar Singhald53568e2013-09-26 11:03:45 -070016542
16543 hddLog(VOS_TRACE_LEVEL_INFO,
16544 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053016545 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016546 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16547 {
16548 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016549 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016550 __func__, vos_status);
16551 }
16552 }
16553
Jeff Johnson295189b2012-06-20 16:38:30 -070016554 /**The get power cmd from the supplicant gets updated by the nl only
16555 *on successful execution of the function call
16556 *we are oppositely mapped w.r.t mode in the driver
16557 **/
16558 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
16559
16560 if (VOS_STATUS_E_FAILURE == vos_status)
16561 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016562 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16563 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016564 return -EINVAL;
16565 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016566 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016567 return 0;
16568}
16569
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016570static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16571 struct net_device *dev, bool mode, int timeout)
16572{
16573 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016574
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016575 vos_ssr_protect(__func__);
16576 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
16577 vos_ssr_unprotect(__func__);
16578
16579 return ret;
16580}
Sushant Kaushik084f6592015-09-10 13:11:56 +053016581
Jeff Johnson295189b2012-06-20 16:38:30 -070016582#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016583static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
16584 struct net_device *netdev,
16585 u8 key_index)
16586{
16587 ENTER();
16588 return 0;
16589}
16590
Jeff Johnson295189b2012-06-20 16:38:30 -070016591static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016592 struct net_device *netdev,
16593 u8 key_index)
16594{
16595 int ret;
16596 vos_ssr_protect(__func__);
16597 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16598 vos_ssr_unprotect(__func__);
16599 return ret;
16600}
16601#endif //LINUX_VERSION_CODE
16602
16603#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16604static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16605 struct net_device *dev,
16606 struct ieee80211_txq_params *params)
16607{
16608 ENTER();
16609 return 0;
16610}
16611#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16612static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16613 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016614{
Jeff Johnsone7245742012-09-05 17:12:55 -070016615 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016616 return 0;
16617}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016618#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016619
16620#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16621static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016622 struct net_device *dev,
16623 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016624{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016625 int ret;
16626
16627 vos_ssr_protect(__func__);
16628 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16629 vos_ssr_unprotect(__func__);
16630 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016631}
16632#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16633static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16634 struct ieee80211_txq_params *params)
16635{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016636 int ret;
16637
16638 vos_ssr_protect(__func__);
16639 ret = __wlan_hdd_set_txq_params(wiphy, params);
16640 vos_ssr_unprotect(__func__);
16641 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016642}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016643#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016644
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016645static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016646 struct net_device *dev,
16647 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016648{
16649 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016650 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016651 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016652 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016653 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016654 v_CONTEXT_t pVosContext = NULL;
16655 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016656
Jeff Johnsone7245742012-09-05 17:12:55 -070016657 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016658
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016659 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016661 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016662 return -EINVAL;
16663 }
16664
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016665 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16666 TRACE_CODE_HDD_CFG80211_DEL_STA,
16667 pAdapter->sessionId, pAdapter->device_mode));
16668
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016669 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16670 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016671 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016672 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016673 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016674 }
16675
Jeff Johnson295189b2012-06-20 16:38:30 -070016676 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016678 )
16679 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016680 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16681 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16682 if(pSapCtx == NULL){
16683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16684 FL("psapCtx is NULL"));
16685 return -ENOENT;
16686 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016687 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016688 {
16689 v_U16_t i;
16690 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16691 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016692 if ((pSapCtx->aStaInfo[i].isUsed) &&
16693 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016694 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016695 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016696 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016697 ETHER_ADDR_LEN);
16698
Jeff Johnson295189b2012-06-20 16:38:30 -070016699 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016700 "%s: Delete STA with MAC::"
16701 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016702 __func__,
16703 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16704 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016705 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016706 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016707 }
16708 }
16709 }
16710 else
16711 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016712
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016713 vos_status = hdd_softap_GetStaId(pAdapter,
16714 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016715 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16716 {
16717 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016718 "%s: Skip this DEL STA as this is not used::"
16719 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016720 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016721 return -ENOENT;
16722 }
16723
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016724 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016725 {
16726 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016727 "%s: Skip this DEL STA as deauth is in progress::"
16728 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016729 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016730 return -ENOENT;
16731 }
16732
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016733 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016734
Jeff Johnson295189b2012-06-20 16:38:30 -070016735 hddLog(VOS_TRACE_LEVEL_INFO,
16736 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016737 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016739 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016740
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016741 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016742 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16743 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016744 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016745 hddLog(VOS_TRACE_LEVEL_INFO,
16746 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016747 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016748 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016749 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016750 return -ENOENT;
16751 }
16752
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 }
16754 }
16755
16756 EXIT();
16757
16758 return 0;
16759}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016760
16761#ifdef CFG80211_DEL_STA_V2
16762static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16763 struct net_device *dev,
16764 struct station_del_parameters *param)
16765#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016766#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16767static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16768 struct net_device *dev, const u8 *mac)
16769#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016770static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16771 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016772#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016773#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016774{
16775 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016776 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016777
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016778 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016779
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016780#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016781 if (NULL == param) {
16782 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016783 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016784 return -EINVAL;
16785 }
16786
16787 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16788 param->subtype, &delStaParams);
16789
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016790#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016791 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016792 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016793#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016794 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16795
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016796 vos_ssr_unprotect(__func__);
16797
16798 return ret;
16799}
16800
16801static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016802 struct net_device *dev,
16803#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16804 const u8 *mac,
16805#else
16806 u8 *mac,
16807#endif
16808 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016809{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016810 hdd_adapter_t *pAdapter;
16811 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016812 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016813#ifdef FEATURE_WLAN_TDLS
16814 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016815
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016816 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016817
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016818 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16819 if (NULL == pAdapter)
16820 {
16821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16822 "%s: Adapter is NULL",__func__);
16823 return -EINVAL;
16824 }
16825 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16826 status = wlan_hdd_validate_context(pHddCtx);
16827 if (0 != status)
16828 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016829 return status;
16830 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016831
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016832 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16833 TRACE_CODE_HDD_CFG80211_ADD_STA,
16834 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016835 mask = params->sta_flags_mask;
16836
16837 set = params->sta_flags_set;
16838
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016839 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016840 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16841 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016842
16843 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16844 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016845 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016846 }
16847 }
16848#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016849 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016850 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016851}
16852
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016853#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16854static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16855 struct net_device *dev, const u8 *mac,
16856 struct station_parameters *params)
16857#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016858static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16859 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016860#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016861{
16862 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016863
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016864 vos_ssr_protect(__func__);
16865 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16866 vos_ssr_unprotect(__func__);
16867
16868 return ret;
16869}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016870#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016871
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016872static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016873 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016874{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016875 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16876 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016877 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016878 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016879 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016880 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016881
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016882 ENTER();
16883
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016884 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016885 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016886 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016887 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016888 return -EINVAL;
16889 }
16890
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016891 if (!pmksa) {
16892 hddLog(LOGE, FL("pmksa is NULL"));
16893 return -EINVAL;
16894 }
16895
16896 if (!pmksa->bssid || !pmksa->pmkid) {
16897 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
16898 pmksa->bssid, pmksa->pmkid);
16899 return -EINVAL;
16900 }
16901
16902 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
16903 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16904
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016905 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16906 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016907 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016908 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016909 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016910 }
16911
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016912 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016913 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16914
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016915 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
16916 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016917
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016918 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016919 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016920 &pmk_id, 1, FALSE);
16921
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016922 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16923 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
16924 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016925
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016926 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016927 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016928}
16929
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016930static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
16931 struct cfg80211_pmksa *pmksa)
16932{
16933 int ret;
16934
16935 vos_ssr_protect(__func__);
16936 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
16937 vos_ssr_unprotect(__func__);
16938
16939 return ret;
16940}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016941
Wilson Yang6507c4e2013-10-01 20:11:19 -070016942
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016943static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070016944 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016945{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016946 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16947 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016948 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016949 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016950
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016951 ENTER();
16952
Wilson Yang6507c4e2013-10-01 20:11:19 -070016953 /* Validate pAdapter */
16954 if (NULL == pAdapter)
16955 {
16956 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
16957 return -EINVAL;
16958 }
16959
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016960 if (!pmksa) {
16961 hddLog(LOGE, FL("pmksa is NULL"));
16962 return -EINVAL;
16963 }
16964
16965 if (!pmksa->bssid) {
16966 hddLog(LOGE, FL("pmksa->bssid is NULL"));
16967 return -EINVAL;
16968 }
16969
Kiet Lam98c46a12014-10-31 15:34:57 -070016970 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
16971 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16972
Wilson Yang6507c4e2013-10-01 20:11:19 -070016973 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16974 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016975 if (0 != status)
16976 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016977 return status;
16978 }
16979
16980 /*Retrieve halHandle*/
16981 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16982
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016983 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16984 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
16985 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016986 /* Delete the PMKID CSR cache */
16987 if (eHAL_STATUS_SUCCESS !=
16988 sme_RoamDelPMKIDfromCache(halHandle,
16989 pAdapter->sessionId, pmksa->bssid, FALSE)) {
16990 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
16991 MAC_ADDR_ARRAY(pmksa->bssid));
16992 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016993 }
16994
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016995 EXIT();
16996 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016997}
16998
Wilson Yang6507c4e2013-10-01 20:11:19 -070016999
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017000static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
17001 struct cfg80211_pmksa *pmksa)
17002{
17003 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017004
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017005 vos_ssr_protect(__func__);
17006 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
17007 vos_ssr_unprotect(__func__);
17008
17009 return ret;
17010
17011}
17012
17013static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017014{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017015 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17016 tHalHandle halHandle;
17017 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017018 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017019
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017020 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070017021
17022 /* Validate pAdapter */
17023 if (NULL == pAdapter)
17024 {
17025 hddLog(VOS_TRACE_LEVEL_ERROR,
17026 "%s: Invalid Adapter" ,__func__);
17027 return -EINVAL;
17028 }
17029
17030 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17031 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017032 if (0 != status)
17033 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017034 return status;
17035 }
17036
17037 /*Retrieve halHandle*/
17038 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17039
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017040 /* Flush the PMKID cache in CSR */
17041 if (eHAL_STATUS_SUCCESS !=
17042 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
17043 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
17044 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017045 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017046 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080017047 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017048}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017049
17050static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
17051{
17052 int ret;
17053
17054 vos_ssr_protect(__func__);
17055 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
17056 vos_ssr_unprotect(__func__);
17057
17058 return ret;
17059}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017060#endif
17061
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017062#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017063static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17064 struct net_device *dev,
17065 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017066{
17067 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17068 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017069 hdd_context_t *pHddCtx;
17070 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017071
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017072 ENTER();
17073
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017074 if (NULL == pAdapter)
17075 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017077 return -ENODEV;
17078 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17080 ret = wlan_hdd_validate_context(pHddCtx);
17081 if (0 != ret)
17082 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017083 return ret;
17084 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017085 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017086 if (NULL == pHddStaCtx)
17087 {
17088 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
17089 return -EINVAL;
17090 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017091
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017092 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17093 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
17094 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017095 // Added for debug on reception of Re-assoc Req.
17096 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
17097 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017098 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017099 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080017100 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017101 }
17102
17103#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080017104 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017105 ftie->ie_len);
17106#endif
17107
17108 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053017109 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
17110 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017111 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017112
17113 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017114 return 0;
17115}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017116
17117static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17118 struct net_device *dev,
17119 struct cfg80211_update_ft_ies_params *ftie)
17120{
17121 int ret;
17122
17123 vos_ssr_protect(__func__);
17124 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
17125 vos_ssr_unprotect(__func__);
17126
17127 return ret;
17128}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017129#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017130
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017131#ifdef FEATURE_WLAN_SCAN_PNO
17132
17133void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
17134 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
17135{
17136 int ret;
17137 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
17138 hdd_context_t *pHddCtx;
17139
Nirav Shah80830bf2013-12-31 16:35:12 +053017140 ENTER();
17141
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017142 if (NULL == pAdapter)
17143 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053017144 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017145 "%s: HDD adapter is Null", __func__);
17146 return ;
17147 }
17148
17149 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17150 if (NULL == pHddCtx)
17151 {
17152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17153 "%s: HDD context is Null!!!", __func__);
17154 return ;
17155 }
17156
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017157 spin_lock(&pHddCtx->schedScan_lock);
17158 if (TRUE == pHddCtx->isWiphySuspended)
17159 {
17160 pHddCtx->isSchedScanUpdatePending = TRUE;
17161 spin_unlock(&pHddCtx->schedScan_lock);
17162 hddLog(VOS_TRACE_LEVEL_INFO,
17163 "%s: Update cfg80211 scan database after it resume", __func__);
17164 return ;
17165 }
17166 spin_unlock(&pHddCtx->schedScan_lock);
17167
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017168 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
17169
17170 if (0 > ret)
17171 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053017172 else
17173 {
17174 /* Acquire wakelock to handle the case where APP's tries to suspend
17175 * immediatly after the driver gets connect request(i.e after pno)
17176 * from supplicant, this result in app's is suspending and not able
17177 * to process the connect request to AP */
17178 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
17179 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017180 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17182 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017183}
17184
17185/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017186 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017187 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017188 */
17189static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
17190{
17191 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
17192 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017193 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017194 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17195 int status = 0;
17196 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
17197
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017198 /* The current firmware design does not allow PNO during any
17199 * active sessions. Hence, determine the active sessions
17200 * and return a failure.
17201 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017202 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
17203 {
17204 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017205 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017206
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017207 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
17208 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
17209 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
17210 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
17211 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053017212 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017213 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017214 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017215 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017216 }
17217 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17218 pAdapterNode = pNext;
17219 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017220 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017221}
17222
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017223void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
17224{
17225 hdd_adapter_t *pAdapter = callbackContext;
17226 hdd_context_t *pHddCtx;
17227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017228 ENTER();
17229
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017230 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
17231 {
17232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17233 FL("Invalid adapter or adapter has invalid magic"));
17234 return;
17235 }
17236
17237 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17238 if (0 != wlan_hdd_validate_context(pHddCtx))
17239 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017240 return;
17241 }
17242
c_hpothub53c45d2014-08-18 16:53:14 +053017243 if (VOS_STATUS_SUCCESS != status)
17244 {
17245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017246 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017247 pHddCtx->isPnoEnable = FALSE;
17248 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017249
17250 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
17251 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017252 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017253}
17254
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017255#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
17256 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
17257/**
17258 * hdd_config_sched_scan_plan() - configures the sched scan plans
17259 * from the framework.
17260 * @pno_req: pointer to PNO scan request
17261 * @request: pointer to scan request from framework
17262 *
17263 * Return: None
17264 */
17265static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
17266 struct cfg80211_sched_scan_request *request,
17267 hdd_context_t *hdd_ctx)
17268{
17269 v_U32_t i = 0;
17270
17271 pno_req.scanTimers.ucScanTimersCount = n_scan_plans;
17272 for (i = 0; i < request->n_scan_plans; i++)
17273 {
17274 pno_req.scanTimers.aTimerValues[i].uTimerRepeat =
17275 request->scan_plans[i]->iterations;
17276 pno_req.scanTimers.aTimerValues[i].uTimerValue =
17277 request->scan_plans[i]->interval;
17278 }
17279}
17280#else
17281static void hdd_config_sched_scan_plan(tSirPNOScanReq pno_req,
17282 struct cfg80211_sched_scan_request *request,
17283 hdd_context_t *hdd_ctx)
17284{
17285 v_U32_t i, temp_int;
17286 /* Driver gets only one time interval which is hardcoded in
17287 * supplicant for 10000ms. Taking power consumption into account 6
17288 * timers will be used, Timervalue is increased exponentially
17289 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
17290 * timer is configurable through INI param gPNOScanTimerRepeatValue.
17291 * If it is set to 0 only one timer will be used and PNO scan cycle
17292 * will be repeated after each interval specified by supplicant
17293 * till PNO is disabled.
17294 */
17295 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
17296 pno_req.scanTimers.ucScanTimersCount =
17297 HDD_PNO_SCAN_TIMERS_SET_ONE;
17298 else
17299 pno_req.scanTimers.ucScanTimersCount =
17300 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17301
17302 temp_int = (request->interval)/1000;
17303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17304 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17305 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
17306 for ( i = 0; i < pno_req.scanTimers.ucScanTimersCount; i++)
17307 {
17308 pno_req.scanTimers.aTimerValues[i].uTimerRepeat =
17309 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
17310 pno_req.scanTimers.aTimerValues[i].uTimerValue = temp_int;
17311 temp_int *= 2;
17312 }
17313 //Repeat last timer until pno disabled.
17314 pno_req.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
17315}
17316#endif
17317
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017318/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017319 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
17320 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017321 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017322static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017323 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17324{
17325 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017326 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017327 hdd_context_t *pHddCtx;
17328 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017329 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053017330 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
17331 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017332 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17333 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017334 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017335 hdd_config_t *pConfig = NULL;
17336 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017337
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017338 ENTER();
17339
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017340 if (NULL == pAdapter)
17341 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017343 "%s: HDD adapter is Null", __func__);
17344 return -ENODEV;
17345 }
17346
17347 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017348 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017349
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017350 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017351 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017352 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017353 }
17354
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017355 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017356 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17357 if (NULL == hHal)
17358 {
17359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17360 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017361 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017362 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017363 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17364 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
17365 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053017366 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017367 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053017368 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017369 {
17370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17371 "%s: aborting the existing scan is unsuccessfull", __func__);
17372 return -EBUSY;
17373 }
17374
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017375 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017376 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017378 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017379 return -EBUSY;
17380 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017381
c_hpothu37f21312014-04-09 21:49:54 +053017382 if (TRUE == pHddCtx->isPnoEnable)
17383 {
17384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
17385 FL("already PNO is enabled"));
17386 return -EBUSY;
17387 }
c_hpothu225aa7c2014-10-22 17:45:13 +053017388
17389 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
17390 {
17391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17392 "%s: abort ROC failed ", __func__);
17393 return -EBUSY;
17394 }
17395
c_hpothu37f21312014-04-09 21:49:54 +053017396 pHddCtx->isPnoEnable = TRUE;
17397
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017398 pnoRequest.enable = 1; /*Enable PNO */
17399 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017400
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017401 if (( !pnoRequest.ucNetworksCount ) ||
17402 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017403 {
17404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017405 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017406 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017407 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017408 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017409 goto error;
17410 }
17411
17412 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
17413 {
17414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017415 "%s: Incorrect number of channels %d",
17416 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017417 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017418 goto error;
17419 }
17420
17421 /* Framework provides one set of channels(all)
17422 * common for all saved profile */
17423 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17424 channels_allowed, &num_channels_allowed))
17425 {
17426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17427 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017428 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017429 goto error;
17430 }
17431 /* Checking each channel against allowed channel list */
17432 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053017433 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017434 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017435 char chList [(request->n_channels*5)+1];
17436 int len;
17437 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017438 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017439 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017440 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017441 if (request->channels[i]->hw_value == channels_allowed[indx])
17442 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017443 if ((!pConfig->enableDFSPnoChnlScan) &&
17444 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
17445 {
17446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17447 "%s : Dropping DFS channel : %d",
17448 __func__,channels_allowed[indx]);
17449 num_ignore_dfs_ch++;
17450 break;
17451 }
17452
Nirav Shah80830bf2013-12-31 16:35:12 +053017453 valid_ch[num_ch++] = request->channels[i]->hw_value;
17454 len += snprintf(chList+len, 5, "%d ",
17455 request->channels[i]->hw_value);
17456 break ;
17457 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017458 }
17459 }
Nirav Shah80830bf2013-12-31 16:35:12 +053017460 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017461
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017462 /*If all channels are DFS and dropped, then ignore the PNO request*/
17463 if (num_ignore_dfs_ch == request->n_channels)
17464 {
17465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17466 "%s : All requested channels are DFS channels", __func__);
17467 ret = -EINVAL;
17468 goto error;
17469 }
17470 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017471
17472 pnoRequest.aNetworks =
17473 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17474 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017475 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017476 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17477 FL("failed to allocate memory aNetworks %u"),
17478 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17479 goto error;
17480 }
17481 vos_mem_zero(pnoRequest.aNetworks,
17482 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17483
17484 /* Filling per profile params */
17485 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
17486 {
17487 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017488 request->match_sets[i].ssid.ssid_len;
17489
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017490 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
17491 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017492 {
17493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017494 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017495 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017496 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017497 goto error;
17498 }
17499
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017500 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017501 request->match_sets[i].ssid.ssid,
17502 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17504 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017505 i, pnoRequest.aNetworks[i].ssId.ssId);
17506 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
17507 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
17508 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017509
17510 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017511 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
17512 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017513
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017514 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017515 }
17516
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017517 for (i = 0; i < request->n_ssids; i++)
17518 {
17519 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017520 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017521 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017522 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017523 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017524 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017525 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017526 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017527 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017528 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017529 break;
17530 }
17531 j++;
17532 }
17533 }
17534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17535 "Number of hidden networks being Configured = %d",
17536 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080017538 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017539
17540 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17541 if (pnoRequest.p24GProbeTemplate == NULL)
17542 {
17543 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17544 FL("failed to allocate memory p24GProbeTemplate %u"),
17545 SIR_PNO_MAX_PB_REQ_SIZE);
17546 goto error;
17547 }
17548
17549 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17550 if (pnoRequest.p5GProbeTemplate == NULL)
17551 {
17552 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17553 FL("failed to allocate memory p5GProbeTemplate %u"),
17554 SIR_PNO_MAX_PB_REQ_SIZE);
17555 goto error;
17556 }
17557
17558 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17559 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17560
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053017561 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
17562 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017563 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017564 pnoRequest.us24GProbeTemplateLen = request->ie_len;
17565 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
17566 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017567
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017568 pnoRequest.us5GProbeTemplateLen = request->ie_len;
17569 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
17570 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017571 }
17572
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017573 hdd_config_sched_scan_plan(pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017574
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017575 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017576
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017577 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017578 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17579 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017580 pAdapter->pno_req_status = 0;
17581
Nirav Shah80830bf2013-12-31 16:35:12 +053017582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17583 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017584 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
17585 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053017586
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017587 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017588 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017589 hdd_cfg80211_sched_scan_done_callback, pAdapter);
17590 if (eHAL_STATUS_SUCCESS != status)
17591 {
17592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017593 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017594 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017595 goto error;
17596 }
17597
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017598 ret = wait_for_completion_timeout(
17599 &pAdapter->pno_comp_var,
17600 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17601 if (0 >= ret)
17602 {
17603 // Did not receive the response for PNO enable in time.
17604 // Assuming the PNO enable was success.
17605 // Returning error from here, because we timeout, results
17606 // in side effect of Wifi (Wifi Setting) not to work.
17607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17608 FL("Timed out waiting for PNO to be Enabled"));
17609 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017610 }
17611
17612 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053017613 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017614
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017615error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17617 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053017618 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017619 if (pnoRequest.aNetworks)
17620 vos_mem_free(pnoRequest.aNetworks);
17621 if (pnoRequest.p24GProbeTemplate)
17622 vos_mem_free(pnoRequest.p24GProbeTemplate);
17623 if (pnoRequest.p5GProbeTemplate)
17624 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017625
17626 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017627 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017628}
17629
17630/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017631 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17632 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017633 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017634static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17635 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17636{
17637 int ret;
17638
17639 vos_ssr_protect(__func__);
17640 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17641 vos_ssr_unprotect(__func__);
17642
17643 return ret;
17644}
17645
17646/*
17647 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17648 * Function to disable PNO
17649 */
17650static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017651 struct net_device *dev)
17652{
17653 eHalStatus status = eHAL_STATUS_FAILURE;
17654 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17655 hdd_context_t *pHddCtx;
17656 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017657 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017658 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017659
17660 ENTER();
17661
17662 if (NULL == pAdapter)
17663 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017665 "%s: HDD adapter is Null", __func__);
17666 return -ENODEV;
17667 }
17668
17669 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017670
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017671 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017672 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017673 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017674 "%s: HDD context is Null", __func__);
17675 return -ENODEV;
17676 }
17677
17678 /* The return 0 is intentional when isLogpInProgress and
17679 * isLoadUnloadInProgress. We did observe a crash due to a return of
17680 * failure in sched_scan_stop , especially for a case where the unload
17681 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17682 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17683 * success. If it returns a failure , then its next invocation due to the
17684 * clean up of the second interface will have the dev pointer corresponding
17685 * to the first one leading to a crash.
17686 */
17687 if (pHddCtx->isLogpInProgress)
17688 {
17689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17690 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017691 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017692 return ret;
17693 }
17694
Mihir Shete18156292014-03-11 15:38:30 +053017695 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017696 {
17697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17698 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17699 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017700 }
17701
17702 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17703 if (NULL == hHal)
17704 {
17705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17706 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017707 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017708 }
17709
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017710 pnoRequest.enable = 0; /* Disable PNO */
17711 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017712
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017713 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17714 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17715 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017716
17717 INIT_COMPLETION(pAdapter->pno_comp_var);
17718 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17719 pnoRequest.callbackContext = pAdapter;
17720 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017721 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017722 pAdapter->sessionId,
17723 NULL, pAdapter);
17724 if (eHAL_STATUS_SUCCESS != status)
17725 {
17726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17727 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017728 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017729 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017730 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017731 ret = wait_for_completion_timeout(
17732 &pAdapter->pno_comp_var,
17733 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17734 if (0 >= ret)
17735 {
17736 // Did not receive the response for PNO disable in time.
17737 // Assuming the PNO disable was success.
17738 // Returning error from here, because we timeout, results
17739 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053017740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017741 FL("Timed out waiting for PNO to be disabled"));
17742 ret = 0;
17743 }
17744
17745 ret = pAdapter->pno_req_status;
17746 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017747
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017748error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017750 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017751
17752 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017753 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017754}
17755
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017756/*
17757 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17758 * NL interface to disable PNO
17759 */
17760static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17761 struct net_device *dev)
17762{
17763 int ret;
17764
17765 vos_ssr_protect(__func__);
17766 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17767 vos_ssr_unprotect(__func__);
17768
17769 return ret;
17770}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017771#endif /*FEATURE_WLAN_SCAN_PNO*/
17772
17773
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017774#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017775#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017776static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17777 struct net_device *dev,
17778 u8 *peer, u8 action_code,
17779 u8 dialog_token,
17780 u16 status_code, u32 peer_capability,
17781 const u8 *buf, size_t len)
17782#else /* TDLS_MGMT_VERSION2 */
17783#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17784static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17785 struct net_device *dev,
17786 const u8 *peer, u8 action_code,
17787 u8 dialog_token, u16 status_code,
17788 u32 peer_capability, bool initiator,
17789 const u8 *buf, size_t len)
17790#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17791static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17792 struct net_device *dev,
17793 const u8 *peer, u8 action_code,
17794 u8 dialog_token, u16 status_code,
17795 u32 peer_capability, const u8 *buf,
17796 size_t len)
17797#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17798static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17799 struct net_device *dev,
17800 u8 *peer, u8 action_code,
17801 u8 dialog_token,
17802 u16 status_code, u32 peer_capability,
17803 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017804#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017805static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17806 struct net_device *dev,
17807 u8 *peer, u8 action_code,
17808 u8 dialog_token,
17809 u16 status_code, const u8 *buf,
17810 size_t len)
17811#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017812#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017813{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017814 hdd_adapter_t *pAdapter;
17815 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017816 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017817 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017818 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017819 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017820 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017821 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017822#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017823 u32 peer_capability = 0;
17824#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017825 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017826 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017827
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017828 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17829 if (NULL == pAdapter)
17830 {
17831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17832 "%s: Adapter is NULL",__func__);
17833 return -EINVAL;
17834 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017835 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17836 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17837 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017838
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017839 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017840 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017841 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017842 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017843 "Invalid arguments");
17844 return -EINVAL;
17845 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017846
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017847 if (pHddCtx->isLogpInProgress)
17848 {
17849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17850 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017851 wlan_hdd_tdls_set_link_status(pAdapter,
17852 peer,
17853 eTDLS_LINK_IDLE,
17854 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017855 return -EBUSY;
17856 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017857
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017858 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17859 {
17860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17861 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17862 return -EAGAIN;
17863 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017864
Hoonki Lee27511902013-03-14 18:19:06 -070017865 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017866 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017867 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017868 "%s: TDLS mode is disabled OR not enabled in FW."
17869 MAC_ADDRESS_STR " action %d declined.",
17870 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017871 return -ENOTSUPP;
17872 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017873
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017874 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17875
17876 if( NULL == pHddStaCtx )
17877 {
17878 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17879 "%s: HDD station context NULL ",__func__);
17880 return -EINVAL;
17881 }
17882
17883 /* STA should be connected and authenticated
17884 * before sending any TDLS frames
17885 */
17886 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
17887 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
17888 {
17889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17890 "STA is not connected or unauthenticated. "
17891 "connState %u, uIsAuthenticated %u",
17892 pHddStaCtx->conn_info.connState,
17893 pHddStaCtx->conn_info.uIsAuthenticated);
17894 return -EAGAIN;
17895 }
17896
Hoonki Lee27511902013-03-14 18:19:06 -070017897 /* other than teardown frame, other mgmt frames are not sent if disabled */
17898 if (SIR_MAC_TDLS_TEARDOWN != action_code)
17899 {
17900 /* if tdls_mode is disabled to respond to peer's request */
17901 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
17902 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017903 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017904 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017905 " TDLS mode is disabled. action %d declined.",
17906 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070017907
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017908 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070017909 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053017910
17911 if (vos_max_concurrent_connections_reached())
17912 {
17913 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17914 return -EINVAL;
17915 }
Hoonki Lee27511902013-03-14 18:19:06 -070017916 }
17917
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017918 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
17919 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053017920 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017921 {
17922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017923 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017924 " TDLS setup is ongoing. action %d declined.",
17925 __func__, MAC_ADDR_ARRAY(peer), action_code);
17926 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017927 }
17928 }
17929
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017930 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
17931 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080017932 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017933 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17934 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017935 {
17936 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
17937 we return error code at 'add_station()'. Hence we have this
17938 check again in addtion to add_station().
17939 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017940 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017941 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17943 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017944 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
17945 __func__, MAC_ADDR_ARRAY(peer), action_code,
17946 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053017947 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080017948 }
17949 else
17950 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017951 /* maximum reached. tweak to send error code to peer and return
17952 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017953 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17955 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017956 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
17957 __func__, MAC_ADDR_ARRAY(peer), status_code,
17958 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070017959 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017960 /* fall through to send setup resp with failure status
17961 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017962 }
17963 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017964 else
17965 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017966 mutex_lock(&pHddCtx->tdls_lock);
17967 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017968 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017969 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017970 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017972 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
17973 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017974 return -EPERM;
17975 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017976 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017977 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017978 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017979
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017980 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017981 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017982 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
17983 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017984
Hoonki Leea34dd892013-02-05 22:56:02 -080017985 /*Except teardown responder will not be used so just make 0*/
17986 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017987 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080017988 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017989
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017990 mutex_lock(&pHddCtx->tdls_lock);
17991 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017992
17993 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
17994 responder = pTdlsPeer->is_responder;
17995 else
Hoonki Leea34dd892013-02-05 22:56:02 -080017996 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017998 "%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 -070017999 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
18000 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018001 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018002 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080018003 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018004 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018005 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018006
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018007 /* Discard TDLS setup if peer is removed by user app */
18008 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
18009 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18010 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
18011 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
18012
18013 mutex_lock(&pHddCtx->tdls_lock);
18014 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18015 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
18016 mutex_unlock(&pHddCtx->tdls_lock);
18017 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
18018 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
18019 MAC_ADDR_ARRAY(peer), action_code);
18020 return -EINVAL;
18021 }
18022 mutex_unlock(&pHddCtx->tdls_lock);
18023 }
18024
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018025 /* For explicit trigger of DIS_REQ come out of BMPS for
18026 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070018027 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053018028 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018029 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
18030 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070018031 {
18032 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
18033 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018035 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018036 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
18037 if (status != VOS_STATUS_SUCCESS) {
18038 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
18039 }
Hoonki Lee14621352013-04-16 17:51:19 -070018040 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018041 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018042 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018043 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
18044 }
18045 }
Hoonki Lee14621352013-04-16 17:51:19 -070018046 }
18047
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018048 /* make sure doesn't call send_mgmt() while it is pending */
18049 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
18050 {
18051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018052 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018053 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018054 ret = -EBUSY;
18055 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018056 }
18057
18058 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018059 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
18060
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018061 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
18062 pAdapter->sessionId, peer, action_code, dialog_token,
18063 status_code, peer_capability, (tANI_U8 *)buf, len,
18064 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018065
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018066 if (VOS_STATUS_SUCCESS != status)
18067 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18069 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018070 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018071 ret = -EINVAL;
18072 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018073 }
18074
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18076 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
18077 WAIT_TIME_TDLS_MGMT);
18078
Hoonki Leed37cbb32013-04-20 00:31:14 -070018079 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
18080 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
18081
18082 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018083 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070018084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070018085 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070018086 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018087 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080018088
18089 if (pHddCtx->isLogpInProgress)
18090 {
18091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18092 "%s: LOGP in Progress. Ignore!!!", __func__);
18093 return -EAGAIN;
18094 }
Abhishek Singh837adf22015-10-01 17:37:37 +053018095 if (rc <= 0)
18096 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
18097 WLAN_LOG_INDICATOR_HOST_DRIVER,
18098 WLAN_LOG_REASON_HDD_TIME_OUT,
18099 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080018100
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018101 ret = -EINVAL;
18102 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018103 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018104 else
18105 {
18106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18107 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
18108 __func__, rc, pAdapter->mgmtTxCompletionStatus);
18109 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018110
Gopichand Nakkala05922802013-03-14 12:23:19 -070018111 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070018112 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018113 ret = max_sta_failed;
18114 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070018115 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018116
Hoonki Leea34dd892013-02-05 22:56:02 -080018117 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
18118 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018119 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018120 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18121 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018122 }
18123 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
18124 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018125 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18127 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018128 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018129
18130 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018131
18132tx_failed:
18133 /* add_station will be called before sending TDLS_SETUP_REQ and
18134 * TDLS_SETUP_RSP and as part of add_station driver will enable
18135 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
18136 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
18137 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
18138 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
18139 */
18140
18141 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18142 (SIR_MAC_TDLS_SETUP_RSP == action_code))
18143 wlan_hdd_tdls_check_bmps(pAdapter);
18144 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018145}
18146
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018147#if TDLS_MGMT_VERSION2
18148static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18149 u8 *peer, u8 action_code, u8 dialog_token,
18150 u16 status_code, u32 peer_capability,
18151 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018152#else /* TDLS_MGMT_VERSION2 */
18153#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18154static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18155 struct net_device *dev,
18156 const u8 *peer, u8 action_code,
18157 u8 dialog_token, u16 status_code,
18158 u32 peer_capability, bool initiator,
18159 const u8 *buf, size_t len)
18160#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18161static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18162 struct net_device *dev,
18163 const u8 *peer, u8 action_code,
18164 u8 dialog_token, u16 status_code,
18165 u32 peer_capability, const u8 *buf,
18166 size_t len)
18167#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18168static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18169 struct net_device *dev,
18170 u8 *peer, u8 action_code,
18171 u8 dialog_token,
18172 u16 status_code, u32 peer_capability,
18173 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018174#else
18175static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18176 u8 *peer, u8 action_code, u8 dialog_token,
18177 u16 status_code, const u8 *buf, size_t len)
18178#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018179#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018180{
18181 int ret;
18182
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018183 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018184#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018185 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18186 dialog_token, status_code,
18187 peer_capability, buf, len);
18188#else /* TDLS_MGMT_VERSION2 */
18189#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18190 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18191 dialog_token, status_code,
18192 peer_capability, initiator,
18193 buf, len);
18194#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18195 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18196 dialog_token, status_code,
18197 peer_capability, buf, len);
18198#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18199 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18200 dialog_token, status_code,
18201 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018202#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018203 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18204 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018205#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018206#endif
18207 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018208
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018209 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018210}
Atul Mittal115287b2014-07-08 13:26:33 +053018211
18212int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018213#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18214 const u8 *peer,
18215#else
Atul Mittal115287b2014-07-08 13:26:33 +053018216 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018217#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018218 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053018219 cfg80211_exttdls_callback callback)
18220{
18221
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018222 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053018223 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053018225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18226 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
18227 __func__, MAC_ADDR_ARRAY(peer));
18228
18229 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18230 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18231
18232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018233 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18234 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18235 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018236 return -ENOTSUPP;
18237 }
18238
18239 /* To cater the requirement of establishing the TDLS link
18240 * irrespective of the data traffic , get an entry of TDLS peer.
18241 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018242 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018243 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
18244 if (pTdlsPeer == NULL) {
18245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18246 "%s: peer " MAC_ADDRESS_STR " not existing",
18247 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018248 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018249 return -EINVAL;
18250 }
18251
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018252 /* check FW TDLS Off Channel capability */
18253 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018254 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018255 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018256 {
18257 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
18258 pTdlsPeer->peerParams.global_operating_class =
18259 tdls_peer_params->global_operating_class;
18260 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
18261 pTdlsPeer->peerParams.min_bandwidth_kbps =
18262 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018263 /* check configured channel is valid, non dfs and
18264 * not current operating channel */
18265 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
18266 tdls_peer_params->channel)) &&
18267 (pHddStaCtx) &&
18268 (tdls_peer_params->channel !=
18269 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018270 {
18271 pTdlsPeer->isOffChannelConfigured = TRUE;
18272 }
18273 else
18274 {
18275 pTdlsPeer->isOffChannelConfigured = FALSE;
18276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18277 "%s: Configured Tdls Off Channel is not valid", __func__);
18278
18279 }
18280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018281 "%s: tdls_off_channel %d isOffChannelConfigured %d "
18282 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018283 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018284 pTdlsPeer->isOffChannelConfigured,
18285 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018286 }
18287 else
18288 {
18289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018290 "%s: TDLS off channel FW capability %d, "
18291 "host capab %d or Invalid TDLS Peer Params", __func__,
18292 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
18293 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018294 }
18295
Atul Mittal115287b2014-07-08 13:26:33 +053018296 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
18297
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018298 mutex_unlock(&pHddCtx->tdls_lock);
18299
Atul Mittal115287b2014-07-08 13:26:33 +053018300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18301 " %s TDLS Add Force Peer Failed",
18302 __func__);
18303 return -EINVAL;
18304 }
18305 /*EXT TDLS*/
18306
18307 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018308 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18310 " %s TDLS set callback Failed",
18311 __func__);
18312 return -EINVAL;
18313 }
18314
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018315 mutex_unlock(&pHddCtx->tdls_lock);
18316
Atul Mittal115287b2014-07-08 13:26:33 +053018317 return(0);
18318
18319}
18320
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018321int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
18322#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18323 const u8 *peer
18324#else
18325 u8 *peer
18326#endif
18327)
Atul Mittal115287b2014-07-08 13:26:33 +053018328{
18329
18330 hddTdlsPeer_t *pTdlsPeer;
18331 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018332
Atul Mittal115287b2014-07-08 13:26:33 +053018333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18334 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
18335 __func__, MAC_ADDR_ARRAY(peer));
18336
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018337 if (0 != wlan_hdd_validate_context(pHddCtx)) {
18338 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
18339 return -EINVAL;
18340 }
18341
Atul Mittal115287b2014-07-08 13:26:33 +053018342 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18343 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18344
18345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018346 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18347 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18348 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018349 return -ENOTSUPP;
18350 }
18351
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018352 mutex_lock(&pHddCtx->tdls_lock);
18353 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053018354
18355 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018356 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018357 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018358 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053018359 __func__, MAC_ADDR_ARRAY(peer));
18360 return -EINVAL;
18361 }
18362 else {
18363 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
18364 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018365 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
18366 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018367 /* if channel switch is configured, reset
18368 the channel for this peer */
18369 if (TRUE == pTdlsPeer->isOffChannelConfigured)
18370 {
18371 pTdlsPeer->peerParams.channel = 0;
18372 pTdlsPeer->isOffChannelConfigured = FALSE;
18373 }
Atul Mittal115287b2014-07-08 13:26:33 +053018374 }
18375
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018376 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018377 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053018379 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018380 }
Atul Mittal115287b2014-07-08 13:26:33 +053018381
18382 /*EXT TDLS*/
18383
18384 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018385 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18387 " %s TDLS set callback Failed",
18388 __func__);
18389 return -EINVAL;
18390 }
Atul Mittal115287b2014-07-08 13:26:33 +053018391
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018392 mutex_unlock(&pHddCtx->tdls_lock);
18393
18394 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053018395}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018396static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018397#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18398 const u8 *peer,
18399#else
18400 u8 *peer,
18401#endif
18402 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018403{
18404 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18405 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018406 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018407 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018408
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018409 ENTER();
18410
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018411 if (!pAdapter) {
18412 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
18413 return -EINVAL;
18414 }
18415
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018416 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18417 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
18418 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018419 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018420 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070018422 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018423 return -EINVAL;
18424 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018425
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018426 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018427 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018428 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018429 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018430 }
18431
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018432
18433 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018434 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018435 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018437 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
18438 "Cannot process TDLS commands",
18439 pHddCtx->cfg_ini->fEnableTDLSSupport,
18440 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018441 return -ENOTSUPP;
18442 }
18443
18444 switch (oper) {
18445 case NL80211_TDLS_ENABLE_LINK:
18446 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018447 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018448 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053018449 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
18450 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053018451 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018452 tANI_U16 numCurrTdlsPeers = 0;
18453 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018454 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018455 tSirMacAddr peerMac;
18456 int channel;
18457 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018458
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18460 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
18461 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018462
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018463 mutex_lock(&pHddCtx->tdls_lock);
18464 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018465 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053018466 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018467 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018468 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18469 " (oper %d) not exsting. ignored",
18470 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18471 return -EINVAL;
18472 }
18473
18474 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18475 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18476 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18477 "NL80211_TDLS_ENABLE_LINK");
18478
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018479 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
18480 {
18481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
18482 MAC_ADDRESS_STR " failed",
18483 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018484 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018485 return -EINVAL;
18486 }
18487
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018488 /* before starting tdls connection, set tdls
18489 * off channel established status to default value */
18490 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018491
18492 mutex_unlock(&pHddCtx->tdls_lock);
18493
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053018494 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018495 /* TDLS Off Channel, Disable tdls channel switch,
18496 when there are more than one tdls link */
18497 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053018498 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018499 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018500 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018501 /* get connected peer and send disable tdls off chan */
18502 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018503 if ((connPeer) &&
18504 (connPeer->isOffChannelSupported == TRUE) &&
18505 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018506 {
18507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18508 "%s: More then one peer connected, Disable "
18509 "TDLS channel switch", __func__);
18510
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018511 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018512 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
18513 channel = connPeer->peerParams.channel;
18514
18515 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018516
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018517 ret = sme_SendTdlsChanSwitchReq(
18518 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018519 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018520 peerMac,
18521 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018522 TDLS_OFF_CHANNEL_BW_OFFSET,
18523 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018524 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018525 hddLog(VOS_TRACE_LEVEL_ERROR,
18526 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018527 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018528 }
18529 else
18530 {
18531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18532 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018533 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018534 "isOffChannelConfigured %d",
18535 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018536 (connPeer ? (connPeer->isOffChannelSupported)
18537 : -1),
18538 (connPeer ? (connPeer->isOffChannelConfigured)
18539 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018540 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018541 }
18542 }
18543
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018544 mutex_lock(&pHddCtx->tdls_lock);
18545 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18546 if ( NULL == pTdlsPeer ) {
18547 mutex_unlock(&pHddCtx->tdls_lock);
18548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18549 "%s: " MAC_ADDRESS_STR
18550 " (oper %d) peer got freed in other context. ignored",
18551 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18552 return -EINVAL;
18553 }
18554 peer_status = pTdlsPeer->link_status;
18555 mutex_unlock(&pHddCtx->tdls_lock);
18556
18557 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018558 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018559 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053018560
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018561 if (0 != wlan_hdd_tdls_get_link_establish_params(
18562 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018564 return -EINVAL;
18565 }
18566 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018567
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018568 ret = sme_SendTdlsLinkEstablishParams(
18569 WLAN_HDD_GET_HAL_CTX(pAdapter),
18570 pAdapter->sessionId, peer,
18571 &tdlsLinkEstablishParams);
18572 if (ret != VOS_STATUS_SUCCESS) {
18573 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
18574 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018575 /* Send TDLS peer UAPSD capabilities to the firmware and
18576 * register with the TL on after the response for this operation
18577 * is received .
18578 */
18579 ret = wait_for_completion_interruptible_timeout(
18580 &pAdapter->tdls_link_establish_req_comp,
18581 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053018582
18583 mutex_lock(&pHddCtx->tdls_lock);
18584 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18585 if ( NULL == pTdlsPeer ) {
18586 mutex_unlock(&pHddCtx->tdls_lock);
18587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18588 "%s %d: " MAC_ADDRESS_STR
18589 " (oper %d) peer got freed in other context. ignored",
18590 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
18591 (int)oper);
18592 return -EINVAL;
18593 }
18594 peer_status = pTdlsPeer->link_status;
18595 mutex_unlock(&pHddCtx->tdls_lock);
18596
18597 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018598 {
18599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018600 FL("Link Establish Request Failed Status %ld"),
18601 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018602 return -EINVAL;
18603 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018604 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018605
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018606 mutex_lock(&pHddCtx->tdls_lock);
18607 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18608 if ( NULL == pTdlsPeer ) {
18609 mutex_unlock(&pHddCtx->tdls_lock);
18610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18611 "%s: " MAC_ADDRESS_STR
18612 " (oper %d) peer got freed in other context. ignored",
18613 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18614 return -EINVAL;
18615 }
18616
Atul Mittal115287b2014-07-08 13:26:33 +053018617 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18618 eTDLS_LINK_CONNECTED,
18619 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018620 staDesc.ucSTAId = pTdlsPeer->staId;
18621 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018622
18623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18624 "%s: tdlsLinkEstablishParams of peer "
18625 MAC_ADDRESS_STR "uapsdQueues: %d"
18626 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18627 "isResponder: %d peerstaId: %d",
18628 __func__,
18629 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18630 tdlsLinkEstablishParams.uapsdQueues,
18631 tdlsLinkEstablishParams.qos,
18632 tdlsLinkEstablishParams.maxSp,
18633 tdlsLinkEstablishParams.isBufSta,
18634 tdlsLinkEstablishParams.isOffChannelSupported,
18635 tdlsLinkEstablishParams.isResponder,
18636 pTdlsPeer->staId);
18637
18638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18639 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18640 __func__,
18641 staDesc.ucSTAId,
18642 staDesc.ucQosEnabled);
18643
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018644 ret = WLANTL_UpdateTdlsSTAClient(
18645 pHddCtx->pvosContext,
18646 &staDesc);
18647 if (ret != VOS_STATUS_SUCCESS) {
18648 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18649 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018650
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018651 /* Mark TDLS client Authenticated .*/
18652 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18653 pTdlsPeer->staId,
18654 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018655 if (VOS_STATUS_SUCCESS == status)
18656 {
Hoonki Lee14621352013-04-16 17:51:19 -070018657 if (pTdlsPeer->is_responder == 0)
18658 {
18659 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018660 tdlsConnInfo_t *tdlsInfo;
18661
18662 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18663
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018664 if (!vos_timer_is_initialized(
18665 &pTdlsPeer->initiatorWaitTimeoutTimer))
18666 {
18667 /* Initialize initiator wait callback */
18668 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018669 &pTdlsPeer->initiatorWaitTimeoutTimer,
18670 VOS_TIMER_TYPE_SW,
18671 wlan_hdd_tdls_initiator_wait_cb,
18672 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018673 }
Hoonki Lee14621352013-04-16 17:51:19 -070018674 wlan_hdd_tdls_timer_restart(pAdapter,
18675 &pTdlsPeer->initiatorWaitTimeoutTimer,
18676 WAIT_TIME_TDLS_INITIATOR);
18677 /* suspend initiator TX until it receives direct packet from the
18678 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018679 ret = WLANTL_SuspendDataTx(
18680 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18681 &staId, NULL);
18682 if (ret != VOS_STATUS_SUCCESS) {
18683 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18684 }
Hoonki Lee14621352013-04-16 17:51:19 -070018685 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018686
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018687 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018688 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018689 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018690 suppChannelLen =
18691 tdlsLinkEstablishParams.supportedChannelsLen;
18692
18693 if ((suppChannelLen > 0) &&
18694 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18695 {
18696 tANI_U8 suppPeerChannel = 0;
18697 int i = 0;
18698 for (i = 0U; i < suppChannelLen; i++)
18699 {
18700 suppPeerChannel =
18701 tdlsLinkEstablishParams.supportedChannels[i];
18702
18703 pTdlsPeer->isOffChannelSupported = FALSE;
18704 if (suppPeerChannel ==
18705 pTdlsPeer->peerParams.channel)
18706 {
18707 pTdlsPeer->isOffChannelSupported = TRUE;
18708 break;
18709 }
18710 }
18711 }
18712 else
18713 {
18714 pTdlsPeer->isOffChannelSupported = FALSE;
18715 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018716 }
18717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18718 "%s: TDLS channel switch request for channel "
18719 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018720 "%d isOffChannelSupported %d", __func__,
18721 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018722 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018723 suppChannelLen,
18724 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018725
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018726 /* TDLS Off Channel, Enable tdls channel switch,
18727 when their is only one tdls link and it supports */
18728 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18729 if ((numCurrTdlsPeers == 1) &&
18730 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18731 (TRUE == pTdlsPeer->isOffChannelConfigured))
18732 {
18733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18734 "%s: Send TDLS channel switch request for channel %d",
18735 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018736
18737 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018738 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18739 channel = pTdlsPeer->peerParams.channel;
18740
18741 mutex_unlock(&pHddCtx->tdls_lock);
18742
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018743 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18744 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018745 peerMac,
18746 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018747 TDLS_OFF_CHANNEL_BW_OFFSET,
18748 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018749 if (ret != VOS_STATUS_SUCCESS) {
18750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18751 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018752 }
18753 else
18754 {
18755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18756 "%s: TDLS channel switch request not sent"
18757 " numCurrTdlsPeers %d "
18758 "isOffChannelSupported %d "
18759 "isOffChannelConfigured %d",
18760 __func__, numCurrTdlsPeers,
18761 pTdlsPeer->isOffChannelSupported,
18762 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018763 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018764 }
18765
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018766 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018767 else
18768 mutex_unlock(&pHddCtx->tdls_lock);
18769
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018770 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018771
18772 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018773 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18774 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018775 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018776 int ac;
18777 uint8 ucAc[4] = { WLANTL_AC_VO,
18778 WLANTL_AC_VI,
18779 WLANTL_AC_BK,
18780 WLANTL_AC_BE };
18781 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18782 for(ac=0; ac < 4; ac++)
18783 {
18784 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18785 pTdlsPeer->staId, ucAc[ac],
18786 tlTid[ac], tlTid[ac], 0, 0,
18787 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018788 if (status != VOS_STATUS_SUCCESS) {
18789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18790 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018791 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018792 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018793 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018794
Bhargav Shah66896792015-10-01 18:17:37 +053018795 /* stop TCP delack timer if TDLS is enable */
18796 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18797 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053018798 hdd_wlan_tdls_enable_link_event(peer,
18799 pTdlsPeer->isOffChannelSupported,
18800 pTdlsPeer->isOffChannelConfigured,
18801 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018802 }
18803 break;
18804 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018805 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018806 tANI_U16 numCurrTdlsPeers = 0;
18807 hddTdlsPeer_t *connPeer = NULL;
18808
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18810 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18811 __func__, MAC_ADDR_ARRAY(peer));
18812
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018813 mutex_lock(&pHddCtx->tdls_lock);
18814 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018815
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018816
Sunil Dutt41de4e22013-11-14 18:09:02 +053018817 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018818 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018819 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18820 " (oper %d) not exsting. ignored",
18821 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18822 return -EINVAL;
18823 }
18824
18825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18826 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18827 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18828 "NL80211_TDLS_DISABLE_LINK");
18829
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018830 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018831 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018832 long status;
18833
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018834 /* set tdls off channel status to false for this peer */
18835 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018836 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18837 eTDLS_LINK_TEARING,
18838 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18839 eTDLS_LINK_UNSPECIFIED:
18840 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018841 mutex_unlock(&pHddCtx->tdls_lock);
18842
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018843 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18844
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018845 status = sme_DeleteTdlsPeerSta(
18846 WLAN_HDD_GET_HAL_CTX(pAdapter),
18847 pAdapter->sessionId, peer );
18848 if (status != VOS_STATUS_SUCCESS) {
18849 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18850 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018851
18852 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18853 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018854
18855 mutex_lock(&pHddCtx->tdls_lock);
18856 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18857 if ( NULL == pTdlsPeer ) {
18858 mutex_unlock(&pHddCtx->tdls_lock);
18859 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18860 " peer was freed in other context",
18861 __func__, MAC_ADDR_ARRAY(peer));
18862 return -EINVAL;
18863 }
18864
Atul Mittal271a7652014-09-12 13:18:22 +053018865 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018866 eTDLS_LINK_IDLE,
18867 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018868 mutex_unlock(&pHddCtx->tdls_lock);
18869
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018870 if (status <= 0)
18871 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18873 "%s: Del station failed status %ld",
18874 __func__, status);
18875 return -EPERM;
18876 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018877
18878 /* TDLS Off Channel, Enable tdls channel switch,
18879 when their is only one tdls link and it supports */
18880 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18881 if (numCurrTdlsPeers == 1)
18882 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018883 tSirMacAddr peerMac;
18884 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018885
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018886 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018887 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018888
18889 if (connPeer == NULL) {
18890 mutex_unlock(&pHddCtx->tdls_lock);
18891 hddLog(VOS_TRACE_LEVEL_ERROR,
18892 "%s connPeer is NULL", __func__);
18893 return -EINVAL;
18894 }
18895
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018896 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
18897 channel = connPeer->peerParams.channel;
18898
18899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18900 "%s: TDLS channel switch "
18901 "isOffChannelSupported %d "
18902 "isOffChannelConfigured %d "
18903 "isOffChannelEstablished %d",
18904 __func__,
18905 (connPeer ? connPeer->isOffChannelSupported : -1),
18906 (connPeer ? connPeer->isOffChannelConfigured : -1),
18907 (connPeer ? connPeer->isOffChannelEstablished : -1));
18908
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018909 if ((connPeer) &&
18910 (connPeer->isOffChannelSupported == TRUE) &&
18911 (connPeer->isOffChannelConfigured == TRUE))
18912 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018913 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018914 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018915 status = sme_SendTdlsChanSwitchReq(
18916 WLAN_HDD_GET_HAL_CTX(pAdapter),
18917 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018918 peerMac,
18919 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018920 TDLS_OFF_CHANNEL_BW_OFFSET,
18921 TDLS_CHANNEL_SWITCH_ENABLE);
18922 if (status != VOS_STATUS_SUCCESS) {
18923 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
18924 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018925 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018926 else
18927 mutex_unlock(&pHddCtx->tdls_lock);
18928 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018929 else
18930 {
18931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18932 "%s: TDLS channel switch request not sent "
18933 "numCurrTdlsPeers %d ",
18934 __func__, numCurrTdlsPeers);
18935 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018936 }
18937 else
18938 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018939 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18941 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080018942 }
Bhargav Shah66896792015-10-01 18:17:37 +053018943 if (numCurrTdlsPeers == 0) {
18944 /* start TCP delack timer if TDLS is disable */
18945 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18946 hdd_manage_delack_timer(pHddCtx);
18947 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018948 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018949 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018950 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018951 {
Atul Mittal115287b2014-07-08 13:26:33 +053018952 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018953
Atul Mittal115287b2014-07-08 13:26:33 +053018954 if (0 != status)
18955 {
18956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018957 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053018958 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018959 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053018960 break;
18961 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018962 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018963 {
Atul Mittal115287b2014-07-08 13:26:33 +053018964 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
18965 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018966 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053018967 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018968
Atul Mittal115287b2014-07-08 13:26:33 +053018969 if (0 != status)
18970 {
18971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018972 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053018973 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053018974 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053018975 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018976 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018977 case NL80211_TDLS_DISCOVERY_REQ:
18978 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018980 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018981 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018982 return -ENOTSUPP;
18983 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18985 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018986 return -ENOTSUPP;
18987 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018988
18989 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018990 return 0;
18991}
Chilam NG571c65a2013-01-19 12:27:36 +053018992
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018993static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018994#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18995 const u8 *peer,
18996#else
18997 u8 *peer,
18998#endif
18999 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019000{
19001 int ret;
19002
19003 vos_ssr_protect(__func__);
19004 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
19005 vos_ssr_unprotect(__func__);
19006
19007 return ret;
19008}
19009
Chilam NG571c65a2013-01-19 12:27:36 +053019010int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
19011 struct net_device *dev, u8 *peer)
19012{
Arif Hussaina7c8e412013-11-20 11:06:42 -080019013 hddLog(VOS_TRACE_LEVEL_INFO,
19014 "tdls send discover req: "MAC_ADDRESS_STR,
19015 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019016#if TDLS_MGMT_VERSION2
19017 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19018 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19019#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019020#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
19021 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19022 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
19023#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19024 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19025 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19026#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
19027 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19028 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19029#else
Chilam NG571c65a2013-01-19 12:27:36 +053019030 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19031 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019032#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019033#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053019034}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019035#endif
19036
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019037#ifdef WLAN_FEATURE_GTK_OFFLOAD
19038/*
19039 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
19040 * Callback rountine called upon receiving response for
19041 * get offload info
19042 */
19043void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
19044 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
19045{
19046
19047 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019048 tANI_U8 tempReplayCounter[8];
19049 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019050
19051 ENTER();
19052
19053 if (NULL == pAdapter)
19054 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019056 "%s: HDD adapter is Null", __func__);
19057 return ;
19058 }
19059
19060 if (NULL == pGtkOffloadGetInfoRsp)
19061 {
19062 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19063 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
19064 return ;
19065 }
19066
19067 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
19068 {
19069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19070 "%s: wlan Failed to get replay counter value",
19071 __func__);
19072 return ;
19073 }
19074
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019075 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19076 /* Update replay counter */
19077 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
19078 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19079
19080 {
19081 /* changing from little to big endian since supplicant
19082 * works on big endian format
19083 */
19084 int i;
19085 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19086
19087 for (i = 0; i < 8; i++)
19088 {
19089 tempReplayCounter[7-i] = (tANI_U8)p[i];
19090 }
19091 }
19092
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019093 /* Update replay counter to NL */
19094 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019095 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019096}
19097
19098/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019099 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019100 * This function is used to offload GTK rekeying job to the firmware.
19101 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019102int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019103 struct cfg80211_gtk_rekey_data *data)
19104{
19105 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19106 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19107 hdd_station_ctx_t *pHddStaCtx;
19108 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019109 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019110 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019111 eHalStatus status = eHAL_STATUS_FAILURE;
19112
19113 ENTER();
19114
19115 if (NULL == pAdapter)
19116 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019118 "%s: HDD adapter is Null", __func__);
19119 return -ENODEV;
19120 }
19121
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019122 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19123 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
19124 pAdapter->sessionId, pAdapter->device_mode));
19125
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019126 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019127 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019128 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019129 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019130 }
19131
19132 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19133 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19134 if (NULL == hHal)
19135 {
19136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19137 "%s: HAL context is Null!!!", __func__);
19138 return -EAGAIN;
19139 }
19140
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019141 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
19142 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
19143 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
19144 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019145 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019146 {
19147 /* changing from big to little endian since driver
19148 * works on little endian format
19149 */
19150 tANI_U8 *p =
19151 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
19152 int i;
19153
19154 for (i = 0; i < 8; i++)
19155 {
19156 p[7-i] = data->replay_ctr[i];
19157 }
19158 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019159
19160 if (TRUE == pHddCtx->hdd_wlan_suspended)
19161 {
19162 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019163 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
19164 sizeof (tSirGtkOffloadParams));
19165 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019166 pAdapter->sessionId);
19167
19168 if (eHAL_STATUS_SUCCESS != status)
19169 {
19170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19171 "%s: sme_SetGTKOffload failed, returned %d",
19172 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019173
19174 /* Need to clear any trace of key value in the memory.
19175 * Thus zero out the memory even though it is local
19176 * variable.
19177 */
19178 vos_mem_zero(&hddGtkOffloadReqParams,
19179 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019180 return status;
19181 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19183 "%s: sme_SetGTKOffload successfull", __func__);
19184 }
19185 else
19186 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19188 "%s: wlan not suspended GTKOffload request is stored",
19189 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019190 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019191
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019192 /* Need to clear any trace of key value in the memory.
19193 * Thus zero out the memory even though it is local
19194 * variable.
19195 */
19196 vos_mem_zero(&hddGtkOffloadReqParams,
19197 sizeof(hddGtkOffloadReqParams));
19198
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019199 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019200 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019201}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019202
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019203int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
19204 struct cfg80211_gtk_rekey_data *data)
19205{
19206 int ret;
19207
19208 vos_ssr_protect(__func__);
19209 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
19210 vos_ssr_unprotect(__func__);
19211
19212 return ret;
19213}
19214#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019215/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019216 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019217 * This function is used to set access control policy
19218 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019219static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19220 struct net_device *dev,
19221 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019222{
19223 int i;
19224 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19225 hdd_hostapd_state_t *pHostapdState;
19226 tsap_Config_t *pConfig;
19227 v_CONTEXT_t pVosContext = NULL;
19228 hdd_context_t *pHddCtx;
19229 int status;
19230
19231 ENTER();
19232
19233 if (NULL == pAdapter)
19234 {
19235 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19236 "%s: HDD adapter is Null", __func__);
19237 return -ENODEV;
19238 }
19239
19240 if (NULL == params)
19241 {
19242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19243 "%s: params is Null", __func__);
19244 return -EINVAL;
19245 }
19246
19247 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19248 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019249 if (0 != status)
19250 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019251 return status;
19252 }
19253
19254 pVosContext = pHddCtx->pvosContext;
19255 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
19256
19257 if (NULL == pHostapdState)
19258 {
19259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19260 "%s: pHostapdState is Null", __func__);
19261 return -EINVAL;
19262 }
19263
19264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
19265 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019266 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19267 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
19268 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019269
19270 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
19271 {
19272 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
19273
19274 /* default value */
19275 pConfig->num_accept_mac = 0;
19276 pConfig->num_deny_mac = 0;
19277
19278 /**
19279 * access control policy
19280 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
19281 * listed in hostapd.deny file.
19282 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
19283 * listed in hostapd.accept file.
19284 */
19285 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
19286 {
19287 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
19288 }
19289 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
19290 {
19291 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
19292 }
19293 else
19294 {
19295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19296 "%s:Acl Policy : %d is not supported",
19297 __func__, params->acl_policy);
19298 return -ENOTSUPP;
19299 }
19300
19301 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
19302 {
19303 pConfig->num_accept_mac = params->n_acl_entries;
19304 for (i = 0; i < params->n_acl_entries; i++)
19305 {
19306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19307 "** Add ACL MAC entry %i in WhiletList :"
19308 MAC_ADDRESS_STR, i,
19309 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19310
19311 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
19312 sizeof(qcmacaddr));
19313 }
19314 }
19315 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
19316 {
19317 pConfig->num_deny_mac = params->n_acl_entries;
19318 for (i = 0; i < params->n_acl_entries; i++)
19319 {
19320 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19321 "** Add ACL MAC entry %i in BlackList :"
19322 MAC_ADDRESS_STR, i,
19323 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19324
19325 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
19326 sizeof(qcmacaddr));
19327 }
19328 }
19329
19330 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
19331 {
19332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19333 "%s: SAP Set Mac Acl fail", __func__);
19334 return -EINVAL;
19335 }
19336 }
19337 else
19338 {
19339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053019340 "%s: Invalid device_mode = %s (%d)",
19341 __func__, hdd_device_modetoString(pAdapter->device_mode),
19342 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019343 return -EINVAL;
19344 }
19345
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019346 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019347 return 0;
19348}
19349
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019350static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19351 struct net_device *dev,
19352 const struct cfg80211_acl_data *params)
19353{
19354 int ret;
19355 vos_ssr_protect(__func__);
19356 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
19357 vos_ssr_unprotect(__func__);
19358
19359 return ret;
19360}
19361
Leo Chang9056f462013-08-01 19:21:11 -070019362#ifdef WLAN_NL80211_TESTMODE
19363#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070019364void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070019365(
19366 void *pAdapter,
19367 void *indCont
19368)
19369{
Leo Changd9df8aa2013-09-26 13:32:26 -070019370 tSirLPHBInd *lphbInd;
19371 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053019372 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070019373
19374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019375 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070019376
c_hpothu73f35e62014-04-18 13:40:08 +053019377 if (pAdapter == NULL)
19378 {
19379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19380 "%s: pAdapter is NULL\n",__func__);
19381 return;
19382 }
19383
Leo Chang9056f462013-08-01 19:21:11 -070019384 if (NULL == indCont)
19385 {
19386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019387 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070019388 return;
19389 }
19390
c_hpothu73f35e62014-04-18 13:40:08 +053019391 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070019392 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070019393 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053019394 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070019395 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070019396 GFP_ATOMIC);
19397 if (!skb)
19398 {
19399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19400 "LPHB timeout, NL buffer alloc fail");
19401 return;
19402 }
19403
Leo Changac3ba772013-10-07 09:47:04 -070019404 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070019405 {
19406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19407 "WLAN_HDD_TM_ATTR_CMD put fail");
19408 goto nla_put_failure;
19409 }
Leo Changac3ba772013-10-07 09:47:04 -070019410 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070019411 {
19412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19413 "WLAN_HDD_TM_ATTR_TYPE put fail");
19414 goto nla_put_failure;
19415 }
Leo Changac3ba772013-10-07 09:47:04 -070019416 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070019417 sizeof(tSirLPHBInd), lphbInd))
19418 {
19419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19420 "WLAN_HDD_TM_ATTR_DATA put fail");
19421 goto nla_put_failure;
19422 }
Leo Chang9056f462013-08-01 19:21:11 -070019423 cfg80211_testmode_event(skb, GFP_ATOMIC);
19424 return;
19425
19426nla_put_failure:
19427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19428 "NLA Put fail");
19429 kfree_skb(skb);
19430
19431 return;
19432}
19433#endif /* FEATURE_WLAN_LPHB */
19434
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019435static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070019436{
19437 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
19438 int err = 0;
19439#ifdef FEATURE_WLAN_LPHB
19440 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070019441 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019442
19443 ENTER();
19444
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019445 err = wlan_hdd_validate_context(pHddCtx);
19446 if (0 != err)
19447 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019448 return err;
19449 }
Leo Chang9056f462013-08-01 19:21:11 -070019450#endif /* FEATURE_WLAN_LPHB */
19451
19452 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
19453 if (err)
19454 {
19455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19456 "%s Testmode INV ATTR", __func__);
19457 return err;
19458 }
19459
19460 if (!tb[WLAN_HDD_TM_ATTR_CMD])
19461 {
19462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19463 "%s Testmode INV CMD", __func__);
19464 return -EINVAL;
19465 }
19466
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019467 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19468 TRACE_CODE_HDD_CFG80211_TESTMODE,
19469 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070019470 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
19471 {
19472#ifdef FEATURE_WLAN_LPHB
19473 /* Low Power Heartbeat configuration request */
19474 case WLAN_HDD_TM_CMD_WLAN_HB:
19475 {
19476 int buf_len;
19477 void *buf;
19478 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080019479 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070019480
19481 if (!tb[WLAN_HDD_TM_ATTR_DATA])
19482 {
19483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19484 "%s Testmode INV DATA", __func__);
19485 return -EINVAL;
19486 }
19487
19488 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
19489 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080019490
19491 hb_params_temp =(tSirLPHBReq *)buf;
19492 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
19493 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
19494 return -EINVAL;
19495
Leo Chang9056f462013-08-01 19:21:11 -070019496 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
19497 if (NULL == hb_params)
19498 {
19499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19500 "%s Request Buffer Alloc Fail", __func__);
19501 return -EINVAL;
19502 }
19503
19504 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070019505 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
19506 hb_params,
19507 wlan_hdd_cfg80211_lphb_ind_handler);
19508 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070019509 {
Leo Changd9df8aa2013-09-26 13:32:26 -070019510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19511 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070019512 vos_mem_free(hb_params);
19513 }
Leo Chang9056f462013-08-01 19:21:11 -070019514 return 0;
19515 }
19516#endif /* FEATURE_WLAN_LPHB */
19517 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19519 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070019520 return -EOPNOTSUPP;
19521 }
19522
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019523 EXIT();
19524 return err;
Leo Chang9056f462013-08-01 19:21:11 -070019525}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019526
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053019527static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
19528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
19529 struct wireless_dev *wdev,
19530#endif
19531 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019532{
19533 int ret;
19534
19535 vos_ssr_protect(__func__);
19536 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
19537 vos_ssr_unprotect(__func__);
19538
19539 return ret;
19540}
Leo Chang9056f462013-08-01 19:21:11 -070019541#endif /* CONFIG_NL80211_TESTMODE */
19542
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019543extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019544static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019545 struct net_device *dev,
19546 int idx, struct survey_info *survey)
19547{
19548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19549 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053019550 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019551 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053019552 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019553 v_S7_t snr,rssi;
19554 int status, i, j, filled = 0;
19555
19556 ENTER();
19557
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019558 if (NULL == pAdapter)
19559 {
19560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19561 "%s: HDD adapter is Null", __func__);
19562 return -ENODEV;
19563 }
19564
19565 if (NULL == wiphy)
19566 {
19567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19568 "%s: wiphy is Null", __func__);
19569 return -ENODEV;
19570 }
19571
19572 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19573 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019574 if (0 != status)
19575 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019576 return status;
19577 }
19578
Mihir Sheted9072e02013-08-21 17:02:29 +053019579 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19580
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019581 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053019582 0 != pAdapter->survey_idx ||
19583 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019584 {
19585 /* The survey dump ops when implemented completely is expected to
19586 * return a survey of all channels and the ops is called by the
19587 * kernel with incremental values of the argument 'idx' till it
19588 * returns -ENONET. But we can only support the survey for the
19589 * operating channel for now. survey_idx is used to track
19590 * that the ops is called only once and then return -ENONET for
19591 * the next iteration
19592 */
19593 pAdapter->survey_idx = 0;
19594 return -ENONET;
19595 }
19596
Mukul Sharma9d5233b2015-06-11 20:28:20 +053019597 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
19598 {
19599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19600 "%s: Roaming in progress, hence return ", __func__);
19601 return -ENONET;
19602 }
19603
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019604 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19605
19606 wlan_hdd_get_snr(pAdapter, &snr);
19607 wlan_hdd_get_rssi(pAdapter, &rssi);
19608
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019609 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19610 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
19611 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019612 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
19613 hdd_wlan_get_freq(channel, &freq);
19614
19615
19616 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
19617 {
19618 if (NULL == wiphy->bands[i])
19619 {
19620 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19621 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19622 continue;
19623 }
19624
19625 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19626 {
19627 struct ieee80211_supported_band *band = wiphy->bands[i];
19628
19629 if (band->channels[j].center_freq == (v_U16_t)freq)
19630 {
19631 survey->channel = &band->channels[j];
19632 /* The Rx BDs contain SNR values in dB for the received frames
19633 * while the supplicant expects noise. So we calculate and
19634 * return the value of noise (dBm)
19635 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19636 */
19637 survey->noise = rssi - snr;
19638 survey->filled = SURVEY_INFO_NOISE_DBM;
19639 filled = 1;
19640 }
19641 }
19642 }
19643
19644 if (filled)
19645 pAdapter->survey_idx = 1;
19646 else
19647 {
19648 pAdapter->survey_idx = 0;
19649 return -ENONET;
19650 }
19651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019652 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019653 return 0;
19654}
19655
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019656static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19657 struct net_device *dev,
19658 int idx, struct survey_info *survey)
19659{
19660 int ret;
19661
19662 vos_ssr_protect(__func__);
19663 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19664 vos_ssr_unprotect(__func__);
19665
19666 return ret;
19667}
19668
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019669/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019670 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019671 * this is called when cfg80211 driver resume
19672 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19673 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019674int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019675{
19676 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19677 hdd_adapter_t *pAdapter;
19678 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19679 VOS_STATUS status = VOS_STATUS_SUCCESS;
19680
19681 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019682
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019683 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019684 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019685 return 0;
19686 }
19687
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019688 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19689 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019690
19691 if ((VOS_STA_SAP_MODE == hdd_get_conparam()) &&
19692 pHddCtx->is_ap_mode_wow_supported)
19693 {
19694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19695 "%s: Resume SoftAP", __func__);
19696 hdd_set_wlan_suspend_mode(false);
19697 }
19698
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019699 spin_lock(&pHddCtx->schedScan_lock);
19700 pHddCtx->isWiphySuspended = FALSE;
19701 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19702 {
19703 spin_unlock(&pHddCtx->schedScan_lock);
19704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19705 "%s: Return resume is not due to PNO indication", __func__);
19706 return 0;
19707 }
19708 // Reset flag to avoid updatating cfg80211 data old results again
19709 pHddCtx->isSchedScanUpdatePending = FALSE;
19710 spin_unlock(&pHddCtx->schedScan_lock);
19711
19712 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19713
19714 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19715 {
19716 pAdapter = pAdapterNode->pAdapter;
19717 if ( (NULL != pAdapter) &&
19718 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19719 {
19720 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019721 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19723 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019724 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019725 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019726 {
19727 /* Acquire wakelock to handle the case where APP's tries to
19728 * suspend immediately after updating the scan results. Whis
19729 * results in app's is in suspended state and not able to
19730 * process the connect request to AP
19731 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019732 hdd_prevent_suspend_timeout(2000,
19733 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019734 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019735 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019736
19737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19738 "%s : cfg80211 scan result database updated", __func__);
19739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019740 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019741 return 0;
19742
19743 }
19744 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19745 pAdapterNode = pNext;
19746 }
19747
19748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19749 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019750 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019751 return 0;
19752}
19753
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019754int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19755{
19756 int ret;
19757
19758 vos_ssr_protect(__func__);
19759 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19760 vos_ssr_unprotect(__func__);
19761
19762 return ret;
19763}
19764
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019765/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019766 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019767 * this is called when cfg80211 driver suspends
19768 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019769int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019770 struct cfg80211_wowlan *wow)
19771{
19772 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019773 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019774
19775 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019776
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019777 ret = wlan_hdd_validate_context(pHddCtx);
19778 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019779 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019780 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019781 }
19782
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019783 if ((VOS_STA_SAP_MODE == hdd_get_conparam()) &&
19784 (pHddCtx->is_ap_mode_wow_supported)) {
19785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19786 "%s: Suspend SoftAP", __func__);
19787 hdd_set_wlan_suspend_mode(true);
19788 }
19789
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019790
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019791 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19792 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19793 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019794 pHddCtx->isWiphySuspended = TRUE;
19795
19796 EXIT();
19797
19798 return 0;
19799}
19800
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019801int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19802 struct cfg80211_wowlan *wow)
19803{
19804 int ret;
19805
19806 vos_ssr_protect(__func__);
19807 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19808 vos_ssr_unprotect(__func__);
19809
19810 return ret;
19811}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019812
19813#ifdef FEATURE_OEM_DATA_SUPPORT
19814static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019815 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019816{
19817 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19818
19819 ENTER();
19820
19821 if (wlan_hdd_validate_context(pHddCtx)) {
19822 return;
19823 }
19824 if (!pMsg)
19825 {
19826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19827 return;
19828 }
19829
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019830 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019831
19832 EXIT();
19833 return;
19834
19835}
19836
19837void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019838 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019839{
19840 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19841
19842 ENTER();
19843
19844 if (wlan_hdd_validate_context(pHddCtx)) {
19845 return;
19846 }
19847
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019848 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019849
19850 switch(evType) {
19851 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019852 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019853 break;
19854 default:
19855 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19856 break;
19857 }
19858 EXIT();
19859}
19860#endif
19861
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019862#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19863 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019864/**
19865 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
19866 * @wiphy: Pointer to wiphy
19867 * @wdev: Pointer to wireless device structure
19868 *
19869 * This function is used to abort an ongoing scan
19870 *
19871 * Return: None
19872 */
19873static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19874 struct wireless_dev *wdev)
19875{
19876 struct net_device *dev = wdev->netdev;
19877 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19878 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19879 int ret;
19880
19881 ENTER();
19882
19883 if (NULL == adapter) {
19884 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
19885 return;
19886 }
19887
19888 ret = wlan_hdd_validate_context(hdd_ctx);
19889 if (0 != ret)
19890 return;
19891
19892 wlan_hdd_scan_abort(adapter);
19893
19894 return;
19895}
19896
19897/**
19898 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
19899 * @wiphy: Pointer to wiphy
19900 * @wdev: Pointer to wireless device structure
19901 *
19902 * Return: None
19903 */
19904void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19905 struct wireless_dev *wdev)
19906{
19907 vos_ssr_protect(__func__);
19908 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
19909 vos_ssr_unprotect(__func__);
19910
19911 return;
19912}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019913#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019914
Jeff Johnson295189b2012-06-20 16:38:30 -070019915/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019916static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070019917{
19918 .add_virtual_intf = wlan_hdd_add_virtual_intf,
19919 .del_virtual_intf = wlan_hdd_del_virtual_intf,
19920 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
19921 .change_station = wlan_hdd_change_station,
19922#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
19923 .add_beacon = wlan_hdd_cfg80211_add_beacon,
19924 .del_beacon = wlan_hdd_cfg80211_del_beacon,
19925 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019926#else
19927 .start_ap = wlan_hdd_cfg80211_start_ap,
19928 .change_beacon = wlan_hdd_cfg80211_change_beacon,
19929 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070019930#endif
19931 .change_bss = wlan_hdd_cfg80211_change_bss,
19932 .add_key = wlan_hdd_cfg80211_add_key,
19933 .get_key = wlan_hdd_cfg80211_get_key,
19934 .del_key = wlan_hdd_cfg80211_del_key,
19935 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019936#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070019937 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019938#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019939 .scan = wlan_hdd_cfg80211_scan,
19940 .connect = wlan_hdd_cfg80211_connect,
19941 .disconnect = wlan_hdd_cfg80211_disconnect,
19942 .join_ibss = wlan_hdd_cfg80211_join_ibss,
19943 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
19944 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
19945 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
19946 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070019947 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
19948 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053019949 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070019950#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19951 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
19952 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
19953 .set_txq_params = wlan_hdd_set_txq_params,
19954#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019955 .get_station = wlan_hdd_cfg80211_get_station,
19956 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
19957 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019958 .add_station = wlan_hdd_cfg80211_add_station,
19959#ifdef FEATURE_WLAN_LFR
19960 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
19961 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
19962 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
19963#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019964#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
19965 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
19966#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019967#ifdef FEATURE_WLAN_TDLS
19968 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
19969 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
19970#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019971#ifdef WLAN_FEATURE_GTK_OFFLOAD
19972 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
19973#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019974#ifdef FEATURE_WLAN_SCAN_PNO
19975 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
19976 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
19977#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019978 .resume = wlan_hdd_cfg80211_resume_wlan,
19979 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019980 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070019981#ifdef WLAN_NL80211_TESTMODE
19982 .testmode_cmd = wlan_hdd_cfg80211_testmode,
19983#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019984 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019985#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19986 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019987 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019988#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019989};
19990