blob: 63fd84d692c2af78eb976978ac9fef590ac12033 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2012-2017 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]);
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05303771 if (pReqMsg->numBssid > WLAN_EXTSCAN_MAX_HOTLIST_APS) {
3772 hddLog(LOGE, FL("Number of AP: %u exceeds max: %u"),
3773 pReqMsg->numBssid, WLAN_EXTSCAN_MAX_HOTLIST_APS);
3774 goto fail;
3775 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303776 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303777
3778 nla_for_each_nested(apTh,
3779 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05303780 if (i == pReqMsg->numBssid) {
3781 hddLog(LOGW, FL("Ignoring excess AP"));
3782 break;
3783 }
3784
Dino Mycle6fb96c12014-06-10 11:52:40 +05303785 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3786 nla_data(apTh), nla_len(apTh),
3787 NULL)) {
3788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3789 goto fail;
3790 }
3791
3792 /* Parse and fetch MAC address */
3793 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3795 goto fail;
3796 }
3797 memcpy(pReqMsg->ap[i].bssid, nla_data(
3798 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3799 sizeof(tSirMacAddr));
3800 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3801
3802 /* Parse and fetch low RSSI */
3803 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3805 goto fail;
3806 }
3807 pReqMsg->ap[i].low = nla_get_s32(
3808 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3809 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3810
3811 /* Parse and fetch high RSSI */
3812 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3813 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3814 goto fail;
3815 }
3816 pReqMsg->ap[i].high = nla_get_s32(
3817 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3818 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3819 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303820 i++;
3821 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303822
Hanumanth Reddy Pothula8e188402017-01-27 16:43:45 +05303823 if (i < pReqMsg->numBssid) {
3824 hddLog(LOGW, FL("Number of AP %u less than expected %u"),
3825 i, pReqMsg->numBssid);
3826 pReqMsg->numBssid = i;
3827 }
3828
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303829 context = &pHddCtx->ext_scan_context;
3830 spin_lock(&hdd_context_lock);
3831 INIT_COMPLETION(context->response_event);
3832 context->request_id = request_id = pReqMsg->requestId;
3833 spin_unlock(&hdd_context_lock);
3834
Dino Mycle6fb96c12014-06-10 11:52:40 +05303835 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3836 if (!HAL_STATUS_SUCCESS(status)) {
3837 hddLog(VOS_TRACE_LEVEL_ERROR,
3838 FL("sme_SetBssHotlist failed(err=%d)"), status);
3839 vos_mem_free(pReqMsg);
3840 return -EINVAL;
3841 }
3842
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303843 /* request was sent -- wait for the response */
3844 rc = wait_for_completion_timeout(&context->response_event,
3845 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3846
3847 if (!rc) {
3848 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3849 retval = -ETIMEDOUT;
3850 } else {
3851 spin_lock(&hdd_context_lock);
3852 if (context->request_id == request_id)
3853 retval = context->response_status;
3854 else
3855 retval = -EINVAL;
3856 spin_unlock(&hdd_context_lock);
3857 }
3858
Dino Myclee8843b32014-07-04 14:21:45 +05303859 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303860 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303861 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303862
3863fail:
3864 vos_mem_free(pReqMsg);
3865 return -EINVAL;
3866}
3867
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303868static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3869 struct wireless_dev *wdev,
3870 const void *data, int dataLen)
3871{
3872 int ret = 0;
3873
3874 vos_ssr_protect(__func__);
3875 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3876 dataLen);
3877 vos_ssr_unprotect(__func__);
3878
3879 return ret;
3880}
3881
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303882/*
3883 * define short names for the global vendor params
3884 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3885 */
3886#define PARAM_MAX \
3887QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3888#define PARAM_REQUEST_ID \
3889QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3890#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3891QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3892#define PARAMS_NUM_SSID \
3893QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3894#define THRESHOLD_PARAM \
3895QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3896#define PARAM_SSID \
3897QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3898#define PARAM_BAND \
3899QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3900#define PARAM_RSSI_LOW \
3901QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3902#define PARAM_RSSI_HIGH \
3903QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3904
3905/**
3906 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3907 * @wiphy: Pointer to wireless phy
3908 * @wdev: Pointer to wireless device
3909 * @data: Pointer to data
3910 * @data_len: Data length
3911 *
3912 * Return: 0 on success, negative errno on failure
3913 */
3914static int
3915__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3916 struct wireless_dev *wdev,
3917 const void *data,
3918 int data_len)
3919{
3920 tSirEXTScanSetSsidHotListReqParams *request;
3921 struct net_device *dev = wdev->netdev;
3922 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3923 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3924 struct nlattr *tb[PARAM_MAX + 1];
3925 struct nlattr *tb2[PARAM_MAX + 1];
3926 struct nlattr *ssids;
3927 struct hdd_ext_scan_context *context;
3928 uint32_t request_id;
3929 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3930 int ssid_len;
Anurag Chouhand64d5232016-08-29 17:01:38 +05303931 int ssid_length;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303932 eHalStatus status;
3933 int i, rem, retval;
3934 unsigned long rc;
3935
3936 ENTER();
3937
3938 if (VOS_FTM_MODE == hdd_get_conparam()) {
3939 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3940 return -EINVAL;
3941 }
3942
3943 retval = wlan_hdd_validate_context(hdd_ctx);
3944 if (0 != retval) {
3945 hddLog(LOGE, FL("HDD context is not valid"));
3946 return -EINVAL;
3947 }
3948
3949 /* check the EXTScan Capability */
3950 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303951 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3952 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303953 {
3954 hddLog(VOS_TRACE_LEVEL_ERROR,
3955 FL("EXTScan not enabled/supported by Firmware"));
3956 return -EINVAL;
3957 }
3958
3959 if (nla_parse(tb, PARAM_MAX,
3960 data, data_len,
3961 wlan_hdd_extscan_config_policy)) {
3962 hddLog(LOGE, FL("Invalid ATTR"));
3963 return -EINVAL;
3964 }
3965
3966 request = vos_mem_malloc(sizeof(*request));
3967 if (!request) {
3968 hddLog(LOGE, FL("vos_mem_malloc failed"));
3969 return -ENOMEM;
3970 }
3971
3972 /* Parse and fetch request Id */
3973 if (!tb[PARAM_REQUEST_ID]) {
3974 hddLog(LOGE, FL("attr request id failed"));
3975 goto fail;
3976 }
3977
3978 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3979 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3980
3981 /* Parse and fetch lost SSID sample size */
3982 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3983 hddLog(LOGE, FL("attr number of Ssid failed"));
3984 goto fail;
3985 }
3986 request->lost_ssid_sample_size =
3987 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3988 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3989 request->lost_ssid_sample_size);
3990
3991 /* Parse and fetch number of hotlist SSID */
3992 if (!tb[PARAMS_NUM_SSID]) {
3993 hddLog(LOGE, FL("attr number of Ssid failed"));
3994 goto fail;
3995 }
3996 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3997 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3998
3999 request->session_id = adapter->sessionId;
4000 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
4001
4002 i = 0;
4003 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
4004 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
4005 hddLog(LOGE,
4006 FL("Too Many SSIDs, %d exceeds %d"),
4007 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
4008 break;
4009 }
4010 if (nla_parse(tb2, PARAM_MAX,
4011 nla_data(ssids), nla_len(ssids),
4012 wlan_hdd_extscan_config_policy)) {
4013 hddLog(LOGE, FL("nla_parse failed"));
4014 goto fail;
4015 }
4016
4017 /* Parse and fetch SSID */
4018 if (!tb2[PARAM_SSID]) {
4019 hddLog(LOGE, FL("attr ssid failed"));
4020 goto fail;
4021 }
Anurag Chouhand64d5232016-08-29 17:01:38 +05304022 ssid_length = nla_strlcpy(ssid_string, tb2[PARAM_SSID],
4023 sizeof(ssid_string));
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304024 hddLog(LOG1, FL("SSID %s"),
4025 ssid_string);
4026 ssid_len = strlen(ssid_string);
SaidiReddy Yenugae4f6f372016-12-06 16:11:39 +05304027 if (ssid_length >= SIR_MAC_MAX_SSID_LENGTH) {
Anurag Chouhand64d5232016-08-29 17:01:38 +05304028 hddLog(LOGE, FL("Invalid ssid length"));
4029 goto fail;
4030 }
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304031 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
4032 request->ssid[i].ssid.length = ssid_len;
4033 request->ssid[i].ssid.ssId[ssid_len] = '\0';
4034 hddLog(LOG1, FL("After copying SSID %s"),
4035 request->ssid[i].ssid.ssId);
4036 hddLog(LOG1, FL("After copying length: %d"),
4037 ssid_len);
4038
4039 /* Parse and fetch low RSSI */
4040 if (!tb2[PARAM_BAND]) {
4041 hddLog(LOGE, FL("attr band failed"));
4042 goto fail;
4043 }
4044 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
4045 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
4046
4047 /* Parse and fetch low RSSI */
4048 if (!tb2[PARAM_RSSI_LOW]) {
4049 hddLog(LOGE, FL("attr low RSSI failed"));
4050 goto fail;
4051 }
4052 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
4053 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
4054
4055 /* Parse and fetch high RSSI */
4056 if (!tb2[PARAM_RSSI_HIGH]) {
4057 hddLog(LOGE, FL("attr high RSSI failed"));
4058 goto fail;
4059 }
4060 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4061 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4062 i++;
4063 }
4064
4065 context = &hdd_ctx->ext_scan_context;
4066 spin_lock(&hdd_context_lock);
4067 INIT_COMPLETION(context->response_event);
4068 context->request_id = request_id = request->request_id;
4069 spin_unlock(&hdd_context_lock);
4070
4071 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4072 if (!HAL_STATUS_SUCCESS(status)) {
4073 hddLog(LOGE,
4074 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4075 goto fail;
4076 }
4077
4078 vos_mem_free(request);
4079
4080 /* request was sent -- wait for the response */
4081 rc = wait_for_completion_timeout(&context->response_event,
4082 msecs_to_jiffies
4083 (WLAN_WAIT_TIME_EXTSCAN));
4084 if (!rc) {
4085 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4086 retval = -ETIMEDOUT;
4087 } else {
4088 spin_lock(&hdd_context_lock);
4089 if (context->request_id == request_id)
4090 retval = context->response_status;
4091 else
4092 retval = -EINVAL;
4093 spin_unlock(&hdd_context_lock);
4094 }
4095
4096 return retval;
4097
4098fail:
4099 vos_mem_free(request);
4100 return -EINVAL;
4101}
4102
4103/*
4104 * done with short names for the global vendor params
4105 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4106 */
4107#undef PARAM_MAX
4108#undef PARAM_REQUEST_ID
4109#undef PARAMS_NUM_SSID
4110#undef THRESHOLD_PARAM
4111#undef PARAM_SSID
4112#undef PARAM_BAND
4113#undef PARAM_RSSI_LOW
4114#undef PARAM_RSSI_HIGH
4115
4116static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4117 struct wireless_dev *wdev,
4118 const void *data, int dataLen)
4119{
4120 int ret = 0;
4121
4122 vos_ssr_protect(__func__);
4123 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4124 dataLen);
4125 vos_ssr_unprotect(__func__);
4126
4127 return ret;
4128}
4129
4130static int
4131__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4132 struct wireless_dev *wdev,
4133 const void *data,
4134 int data_len)
4135{
4136 tSirEXTScanResetSsidHotlistReqParams request;
4137 struct net_device *dev = wdev->netdev;
4138 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4139 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4140 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4141 struct hdd_ext_scan_context *context;
4142 uint32_t request_id;
4143 eHalStatus status;
4144 int retval;
4145 unsigned long rc;
4146
4147 ENTER();
4148
4149 if (VOS_FTM_MODE == hdd_get_conparam()) {
4150 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4151 return -EINVAL;
4152 }
4153
4154 retval = wlan_hdd_validate_context(hdd_ctx);
4155 if (0 != retval) {
4156 hddLog(LOGE, FL("HDD context is not valid"));
4157 return -EINVAL;
4158 }
4159
4160 /* check the EXTScan Capability */
4161 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304162 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4163 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304164 {
4165 hddLog(LOGE,
4166 FL("EXTScan not enabled/supported by Firmware"));
4167 return -EINVAL;
4168 }
4169
4170 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4171 data, data_len,
4172 wlan_hdd_extscan_config_policy)) {
4173 hddLog(LOGE, FL("Invalid ATTR"));
4174 return -EINVAL;
4175 }
4176
4177 /* Parse and fetch request Id */
4178 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4179 hddLog(LOGE, FL("attr request id failed"));
4180 return -EINVAL;
4181 }
4182
4183 request.requestId = nla_get_u32(
4184 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4185 request.sessionId = adapter->sessionId;
4186 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4187 request.sessionId);
4188
4189 context = &hdd_ctx->ext_scan_context;
4190 spin_lock(&hdd_context_lock);
4191 INIT_COMPLETION(context->response_event);
4192 context->request_id = request_id = request.requestId;
4193 spin_unlock(&hdd_context_lock);
4194
4195 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4196 if (!HAL_STATUS_SUCCESS(status)) {
4197 hddLog(LOGE,
4198 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4199 return -EINVAL;
4200 }
4201
4202 /* request was sent -- wait for the response */
4203 rc = wait_for_completion_timeout(&context->response_event,
4204 msecs_to_jiffies
4205 (WLAN_WAIT_TIME_EXTSCAN));
4206 if (!rc) {
4207 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4208 retval = -ETIMEDOUT;
4209 } else {
4210 spin_lock(&hdd_context_lock);
4211 if (context->request_id == request_id)
4212 retval = context->response_status;
4213 else
4214 retval = -EINVAL;
4215 spin_unlock(&hdd_context_lock);
4216 }
4217
4218 return retval;
4219}
4220
4221static int
4222wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4223 struct wireless_dev *wdev,
4224 const void *data,
4225 int data_len)
4226{
4227 int ret;
4228
4229 vos_ssr_protect(__func__);
4230 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4231 data, data_len);
4232 vos_ssr_unprotect(__func__);
4233
4234 return ret;
4235}
4236
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304237static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304238 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304239 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304240{
Agrawal Ashish16abf782016-08-18 22:42:59 +05304241 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4242 struct net_device *dev = wdev->netdev;
4243 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4244 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4245 uint8_t num_channels = 0;
4246 uint8_t num_chan_new = 0;
4247 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05304248 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304249 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304250 tWifiBand wifiBand;
4251 eHalStatus status;
4252 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05304253 tANI_U8 i,j,k;
4254 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304255
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304256 ENTER();
4257
Dino Mycle6fb96c12014-06-10 11:52:40 +05304258 status = wlan_hdd_validate_context(pHddCtx);
4259 if (0 != status)
4260 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261 return -EINVAL;
4262 }
Dino Myclee8843b32014-07-04 14:21:45 +05304263
Dino Mycle6fb96c12014-06-10 11:52:40 +05304264 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4265 data, dataLen,
4266 wlan_hdd_extscan_config_policy)) {
4267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4268 return -EINVAL;
4269 }
4270
4271 /* Parse and fetch request Id */
4272 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4273 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4274 return -EINVAL;
4275 }
4276 requestId = nla_get_u32(
4277 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4278 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4279
4280 /* Parse and fetch wifi band */
4281 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4282 {
4283 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4284 return -EINVAL;
4285 }
4286 wifiBand = nla_get_u32(
4287 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4288 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4289
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304290 /* Parse and fetch max channels */
4291 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4292 {
4293 hddLog(LOGE, FL("attr max channels failed"));
4294 return -EINVAL;
4295 }
4296 maxChannels = nla_get_u32(
4297 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4298 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4299
Dino Mycle6fb96c12014-06-10 11:52:40 +05304300 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05304301 wifiBand, chan_list,
4302 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304303 if (eHAL_STATUS_SUCCESS != status) {
4304 hddLog(VOS_TRACE_LEVEL_ERROR,
4305 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4306 return -EINVAL;
4307 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304308
Agrawal Ashish16abf782016-08-18 22:42:59 +05304309 num_channels = VOS_MIN(num_channels, maxChannels);
4310 num_chan_new = num_channels;
4311 /* remove the indoor only channels if iface is SAP */
4312 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
4313 {
4314 num_chan_new = 0;
4315 for (i = 0; i < num_channels; i++)
4316 for (j = 0; j < IEEE80211_NUM_BANDS; j++) {
4317 if (wiphy->bands[j] == NULL)
4318 continue;
4319 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
4320 if ((chan_list[i] ==
4321 wiphy->bands[j]->channels[k].center_freq) &&
4322 (!(wiphy->bands[j]->channels[k].flags &
4323 IEEE80211_CHAN_INDOOR_ONLY))) {
4324 chan_list[num_chan_new] = chan_list[i];
4325 num_chan_new++;
4326 }
4327 }
4328 }
4329 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304330
Agrawal Ashish16abf782016-08-18 22:42:59 +05304331 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
4332 for (i = 0; i < num_chan_new; i++)
4333 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
4334 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304335
4336 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05304337 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05304338 NLMSG_HDRLEN);
4339
4340 if (!replySkb) {
4341 hddLog(VOS_TRACE_LEVEL_ERROR,
4342 FL("valid channels: buffer alloc fail"));
4343 return -EINVAL;
4344 }
4345 if (nla_put_u32(replySkb,
4346 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304347 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304348 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304349 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350
4351 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4352 kfree_skb(replySkb);
4353 return -EINVAL;
4354 }
4355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304356 ret = cfg80211_vendor_cmd_reply(replySkb);
4357
4358 EXIT();
4359 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360}
4361
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304362static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4363 struct wireless_dev *wdev,
4364 const void *data, int dataLen)
4365{
4366 int ret = 0;
4367
4368 vos_ssr_protect(__func__);
4369 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4370 dataLen);
4371 vos_ssr_unprotect(__func__);
4372
4373 return ret;
4374}
4375
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304376static int hdd_extscan_start_fill_bucket_channel_spec(
4377 hdd_context_t *pHddCtx,
4378 tpSirEXTScanStartReqParams pReqMsg,
4379 struct nlattr **tb)
4380{
4381 struct nlattr *bucket[
4382 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4383 struct nlattr *channel[
4384 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4385 struct nlattr *buckets;
4386 struct nlattr *channels;
4387 int rem1, rem2;
4388 eHalStatus status;
4389 tANI_U8 bktIndex, j, numChannels;
4390 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4391 tANI_U32 passive_max_chn_time, active_max_chn_time;
4392
4393 bktIndex = 0;
4394
4395 nla_for_each_nested(buckets,
4396 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4397 if (nla_parse(bucket,
4398 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4399 nla_data(buckets), nla_len(buckets), NULL)) {
4400 hddLog(LOGE, FL("nla_parse failed"));
4401 return -EINVAL;
4402 }
4403
4404 /* Parse and fetch bucket spec */
4405 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4406 hddLog(LOGE, FL("attr bucket index failed"));
4407 return -EINVAL;
4408 }
4409 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4410 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4411 hddLog(LOG1, FL("Bucket spec Index %d"),
4412 pReqMsg->buckets[bktIndex].bucket);
4413
4414 /* Parse and fetch wifi band */
4415 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4416 hddLog(LOGE, FL("attr wifi band failed"));
4417 return -EINVAL;
4418 }
4419 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4420 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4421 hddLog(LOG1, FL("Wifi band %d"),
4422 pReqMsg->buckets[bktIndex].band);
4423
4424 /* Parse and fetch period */
4425 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4426 hddLog(LOGE, FL("attr period failed"));
4427 return -EINVAL;
4428 }
4429 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4430 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4431 hddLog(LOG1, FL("period %d"),
4432 pReqMsg->buckets[bktIndex].period);
4433
4434 /* Parse and fetch report events */
4435 if (!bucket[
4436 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4437 hddLog(LOGE, FL("attr report events failed"));
4438 return -EINVAL;
4439 }
4440 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4441 bucket[
4442 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4443 hddLog(LOG1, FL("report events %d"),
4444 pReqMsg->buckets[bktIndex].reportEvents);
4445
4446 /* Parse and fetch max period */
4447 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4448 hddLog(LOGE, FL("attr max period failed"));
4449 return -EINVAL;
4450 }
4451 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4452 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4453 hddLog(LOG1, FL("max period %u"),
4454 pReqMsg->buckets[bktIndex].max_period);
4455
4456 /* Parse and fetch exponent */
4457 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4458 hddLog(LOGE, FL("attr exponent failed"));
4459 return -EINVAL;
4460 }
4461 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4462 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4463 hddLog(LOG1, FL("exponent %u"),
4464 pReqMsg->buckets[bktIndex].exponent);
4465
4466 /* Parse and fetch step count */
4467 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4468 hddLog(LOGE, FL("attr step count failed"));
4469 return -EINVAL;
4470 }
4471 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4472 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4473 hddLog(LOG1, FL("Step count %u"),
4474 pReqMsg->buckets[bktIndex].step_count);
4475
4476 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4477 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4478
4479 /* Framework shall pass the channel list if the input WiFi band is
4480 * WIFI_BAND_UNSPECIFIED.
4481 * If the input WiFi band is specified (any value other than
4482 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4483 */
4484 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4485 numChannels = 0;
4486 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4487 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4488 pReqMsg->buckets[bktIndex].band,
4489 chanList, &numChannels);
4490 if (!HAL_STATUS_SUCCESS(status)) {
4491 hddLog(LOGE,
4492 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4493 status);
4494 return -EINVAL;
4495 }
4496
4497 pReqMsg->buckets[bktIndex].numChannels =
4498 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4499 hddLog(LOG1, FL("Num channels %d"),
4500 pReqMsg->buckets[bktIndex].numChannels);
4501
4502 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4503 j++) {
4504 pReqMsg->buckets[bktIndex].channels[j].channel =
4505 chanList[j];
4506 pReqMsg->buckets[bktIndex].channels[j].
4507 chnlClass = 0;
4508 if (CSR_IS_CHANNEL_DFS(
4509 vos_freq_to_chan(chanList[j]))) {
4510 pReqMsg->buckets[bktIndex].channels[j].
4511 passive = 1;
4512 pReqMsg->buckets[bktIndex].channels[j].
4513 dwellTimeMs = passive_max_chn_time;
4514 } else {
4515 pReqMsg->buckets[bktIndex].channels[j].
4516 passive = 0;
4517 pReqMsg->buckets[bktIndex].channels[j].
4518 dwellTimeMs = active_max_chn_time;
4519 }
4520
4521 hddLog(LOG1,
4522 "Channel %u Passive %u Dwell time %u ms",
4523 pReqMsg->buckets[bktIndex].channels[j].channel,
4524 pReqMsg->buckets[bktIndex].channels[j].passive,
4525 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4526 }
4527
4528 bktIndex++;
4529 continue;
4530 }
4531
4532 /* Parse and fetch number of channels */
4533 if (!bucket[
4534 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4535 hddLog(LOGE, FL("attr num channels failed"));
4536 return -EINVAL;
4537 }
4538
4539 pReqMsg->buckets[bktIndex].numChannels =
4540 nla_get_u32(bucket[
4541 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4542 hddLog(LOG1, FL("num channels %d"),
4543 pReqMsg->buckets[bktIndex].numChannels);
4544
4545 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4546 hddLog(LOGE, FL("attr channel spec failed"));
4547 return -EINVAL;
4548 }
4549
4550 j = 0;
4551 nla_for_each_nested(channels,
4552 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4553 if (nla_parse(channel,
4554 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4555 nla_data(channels), nla_len(channels),
4556 wlan_hdd_extscan_config_policy)) {
4557 hddLog(LOGE, FL("nla_parse failed"));
4558 return -EINVAL;
4559 }
4560
4561 /* Parse and fetch channel */
4562 if (!channel[
4563 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4564 hddLog(LOGE, FL("attr channel failed"));
4565 return -EINVAL;
4566 }
4567 pReqMsg->buckets[bktIndex].channels[j].channel =
4568 nla_get_u32(channel[
4569 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4570 hddLog(LOG1, FL("channel %u"),
4571 pReqMsg->buckets[bktIndex].channels[j].channel);
4572
4573 /* Parse and fetch dwell time */
4574 if (!channel[
4575 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4576 hddLog(LOGE, FL("attr dwelltime failed"));
4577 return -EINVAL;
4578 }
4579 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4580 nla_get_u32(channel[
4581 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4582
4583 hddLog(LOG1, FL("Dwell time (%u ms)"),
4584 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4585
4586
4587 /* Parse and fetch channel spec passive */
4588 if (!channel[
4589 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4590 hddLog(LOGE,
4591 FL("attr channel spec passive failed"));
4592 return -EINVAL;
4593 }
4594 pReqMsg->buckets[bktIndex].channels[j].passive =
4595 nla_get_u8(channel[
4596 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4597 hddLog(LOG1, FL("Chnl spec passive %u"),
4598 pReqMsg->buckets[bktIndex].channels[j].passive);
4599
4600 j++;
4601 }
4602
4603 bktIndex++;
4604 }
4605
4606 return 0;
4607}
4608
4609
4610/*
4611 * define short names for the global vendor params
4612 * used by wlan_hdd_cfg80211_extscan_start()
4613 */
4614#define PARAM_MAX \
4615QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4616#define PARAM_REQUEST_ID \
4617QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4618#define PARAM_BASE_PERIOD \
4619QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4620#define PARAM_MAX_AP_PER_SCAN \
4621QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4622#define PARAM_RPT_THRHLD_PERCENT \
4623QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4624#define PARAM_RPT_THRHLD_NUM_SCANS \
4625QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4626#define PARAM_NUM_BUCKETS \
4627QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4628
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304629static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304630 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304631 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304632{
Dino Myclee8843b32014-07-04 14:21:45 +05304633 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304634 struct net_device *dev = wdev->netdev;
4635 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4636 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4637 struct nlattr *tb[PARAM_MAX + 1];
4638 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304639 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304640 tANI_U32 request_id;
4641 struct hdd_ext_scan_context *context;
4642 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304644 ENTER();
4645
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304646 if (VOS_FTM_MODE == hdd_get_conparam()) {
4647 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4648 return -EINVAL;
4649 }
4650
Dino Mycle6fb96c12014-06-10 11:52:40 +05304651 status = wlan_hdd_validate_context(pHddCtx);
4652 if (0 != status)
4653 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304654 return -EINVAL;
4655 }
Dino Myclee8843b32014-07-04 14:21:45 +05304656 /* check the EXTScan Capability */
4657 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304658 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4659 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304660 {
4661 hddLog(VOS_TRACE_LEVEL_ERROR,
4662 FL("EXTScan not enabled/supported by Firmware"));
4663 return -EINVAL;
4664 }
4665
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304666 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304667 data, dataLen,
4668 wlan_hdd_extscan_config_policy)) {
4669 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4670 return -EINVAL;
4671 }
4672
4673 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304674 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4676 return -EINVAL;
4677 }
4678
Dino Myclee8843b32014-07-04 14:21:45 +05304679 pReqMsg = (tpSirEXTScanStartReqParams)
4680 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304681 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304682 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4683 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304684 }
4685
4686 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304687 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304688 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4689
4690 pReqMsg->sessionId = pAdapter->sessionId;
4691 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4692
4693 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304694 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4696 goto fail;
4697 }
4698 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304699 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304700 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4701 pReqMsg->basePeriod);
4702
4703 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304704 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304705 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4706 goto fail;
4707 }
4708 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304709 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304710 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4711 pReqMsg->maxAPperScan);
4712
4713 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304714 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4716 goto fail;
4717 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304718 pReqMsg->reportThresholdPercent = nla_get_u8(
4719 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304720 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304721 pReqMsg->reportThresholdPercent);
4722
4723 /* Parse and fetch report threshold num scans */
4724 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4725 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4726 goto fail;
4727 }
4728 pReqMsg->reportThresholdNumScans = nla_get_u8(
4729 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4730 hddLog(LOG1, FL("Report Threshold num scans %d"),
4731 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304732
4733 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304734 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304735 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4736 goto fail;
4737 }
4738 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304739 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304740 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4741 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4742 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4743 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4744 }
4745 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4746 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304747
Dino Mycle6fb96c12014-06-10 11:52:40 +05304748 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4749 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4750 goto fail;
4751 }
4752
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304753 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304754
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304755 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4756 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304757
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304758 context = &pHddCtx->ext_scan_context;
4759 spin_lock(&hdd_context_lock);
4760 INIT_COMPLETION(context->response_event);
4761 context->request_id = request_id = pReqMsg->requestId;
4762 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304763
Dino Mycle6fb96c12014-06-10 11:52:40 +05304764 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4765 if (!HAL_STATUS_SUCCESS(status)) {
4766 hddLog(VOS_TRACE_LEVEL_ERROR,
4767 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304768 goto fail;
4769 }
4770
Srinivas Dasari91727c12016-03-23 17:59:06 +05304771 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
4772
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304773 /* request was sent -- wait for the response */
4774 rc = wait_for_completion_timeout(&context->response_event,
4775 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4776
4777 if (!rc) {
4778 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4779 retval = -ETIMEDOUT;
4780 } else {
4781 spin_lock(&hdd_context_lock);
4782 if (context->request_id == request_id)
4783 retval = context->response_status;
4784 else
4785 retval = -EINVAL;
4786 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304787 }
4788
Dino Myclee8843b32014-07-04 14:21:45 +05304789 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304790 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304791 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304792
4793fail:
4794 vos_mem_free(pReqMsg);
4795 return -EINVAL;
4796}
4797
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304798/*
4799 * done with short names for the global vendor params
4800 * used by wlan_hdd_cfg80211_extscan_start()
4801 */
4802#undef PARAM_MAX
4803#undef PARAM_REQUEST_ID
4804#undef PARAM_BASE_PERIOD
4805#undef PARAMS_MAX_AP_PER_SCAN
4806#undef PARAMS_RPT_THRHLD_PERCENT
4807#undef PARAMS_RPT_THRHLD_NUM_SCANS
4808#undef PARAMS_NUM_BUCKETS
4809
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304810static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4811 struct wireless_dev *wdev,
4812 const void *data, int dataLen)
4813{
4814 int ret = 0;
4815
4816 vos_ssr_protect(__func__);
4817 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4818 vos_ssr_unprotect(__func__);
4819
4820 return ret;
4821}
4822
4823static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304824 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304825 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304826{
Dino Myclee8843b32014-07-04 14:21:45 +05304827 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304828 struct net_device *dev = wdev->netdev;
4829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4830 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4831 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4832 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304833 int retval;
4834 unsigned long rc;
4835 struct hdd_ext_scan_context *context;
4836 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304837
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304838 ENTER();
4839
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304840 if (VOS_FTM_MODE == hdd_get_conparam()) {
4841 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4842 return -EINVAL;
4843 }
4844
Dino Mycle6fb96c12014-06-10 11:52:40 +05304845 status = wlan_hdd_validate_context(pHddCtx);
4846 if (0 != status)
4847 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304848 return -EINVAL;
4849 }
Dino Myclee8843b32014-07-04 14:21:45 +05304850 /* check the EXTScan Capability */
4851 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304852 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4853 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304854 {
4855 hddLog(VOS_TRACE_LEVEL_ERROR,
4856 FL("EXTScan not enabled/supported by Firmware"));
4857 return -EINVAL;
4858 }
4859
Dino Mycle6fb96c12014-06-10 11:52:40 +05304860 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4861 data, dataLen,
4862 wlan_hdd_extscan_config_policy)) {
4863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4864 return -EINVAL;
4865 }
4866
4867 /* Parse and fetch request Id */
4868 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4869 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4870 return -EINVAL;
4871 }
4872
Dino Myclee8843b32014-07-04 14:21:45 +05304873 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304874 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304875 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304876
Dino Myclee8843b32014-07-04 14:21:45 +05304877 reqMsg.sessionId = pAdapter->sessionId;
4878 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304879
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304880 context = &pHddCtx->ext_scan_context;
4881 spin_lock(&hdd_context_lock);
4882 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05304883 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304884 spin_unlock(&hdd_context_lock);
4885
Dino Myclee8843b32014-07-04 14:21:45 +05304886 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304887 if (!HAL_STATUS_SUCCESS(status)) {
4888 hddLog(VOS_TRACE_LEVEL_ERROR,
4889 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304890 return -EINVAL;
4891 }
4892
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304893 /* request was sent -- wait for the response */
4894 rc = wait_for_completion_timeout(&context->response_event,
4895 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4896
4897 if (!rc) {
4898 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4899 retval = -ETIMEDOUT;
4900 } else {
4901 spin_lock(&hdd_context_lock);
4902 if (context->request_id == request_id)
4903 retval = context->response_status;
4904 else
4905 retval = -EINVAL;
4906 spin_unlock(&hdd_context_lock);
4907 }
4908
4909 return retval;
4910
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304911 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304912 return 0;
4913}
4914
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304915static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4916 struct wireless_dev *wdev,
4917 const void *data, int dataLen)
4918{
4919 int ret = 0;
4920
4921 vos_ssr_protect(__func__);
4922 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4923 vos_ssr_unprotect(__func__);
4924
4925 return ret;
4926}
4927
4928static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304929 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304930 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304931{
Dino Myclee8843b32014-07-04 14:21:45 +05304932 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304933 struct net_device *dev = wdev->netdev;
4934 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4935 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4936 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4937 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304938 struct hdd_ext_scan_context *context;
4939 tANI_U32 request_id;
4940 unsigned long rc;
4941 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304942
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304943 ENTER();
4944
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304945 if (VOS_FTM_MODE == hdd_get_conparam()) {
4946 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4947 return -EINVAL;
4948 }
4949
Dino Mycle6fb96c12014-06-10 11:52:40 +05304950 status = wlan_hdd_validate_context(pHddCtx);
4951 if (0 != status)
4952 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304953 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304954 return -EINVAL;
4955 }
Dino Myclee8843b32014-07-04 14:21:45 +05304956 /* check the EXTScan Capability */
4957 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304958 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4959 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304960 {
4961 hddLog(VOS_TRACE_LEVEL_ERROR,
4962 FL("EXTScan not enabled/supported by Firmware"));
4963 return -EINVAL;
4964 }
4965
Dino Mycle6fb96c12014-06-10 11:52:40 +05304966 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4967 data, dataLen,
4968 wlan_hdd_extscan_config_policy)) {
4969 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4970 return -EINVAL;
4971 }
4972
4973 /* Parse and fetch request Id */
4974 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4976 return -EINVAL;
4977 }
4978
Dino Myclee8843b32014-07-04 14:21:45 +05304979 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304980 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304981 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304982
Dino Myclee8843b32014-07-04 14:21:45 +05304983 reqMsg.sessionId = pAdapter->sessionId;
4984 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304985
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304986 context = &pHddCtx->ext_scan_context;
4987 spin_lock(&hdd_context_lock);
4988 INIT_COMPLETION(context->response_event);
4989 context->request_id = request_id = reqMsg.requestId;
4990 spin_unlock(&hdd_context_lock);
4991
Dino Myclee8843b32014-07-04 14:21:45 +05304992 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304993 if (!HAL_STATUS_SUCCESS(status)) {
4994 hddLog(VOS_TRACE_LEVEL_ERROR,
4995 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304996 return -EINVAL;
4997 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304998
4999 /* request was sent -- wait for the response */
5000 rc = wait_for_completion_timeout(&context->response_event,
5001 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
5002 if (!rc) {
5003 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
5004 retval = -ETIMEDOUT;
5005 } else {
5006 spin_lock(&hdd_context_lock);
5007 if (context->request_id == request_id)
5008 retval = context->response_status;
5009 else
5010 retval = -EINVAL;
5011 spin_unlock(&hdd_context_lock);
5012 }
5013
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305014 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05305015 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05305016}
5017
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305018static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
5019 struct wireless_dev *wdev,
5020 const void *data, int dataLen)
5021{
5022 int ret = 0;
5023
5024 vos_ssr_protect(__func__);
5025 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
5026 vos_ssr_unprotect(__func__);
5027
5028 return ret;
5029}
Dino Mycle6fb96c12014-06-10 11:52:40 +05305030#endif /* WLAN_FEATURE_EXTSCAN */
5031
Atul Mittal115287b2014-07-08 13:26:33 +05305032/*EXT TDLS*/
5033static const struct nla_policy
5034wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
5035{
5036 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
5037 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
5038 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
5039 {.type = NLA_S32 },
5040 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
5041 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
5042
5043};
5044
5045static const struct nla_policy
5046wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
5047{
5048 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
5049
5050};
5051
5052static const struct nla_policy
5053wlan_hdd_tdls_config_state_change_policy[
5054 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5055{
5056 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
5057 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5058 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305059 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5060 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5061 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305062
5063};
5064
5065static const struct nla_policy
5066wlan_hdd_tdls_config_get_status_policy[
5067 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5068{
5069 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
5070 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5071 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305072 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5073 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5074 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305075
5076};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305077
5078static const struct nla_policy
5079wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5080{
5081 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
5082};
5083
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305084static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305085 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305086 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305087 int data_len)
5088{
5089
5090 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5091 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5092
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305093 ENTER();
5094
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305095 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305096 return -EINVAL;
5097 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305098 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305099 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305100 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305101 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305102 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305103 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305104 return -ENOTSUPP;
5105 }
5106
5107 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5108 data, data_len, wlan_hdd_mac_config)) {
5109 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5110 return -EINVAL;
5111 }
5112
5113 /* Parse and fetch mac address */
5114 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5115 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5116 return -EINVAL;
5117 }
5118
5119 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5120 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5121 VOS_MAC_ADDR_LAST_3_BYTES);
5122
Siddharth Bhal76972212014-10-15 16:22:51 +05305123 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5124
5125 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305126 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5127 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305128 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5129 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5130 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5131 {
5132 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5133 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5134 VOS_MAC_ADDRESS_LEN);
5135 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305136 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305137
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305138 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5139 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305140
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305141 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305142 return 0;
5143}
5144
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305145static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5146 struct wireless_dev *wdev,
5147 const void *data,
5148 int data_len)
5149{
5150 int ret = 0;
5151
5152 vos_ssr_protect(__func__);
5153 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5154 vos_ssr_unprotect(__func__);
5155
5156 return ret;
5157}
5158
5159static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305160 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305161 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305162 int data_len)
5163{
5164 u8 peer[6] = {0};
5165 struct net_device *dev = wdev->netdev;
5166 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5167 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5168 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5169 eHalStatus ret;
5170 tANI_S32 state;
5171 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305172 tANI_S32 global_operating_class = 0;
5173 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305174 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305175 int retVal;
5176
5177 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305178
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305179 if (!pAdapter) {
5180 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5181 return -EINVAL;
5182 }
5183
Atul Mittal115287b2014-07-08 13:26:33 +05305184 ret = wlan_hdd_validate_context(pHddCtx);
5185 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305186 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305187 return -EINVAL;
5188 }
5189 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305191 return -ENOTSUPP;
5192 }
5193 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5194 data, data_len,
5195 wlan_hdd_tdls_config_get_status_policy)) {
5196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5197 return -EINVAL;
5198 }
5199
5200 /* Parse and fetch mac address */
5201 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5202 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5203 return -EINVAL;
5204 }
5205
5206 memcpy(peer, nla_data(
5207 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5208 sizeof(peer));
5209 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5210
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305211 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305212
Atul Mittal115287b2014-07-08 13:26:33 +05305213 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305214 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305215 NLMSG_HDRLEN);
5216
5217 if (!skb) {
5218 hddLog(VOS_TRACE_LEVEL_ERROR,
5219 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5220 return -EINVAL;
5221 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305222 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 +05305223 reason,
5224 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305225 global_operating_class,
5226 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305227 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305228 if (nla_put_s32(skb,
5229 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5230 state) ||
5231 nla_put_s32(skb,
5232 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5233 reason) ||
5234 nla_put_s32(skb,
5235 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5236 global_operating_class) ||
5237 nla_put_s32(skb,
5238 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5239 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305240
5241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5242 goto nla_put_failure;
5243 }
5244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305245 retVal = cfg80211_vendor_cmd_reply(skb);
5246 EXIT();
5247 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305248
5249nla_put_failure:
5250 kfree_skb(skb);
5251 return -EINVAL;
5252}
5253
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305254static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5255 struct wireless_dev *wdev,
5256 const void *data,
5257 int data_len)
5258{
5259 int ret = 0;
5260
5261 vos_ssr_protect(__func__);
5262 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5263 vos_ssr_unprotect(__func__);
5264
5265 return ret;
5266}
5267
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305268static int wlan_hdd_cfg80211_exttdls_callback(
5269#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5270 const tANI_U8* mac,
5271#else
5272 tANI_U8* mac,
5273#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305274 tANI_S32 state,
5275 tANI_S32 reason,
5276 void *ctx)
5277{
5278 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305279 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305280 tANI_S32 global_operating_class = 0;
5281 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305282 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305283
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305284 ENTER();
5285
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305286 if (!pAdapter) {
5287 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5288 return -EINVAL;
5289 }
5290
5291 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305292 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305293 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305294 return -EINVAL;
5295 }
5296
5297 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305298 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305299 return -ENOTSUPP;
5300 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305301 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5302#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5303 NULL,
5304#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305305 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5306 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5307 GFP_KERNEL);
5308
5309 if (!skb) {
5310 hddLog(VOS_TRACE_LEVEL_ERROR,
5311 FL("cfg80211_vendor_event_alloc failed"));
5312 return -EINVAL;
5313 }
5314 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305315 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5316 reason,
5317 state,
5318 global_operating_class,
5319 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305320 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5321 MAC_ADDR_ARRAY(mac));
5322
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305323 if (nla_put(skb,
5324 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5325 VOS_MAC_ADDR_SIZE, mac) ||
5326 nla_put_s32(skb,
5327 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5328 state) ||
5329 nla_put_s32(skb,
5330 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5331 reason) ||
5332 nla_put_s32(skb,
5333 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5334 channel) ||
5335 nla_put_s32(skb,
5336 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5337 global_operating_class)
5338 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305339 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5340 goto nla_put_failure;
5341 }
5342
5343 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305344 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305345 return (0);
5346
5347nla_put_failure:
5348 kfree_skb(skb);
5349 return -EINVAL;
5350}
5351
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305352static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305353 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305354 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305355 int data_len)
5356{
5357 u8 peer[6] = {0};
5358 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305359 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5360 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5361 eHalStatus status;
5362 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305363 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305364 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305365
5366 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305367
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305368 if (!dev) {
5369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5370 return -EINVAL;
5371 }
5372
5373 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5374 if (!pAdapter) {
5375 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5376 return -EINVAL;
5377 }
5378
Atul Mittal115287b2014-07-08 13:26:33 +05305379 status = wlan_hdd_validate_context(pHddCtx);
5380 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305381 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305382 return -EINVAL;
5383 }
5384 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305385 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305386 return -ENOTSUPP;
5387 }
5388 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5389 data, data_len,
5390 wlan_hdd_tdls_config_enable_policy)) {
5391 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5392 return -EINVAL;
5393 }
5394
5395 /* Parse and fetch mac address */
5396 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5398 return -EINVAL;
5399 }
5400
5401 memcpy(peer, nla_data(
5402 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5403 sizeof(peer));
5404 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5405
5406 /* Parse and fetch channel */
5407 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5408 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5409 return -EINVAL;
5410 }
5411 pReqMsg.channel = nla_get_s32(
5412 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5413 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5414
5415 /* Parse and fetch global operating class */
5416 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5417 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5418 return -EINVAL;
5419 }
5420 pReqMsg.global_operating_class = nla_get_s32(
5421 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5422 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5423 pReqMsg.global_operating_class);
5424
5425 /* Parse and fetch latency ms */
5426 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5427 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5428 return -EINVAL;
5429 }
5430 pReqMsg.max_latency_ms = nla_get_s32(
5431 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5432 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5433 pReqMsg.max_latency_ms);
5434
5435 /* Parse and fetch required bandwidth kbps */
5436 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5437 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5438 return -EINVAL;
5439 }
5440
5441 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5442 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5443 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5444 pReqMsg.min_bandwidth_kbps);
5445
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305446 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305447 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305448 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305449 wlan_hdd_cfg80211_exttdls_callback);
5450
5451 EXIT();
5452 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305453}
5454
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305455static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5456 struct wireless_dev *wdev,
5457 const void *data,
5458 int data_len)
5459{
5460 int ret = 0;
5461
5462 vos_ssr_protect(__func__);
5463 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5464 vos_ssr_unprotect(__func__);
5465
5466 return ret;
5467}
5468
5469static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305470 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305471 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305472 int data_len)
5473{
5474 u8 peer[6] = {0};
5475 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305476 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5477 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5478 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305479 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305480 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305481
5482 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305483
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305484 if (!dev) {
5485 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5486 return -EINVAL;
5487 }
5488
5489 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5490 if (!pAdapter) {
5491 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5492 return -EINVAL;
5493 }
5494
Atul Mittal115287b2014-07-08 13:26:33 +05305495 status = wlan_hdd_validate_context(pHddCtx);
5496 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305497 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305498 return -EINVAL;
5499 }
5500 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305502 return -ENOTSUPP;
5503 }
5504 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5505 data, data_len,
5506 wlan_hdd_tdls_config_disable_policy)) {
5507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5508 return -EINVAL;
5509 }
5510 /* Parse and fetch mac address */
5511 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5512 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5513 return -EINVAL;
5514 }
5515
5516 memcpy(peer, nla_data(
5517 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5518 sizeof(peer));
5519 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5520
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305521 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5522
5523 EXIT();
5524 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305525}
5526
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305527static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5528 struct wireless_dev *wdev,
5529 const void *data,
5530 int data_len)
5531{
5532 int ret = 0;
5533
5534 vos_ssr_protect(__func__);
5535 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5536 vos_ssr_unprotect(__func__);
5537
5538 return ret;
5539}
5540
Dasari Srinivas7875a302014-09-26 17:50:57 +05305541static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305542__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305543 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305544 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305545{
5546 struct net_device *dev = wdev->netdev;
5547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5548 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5549 struct sk_buff *skb = NULL;
5550 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305551 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305553 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305554
5555 ret = wlan_hdd_validate_context(pHddCtx);
5556 if (0 != ret)
5557 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305558 return ret;
5559 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305560 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5561 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5562 fset |= WIFI_FEATURE_INFRA;
5563 }
5564
5565 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5566 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5567 fset |= WIFI_FEATURE_INFRA_5G;
5568 }
5569
5570#ifdef WLAN_FEATURE_P2P
5571 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5572 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5573 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5574 fset |= WIFI_FEATURE_P2P;
5575 }
5576#endif
5577
5578 /* Soft-AP is supported currently by default */
5579 fset |= WIFI_FEATURE_SOFT_AP;
5580
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305581 /* HOTSPOT is a supplicant feature, enable it by default */
5582 fset |= WIFI_FEATURE_HOTSPOT;
5583
Dasari Srinivas7875a302014-09-26 17:50:57 +05305584#ifdef WLAN_FEATURE_EXTSCAN
5585 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305586 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5587 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5588 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305589 fset |= WIFI_FEATURE_EXTSCAN;
5590 }
5591#endif
5592
Dasari Srinivas7875a302014-09-26 17:50:57 +05305593 if (sme_IsFeatureSupportedByFW(NAN)) {
5594 hddLog(LOG1, FL("NAN is supported by firmware"));
5595 fset |= WIFI_FEATURE_NAN;
5596 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305597
5598 /* D2D RTT is not supported currently by default */
5599 if (sme_IsFeatureSupportedByFW(RTT)) {
5600 hddLog(LOG1, FL("RTT is supported by firmware"));
5601 fset |= WIFI_FEATURE_D2AP_RTT;
5602 }
5603
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305604 if (sme_IsFeatureSupportedByFW(RTT3)) {
5605 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5606 fset |= WIFI_FEATURE_RTT3;
5607 }
5608
Dasari Srinivas7875a302014-09-26 17:50:57 +05305609#ifdef FEATURE_WLAN_BATCH_SCAN
5610 if (fset & WIFI_FEATURE_EXTSCAN) {
5611 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5612 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5613 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5614 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5615 fset |= WIFI_FEATURE_BATCH_SCAN;
5616 }
5617#endif
5618
5619#ifdef FEATURE_WLAN_SCAN_PNO
5620 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5621 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5622 hddLog(LOG1, FL("PNO is supported by firmware"));
5623 fset |= WIFI_FEATURE_PNO;
5624 }
5625#endif
5626
5627 /* STA+STA is supported currently by default */
5628 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5629
5630#ifdef FEATURE_WLAN_TDLS
5631 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5632 sme_IsFeatureSupportedByFW(TDLS)) {
5633 hddLog(LOG1, FL("TDLS is supported by firmware"));
5634 fset |= WIFI_FEATURE_TDLS;
5635 }
5636
5637 /* TDLS_OFFCHANNEL is not supported currently by default */
5638#endif
5639
5640#ifdef WLAN_AP_STA_CONCURRENCY
5641 /* AP+STA concurrency is supported currently by default */
5642 fset |= WIFI_FEATURE_AP_STA;
5643#endif
5644
Mukul Sharma5add0532015-08-17 15:57:47 +05305645#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5646 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5647 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5648#endif
5649
Dasari Srinivas7875a302014-09-26 17:50:57 +05305650 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5651 NLMSG_HDRLEN);
5652
5653 if (!skb) {
5654 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5655 return -EINVAL;
5656 }
5657 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5658
5659 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5660 hddLog(LOGE, FL("nla put fail"));
5661 goto nla_put_failure;
5662 }
5663
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305664 ret = cfg80211_vendor_cmd_reply(skb);
5665 EXIT();
5666 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305667
5668nla_put_failure:
5669 kfree_skb(skb);
5670 return -EINVAL;
5671}
5672
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305673static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305674wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5675 struct wireless_dev *wdev,
5676 const void *data, int data_len)
5677{
5678 int ret = 0;
5679
5680 vos_ssr_protect(__func__);
5681 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5682 vos_ssr_unprotect(__func__);
5683
5684 return ret;
5685}
5686
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305687
5688static const struct
5689nla_policy
5690qca_wlan_vendor_wifi_logger_get_ring_data_policy
5691[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5692 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5693 = {.type = NLA_U32 },
5694};
5695
5696static int
5697 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5698 struct wireless_dev *wdev,
5699 const void *data,
5700 int data_len)
5701{
5702 int ret;
5703 VOS_STATUS status;
5704 uint32_t ring_id;
5705 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5706 struct nlattr *tb
5707 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5708
5709 ENTER();
5710
5711 ret = wlan_hdd_validate_context(hdd_ctx);
5712 if (0 != ret) {
5713 return ret;
5714 }
5715
5716 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5717 data, data_len,
5718 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5719 hddLog(LOGE, FL("Invalid attribute"));
5720 return -EINVAL;
5721 }
5722
5723 /* Parse and fetch ring id */
5724 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5725 hddLog(LOGE, FL("attr ATTR failed"));
5726 return -EINVAL;
5727 }
5728
5729 ring_id = nla_get_u32(
5730 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5731
5732 hddLog(LOG1, FL("Bug report triggered by framework"));
5733
5734 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5735 WLAN_LOG_INDICATOR_FRAMEWORK,
5736 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305737 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305738 );
5739 if (VOS_STATUS_SUCCESS != status) {
5740 hddLog(LOGE, FL("Failed to trigger bug report"));
5741
5742 return -EINVAL;
5743 }
5744
5745 return 0;
5746
5747
5748}
5749
5750
5751static int
5752 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5753 struct wireless_dev *wdev,
5754 const void *data,
5755 int data_len)
5756{
5757 int ret = 0;
5758
5759 vos_ssr_protect(__func__);
5760 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5761 wdev, data, data_len);
5762 vos_ssr_unprotect(__func__);
5763
5764 return ret;
5765
5766}
5767
5768
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305769static int
5770__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305771 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305772 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305773{
5774 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5775 uint8_t i, feature_sets, max_feature_sets;
5776 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5777 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305778 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5779 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305780
5781 ENTER();
5782
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305783 ret = wlan_hdd_validate_context(pHddCtx);
5784 if (0 != ret)
5785 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305786 return ret;
5787 }
5788
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305789 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5790 data, data_len, NULL)) {
5791 hddLog(LOGE, FL("Invalid ATTR"));
5792 return -EINVAL;
5793 }
5794
5795 /* Parse and fetch max feature set */
5796 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5797 hddLog(LOGE, FL("Attr max feature set size failed"));
5798 return -EINVAL;
5799 }
5800 max_feature_sets = nla_get_u32(
5801 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5802 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5803
5804 /* Fill feature combination matrix */
5805 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305806 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5807 WIFI_FEATURE_P2P;
5808
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305809 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5810 WIFI_FEATURE_SOFT_AP;
5811
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305812 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5813 WIFI_FEATURE_SOFT_AP;
5814
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305815 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5816 WIFI_FEATURE_SOFT_AP |
5817 WIFI_FEATURE_P2P;
5818
5819 /* Add more feature combinations here */
5820
5821 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5822 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5823 hddLog(LOG1, "Feature set matrix");
5824 for (i = 0; i < feature_sets; i++)
5825 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5826
5827 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5828 sizeof(u32) * feature_sets +
5829 NLMSG_HDRLEN);
5830
5831 if (reply_skb) {
5832 if (nla_put_u32(reply_skb,
5833 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5834 feature_sets) ||
5835 nla_put(reply_skb,
5836 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5837 sizeof(u32) * feature_sets, feature_set_matrix)) {
5838 hddLog(LOGE, FL("nla put fail"));
5839 kfree_skb(reply_skb);
5840 return -EINVAL;
5841 }
5842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305843 ret = cfg80211_vendor_cmd_reply(reply_skb);
5844 EXIT();
5845 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305846 }
5847 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5848 return -ENOMEM;
5849
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305850}
5851
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305852static int
5853wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5854 struct wireless_dev *wdev,
5855 const void *data, int data_len)
5856{
5857 int ret = 0;
5858
5859 vos_ssr_protect(__func__);
5860 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5861 data_len);
5862 vos_ssr_unprotect(__func__);
5863
5864 return ret;
5865}
5866
c_manjeecfd1efb2015-09-25 19:32:34 +05305867
5868static int
5869__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5870 struct wireless_dev *wdev,
5871 const void *data, int data_len)
5872{
5873 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5874 int ret;
5875 ENTER();
5876
5877 ret = wlan_hdd_validate_context(pHddCtx);
5878 if (0 != ret)
5879 {
5880 return ret;
5881 }
5882
5883 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5884 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5885 {
5886 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5887 return -EINVAL;
5888 }
5889 /*call common API for FW mem dump req*/
5890 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5891
Abhishek Singhc783fa72015-12-09 18:07:34 +05305892 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305893 {
5894 /*indicate to userspace the status of fw mem dump */
5895 wlan_indicate_mem_dump_complete(true);
5896 }
5897 else
5898 {
5899 /*else send failure to userspace */
5900 wlan_indicate_mem_dump_complete(false);
5901 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305902 EXIT();
5903 return ret;
5904}
5905
5906/**
5907 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5908 * @wiphy: pointer to wireless wiphy structure.
5909 * @wdev: pointer to wireless_dev structure.
5910 * @data: Pointer to the NL data.
5911 * @data_len:Length of @data
5912 *
5913 * This is called when wlan driver needs to get the firmware memory dump
5914 * via vendor specific command.
5915 *
5916 * Return: 0 on success, error number otherwise.
5917 */
5918
5919static int
5920wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5921 struct wireless_dev *wdev,
5922 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305923{
5924 int ret = 0;
5925 vos_ssr_protect(__func__);
5926 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5927 data_len);
5928 vos_ssr_unprotect(__func__);
5929 return ret;
5930}
c_manjeecfd1efb2015-09-25 19:32:34 +05305931
Sushant Kaushik8e644982015-09-23 12:18:54 +05305932static const struct
5933nla_policy
5934qca_wlan_vendor_wifi_logger_start_policy
5935[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5936 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5937 = {.type = NLA_U32 },
5938 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5939 = {.type = NLA_U32 },
5940 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5941 = {.type = NLA_U32 },
5942};
5943
5944/**
5945 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5946 * or disable the collection of packet statistics from the firmware
5947 * @wiphy: WIPHY structure pointer
5948 * @wdev: Wireless device structure pointer
5949 * @data: Pointer to the data received
5950 * @data_len: Length of the data received
5951 *
5952 * This function is used to enable or disable the collection of packet
5953 * statistics from the firmware
5954 *
5955 * Return: 0 on success and errno on failure
5956 */
5957static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5958 struct wireless_dev *wdev,
5959 const void *data,
5960 int data_len)
5961{
5962 eHalStatus status;
5963 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5964 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5965 tAniWifiStartLog start_log;
5966
5967 status = wlan_hdd_validate_context(hdd_ctx);
5968 if (0 != status) {
5969 return -EINVAL;
5970 }
5971
5972 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5973 data, data_len,
5974 qca_wlan_vendor_wifi_logger_start_policy)) {
5975 hddLog(LOGE, FL("Invalid attribute"));
5976 return -EINVAL;
5977 }
5978
5979 /* Parse and fetch ring id */
5980 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5981 hddLog(LOGE, FL("attr ATTR failed"));
5982 return -EINVAL;
5983 }
5984 start_log.ringId = nla_get_u32(
5985 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5986 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5987
5988 /* Parse and fetch verbose level */
5989 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5990 hddLog(LOGE, FL("attr verbose_level failed"));
5991 return -EINVAL;
5992 }
5993 start_log.verboseLevel = nla_get_u32(
5994 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5995 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5996
5997 /* Parse and fetch flag */
5998 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5999 hddLog(LOGE, FL("attr flag failed"));
6000 return -EINVAL;
6001 }
6002 start_log.flag = nla_get_u32(
6003 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
6004 hddLog(LOG1, FL("flag=%d"), start_log.flag);
6005
6006 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05306007 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
6008 !vos_isPktStatsEnabled()))
6009
Sushant Kaushik8e644982015-09-23 12:18:54 +05306010 {
6011 hddLog(LOGE, FL("per pkt stats not enabled"));
6012 return -EINVAL;
6013 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05306014
Sushant Kaushik33200572015-08-05 16:46:20 +05306015 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306016 return 0;
6017}
6018
6019/**
6020 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6021 * or disable the collection of packet statistics from the firmware
6022 * @wiphy: WIPHY structure pointer
6023 * @wdev: Wireless device structure pointer
6024 * @data: Pointer to the data received
6025 * @data_len: Length of the data received
6026 *
6027 * This function is used to enable or disable the collection of packet
6028 * statistics from the firmware
6029 *
6030 * Return: 0 on success and errno on failure
6031 */
6032static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6033 struct wireless_dev *wdev,
6034 const void *data,
6035 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306036{
6037 int ret = 0;
6038
6039 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306040
6041 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6042 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306043 vos_ssr_unprotect(__func__);
6044
6045 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306046}
6047
6048
Agarwal Ashish738843c2014-09-25 12:27:56 +05306049static const struct nla_policy
6050wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6051 +1] =
6052{
6053 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6054};
6055
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306056static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306057 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306058 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306059 int data_len)
6060{
6061 struct net_device *dev = wdev->netdev;
6062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6063 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6064 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6065 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6066 eHalStatus status;
6067 u32 dfsFlag = 0;
6068
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306069 ENTER();
6070
Agarwal Ashish738843c2014-09-25 12:27:56 +05306071 status = wlan_hdd_validate_context(pHddCtx);
6072 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306073 return -EINVAL;
6074 }
6075 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6076 data, data_len,
6077 wlan_hdd_set_no_dfs_flag_config_policy)) {
6078 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6079 return -EINVAL;
6080 }
6081
6082 /* Parse and fetch required bandwidth kbps */
6083 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6085 return -EINVAL;
6086 }
6087
6088 dfsFlag = nla_get_u32(
6089 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6090 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6091 dfsFlag);
6092
6093 pHddCtx->disable_dfs_flag = dfsFlag;
6094
6095 sme_disable_dfs_channel(hHal, dfsFlag);
6096 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306097
6098 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306099 return 0;
6100}
Atul Mittal115287b2014-07-08 13:26:33 +05306101
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306102static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6103 struct wireless_dev *wdev,
6104 const void *data,
6105 int data_len)
6106{
6107 int ret = 0;
6108
6109 vos_ssr_protect(__func__);
6110 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6111 vos_ssr_unprotect(__func__);
6112
6113 return ret;
6114
6115}
6116
Mukul Sharma2a271632014-10-13 14:59:01 +05306117const struct
6118nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6119{
6120 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6121 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6122};
6123
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306124static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306125 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306126{
6127
6128 u8 bssid[6] = {0};
6129 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6130 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6131 eHalStatus status = eHAL_STATUS_SUCCESS;
6132 v_U32_t isFwrRoamEnabled = FALSE;
6133 int ret;
6134
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306135 ENTER();
6136
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306137 ret = wlan_hdd_validate_context(pHddCtx);
6138 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306139 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306140 }
6141
6142 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6143 data, data_len,
6144 qca_wlan_vendor_attr);
6145 if (ret){
6146 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6147 return -EINVAL;
6148 }
6149
6150 /* Parse and fetch Enable flag */
6151 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6152 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6153 return -EINVAL;
6154 }
6155
6156 isFwrRoamEnabled = nla_get_u32(
6157 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6158
6159 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6160
6161 /* Parse and fetch bssid */
6162 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6163 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6164 return -EINVAL;
6165 }
6166
6167 memcpy(bssid, nla_data(
6168 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6169 sizeof(bssid));
6170 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6171
6172 //Update roaming
6173 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306174 if (!HAL_STATUS_SUCCESS(status)) {
6175 hddLog(LOGE,
6176 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6177 return -EINVAL;
6178 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306179 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306180 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306181}
6182
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306183static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6184 struct wireless_dev *wdev, const void *data, int data_len)
6185{
6186 int ret = 0;
6187
6188 vos_ssr_protect(__func__);
6189 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6190 vos_ssr_unprotect(__func__);
6191
6192 return ret;
6193}
6194
Sushant Kaushik847890c2015-09-28 16:05:17 +05306195static const struct
6196nla_policy
6197qca_wlan_vendor_get_wifi_info_policy[
6198 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6199 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6200 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6201};
6202
6203
6204/**
6205 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6206 * @wiphy: pointer to wireless wiphy structure.
6207 * @wdev: pointer to wireless_dev structure.
6208 * @data: Pointer to the data to be passed via vendor interface
6209 * @data_len:Length of the data to be passed
6210 *
6211 * This is called when wlan driver needs to send wifi driver related info
6212 * (driver/fw version) to the user space application upon request.
6213 *
6214 * Return: Return the Success or Failure code.
6215 */
6216static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6217 struct wireless_dev *wdev,
6218 const void *data, int data_len)
6219{
6220 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6221 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6222 tSirVersionString version;
6223 uint32 version_len;
6224 uint8 attr;
6225 int status;
6226 struct sk_buff *reply_skb = NULL;
6227
6228 if (VOS_FTM_MODE == hdd_get_conparam()) {
6229 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6230 return -EINVAL;
6231 }
6232
6233 status = wlan_hdd_validate_context(hdd_ctx);
6234 if (0 != status) {
6235 hddLog(LOGE, FL("HDD context is not valid"));
6236 return -EINVAL;
6237 }
6238
6239 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6240 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6241 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6242 return -EINVAL;
6243 }
6244
6245 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6246 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6247 QWLAN_VERSIONSTR);
6248 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6249 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6250 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6251 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6252 hdd_ctx->fw_Version);
6253 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6254 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6255 } else {
6256 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6257 return -EINVAL;
6258 }
6259
6260 version_len = strlen(version);
6261 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6262 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6263 if (!reply_skb) {
6264 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6265 return -ENOMEM;
6266 }
6267
6268 if (nla_put(reply_skb, attr, version_len, version)) {
6269 hddLog(LOGE, FL("nla put fail"));
6270 kfree_skb(reply_skb);
6271 return -EINVAL;
6272 }
6273
6274 return cfg80211_vendor_cmd_reply(reply_skb);
6275}
6276
6277/**
6278 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6279 * @wiphy: pointer to wireless wiphy structure.
6280 * @wdev: pointer to wireless_dev structure.
6281 * @data: Pointer to the data to be passed via vendor interface
6282 * @data_len:Length of the data to be passed
6283 * @data_len: Length of the data received
6284 *
6285 * This function is used to enable or disable the collection of packet
6286 * statistics from the firmware
6287 *
6288 * Return: 0 on success and errno on failure
6289 */
6290
6291static int
6292wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6293 struct wireless_dev *wdev,
6294 const void *data, int data_len)
6295
6296
6297{
6298 int ret = 0;
6299
6300 vos_ssr_protect(__func__);
6301 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6302 wdev, data, data_len);
6303 vos_ssr_unprotect(__func__);
6304
6305 return ret;
6306}
6307
6308
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306309/*
6310 * define short names for the global vendor params
6311 * used by __wlan_hdd_cfg80211_monitor_rssi()
6312 */
6313#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6314#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6315#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6316#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6317#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6318
6319/**---------------------------------------------------------------------------
6320
6321 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6322 monitor start is completed successfully.
6323
6324 \return - None
6325
6326 --------------------------------------------------------------------------*/
6327void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6328{
6329 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6330
6331 if (NULL == pHddCtx)
6332 {
6333 hddLog(VOS_TRACE_LEVEL_ERROR,
6334 "%s: HDD context is NULL",__func__);
6335 return;
6336 }
6337
6338 if (VOS_STATUS_SUCCESS == status)
6339 {
6340 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6341 }
6342 else
6343 {
6344 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6345 }
6346
6347 return;
6348}
6349
6350/**---------------------------------------------------------------------------
6351
6352 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6353 stop is completed successfully.
6354
6355 \return - None
6356
6357 --------------------------------------------------------------------------*/
6358void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6359{
6360 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6361
6362 if (NULL == pHddCtx)
6363 {
6364 hddLog(VOS_TRACE_LEVEL_ERROR,
6365 "%s: HDD context is NULL",__func__);
6366 return;
6367 }
6368
6369 if (VOS_STATUS_SUCCESS == status)
6370 {
6371 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6372 }
6373 else
6374 {
6375 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6376 }
6377
6378 return;
6379}
6380
6381/**
6382 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6383 * @wiphy: Pointer to wireless phy
6384 * @wdev: Pointer to wireless device
6385 * @data: Pointer to data
6386 * @data_len: Data length
6387 *
6388 * Return: 0 on success, negative errno on failure
6389 */
6390
6391static int
6392__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6393 struct wireless_dev *wdev,
6394 const void *data,
6395 int data_len)
6396{
6397 struct net_device *dev = wdev->netdev;
6398 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6399 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6400 hdd_station_ctx_t *pHddStaCtx;
6401 struct nlattr *tb[PARAM_MAX + 1];
6402 tpSirRssiMonitorReq pReq;
6403 eHalStatus status;
6404 int ret;
6405 uint32_t control;
6406 static const struct nla_policy policy[PARAM_MAX + 1] = {
6407 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6408 [PARAM_CONTROL] = { .type = NLA_U32 },
6409 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6410 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6411 };
6412
6413 ENTER();
6414
6415 ret = wlan_hdd_validate_context(hdd_ctx);
6416 if (0 != ret) {
6417 return -EINVAL;
6418 }
6419
6420 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6421 hddLog(LOGE, FL("Not in Connected state!"));
6422 return -ENOTSUPP;
6423 }
6424
6425 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6426 hddLog(LOGE, FL("Invalid ATTR"));
6427 return -EINVAL;
6428 }
6429
6430 if (!tb[PARAM_REQUEST_ID]) {
6431 hddLog(LOGE, FL("attr request id failed"));
6432 return -EINVAL;
6433 }
6434
6435 if (!tb[PARAM_CONTROL]) {
6436 hddLog(LOGE, FL("attr control failed"));
6437 return -EINVAL;
6438 }
6439
6440 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6441
6442 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6443 if(NULL == pReq)
6444 {
6445 hddLog(LOGE,
6446 FL("vos_mem_alloc failed "));
6447 return eHAL_STATUS_FAILED_ALLOC;
6448 }
6449 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6450
6451 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6452 pReq->sessionId = pAdapter->sessionId;
6453 pReq->rssiMonitorCbContext = hdd_ctx;
6454 control = nla_get_u32(tb[PARAM_CONTROL]);
6455 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6456
6457 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6458 pReq->requestId, pReq->sessionId, control);
6459
6460 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6461 if (!tb[PARAM_MIN_RSSI]) {
6462 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306463 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306464 }
6465
6466 if (!tb[PARAM_MAX_RSSI]) {
6467 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306468 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306469 }
6470
6471 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6472 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6473 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6474
6475 if (!(pReq->minRssi < pReq->maxRssi)) {
6476 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6477 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306478 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306479 }
6480 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6481 pReq->minRssi, pReq->maxRssi);
6482 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6483
6484 }
6485 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6486 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6487 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6488 }
6489 else {
6490 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306491 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306492 }
6493
6494 if (!HAL_STATUS_SUCCESS(status)) {
6495 hddLog(LOGE,
6496 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306497 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306498 }
6499
6500 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306501fail:
6502 vos_mem_free(pReq);
6503 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306504}
6505
6506/*
6507 * done with short names for the global vendor params
6508 * used by __wlan_hdd_cfg80211_monitor_rssi()
6509 */
6510#undef PARAM_MAX
6511#undef PARAM_CONTROL
6512#undef PARAM_REQUEST_ID
6513#undef PARAM_MAX_RSSI
6514#undef PARAM_MIN_RSSI
6515
6516/**
6517 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6518 * @wiphy: wiphy structure pointer
6519 * @wdev: Wireless device structure pointer
6520 * @data: Pointer to the data received
6521 * @data_len: Length of @data
6522 *
6523 * Return: 0 on success; errno on failure
6524 */
6525static int
6526wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6527 const void *data, int data_len)
6528{
6529 int ret;
6530
6531 vos_ssr_protect(__func__);
6532 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6533 vos_ssr_unprotect(__func__);
6534
6535 return ret;
6536}
6537
6538/**
6539 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6540 * @hddctx: HDD context
6541 * @data: rssi breached event data
6542 *
6543 * This function reads the rssi breached event %data and fill in the skb with
6544 * NL attributes and send up the NL event.
6545 * This callback execute in atomic context and must not invoke any
6546 * blocking calls.
6547 *
6548 * Return: none
6549 */
6550void hdd_rssi_threshold_breached_cb(void *hddctx,
6551 struct rssi_breach_event *data)
6552{
6553 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6554 int status;
6555 struct sk_buff *skb;
6556
6557 ENTER();
6558 status = wlan_hdd_validate_context(pHddCtx);
6559
6560 if (0 != status) {
6561 return;
6562 }
6563
6564 if (!data) {
6565 hddLog(LOGE, FL("data is null"));
6566 return;
6567 }
6568
6569 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6570#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6571 NULL,
6572#endif
6573 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6574 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6575 GFP_KERNEL);
6576
6577 if (!skb) {
6578 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6579 return;
6580 }
6581
6582 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6583 data->request_id, data->curr_rssi);
6584 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6585 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6586
6587 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6588 data->request_id) ||
6589 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6590 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6591 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6592 data->curr_rssi)) {
6593 hddLog(LOGE, FL("nla put fail"));
6594 goto fail;
6595 }
6596
6597 cfg80211_vendor_event(skb, GFP_KERNEL);
6598 return;
6599
6600fail:
6601 kfree_skb(skb);
6602 return;
6603}
6604
6605
6606
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306607/**
6608 * __wlan_hdd_cfg80211_setband() - set band
6609 * @wiphy: Pointer to wireless phy
6610 * @wdev: Pointer to wireless device
6611 * @data: Pointer to data
6612 * @data_len: Data length
6613 *
6614 * Return: 0 on success, negative errno on failure
6615 */
6616static int
6617__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6618 struct wireless_dev *wdev,
6619 const void *data,
6620 int data_len)
6621{
6622 struct net_device *dev = wdev->netdev;
6623 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6624 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6625 int ret;
6626 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6627 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6628
6629 ENTER();
6630
6631 ret = wlan_hdd_validate_context(hdd_ctx);
6632 if (0 != ret) {
6633 hddLog(LOGE, FL("HDD context is not valid"));
6634 return ret;
6635 }
6636
6637 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6638 policy)) {
6639 hddLog(LOGE, FL("Invalid ATTR"));
6640 return -EINVAL;
6641 }
6642
6643 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6644 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6645 return -EINVAL;
6646 }
6647
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306648 hdd_ctx->isSetBandByNL = TRUE;
6649 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306650 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306651 hdd_ctx->isSetBandByNL = FALSE;
6652
6653 EXIT();
6654 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306655}
6656
6657/**
6658 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6659 * @wiphy: wiphy structure pointer
6660 * @wdev: Wireless device structure pointer
6661 * @data: Pointer to the data received
6662 * @data_len: Length of @data
6663 *
6664 * Return: 0 on success; errno on failure
6665 */
6666static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6667 struct wireless_dev *wdev,
6668 const void *data,
6669 int data_len)
6670{
6671 int ret = 0;
6672
6673 vos_ssr_protect(__func__);
6674 ret = __wlan_hdd_cfg80211_setband(wiphy,
6675 wdev, data, data_len);
6676 vos_ssr_unprotect(__func__);
6677
6678 return ret;
6679}
6680
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306681#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6682/**
6683 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6684 * @hdd_ctx: HDD context
6685 * @request_id: [input] request id
6686 * @pattern_id: [output] pattern id
6687 *
6688 * This function loops through request id to pattern id array
6689 * if the slot is available, store the request id and return pattern id
6690 * if entry exists, return the pattern id
6691 *
6692 * Return: 0 on success and errno on failure
6693 */
6694static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6695 uint32_t request_id,
6696 uint8_t *pattern_id)
6697{
6698 uint32_t i;
6699
6700 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6701 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6702 {
6703 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6704 {
6705 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6706 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6707 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6708 return 0;
6709 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6710 request_id) {
6711 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6712 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6713 return 0;
6714 }
6715 }
6716 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6717 return -EINVAL;
6718}
6719
6720/**
6721 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6722 * @hdd_ctx: HDD context
6723 * @request_id: [input] request id
6724 * @pattern_id: [output] pattern id
6725 *
6726 * This function loops through request id to pattern id array
6727 * reset request id to 0 (slot available again) and
6728 * return pattern id
6729 *
6730 * Return: 0 on success and errno on failure
6731 */
6732static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6733 uint32_t request_id,
6734 uint8_t *pattern_id)
6735{
6736 uint32_t i;
6737
6738 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6739 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6740 {
6741 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6742 {
6743 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6744 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6745 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6746 return 0;
6747 }
6748 }
6749 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6750 return -EINVAL;
6751}
6752
6753
6754/*
6755 * define short names for the global vendor params
6756 * used by __wlan_hdd_cfg80211_offloaded_packets()
6757 */
6758#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6759#define PARAM_REQUEST_ID \
6760 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6761#define PARAM_CONTROL \
6762 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6763#define PARAM_IP_PACKET \
6764 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6765#define PARAM_SRC_MAC_ADDR \
6766 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6767#define PARAM_DST_MAC_ADDR \
6768 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6769#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6770
6771/**
6772 * wlan_hdd_add_tx_ptrn() - add tx pattern
6773 * @adapter: adapter pointer
6774 * @hdd_ctx: hdd context
6775 * @tb: nl attributes
6776 *
6777 * This function reads the NL attributes and forms a AddTxPtrn message
6778 * posts it to SME.
6779 *
6780 */
6781static int
6782wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6783 struct nlattr **tb)
6784{
6785 struct sSirAddPeriodicTxPtrn *add_req;
6786 eHalStatus status;
6787 uint32_t request_id, ret, len;
6788 uint8_t pattern_id = 0;
6789 v_MACADDR_t dst_addr;
6790 uint16_t eth_type = htons(ETH_P_IP);
6791
6792 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6793 {
6794 hddLog(LOGE, FL("Not in Connected state!"));
6795 return -ENOTSUPP;
6796 }
6797
6798 add_req = vos_mem_malloc(sizeof(*add_req));
6799 if (!add_req)
6800 {
6801 hddLog(LOGE, FL("memory allocation failed"));
6802 return -ENOMEM;
6803 }
6804
6805 /* Parse and fetch request Id */
6806 if (!tb[PARAM_REQUEST_ID])
6807 {
6808 hddLog(LOGE, FL("attr request id failed"));
6809 goto fail;
6810 }
6811
6812 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6813 hddLog(LOG1, FL("Request Id: %u"), request_id);
6814 if (request_id == 0)
6815 {
6816 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306817 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306818 }
6819
6820 if (!tb[PARAM_PERIOD])
6821 {
6822 hddLog(LOGE, FL("attr period failed"));
6823 goto fail;
6824 }
6825 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6826 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6827 if (add_req->usPtrnIntervalMs == 0)
6828 {
6829 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6830 goto fail;
6831 }
6832
6833 if (!tb[PARAM_SRC_MAC_ADDR])
6834 {
6835 hddLog(LOGE, FL("attr source mac address failed"));
6836 goto fail;
6837 }
6838 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6839 VOS_MAC_ADDR_SIZE);
6840 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6841 MAC_ADDR_ARRAY(add_req->macAddress));
6842
6843 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6844 VOS_MAC_ADDR_SIZE))
6845 {
6846 hddLog(LOGE,
6847 FL("input src mac address and connected ap bssid are different"));
6848 goto fail;
6849 }
6850
6851 if (!tb[PARAM_DST_MAC_ADDR])
6852 {
6853 hddLog(LOGE, FL("attr dst mac address failed"));
6854 goto fail;
6855 }
6856 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6857 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6858 MAC_ADDR_ARRAY(dst_addr.bytes));
6859
6860 if (!tb[PARAM_IP_PACKET])
6861 {
6862 hddLog(LOGE, FL("attr ip packet failed"));
6863 goto fail;
6864 }
6865 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6866 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6867
6868 if (add_req->ucPtrnSize < 0 ||
6869 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6870 HDD_ETH_HEADER_LEN))
6871 {
6872 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6873 add_req->ucPtrnSize);
6874 goto fail;
6875 }
6876
6877 len = 0;
6878 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6879 len += VOS_MAC_ADDR_SIZE;
6880 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6881 VOS_MAC_ADDR_SIZE);
6882 len += VOS_MAC_ADDR_SIZE;
6883 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6884 len += 2;
6885
6886 /*
6887 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6888 * ------------------------------------------------------------
6889 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6890 * ------------------------------------------------------------
6891 */
6892 vos_mem_copy(&add_req->ucPattern[len],
6893 nla_data(tb[PARAM_IP_PACKET]),
6894 add_req->ucPtrnSize);
6895 add_req->ucPtrnSize += len;
6896
6897 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6898 add_req->ucPattern, add_req->ucPtrnSize);
6899
6900 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6901 if (ret)
6902 {
6903 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6904 goto fail;
6905 }
6906 add_req->ucPtrnId = pattern_id;
6907 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6908
6909 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6910 if (!HAL_STATUS_SUCCESS(status))
6911 {
6912 hddLog(LOGE,
6913 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6914 goto fail;
6915 }
6916
6917 EXIT();
6918 vos_mem_free(add_req);
6919 return 0;
6920
6921fail:
6922 vos_mem_free(add_req);
6923 return -EINVAL;
6924}
6925
6926/**
6927 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6928 * @adapter: adapter pointer
6929 * @hdd_ctx: hdd context
6930 * @tb: nl attributes
6931 *
6932 * This function reads the NL attributes and forms a DelTxPtrn message
6933 * posts it to SME.
6934 *
6935 */
6936static int
6937wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6938 struct nlattr **tb)
6939{
6940 struct sSirDelPeriodicTxPtrn *del_req;
6941 eHalStatus status;
6942 uint32_t request_id, ret;
6943 uint8_t pattern_id = 0;
6944
6945 /* Parse and fetch request Id */
6946 if (!tb[PARAM_REQUEST_ID])
6947 {
6948 hddLog(LOGE, FL("attr request id failed"));
6949 return -EINVAL;
6950 }
6951 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6952 if (request_id == 0)
6953 {
6954 hddLog(LOGE, FL("request_id cannot be zero"));
6955 return -EINVAL;
6956 }
6957
6958 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6959 if (ret)
6960 {
6961 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6962 return -EINVAL;
6963 }
6964
6965 del_req = vos_mem_malloc(sizeof(*del_req));
6966 if (!del_req)
6967 {
6968 hddLog(LOGE, FL("memory allocation failed"));
6969 return -ENOMEM;
6970 }
6971
6972 vos_mem_set(del_req, sizeof(*del_req), 0);
6973 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6974 VOS_MAC_ADDR_SIZE);
6975 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6976 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6977 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6978 request_id, pattern_id, del_req->ucPatternIdBitmap);
6979
6980 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6981 if (!HAL_STATUS_SUCCESS(status))
6982 {
6983 hddLog(LOGE,
6984 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6985 goto fail;
6986 }
6987
6988 EXIT();
6989 vos_mem_free(del_req);
6990 return 0;
6991
6992fail:
6993 vos_mem_free(del_req);
6994 return -EINVAL;
6995}
6996
6997
6998/**
6999 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
7000 * @wiphy: Pointer to wireless phy
7001 * @wdev: Pointer to wireless device
7002 * @data: Pointer to data
7003 * @data_len: Data length
7004 *
7005 * Return: 0 on success, negative errno on failure
7006 */
7007static int
7008__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7009 struct wireless_dev *wdev,
7010 const void *data,
7011 int data_len)
7012{
7013 struct net_device *dev = wdev->netdev;
7014 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7015 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7016 struct nlattr *tb[PARAM_MAX + 1];
7017 uint8_t control;
7018 int ret;
7019 static const struct nla_policy policy[PARAM_MAX + 1] =
7020 {
7021 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7022 [PARAM_CONTROL] = { .type = NLA_U32 },
7023 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7024 .len = VOS_MAC_ADDR_SIZE },
7025 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7026 .len = VOS_MAC_ADDR_SIZE },
7027 [PARAM_PERIOD] = { .type = NLA_U32 },
7028 };
7029
7030 ENTER();
7031
7032 ret = wlan_hdd_validate_context(hdd_ctx);
7033 if (0 != ret)
7034 {
7035 hddLog(LOGE, FL("HDD context is not valid"));
7036 return ret;
7037 }
7038
7039 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7040 {
7041 hddLog(LOGE,
7042 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7043 return -ENOTSUPP;
7044 }
7045
7046 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7047 {
7048 hddLog(LOGE, FL("Invalid ATTR"));
7049 return -EINVAL;
7050 }
7051
7052 if (!tb[PARAM_CONTROL])
7053 {
7054 hddLog(LOGE, FL("attr control failed"));
7055 return -EINVAL;
7056 }
7057 control = nla_get_u32(tb[PARAM_CONTROL]);
7058 hddLog(LOG1, FL("Control: %d"), control);
7059
7060 if (control == WLAN_START_OFFLOADED_PACKETS)
7061 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7062 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7063 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7064 else
7065 {
7066 hddLog(LOGE, FL("Invalid control: %d"), control);
7067 return -EINVAL;
7068 }
7069}
7070
7071/*
7072 * done with short names for the global vendor params
7073 * used by __wlan_hdd_cfg80211_offloaded_packets()
7074 */
7075#undef PARAM_MAX
7076#undef PARAM_REQUEST_ID
7077#undef PARAM_CONTROL
7078#undef PARAM_IP_PACKET
7079#undef PARAM_SRC_MAC_ADDR
7080#undef PARAM_DST_MAC_ADDR
7081#undef PARAM_PERIOD
7082
7083/**
7084 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7085 * @wiphy: wiphy structure pointer
7086 * @wdev: Wireless device structure pointer
7087 * @data: Pointer to the data received
7088 * @data_len: Length of @data
7089 *
7090 * Return: 0 on success; errno on failure
7091 */
7092static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7093 struct wireless_dev *wdev,
7094 const void *data,
7095 int data_len)
7096{
7097 int ret = 0;
7098
7099 vos_ssr_protect(__func__);
7100 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7101 wdev, data, data_len);
7102 vos_ssr_unprotect(__func__);
7103
7104 return ret;
7105}
7106#endif
7107
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307108static const struct
7109nla_policy
7110qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
7111 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
7112};
7113
7114/**
7115 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7116 * get link properties like nss, rate flags and operating frequency for
7117 * the connection with the given peer.
7118 * @wiphy: WIPHY structure pointer
7119 * @wdev: Wireless device structure pointer
7120 * @data: Pointer to the data received
7121 * @data_len: Length of the data received
7122 *
7123 * This function return the above link properties on success.
7124 *
7125 * Return: 0 on success and errno on failure
7126 */
7127static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7128 struct wireless_dev *wdev,
7129 const void *data,
7130 int data_len)
7131{
7132 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7133 struct net_device *dev = wdev->netdev;
7134 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7135 hdd_station_ctx_t *hdd_sta_ctx;
7136 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7137 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7138 uint32_t sta_id;
7139 struct sk_buff *reply_skb;
7140 uint32_t rate_flags = 0;
7141 uint8_t nss;
7142 uint8_t final_rate_flags = 0;
7143 uint32_t freq;
7144 v_CONTEXT_t pVosContext = NULL;
7145 ptSapContext pSapCtx = NULL;
7146
7147 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7148 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7149 return -EINVAL;
7150 }
7151
7152 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7153 qca_wlan_vendor_attr_policy)) {
7154 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7155 return -EINVAL;
7156 }
7157
7158 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7159 hddLog(VOS_TRACE_LEVEL_ERROR,
7160 FL("Attribute peerMac not provided for mode=%d"),
7161 adapter->device_mode);
7162 return -EINVAL;
7163 }
7164
7165 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7166 sizeof(peer_mac));
7167 hddLog(VOS_TRACE_LEVEL_INFO,
7168 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7169 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7170
7171 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7172 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7173 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7174 if ((hdd_sta_ctx->conn_info.connState !=
7175 eConnectionState_Associated) ||
7176 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7177 VOS_MAC_ADDRESS_LEN)) {
7178 hddLog(VOS_TRACE_LEVEL_ERROR,
7179 FL("Not Associated to mac "MAC_ADDRESS_STR),
7180 MAC_ADDR_ARRAY(peer_mac));
7181 return -EINVAL;
7182 }
7183
7184 nss = 1; //pronto supports only one spatial stream
7185 freq = vos_chan_to_freq(
7186 hdd_sta_ctx->conn_info.operationChannel);
7187 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7188
7189 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7190 adapter->device_mode == WLAN_HDD_SOFTAP) {
7191
7192 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7193 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7194 if(pSapCtx == NULL){
7195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7196 FL("psapCtx is NULL"));
7197 return -ENOENT;
7198 }
7199
7200
7201 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7202 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7203 !vos_is_macaddr_broadcast(
7204 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7205 vos_mem_compare(
7206 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7207 peer_mac, VOS_MAC_ADDRESS_LEN))
7208 break;
7209 }
7210
7211 if (WLAN_MAX_STA_COUNT == sta_id) {
7212 hddLog(VOS_TRACE_LEVEL_ERROR,
7213 FL("No active peer with mac="MAC_ADDRESS_STR),
7214 MAC_ADDR_ARRAY(peer_mac));
7215 return -EINVAL;
7216 }
7217
7218 nss = 1; //pronto supports only one spatial stream
7219 freq = vos_chan_to_freq(
7220 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7221 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7222 } else {
7223 hddLog(VOS_TRACE_LEVEL_ERROR,
7224 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7225 MAC_ADDR_ARRAY(peer_mac));
7226 return -EINVAL;
7227 }
7228
7229 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7230 if (rate_flags & eHAL_TX_RATE_VHT80) {
7231 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7232 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7233 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7234 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7235 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7236 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7237 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7238 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7239 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7240 if (rate_flags & eHAL_TX_RATE_HT40)
7241 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7242 }
7243
7244 if (rate_flags & eHAL_TX_RATE_SGI) {
7245 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7246 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7247 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7248 }
7249 }
7250
7251 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7252 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7253
7254 if (NULL == reply_skb) {
7255 hddLog(VOS_TRACE_LEVEL_ERROR,
7256 FL("getLinkProperties: skb alloc failed"));
7257 return -EINVAL;
7258 }
7259
7260 if (nla_put_u8(reply_skb,
7261 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7262 nss) ||
7263 nla_put_u8(reply_skb,
7264 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7265 final_rate_flags) ||
7266 nla_put_u32(reply_skb,
7267 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7268 freq)) {
7269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7270 kfree_skb(reply_skb);
7271 return -EINVAL;
7272 }
7273
7274 return cfg80211_vendor_cmd_reply(reply_skb);
7275}
7276
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307277#define BEACON_MISS_THRESH_2_4 \
7278 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24
7279#define BEACON_MISS_THRESH_5_0 \
7280 QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307281#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7282#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7283#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7284#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307285#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7286 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307287
7288/**
7289 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7290 * vendor command
7291 *
7292 * @wiphy: wiphy device pointer
7293 * @wdev: wireless device pointer
7294 * @data: Vendor command data buffer
7295 * @data_len: Buffer length
7296 *
7297 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7298 *
7299 * Return: EOK or other error codes.
7300 */
7301
7302static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7303 struct wireless_dev *wdev,
7304 const void *data,
7305 int data_len)
7306{
7307 struct net_device *dev = wdev->netdev;
7308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7309 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7310 hdd_station_ctx_t *pHddStaCtx;
7311 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7312 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307313 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307314 eHalStatus status;
7315 int ret_val;
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307316 uint8_t hb_thresh_val;
7317
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307318 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7319 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7320 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307321 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7322 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7323 { .type = NLA_U32},
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307324 [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 },
7325 [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 },
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307326 };
7327
7328 ENTER();
7329
7330 if (VOS_FTM_MODE == hdd_get_conparam()) {
7331 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7332 return -EINVAL;
7333 }
7334
7335 ret_val = wlan_hdd_validate_context(pHddCtx);
7336 if (ret_val) {
7337 return ret_val;
7338 }
7339
7340 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7341
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307342 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7343 hddLog(LOGE, FL("Invalid ATTR"));
7344 return -EINVAL;
7345 }
7346
7347 /* check the Wifi Capability */
7348 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7349 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7350 {
7351 hddLog(VOS_TRACE_LEVEL_ERROR,
7352 FL("WIFICONFIG not supported by Firmware"));
7353 return -EINVAL;
7354 }
7355
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307356 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7357 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7358 modifyRoamParamsReq.value =
7359 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7360
7361 if (eHAL_STATUS_SUCCESS !=
7362 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7363 {
7364 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7365 ret_val = -EINVAL;
7366 }
7367 return ret_val;
7368 }
7369
7370 /* Moved this down in order to provide provision to set beacon
7371 * miss penalty count irrespective of connection state.
7372 */
7373 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7374 hddLog(LOGE, FL("Not in Connected state!"));
7375 return -ENOTSUPP;
7376 }
7377
7378 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307379
7380 if (!pReq) {
7381 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7382 "%s: Not able to allocate memory for tSetWifiConfigParams",
7383 __func__);
7384 return eHAL_STATUS_E_MALLOC_FAILED;
7385 }
7386
7387 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7388
7389 pReq->sessionId = pAdapter->sessionId;
7390 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7391
7392 if (tb[PARAM_MODULATED_DTIM]) {
7393 pReq->paramValue = nla_get_u32(
7394 tb[PARAM_MODULATED_DTIM]);
7395 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7396 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307397 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307398 hdd_set_pwrparams(pHddCtx);
7399 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7400 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7401
7402 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7403 iw_full_power_cbfn, pAdapter,
7404 eSME_FULL_PWR_NEEDED_BY_HDD);
7405 }
7406 else
7407 {
7408 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7409 }
7410 }
7411
7412 if (tb[PARAM_STATS_AVG_FACTOR]) {
7413 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7414 pReq->paramValue = nla_get_u16(
7415 tb[PARAM_STATS_AVG_FACTOR]);
7416 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7417 pReq->paramType, pReq->paramValue);
7418 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7419
7420 if (eHAL_STATUS_SUCCESS != status)
7421 {
7422 vos_mem_free(pReq);
7423 pReq = NULL;
7424 ret_val = -EPERM;
7425 return ret_val;
7426 }
7427 }
7428
7429
7430 if (tb[PARAM_GUARD_TIME]) {
7431 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7432 pReq->paramValue = nla_get_u32(
7433 tb[PARAM_GUARD_TIME]);
7434 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7435 pReq->paramType, pReq->paramValue);
7436 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7437
7438 if (eHAL_STATUS_SUCCESS != status)
7439 {
7440 vos_mem_free(pReq);
7441 pReq = NULL;
7442 ret_val = -EPERM;
7443 return ret_val;
7444 }
7445
7446 }
7447
Ravi Kumar bokka7d032762016-12-12 23:33:01 +05307448 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) {
7449 hb_thresh_val = nla_get_u8(
7450 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]);
7451
7452 hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d",
7453 hb_thresh_val);
7454 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7455 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7456 NULL, eANI_BOOLEAN_FALSE);
7457
7458 status = sme_update_hb_threshold(
7459 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
7460 WNI_CFG_HEART_BEAT_THRESHOLD,
7461 hb_thresh_val, eCSR_BAND_24);
7462 if (eHAL_STATUS_SUCCESS != status) {
7463 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
7464 vos_mem_free(pReq);
7465 pReq = NULL;
7466 return -EPERM;
7467 }
7468 }
7469
7470 if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) {
7471 hb_thresh_val = nla_get_u8(
7472 tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]);
7473
7474 hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d",
7475 hb_thresh_val);
7476 ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7477 WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val,
7478 NULL, eANI_BOOLEAN_FALSE);
7479
7480 status = sme_update_hb_threshold(
7481 (WLAN_HDD_GET_CTX(pAdapter))->hHal,
7482 WNI_CFG_HEART_BEAT_THRESHOLD,
7483 hb_thresh_val, eCSR_BAND_5G);
7484 if (eHAL_STATUS_SUCCESS != status) {
7485 hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status);
7486 vos_mem_free(pReq);
7487 pReq = NULL;
7488 return -EPERM;
7489 }
7490 }
7491
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307492 EXIT();
7493 return ret_val;
7494}
7495
7496/**
7497 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7498 * vendor command
7499 *
7500 * @wiphy: wiphy device pointer
7501 * @wdev: wireless device pointer
7502 * @data: Vendor command data buffer
7503 * @data_len: Buffer length
7504 *
7505 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7506 *
7507 * Return: EOK or other error codes.
7508 */
7509static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7510 struct wireless_dev *wdev,
7511 const void *data,
7512 int data_len)
7513{
7514 int ret;
7515
7516 vos_ssr_protect(__func__);
7517 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
7518 data, data_len);
7519 vos_ssr_unprotect(__func__);
7520
7521 return ret;
7522}
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307523
7524/*
7525 * define short names for the global vendor params
7526 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
7527 */
7528#define STATS_SET_INVALID \
7529 QCA_ATTR_NUD_STATS_SET_INVALID
7530#define STATS_SET_START \
7531 QCA_ATTR_NUD_STATS_SET_START
7532#define STATS_GW_IPV4 \
7533 QCA_ATTR_NUD_STATS_GW_IPV4
7534#define STATS_SET_MAX \
7535 QCA_ATTR_NUD_STATS_SET_MAX
7536
7537const struct nla_policy
7538qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] =
7539{
7540 [STATS_SET_START] = {.type = NLA_FLAG },
7541 [STATS_GW_IPV4] = {.type = NLA_U32 },
7542};
7543
7544/**
7545 * hdd_set_nud_stats_cb() - hdd callback api to get status
7546 * @data: pointer to adapter
7547 * @rsp: status
7548 *
7549 * Return: None
7550 */
7551static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp)
7552{
7553
7554 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
7555
7556 if (NULL == adapter)
7557 return;
7558
7559 if (VOS_STATUS_SUCCESS == rsp) {
7560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7561 "%s success received STATS_SET_START", __func__);
7562 } else {
7563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7564 "%s STATS_SET_START Failed!!", __func__);
7565 }
7566 return;
7567}
7568
7569/**
7570 * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7571 * @wiphy: pointer to wireless wiphy structure.
7572 * @wdev: pointer to wireless_dev structure.
7573 * @data: pointer to apfind configuration data.
7574 * @data_len: the length in byte of apfind data.
7575 *
7576 * This is called when wlan driver needs to send arp stats to
7577 * firmware.
7578 *
7579 * Return: An error code or 0 on success.
7580 */
7581static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7582 struct wireless_dev *wdev,
7583 const void *data, int data_len)
7584{
7585 struct nlattr *tb[STATS_SET_MAX + 1];
7586 struct net_device *dev = wdev->netdev;
7587 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7588 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307589 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext;
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307590 setArpStatsParams arp_stats_params;
7591 int err = 0;
7592
7593 ENTER();
7594
7595 err = wlan_hdd_validate_context(hdd_ctx);
7596 if (0 != err)
7597 return err;
7598
7599 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7601 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7602 return -EINVAL;
7603 }
7604
7605 err = nla_parse(tb, STATS_SET_MAX, data, data_len,
7606 qca_wlan_vendor_set_nud_stats);
7607 if (err)
7608 {
7609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7610 "%s STATS_SET_START ATTR", __func__);
7611 return err;
7612 }
7613
7614 if (tb[STATS_SET_START])
7615 {
7616 if (!tb[STATS_GW_IPV4]) {
7617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7618 "%s STATS_SET_START CMD", __func__);
7619 return -EINVAL;
7620 }
7621 arp_stats_params.flag = true;
7622 arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]);
7623 } else {
7624 arp_stats_params.flag = false;
7625 }
Anurag Chouhan630c5562017-03-23 14:51:47 +05307626 if (arp_stats_params.flag)
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7628 "%s STATS_SET_START Cleared!!", __func__);
Anurag Chouhan630c5562017-03-23 14:51:47 +05307629 vos_mem_zero(&adapter->hdd_stats.hddArpStats,
7630 sizeof(adapter->hdd_stats.hddArpStats));
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307631
7632 arp_stats_params.pkt_type = 1; // ARP packet type
7633
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05307634 if (arp_stats_params.flag) {
7635 hdd_ctx->track_arp_ip = arp_stats_params.ip_addr;
7636 WLANTL_SetARPFWDatapath(pVosContext, true);
7637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7638 "%s Set FW in data path for ARP with tgt IP :%d",
7639 __func__, hdd_ctx->track_arp_ip);
7640 }
7641 else {
7642 WLANTL_SetARPFWDatapath(pVosContext, false);
7643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7644 "%s Remove FW from data path", __func__);
7645 }
7646
Anurag Chouhan6ee81542017-02-09 18:09:27 +05307647 arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb;
7648 arp_stats_params.data_ctx = adapter;
7649
7650 if (eHAL_STATUS_SUCCESS !=
7651 sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7653 "%s STATS_SET_START CMD Failed!!", __func__);
7654 return -EINVAL;
7655 }
7656
7657 EXIT();
7658
7659 return err;
7660}
7661
7662/**
7663 * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware
7664 * @wiphy: pointer to wireless wiphy structure.
7665 * @wdev: pointer to wireless_dev structure.
7666 * @data: pointer to apfind configuration data.
7667 * @data_len: the length in byte of apfind data.
7668 *
7669 * This is called when wlan driver needs to send arp stats to
7670 * firmware.
7671 *
7672 * Return: An error code or 0 on success.
7673 */
7674static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
7675 struct wireless_dev *wdev,
7676 const void *data, int data_len)
7677{
7678 int ret;
7679
7680 vos_ssr_protect(__func__);
7681 ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len);
7682 vos_ssr_unprotect(__func__);
7683
7684 return ret;
7685}
7686#undef STATS_SET_INVALID
7687#undef STATS_SET_START
7688#undef STATS_GW_IPV4
7689#undef STATS_SET_MAX
7690
7691/*
7692 * define short names for the global vendor params
7693 * used by wlan_hdd_cfg80211_setarp_stats_cmd()
7694 */
7695#define STATS_GET_INVALID \
7696 QCA_ATTR_NUD_STATS_SET_INVALID
7697#define COUNT_FROM_NETDEV \
7698 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7699#define COUNT_TO_LOWER_MAC \
7700 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7701#define RX_COUNT_BY_LOWER_MAC \
7702 QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7703#define COUNT_TX_SUCCESS \
7704 QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7705#define RSP_RX_COUNT_BY_LOWER_MAC \
7706 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7707#define RSP_RX_COUNT_BY_UPPER_MAC \
7708 QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7709#define RSP_COUNT_TO_NETDEV \
7710 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7711#define RSP_COUNT_OUT_OF_ORDER_DROP \
7712 QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7713#define AP_LINK_ACTIVE \
7714 QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7715#define AP_LINK_DAD \
7716 QCA_ATTR_NUD_STATS_AP_LINK_DAD
7717#define STATS_GET_MAX \
7718 QCA_ATTR_NUD_STATS_GET_MAX
7719
7720const struct nla_policy
7721qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] =
7722{
7723 [COUNT_FROM_NETDEV] = {.type = NLA_U16 },
7724 [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 },
7725 [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7726 [COUNT_TX_SUCCESS] = {.type = NLA_U16 },
7727 [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 },
7728 [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 },
7729 [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 },
7730 [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 },
7731 [AP_LINK_ACTIVE] = {.type = NLA_FLAG },
7732 [AP_LINK_DAD] = {.type = NLA_FLAG },
7733};
7734
7735static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp)
7736{
7737
7738 hdd_adapter_t *adapter = (hdd_adapter_t *)data;
7739 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7740 struct hdd_nud_stats_context *context;
7741 int status;
7742
7743 ENTER();
7744
7745 if (NULL == adapter)
7746 return;
7747
7748 status = wlan_hdd_validate_context(hdd_ctx);
7749 if (0 != status) {
7750 return;
7751 }
7752
7753 if (!rsp) {
7754 hddLog(LOGE, FL("data is null"));
7755 return;
7756 }
7757
7758 adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt;
7759 adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt;
7760 adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt;
7761 adapter->dad |= rsp->dad;
7762
7763 spin_lock(&hdd_context_lock);
7764 context = &hdd_ctx->nud_stats_context;
7765 complete(&context->response_event);
7766 spin_unlock(&hdd_context_lock);
7767
7768 return;
7769}
7770static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7771 struct wireless_dev *wdev,
7772 const void *data, int data_len)
7773{
7774 int err = 0;
7775 unsigned long rc;
7776 struct hdd_nud_stats_context *context;
7777 struct net_device *dev = wdev->netdev;
7778 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7779 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7780 getArpStatsParams arp_stats_params;
7781 struct sk_buff *skb;
7782
7783 ENTER();
7784
7785 err = wlan_hdd_validate_context(hdd_ctx);
7786 if (0 != err)
7787 return err;
7788
7789 arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE;
7790 arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb;
7791 arp_stats_params.data_ctx = adapter;
7792
7793 spin_lock(&hdd_context_lock);
7794 context = &hdd_ctx->nud_stats_context;
7795 INIT_COMPLETION(context->response_event);
7796 spin_unlock(&hdd_context_lock);
7797
7798 if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) {
7799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7800 "%s NUD_DEBUG feature not supported by firmware!!", __func__);
7801 return -EINVAL;
7802 }
7803
7804 if (eHAL_STATUS_SUCCESS !=
7805 sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) {
7806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 "%s STATS_SET_START CMD Failed!!", __func__);
7808 return -EINVAL;
7809 }
7810
7811 rc = wait_for_completion_timeout(&context->response_event,
7812 msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS));
7813 if (!rc)
7814 {
7815 hddLog(LOGE,
7816 FL("Target response timed out request "));
7817 return -ETIMEDOUT;
7818 }
7819
7820 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7821 WLAN_NUD_STATS_LEN);
7822 if (!skb)
7823 {
7824 hddLog(VOS_TRACE_LEVEL_ERROR,
7825 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
7826 __func__);
7827 return -ENOMEM;
7828 }
7829
7830 if (nla_put_u16(skb, COUNT_FROM_NETDEV,
7831 adapter->hdd_stats.hddArpStats.txCount) ||
7832 nla_put_u16(skb, COUNT_TO_LOWER_MAC,
7833 adapter->hdd_stats.hddArpStats.tx_host_fw_sent) ||
7834 nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC,
7835 adapter->hdd_stats.hddArpStats.tx_fw_cnt) ||
7836 nla_put_u16(skb, COUNT_TX_SUCCESS,
7837 adapter->hdd_stats.hddArpStats.tx_ack_cnt) ||
7838 nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC,
7839 adapter->hdd_stats.hddArpStats.rx_fw_cnt) ||
7840 nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC,
7841 adapter->hdd_stats.hddArpStats.rxCount) ||
7842 nla_put_u16(skb, RSP_COUNT_TO_NETDEV,
7843 adapter->hdd_stats.hddArpStats.rxDelivered) ||
7844 nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP,
7845 adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) {
7846 hddLog(LOGE, FL("nla put fail"));
7847 kfree_skb(skb);
7848 return -EINVAL;
7849 }
7850 if (adapter->con_status)
7851 nla_put_flag(skb, AP_LINK_ACTIVE);
7852 if (adapter->dad)
7853 nla_put_flag(skb, AP_LINK_DAD);
7854
7855 cfg80211_vendor_cmd_reply(skb);
7856 return err;
7857}
7858
7859static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy,
7860 struct wireless_dev *wdev,
7861 const void *data, int data_len)
7862{
7863 int ret;
7864
7865 vos_ssr_protect(__func__);
7866 ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len);
7867 vos_ssr_unprotect(__func__);
7868
7869 return ret;
7870}
7871
7872#undef QCA_ATTR_NUD_STATS_SET_INVALID
7873#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV
7874#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC
7875#undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC
7876#undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS
7877#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC
7878#undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC
7879#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV
7880#undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP
7881#undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE
7882#undef QCA_ATTR_NUD_STATS_GET_MAX
7883
7884
7885
Kapil Guptaee33bf12016-12-20 18:27:37 +05307886#ifdef WLAN_FEATURE_APFIND
7887/**
7888 * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7889 * @wiphy: pointer to wireless wiphy structure.
7890 * @wdev: pointer to wireless_dev structure.
7891 * @data: pointer to apfind configuration data.
7892 * @data_len: the length in byte of apfind data.
7893 *
7894 * This is called when wlan driver needs to send APFIND configurations to
7895 * firmware.
7896 *
7897 * Return: An error code or 0 on success.
7898 */
7899static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7900 struct wireless_dev *wdev,
7901 const void *data, int data_len)
7902{
7903 struct sme_ap_find_request_req apfind_req;
7904 VOS_STATUS status;
7905 int ret_val;
7906 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7907
7908 ENTER();
7909
7910 ret_val = wlan_hdd_validate_context(hdd_ctx);
7911 if (ret_val)
7912 return ret_val;
7913
7914 if (VOS_FTM_MODE == hdd_get_conparam()) {
7915 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7916 return -EPERM;
7917 }
7918
7919 apfind_req.request_data_len = data_len;
7920 apfind_req.request_data = data;
7921
7922 status = sme_apfind_set_cmd(&apfind_req);
7923 if (VOS_STATUS_SUCCESS != status) {
7924 ret_val = -EIO;
7925 }
7926 return ret_val;
7927}
7928
7929/**
7930 * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware
7931 * @wiphy: pointer to wireless wiphy structure.
7932 * @wdev: pointer to wireless_dev structure.
7933 * @data: pointer to apfind configuration data.
7934 * @data_len: the length in byte of apfind data.
7935 *
7936 * This is called when wlan driver needs to send APFIND configurations to
7937 * firmware.
7938 *
7939 * Return: An error code or 0 on success.
7940 */
7941static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy,
7942 struct wireless_dev *wdev,
7943 const void *data, int data_len)
7944{
7945 int ret;
7946
7947 vos_ssr_protect(__func__);
7948 ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len);
7949 vos_ssr_unprotect(__func__);
7950
7951 return ret;
7952}
7953#endif /* WLAN_FEATURE_APFIND */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307954const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7955{
Mukul Sharma2a271632014-10-13 14:59:01 +05307956 {
7957 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7958 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7959 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7960 WIPHY_VENDOR_CMD_NEED_NETDEV |
7961 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307962 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307963 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307964
7965 {
7966 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7967 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7968 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7969 WIPHY_VENDOR_CMD_NEED_NETDEV |
7970 WIPHY_VENDOR_CMD_NEED_RUNNING,
7971 .doit = wlan_hdd_cfg80211_nan_request
7972 },
7973
Sunil Duttc69bccb2014-05-26 21:30:20 +05307974#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7975 {
7976 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7977 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7978 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7979 WIPHY_VENDOR_CMD_NEED_NETDEV |
7980 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307981 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307982 },
7983
7984 {
7985 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7986 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7987 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7988 WIPHY_VENDOR_CMD_NEED_NETDEV |
7989 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307990 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307991 },
7992
7993 {
7994 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7995 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7996 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7997 WIPHY_VENDOR_CMD_NEED_NETDEV |
7998 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307999 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05308000 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308001#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308002#ifdef WLAN_FEATURE_EXTSCAN
8003 {
8004 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8005 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
8006 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8007 WIPHY_VENDOR_CMD_NEED_NETDEV |
8008 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308009 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05308010 },
8011 {
8012 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8013 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
8014 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8015 WIPHY_VENDOR_CMD_NEED_NETDEV |
8016 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308017 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05308018 },
8019 {
8020 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8021 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
8022 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8023 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308024 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05308025 },
8026 {
8027 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8028 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
8029 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8030 WIPHY_VENDOR_CMD_NEED_NETDEV |
8031 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308032 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05308033 },
8034 {
8035 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8036 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
8037 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8038 WIPHY_VENDOR_CMD_NEED_NETDEV |
8039 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308040 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05308041 },
8042 {
8043 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8044 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
8045 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8046 WIPHY_VENDOR_CMD_NEED_NETDEV |
8047 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308048 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308049 },
8050 {
8051 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8052 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
8053 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8054 WIPHY_VENDOR_CMD_NEED_NETDEV |
8055 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308056 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05308057 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05308058 {
8059 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8060 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
8061 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8062 WIPHY_VENDOR_CMD_NEED_NETDEV |
8063 WIPHY_VENDOR_CMD_NEED_RUNNING,
8064 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
8065 },
8066 {
8067 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8068 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
8069 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8070 WIPHY_VENDOR_CMD_NEED_NETDEV |
8071 WIPHY_VENDOR_CMD_NEED_RUNNING,
8072 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
8073 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308074#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308075/*EXT TDLS*/
8076 {
8077 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8078 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
8079 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8080 WIPHY_VENDOR_CMD_NEED_NETDEV |
8081 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308082 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05308083 },
8084 {
8085 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8086 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
8087 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8088 WIPHY_VENDOR_CMD_NEED_NETDEV |
8089 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308090 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05308091 },
8092 {
8093 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8094 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
8095 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8096 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308097 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05308098 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05308099 {
8100 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8101 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
8102 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8103 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308104 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05308105 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05308106 {
8107 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8108 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
8109 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8110 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308111 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05308112 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308113 {
8114 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8115 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
8116 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8117 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308118 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05308119 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308120 {
8121 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8122 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
8123 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8124 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05308125 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05308126 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308127 {
8128 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05308129 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
8130 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8131 WIPHY_VENDOR_CMD_NEED_NETDEV |
8132 WIPHY_VENDOR_CMD_NEED_RUNNING,
8133 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
8134 },
8135 {
8136 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05308137 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
8138 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8139 WIPHY_VENDOR_CMD_NEED_NETDEV |
8140 WIPHY_VENDOR_CMD_NEED_RUNNING,
8141 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05308142 },
8143 {
8144 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8145 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
8146 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8147 WIPHY_VENDOR_CMD_NEED_NETDEV,
8148 .doit = wlan_hdd_cfg80211_wifi_logger_start
8149 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05308150 {
8151 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8152 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
8153 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8154 WIPHY_VENDOR_CMD_NEED_NETDEV|
8155 WIPHY_VENDOR_CMD_NEED_RUNNING,
8156 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05308157 },
8158 {
8159 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8160 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
8161 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8162 WIPHY_VENDOR_CMD_NEED_NETDEV |
8163 WIPHY_VENDOR_CMD_NEED_RUNNING,
8164 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308165 },
8166 {
8167 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8168 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
8169 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8170 WIPHY_VENDOR_CMD_NEED_NETDEV |
8171 WIPHY_VENDOR_CMD_NEED_RUNNING,
8172 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308173 },
8174#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
8175 {
8176 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8177 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
8178 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8179 WIPHY_VENDOR_CMD_NEED_NETDEV |
8180 WIPHY_VENDOR_CMD_NEED_RUNNING,
8181 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308182 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05308183#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308184 {
8185 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8186 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
8187 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8188 WIPHY_VENDOR_CMD_NEED_NETDEV |
8189 WIPHY_VENDOR_CMD_NEED_RUNNING,
8190 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05308191 },
8192 {
8193 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8194 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
8195 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8196 WIPHY_VENDOR_CMD_NEED_NETDEV |
8197 WIPHY_VENDOR_CMD_NEED_RUNNING,
8198 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Kapil Guptaee33bf12016-12-20 18:27:37 +05308199 },
8200#ifdef WLAN_FEATURE_APFIND
8201 {
8202 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8203 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND,
8204 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8205 WIPHY_VENDOR_CMD_NEED_NETDEV,
8206 .doit = wlan_hdd_cfg80211_apfind_cmd
8207 },
8208#endif /* WLAN_FEATURE_APFIND */
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308209 {
8210 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8211 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET,
8212 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8213 WIPHY_VENDOR_CMD_NEED_NETDEV |
8214 WIPHY_VENDOR_CMD_NEED_RUNNING,
8215 .doit = wlan_hdd_cfg80211_set_nud_stats
8216 },
8217 {
8218 .info.vendor_id = QCA_NL80211_VENDOR_ID,
8219 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8220 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
8221 WIPHY_VENDOR_CMD_NEED_NETDEV |
8222 WIPHY_VENDOR_CMD_NEED_RUNNING,
8223 .doit = wlan_hdd_cfg80211_get_nud_stats
8224 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308225};
8226
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008227/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05308228static const
8229struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008230{
8231#ifdef FEATURE_WLAN_CH_AVOID
8232 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05308233 .vendor_id = QCA_NL80211_VENDOR_ID,
8234 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008235 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05308236#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
8237#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8238 {
8239 /* Index = 1*/
8240 .vendor_id = QCA_NL80211_VENDOR_ID,
8241 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
8242 },
8243 {
8244 /* Index = 2*/
8245 .vendor_id = QCA_NL80211_VENDOR_ID,
8246 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
8247 },
8248 {
8249 /* Index = 3*/
8250 .vendor_id = QCA_NL80211_VENDOR_ID,
8251 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
8252 },
8253 {
8254 /* Index = 4*/
8255 .vendor_id = QCA_NL80211_VENDOR_ID,
8256 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
8257 },
8258 {
8259 /* Index = 5*/
8260 .vendor_id = QCA_NL80211_VENDOR_ID,
8261 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
8262 },
8263 {
8264 /* Index = 6*/
8265 .vendor_id = QCA_NL80211_VENDOR_ID,
8266 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
8267 },
8268#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05308269#ifdef WLAN_FEATURE_EXTSCAN
8270 {
8271 .vendor_id = QCA_NL80211_VENDOR_ID,
8272 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
8273 },
8274 {
8275 .vendor_id = QCA_NL80211_VENDOR_ID,
8276 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
8277 },
8278 {
8279 .vendor_id = QCA_NL80211_VENDOR_ID,
8280 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
8281 },
8282 {
8283 .vendor_id = QCA_NL80211_VENDOR_ID,
8284 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
8285 },
8286 {
8287 .vendor_id = QCA_NL80211_VENDOR_ID,
8288 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
8289 },
8290 {
8291 .vendor_id = QCA_NL80211_VENDOR_ID,
8292 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
8293 },
8294 {
8295 .vendor_id = QCA_NL80211_VENDOR_ID,
8296 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
8297 },
8298 {
8299 .vendor_id = QCA_NL80211_VENDOR_ID,
8300 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
8301 },
8302 {
8303 .vendor_id = QCA_NL80211_VENDOR_ID,
8304 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
8305 },
8306 {
8307 .vendor_id = QCA_NL80211_VENDOR_ID,
8308 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
8309 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05308310 {
8311 .vendor_id = QCA_NL80211_VENDOR_ID,
8312 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
8313 },
8314 {
8315 .vendor_id = QCA_NL80211_VENDOR_ID,
8316 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
8317 },
8318 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
8319 .vendor_id = QCA_NL80211_VENDOR_ID,
8320 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
8321 },
8322 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
8323 .vendor_id = QCA_NL80211_VENDOR_ID,
8324 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
8325 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05308326#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05308327/*EXT TDLS*/
8328 {
8329 .vendor_id = QCA_NL80211_VENDOR_ID,
8330 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
8331 },
c_manjeecfd1efb2015-09-25 19:32:34 +05308332 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
8333 .vendor_id = QCA_NL80211_VENDOR_ID,
8334 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
8335 },
8336
Srinivas Dasari030bad32015-02-18 23:23:54 +05308337
Srinivas Dasaribd1cf642017-01-23 14:54:41 +05308338 [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = {
Srinivas Dasari030bad32015-02-18 23:23:54 +05308339 .vendor_id = QCA_NL80211_VENDOR_ID,
8340 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
8341 },
8342
Sushant Kaushik084f6592015-09-10 13:11:56 +05308343 {
8344 .vendor_id = QCA_NL80211_VENDOR_ID,
8345 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05308346 },
8347 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
8348 .vendor_id = QCA_NL80211_VENDOR_ID,
8349 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
8350 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05308351 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
8352 .vendor_id = QCA_NL80211_VENDOR_ID,
8353 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
8354 },
Anurag Chouhan6ee81542017-02-09 18:09:27 +05308355 [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = {
8356 .vendor_id = QCA_NL80211_VENDOR_ID,
8357 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET,
8358 },
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008359};
8360
Jeff Johnson295189b2012-06-20 16:38:30 -07008361/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308362 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308363 * This function is called by hdd_wlan_startup()
8364 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308365 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308367struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07008368{
8369 struct wiphy *wiphy;
8370 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308371 /*
8372 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 */
8374 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
8375
8376 if (!wiphy)
8377 {
8378 /* Print error and jump into err label and free the memory */
8379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
8380 return NULL;
8381 }
8382
Sunil Duttc69bccb2014-05-26 21:30:20 +05308383
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 return wiphy;
8385}
8386
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308387#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \
8388 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
8389/**
8390 * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy
8391 * @wiphy: pointer to wiphy
8392 * @config: pointer to config
8393 *
8394 * Return: None
8395 */
8396static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
8397 hdd_config_t *config)
8398{
8399 wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS;
8400 if (config->max_sched_scan_plan_interval)
8401 wiphy->max_sched_scan_plan_interval =
8402 config->max_sched_scan_plan_interval;
8403 if (config->max_sched_scan_plan_iterations)
8404 wiphy->max_sched_scan_plan_iterations =
8405 config->max_sched_scan_plan_iterations;
8406}
8407#else
8408static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
8409 hdd_config_t *config)
8410{
8411}
8412#endif
8413
Jeff Johnson295189b2012-06-20 16:38:30 -07008414/*
8415 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308416 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07008417 * private ioctl to change the band value
8418 */
8419int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
8420{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308421 int i, j;
8422 eNVChannelEnabledType channelEnabledState;
8423
Jeff Johnsone7245742012-09-05 17:12:55 -07008424 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308425
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308426 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308428
8429 if (NULL == wiphy->bands[i])
8430 {
8431 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
8432 __func__, i);
8433 continue;
8434 }
8435
8436 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8437 {
8438 struct ieee80211_supported_band *band = wiphy->bands[i];
8439
8440 channelEnabledState = vos_nv_getChannelEnabledState(
8441 band->channels[j].hw_value);
8442
8443 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
8444 {
Abhishek Singh678227a2014-11-04 10:52:38 +05308445 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308446 continue;
8447 }
8448 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
8449 {
8450 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8451 continue;
8452 }
8453
8454 if (NV_CHANNEL_DISABLE == channelEnabledState ||
8455 NV_CHANNEL_INVALID == channelEnabledState)
8456 {
8457 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8458 }
8459 else if (NV_CHANNEL_DFS == channelEnabledState)
8460 {
8461 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8462 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
8463 }
8464 else
8465 {
8466 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
8467 |IEEE80211_CHAN_RADAR);
8468 }
8469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 }
8471 return 0;
8472}
8473/*
8474 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308475 * This function is called by hdd_wlan_startup()
8476 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 * This function is used to initialize and register wiphy structure.
8478 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308479int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 struct wiphy *wiphy,
8481 hdd_config_t *pCfg
8482 )
8483{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308484 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05308485 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8486
Jeff Johnsone7245742012-09-05 17:12:55 -07008487 ENTER();
8488
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 /* Now bind the underlying wlan device with wiphy */
8490 set_wiphy_dev(wiphy, dev);
8491
8492 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07008493
Kiet Lam6c583332013-10-14 05:37:09 +05308494#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07008495 /* the flag for the other case would be initialzed in
8496 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05308497#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
8498 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
8499#else
Amar Singhal0a402232013-10-11 20:57:16 -07008500 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05308501#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05308502#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07008503
Amar Singhalfddc28c2013-09-05 13:03:40 -07008504 /* This will disable updating of NL channels from passive to
8505 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308506#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
8507 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
8508#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07008509 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308510#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07008511
Amar Singhala49cbc52013-10-08 18:37:44 -07008512
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008513#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07008514 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
8515 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
8516 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07008517 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308518#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05308519 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308520#else
8521 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
8522#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008523#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07008524
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008525#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008526 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08008527#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008528 || pCfg->isFastRoamIniFeatureEnabled
8529#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008530#ifdef FEATURE_WLAN_ESE
8531 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07008532#endif
8533 )
8534 {
8535 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
8536 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08008537#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008538#ifdef FEATURE_WLAN_TDLS
8539 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
8540 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
8541#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308542#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05308543 if (pCfg->configPNOScanSupport)
8544 {
8545 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
8546 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
8547 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
8548 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
8549 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308550#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008551
Abhishek Singh10d85972015-04-17 10:27:23 +05308552#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8553 wiphy->features |= NL80211_FEATURE_HT_IBSS;
8554#endif
8555
Amar Singhalfddc28c2013-09-05 13:03:40 -07008556#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008557 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
8558 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07008559 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008560 driver need to determine what to do with both
8561 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07008562
8563 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07008564#else
8565 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07008566#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008567
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308568 wiphy->max_scan_ssids = MAX_SCAN_SSID;
8569
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05308570 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07008571
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308572 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
8573
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05308575 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
8576 | BIT(NL80211_IFTYPE_ADHOC)
8577 | BIT(NL80211_IFTYPE_P2P_CLIENT)
8578 | BIT(NL80211_IFTYPE_P2P_GO)
8579 | BIT(NL80211_IFTYPE_AP);
8580
8581 if (VOS_MONITOR_MODE == hdd_get_conparam())
8582 {
8583 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
8584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008585
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308586 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008587 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8589 if( pCfg->enableMCC )
8590 {
8591 /* Currently, supports up to two channels */
8592 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008593
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308594 if( !pCfg->allowMCCGODiffBI )
8595 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008596
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308597 }
8598 wiphy->iface_combinations = &wlan_hdd_iface_combination;
8599 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008600#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308601 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008602
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 /* Before registering we need to update the ht capabilitied based
8604 * on ini values*/
8605 if( !pCfg->ShortGI20MhzEnable )
8606 {
8607 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8608 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 }
8610
8611 if( !pCfg->ShortGI40MhzEnable )
8612 {
8613 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8614 }
8615
8616 if( !pCfg->nChannelBondingMode5GHz )
8617 {
8618 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8619 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308620 /*
8621 * In case of static linked driver at the time of driver unload,
8622 * module exit doesn't happens. Module cleanup helps in cleaning
8623 * of static memory.
8624 * If driver load happens statically, at the time of driver unload,
8625 * wiphy flags don't get reset because of static memory.
8626 * It's better not to store channel in static memory.
8627 */
8628 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8629 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8630 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8631 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8632 {
8633 hddLog(VOS_TRACE_LEVEL_ERROR,
8634 FL("Not enough memory to allocate channels"));
8635 return -ENOMEM;
8636 }
8637 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8638 &hdd_channels_2_4_GHZ[0],
8639 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008640
Agrawal Ashish97dec502015-11-26 20:20:58 +05308641 if (true == hdd_is_5g_supported(pHddCtx))
8642 {
8643 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8644 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8645 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8646 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8647 {
8648 hddLog(VOS_TRACE_LEVEL_ERROR,
8649 FL("Not enough memory to allocate channels"));
8650 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8651 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8652 return -ENOMEM;
8653 }
8654 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8655 &hdd_channels_5_GHZ[0],
8656 sizeof(hdd_channels_5_GHZ));
8657 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308658
8659 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8660 {
8661
8662 if (NULL == wiphy->bands[i])
8663 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308664 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308665 __func__, i);
8666 continue;
8667 }
8668
8669 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8670 {
8671 struct ieee80211_supported_band *band = wiphy->bands[i];
8672
8673 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8674 {
8675 // Enable social channels for P2P
8676 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8677 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8678 else
8679 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8680 continue;
8681 }
8682 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8683 {
8684 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8685 continue;
8686 }
8687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 }
8689 /*Initialise the supported cipher suite details*/
8690 wiphy->cipher_suites = hdd_cipher_suites;
8691 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8692
8693 /*signal strength in mBm (100*dBm) */
8694 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8695
8696#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308697 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008698#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008699
Sunil Duttc69bccb2014-05-26 21:30:20 +05308700 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8701 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008702 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8703 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8704
Anurag Chouhan343af7e2016-12-16 13:11:19 +05308705 hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
8706
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308707 EXIT();
8708 return 0;
8709}
8710
8711/* In this function we are registering wiphy. */
8712int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8713{
8714 ENTER();
8715 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 if (0 > wiphy_register(wiphy))
8717 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308718 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8720 return -EIO;
8721 }
8722
8723 EXIT();
8724 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308725}
Jeff Johnson295189b2012-06-20 16:38:30 -07008726
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308727/* In this function we are updating channel list when,
8728 regulatory domain is FCC and country code is US.
8729 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8730 As per FCC smart phone is not a indoor device.
8731 GO should not opeate on indoor channels */
8732void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8733{
8734 int j;
8735 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8736 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8737 //Default counrtycode from NV at the time of wiphy initialization.
8738 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8739 &defaultCountryCode[0]))
8740 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008741 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308742 }
8743 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8744 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308745 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8746 {
8747 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8748 return;
8749 }
8750 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8751 {
8752 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8753 // Mark UNII -1 band channel as passive
8754 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8755 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8756 }
8757 }
8758}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308759/* This function registers for all frame which supplicant is interested in */
8760void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008761{
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8763 /* Register for all P2P action, public action etc frames */
8764 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008765 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308766 /* Register frame indication call back */
8767 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 /* Right now we are registering these frame when driver is getting
8769 initialized. Once we will move to 2.6.37 kernel, in which we have
8770 frame register ops, we will move this code as a part of that */
8771 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308772 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8774
8775 /* GAS Initial Response */
8776 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8777 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308778
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 /* GAS Comeback Request */
8780 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8781 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8782
8783 /* GAS Comeback Response */
8784 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8785 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8786
8787 /* P2P Public Action */
8788 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308789 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 P2P_PUBLIC_ACTION_FRAME_SIZE );
8791
8792 /* P2P Action */
8793 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8794 (v_U8_t*)P2P_ACTION_FRAME,
8795 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008796
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308797 /* WNM BSS Transition Request frame */
8798 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8799 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8800 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008801
8802 /* WNM-Notification */
8803 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8804 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8805 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008806}
8807
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308808void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008809{
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8811 /* Register for all P2P action, public action etc frames */
8812 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8813
Jeff Johnsone7245742012-09-05 17:12:55 -07008814 ENTER();
8815
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 /* Right now we are registering these frame when driver is getting
8817 initialized. Once we will move to 2.6.37 kernel, in which we have
8818 frame register ops, we will move this code as a part of that */
8819 /* GAS Initial Request */
8820
8821 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8822 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8823
8824 /* GAS Initial Response */
8825 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8826 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308827
Jeff Johnson295189b2012-06-20 16:38:30 -07008828 /* GAS Comeback Request */
8829 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8830 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8831
8832 /* GAS Comeback Response */
8833 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8834 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8835
8836 /* P2P Public Action */
8837 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308838 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 P2P_PUBLIC_ACTION_FRAME_SIZE );
8840
8841 /* P2P Action */
8842 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8843 (v_U8_t*)P2P_ACTION_FRAME,
8844 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008845 /* WNM-Notification */
8846 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8847 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8848 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008849}
8850
8851#ifdef FEATURE_WLAN_WAPI
8852void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308853 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008854{
8855 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8856 tCsrRoamSetKey setKey;
8857 v_BOOL_t isConnected = TRUE;
8858 int status = 0;
8859 v_U32_t roamId= 0xFF;
8860 tANI_U8 *pKeyPtr = NULL;
8861 int n = 0;
8862
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308863 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8864 __func__, hdd_device_modetoString(pAdapter->device_mode),
8865 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008866
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308867 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 setKey.keyId = key_index; // Store Key ID
8869 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8870 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8871 setKey.paeRole = 0 ; // the PAE role
8872 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8873 {
8874 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8875 }
8876 else
8877 {
8878 isConnected = hdd_connIsConnected(pHddStaCtx);
8879 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8880 }
8881 setKey.keyLength = key_Len;
8882 pKeyPtr = setKey.Key;
8883 memcpy( pKeyPtr, key, key_Len);
8884
Arif Hussain6d2a3322013-11-17 19:50:10 -08008885 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 __func__, key_Len);
8887 for (n = 0 ; n < key_Len; n++)
8888 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8889 __func__,n,setKey.Key[n]);
8890
8891 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8892 if ( isConnected )
8893 {
8894 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8895 pAdapter->sessionId, &setKey, &roamId );
8896 }
8897 if ( status != 0 )
8898 {
8899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8900 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8901 __LINE__, status );
8902 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8903 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308904 /* Need to clear any trace of key value in the memory.
8905 * Thus zero out the memory even though it is local
8906 * variable.
8907 */
8908 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008909}
8910#endif /* FEATURE_WLAN_WAPI*/
8911
8912#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308913int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 beacon_data_t **ppBeacon,
8915 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008916#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308917int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008918 beacon_data_t **ppBeacon,
8919 struct cfg80211_beacon_data *params,
8920 int dtim_period)
8921#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308922{
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 int size;
8924 beacon_data_t *beacon = NULL;
8925 beacon_data_t *old = NULL;
Kapil Gupta137ef892016-12-13 19:38:00 +05308926 int head_len, tail_len, proberesp_ies_len, assocresp_ies_len;
8927 const u8 *head, *tail, *proberesp_ies, *assocresp_ies;
Jeff Johnson295189b2012-06-20 16:38:30 -07008928
Jeff Johnsone7245742012-09-05 17:12:55 -07008929 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308931 {
8932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8933 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008936
8937 old = pAdapter->sessionCtx.ap.beacon;
8938
8939 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308940 {
8941 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8942 FL("session(%d) old and new heads points to NULL"),
8943 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308945 }
8946
8947 if (params->tail && !params->tail_len)
8948 {
8949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8950 FL("tail_len is zero but tail is not NULL"));
8951 return -EINVAL;
8952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008953
Jeff Johnson295189b2012-06-20 16:38:30 -07008954#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8955 /* Kernel 3.0 is not updating dtim_period for set beacon */
8956 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308957 {
8958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8959 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008960 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008962#endif
8963
Kapil Gupta137ef892016-12-13 19:38:00 +05308964 if (params->head)
8965 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 head_len = params->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308967 head = params->head;
8968 } else
8969 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 head_len = old->head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308971 head = old->head;
8972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008973
Kapil Gupta137ef892016-12-13 19:38:00 +05308974 if (params->tail || !old)
8975 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008976 tail_len = params->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308977 tail = params->tail;
8978 } else
8979 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 tail_len = old->tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05308981 tail = old->tail;
8982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008983
Kapil Gupta137ef892016-12-13 19:38:00 +05308984 if (params->proberesp_ies || !old)
8985 {
8986 proberesp_ies_len = params->proberesp_ies_len;
8987 proberesp_ies = params->proberesp_ies;
8988 } else
8989 {
8990 proberesp_ies_len = old->proberesp_ies_len;
8991 proberesp_ies = old->proberesp_ies;
8992 }
8993
8994 if (params->assocresp_ies || !old)
8995 {
8996 assocresp_ies_len = params->assocresp_ies_len;
8997 assocresp_ies = params->assocresp_ies;
8998 } else
8999 {
9000 assocresp_ies_len = old->assocresp_ies_len;
9001 assocresp_ies = old->assocresp_ies;
9002 }
9003
9004 size = sizeof(beacon_data_t) + head_len + tail_len +
9005 proberesp_ies_len + assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009006
9007 beacon = kzalloc(size, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309009 {
9010 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9011 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009012 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009014
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009015#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Kapil Gupta137ef892016-12-13 19:38:00 +05309016 if (params->dtim_period)
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 beacon->dtim_period = params->dtim_period;
9018 else
9019 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009020#else
Kapil Gupta137ef892016-12-13 19:38:00 +05309021 if (dtim_period)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009022 beacon->dtim_period = dtim_period;
9023 else
9024 beacon->dtim_period = old->dtim_period;
9025#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309026
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
9028 beacon->tail = beacon->head + head_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309029 beacon->proberesp_ies = beacon->tail + tail_len;
9030 beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len;
9031
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 beacon->head_len = head_len;
9033 beacon->tail_len = tail_len;
Kapil Gupta137ef892016-12-13 19:38:00 +05309034 beacon->proberesp_ies_len = proberesp_ies_len;
9035 beacon->assocresp_ies_len= assocresp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009036
c_manjee527ecac2017-01-25 12:25:27 +05309037 if (head && head_len)
9038 memcpy(beacon->head, head, head_len);
9039 if (tail && tail_len)
9040 memcpy(beacon->tail, tail, tail_len);
9041 if (proberesp_ies && proberesp_ies_len)
9042 memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len);
9043 if (assocresp_ies && assocresp_ies_len)
9044 memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009045
9046 *ppBeacon = beacon;
9047
9048 kfree(old);
9049
9050 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009051}
Jeff Johnson295189b2012-06-20 16:38:30 -07009052
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309053v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
9054#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
9055 const v_U8_t *pIes,
9056#else
9057 v_U8_t *pIes,
9058#endif
9059 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009060{
9061 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309062 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309064
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309066 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 elem_id = ptr[0];
9068 elem_len = ptr[1];
9069 left -= 2;
9070 if(elem_len > left)
9071 {
9072 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009073 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 eid,elem_len,left);
9075 return NULL;
9076 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309077 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 {
9079 return ptr;
9080 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309081
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 left -= elem_len;
9083 ptr += (elem_len + 2);
9084 }
9085 return NULL;
9086}
9087
Jeff Johnson295189b2012-06-20 16:38:30 -07009088/* Check if rate is 11g rate or not */
9089static int wlan_hdd_rate_is_11g(u8 rate)
9090{
Sanjay Devnani28322e22013-06-21 16:13:40 -07009091 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 u8 i;
9093 for (i = 0; i < 8; i++)
9094 {
9095 if(rate == gRateArray[i])
9096 return TRUE;
9097 }
9098 return FALSE;
9099}
9100
9101/* Check for 11g rate and set proper 11g only mode */
9102static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
9103 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
9104{
9105 u8 i, num_rates = pIe[0];
9106
9107 pIe += 1;
9108 for ( i = 0; i < num_rates; i++)
9109 {
9110 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
9111 {
9112 /* If rate set have 11g rate than change the mode to 11G */
9113 *pSapHw_mode = eSAP_DOT11_MODE_11g;
9114 if (pIe[i] & BASIC_RATE_MASK)
9115 {
9116 /* If we have 11g rate as basic rate, it means mode
9117 is 11g only mode.
9118 */
9119 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
9120 *pCheckRatesfor11g = FALSE;
9121 }
9122 }
9123 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
9124 {
9125 *require_ht = TRUE;
9126 }
9127 }
9128 return;
9129}
9130
9131static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
9132{
9133 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9134 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9135 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9136 u8 checkRatesfor11g = TRUE;
9137 u8 require_ht = FALSE;
9138 u8 *pIe=NULL;
9139
9140 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
9141
9142 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
9143 pBeacon->head_len, WLAN_EID_SUPP_RATES);
9144 if (pIe != NULL)
9145 {
9146 pIe += 1;
9147 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9148 &pConfig->SapHw_mode);
9149 }
9150
9151 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9152 WLAN_EID_EXT_SUPP_RATES);
9153 if (pIe != NULL)
9154 {
9155
9156 pIe += 1;
9157 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
9158 &pConfig->SapHw_mode);
9159 }
9160
9161 if( pConfig->channel > 14 )
9162 {
9163 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
9164 }
9165
9166 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
9167 WLAN_EID_HT_CAPABILITY);
9168
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309169 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 {
9171 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
9172 if(require_ht)
9173 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
9174 }
9175}
9176
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309177static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
9178 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
9179{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009180 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309181 v_U8_t *pIe = NULL;
9182 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9183
9184 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
9185 pBeacon->tail, pBeacon->tail_len);
9186
9187 if (pIe)
9188 {
9189 ielen = pIe[1] + 2;
9190 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9191 {
9192 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
9193 }
9194 else
9195 {
9196 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
9197 return -EINVAL;
9198 }
9199 *total_ielen += ielen;
9200 }
9201 return 0;
9202}
9203
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009204static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
9205 v_U8_t *genie, v_U8_t *total_ielen)
9206{
9207 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9208 int left = pBeacon->tail_len;
9209 v_U8_t *ptr = pBeacon->tail;
9210 v_U8_t elem_id, elem_len;
9211 v_U16_t ielen = 0;
9212
9213 if ( NULL == ptr || 0 == left )
9214 return;
9215
9216 while (left >= 2)
9217 {
9218 elem_id = ptr[0];
9219 elem_len = ptr[1];
9220 left -= 2;
9221 if (elem_len > left)
9222 {
9223 hddLog( VOS_TRACE_LEVEL_ERROR,
9224 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
9225 elem_id, elem_len, left);
9226 return;
9227 }
9228 if (IE_EID_VENDOR == elem_id)
9229 {
9230 /* skipping the VSIE's which we don't want to include or
9231 * it will be included by existing code
9232 */
9233 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
9234#ifdef WLAN_FEATURE_WFD
9235 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
9236#endif
9237 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9238 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9239 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
9240 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
9241 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
9242 {
9243 ielen = ptr[1] + 2;
9244 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
9245 {
9246 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
9247 *total_ielen += ielen;
9248 }
9249 else
9250 {
9251 hddLog( VOS_TRACE_LEVEL_ERROR,
9252 "IE Length is too big "
9253 "IEs eid=%d elem_len=%d total_ie_lent=%d",
9254 elem_id, elem_len, *total_ielen);
9255 }
9256 }
9257 }
9258
9259 left -= elem_len;
9260 ptr += (elem_len + 2);
9261 }
9262 return;
9263}
9264
Kapil Gupta137ef892016-12-13 19:38:00 +05309265int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009266{
9267 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309268 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07009270 int ret = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +05309271 beacon_data_t *pBeacon = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009272
9273 genie = vos_mem_malloc(MAX_GENIE_LEN);
9274
9275 if(genie == NULL) {
9276
9277 return -ENOMEM;
9278 }
9279
Kapil Gupta137ef892016-12-13 19:38:00 +05309280 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309281 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9282 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309284 hddLog(LOGE,
9285 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309286 ret = -EINVAL;
9287 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 }
9289
9290#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309291 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9292 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
9293 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309294 hddLog(LOGE,
9295 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309296 ret = -EINVAL;
9297 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 }
9299#endif
9300
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309301 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
9302 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009303 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309304 hddLog(LOGE,
9305 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309306 ret = -EINVAL;
9307 goto done;
9308 }
9309
9310 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
9311 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07009312 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009314
9315 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9316 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
9317 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
9318 {
9319 hddLog(LOGE,
9320 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009321 ret = -EINVAL;
9322 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 }
9324
9325 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9326 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
9327 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9328 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9329 ==eHAL_STATUS_FAILURE)
9330 {
9331 hddLog(LOGE,
9332 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009333 ret = -EINVAL;
9334 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 }
9336
9337 // Added for ProResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05309338 if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 {
Kapil Gupta137ef892016-12-13 19:38:00 +05309340 u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len;
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 u8 probe_rsp_ie_len[3] = {0};
9342 u8 counter = 0;
9343 /* Check Probe Resp Length if it is greater then 255 then Store
9344 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
9345 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
9346 Store More then 255 bytes into One Variable.
9347 */
9348 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
9349 {
9350 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
9351 {
9352 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
9353 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
9354 }
9355 else
9356 {
9357 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
9358 rem_probe_resp_ie_len = 0;
9359 }
9360 }
9361
9362 rem_probe_resp_ie_len = 0;
9363
9364 if (probe_rsp_ie_len[0] > 0)
9365 {
9366 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9367 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
Kapil Gupta137ef892016-12-13 19:38:00 +05309368 (tANI_U8*)&pBeacon->
9369 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 probe_rsp_ie_len[0], NULL,
9371 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9372 {
9373 hddLog(LOGE,
9374 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009375 ret = -EINVAL;
9376 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 }
9378 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
9379 }
9380
9381 if (probe_rsp_ie_len[1] > 0)
9382 {
9383 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9384 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
Kapil Gupta137ef892016-12-13 19:38:00 +05309385 (tANI_U8*)&pBeacon->
9386 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 probe_rsp_ie_len[1], NULL,
9388 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9389 {
9390 hddLog(LOGE,
9391 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009392 ret = -EINVAL;
9393 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 }
9395 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
9396 }
9397
9398 if (probe_rsp_ie_len[2] > 0)
9399 {
9400 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9401 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
Kapil Gupta137ef892016-12-13 19:38:00 +05309402 (tANI_U8*)&pBeacon->
9403 proberesp_ies[rem_probe_resp_ie_len],
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 probe_rsp_ie_len[2], NULL,
9405 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9406 {
9407 hddLog(LOGE,
9408 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009409 ret = -EINVAL;
9410 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009411 }
9412 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
9413 }
9414
9415 if (probe_rsp_ie_len[1] == 0 )
9416 {
9417 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9418 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
9419 eANI_BOOLEAN_FALSE) )
9420 {
9421 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009422 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 }
9424 }
9425
9426 if (probe_rsp_ie_len[2] == 0 )
9427 {
9428 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9429 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
9430 eANI_BOOLEAN_FALSE) )
9431 {
9432 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009433 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 }
9435 }
9436
9437 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9438 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
9439 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9440 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9441 == eHAL_STATUS_FAILURE)
9442 {
9443 hddLog(LOGE,
9444 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009445 ret = -EINVAL;
9446 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 }
9448 }
9449 else
9450 {
9451 // Reset WNI_CFG_PROBE_RSP Flags
9452 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
9453
9454 hddLog(VOS_TRACE_LEVEL_INFO,
9455 "%s: No Probe Response IE received in set beacon",
9456 __func__);
9457 }
9458
9459 // Added for AssocResp IE
Kapil Gupta137ef892016-12-13 19:38:00 +05309460 if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 {
9462 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
Kapil Gupta137ef892016-12-13 19:38:00 +05309463 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies,
9464 pBeacon->assocresp_ies_len, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9466 {
9467 hddLog(LOGE,
9468 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009469 ret = -EINVAL;
9470 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009471 }
9472
9473 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9474 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
9475 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
9476 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
9477 == eHAL_STATUS_FAILURE)
9478 {
9479 hddLog(LOGE,
9480 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07009481 ret = -EINVAL;
9482 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 }
9484 }
9485 else
9486 {
9487 hddLog(VOS_TRACE_LEVEL_INFO,
9488 "%s: No Assoc Response IE received in set beacon",
9489 __func__);
9490
9491 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
9492 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9493 eANI_BOOLEAN_FALSE) )
9494 {
9495 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009496 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 }
9498 }
9499
Jeff Johnsone7245742012-09-05 17:12:55 -07009500done:
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05309502 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009503}
Jeff Johnson295189b2012-06-20 16:38:30 -07009504
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309505/*
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 * FUNCTION: wlan_hdd_validate_operation_channel
9507 * called by wlan_hdd_cfg80211_start_bss() and
9508 * wlan_hdd_cfg80211_set_channel()
9509 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309510 * channel list.
9511 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07009512VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009513{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309514
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 v_U32_t num_ch = 0;
9516 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
9517 u32 indx = 0;
9518 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309519 v_U8_t fValidChannel = FALSE, count = 0;
9520 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309521
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9523
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309524 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309526 /* Validate the channel */
9527 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309529 if ( channel == rfChannels[count].channelNum )
9530 {
9531 fValidChannel = TRUE;
9532 break;
9533 }
9534 }
9535 if (fValidChannel != TRUE)
9536 {
9537 hddLog(VOS_TRACE_LEVEL_ERROR,
9538 "%s: Invalid Channel [%d]", __func__, channel);
9539 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 }
9541 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309542 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05309544 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
9545 valid_ch, &num_ch))
9546 {
9547 hddLog(VOS_TRACE_LEVEL_ERROR,
9548 "%s: failed to get valid channel list", __func__);
9549 return VOS_STATUS_E_FAILURE;
9550 }
9551 for (indx = 0; indx < num_ch; indx++)
9552 {
9553 if (channel == valid_ch[indx])
9554 {
9555 break;
9556 }
9557 }
9558
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309559 if (indx >= num_ch)
9560 {
9561 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9562 {
9563 eCsrBand band;
9564 unsigned int freq;
9565
9566 sme_GetFreqBand(hHal, &band);
9567
9568 if (eCSR_BAND_5G == band)
9569 {
9570#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9571 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9572 {
9573 freq = ieee80211_channel_to_frequency(channel,
9574 IEEE80211_BAND_2GHZ);
9575 }
9576 else
9577 {
9578 freq = ieee80211_channel_to_frequency(channel,
9579 IEEE80211_BAND_5GHZ);
9580 }
9581#else
9582 freq = ieee80211_channel_to_frequency(channel);
9583#endif
9584 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
9585 return VOS_STATUS_SUCCESS;
9586 }
9587 }
9588
9589 hddLog(VOS_TRACE_LEVEL_ERROR,
9590 "%s: Invalid Channel [%d]", __func__, channel);
9591 return VOS_STATUS_E_FAILURE;
9592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309594
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309596
Jeff Johnson295189b2012-06-20 16:38:30 -07009597}
9598
Viral Modi3a32cc52013-02-08 11:14:52 -08009599/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309600 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08009601 * This function is used to set the channel number
9602 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309603static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08009604 struct ieee80211_channel *chan,
9605 enum nl80211_channel_type channel_type
9606 )
9607{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309608 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08009609 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07009610 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08009611 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309612 hdd_context_t *pHddCtx;
9613 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009614
9615 ENTER();
9616
9617 if( NULL == dev )
9618 {
9619 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009620 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009621 return -ENODEV;
9622 }
9623 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309624
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309625 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9626 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9627 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009628 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309629 "%s: device_mode = %s (%d) freq = %d", __func__,
9630 hdd_device_modetoString(pAdapter->device_mode),
9631 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309632
9633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9634 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309635 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009636 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309637 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009638 }
9639
9640 /*
9641 * Do freq to chan conversion
9642 * TODO: for 11a
9643 */
9644
9645 channel = ieee80211_frequency_to_channel(freq);
9646
9647 /* Check freq range */
9648 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9649 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9650 {
9651 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009652 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009653 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9654 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9655 return -EINVAL;
9656 }
9657
9658 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9659
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309660 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9661 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009662 {
9663 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9664 {
9665 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009666 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009667 return -EINVAL;
9668 }
9669 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9670 "%s: set channel to [%d] for device mode =%d",
9671 __func__, channel,pAdapter->device_mode);
9672 }
9673 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009674 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009675 )
9676 {
9677 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9678 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9679 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9680
9681 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9682 {
9683 /* Link is up then return cant set channel*/
9684 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009685 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009686 return -EINVAL;
9687 }
9688
9689 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9690 pHddStaCtx->conn_info.operationChannel = channel;
9691 pRoamProfile->ChannelInfo.ChannelList =
9692 &pHddStaCtx->conn_info.operationChannel;
9693 }
9694 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009695 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009696 )
9697 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309698 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9699 {
9700 if(VOS_STATUS_SUCCESS !=
9701 wlan_hdd_validate_operation_channel(pAdapter,channel))
9702 {
9703 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009704 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309705 return -EINVAL;
9706 }
9707 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9708 }
9709 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009710 {
9711 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9712
9713 /* If auto channel selection is configured as enable/ 1 then ignore
9714 channel set by supplicant
9715 */
9716 if ( cfg_param->apAutoChannelSelection )
9717 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309718 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9719 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009720 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309721 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9722 __func__, hdd_device_modetoString(pAdapter->device_mode),
9723 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009724 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309725 else
9726 {
9727 if(VOS_STATUS_SUCCESS !=
9728 wlan_hdd_validate_operation_channel(pAdapter,channel))
9729 {
9730 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009731 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309732 return -EINVAL;
9733 }
9734 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9735 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009736 }
9737 }
9738 else
9739 {
9740 hddLog(VOS_TRACE_LEVEL_FATAL,
9741 "%s: Invalid device mode failed to set valid channel", __func__);
9742 return -EINVAL;
9743 }
9744 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309745 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009746}
9747
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309748static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9749 struct net_device *dev,
9750 struct ieee80211_channel *chan,
9751 enum nl80211_channel_type channel_type
9752 )
9753{
9754 int ret;
9755
9756 vos_ssr_protect(__func__);
9757 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9758 vos_ssr_unprotect(__func__);
9759
9760 return ret;
9761}
9762
Anurag Chouhan83026002016-12-13 22:46:21 +05309763#ifdef DHCP_SERVER_OFFLOAD
9764void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context,
9765 VOS_STATUS status)
9766{
9767 hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context;
9768
9769 ENTER();
9770
9771 if (NULL == adapter)
9772 {
9773 hddLog(VOS_TRACE_LEVEL_ERROR,
9774 "%s: adapter is NULL",__func__);
9775 return;
9776 }
9777
9778 adapter->dhcp_status.dhcp_offload_status = status;
9779 vos_event_set(&adapter->dhcp_status.vos_event);
9780 return;
9781}
9782
9783/**
9784 * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload
9785 * @hostapd_adapter: pointer to hostapd adapter.
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309786 * @re_init: flag set if api called post ssr
Anurag Chouhan83026002016-12-13 22:46:21 +05309787 *
9788 * Return: None
9789 */
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309790VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter,
9791 bool re_init)
Anurag Chouhan83026002016-12-13 22:46:21 +05309792{
9793 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter);
9794 sir_dhcp_srv_offload_info dhcp_srv_info;
9795 tANI_U8 num_entries = 0;
9796 tANI_U8 srv_ip[IPADDR_NUM_ENTRIES];
9797 tANI_U8 num;
9798 tANI_U32 temp;
9799 VOS_STATUS ret;
9800
9801 ENTER();
9802
Anurag Chouhan638f5e22017-03-06 12:28:43 +05309803 if (!re_init) {
9804 ret = wlan_hdd_validate_context(hdd_ctx);
9805 if (0 != ret)
9806 return VOS_STATUS_E_INVAL;
9807 }
Anurag Chouhan83026002016-12-13 22:46:21 +05309808
9809 /* Prepare the request to send to SME */
9810 dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info));
9811 if (NULL == dhcp_srv_info) {
9812 hddLog(VOS_TRACE_LEVEL_ERROR,
9813 "%s: could not allocate tDhcpSrvOffloadInfo!", __func__);
9814 return VOS_STATUS_E_NOMEM;
9815 }
9816
9817 vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info));
9818
9819 dhcp_srv_info->bssidx = hostapd_adapter->sessionId;
9820 dhcp_srv_info->dhcp_srv_offload_enabled = TRUE;
9821 dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients;
9822 dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb;
9823 dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done;
9824 dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter;
9825
9826 hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip,
9827 srv_ip,
9828 &num_entries,
Anurag Chouhanac145c22016-11-22 16:51:47 +05309829 IPADDR_NUM_ENTRIES, ".");
Anurag Chouhan83026002016-12-13 22:46:21 +05309830 if (num_entries != IPADDR_NUM_ENTRIES) {
9831 hddLog(VOS_TRACE_LEVEL_ERROR,
9832 "%s: incorrect IP address (%s) assigned for DHCP server!",
9833 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9834 vos_mem_free(dhcp_srv_info);
9835 return VOS_STATUS_E_FAILURE;
9836 }
9837
9838 if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) {
9839 hddLog(VOS_TRACE_LEVEL_ERROR,
9840 "%s: invalid IP address (%s)! It could NOT be multicast IP address!",
9841 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9842 vos_mem_free(dhcp_srv_info);
9843 return VOS_STATUS_E_FAILURE;
9844 }
9845
9846 if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) {
9847 hddLog(VOS_TRACE_LEVEL_ERROR,
9848 "%s: invalid IP address (%s)! The last field must be less than 100!",
9849 __func__, hdd_ctx->cfg_ini->dhcp_srv_ip);
9850 vos_mem_free(dhcp_srv_info);
9851 return VOS_STATUS_E_FAILURE;
9852 }
9853
9854 for (num = 0; num < num_entries; num++) {
9855 temp = srv_ip[num];
9856 dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num));
9857 }
9858
9859 if (eHAL_STATUS_SUCCESS !=
9860 sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) {
9861 hddLog(VOS_TRACE_LEVEL_ERROR,
9862 "%s: sme_set_dhcp_srv_offload fail!", __func__);
9863 vos_mem_free(dhcp_srv_info);
9864 return VOS_STATUS_E_FAILURE;
9865 }
9866
9867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9868 "%s: enable DHCP Server offload successfully!", __func__);
9869
9870 vos_mem_free(dhcp_srv_info);
9871 return 0;
9872}
9873#endif /* DHCP_SERVER_OFFLOAD */
9874
Jeff Johnson295189b2012-06-20 16:38:30 -07009875#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9876static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9877 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009878#else
9879static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9880 struct cfg80211_beacon_data *params,
9881 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309882 enum nl80211_hidden_ssid hidden_ssid,
9883 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009885{
9886 tsap_Config_t *pConfig;
9887 beacon_data_t *pBeacon = NULL;
9888 struct ieee80211_mgmt *pMgmt_frame;
9889 v_U8_t *pIe=NULL;
9890 v_U16_t capab_info;
9891 eCsrAuthType RSNAuthType;
9892 eCsrEncryptionType RSNEncryptType;
9893 eCsrEncryptionType mcRSNEncryptType;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +05309894 int status = VOS_STATUS_SUCCESS, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009895 tpWLAN_SAPEventCB pSapEventCallback;
9896 hdd_hostapd_state_t *pHostapdState;
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309898 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309900 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009901 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009902 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309903 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009904 v_BOOL_t MFPCapable = VOS_FALSE;
9905 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309906 v_BOOL_t sapEnable11AC =
9907 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Kapil Gupta137ef892016-12-13 19:38:00 +05309908 u_int16_t prev_rsn_length = 0;
9909
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 ENTER();
9911
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309912 iniConfig = pHddCtx->cfg_ini;
9913
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9915
9916 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9917
9918 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9919
9920 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9921
9922 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9923
9924 //channel is already set in the set_channel Call back
9925 //pConfig->channel = pCommitConfig->channel;
9926
9927 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309928 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9930
9931 pConfig->dtim_period = pBeacon->dtim_period;
9932
Arif Hussain6d2a3322013-11-17 19:50:10 -08009933 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 pConfig->dtim_period);
9935
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009936 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009937 {
9938 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309940 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9941 {
9942 tANI_BOOLEAN restartNeeded;
9943 pConfig->ieee80211d = 1;
9944 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9945 sme_setRegInfo(hHal, pConfig->countryCode);
9946 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9947 }
9948 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009950 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009951 pConfig->ieee80211d = 1;
9952 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9953 sme_setRegInfo(hHal, pConfig->countryCode);
9954 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009956 else
9957 {
9958 pConfig->ieee80211d = 0;
9959 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309960 /*
9961 * If auto channel is configured i.e. channel is 0,
9962 * so skip channel validation.
9963 */
9964 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9965 {
9966 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9967 {
9968 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009969 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309970 return -EINVAL;
9971 }
9972 }
9973 else
9974 {
9975 if(1 != pHddCtx->is_dynamic_channel_range_set)
9976 {
9977 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9978 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9979 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9980 }
9981 pHddCtx->is_dynamic_channel_range_set = 0;
9982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009984 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 {
9986 pConfig->ieee80211d = 0;
9987 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309988
9989#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9990 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9991 pConfig->authType = eSAP_OPEN_SYSTEM;
9992 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9993 pConfig->authType = eSAP_SHARED_KEY;
9994 else
9995 pConfig->authType = eSAP_AUTO_SWITCH;
9996#else
9997 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9998 pConfig->authType = eSAP_OPEN_SYSTEM;
9999 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
10000 pConfig->authType = eSAP_SHARED_KEY;
10001 else
10002 pConfig->authType = eSAP_AUTO_SWITCH;
10003#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010004
10005 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010006
10007 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010009#ifdef SAP_AUTH_OFFLOAD
10010 /* In case of sap offload, hostapd.conf is configuted with open mode and
10011 * security is configured from ini file. Due to open mode in hostapd.conf
10012 * privacy bit is set to false which will result in not sending,
10013 * data packets as encrypted.
10014 * If enable_sap_auth_offload is enabled in ini and
10015 * sap_auth_offload_sec_type is type of WPA2-PSK,
10016 * driver will set privacy bit to 1.
10017 */
10018 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
10019 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
10020 pConfig->privacy = VOS_TRUE;
10021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010022
10023 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
10024
10025 /*Set wps station to configured*/
10026 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
10027
10028 if(pIe)
10029 {
10030 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
10031 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010032 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 return -EINVAL;
10034 }
10035 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
10036 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070010037 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 /* Check 15 bit of WPS IE as it contain information for wps state
10039 * WPS state
10040 */
10041 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
10042 {
10043 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
10044 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
10045 {
10046 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
10047 }
10048 }
10049 }
10050 else
10051 {
10052 pConfig->wps_state = SAP_WPS_DISABLED;
10053 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010054 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -070010055
c_hpothufe599e92014-06-16 11:38:55 +053010056 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
10057 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
10058 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
10059 eCSR_ENCRYPT_TYPE_NONE;
10060
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 pConfig->RSNWPAReqIELength = 0;
Kapil Gupta137ef892016-12-13 19:38:00 +053010062 memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010063 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 WLAN_EID_RSN);
10065 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010066 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053010068 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
10069 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
10070 pConfig->RSNWPAReqIELength);
10071 else
10072 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
10073 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010074 /* The actual processing may eventually be more extensive than
10075 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 * by the app.
10077 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010078 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
10080 &RSNEncryptType,
10081 &mcRSNEncryptType,
10082 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080010083 &MFPCapable,
10084 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053010085 pConfig->RSNWPAReqIE[1]+2,
10086 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010087
10088 if( VOS_STATUS_SUCCESS == status )
10089 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010090 /* Now copy over all the security attributes you have
10091 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 * */
10093 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
10094 pConfig->mcRSNEncryptType = mcRSNEncryptType;
10095 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
10096 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010097 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010098 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
10100 }
10101 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010102
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
10104 pBeacon->tail, pBeacon->tail_len);
10105
10106 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
10107 {
Kapil Gupta137ef892016-12-13 19:38:00 +053010108 if (pConfig->RSNWPAReqIE[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 {
10110 /*Mixed mode WPA/WPA2*/
Kapil Gupta137ef892016-12-13 19:38:00 +053010111 prev_rsn_length = pConfig->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 pConfig->RSNWPAReqIELength += pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053010113 if (pConfig->RSNWPAReqIELength <=
10114 (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length))
10115 memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe,
10116 pIe[1] + 2);
10117 else
10118 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
10119 pConfig->RSNWPAReqIELength);
10120
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 }
10122 else
10123 {
10124 pConfig->RSNWPAReqIELength = pIe[1] + 2;
Kapil Gupta137ef892016-12-13 19:38:00 +053010125 if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE))
10126 memcpy(&pConfig->RSNWPAReqIE[0], pIe,
10127 pConfig->RSNWPAReqIELength);
10128 else
10129 hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d",
10130 pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010131 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
10133 &RSNEncryptType,
10134 &mcRSNEncryptType,
10135 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -080010136 &MFPCapable,
10137 &MFPRequired,
Kapil Gupta137ef892016-12-13 19:38:00 +053010138 pConfig->RSNWPAReqIE[1]+2,
10139 pConfig->RSNWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010140
10141 if( VOS_STATUS_SUCCESS == status )
10142 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010143 /* Now copy over all the security attributes you have
10144 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 * */
10146 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
10147 pConfig->mcRSNEncryptType = mcRSNEncryptType;
10148 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
10149 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010150 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010151 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010152 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
10153 }
10154 }
10155 }
10156
Kapil Gupta137ef892016-12-13 19:38:00 +053010157 if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) {
Jeff Johnson4416a782013-03-25 14:17:50 -070010158 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
10159 return -EINVAL;
10160 }
10161
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
10163
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010164#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 if (params->ssid != NULL)
10166 {
10167 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
10168 pConfig->SSIDinfo.ssid.length = params->ssid_len;
10169 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
10170 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
10171 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010172#else
10173 if (ssid != NULL)
10174 {
10175 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
10176 pConfig->SSIDinfo.ssid.length = ssid_len;
10177 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
10178 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
10179 }
10180#endif
10181
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010182 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010184
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 /* default value */
10186 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
10187 pConfig->num_accept_mac = 0;
10188 pConfig->num_deny_mac = 0;
10189
10190 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
10191 pBeacon->tail, pBeacon->tail_len);
10192
10193 /* pIe for black list is following form:
10194 type : 1 byte
10195 length : 1 byte
10196 OUI : 4 bytes
10197 acl type : 1 byte
10198 no of mac addr in black list: 1 byte
10199 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010200 */
10201 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 {
10203 pConfig->SapMacaddr_acl = pIe[6];
10204 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080010205 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010207 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
10208 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
10210 for (i = 0; i < pConfig->num_deny_mac; i++)
10211 {
10212 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
10213 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 }
10216 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
10217 pBeacon->tail, pBeacon->tail_len);
10218
10219 /* pIe for white list is following form:
10220 type : 1 byte
10221 length : 1 byte
10222 OUI : 4 bytes
10223 acl type : 1 byte
10224 no of mac addr in white list: 1 byte
10225 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010226 */
10227 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 {
10229 pConfig->SapMacaddr_acl = pIe[6];
10230 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -080010231 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010233 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
10234 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
10236 for (i = 0; i < pConfig->num_accept_mac; i++)
10237 {
10238 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
10239 acl_entry++;
10240 }
10241 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010242
Jeff Johnson295189b2012-06-20 16:38:30 -070010243 wlan_hdd_set_sapHwmode(pHostapdAdapter);
10244
Jeff Johnsone7245742012-09-05 17:12:55 -070010245#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080010246 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +053010247 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
10248 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +053010249 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
10250 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -080010251 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
10252 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +053010253 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
10254 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010255 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053010256 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -070010257 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +053010258 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070010259
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053010260 /* If ACS disable and selected channel <= 14
10261 * OR
10262 * ACS enabled and ACS operating band is choosen as 2.4
10263 * AND
10264 * VHT in 2.4G Disabled
10265 * THEN
10266 * Fallback to 11N mode
10267 */
10268 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
10269 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +053010270 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +053010271 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -070010272 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +053010273 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
10274 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -070010275 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
10276 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010277 }
10278#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010279
Jeff Johnson295189b2012-06-20 16:38:30 -070010280 // ht_capab is not what the name conveys,this is used for protection bitmap
10281 pConfig->ht_capab =
10282 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
10283
Kapil Gupta137ef892016-12-13 19:38:00 +053010284 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 {
10286 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
10287 return -EINVAL;
10288 }
10289
10290 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010291 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
10293 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010294 pConfig->obssProtEnabled =
10295 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -070010296
Chet Lanctot8cecea22014-02-11 19:09:36 -080010297#ifdef WLAN_FEATURE_11W
10298 pConfig->mfpCapable = MFPCapable;
10299 pConfig->mfpRequired = MFPRequired;
10300 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
10301 pConfig->mfpCapable, pConfig->mfpRequired);
10302#endif
10303
Arif Hussain6d2a3322013-11-17 19:50:10 -080010304 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010306 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
10307 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
10308 (int)pConfig->channel);
10309 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
10310 pConfig->SapHw_mode, pConfig->privacy,
10311 pConfig->authType);
10312 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
10313 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
10314 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
10315 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010316
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010317 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 {
10319 //Bss already started. just return.
10320 //TODO Probably it should update some beacon params.
10321 hddLog( LOGE, "Bss Already started...Ignore the request");
10322 EXIT();
10323 return 0;
10324 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010325
Agarwal Ashish51325b52014-06-16 16:50:49 +053010326 if (vos_max_concurrent_connections_reached()) {
10327 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10328 return -EINVAL;
10329 }
10330
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 pConfig->persona = pHostapdAdapter->device_mode;
10332
Peng Xu2446a892014-09-05 17:21:18 +053010333 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
10334 if ( NULL != psmeConfig)
10335 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010336 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +053010337 sme_GetConfigParam(hHal, psmeConfig);
10338 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010339#ifdef WLAN_FEATURE_AP_HT40_24G
10340 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
10341 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
10342 && pHddCtx->cfg_ini->apHT40_24GEnabled)
10343 {
10344 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
10345 sme_UpdateConfig (hHal, psmeConfig);
10346 }
10347#endif
Peng Xu2446a892014-09-05 17:21:18 +053010348 vos_mem_free(psmeConfig);
10349 }
Peng Xuafc34e32014-09-25 13:23:55 +053010350 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +053010351
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010352 set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
10353
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 pSapEventCallback = hdd_hostapd_SAPEventCB;
10355 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
10356 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
10357 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010358 hddLog(LOGE,FL("SAP Start Bss fail"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010359 ret = -EINVAL;
10360 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 }
10362
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010363 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
10365
10366 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010367
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010369 {
10370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010371 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -070010372 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 VOS_ASSERT(0);
10374 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010375
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053010377 if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) !=
10378 VOS_STATUS_SUCCESS)
10379 {
10380 hddLog(LOGE,FL("Fail to get Softap sessionID"));
10381 VOS_ASSERT(0);
10382 }
Kaushik, Sushantf6070802014-10-15 15:09:23 +053010383 /* Initialize WMM configuation */
10384 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010385 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010386
Anurag Chouhan83026002016-12-13 22:46:21 +053010387#ifdef DHCP_SERVER_OFFLOAD
10388 /* set dhcp server offload */
10389 if (iniConfig->enable_dhcp_srv_offload &&
10390 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010391 vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event);
Anurag Chouhan638f5e22017-03-06 12:28:43 +053010392 status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false);
Anurag Chouhan83026002016-12-13 22:46:21 +053010393 if (!VOS_IS_STATUS_SUCCESS(status))
10394 {
10395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10396 ("HDD DHCP Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010397 vos_event_reset(&pHostapdState->vosEvent);
10398 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
10399 status = vos_wait_single_event(&pHostapdState->vosEvent,
10400 10000);
10401 if (!VOS_IS_STATUS_SUCCESS(status)) {
10402 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010403 ret = -EINVAL;
10404 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010405 }
10406 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010407 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010408 status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000);
10409 if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status)
10410 {
10411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10412 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
10413 pHostapdAdapter->dhcp_status.dhcp_offload_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010414 vos_event_reset(&pHostapdState->vosEvent);
10415 if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) {
10416 status = vos_wait_single_event(&pHostapdState->vosEvent,
10417 10000);
10418 if (!VOS_IS_STATUS_SUCCESS(status)) {
10419 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010420 ret = -EINVAL;
10421 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010422 }
10423 }
Anurag Chouhan83026002016-12-13 22:46:21 +053010424 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010425#ifdef MDNS_OFFLOAD
10426 if (iniConfig->enable_mdns_offload) {
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010427 vos_event_reset(&pHostapdAdapter->mdns_status.vos_event);
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010428 status = wlan_hdd_set_mdns_offload(pHostapdAdapter);
10429 if (VOS_IS_STATUS_SUCCESS(status))
10430 {
10431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10432 ("HDD MDNS Server Offload Failed!!"));
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010433 vos_event_reset(&pHostapdState->vosEvent);
10434 if (VOS_STATUS_SUCCESS ==
10435 WLANSAP_StopBss(pHddCtx->pvosContext)) {
10436 status = vos_wait_single_event(&pHostapdState->vosEvent,
10437 10000);
10438 if (!VOS_IS_STATUS_SUCCESS(status)) {
10439 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010440 ret = -EINVAL;
10441 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010442 }
10443 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010444 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010445 status = vos_wait_single_event(&pHostapdAdapter->
10446 mdns_status.vos_event, 2000);
10447 if (!VOS_IS_STATUS_SUCCESS(status) ||
10448 pHostapdAdapter->mdns_status.mdns_enable_status ||
10449 pHostapdAdapter->mdns_status.mdns_fqdn_status ||
10450 pHostapdAdapter->mdns_status.mdns_resp_status)
10451 {
10452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10453 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
10454 pHostapdAdapter->mdns_status.mdns_enable_status,
10455 pHostapdAdapter->mdns_status.mdns_fqdn_status,
10456 pHostapdAdapter->mdns_status.mdns_resp_status);
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010457 vos_event_reset(&pHostapdState->vosEvent);
10458 if (VOS_STATUS_SUCCESS ==
10459 WLANSAP_StopBss(pHddCtx->pvosContext)) {
10460 status = vos_wait_single_event(&pHostapdState->vosEvent,
10461 10000);
10462 if (!VOS_IS_STATUS_SUCCESS(status)) {
10463 hddLog(LOGE, FL("SAP Stop Failed"));
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010464 ret = -EINVAL;
10465 goto error;
Anurag Chouhanb2951ae2017-03-12 13:41:35 +053010466 }
10467 }
Anurag Chouhan0b29de02016-12-16 13:18:40 +053010468 }
10469 }
10470#endif /* MDNS_OFFLOAD */
10471 } else {
10472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10473 ("DHCP Disabled ini %d, FW %d"),
10474 iniConfig->enable_dhcp_srv_offload,
10475 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
Anurag Chouhan83026002016-12-13 22:46:21 +053010476 }
10477#endif /* DHCP_SERVER_OFFLOAD */
10478
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010479#ifdef WLAN_FEATURE_P2P_DEBUG
10480 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
10481 {
10482 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
10483 {
10484 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
10485 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -080010486 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010487 }
10488 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
10489 {
10490 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
10491 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -080010492 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010493 }
10494 }
10495#endif
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +053010496 /* Check and restart SAP if it is on Unsafe channel */
10497 hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010498
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 pHostapdState->bCommit = TRUE;
10500 EXIT();
10501
10502 return 0;
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010503error:
10504 clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags);
10505 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010506}
10507
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010508#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010509static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010510 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 struct beacon_parameters *params)
10512{
10513 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010514 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010515 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010516
10517 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010518
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010519 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10520 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
10521 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010522 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
10523 hdd_device_modetoString(pAdapter->device_mode),
10524 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010525
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010526 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10527 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010528 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010529 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010530 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010531 }
10532
Agarwal Ashish51325b52014-06-16 16:50:49 +053010533 if (vos_max_concurrent_connections_reached()) {
10534 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10535 return -EINVAL;
10536 }
10537
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010538 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 )
10541 {
10542 beacon_data_t *old,*new;
10543
10544 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010545
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010547 {
10548 hddLog(VOS_TRACE_LEVEL_WARN,
10549 FL("already beacon info added to session(%d)"),
10550 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010553
10554 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10555
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010556 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 {
10558 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010559 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 return -EINVAL;
10561 }
10562
10563 pAdapter->sessionCtx.ap.beacon = new;
10564
10565 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10566 }
10567
10568 EXIT();
10569 return status;
10570}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010571
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010572static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
10573 struct net_device *dev,
10574 struct beacon_parameters *params)
10575{
10576 int ret;
10577
10578 vos_ssr_protect(__func__);
10579 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
10580 vos_ssr_unprotect(__func__);
10581
10582 return ret;
10583}
10584
10585static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 struct net_device *dev,
10587 struct beacon_parameters *params)
10588{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010590 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10591 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010592 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010593
10594 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010595
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010596 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10597 TRACE_CODE_HDD_CFG80211_SET_BEACON,
10598 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
10599 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10600 __func__, hdd_device_modetoString(pAdapter->device_mode),
10601 pAdapter->device_mode);
10602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010603 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10604 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010605 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010606 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010607 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010608 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010609
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010610 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010612 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 {
10614 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010615
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010617
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010619 {
10620 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10621 FL("session(%d) old and new heads points to NULL"),
10622 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010625
10626 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
10627
10628 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010629 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010630 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010631 return -EINVAL;
10632 }
10633
10634 pAdapter->sessionCtx.ap.beacon = new;
10635
10636 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
10637 }
10638
10639 EXIT();
10640 return status;
10641}
10642
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010643static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
10644 struct net_device *dev,
10645 struct beacon_parameters *params)
10646{
10647 int ret;
10648
10649 vos_ssr_protect(__func__);
10650 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
10651 vos_ssr_unprotect(__func__);
10652
10653 return ret;
10654}
10655
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010656#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10657
10658#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010659static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010661#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010662static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010663 struct net_device *dev)
10664#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010665{
10666 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -070010667 hdd_context_t *pHddCtx = NULL;
10668 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010669 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010670 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010671
10672 ENTER();
10673
10674 if (NULL == pAdapter)
10675 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010677 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 return -ENODEV;
10679 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010680
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010681 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10682 TRACE_CODE_HDD_CFG80211_STOP_AP,
10683 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010684 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10685 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010686 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010687 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010688 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -070010689 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010690
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010691 pScanInfo = &pHddCtx->scan_info;
10692
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010693 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10694 __func__, hdd_device_modetoString(pAdapter->device_mode),
10695 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010696
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010697 ret = wlan_hdd_scan_abort(pAdapter);
10698
Girish Gowli4bf7a632014-06-12 13:42:11 +053010699 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -070010700 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10702 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010703
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010704 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -070010705 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10707 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -080010708
Jeff Johnsone7245742012-09-05 17:12:55 -070010709 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010710 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -070010711 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010712 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010713 }
10714
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010715 /* Delete all associated STAs before stopping AP/P2P GO */
10716 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +053010717 hdd_hostapd_stop(dev);
10718
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 )
10722 {
10723 beacon_data_t *old;
10724
10725 old = pAdapter->sessionCtx.ap.beacon;
10726
10727 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010728 {
10729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10730 FL("session(%d) beacon data points to NULL"),
10731 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010732 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010734
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010736
10737 mutex_lock(&pHddCtx->sap_lock);
10738 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10739 {
Jeff Johnson4416a782013-03-25 14:17:50 -070010740 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010741 {
10742 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
10743
10744 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
10745
10746 if (!VOS_IS_STATUS_SUCCESS(status))
10747 {
10748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010749 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010750 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010751 }
10752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010754 /* BSS stopped, clear the active sessions for this device mode */
10755 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 }
10757 mutex_unlock(&pHddCtx->sap_lock);
10758
10759 if(status != VOS_STATUS_SUCCESS)
10760 {
10761 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010762 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010763 return -EINVAL;
10764 }
10765
Jeff Johnson4416a782013-03-25 14:17:50 -070010766 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
10768 ==eHAL_STATUS_FAILURE)
10769 {
10770 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010771 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 }
10773
Jeff Johnson4416a782013-03-25 14:17:50 -070010774 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
10776 eANI_BOOLEAN_FALSE) )
10777 {
10778 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010779 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 }
10781
10782 // Reset WNI_CFG_PROBE_RSP Flags
10783 wlan_hdd_reset_prob_rspies(pAdapter);
10784
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010785 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10786
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 pAdapter->sessionCtx.ap.beacon = NULL;
10788 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -070010789#ifdef WLAN_FEATURE_P2P_DEBUG
10790 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
10791 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
10792 {
10793 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
10794 "GO got removed");
10795 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
10796 }
10797#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010798 }
10799 EXIT();
10800 return status;
10801}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010802
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010803#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10804static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
10805 struct net_device *dev)
10806{
10807 int ret;
10808
10809 vos_ssr_protect(__func__);
10810 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
10811 vos_ssr_unprotect(__func__);
10812
10813 return ret;
10814}
10815#else
10816static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
10817 struct net_device *dev)
10818{
10819 int ret;
10820
10821 vos_ssr_protect(__func__);
10822 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
10823 vos_ssr_unprotect(__func__);
10824
10825 return ret;
10826}
10827#endif
10828
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010829#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
10830
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010831static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010832 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010833 struct cfg80211_ap_settings *params)
10834{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010835 hdd_adapter_t *pAdapter;
10836 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010837 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010838
10839 ENTER();
10840
Girish Gowlib143d7a2015-02-18 19:39:55 +053010841 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010842 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010844 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010845 return -ENODEV;
10846 }
10847
10848 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10849 if (NULL == pAdapter)
10850 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010852 "%s: HDD adapter is Null", __func__);
10853 return -ENODEV;
10854 }
10855
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010856 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10857 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10858 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010859 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10860 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010861 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010862 "%s: HDD adapter magic is invalid", __func__);
10863 return -ENODEV;
10864 }
10865
Hanumanth Reddy Pothula1428c612017-03-06 11:35:34 +053010866 clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags);
10867
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010868 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010869 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010870 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010871 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010872 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010873 }
10874
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010875 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10876 __func__, hdd_device_modetoString(pAdapter->device_mode),
10877 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010878
10879 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010880 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010881 )
10882 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010883 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010884
10885 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010886
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010887 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010888 {
10889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10890 FL("already beacon info added to session(%d)"),
10891 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010892 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010893 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010894
Girish Gowlib143d7a2015-02-18 19:39:55 +053010895#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10896 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10897 &new,
10898 &params->beacon);
10899#else
10900 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10901 &new,
10902 &params->beacon,
10903 params->dtim_period);
10904#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010905
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010906 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010907 {
10908 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010909 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010910 return -EINVAL;
10911 }
10912 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010913#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010914 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10915#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10916 params->channel, params->channel_type);
10917#else
10918 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10919#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010920#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010921 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010922 params->ssid_len, params->hidden_ssid,
10923 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010924 }
10925
10926 EXIT();
10927 return status;
10928}
10929
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010930static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10931 struct net_device *dev,
10932 struct cfg80211_ap_settings *params)
10933{
10934 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010935
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010936 vos_ssr_protect(__func__);
10937 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10938 vos_ssr_unprotect(__func__);
10939
10940 return ret;
10941}
10942
10943static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010944 struct net_device *dev,
10945 struct cfg80211_beacon_data *params)
10946{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010947 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010948 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010949 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010950
10951 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010952
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010953 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10954 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10955 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010956 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010957 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010958
10959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10960 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010961 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010962 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010963 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010964 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010965
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010966 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010967 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010968 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010969 {
10970 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010971
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010972 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010973
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010974 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010975 {
10976 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10977 FL("session(%d) beacon data points to NULL"),
10978 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010979 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010980 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010981
10982 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10983
10984 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010985 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010986 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010987 return -EINVAL;
10988 }
10989
10990 pAdapter->sessionCtx.ap.beacon = new;
10991
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010992 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10993 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010994 }
10995
10996 EXIT();
10997 return status;
10998}
10999
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011000static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
11001 struct net_device *dev,
11002 struct cfg80211_beacon_data *params)
11003{
11004 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011005
Mukul Sharmab0e0a982014-12-15 18:58:53 +053011006 vos_ssr_protect(__func__);
11007 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
11008 vos_ssr_unprotect(__func__);
11009
11010 return ret;
11011}
11012
11013#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011014
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011015static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011016 struct net_device *dev,
11017 struct bss_parameters *params)
11018{
11019 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011020 hdd_context_t *pHddCtx;
11021 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011022
11023 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011024
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011025 if (NULL == pAdapter)
11026 {
11027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11028 "%s: HDD adapter is Null", __func__);
11029 return -ENODEV;
11030 }
11031 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011032 ret = wlan_hdd_validate_context(pHddCtx);
11033 if (0 != ret)
11034 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011035 return ret;
11036 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011037 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11038 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
11039 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011040 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11041 __func__, hdd_device_modetoString(pAdapter->device_mode),
11042 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011043
11044 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011046 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 {
11048 /* ap_isolate == -1 means that in change bss, upper layer doesn't
11049 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011050 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070011051 {
11052 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011053 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 }
11055
11056 EXIT();
11057 return 0;
11058}
11059
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011060static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
11061 struct net_device *dev,
11062 struct bss_parameters *params)
11063{
11064 int ret;
11065
11066 vos_ssr_protect(__func__);
11067 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
11068 vos_ssr_unprotect(__func__);
11069
11070 return ret;
11071}
Kiet Lam10841362013-11-01 11:36:50 +053011072/* FUNCTION: wlan_hdd_change_country_code_cd
11073* to wait for contry code completion
11074*/
11075void* wlan_hdd_change_country_code_cb(void *pAdapter)
11076{
11077 hdd_adapter_t *call_back_pAdapter = pAdapter;
11078 complete(&call_back_pAdapter->change_country_code);
11079 return NULL;
11080}
11081
Jeff Johnson295189b2012-06-20 16:38:30 -070011082/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053011083 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
11085 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053011086int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 struct net_device *ndev,
11088 enum nl80211_iftype type,
11089 u32 *flags,
11090 struct vif_params *params
11091 )
11092{
11093 struct wireless_dev *wdev;
11094 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011095 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070011096 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011097 tCsrRoamProfile *pRoamProfile = NULL;
11098 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011099 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 eMib_dot11DesiredBssType connectedBssType;
11101 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011102 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011103
11104 ENTER();
11105
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011106 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011107 {
11108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11109 "%s: Adapter context is null", __func__);
11110 return VOS_STATUS_E_FAILURE;
11111 }
11112
11113 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11114 if (!pHddCtx)
11115 {
11116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11117 "%s: HDD context is null", __func__);
11118 return VOS_STATUS_E_FAILURE;
11119 }
11120
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011121 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11122 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
11123 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011124 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011125 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011127 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 }
11129
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011130 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11131 __func__, hdd_device_modetoString(pAdapter->device_mode),
11132 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011133
Agarwal Ashish51325b52014-06-16 16:50:49 +053011134 if (vos_max_concurrent_connections_reached()) {
11135 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
11136 return -EINVAL;
11137 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011138 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 wdev = ndev->ieee80211_ptr;
11140
11141#ifdef WLAN_BTAMP_FEATURE
11142 if((NL80211_IFTYPE_P2P_CLIENT == type)||
11143 (NL80211_IFTYPE_ADHOC == type)||
11144 (NL80211_IFTYPE_AP == type)||
11145 (NL80211_IFTYPE_P2P_GO == type))
11146 {
11147 pHddCtx->isAmpAllowed = VOS_FALSE;
11148 // stop AMP traffic
11149 status = WLANBAP_StopAmp();
11150 if(VOS_STATUS_SUCCESS != status )
11151 {
11152 pHddCtx->isAmpAllowed = VOS_TRUE;
11153 hddLog(VOS_TRACE_LEVEL_FATAL,
11154 "%s: Failed to stop AMP", __func__);
11155 return -EINVAL;
11156 }
11157 }
11158#endif //WLAN_BTAMP_FEATURE
11159 /* Reset the current device mode bit mask*/
11160 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
11161
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053011162 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
11163 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
11164 (type == NL80211_IFTYPE_P2P_GO)))
11165 {
11166 /* Notify Mode change in case of concurrency.
11167 * Below function invokes TDLS teardown Functionality Since TDLS is
11168 * not Supported in case of concurrency i.e Once P2P session
11169 * is detected disable offchannel and teardown TDLS links
11170 */
11171 hddLog(LOG1,
11172 FL("Device mode = %d Interface type = %d"),
11173 pAdapter->device_mode, type);
11174 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
11175 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053011176
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011178 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070011179 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 )
11181 {
11182 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080011183 if (!pWextState)
11184 {
11185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11186 "%s: pWextState is null", __func__);
11187 return VOS_STATUS_E_FAILURE;
11188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 pRoamProfile = &pWextState->roamProfile;
11190 LastBSSType = pRoamProfile->BSSType;
11191
11192 switch (type)
11193 {
11194 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 hddLog(VOS_TRACE_LEVEL_INFO,
11197 "%s: setting interface Type to INFRASTRUCTURE", __func__);
11198 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070011199#ifdef WLAN_FEATURE_11AC
11200 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
11201 {
11202 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
11203 }
11204#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011205 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070011206 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011207 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080011208 //Check for sub-string p2p to confirm its a p2p interface
11209 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011210 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053011211#ifdef FEATURE_WLAN_TDLS
11212 mutex_lock(&pHddCtx->tdls_lock);
11213 wlan_hdd_tdls_exit(pAdapter, TRUE);
11214 mutex_unlock(&pHddCtx->tdls_lock);
11215#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011216 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
11217 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
11218 }
11219 else
11220 {
11221 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053011225
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 case NL80211_IFTYPE_ADHOC:
11227 hddLog(VOS_TRACE_LEVEL_INFO,
11228 "%s: setting interface Type to ADHOC", __func__);
11229 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
11230 pRoamProfile->phyMode =
11231 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070011232 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053011234 hdd_set_ibss_ops( pAdapter );
11235 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053011236
11237 status = hdd_sta_id_hash_attach(pAdapter);
11238 if (VOS_STATUS_SUCCESS != status) {
11239 hddLog(VOS_TRACE_LEVEL_ERROR,
11240 FL("Failed to initialize hash for IBSS"));
11241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 break;
11243
11244 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070011245 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 {
11247 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11248 "%s: setting interface Type to %s", __func__,
11249 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
11250
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080011251 //Cancel any remain on channel for GO mode
11252 if (NL80211_IFTYPE_P2P_GO == type)
11253 {
11254 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
11255 }
Mohit Khanna0f232092012-09-11 14:46:08 -070011256 if (NL80211_IFTYPE_AP == type)
11257 {
11258 /* As Loading WLAN Driver one interface being created for p2p device
11259 * address. This will take one HW STA and the max number of clients
11260 * that can connect to softAP will be reduced by one. so while changing
11261 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
11262 * interface as it is not required in SoftAP mode.
11263 */
11264
11265 // Get P2P Adapter
11266 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
11267
11268 if (pP2pAdapter)
11269 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053011270 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053011271 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070011272 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
11273 }
11274 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053011275 //Disable IMPS & BMPS for SAP/GO
11276 if(VOS_STATUS_E_FAILURE ==
11277 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
11278 {
11279 //Fail to Exit BMPS
11280 VOS_ASSERT(0);
11281 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053011282
11283 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
11284
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011285#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070011286
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011287 /* A Mutex Lock is introduced while changing the mode to
11288 * protect the concurrent access for the Adapters by TDLS
11289 * module.
11290 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011291 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011293 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053011294 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
11297 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011298#ifdef FEATURE_WLAN_TDLS
11299 mutex_unlock(&pHddCtx->tdls_lock);
11300#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070011301 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
11302 (pConfig->apRandomBssidEnabled))
11303 {
11304 /* To meet Android requirements create a randomized
11305 MAC address of the form 02:1A:11:Fx:xx:xx */
11306 get_random_bytes(&ndev->dev_addr[3], 3);
11307 ndev->dev_addr[0] = 0x02;
11308 ndev->dev_addr[1] = 0x1A;
11309 ndev->dev_addr[2] = 0x11;
11310 ndev->dev_addr[3] |= 0xF0;
11311 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
11312 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080011313 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
11314 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070011315 }
11316
Jeff Johnson295189b2012-06-20 16:38:30 -070011317 hdd_set_ap_ops( pAdapter->dev );
11318
Kiet Lam10841362013-11-01 11:36:50 +053011319 /* This is for only SAP mode where users can
11320 * control country through ini.
11321 * P2P GO follows station country code
11322 * acquired during the STA scanning. */
11323 if((NL80211_IFTYPE_AP == type) &&
11324 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
11325 {
11326 int status = 0;
11327 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
11328 "%s: setting country code from INI ", __func__);
11329 init_completion(&pAdapter->change_country_code);
11330 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
11331 (void *)(tSmeChangeCountryCallback)
11332 wlan_hdd_change_country_code_cb,
11333 pConfig->apCntryCode, pAdapter,
11334 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053011335 eSIR_FALSE,
11336 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053011337 if (eHAL_STATUS_SUCCESS == status)
11338 {
11339 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011340 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053011341 &pAdapter->change_country_code,
11342 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011343 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053011344 {
11345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011346 FL("SME Timed out while setting country code %ld"),
11347 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080011348
11349 if (pHddCtx->isLogpInProgress)
11350 {
11351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11352 "%s: LOGP in Progress. Ignore!!!", __func__);
11353 return -EAGAIN;
11354 }
Kiet Lam10841362013-11-01 11:36:50 +053011355 }
11356 }
11357 else
11358 {
11359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011360 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053011361 return -EINVAL;
11362 }
11363 }
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +053011364 status = hdd_init_ap_mode(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 if(status != VOS_STATUS_SUCCESS)
11366 {
11367 hddLog(VOS_TRACE_LEVEL_FATAL,
11368 "%s: Error initializing the ap mode", __func__);
11369 return -EINVAL;
11370 }
11371 hdd_set_conparam(1);
11372
Nirav Shah7e3c8132015-06-22 23:51:42 +053011373 status = hdd_sta_id_hash_attach(pAdapter);
11374 if (VOS_STATUS_SUCCESS != status)
11375 {
11376 hddLog(VOS_TRACE_LEVEL_ERROR,
11377 FL("Failed to initialize hash for AP"));
11378 return -EINVAL;
11379 }
11380
Jeff Johnson295189b2012-06-20 16:38:30 -070011381 /*interface type changed update in wiphy structure*/
11382 if(wdev)
11383 {
11384 wdev->iftype = type;
11385 pHddCtx->change_iface = type;
11386 }
11387 else
11388 {
11389 hddLog(VOS_TRACE_LEVEL_ERROR,
11390 "%s: ERROR !!!! Wireless dev is NULL", __func__);
11391 return -EINVAL;
11392 }
11393 goto done;
11394 }
11395
11396 default:
11397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
11398 __func__);
11399 return -EOPNOTSUPP;
11400 }
11401 }
11402 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011403 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 )
11405 {
11406 switch(type)
11407 {
11408 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053011411
11412 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011413#ifdef FEATURE_WLAN_TDLS
11414
11415 /* A Mutex Lock is introduced while changing the mode to
11416 * protect the concurrent access for the Adapters by TDLS
11417 * module.
11418 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011419 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011420#endif
c_hpothu002231a2015-02-05 14:58:51 +053011421 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080011423 //Check for sub-string p2p to confirm its a p2p interface
11424 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011425 {
11426 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
11427 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
11428 }
11429 else
11430 {
11431 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080011433 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053011434
11435 /* set con_mode to STA only when no SAP concurrency mode */
11436 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
11437 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
11440 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053011441#ifdef FEATURE_WLAN_TDLS
11442 mutex_unlock(&pHddCtx->tdls_lock);
11443#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053011444 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 if( VOS_STATUS_SUCCESS != status )
11446 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070011447 /* In case of JB, for P2P-GO, only change interface will be called,
11448 * This is the right place to enable back bmps_imps()
11449 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053011450 if (pHddCtx->hdd_wlan_suspended)
11451 {
11452 hdd_set_pwrparams(pHddCtx);
11453 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011454 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 goto done;
11456 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
11460 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 goto done;
11462 default:
11463 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
11464 __func__);
11465 return -EOPNOTSUPP;
11466
11467 }
11468
11469 }
11470 else
11471 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011472 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
11473 __func__, hdd_device_modetoString(pAdapter->device_mode),
11474 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 return -EOPNOTSUPP;
11476 }
11477
11478
11479 if(pRoamProfile)
11480 {
11481 if ( LastBSSType != pRoamProfile->BSSType )
11482 {
11483 /*interface type changed update in wiphy structure*/
11484 wdev->iftype = type;
11485
11486 /*the BSS mode changed, We need to issue disconnect
11487 if connected or in IBSS disconnect state*/
11488 if ( hdd_connGetConnectedBssType(
11489 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
11490 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
11491 {
11492 /*need to issue a disconnect to CSR.*/
11493 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11494 if( eHAL_STATUS_SUCCESS ==
11495 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11496 pAdapter->sessionId,
11497 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11498 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011499 ret = wait_for_completion_interruptible_timeout(
11500 &pAdapter->disconnect_comp_var,
11501 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11502 if (ret <= 0)
11503 {
11504 hddLog(VOS_TRACE_LEVEL_ERROR,
11505 FL("wait on disconnect_comp_var failed %ld"), ret);
11506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 }
11508 }
11509 }
11510 }
11511
11512done:
11513 /*set bitmask based on updated value*/
11514 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070011515
11516 /* Only STA mode support TM now
11517 * all other mode, TM feature should be disabled */
11518 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
11519 (~VOS_STA & pHddCtx->concurrency_mode) )
11520 {
11521 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
11522 }
11523
Jeff Johnson295189b2012-06-20 16:38:30 -070011524#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011525 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053011526 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 {
11528 //we are ok to do AMP
11529 pHddCtx->isAmpAllowed = VOS_TRUE;
11530 }
11531#endif //WLAN_BTAMP_FEATURE
11532 EXIT();
11533 return 0;
11534}
11535
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053011536/*
11537 * FUNCTION: wlan_hdd_cfg80211_change_iface
11538 * wrapper function to protect the actual implementation from SSR.
11539 */
11540int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
11541 struct net_device *ndev,
11542 enum nl80211_iftype type,
11543 u32 *flags,
11544 struct vif_params *params
11545 )
11546{
11547 int ret;
11548
11549 vos_ssr_protect(__func__);
11550 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
11551 vos_ssr_unprotect(__func__);
11552
11553 return ret;
11554}
11555
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011556#ifdef FEATURE_WLAN_TDLS
11557static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011558 struct net_device *dev,
11559#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11560 const u8 *mac,
11561#else
11562 u8 *mac,
11563#endif
11564 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011565{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011566 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011567 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011568 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011569 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053011570 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011571 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011572
11573 ENTER();
11574
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053011575 if (!dev) {
11576 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
11577 return -EINVAL;
11578 }
11579
11580 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11581 if (!pAdapter) {
11582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
11583 return -EINVAL;
11584 }
11585
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011586 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011587 {
11588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11589 "Invalid arguments");
11590 return -EINVAL;
11591 }
Hoonki Lee27511902013-03-14 18:19:06 -070011592
11593 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
11594 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
11595 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070011597 "%s: TDLS mode is disabled OR not enabled in FW."
11598 MAC_ADDRESS_STR " Request declined.",
11599 __func__, MAC_ADDR_ARRAY(mac));
11600 return -ENOTSUPP;
11601 }
11602
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011603 if (pHddCtx->isLogpInProgress)
11604 {
11605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11606 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053011607 wlan_hdd_tdls_set_link_status(pAdapter,
11608 mac,
11609 eTDLS_LINK_IDLE,
11610 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011611 return -EBUSY;
11612 }
11613
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011614 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053011615 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011616
11617 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011619 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
11620 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053011621 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011622 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011623 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011624
11625 /* in add station, we accept existing valid staId if there is */
11626 if ((0 == update) &&
11627 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
11628 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011629 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011631 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011632 " link_status %d. staId %d. add station ignored.",
11633 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011634 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011635 return 0;
11636 }
11637 /* in change station, we accept only when staId is valid */
11638 if ((1 == update) &&
11639 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
11640 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
11641 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011642 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011643 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011644 "%s: " MAC_ADDRESS_STR
11645 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011646 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
11647 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
11648 mutex_unlock(&pHddCtx->tdls_lock);
11649 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011650 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011651 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011652
11653 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053011654 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011655 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11657 "%s: " MAC_ADDRESS_STR
11658 " TDLS setup is ongoing. Request declined.",
11659 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070011660 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011661 }
11662
11663 /* first to check if we reached to maximum supported TDLS peer.
11664 TODO: for now, return -EPERM looks working fine,
11665 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011666 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
11667 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011668 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011669 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11670 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053011671 " TDLS Max peer already connected. Request declined."
11672 " Num of peers (%d), Max allowed (%d).",
11673 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
11674 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011675 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011676 }
11677 else
11678 {
11679 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011680 mutex_lock(&pHddCtx->tdls_lock);
11681 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011682 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011683 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011684 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011685 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11686 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
11687 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011688 return -EPERM;
11689 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011690 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011691 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011692 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053011693 wlan_hdd_tdls_set_link_status(pAdapter,
11694 mac,
11695 eTDLS_LINK_CONNECTING,
11696 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011697
Jeff Johnsond75fe012013-04-06 10:53:06 -070011698 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011699 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011700 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011702 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011703 if(StaParams->htcap_present)
11704 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011706 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011708 "ht_capa->extended_capabilities: %0x",
11709 StaParams->HTCap.extendedHtCapInfo);
11710 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011712 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011714 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070011715 if(StaParams->vhtcap_present)
11716 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070011718 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
11719 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
11720 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
11721 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011722 {
11723 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011725 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053011726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011727 "[%d]: %x ", i, StaParams->supported_rates[i]);
11728 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070011729 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053011730 else if ((1 == update) && (NULL == StaParams))
11731 {
11732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11733 "%s : update is true, but staParams is NULL. Error!", __func__);
11734 return -EPERM;
11735 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011736
11737 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
11738
11739 if (!update)
11740 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011741 /*Before adding sta make sure that device exited from BMPS*/
11742 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
11743 {
11744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11745 "%s: Adding tdls peer sta. Disable BMPS", __func__);
11746 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
11747 if (status != VOS_STATUS_SUCCESS) {
11748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
11749 }
11750 }
11751
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011752 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011753 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011754 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053011755 hddLog(VOS_TRACE_LEVEL_ERROR,
11756 FL("Failed to add TDLS peer STA. Enable Bmps"));
11757 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011758 return -EPERM;
11759 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011760 }
11761 else
11762 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011763 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011764 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053011765 if (ret != eHAL_STATUS_SUCCESS) {
11766 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
11767 return -EPERM;
11768 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011769 }
11770
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011771 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011772 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
11773
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011774 mutex_lock(&pHddCtx->tdls_lock);
11775 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
11776
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011777 if ((pTdlsPeer != NULL) &&
11778 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011779 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011780 hddLog(VOS_TRACE_LEVEL_ERROR,
11781 FL("peer link status %u"), pTdlsPeer->link_status);
11782 mutex_unlock(&pHddCtx->tdls_lock);
11783 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011784 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053011785 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011786
Masti, Narayanraddi07262462016-01-19 12:40:06 +053011787 if (ret <= 0)
11788 {
11789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11790 "%s: timeout waiting for tdls add station indication %ld",
11791 __func__, ret);
11792 goto error;
11793 }
11794
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011795 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
11796 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011798 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070011799 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011800 }
11801
11802 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070011803
11804error:
Atul Mittal115287b2014-07-08 13:26:33 +053011805 wlan_hdd_tdls_set_link_status(pAdapter,
11806 mac,
11807 eTDLS_LINK_IDLE,
11808 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070011809 return -EPERM;
11810
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011811}
11812#endif
11813
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011814static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011816#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11817 const u8 *mac,
11818#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 struct station_parameters *params)
11822{
11823 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011824 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011825 hdd_context_t *pHddCtx;
11826 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011827 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011828 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011829#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011830 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011831 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011832 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011833 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011834#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011835
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011836 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011837
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011838 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011839 if ((NULL == pAdapter))
11840 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011842 "invalid adapter ");
11843 return -EINVAL;
11844 }
11845
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011846 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11847 TRACE_CODE_HDD_CHANGE_STATION,
11848 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011849 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011850
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011851 ret = wlan_hdd_validate_context(pHddCtx);
11852 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011853 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011854 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011855 }
11856
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011857 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11858
11859 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011860 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11862 "invalid HDD station context");
11863 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011864 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11866
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011867 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11868 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011870 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011872 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 WLANTL_STA_AUTHENTICATED);
11874
Gopichand Nakkala29149562013-05-10 21:43:41 +053011875 if (status != VOS_STATUS_SUCCESS)
11876 {
11877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11878 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11879 return -EINVAL;
11880 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011881 }
11882 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011883 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11884 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011885#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011886 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11887 StaParams.capability = params->capability;
11888 StaParams.uapsd_queues = params->uapsd_queues;
11889 StaParams.max_sp = params->max_sp;
11890
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011891 /* Convert (first channel , number of channels) tuple to
11892 * the total list of channels. This goes with the assumption
11893 * that if the first channel is < 14, then the next channels
11894 * are an incremental of 1 else an incremental of 4 till the number
11895 * of channels.
11896 */
11897 if (0 != params->supported_channels_len) {
11898 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11899 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11900 {
11901 int wifi_chan_index;
11902 StaParams.supported_channels[j] = params->supported_channels[i];
11903 wifi_chan_index =
11904 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11905 no_of_channels = params->supported_channels[i+1];
11906 for(k=1; k <= no_of_channels; k++)
11907 {
11908 StaParams.supported_channels[j+1] =
11909 StaParams.supported_channels[j] + wifi_chan_index;
11910 j+=1;
11911 }
11912 }
11913 StaParams.supported_channels_len = j;
11914 }
SaidiReddy Yenuga0f1a1592017-04-05 13:18:26 +053011915 if (params->supported_oper_classes_len >
11916 SIR_MAC_MAX_SUPP_OPER_CLASSES) {
11917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11918 "received oper classes:%d, resetting it to max supported %d",
11919 params->supported_oper_classes_len,
11920 SIR_MAC_MAX_SUPP_OPER_CLASSES);
11921 params->supported_oper_classes_len =
11922 SIR_MAC_MAX_SUPP_OPER_CLASSES;
11923 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011924 vos_mem_copy(StaParams.supported_oper_classes,
11925 params->supported_oper_classes,
11926 params->supported_oper_classes_len);
11927 StaParams.supported_oper_classes_len =
11928 params->supported_oper_classes_len;
11929
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011930 if (params->ext_capab_len > sizeof(StaParams.extn_capability)) {
11931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11932 "received extn capabilities:%d, resetting it to max supported",
11933 params->ext_capab_len);
11934 params->ext_capab_len = sizeof(StaParams.extn_capability);
11935 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011936 if (0 != params->ext_capab_len)
11937 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
SaidiReddy Yenuga96d8ca52017-06-06 13:01:29 +053011938 params->ext_capab_len);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011939
11940 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011941 {
11942 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011943 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011944 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011945
11946 StaParams.supported_rates_len = params->supported_rates_len;
11947
11948 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11949 * The supported_rates array , for all the structures propogating till Add Sta
11950 * to the firmware has to be modified , if the supplicant (ieee80211) is
11951 * modified to send more rates.
11952 */
11953
11954 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11955 */
11956 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11957 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11958
11959 if (0 != StaParams.supported_rates_len) {
11960 int i = 0;
11961 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11962 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011964 "Supported Rates with Length %d", StaParams.supported_rates_len);
11965 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011967 "[%d]: %0x", i, StaParams.supported_rates[i]);
11968 }
11969
11970 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011971 {
11972 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011973 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011974 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011975
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011976 if (0 != params->ext_capab_len ) {
11977 /*Define A Macro : TODO Sunil*/
11978 if ((1<<4) & StaParams.extn_capability[3]) {
11979 isBufSta = 1;
11980 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011981 /* TDLS Channel Switching Support */
11982 if ((1<<6) & StaParams.extn_capability[3]) {
11983 isOffChannelSupported = 1;
11984 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011985 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011986
11987 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011988 (params->ht_capa || params->vht_capa ||
11989 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011990 /* TDLS Peer is WME/QoS capable */
11991 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011992
11993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11994 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11995 __func__, isQosWmmSta, StaParams.htcap_present);
11996
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011997 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11998 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011999 isOffChannelSupported,
12000 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053012001
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012002 if (VOS_STATUS_SUCCESS != status) {
12003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12004 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
12005 return -EINVAL;
12006 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012007 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
12008
12009 if (VOS_STATUS_SUCCESS != status) {
12010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12011 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
12012 return -EINVAL;
12013 }
12014 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070012015#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053012016 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012017 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 return status;
12019}
12020
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012021#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
12022static int wlan_hdd_change_station(struct wiphy *wiphy,
12023 struct net_device *dev,
12024 const u8 *mac,
12025 struct station_parameters *params)
12026#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012027static int wlan_hdd_change_station(struct wiphy *wiphy,
12028 struct net_device *dev,
12029 u8 *mac,
12030 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012031#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012032{
12033 int ret;
12034
12035 vos_ssr_protect(__func__);
12036 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
12037 vos_ssr_unprotect(__func__);
12038
12039 return ret;
12040}
12041
Jeff Johnson295189b2012-06-20 16:38:30 -070012042/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012043 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 * This function is used to initialize the key information
12045 */
12046#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012047static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012048 struct net_device *ndev,
12049 u8 key_index, bool pairwise,
12050 const u8 *mac_addr,
12051 struct key_params *params
12052 )
12053#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012054static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 struct net_device *ndev,
12056 u8 key_index, const u8 *mac_addr,
12057 struct key_params *params
12058 )
12059#endif
12060{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012061 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 tCsrRoamSetKey setKey;
12063 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012064 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012065 v_U32_t roamId= 0xFF;
12066 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 hdd_hostapd_state_t *pHostapdState;
12068 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012069 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012070 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012071
12072 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012073
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012074 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12075 TRACE_CODE_HDD_CFG80211_ADD_KEY,
12076 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012077 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12078 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012079 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012080 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012081 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012082 }
12083
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012084 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12085 __func__, hdd_device_modetoString(pAdapter->device_mode),
12086 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012087
12088 if (CSR_MAX_NUM_KEY <= key_index)
12089 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012091 key_index);
12092
12093 return -EINVAL;
12094 }
12095
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012096 if (CSR_MAX_KEY_LEN < params->key_len)
12097 {
12098 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
12099 params->key_len);
12100
12101 return -EINVAL;
12102 }
12103
12104 hddLog(VOS_TRACE_LEVEL_INFO,
12105 "%s: called with key index = %d & key length %d",
12106 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070012107
12108 /*extract key idx, key len and key*/
12109 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12110 setKey.keyId = key_index;
12111 setKey.keyLength = params->key_len;
12112 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
12113
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012114 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 {
12116 case WLAN_CIPHER_SUITE_WEP40:
12117 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12118 break;
12119
12120 case WLAN_CIPHER_SUITE_WEP104:
12121 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
12122 break;
12123
12124 case WLAN_CIPHER_SUITE_TKIP:
12125 {
12126 u8 *pKey = &setKey.Key[0];
12127 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
12128
12129 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
12130
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012131 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070012132
12133 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012134 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 |--------------|----------|----------|
12136 <---16bytes---><--8bytes--><--8bytes-->
12137
12138 */
12139 /*Sme expects the 32 bytes key to be in the below order
12140
12141 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012142 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 |--------------|----------|----------|
12144 <---16bytes---><--8bytes--><--8bytes-->
12145 */
12146 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012147 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012148
12149 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012150 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012151
12152 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012153 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012154
12155
12156 break;
12157 }
12158
12159 case WLAN_CIPHER_SUITE_CCMP:
12160 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
12161 break;
12162
12163#ifdef FEATURE_WLAN_WAPI
12164 case WLAN_CIPHER_SUITE_SMS4:
12165 {
12166 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12167 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
12168 params->key, params->key_len);
12169 return 0;
12170 }
12171#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070012172
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012173#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 case WLAN_CIPHER_SUITE_KRK:
12175 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
12176 break;
12177#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070012178
12179#ifdef WLAN_FEATURE_11W
12180 case WLAN_CIPHER_SUITE_AES_CMAC:
12181 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070012182 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070012183#endif
12184
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012186 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012188 status = -EOPNOTSUPP;
12189 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 }
12191
12192 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
12193 __func__, setKey.encType);
12194
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012195 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070012196#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12197 (!pairwise)
12198#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012199 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070012200#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012201 )
12202 {
12203 /* set group key*/
12204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12205 "%s- %d: setting Broadcast key",
12206 __func__, __LINE__);
12207 setKey.keyDirection = eSIR_RX_ONLY;
12208 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
12209 }
12210 else
12211 {
12212 /* set pairwise key*/
12213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12214 "%s- %d: setting pairwise key",
12215 __func__, __LINE__);
12216 setKey.keyDirection = eSIR_TX_RX;
12217 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
12218 }
12219 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
12220 {
12221 setKey.keyDirection = eSIR_TX_RX;
12222 /*Set the group key*/
12223 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
12224 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012225
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012226 if ( 0 != status )
12227 {
12228 hddLog(VOS_TRACE_LEVEL_ERROR,
12229 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012230 status = -EINVAL;
12231 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012232 }
12233 /*Save the keys here and call sme_RoamSetKey for setting
12234 the PTK after peer joins the IBSS network*/
12235 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
12236 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012237 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012238 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053012239 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
12240 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
12241 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012243 if( pHostapdState->bssState == BSS_START )
12244 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012245 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12246 vos_status = wlan_hdd_check_ula_done(pAdapter);
12247
12248 if ( vos_status != VOS_STATUS_SUCCESS )
12249 {
12250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12251 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
12252 __LINE__, vos_status );
12253
12254 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12255
12256 status = -EINVAL;
12257 goto end;
12258 }
12259
Jeff Johnson295189b2012-06-20 16:38:30 -070012260 status = WLANSAP_SetKeySta( pVosContext, &setKey);
12261
12262 if ( status != eHAL_STATUS_SUCCESS )
12263 {
12264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12265 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12266 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012267 status = -EINVAL;
12268 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 }
12270 }
12271
12272 /* Saving WEP keys */
12273 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
12274 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
12275 {
12276 //Save the wep key in ap context. Issue setkey after the BSS is started.
12277 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12278 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
12279 }
12280 else
12281 {
12282 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012283 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
12285 }
12286 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012287 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
12288 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 {
12290 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12291 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12292
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012293#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12294 if (!pairwise)
12295#else
12296 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
12297#endif
12298 {
12299 /* set group key*/
12300 if (pHddStaCtx->roam_info.deferKeyComplete)
12301 {
12302 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12303 "%s- %d: Perform Set key Complete",
12304 __func__, __LINE__);
12305 hdd_PerformRoamSetKeyComplete(pAdapter);
12306 }
12307 }
12308
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
12310
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080012311 pWextState->roamProfile.Keys.defaultIndex = key_index;
12312
12313
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070012314 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 params->key, params->key_len);
12316
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012317
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12319
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012320 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012321 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012322 __func__, setKey.peerMac[0], setKey.peerMac[1],
12323 setKey.peerMac[2], setKey.peerMac[3],
12324 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 setKey.keyDirection);
12326
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012327 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053012328
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012329 if ( vos_status != VOS_STATUS_SUCCESS )
12330 {
12331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
12333 __LINE__, vos_status );
12334
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012335 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012336
Nirav Shah4b53d4b2015-05-08 05:35:00 -070012337 status = -EINVAL;
12338 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012339
12340 }
12341
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012342#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012343 /* The supplicant may attempt to set the PTK once pre-authentication
12344 is done. Save the key in the UMAC and include it in the ADD BSS
12345 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012346 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012347 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012348 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012349 hddLog(VOS_TRACE_LEVEL_INFO_MED,
12350 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012351 status = 0;
12352 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053012353 }
12354 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
12355 {
12356 hddLog(VOS_TRACE_LEVEL_ERROR,
12357 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012358 status = -EINVAL;
12359 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012360 }
12361#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070012362
12363 /* issue set key request to SME*/
12364 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
12365 pAdapter->sessionId, &setKey, &roamId );
12366
12367 if ( 0 != status )
12368 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012369 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
12371 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012372 status = -EINVAL;
12373 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 }
12375
12376
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012377 /* in case of IBSS as there was no information available about WEP keys during
12378 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012380 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
12381 !( ( IW_AUTH_KEY_MGMT_802_1X
12382 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
12384 )
12385 &&
12386 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
12387 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
12388 )
12389 )
12390 {
12391 setKey.keyDirection = eSIR_RX_ONLY;
12392 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
12393
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012394 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012396 __func__, setKey.peerMac[0], setKey.peerMac[1],
12397 setKey.peerMac[2], setKey.peerMac[3],
12398 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 setKey.keyDirection);
12400
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012401 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 pAdapter->sessionId, &setKey, &roamId );
12403
12404 if ( 0 != status )
12405 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012406 hddLog(VOS_TRACE_LEVEL_ERROR,
12407 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 __func__, status);
12409 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012410 status = -EINVAL;
12411 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 }
12413 }
12414 }
12415
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012416end:
12417 /* Need to clear any trace of key value in the memory.
12418 * Thus zero out the memory even though it is local
12419 * variable.
12420 */
12421 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012422 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053012423 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012424}
12425
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012426#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12427static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
12428 struct net_device *ndev,
12429 u8 key_index, bool pairwise,
12430 const u8 *mac_addr,
12431 struct key_params *params
12432 )
12433#else
12434static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
12435 struct net_device *ndev,
12436 u8 key_index, const u8 *mac_addr,
12437 struct key_params *params
12438 )
12439#endif
12440{
12441 int ret;
12442 vos_ssr_protect(__func__);
12443#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12444 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
12445 mac_addr, params);
12446#else
12447 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
12448 params);
12449#endif
12450 vos_ssr_unprotect(__func__);
12451
12452 return ret;
12453}
12454
Jeff Johnson295189b2012-06-20 16:38:30 -070012455/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012456 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 * This function is used to get the key information
12458 */
12459#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012460static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012461 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012463 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 const u8 *mac_addr, void *cookie,
12465 void (*callback)(void *cookie, struct key_params*)
12466 )
12467#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012468static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012469 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 struct net_device *ndev,
12471 u8 key_index, const u8 *mac_addr, void *cookie,
12472 void (*callback)(void *cookie, struct key_params*)
12473 )
12474#endif
12475{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012476 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012477 hdd_wext_state_t *pWextState = NULL;
12478 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012480 hdd_context_t *pHddCtx;
12481 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012482
12483 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012484
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012485 if (NULL == pAdapter)
12486 {
12487 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12488 "%s: HDD adapter is Null", __func__);
12489 return -ENODEV;
12490 }
12491
12492 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12493 ret = wlan_hdd_validate_context(pHddCtx);
12494 if (0 != ret)
12495 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053012496 return ret;
12497 }
12498
12499 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12500 pRoamProfile = &(pWextState->roamProfile);
12501
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012502 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12503 __func__, hdd_device_modetoString(pAdapter->device_mode),
12504 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012505
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 memset(&params, 0, sizeof(params));
12507
12508 if (CSR_MAX_NUM_KEY <= key_index)
12509 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012510 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012513
12514 switch(pRoamProfile->EncryptionType.encryptionType[0])
12515 {
12516 case eCSR_ENCRYPT_TYPE_NONE:
12517 params.cipher = IW_AUTH_CIPHER_NONE;
12518 break;
12519
12520 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
12521 case eCSR_ENCRYPT_TYPE_WEP40:
12522 params.cipher = WLAN_CIPHER_SUITE_WEP40;
12523 break;
12524
12525 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
12526 case eCSR_ENCRYPT_TYPE_WEP104:
12527 params.cipher = WLAN_CIPHER_SUITE_WEP104;
12528 break;
12529
12530 case eCSR_ENCRYPT_TYPE_TKIP:
12531 params.cipher = WLAN_CIPHER_SUITE_TKIP;
12532 break;
12533
12534 case eCSR_ENCRYPT_TYPE_AES:
12535 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
12536 break;
12537
12538 default:
12539 params.cipher = IW_AUTH_CIPHER_NONE;
12540 break;
12541 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012542
c_hpothuaaf19692014-05-17 17:01:48 +053012543 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12544 TRACE_CODE_HDD_CFG80211_GET_KEY,
12545 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012546
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
12548 params.seq_len = 0;
12549 params.seq = NULL;
12550 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
12551 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012552 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 return 0;
12554}
12555
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012556#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12557static int wlan_hdd_cfg80211_get_key(
12558 struct wiphy *wiphy,
12559 struct net_device *ndev,
12560 u8 key_index, bool pairwise,
12561 const u8 *mac_addr, void *cookie,
12562 void (*callback)(void *cookie, struct key_params*)
12563 )
12564#else
12565static int wlan_hdd_cfg80211_get_key(
12566 struct wiphy *wiphy,
12567 struct net_device *ndev,
12568 u8 key_index, const u8 *mac_addr, void *cookie,
12569 void (*callback)(void *cookie, struct key_params*)
12570 )
12571#endif
12572{
12573 int ret;
12574
12575 vos_ssr_protect(__func__);
12576#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12577 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
12578 mac_addr, cookie, callback);
12579#else
12580 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
12581 callback);
12582#endif
12583 vos_ssr_unprotect(__func__);
12584
12585 return ret;
12586}
12587
Jeff Johnson295189b2012-06-20 16:38:30 -070012588/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012589 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 * This function is used to delete the key information
12591 */
12592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012593static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012595 u8 key_index,
12596 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 const u8 *mac_addr
12598 )
12599#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012600static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 struct net_device *ndev,
12602 u8 key_index,
12603 const u8 *mac_addr
12604 )
12605#endif
12606{
12607 int status = 0;
12608
12609 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012610 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 //it is observed that this is invalidating peer
12612 //key index whenever re-key is done. This is affecting data link.
12613 //It should be ok to ignore del_key.
12614#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012615 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
12616 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12618 tCsrRoamSetKey setKey;
12619 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012620
Jeff Johnson295189b2012-06-20 16:38:30 -070012621 ENTER();
12622
12623 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
12624 __func__,pAdapter->device_mode);
12625
12626 if (CSR_MAX_NUM_KEY <= key_index)
12627 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012629 key_index);
12630
12631 return -EINVAL;
12632 }
12633
12634 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12635 setKey.keyId = key_index;
12636
12637 if (mac_addr)
12638 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
12639 else
12640 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
12641
12642 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
12643
12644 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012646 )
12647 {
12648
12649 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
12651 if( pHostapdState->bssState == BSS_START)
12652 {
12653 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012654
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 if ( status != eHAL_STATUS_SUCCESS )
12656 {
12657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12658 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
12659 __LINE__, status );
12660 }
12661 }
12662 }
12663 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012664 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 )
12666 {
12667 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12668
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012669 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
12670
12671 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012673 __func__, setKey.peerMac[0], setKey.peerMac[1],
12674 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012676 if(pAdapter->sessionCtx.station.conn_info.connState ==
12677 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012679 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012681
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 if ( 0 != status )
12683 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012684 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 "%s: sme_RoamSetKey failure, returned %d",
12686 __func__, status);
12687 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
12688 return -EINVAL;
12689 }
12690 }
12691 }
12692#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012693 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 return status;
12695}
12696
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012697#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12698static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12699 struct net_device *ndev,
12700 u8 key_index,
12701 bool pairwise,
12702 const u8 *mac_addr
12703 )
12704#else
12705static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
12706 struct net_device *ndev,
12707 u8 key_index,
12708 const u8 *mac_addr
12709 )
12710#endif
12711{
12712 int ret;
12713
12714 vos_ssr_protect(__func__);
12715#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12716 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
12717 mac_addr);
12718#else
12719 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
12720#endif
12721 vos_ssr_unprotect(__func__);
12722
12723 return ret;
12724}
12725
Jeff Johnson295189b2012-06-20 16:38:30 -070012726/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012727 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 * This function is used to set the default tx key index
12729 */
12730#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012731static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 struct net_device *ndev,
12733 u8 key_index,
12734 bool unicast, bool multicast)
12735#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012736static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 struct net_device *ndev,
12738 u8 key_index)
12739#endif
12740{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012741 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012742 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053012743 hdd_wext_state_t *pWextState;
12744 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012745 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012746
12747 ENTER();
12748
Gopichand Nakkala29149562013-05-10 21:43:41 +053012749 if ((NULL == pAdapter))
12750 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053012752 "invalid adapter");
12753 return -EINVAL;
12754 }
12755
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012756 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12757 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
12758 pAdapter->sessionId, key_index));
12759
Gopichand Nakkala29149562013-05-10 21:43:41 +053012760 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12761 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12762
12763 if ((NULL == pWextState) || (NULL == pHddStaCtx))
12764 {
12765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12766 "invalid Wext state or HDD context");
12767 return -EINVAL;
12768 }
12769
Arif Hussain6d2a3322013-11-17 19:50:10 -080012770 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012772
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 if (CSR_MAX_NUM_KEY <= key_index)
12774 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 key_index);
12777
12778 return -EINVAL;
12779 }
12780
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12782 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012783 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012784 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012785 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012786 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012787
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012790 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053012792 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080012793 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012794 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080012795 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012797 {
12798 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012800
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 tCsrRoamSetKey setKey;
12802 v_U32_t roamId= 0xFF;
12803 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012804
12805 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012807
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 Keys->defaultIndex = (u8)key_index;
12809 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
12810 setKey.keyId = key_index;
12811 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012812
12813 vos_mem_copy(&setKey.Key[0],
12814 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012816
Gopichand Nakkala29149562013-05-10 21:43:41 +053012817 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012818
12819 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 &pHddStaCtx->conn_info.bssId[0],
12821 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012822
Gopichand Nakkala29149562013-05-10 21:43:41 +053012823 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
12824 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
12825 eCSR_ENCRYPT_TYPE_WEP104)
12826 {
12827 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
12828 even though ap is configured for WEP-40 encryption. In this canse the key length
12829 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
12830 type(104) and switching encryption type to 40*/
12831 pWextState->roamProfile.EncryptionType.encryptionType[0] =
12832 eCSR_ENCRYPT_TYPE_WEP40;
12833 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
12834 eCSR_ENCRYPT_TYPE_WEP40;
12835 }
12836
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012837 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012839
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012841 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012843
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 if ( 0 != status )
12845 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012846 hddLog(VOS_TRACE_LEVEL_ERROR,
12847 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 status);
12849 return -EINVAL;
12850 }
12851 }
12852 }
12853
12854 /* In SoftAp mode setting key direction for default mode */
12855 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12856 {
12857 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12858 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12859 (eCSR_ENCRYPT_TYPE_AES !=
12860 pWextState->roamProfile.EncryptionType.encryptionType[0])
12861 )
12862 {
12863 /* Saving key direction for default key index to TX default */
12864 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12865 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12866 }
12867 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012868 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 return status;
12870}
12871
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012872#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12873static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12874 struct net_device *ndev,
12875 u8 key_index,
12876 bool unicast, bool multicast)
12877#else
12878static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12879 struct net_device *ndev,
12880 u8 key_index)
12881#endif
12882{
12883 int ret;
12884 vos_ssr_protect(__func__);
12885#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12886 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12887 multicast);
12888#else
12889 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12890#endif
12891 vos_ssr_unprotect(__func__);
12892
12893 return ret;
12894}
12895
Jeff Johnson295189b2012-06-20 16:38:30 -070012896/*
12897 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12898 * This function is used to inform the BSS details to nl80211 interface.
12899 */
12900static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12901 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12902{
12903 struct net_device *dev = pAdapter->dev;
12904 struct wireless_dev *wdev = dev->ieee80211_ptr;
12905 struct wiphy *wiphy = wdev->wiphy;
12906 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12907 int chan_no;
12908 int ie_length;
12909 const char *ie;
12910 unsigned int freq;
12911 struct ieee80211_channel *chan;
12912 int rssi = 0;
12913 struct cfg80211_bss *bss = NULL;
12914
Jeff Johnson295189b2012-06-20 16:38:30 -070012915 if( NULL == pBssDesc )
12916 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012917 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 return bss;
12919 }
12920
12921 chan_no = pBssDesc->channelId;
12922 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12923 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12924
12925 if( NULL == ie )
12926 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012927 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 return bss;
12929 }
12930
12931#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12932 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12933 {
12934 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12935 }
12936 else
12937 {
12938 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12939 }
12940#else
12941 freq = ieee80211_channel_to_frequency(chan_no);
12942#endif
12943
12944 chan = __ieee80211_get_channel(wiphy, freq);
12945
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012946 if (!chan) {
12947 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12948 return NULL;
12949 }
12950
Abhishek Singhaee43942014-06-16 18:55:47 +053012951 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012952
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012953 return cfg80211_inform_bss(wiphy, chan,
12954#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12955 CFG80211_BSS_FTYPE_UNKNOWN,
12956#endif
12957 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012958 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 pBssDesc->capabilityInfo,
12960 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012961 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012962}
12963
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012964/*
12965 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12966 * interface that BSS might have been lost.
12967 * @pAdapter: adaptor
12968 * @bssid: bssid which might have been lost
12969 *
12970 * Return: bss which is unlinked from kernel cache
12971 */
12972struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12973 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12974{
12975 struct net_device *dev = pAdapter->dev;
12976 struct wireless_dev *wdev = dev->ieee80211_ptr;
12977 struct wiphy *wiphy = wdev->wiphy;
12978 struct cfg80211_bss *bss = NULL;
12979
Abhishek Singh5a597e62016-12-05 15:16:30 +053012980 bss = hdd_get_bss_entry(wiphy,
12981 NULL, bssid,
12982 NULL, 0);
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012983 if (bss == NULL) {
12984 hddLog(LOGE, FL("BSS not present"));
12985 } else {
12986 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12987 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12988 cfg80211_unlink_bss(wiphy, bss);
12989 }
12990 return bss;
12991}
Jeff Johnson295189b2012-06-20 16:38:30 -070012992
12993
12994/*
12995 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12996 * This function is used to inform the BSS details to nl80211 interface.
12997 */
12998struct cfg80211_bss*
12999wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
13000 tSirBssDescription *bss_desc
13001 )
13002{
13003 /*
13004 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
13005 already exists in bss data base of cfg80211 for that particular BSS ID.
13006 Using cfg80211_inform_bss_frame to update the bss entry instead of
13007 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
13008 now there is no possibility to get the mgmt(probe response) frame from PE,
13009 converting bss_desc to ieee80211_mgmt(probe response) and passing to
13010 cfg80211_inform_bss_frame.
13011 */
13012 struct net_device *dev = pAdapter->dev;
13013 struct wireless_dev *wdev = dev->ieee80211_ptr;
13014 struct wiphy *wiphy = wdev->wiphy;
13015 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080013016#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
13017 qcom_ie_age *qie_age = NULL;
13018 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
13019#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080013021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013022 const char *ie =
13023 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
13024 unsigned int freq;
13025 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053013026 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 struct cfg80211_bss *bss_status = NULL;
13028 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
13029 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070013030 hdd_context_t *pHddCtx;
13031 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070013032#ifdef WLAN_OPEN_SOURCE
13033 struct timespec ts;
13034#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013035
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013036
Wilson Yangf80a0542013-10-07 13:02:37 -070013037 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13038 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070013039 if (0 != status)
13040 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070013041 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070013042 }
13043
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053013044 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070013045 if (!mgmt)
13046 {
13047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13048 "%s: memory allocation failed ", __func__);
13049 return NULL;
13050 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070013051
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013053
13054#ifdef WLAN_OPEN_SOURCE
13055 /* Android does not want the timestamp from the frame.
13056 Instead it wants a monotonic increasing value */
13057 get_monotonic_boottime(&ts);
13058 mgmt->u.probe_resp.timestamp =
13059 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
13060#else
13061 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
13063 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070013064
13065#endif
13066
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
13068 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080013069
13070#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
13071 /* GPS Requirement: need age ie per entry. Using vendor specific. */
13072 /* Assuming this is the last IE, copy at the end */
13073 ie_length -=sizeof(qcom_ie_age);
13074 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
13075 qie_age->element_id = QCOM_VENDOR_IE_ID;
13076 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
13077 qie_age->oui_1 = QCOM_OUI1;
13078 qie_age->oui_2 = QCOM_OUI2;
13079 qie_age->oui_3 = QCOM_OUI3;
13080 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053013081 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
13082 * bss related timestamp is in units of ms. Due to this when scan results
13083 * are sent to lowi the scan age is high.To address this, send age in units
13084 * of 1/10 ms.
13085 */
13086 qie_age->age = (vos_timer_get_system_time() -
13087 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080013088#endif
13089
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053013091 if (bss_desc->fProbeRsp)
13092 {
13093 mgmt->frame_control |=
13094 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
13095 }
13096 else
13097 {
13098 mgmt->frame_control |=
13099 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
13100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013101
13102#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013103 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
13105 {
13106 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
13107 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013108 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
13110
13111 {
13112 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
13113 }
13114 else
13115 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013116 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
13117 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 kfree(mgmt);
13119 return NULL;
13120 }
13121#else
13122 freq = ieee80211_channel_to_frequency(chan_no);
13123#endif
13124 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080013125 /*when the band is changed on the fly using the GUI, three things are done
13126 * 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)
13127 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
13128 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
13129 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
13130 * and discards the channels correponding to previous band and calls back with zero bss results.
13131 * 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
13132 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
13133 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
13134 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
13135 * So drop the bss and continue to next bss.
13136 */
13137 if(chan == NULL)
13138 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053013139 hddLog(VOS_TRACE_LEVEL_ERROR,
13140 FL("chan pointer is NULL, chan_no: %d freq: %d"),
13141 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070013142 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080013143 return NULL;
13144 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053013145 /*To keep the rssi icon of the connected AP in the scan window
13146 *and the rssi icon of the wireless networks in sync
13147 * */
13148 if (( eConnectionState_Associated ==
13149 pAdapter->sessionCtx.station.conn_info.connState ) &&
13150 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
13151 pAdapter->sessionCtx.station.conn_info.bssId,
13152 WNI_CFG_BSSID_LEN)) &&
13153 (pHddCtx->hdd_wlan_suspended == FALSE))
13154 {
13155 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
13156 rssi = (pAdapter->rssi * 100);
13157 }
13158 else
13159 {
13160 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
13161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013162
Nirav Shah20ac06f2013-12-12 18:14:06 +053013163 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053013164 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
13165 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053013166
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
13168 frame_len, rssi, GFP_KERNEL);
13169 kfree(mgmt);
13170 return bss_status;
13171}
13172
13173/*
13174 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
13175 * This function is used to update the BSS data base of CFG8011
13176 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013177struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 tCsrRoamInfo *pRoamInfo
13179 )
13180{
13181 tCsrRoamConnectedProfile roamProfile;
13182 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13183 struct cfg80211_bss *bss = NULL;
13184
13185 ENTER();
13186
13187 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
13188 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
13189
13190 if (NULL != roamProfile.pBssDesc)
13191 {
Girish Gowlif4b68022014-08-28 23:18:57 +053013192 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
13193 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013194
13195 if (NULL == bss)
13196 {
13197 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
13198 __func__);
13199 }
13200
13201 sme_RoamFreeConnectProfile(hHal, &roamProfile);
13202 }
13203 else
13204 {
13205 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
13206 __func__);
13207 }
13208 return bss;
13209}
13210
13211/*
13212 * FUNCTION: wlan_hdd_cfg80211_update_bss
13213 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013214static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
13215 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013217{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013218 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 tCsrScanResultInfo *pScanResult;
13220 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013221 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 tScanResultHandle pResult;
13223 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070013224 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013225 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013227
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013228 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13229 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
13230 NO_SESSION, pAdapter->sessionId));
13231
Wilson Yangf80a0542013-10-07 13:02:37 -070013232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013233 ret = wlan_hdd_validate_context(pHddCtx);
13234 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013236 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070013237 }
13238
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013239 if (pAdapter->request != NULL)
13240 {
13241 if ((pAdapter->request->n_ssids == 1)
13242 && (pAdapter->request->ssids != NULL)
13243 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
13244 is_p2p_scan = true;
13245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 /*
13247 * start getting scan results and populate cgf80211 BSS database
13248 */
13249 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
13250
13251 /* no scan results */
13252 if (NULL == pResult)
13253 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013254 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
13255 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013256 wlan_hdd_get_frame_logs(pAdapter,
13257 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 return status;
13259 }
13260
13261 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
13262
13263 while (pScanResult)
13264 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013265 /*
13266 * cfg80211_inform_bss() is not updating ie field of bss entry, if
13267 * entry already exists in bss data base of cfg80211 for that
13268 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
13269 * bss entry instead of cfg80211_inform_bss, But this call expects
13270 * mgmt packet as input. As of now there is no possibility to get
13271 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 * ieee80211_mgmt(probe response) and passing to c
13273 * fg80211_inform_bss_frame.
13274 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013275 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
13276 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
13277 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013278 pScanResult = sme_ScanResultGetNext(hHal, pResult);
13279 continue; //Skip the non p2p bss entries
13280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
13282 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013283
Jeff Johnson295189b2012-06-20 16:38:30 -070013284
13285 if (NULL == bss_status)
13286 {
13287 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013288 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 }
13290 else
13291 {
Yue Maf49ba872013-08-19 12:04:25 -070013292 cfg80211_put_bss(
13293#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
13294 wiphy,
13295#endif
13296 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 }
13298
13299 pScanResult = sme_ScanResultGetNext(hHal, pResult);
13300 }
13301
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013302 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053013303 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013304 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013305}
13306
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013307void
13308hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
13309{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013310 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080013311 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013312} /****** end hddPrintMacAddr() ******/
13313
13314void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013315hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013316{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013317 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013318 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013319 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
13320 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
13321 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013322} /****** end hddPrintPmkId() ******/
13323
13324//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
13325//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
13326
13327//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
13328//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
13329
13330#define dump_bssid(bssid) \
13331 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070013332 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
13333 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013334 }
13335
13336#define dump_pmkid(pMac, pmkid) \
13337 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070013338 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
13339 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013340 }
13341
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070013342#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013343/*
13344 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
13345 * This function is used to notify the supplicant of a new PMKSA candidate.
13346 */
13347int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013348 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013349 int index, bool preauth )
13350{
Jeff Johnsone7245742012-09-05 17:12:55 -070013351#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013352 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070013353 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013354
13355 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070013356 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013357
13358 if( NULL == pRoamInfo )
13359 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013360 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013361 return -EINVAL;
13362 }
13363
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070013364 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
13365 {
13366 dump_bssid(pRoamInfo->bssid);
13367 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013368 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070013369 }
Jeff Johnsone7245742012-09-05 17:12:55 -070013370#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013371 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013372}
13373#endif //FEATURE_WLAN_LFR
13374
Yue Maef608272013-04-08 23:09:17 -070013375#ifdef FEATURE_WLAN_LFR_METRICS
13376/*
13377 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
13378 * 802.11r/LFR metrics reporting function to report preauth initiation
13379 *
13380 */
13381#define MAX_LFR_METRICS_EVENT_LENGTH 100
13382VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
13383 tCsrRoamInfo *pRoamInfo)
13384{
13385 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
13386 union iwreq_data wrqu;
13387
13388 ENTER();
13389
13390 if (NULL == pAdapter)
13391 {
13392 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
13393 return VOS_STATUS_E_FAILURE;
13394 }
13395
13396 /* create the event */
13397 memset(&wrqu, 0, sizeof(wrqu));
13398 memset(metrics_notification, 0, sizeof(metrics_notification));
13399
13400 wrqu.data.pointer = metrics_notification;
13401 wrqu.data.length = scnprintf(metrics_notification,
13402 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
13403 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
13404
13405 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
13406
13407 EXIT();
13408
13409 return VOS_STATUS_SUCCESS;
13410}
13411
13412/*
13413 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
13414 * 802.11r/LFR metrics reporting function to report preauth completion
13415 * or failure
13416 */
13417VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
13418 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
13419{
13420 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
13421 union iwreq_data wrqu;
13422
13423 ENTER();
13424
13425 if (NULL == pAdapter)
13426 {
13427 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
13428 return VOS_STATUS_E_FAILURE;
13429 }
13430
13431 /* create the event */
13432 memset(&wrqu, 0, sizeof(wrqu));
13433 memset(metrics_notification, 0, sizeof(metrics_notification));
13434
13435 scnprintf(metrics_notification, sizeof(metrics_notification),
13436 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
13437 MAC_ADDR_ARRAY(pRoamInfo->bssid));
13438
13439 if (1 == preauth_status)
13440 strncat(metrics_notification, " TRUE", 5);
13441 else
13442 strncat(metrics_notification, " FALSE", 6);
13443
13444 wrqu.data.pointer = metrics_notification;
13445 wrqu.data.length = strlen(metrics_notification);
13446
13447 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
13448
13449 EXIT();
13450
13451 return VOS_STATUS_SUCCESS;
13452}
13453
13454/*
13455 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
13456 * 802.11r/LFR metrics reporting function to report handover initiation
13457 *
13458 */
13459VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
13460 tCsrRoamInfo *pRoamInfo)
13461{
13462 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
13463 union iwreq_data wrqu;
13464
13465 ENTER();
13466
13467 if (NULL == pAdapter)
13468 {
13469 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
13470 return VOS_STATUS_E_FAILURE;
13471 }
13472
13473 /* create the event */
13474 memset(&wrqu, 0, sizeof(wrqu));
13475 memset(metrics_notification, 0, sizeof(metrics_notification));
13476
13477 wrqu.data.pointer = metrics_notification;
13478 wrqu.data.length = scnprintf(metrics_notification,
13479 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
13480 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
13481
13482 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
13483
13484 EXIT();
13485
13486 return VOS_STATUS_SUCCESS;
13487}
13488#endif
13489
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013490
13491/**
13492 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
13493 * @scan_req: scan request to be checked
13494 *
13495 * Return: true or false
13496 */
13497#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
13498static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
13499 cfg80211_scan_request
13500 *scan_req)
13501{
13502 if (!scan_req || !scan_req->wiphy) {
13503 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
13504 return false;
13505 }
13506 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
13507 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
13508 return false;
13509 }
13510 return true;
13511}
13512#else
13513static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
13514 cfg80211_scan_request
13515 *scan_req)
13516{
13517 if (!scan_req || !scan_req->wiphy) {
13518 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
13519 return false;
13520 }
13521 return true;
13522}
13523#endif
13524
13525
Jeff Johnson295189b2012-06-20 16:38:30 -070013526/*
13527 * FUNCTION: hdd_cfg80211_scan_done_callback
13528 * scanning callback function, called after finishing scan
13529 *
13530 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013531static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
13533{
13534 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013535 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013537 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 struct cfg80211_scan_request *req = NULL;
13539 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013540 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013541#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13542 bool iface_down = false;
13543#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013544 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013545 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013546 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013547
13548 ENTER();
13549
c_manjee1b4ab9a2016-10-26 11:36:55 +053013550 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
13551 !pAdapter->dev) {
13552 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
13553 return 0;
13554 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013555 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053013556 if (NULL == pHddCtx) {
13557 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013558 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013559 }
13560
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053013561#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13562 if (!(pAdapter->dev->flags & IFF_UP))
13563 {
13564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013565 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053013566 }
13567#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053013568 pScanInfo = &pHddCtx->scan_info;
13569
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 hddLog(VOS_TRACE_LEVEL_INFO,
13571 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080013572 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 __func__, halHandle, pContext, (int) scanId, (int) status);
13574
Kiet Lamac06e2c2013-10-23 16:25:07 +053013575 pScanInfo->mScanPendingCounter = 0;
13576
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013578 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 &pScanInfo->scan_req_completion_event,
13580 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013581 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013583 hddLog(VOS_TRACE_LEVEL_ERROR,
13584 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070013586 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 }
13588
Yue Maef608272013-04-08 23:09:17 -070013589 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 {
13591 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070013592 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 }
13594
13595 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013596 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 {
13598 hddLog(VOS_TRACE_LEVEL_INFO,
13599 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080013600 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 (int) scanId);
13602 }
13603
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013604#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013605 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013606#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013607 {
13608 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
13609 pAdapter);
13610 if (0 > ret)
13611 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053013612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013613
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 /* If any client wait scan result through WEXT
13615 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013616 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 {
13618 /* The other scan request waiting for current scan finish
13619 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013620 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013622 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 }
13624 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013625 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 {
13627 struct net_device *dev = pAdapter->dev;
13628 union iwreq_data wrqu;
13629 int we_event;
13630 char *msg;
13631
13632 memset(&wrqu, '\0', sizeof(wrqu));
13633 we_event = SIOCGIWSCAN;
13634 msg = NULL;
13635 wireless_send_event(dev, we_event, &wrqu, msg);
13636 }
13637 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070013638 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013639
13640 /* Get the Scan Req */
13641 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053013642 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013644 /* Scan is no longer pending */
13645 pScanInfo->mScanPending = VOS_FALSE;
13646
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013647 if (!wlan_hdd_cfg80211_validate_scan_req(req))
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053013649#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13650 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
13651 iface_down ? "up" : "down");
13652#endif
13653
13654 if (pAdapter->dev) {
13655 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
13656 pAdapter->dev->name);
13657 }
mukul sharmae7041822015-12-03 15:09:21 +053013658 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070013659 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 }
13661
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013662 /* last_scan_timestamp is used to decide if new scan
13663 * is needed or not on station interface. If last station
13664 * scan time and new station scan time is less then
13665 * last_scan_timestamp ; driver will return cached scan.
13666 */
13667 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
13668 {
13669 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
13670
13671 if ( req->n_channels )
13672 {
13673 for (i = 0; i < req->n_channels ; i++ )
13674 {
13675 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
13676 }
13677 /* store no of channel scanned */
13678 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
13679 }
13680
13681 }
13682
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070013683 /*
13684 * cfg80211_scan_done informing NL80211 about completion
13685 * of scanning
13686 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053013687 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
13688 {
13689 aborted = true;
13690 }
mukul sharmae7041822015-12-03 15:09:21 +053013691
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013692#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13693 if (!iface_down)
13694#endif
13695 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053013696
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080013697 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070013698
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013699allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013700 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
13701 ) && (pHddCtx->spoofMacAddr.isEnabled
13702 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053013703 /* Generate new random mac addr for next scan */
13704 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053013705
13706 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
13707 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053013708 }
13709
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013710 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013711 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013712
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013713 /* Acquire wakelock to handle the case where APP's tries to suspend
13714 * immediatly after the driver gets connect request(i.e after scan)
13715 * from supplicant, this result in app's is suspending and not able
13716 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013717 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070013718
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013719#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
13720 if (!iface_down)
13721#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013722#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053013723 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070013724#endif
13725
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 EXIT();
13727 return 0;
13728}
13729
13730/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053013731 * FUNCTION: hdd_isConnectionInProgress
13732 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013733 *
13734 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013735v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
13736 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013737{
13738 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
13739 hdd_station_ctx_t *pHddStaCtx = NULL;
13740 hdd_adapter_t *pAdapter = NULL;
13741 VOS_STATUS status = 0;
13742 v_U8_t staId = 0;
13743 v_U8_t *staMac = NULL;
13744
13745 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
13746
13747 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
13748 {
13749 pAdapter = pAdapterNode->pAdapter;
13750
13751 if( pAdapter )
13752 {
13753 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013754 "%s: Adapter with device mode %s (%d) exists",
13755 __func__, hdd_device_modetoString(pAdapter->device_mode),
13756 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013757 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053013758 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13759 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
13760 (eConnectionState_Connecting ==
13761 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13762 {
13763 hddLog(VOS_TRACE_LEVEL_ERROR,
13764 "%s: %p(%d) Connection is in progress", __func__,
13765 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013766 if (session_id && reason)
13767 {
13768 *session_id = pAdapter->sessionId;
13769 *reason = eHDD_CONNECTION_IN_PROGRESS;
13770 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013771 return VOS_TRUE;
13772 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013773 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053013774 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013775 {
13776 hddLog(VOS_TRACE_LEVEL_ERROR,
13777 "%s: %p(%d) Reassociation is in progress", __func__,
13778 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013779 if (session_id && reason)
13780 {
13781 *session_id = pAdapter->sessionId;
13782 *reason = eHDD_REASSOC_IN_PROGRESS;
13783 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013784 return VOS_TRUE;
13785 }
13786 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013787 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13788 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013789 {
13790 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13791 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013792 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013793 {
13794 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
13795 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013796 "%s: client " MAC_ADDRESS_STR
13797 " is in the middle of WPS/EAPOL exchange.", __func__,
13798 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013799 if (session_id && reason)
13800 {
13801 *session_id = pAdapter->sessionId;
13802 *reason = eHDD_EAPOL_IN_PROGRESS;
13803 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013804 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013805 }
13806 }
13807 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
13808 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
13809 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013810 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13811 ptSapContext pSapCtx = NULL;
13812 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13813 if(pSapCtx == NULL){
13814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13815 FL("psapCtx is NULL"));
13816 return VOS_FALSE;
13817 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013818 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
13819 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013820 if ((pSapCtx->aStaInfo[staId].isUsed) &&
13821 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013822 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013823 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013824
13825 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080013826 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
13827 "middle of WPS/EAPOL exchange.", __func__,
13828 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013829 if (session_id && reason)
13830 {
13831 *session_id = pAdapter->sessionId;
13832 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
13833 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013834 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013835 }
13836 }
13837 }
13838 }
13839 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13840 pAdapterNode = pNext;
13841 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013842 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013843}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013844
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013845/**
13846 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
13847 * to the Scan request
13848 * @scanRequest: Pointer to the csr scan request
13849 * @request: Pointer to the scan request from supplicant
13850 *
13851 * Return: None
13852 */
13853#ifdef CFG80211_SCAN_BSSID
13854static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13855 struct cfg80211_scan_request *request)
13856{
13857 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13858}
13859#else
13860static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13861 struct cfg80211_scan_request *request)
13862{
13863}
13864#endif
13865
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013866/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013867 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 * this scan respond to scan trigger and update cfg80211 scan database
13869 * later, scan dump command can be used to recieve scan results
13870 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013871int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013872#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13873 struct net_device *dev,
13874#endif
13875 struct cfg80211_scan_request *request)
13876{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013877 hdd_adapter_t *pAdapter = NULL;
13878 hdd_context_t *pHddCtx = NULL;
13879 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013880 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 tCsrScanRequest scanRequest;
13882 tANI_U8 *channelList = NULL, i;
13883 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013884 int status;
13885 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013887 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013888 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013889 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013890 v_U8_t curr_session_id;
13891 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013892
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013893#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13894 struct net_device *dev = NULL;
13895 if (NULL == request)
13896 {
13897 hddLog(VOS_TRACE_LEVEL_ERROR,
13898 "%s: scan req param null", __func__);
13899 return -EINVAL;
13900 }
13901 dev = request->wdev->netdev;
13902#endif
13903
13904 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13905 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13906 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13907
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 ENTER();
13909
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013910 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13911 __func__, hdd_device_modetoString(pAdapter->device_mode),
13912 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013913
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013914 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013915 if (0 != status)
13916 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013917 return status;
13918 }
13919
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013920 if (NULL == pwextBuf)
13921 {
13922 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13923 __func__);
13924 return -EIO;
13925 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013926 cfg_param = pHddCtx->cfg_ini;
13927 pScanInfo = &pHddCtx->scan_info;
13928
Jeff Johnson295189b2012-06-20 16:38:30 -070013929#ifdef WLAN_BTAMP_FEATURE
13930 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013931 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013933 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 "%s: No scanning when AMP is on", __func__);
13935 return -EOPNOTSUPP;
13936 }
13937#endif
13938 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013939 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013941 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013942 "%s: Not scanning on device_mode = %s (%d)",
13943 __func__, hdd_device_modetoString(pAdapter->device_mode),
13944 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 return -EOPNOTSUPP;
13946 }
13947
13948 if (TRUE == pScanInfo->mScanPending)
13949 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013950 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13951 {
13952 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13953 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013954 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 }
13956
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013957 // Don't allow scan if PNO scan is going on.
13958 if (pHddCtx->isPnoEnable)
13959 {
13960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13961 FL("pno scan in progress"));
13962 return -EBUSY;
13963 }
13964
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013965 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013966 //Channel and action frame is pending
13967 //Otherwise Cancel Remain On Channel and allow Scan
13968 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013969 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013970 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013971 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013972 return -EBUSY;
13973 }
13974
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13976 {
13977 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013978 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13982 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013983 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 "%s: MAX TM Level Scan not allowed", __func__);
13985 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013986 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 }
13988 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13989
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013990 /* Check if scan is allowed at this point of time.
13991 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013992 if (TRUE == pHddCtx->btCoexModeSet)
13993 {
13994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13995 FL("BTCoex Mode operation in progress"));
13996 return -EBUSY;
13997 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013998 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013999 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053014000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053014001 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
14002 pHddCtx->last_scan_reject_reason != curr_reason ||
14003 !pHddCtx->last_scan_reject_timestamp)
14004 {
14005 pHddCtx->last_scan_reject_session_id = curr_session_id;
14006 pHddCtx->last_scan_reject_reason = curr_reason;
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053014007 pHddCtx->last_scan_reject_timestamp = jiffies_to_msecs(jiffies);
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053014008 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053014009 else {
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053014010 if ((jiffies_to_msecs(jiffies) -
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053014011 pHddCtx->last_scan_reject_timestamp) >=
14012 SCAN_REJECT_THRESHOLD_TIME)
14013 {
14014 pHddCtx->last_scan_reject_timestamp = 0;
14015 if (pHddCtx->cfg_ini->enableFatalEvent)
14016 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
14017 WLAN_LOG_INDICATOR_HOST_DRIVER,
14018 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
14019 FALSE, FALSE);
14020 else
14021 {
14022 hddLog(LOGE, FL("Triggering SSR"));
14023 vos_wlanRestart();
14024 }
14025 }
14026 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080014027 return -EBUSY;
14028 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053014029 pHddCtx->last_scan_reject_timestamp = 0;
14030 pHddCtx->last_scan_reject_session_id = 0xFF;
14031 pHddCtx->last_scan_reject_reason = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014032
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 vos_mem_zero( &scanRequest, sizeof(scanRequest));
14034
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014035 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
14036 * Becasue of this, driver is assuming that this is not wildcard scan and so
14037 * is not aging out the scan results.
14038 */
14039 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014041 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014043
14044 if ((request->ssids) && (0 < request->n_ssids))
14045 {
14046 tCsrSSIDInfo *SsidInfo;
14047 int j;
14048 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
14049 /* Allocate num_ssid tCsrSSIDInfo structure */
14050 SsidInfo = scanRequest.SSIDs.SSIDList =
14051 ( tCsrSSIDInfo *)vos_mem_malloc(
14052 request->n_ssids*sizeof(tCsrSSIDInfo));
14053
14054 if(NULL == scanRequest.SSIDs.SSIDList)
14055 {
14056 hddLog(VOS_TRACE_LEVEL_ERROR,
14057 "%s: memory alloc failed SSIDInfo buffer", __func__);
14058 return -ENOMEM;
14059 }
14060
14061 /* copy all the ssid's and their length */
14062 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
14063 {
14064 /* get the ssid length */
14065 SsidInfo->SSID.length = request->ssids[j].ssid_len;
14066 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
14067 SsidInfo->SSID.length);
14068 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
14069 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
14070 j, SsidInfo->SSID.ssId);
14071 }
14072 /* set the scan type to active */
14073 scanRequest.scanType = eSIR_ACTIVE_SCAN;
14074 }
14075 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053014077 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14078 TRACE_CODE_HDD_CFG80211_SCAN,
14079 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 /* set the scan type to active */
14081 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014083 else
14084 {
14085 /*Set the scan type to default type, in this case it is ACTIVE*/
14086 scanRequest.scanType = pScanInfo->scan_mode;
14087 }
14088 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
14089 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070014090
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053014091 csr_scan_request_assign_bssid(&scanRequest, request);
14092
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 /* set BSSType to default type */
14094 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
14095
14096 /*TODO: scan the requested channels only*/
14097
14098 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014099 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014101 hddLog(VOS_TRACE_LEVEL_WARN,
14102 "No of Scan Channels exceeded limit: %d", request->n_channels);
14103 request->n_channels = MAX_CHANNEL;
14104 }
14105
14106 hddLog(VOS_TRACE_LEVEL_INFO,
14107 "No of Scan Channels: %d", request->n_channels);
14108
14109
14110 if( request->n_channels )
14111 {
14112 char chList [(request->n_channels*5)+1];
14113 int len;
14114 channelList = vos_mem_malloc( request->n_channels );
14115 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053014116 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014117 hddLog(VOS_TRACE_LEVEL_ERROR,
14118 "%s: memory alloc failed channelList", __func__);
14119 status = -ENOMEM;
14120 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053014121 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014122
14123 for( i = 0, len = 0; i < request->n_channels ; i++ )
14124 {
14125 channelList[i] = request->channels[i]->hw_value;
14126 len += snprintf(chList+len, 5, "%d ", channelList[i]);
14127 }
14128
Nirav Shah20ac06f2013-12-12 18:14:06 +053014129 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014130 "Channel-List: %s ", chList);
14131 }
c_hpothu53512302014-04-15 18:49:53 +053014132
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014133 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
14134 scanRequest.ChannelInfo.ChannelList = channelList;
14135
14136 /* set requestType to full scan */
14137 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
14138
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014139 /* if there is back to back scan happening in driver with in
14140 * nDeferScanTimeInterval interval driver should defer new scan request
14141 * and should provide last cached scan results instead of new channel list.
14142 * This rule is not applicable if scan is p2p scan.
14143 * This condition will work only in case when last request no of channels
14144 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053014145 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053014146 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014147 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014148
Sushant Kaushik86592172015-04-27 16:35:03 +053014149 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
14150 /* if wps ie is NULL , then only defer scan */
14151 if ( pWpsIe == NULL &&
14152 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053014153 {
14154 if ( pScanInfo->last_scan_timestamp !=0 &&
14155 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
14156 {
14157 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
14158 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
14159 vos_mem_compare(pScanInfo->last_scan_channelList,
14160 channelList, pScanInfo->last_scan_numChannels))
14161 {
14162 hddLog(VOS_TRACE_LEVEL_WARN,
14163 " New and old station scan time differ is less then %u",
14164 pHddCtx->cfg_ini->nDeferScanTimeInterval);
14165
14166 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014167 pAdapter);
14168
Agarwal Ashish57e84372014-12-05 18:26:53 +053014169 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053014170 "Return old cached scan as all channels and no of channels are same");
14171
Agarwal Ashish57e84372014-12-05 18:26:53 +053014172 if (0 > ret)
14173 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014174
Agarwal Ashish57e84372014-12-05 18:26:53 +053014175 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053014176
14177 status = eHAL_STATUS_SUCCESS;
14178 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053014179 }
14180 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053014181 }
14182
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014183 /* Flush the scan results(only p2p beacons) for STA scan and P2P
14184 * search (Flush on both full scan and social scan but not on single
14185 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
14186 */
14187
14188 /* Supplicant does single channel scan after 8-way handshake
14189 * and in that case driver shoudnt flush scan results. If
14190 * driver flushes the scan results here and unfortunately if
14191 * the AP doesnt respond to our probe req then association
14192 * fails which is not desired
14193 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053014194 if ((request->n_ssids == 1)
14195 && (request->ssids != NULL)
14196 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
14197 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014198
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053014199 if( is_p2p_scan ||
14200 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014201 {
14202 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
14203 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
14204 pAdapter->sessionId );
14205 }
14206
14207 if( request->ie_len )
14208 {
14209 /* save this for future association (join requires this) */
14210 /*TODO: Array needs to be converted to dynamic allocation,
14211 * as multiple ie.s can be sent in cfg80211_scan_request structure
14212 * CR 597966
14213 */
14214 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
14215 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
14216 pScanInfo->scanAddIE.length = request->ie_len;
14217
14218 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
14219 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
14220 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014222 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014224 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
14225 memcpy( pwextBuf->roamProfile.addIEScan,
14226 request->ie, request->ie_len);
14227 }
14228 else
14229 {
14230 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
14231 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 }
14233
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014234 }
14235 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
14236 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
14237
14238 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
14239 request->ie_len);
14240 if (pP2pIe != NULL)
14241 {
14242#ifdef WLAN_FEATURE_P2P_DEBUG
14243 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
14244 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
14245 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053014246 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014247 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
14248 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
14249 "Go nego completed to Connection is started");
14250 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
14251 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053014252 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014253 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
14254 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014256 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
14257 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
14258 "Disconnected state to Connection is started");
14259 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
14260 "for 4way Handshake");
14261 }
14262#endif
14263
14264 /* no_cck will be set during p2p find to disable 11b rates */
14265 if(TRUE == request->no_cck)
14266 {
14267 hddLog(VOS_TRACE_LEVEL_INFO,
14268 "%s: This is a P2P Search", __func__);
14269 scanRequest.p2pSearch = 1;
14270
14271 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053014272 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014273 /* set requestType to P2P Discovery */
14274 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
14275 }
14276
14277 /*
14278 Skip Dfs Channel in case of P2P Search
14279 if it is set in ini file
14280 */
14281 if(cfg_param->skipDfsChnlInP2pSearch)
14282 {
14283 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014284 }
14285 else
14286 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053014287 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014289
Agarwal Ashish4f616132013-12-30 23:32:50 +053014290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 }
14292 }
14293
14294 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
14295
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014296#ifdef FEATURE_WLAN_TDLS
14297 /* if tdls disagree scan right now, return immediately.
14298 tdls will schedule the scan when scan is allowed. (return SUCCESS)
14299 or will reject the scan if any TDLS is in progress. (return -EBUSY)
14300 */
14301 status = wlan_hdd_tdls_scan_callback (pAdapter,
14302 wiphy,
14303#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
14304 dev,
14305#endif
14306 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053014307 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014308 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053014309 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
14311 "scan rejected %d", __func__, status);
14312 else
14313 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
14314 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053014315 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053014316 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014317 }
14318#endif
14319
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070014320 /* acquire the wakelock to avoid the apps suspend during the scan. To
14321 * address the following issues.
14322 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
14323 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
14324 * for long time, this result in apps running at full power for long time.
14325 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
14326 * be stuck in full power because of resume BMPS
14327 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053014328 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070014329
Nirav Shah20ac06f2013-12-12 18:14:06 +053014330 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
14331 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014332 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
14333 scanRequest.requestType, scanRequest.scanType,
14334 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053014335 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
14336
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053014337 if (pHddCtx->spoofMacAddr.isEnabled &&
14338 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053014339 {
14340 hddLog(VOS_TRACE_LEVEL_INFO,
14341 "%s: MAC Spoofing enabled for current scan", __func__);
14342 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
14343 * to fill TxBds for probe request during current scan
14344 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014345 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053014346 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014347
14348 if(status != VOS_STATUS_SUCCESS)
14349 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053014350 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014351 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053014352#ifdef FEATURE_WLAN_TDLS
14353 wlan_hdd_tdls_scan_done_callback(pAdapter);
14354#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053014355 goto free_mem;
14356 }
Siddharth Bhal76972212014-10-15 16:22:51 +053014357 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053014358 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070014359 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 pAdapter->sessionId, &scanRequest, &scanId,
14361 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070014362
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 if (eHAL_STATUS_SUCCESS != status)
14364 {
14365 hddLog(VOS_TRACE_LEVEL_ERROR,
14366 "%s: sme_ScanRequest returned error %d", __func__, status);
14367 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070014368 if(eHAL_STATUS_RESOURCES == status)
14369 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053014370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
14371 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070014372 status = -EBUSY;
14373 } else {
14374 status = -EIO;
14375 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053014376 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053014377
14378#ifdef FEATURE_WLAN_TDLS
14379 wlan_hdd_tdls_scan_done_callback(pAdapter);
14380#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014381 goto free_mem;
14382 }
14383
14384 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053014385 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 pAdapter->request = request;
14387 pScanInfo->scanId = scanId;
14388
14389 complete(&pScanInfo->scan_req_completion_event);
14390
14391free_mem:
14392 if( scanRequest.SSIDs.SSIDList )
14393 {
14394 vos_mem_free(scanRequest.SSIDs.SSIDList);
14395 }
14396
14397 if( channelList )
14398 vos_mem_free( channelList );
14399
14400 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 return status;
14402}
14403
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014404int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
14405#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
14406 struct net_device *dev,
14407#endif
14408 struct cfg80211_scan_request *request)
14409{
14410 int ret;
14411
14412 vos_ssr_protect(__func__);
14413 ret = __wlan_hdd_cfg80211_scan(wiphy,
14414#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
14415 dev,
14416#endif
14417 request);
14418 vos_ssr_unprotect(__func__);
14419
14420 return ret;
14421}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014422
14423void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
14424{
14425 v_U8_t iniDot11Mode =
14426 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
14427 eHddDot11Mode hddDot11Mode = iniDot11Mode;
14428
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014429 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
14430 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014431 switch ( iniDot11Mode )
14432 {
14433 case eHDD_DOT11_MODE_AUTO:
14434 case eHDD_DOT11_MODE_11ac:
14435 case eHDD_DOT11_MODE_11ac_ONLY:
14436#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053014437 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
14438 sme_IsFeatureSupportedByFW(DOT11AC) )
14439 hddDot11Mode = eHDD_DOT11_MODE_11ac;
14440 else
14441 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014442#else
14443 hddDot11Mode = eHDD_DOT11_MODE_11n;
14444#endif
14445 break;
14446 case eHDD_DOT11_MODE_11n:
14447 case eHDD_DOT11_MODE_11n_ONLY:
14448 hddDot11Mode = eHDD_DOT11_MODE_11n;
14449 break;
14450 default:
14451 hddDot11Mode = iniDot11Mode;
14452 break;
14453 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053014454#ifdef WLAN_FEATURE_AP_HT40_24G
14455 if (operationChannel > SIR_11B_CHANNEL_END)
14456#endif
14457 {
14458 /* This call decides required channel bonding mode */
14459 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014460 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
14461 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053014462 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014463}
14464
Jeff Johnson295189b2012-06-20 16:38:30 -070014465/*
14466 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014467 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014468 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014469int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014470 const u8 *ssid, size_t ssid_len, const u8 *bssid,
14471 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070014472{
14473 int status = 0;
14474 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080014475 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014476 v_U32_t roamId;
14477 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 eCsrAuthType RSNAuthType;
14479
14480 ENTER();
14481
14482 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080014483 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14484
14485 status = wlan_hdd_validate_context(pHddCtx);
14486 if (status)
14487 {
Yue Mae36e3552014-03-05 17:06:20 -080014488 return status;
14489 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014490
Jeff Johnson295189b2012-06-20 16:38:30 -070014491 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
14492 {
14493 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
14494 return -EINVAL;
14495 }
14496
14497 pRoamProfile = &pWextState->roamProfile;
14498
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014499 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014501 hdd_station_ctx_t *pHddStaCtx;
14502 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014503
Siddharth Bhalda0d1622015-04-24 15:47:49 +053014504 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
14505
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014506 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
14508 {
14509 /*QoS not enabled in cfg file*/
14510 pRoamProfile->uapsd_mask = 0;
14511 }
14512 else
14513 {
14514 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014515 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070014516 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
14517 }
14518
14519 pRoamProfile->SSIDs.numOfSSIDs = 1;
14520 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
14521 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014522 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
14524 ssid, ssid_len);
14525
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014526 vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN);
14527 vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN);
14528
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 if (bssid)
14530 {
14531 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014532 vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014534 /* Save BSSID in seperate variable as well, as RoamProfile
14535 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 case of join failure we should send valid BSSID to supplicant
14537 */
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014538 vos_mem_copy(pWextState->req_bssId, bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 WNI_CFG_BSSID_LEN);
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014540
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 }
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014542 else if (bssid_hint)
Dhanashri Atre51981c62013-06-13 11:47:57 -070014543 {
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014544 /* Store bssid_hint to use in the scan filter. */
14545 vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint,
14546 WNI_CFG_BSSID_LEN);
14547 /*
14548 * Save BSSID in seperate variable as well, as RoamProfile
14549 * BSSID is getting zeroed out in the association process. And in
14550 * case of join failure we should send valid BSSID to supplicant
14551 */
14552 vos_mem_copy(pWextState->req_bssId, bssid_hint,
14553 WNI_CFG_BSSID_LEN);
14554 hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR),
14555 MAC_ADDR_ARRAY(pRoamProfile->bssid_hint));
Dhanashri Atre51981c62013-06-13 11:47:57 -070014556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014557
Abhishek Singhb3e376c2017-01-04 15:27:13 +053014558
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014559 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
14560 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
14562 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014563 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 /*set gen ie*/
14565 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
14566 /*set auth*/
14567 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
14568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014569#ifdef FEATURE_WLAN_WAPI
14570 if (pAdapter->wapi_info.nWapiMode)
14571 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014572 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 switch (pAdapter->wapi_info.wapiAuthMode)
14574 {
14575 case WAPI_AUTH_MODE_PSK:
14576 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014577 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014578 pAdapter->wapi_info.wapiAuthMode);
14579 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
14580 break;
14581 }
14582 case WAPI_AUTH_MODE_CERT:
14583 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014584 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 pAdapter->wapi_info.wapiAuthMode);
14586 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
14587 break;
14588 }
14589 } // End of switch
14590 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
14591 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
14592 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014593 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 pRoamProfile->AuthType.numEntries = 1;
14595 pRoamProfile->EncryptionType.numEntries = 1;
14596 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14597 pRoamProfile->mcEncryptionType.numEntries = 1;
14598 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
14599 }
14600 }
14601#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014602#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014603 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014604 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
14605 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
14606 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053014607 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
14608 sizeof (tSirGtkOffloadParams));
14609 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014610 }
14611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014612 pRoamProfile->csrPersona = pAdapter->device_mode;
14613
Jeff Johnson32d95a32012-09-10 13:15:23 -070014614 if( operatingChannel )
14615 {
14616 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
14617 pRoamProfile->ChannelInfo.numOfChannels = 1;
14618 }
Chet Lanctot186b5732013-03-18 10:26:30 -070014619 else
14620 {
14621 pRoamProfile->ChannelInfo.ChannelList = NULL;
14622 pRoamProfile->ChannelInfo.numOfChannels = 0;
14623 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014624 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
14625 {
14626 hdd_select_cbmode(pAdapter,operatingChannel);
14627 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014628
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014629 /*
14630 * Change conn_state to connecting before sme_RoamConnect(),
14631 * because sme_RoamConnect() has a direct path to call
14632 * hdd_smeRoamCallback(), which will change the conn_state
14633 * If direct path, conn_state will be accordingly changed
14634 * to NotConnected or Associated by either
14635 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
14636 * in sme_RoamCallback()
14637 * if sme_RomConnect is to be queued,
14638 * Connecting state will remain until it is completed.
14639 * If connection state is not changed,
14640 * connection state will remain in eConnectionState_NotConnected state.
14641 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
14642 * if conn state is eConnectionState_NotConnected.
14643 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
14644 * informed of connect result indication which is an issue.
14645 */
14646
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014647 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14648 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053014649 {
14650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014651 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014652 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
14653 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053014654 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014655 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070014656 pAdapter->sessionId, pRoamProfile, &roamId);
14657
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053014658 if ((eHAL_STATUS_SUCCESS != status) &&
14659 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
14660 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014661
14662 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053014663 hddLog(VOS_TRACE_LEVEL_ERROR,
14664 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
14665 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014666 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014667 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080014668 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053014669 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080014670
14671 pRoamProfile->ChannelInfo.ChannelList = NULL;
14672 pRoamProfile->ChannelInfo.numOfChannels = 0;
14673
Jeff Johnson295189b2012-06-20 16:38:30 -070014674 }
14675 else
14676 {
14677 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
14678 return -EINVAL;
14679 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080014680 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014681 return status;
14682}
14683
14684/*
14685 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
14686 * This function is used to set the authentication type (OPEN/SHARED).
14687 *
14688 */
14689static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
14690 enum nl80211_auth_type auth_type)
14691{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014692 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014693 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14694
14695 ENTER();
14696
14697 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014698 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014700 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014701 hddLog(VOS_TRACE_LEVEL_INFO,
14702 "%s: set authentication type to AUTOSWITCH", __func__);
14703 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
14704 break;
14705
14706 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014707#ifdef WLAN_FEATURE_VOWIFI_11R
14708 case NL80211_AUTHTYPE_FT:
14709#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014710 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 "%s: set authentication type to OPEN", __func__);
14712 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14713 break;
14714
14715 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014716 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 "%s: set authentication type to SHARED", __func__);
14718 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
14719 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014720#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014722 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 "%s: set authentication type to CCKM WPA", __func__);
14724 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
14725 break;
14726#endif
14727
14728
14729 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014730 hddLog(VOS_TRACE_LEVEL_ERROR,
14731 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 auth_type);
14733 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
14734 return -EINVAL;
14735 }
14736
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014737 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 pHddStaCtx->conn_info.authType;
14739 return 0;
14740}
14741
14742/*
14743 * FUNCTION: wlan_hdd_set_akm_suite
14744 * This function is used to set the key mgmt type(PSK/8021x).
14745 *
14746 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014747static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014748 u32 key_mgmt
14749 )
14750{
14751 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14752 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053014753 /* Should be in ieee802_11_defs.h */
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014754#ifndef WLAN_AKM_SUITE_8021X_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014755#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014756#endif
14757#ifndef WLAN_AKM_SUITE_PSK_SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053014758#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Vidyullatha Kanchanapally08197682017-04-18 16:30:11 +053014759#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 /*set key mgmt type*/
14761 switch(key_mgmt)
14762 {
14763 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053014764 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014765#ifdef WLAN_FEATURE_VOWIFI_11R
14766 case WLAN_AKM_SUITE_FT_PSK:
14767#endif
14768 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 __func__);
14770 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
14771 break;
14772
14773 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053014774 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014775#ifdef WLAN_FEATURE_VOWIFI_11R
14776 case WLAN_AKM_SUITE_FT_8021X:
14777#endif
14778 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 __func__);
14780 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14781 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014782#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014783#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
14784#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
14785 case WLAN_AKM_SUITE_CCKM:
14786 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
14787 __func__);
14788 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
14789 break;
14790#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070014791#ifndef WLAN_AKM_SUITE_OSEN
14792#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
14793 case WLAN_AKM_SUITE_OSEN:
14794 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
14795 __func__);
14796 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
14797 break;
14798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014799
14800 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014801 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 __func__, key_mgmt);
14803 return -EINVAL;
14804
14805 }
14806 return 0;
14807}
14808
14809/*
14810 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014811 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070014812 * (NONE/WEP40/WEP104/TKIP/CCMP).
14813 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014814static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
14815 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 bool ucast
14817 )
14818{
14819 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014820 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14822
14823 ENTER();
14824
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014825 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014826 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053014827 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070014828 __func__, cipher);
14829 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14830 }
14831 else
14832 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014833
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014835 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 {
14837 case IW_AUTH_CIPHER_NONE:
14838 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14839 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014840
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014842 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070014843 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014844
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014846 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014848
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 case WLAN_CIPHER_SUITE_TKIP:
14850 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
14851 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014852
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 case WLAN_CIPHER_SUITE_CCMP:
14854 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14855 break;
14856#ifdef FEATURE_WLAN_WAPI
14857 case WLAN_CIPHER_SUITE_SMS4:
14858 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14859 break;
14860#endif
14861
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014862#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014863 case WLAN_CIPHER_SUITE_KRK:
14864 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14865 break;
14866#endif
14867 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014868 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 __func__, cipher);
14870 return -EOPNOTSUPP;
14871 }
14872 }
14873
14874 if (ucast)
14875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014876 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014877 __func__, encryptionType);
14878 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14879 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014880 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 encryptionType;
14882 }
14883 else
14884 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014885 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 __func__, encryptionType);
14887 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14888 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14889 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14890 }
14891
14892 return 0;
14893}
14894
14895
14896/*
14897 * FUNCTION: wlan_hdd_cfg80211_set_ie
14898 * This function is used to parse WPA/RSN IE's.
14899 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014900int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014901#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14902 const u8 *ie,
14903#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014904 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014905#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 size_t ie_len
14907 )
14908{
14909 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014910#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14911 const u8 *genie = ie;
14912#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014914#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 v_U16_t remLen = ie_len;
14916#ifdef FEATURE_WLAN_WAPI
14917 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14918 u16 *tmp;
14919 v_U16_t akmsuiteCount;
14920 int *akmlist;
14921#endif
14922 ENTER();
14923
14924 /* clear previous assocAddIE */
14925 pWextState->assocAddIE.length = 0;
14926 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014927 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014928
14929 while (remLen >= 2)
14930 {
14931 v_U16_t eLen = 0;
14932 v_U8_t elementId;
14933 elementId = *genie++;
14934 eLen = *genie++;
14935 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014936
Arif Hussain6d2a3322013-11-17 19:50:10 -080014937 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014938 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014939
14940 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014942 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014943 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 -070014944 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014945 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 "%s: Invalid WPA IE", __func__);
14947 return -EINVAL;
14948 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014949 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 {
14951 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014952 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014954
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014955 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014957 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14958 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 VOS_ASSERT(0);
14960 return -ENOMEM;
14961 }
14962 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14963 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14964 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014965
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14967 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14968 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14969 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014970 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14971 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14973 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14974 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14975 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14976 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14977 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014978 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014979 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014980 {
14981 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014982 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014984
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014985 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014987 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14988 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 VOS_ASSERT(0);
14990 return -ENOMEM;
14991 }
14992 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14993 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14994 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014995
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14997 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14998 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014999#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015000 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
15001 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 /*Consider WFD IE, only for P2P Client */
15003 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
15004 {
15005 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015006 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015008
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015009 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 {
Jeff Johnson902c9832012-12-10 14:28:09 -080015011 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15012 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 VOS_ASSERT(0);
15014 return -ENOMEM;
15015 }
15016 // WFD IE is saved to Additional IE ; it should be accumulated to handle
15017 // WPS IE + P2P IE + WFD IE
15018 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15019 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015020
Jeff Johnson295189b2012-06-20 16:38:30 -070015021 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15022 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15023 }
15024#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015025 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015026 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015027 HS20_OUI_TYPE_SIZE)) )
15028 {
15029 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015030 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015031 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015032
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015033 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015034 {
Jeff Johnson902c9832012-12-10 14:28:09 -080015035 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15036 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015037 VOS_ASSERT(0);
15038 return -ENOMEM;
15039 }
15040 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15041 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015042
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070015043 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15044 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15045 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070015046 /* Appending OSEN Information Element in Assiciation Request */
15047 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
15048 OSEN_OUI_TYPE_SIZE)) )
15049 {
15050 v_U16_t curAddIELen = pWextState->assocAddIE.length;
15051 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
15052 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015053
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015054 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070015055 {
15056 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15057 "Need bigger buffer space");
15058 VOS_ASSERT(0);
15059 return -ENOMEM;
15060 }
15061 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15062 pWextState->assocAddIE.length += eLen + 2;
15063
15064 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
15065 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15066 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15067 }
15068
Abhishek Singh4322e622015-06-10 15:42:54 +053015069 /* Update only for WPA IE */
15070 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
15071 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070015072
15073 /* populating as ADDIE in beacon frames */
15074 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015075 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070015076 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
15077 {
15078 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15079 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
15080 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15081 {
15082 hddLog(LOGE,
15083 "Coldn't pass "
15084 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
15085 }
15086 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
15087 else
15088 hddLog(LOGE,
15089 "Could not pass on "
15090 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
15091
15092 /* IBSS mode doesn't contain params->proberesp_ies still
15093 beaconIE's need to be populated in probe response frames */
15094 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
15095 {
15096 u16 rem_probe_resp_ie_len = eLen + 2;
15097 u8 probe_rsp_ie_len[3] = {0};
15098 u8 counter = 0;
15099
15100 /* Check Probe Resp Length if it is greater then 255 then
15101 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
15102 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
15103 not able Store More then 255 bytes into One Variable */
15104
15105 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
15106 {
15107 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
15108 {
15109 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
15110 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
15111 }
15112 else
15113 {
15114 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
15115 rem_probe_resp_ie_len = 0;
15116 }
15117 }
15118
15119 rem_probe_resp_ie_len = 0;
15120
15121 if (probe_rsp_ie_len[0] > 0)
15122 {
15123 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
15124 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
15125 (tANI_U8*)(genie - 2),
15126 probe_rsp_ie_len[0], NULL,
15127 eANI_BOOLEAN_FALSE)
15128 == eHAL_STATUS_FAILURE)
15129 {
15130 hddLog(LOGE,
15131 "Could not pass"
15132 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
15133 }
15134 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
15135 }
15136
15137 if (probe_rsp_ie_len[1] > 0)
15138 {
15139 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
15140 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
15141 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
15142 probe_rsp_ie_len[1], NULL,
15143 eANI_BOOLEAN_FALSE)
15144 == eHAL_STATUS_FAILURE)
15145 {
15146 hddLog(LOGE,
15147 "Could not pass"
15148 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
15149 }
15150 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
15151 }
15152
15153 if (probe_rsp_ie_len[2] > 0)
15154 {
15155 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
15156 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
15157 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
15158 probe_rsp_ie_len[2], NULL,
15159 eANI_BOOLEAN_FALSE)
15160 == eHAL_STATUS_FAILURE)
15161 {
15162 hddLog(LOGE,
15163 "Could not pass"
15164 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
15165 }
15166 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
15167 }
15168
15169 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15170 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
15171 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15172 {
15173 hddLog(LOGE,
15174 "Could not pass"
15175 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
15176 }
15177 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070015178 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 break;
15180 case DOT11F_EID_RSN:
15181 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
15182 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
15183 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
15184 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
15185 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
15186 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053015187
Abhishek Singhb16f3562016-01-20 11:08:32 +053015188 /* Appending extended capabilities with Interworking or
15189 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053015190 *
15191 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053015192 * interworkingService or bsstransition bit is set to 1.
15193 * Driver is only interested in interworkingService and
15194 * bsstransition capability from supplicant.
15195 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053015196 * required from supplicat, it needs to be handled while
15197 * sending Assoc Req in LIM.
15198 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015199 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015200 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015201 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015202 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015203 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015204
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015205 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015206 {
Jeff Johnson902c9832012-12-10 14:28:09 -080015207 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
15208 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015209 VOS_ASSERT(0);
15210 return -ENOMEM;
15211 }
15212 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
15213 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015214
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015215 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
15216 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
15217 break;
15218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015219#ifdef FEATURE_WLAN_WAPI
15220 case WLAN_EID_WAPI:
15221 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015222 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070015223 pAdapter->wapi_info.nWapiMode);
15224 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015225 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 akmsuiteCount = WPA_GET_LE16(tmp);
15227 tmp = tmp + 1;
15228 akmlist = (int *)(tmp);
15229 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
15230 {
15231 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
15232 }
15233 else
15234 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015235 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 VOS_ASSERT(0);
15237 return -EINVAL;
15238 }
15239
15240 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
15241 {
15242 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015243 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015247 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015248 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015249 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
15251 }
15252 break;
15253#endif
15254 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015255 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070015257 /* when Unknown IE is received we should break and continue
15258 * to the next IE in the buffer instead we were returning
15259 * so changing this to break */
15260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015261 }
15262 genie += eLen;
15263 remLen -= eLen;
15264 }
15265 EXIT();
15266 return 0;
15267}
15268
15269/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053015270 * FUNCTION: hdd_isWPAIEPresent
15271 * Parse the received IE to find the WPA IE
15272 *
15273 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015274static bool hdd_isWPAIEPresent(
15275#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
15276 const u8 *ie,
15277#else
15278 u8 *ie,
15279#endif
15280 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053015281{
15282 v_U8_t eLen = 0;
15283 v_U16_t remLen = ie_len;
15284 v_U8_t elementId = 0;
15285
15286 while (remLen >= 2)
15287 {
15288 elementId = *ie++;
15289 eLen = *ie++;
15290 remLen -= 2;
15291 if (eLen > remLen)
15292 {
15293 hddLog(VOS_TRACE_LEVEL_ERROR,
15294 "%s: IE length is wrong %d", __func__, eLen);
15295 return FALSE;
15296 }
15297 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
15298 {
15299 /* OUI - 0x00 0X50 0XF2
15300 WPA Information Element - 0x01
15301 WPA version - 0x01*/
15302 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
15303 return TRUE;
15304 }
15305 ie += eLen;
15306 remLen -= eLen;
15307 }
15308 return FALSE;
15309}
15310
15311/*
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015313 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 * parameters during connect operation.
15315 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015316int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015318 )
Jeff Johnson295189b2012-06-20 16:38:30 -070015319{
15320 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015321 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015322 ENTER();
15323
15324 /*set wpa version*/
15325 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
15326
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015327 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053015329 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 {
15331 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15332 }
15333 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
15334 {
15335 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15336 }
15337 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015338
15339 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 pWextState->wpaVersion);
15341
15342 /*set authentication type*/
15343 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
15344
15345 if (0 > status)
15346 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015347 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 "%s: failed to set authentication type ", __func__);
15349 return status;
15350 }
15351
15352 /*set key mgmt type*/
15353 if (req->crypto.n_akm_suites)
15354 {
15355 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
15356 if (0 > status)
15357 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015358 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 __func__);
15360 return status;
15361 }
15362 }
15363
15364 /*set pairwise cipher type*/
15365 if (req->crypto.n_ciphers_pairwise)
15366 {
15367 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
15368 req->crypto.ciphers_pairwise[0], true);
15369 if (0 > status)
15370 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015371 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 "%s: failed to set unicast cipher type", __func__);
15373 return status;
15374 }
15375 }
15376 else
15377 {
15378 /*Reset previous cipher suite to none*/
15379 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
15380 if (0 > status)
15381 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015382 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 "%s: failed to set unicast cipher type", __func__);
15384 return status;
15385 }
15386 }
15387
15388 /*set group cipher type*/
15389 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
15390 false);
15391
15392 if (0 > status)
15393 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015394 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 __func__);
15396 return status;
15397 }
15398
Chet Lanctot186b5732013-03-18 10:26:30 -070015399#ifdef WLAN_FEATURE_11W
15400 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
15401#endif
15402
Jeff Johnson295189b2012-06-20 16:38:30 -070015403 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
15404 if (req->ie_len)
15405 {
15406 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
15407 if ( 0 > status)
15408 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015409 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 __func__);
15411 return status;
15412 }
15413 }
15414
15415 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015416 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 {
15418 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
15419 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
15420 )
15421 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015422 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
15424 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015425 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 __func__);
15427 return -EOPNOTSUPP;
15428 }
15429 else
15430 {
15431 u8 key_len = req->key_len;
15432 u8 key_idx = req->key_idx;
15433
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015434 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070015435 && (CSR_MAX_NUM_KEY > key_idx)
15436 )
15437 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015438 hddLog(VOS_TRACE_LEVEL_INFO,
15439 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 __func__, key_idx, key_len);
15441 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015442 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015444 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 (u8)key_len;
15446 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
15447 }
15448 }
15449 }
15450 }
15451
15452 return status;
15453}
15454
15455/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015456 * FUNCTION: wlan_hdd_try_disconnect
15457 * This function is used to disconnect from previous
15458 * connection
15459 */
Agrawal Ashishc407f192017-01-23 17:18:35 +053015460int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015461{
15462 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015463 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015464 hdd_station_ctx_t *pHddStaCtx;
15465 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053015466 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015467
Abhishek Singh19a7dd92015-12-30 16:31:51 +053015468 ret = wlan_hdd_validate_context(pHddCtx);
15469 if (0 != ret)
15470 {
15471 return ret;
15472 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015473 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15474
15475 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
15476
15477 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
15478 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053015479 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015480 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
15481 {
Abhishek Singh9f4df782017-03-15 17:29:10 +053015482 /* Indicate disconnect to SME so that in-progress connection or preauth
15483 * can be aborted
15484 */
15485 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
15486 pAdapter->sessionId);
Abhishek Singh19a7dd92015-12-30 16:31:51 +053015487 spin_lock_bh(&pAdapter->lock_for_active_session);
15488 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15489 {
15490 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15491 }
15492 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053015493 hdd_connSetConnectionState(pHddStaCtx,
15494 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015495 /* Issue disconnect to CSR */
15496 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015497 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015498 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015499 eCSR_DISCONNECT_REASON_UNSPECIFIED);
15500 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
15501 hddLog(LOG1,
15502 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
15503 } else if ( 0 != status ) {
15504 hddLog(LOGE,
15505 FL("csrRoamDisconnect failure, returned %d"),
15506 (int)status );
15507 result = -EINVAL;
15508 goto disconnected;
15509 }
15510 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015511 &pAdapter->disconnect_comp_var,
15512 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015513 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
15514 hddLog(LOGE,
15515 "%s: Failed to disconnect, timed out", __func__);
15516 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015517 }
15518 }
15519 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
15520 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015521 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015522 &pAdapter->disconnect_comp_var,
15523 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015524 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015525 {
15526 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015527 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015528 }
15529 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015530disconnected:
15531 hddLog(LOG1,
15532 FL("Set HDD connState to eConnectionState_NotConnected"));
15533 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
15534 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015535}
15536
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053015537/**
15538 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
15539 * @adapter: Pointer to the HDD adapter
15540 * @req: Pointer to the structure cfg_connect_params receieved from user space
15541 *
15542 * This function will start reassociation if bssid hint, channel hint and
15543 * previous bssid parameters are present in the connect request
15544 *
15545 * Return: success if reassociation is happening
15546 * Error code if reassociation is not permitted or not happening
15547 */
15548#ifdef CFG80211_CONNECT_PREV_BSSID
15549static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
15550 struct cfg80211_connect_params *req)
15551{
15552 int status = -EPERM;
15553 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
15554 hddLog(VOS_TRACE_LEVEL_INFO,
15555 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
15556 req->channel_hint->hw_value,
15557 MAC_ADDR_ARRAY(req->bssid_hint));
15558 status = hdd_reassoc(adapter, req->bssid_hint,
15559 req->channel_hint->hw_value,
15560 CONNECT_CMD_USERSPACE);
15561 }
15562 return status;
15563}
15564#else
15565static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
15566 struct cfg80211_connect_params *req)
15567{
15568 return -EPERM;
15569}
15570#endif
15571
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015572/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053015573 * FUNCTION: __wlan_hdd_cfg80211_connect
15574 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070015575 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015576static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 struct net_device *ndev,
15578 struct cfg80211_connect_params *req
15579 )
15580{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015581 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015582 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053015583#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
15584 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015585 const u8 *bssid_hint = req->bssid_hint;
15586#else
15587 const u8 *bssid_hint = NULL;
15588#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053015591 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015592
15593 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015594
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015595 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15596 TRACE_CODE_HDD_CFG80211_CONNECT,
15597 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015598 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015599 "%s: device_mode = %s (%d)", __func__,
15600 hdd_device_modetoString(pAdapter->device_mode),
15601 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015603 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015604 if (!pHddCtx)
15605 {
15606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15607 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053015608 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080015609 }
15610
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015611 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015612 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015613 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015614 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015615 }
15616
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053015617 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
15618 if (0 == status)
15619 return status;
15620
Agarwal Ashish51325b52014-06-16 16:50:49 +053015621
Jeff Johnson295189b2012-06-20 16:38:30 -070015622#ifdef WLAN_BTAMP_FEATURE
15623 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015624 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070015625 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015626 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080015628 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070015629 }
15630#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015631
15632 //If Device Mode is Station Concurrent Sessions Exit BMps
15633 //P2P Mode will be taken care in Open/close adapter
15634 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053015635 (vos_concurrent_open_sessions_running())) {
15636 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
15637 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015638 }
15639
15640 /*Try disconnecting if already in connected state*/
15641 status = wlan_hdd_try_disconnect(pAdapter);
15642 if ( 0 > status)
15643 {
15644 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15645 " connection"));
15646 return -EALREADY;
15647 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053015648 /* Check for max concurrent connections after doing disconnect if any*/
15649 if (vos_max_concurrent_connections_reached()) {
15650 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15651 return -ECONNREFUSED;
15652 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015653
Jeff Johnson295189b2012-06-20 16:38:30 -070015654 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015655 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070015656
15657 if ( 0 > status)
15658 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015659 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070015660 __func__);
15661 return status;
15662 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053015663
15664 if (pHddCtx->spoofMacAddr.isEnabled)
15665 {
15666 hddLog(VOS_TRACE_LEVEL_INFO,
15667 "%s: MAC Spoofing enabled ", __func__);
15668 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
15669 * to fill TxBds for probe request during SSID scan which may happen
15670 * as part of connect command
15671 */
15672 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
15673 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
15674 if (status != VOS_STATUS_SUCCESS)
15675 return -ECONNREFUSED;
15676 }
15677
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015678 if (req->channel)
15679 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070015680 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015681 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053015682
15683 /* Abort if any scan is going on */
15684 status = wlan_hdd_scan_abort(pAdapter);
15685 if (0 != status)
15686 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
15687
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053015688 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
15689 req->ssid_len, req->bssid,
15690 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015691
Sushant Kaushikd7083982015-03-18 14:33:24 +053015692 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015693 {
15694 //ReEnable BMPS if disabled
15695 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
15696 (NULL != pHddCtx))
15697 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053015698 if (pHddCtx->hdd_wlan_suspended)
15699 {
15700 hdd_set_pwrparams(pHddCtx);
15701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015702 //ReEnable Bmps and Imps back
15703 hdd_enable_bmps_imps(pHddCtx);
15704 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053015705 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015706 return status;
15707 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015708 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015709 EXIT();
15710 return status;
15711}
15712
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015713static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
15714 struct net_device *ndev,
15715 struct cfg80211_connect_params *req)
15716{
15717 int ret;
15718 vos_ssr_protect(__func__);
15719 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
15720 vos_ssr_unprotect(__func__);
15721
15722 return ret;
15723}
Jeff Johnson295189b2012-06-20 16:38:30 -070015724
15725/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015726 * FUNCTION: wlan_hdd_disconnect
15727 * This function is used to issue a disconnect request to SME
15728 */
15729int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
15730{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015731 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015732 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015733 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015734 long ret;
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015735 eConnectionState prev_conn_state;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015736
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015737 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015738
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015739 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015740 if (0 != status)
15741 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015742 return status;
15743 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053015744 /* Indicate sme of disconnect so that in progress connection or preauth
15745 * can be aborted
15746 */
15747 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053015748 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015749 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015750
Agarwal Ashish47d18112014-08-04 19:55:07 +053015751 /* Need to apply spin lock before decreasing active sessions
15752 * as there can be chance for double decrement if context switch
15753 * Calls hdd_DisConnectHandler.
15754 */
15755
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015756 prev_conn_state = pHddStaCtx->conn_info.connState;
15757
Agarwal Ashish47d18112014-08-04 19:55:07 +053015758 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015759 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
15760 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015761 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
15762 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053015763 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
15764 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053015765
Abhishek Singhf4669da2014-05-26 15:07:49 +053015766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053015767 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
15768
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015769 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015770
Mihir Shete182a0b22014-08-18 16:08:48 +053015771 /*
15772 * stop tx queues before deleting STA/BSS context from the firmware.
15773 * tx has to be disabled because the firmware can get busy dropping
15774 * the tx frames after BSS/STA has been deleted and will not send
15775 * back a response resulting in WDI timeout
15776 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053015777 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053015778 netif_tx_disable(pAdapter->dev);
15779 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015780
Mihir Shete182a0b22014-08-18 16:08:48 +053015781 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015782 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
15783 pAdapter->sessionId, reason);
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015784 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
15785 prev_conn_state != eConnectionState_Connecting)
15786 {
15787 hddLog(LOG1,
15788 FL("status = %d, already disconnected"), status);
15789 result = 0;
15790 goto disconnected;
15791 }
15792 /*
15793 * Wait here instead of returning directly, this will block the next
15794 * connect command and allow processing of the scan for ssid and
15795 * the previous connect command in CSR. Else we might hit some
15796 * race conditions leading to SME and HDD out of sync.
15797 */
15798 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015799 {
15800 hddLog(LOG1,
15801 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015802 }
15803 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015804 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015805 hddLog(LOGE,
15806 FL("csrRoamDisconnect failure, returned %d"),
15807 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015808 result = -EINVAL;
15809 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015810 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015811 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015812 &pAdapter->disconnect_comp_var,
15813 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015814 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015815 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015816 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015817 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015818 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053015819 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015820disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053015821 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015822 FL("Set HDD connState to eConnectionState_NotConnected"));
15823 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015824#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
15825 /* Sending disconnect event to userspace for kernel version < 3.11
15826 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
15827 */
15828 hddLog(LOG1, FL("Send disconnected event to userspace"));
15829
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053015830 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053015831 WLAN_REASON_UNSPECIFIED);
15832#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053015833
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015834 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053015835 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015836}
15837
15838
15839/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015840 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 * This function is used to issue a disconnect request to SME
15842 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015843static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 struct net_device *dev,
15845 u16 reason
15846 )
15847{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015849 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015850 tCsrRoamProfile *pRoamProfile;
15851 hdd_station_ctx_t *pHddStaCtx;
15852 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015853#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015854 tANI_U8 staIdx;
15855#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015856
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015858
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015859 if (!pAdapter) {
15860 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15861 return -EINVAL;
15862 }
15863
15864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15865 if (!pHddStaCtx) {
15866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
15867 return -EINVAL;
15868 }
15869
15870 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15871 status = wlan_hdd_validate_context(pHddCtx);
15872 if (0 != status)
15873 {
15874 return status;
15875 }
15876
15877 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
15878
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015879 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15880 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15881 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015882 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15883 __func__, hdd_device_modetoString(pAdapter->device_mode),
15884 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015885
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015886 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15887 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015888
Jeff Johnson295189b2012-06-20 16:38:30 -070015889 if (NULL != pRoamProfile)
15890 {
15891 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015892 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15893 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015895 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015897 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015898 switch(reason)
15899 {
15900 case WLAN_REASON_MIC_FAILURE:
15901 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15902 break;
15903
15904 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15905 case WLAN_REASON_DISASSOC_AP_BUSY:
15906 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15907 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15908 break;
15909
15910 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15911 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015912 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015913 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15914 break;
15915
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 default:
15917 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15918 break;
15919 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015920 pScanInfo = &pHddCtx->scan_info;
15921 if (pScanInfo->mScanPending)
15922 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015923 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015924 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015925 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015926 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015927 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015928 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015929#ifdef FEATURE_WLAN_TDLS
15930 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015931 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015932 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015933 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15934 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015935 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015936 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015937 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015939 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015940 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015941 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015942 status = sme_DeleteTdlsPeerSta(
15943 WLAN_HDD_GET_HAL_CTX(pAdapter),
15944 pAdapter->sessionId,
15945 mac);
15946 if (status != eHAL_STATUS_SUCCESS) {
15947 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15948 return -EPERM;
15949 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015950 }
15951 }
15952#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015953
15954 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
15955 reasonCode,
15956 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015957 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15958 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015959 {
15960 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015961 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015962 __func__, (int)status );
15963 return -EINVAL;
15964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015966 else
15967 {
15968 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15969 "called while in %d state", __func__,
15970 pHddStaCtx->conn_info.connState);
15971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015972 }
15973 else
15974 {
15975 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15976 }
15977
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015978 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015979 return status;
15980}
15981
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015982static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15983 struct net_device *dev,
15984 u16 reason
15985 )
15986{
15987 int ret;
15988 vos_ssr_protect(__func__);
15989 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15990 vos_ssr_unprotect(__func__);
15991
15992 return ret;
15993}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015994
Jeff Johnson295189b2012-06-20 16:38:30 -070015995/*
15996 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015997 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 * settings in IBSS mode.
15999 */
16000static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016001 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070016002 struct cfg80211_ibss_params *params
16003 )
16004{
16005 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016006 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016007 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
16008 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016009
Jeff Johnson295189b2012-06-20 16:38:30 -070016010 ENTER();
16011
16012 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070016013 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070016014
16015 if (params->ie_len && ( NULL != params->ie) )
16016 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016017 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
16018 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 {
16020 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
16021 encryptionType = eCSR_ENCRYPT_TYPE_AES;
16022 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016023 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070016024 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070016025 tDot11fIEWPA dot11WPAIE;
16026 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016027 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070016028
Wilson Yang00256342013-10-10 23:13:38 -070016029 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016030 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
16031 params->ie_len, DOT11F_EID_WPA);
16032 if ( NULL != ie )
16033 {
16034 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
16035 // Unpack the WPA IE
16036 //Skip past the EID byte and length byte - and four byte WiFi OUI
16037 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
16038 &ie[2+4],
16039 ie[1] - 4,
16040 &dot11WPAIE);
16041 /*Extract the multicast cipher, the encType for unicast
16042 cipher for wpa-none is none*/
16043 encryptionType =
16044 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
16045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070016047
Jeff Johnson295189b2012-06-20 16:38:30 -070016048 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
16049
16050 if (0 > status)
16051 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016052 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070016053 __func__);
16054 return status;
16055 }
16056 }
16057
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016058 pWextState->roamProfile.AuthType.authType[0] =
16059 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 eCSR_AUTH_TYPE_OPEN_SYSTEM;
16061
16062 if (params->privacy)
16063 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016064 /* Security enabled IBSS, At this time there is no information available
16065 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016067 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070016068 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016069 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 *enable privacy bit in beacons */
16071
16072 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
16073 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070016074 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
16075 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070016076 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
16077 pWextState->roamProfile.EncryptionType.numEntries = 1;
16078 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070016079 return status;
16080}
16081
16082/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016083 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016084 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070016085 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016086static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 struct net_device *dev,
16088 struct cfg80211_ibss_params *params
16089 )
16090{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016091 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070016092 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16093 tCsrRoamProfile *pRoamProfile;
16094 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016095 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16096 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016097 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070016098
16099 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016100
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016101 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16102 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
16103 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016104 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016105 "%s: device_mode = %s (%d)", __func__,
16106 hdd_device_modetoString(pAdapter->device_mode),
16107 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070016108
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016109 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016110 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070016111 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016112 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016113 }
16114
16115 if (NULL == pWextState)
16116 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016117 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070016118 __func__);
16119 return -EIO;
16120 }
16121
Agarwal Ashish51325b52014-06-16 16:50:49 +053016122 if (vos_max_concurrent_connections_reached()) {
16123 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
16124 return -ECONNREFUSED;
16125 }
16126
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053016127 /*Try disconnecting if already in connected state*/
16128 status = wlan_hdd_try_disconnect(pAdapter);
16129 if ( 0 > status)
16130 {
16131 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
16132 " IBSS connection"));
16133 return -EALREADY;
16134 }
16135
Jeff Johnson295189b2012-06-20 16:38:30 -070016136 pRoamProfile = &pWextState->roamProfile;
16137
16138 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
16139 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016140 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016141 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016142 return -EINVAL;
16143 }
16144
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070016145 /* BSSID is provided by upper layers hence no need to AUTO generate */
16146 if (NULL != params->bssid) {
16147 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
16148 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
16149 hddLog (VOS_TRACE_LEVEL_ERROR,
16150 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
16151 return -EIO;
16152 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016153 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070016154 }
krunal sonie9002db2013-11-25 14:24:17 -080016155 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
16156 {
16157 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
16158 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
16159 {
16160 hddLog (VOS_TRACE_LEVEL_ERROR,
16161 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
16162 return -EIO;
16163 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016164
16165 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080016166 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016167 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080016168 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070016169
Jeff Johnson295189b2012-06-20 16:38:30 -070016170 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070016171 if (NULL !=
16172#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
16173 params->chandef.chan)
16174#else
16175 params->channel)
16176#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016177 {
16178 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016179 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
16180 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
16181 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16182 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016183
16184 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016185 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070016186 ieee80211_frequency_to_channel(
16187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
16188 params->chandef.chan->center_freq);
16189#else
16190 params->channel->center_freq);
16191#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016192
16193 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
16194 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070016195 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016196 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
16197 __func__);
16198 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016200
16201 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016202 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016203 if (channelNum == validChan[indx])
16204 {
16205 break;
16206 }
16207 }
16208 if (indx >= numChans)
16209 {
16210 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016211 __func__, channelNum);
16212 return -EINVAL;
16213 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016214 /* Set the Operational Channel */
16215 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
16216 channelNum);
16217 pRoamProfile->ChannelInfo.numOfChannels = 1;
16218 pHddStaCtx->conn_info.operationChannel = channelNum;
16219 pRoamProfile->ChannelInfo.ChannelList =
16220 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070016221 }
16222
16223 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016224 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070016225 if (status < 0)
16226 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070016228 __func__);
16229 return status;
16230 }
16231
16232 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016233 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053016234 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070016235 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070016236
16237 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070016238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016240 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016241 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016242}
16243
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016244static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
16245 struct net_device *dev,
16246 struct cfg80211_ibss_params *params
16247 )
16248{
16249 int ret = 0;
16250
16251 vos_ssr_protect(__func__);
16252 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
16253 vos_ssr_unprotect(__func__);
16254
16255 return ret;
16256}
16257
Jeff Johnson295189b2012-06-20 16:38:30 -070016258/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016259 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016260 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070016261 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016262static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070016263 struct net_device *dev
16264 )
16265{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016266 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016267 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
16268 tCsrRoamProfile *pRoamProfile;
16269 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016270 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053016271 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053016272#ifdef WLAN_FEATURE_RMC
16273 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
16274#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016275
16276 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016277
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016278 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16279 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
16280 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016281 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016282 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016283 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016284 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016285 }
16286
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
16288 hdd_device_modetoString(pAdapter->device_mode),
16289 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070016290 if (NULL == pWextState)
16291 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016292 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070016293 __func__);
16294 return -EIO;
16295 }
16296
16297 pRoamProfile = &pWextState->roamProfile;
16298
16299 /* Issue disconnect only if interface type is set to IBSS */
16300 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
16301 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016302 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 __func__);
16304 return -EINVAL;
16305 }
16306
Abhishek Singh7cd040e2016-01-07 10:51:04 +053016307#ifdef WLAN_FEATURE_RMC
16308 /* Clearing add IE of beacon */
16309 if (ccmCfgSetStr(pHddCtx->hHal,
16310 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
16311 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
16312 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
16313 {
16314 hddLog (VOS_TRACE_LEVEL_ERROR,
16315 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
16316 return -EINVAL;
16317 }
16318 if (ccmCfgSetInt(pHddCtx->hHal,
16319 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
16320 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
16321 {
16322 hddLog (VOS_TRACE_LEVEL_ERROR,
16323 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
16324 __func__);
16325 return -EINVAL;
16326 }
16327
16328 // Reset WNI_CFG_PROBE_RSP Flags
16329 wlan_hdd_reset_prob_rspies(pAdapter);
16330
16331 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
16332 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
16333 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
16334 {
16335 hddLog (VOS_TRACE_LEVEL_ERROR,
16336 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
16337 __func__);
16338 return -EINVAL;
16339 }
16340#endif
16341
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 /* Issue Disconnect request */
16343 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053016344 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
16345 pAdapter->sessionId,
16346 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
16347 if (!HAL_STATUS_SUCCESS(hal_status)) {
16348 hddLog(LOGE,
16349 FL("sme_RoamDisconnect failed hal_status(%d)"),
16350 hal_status);
16351 return -EAGAIN;
16352 }
16353 status = wait_for_completion_timeout(
16354 &pAdapter->disconnect_comp_var,
16355 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
16356 if (!status) {
16357 hddLog(LOGE,
16358 FL("wait on disconnect_comp_var failed"));
16359 return -ETIMEDOUT;
16360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016362 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016363 return 0;
16364}
16365
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016366static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
16367 struct net_device *dev
16368 )
16369{
16370 int ret = 0;
16371
16372 vos_ssr_protect(__func__);
16373 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
16374 vos_ssr_unprotect(__func__);
16375
16376 return ret;
16377}
16378
Jeff Johnson295189b2012-06-20 16:38:30 -070016379/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016380 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070016381 * This function is used to set the phy parameters
16382 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
16383 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016384static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 u32 changed)
16386{
16387 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16388 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016389 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016390
16391 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016392
16393 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016394 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
16395 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016396
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016397 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016398 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016399 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016400 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016401 }
16402
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
16404 {
16405 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
16406 WNI_CFG_RTS_THRESHOLD_STAMAX :
16407 wiphy->rts_threshold;
16408
16409 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016410 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070016411 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016412 hddLog(VOS_TRACE_LEVEL_ERROR,
16413 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016414 __func__, rts_threshold);
16415 return -EINVAL;
16416 }
16417
16418 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
16419 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016420 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016421 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016422 hddLog(VOS_TRACE_LEVEL_ERROR,
16423 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016424 __func__, rts_threshold);
16425 return -EIO;
16426 }
16427
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016428 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 rts_threshold);
16430 }
16431
16432 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
16433 {
16434 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
16435 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
16436 wiphy->frag_threshold;
16437
16438 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016439 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016441 hddLog(VOS_TRACE_LEVEL_ERROR,
16442 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 frag_threshold);
16444 return -EINVAL;
16445 }
16446
16447 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
16448 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016449 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016451 hddLog(VOS_TRACE_LEVEL_ERROR,
16452 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 __func__, frag_threshold);
16454 return -EIO;
16455 }
16456
16457 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
16458 frag_threshold);
16459 }
16460
16461 if ((changed & WIPHY_PARAM_RETRY_SHORT)
16462 || (changed & WIPHY_PARAM_RETRY_LONG))
16463 {
16464 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
16465 wiphy->retry_short :
16466 wiphy->retry_long;
16467
16468 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
16469 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
16470 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016471 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 __func__, retry_value);
16473 return -EINVAL;
16474 }
16475
16476 if (changed & WIPHY_PARAM_RETRY_SHORT)
16477 {
16478 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
16479 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016480 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016481 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016482 hddLog(VOS_TRACE_LEVEL_ERROR,
16483 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016484 __func__, retry_value);
16485 return -EIO;
16486 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016487 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 __func__, retry_value);
16489 }
16490 else if (changed & WIPHY_PARAM_RETRY_SHORT)
16491 {
16492 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
16493 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016494 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016496 hddLog(VOS_TRACE_LEVEL_ERROR,
16497 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 __func__, retry_value);
16499 return -EIO;
16500 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016501 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070016502 __func__, retry_value);
16503 }
16504 }
16505
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016506 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 return 0;
16508}
16509
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016510static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
16511 u32 changed)
16512{
16513 int ret;
16514
16515 vos_ssr_protect(__func__);
16516 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
16517 vos_ssr_unprotect(__func__);
16518
16519 return ret;
16520}
16521
Jeff Johnson295189b2012-06-20 16:38:30 -070016522/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016523 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070016524 * This function is used to set the txpower
16525 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016526static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070016527#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16528 struct wireless_dev *wdev,
16529#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016530#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016531 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070016532#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016533 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070016534#endif
16535 int dbm)
16536{
16537 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016538 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016539 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
16540 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016541 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016542
16543 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016544
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016545 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16546 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
16547 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016548 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016549 if (0 != status)
16550 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016551 return status;
16552 }
16553
16554 hHal = pHddCtx->hHal;
16555
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016556 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
16557 dbm, ccmCfgSetCallback,
16558 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070016559 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016560 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
16562 return -EIO;
16563 }
16564
16565 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
16566 dbm);
16567
16568 switch(type)
16569 {
16570 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
16571 /* Fall through */
16572 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
16573 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
16574 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016575 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
16576 __func__);
16577 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070016578 }
16579 break;
16580 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016581 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070016582 __func__);
16583 return -EOPNOTSUPP;
16584 break;
16585 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
16587 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070016588 return -EIO;
16589 }
16590
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016591 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016592 return 0;
16593}
16594
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053016595static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
16596#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16597 struct wireless_dev *wdev,
16598#endif
16599#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16600 enum tx_power_setting type,
16601#else
16602 enum nl80211_tx_power_setting type,
16603#endif
16604 int dbm)
16605{
16606 int ret;
16607 vos_ssr_protect(__func__);
16608 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
16609#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16610 wdev,
16611#endif
16612#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
16613 type,
16614#else
16615 type,
16616#endif
16617 dbm);
16618 vos_ssr_unprotect(__func__);
16619
16620 return ret;
16621}
16622
Jeff Johnson295189b2012-06-20 16:38:30 -070016623/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016624 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070016625 * This function is used to read the txpower
16626 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016627static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070016628#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16629 struct wireless_dev *wdev,
16630#endif
16631 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070016632{
16633
16634 hdd_adapter_t *pAdapter;
16635 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016636 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016637
Jeff Johnsone7245742012-09-05 17:12:55 -070016638 ENTER();
16639
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016640 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016641 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016642 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016643 *dbm = 0;
16644 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016645 }
16646
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
16648 if (NULL == pAdapter)
16649 {
16650 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
16651 return -ENOENT;
16652 }
16653
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016654 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16655 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
16656 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070016657 wlan_hdd_get_classAstats(pAdapter);
16658 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
16659
Jeff Johnsone7245742012-09-05 17:12:55 -070016660 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016661 return 0;
16662}
16663
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016664static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
16665#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16666 struct wireless_dev *wdev,
16667#endif
16668 int *dbm)
16669{
16670 int ret;
16671
16672 vos_ssr_protect(__func__);
16673 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
16674#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
16675 wdev,
16676#endif
16677 dbm);
16678 vos_ssr_unprotect(__func__);
16679
16680 return ret;
16681}
16682
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016683static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016684#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16685 const u8* mac,
16686#else
16687 u8* mac,
16688#endif
16689 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070016690{
16691 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
16692 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16693 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053016694 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016695
16696 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
16697 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070016698
16699 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
16700 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
16701 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
16702 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
16703 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
16704 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
16705 tANI_U16 maxRate = 0;
16706 tANI_U16 myRate;
16707 tANI_U16 currentRate = 0;
16708 tANI_U8 maxSpeedMCS = 0;
16709 tANI_U8 maxMCSIdx = 0;
16710 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053016711 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070016712 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016713 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016714
Leo Chang6f8870f2013-03-26 18:11:36 -070016715#ifdef WLAN_FEATURE_11AC
16716 tANI_U32 vht_mcs_map;
16717 eDataRate11ACMaxMcs vhtMaxMcs;
16718#endif /* WLAN_FEATURE_11AC */
16719
Jeff Johnsone7245742012-09-05 17:12:55 -070016720 ENTER();
16721
Jeff Johnson295189b2012-06-20 16:38:30 -070016722 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
16723 (0 == ssidlen))
16724 {
16725 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
16726 " Invalid ssidlen, %d", __func__, ssidlen);
16727 /*To keep GUI happy*/
16728 return 0;
16729 }
16730
Mukul Sharma811205f2014-07-09 21:07:30 +053016731 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16732 {
16733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16734 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053016735 /* return a cached value */
16736 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053016737 return 0;
16738 }
16739
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016740 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016741 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016742 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016743 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016744 }
16745
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053016746 wlan_hdd_get_station_stats(pAdapter);
16747 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070016748
Kiet Lam3b17fc82013-09-27 05:24:08 +053016749 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
16750 sinfo->filled |= STATION_INFO_SIGNAL;
16751
c_hpothu09f19542014-05-30 21:53:31 +053016752 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053016753 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
16754 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053016755 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053016756 {
16757 rate_flags = pAdapter->maxRateFlags;
16758 }
c_hpothu44ff4e02014-05-08 00:13:57 +053016759
Jeff Johnson295189b2012-06-20 16:38:30 -070016760 //convert to the UI units of 100kbps
16761 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
16762
16763#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070016764 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 -070016765 sinfo->signal,
16766 pCfg->reportMaxLinkSpeed,
16767 myRate,
16768 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016769 (int) pCfg->linkSpeedRssiMid,
16770 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070016771 (int) rate_flags,
16772 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070016773#endif //LINKSPEED_DEBUG_ENABLED
16774
16775 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
16776 {
16777 // we do not want to necessarily report the current speed
16778 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
16779 {
16780 // report the max possible speed
16781 rssidx = 0;
16782 }
16783 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
16784 {
16785 // report the max possible speed with RSSI scaling
16786 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
16787 {
16788 // report the max possible speed
16789 rssidx = 0;
16790 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016791 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016792 {
16793 // report middle speed
16794 rssidx = 1;
16795 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016796 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
16797 {
16798 // report middle speed
16799 rssidx = 2;
16800 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016801 else
16802 {
16803 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070016804 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 }
16806 }
16807 else
16808 {
16809 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
16810 hddLog(VOS_TRACE_LEVEL_ERROR,
16811 "%s: Invalid value for reportMaxLinkSpeed: %u",
16812 __func__, pCfg->reportMaxLinkSpeed);
16813 rssidx = 0;
16814 }
16815
16816 maxRate = 0;
16817
16818 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016819 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
16820 OperationalRates, &ORLeng))
16821 {
16822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16823 /*To keep GUI happy*/
16824 return 0;
16825 }
16826
Jeff Johnson295189b2012-06-20 16:38:30 -070016827 for (i = 0; i < ORLeng; i++)
16828 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016829 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016830 {
16831 /* Validate Rate Set */
16832 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
16833 {
16834 currentRate = supported_data_rate[j].supported_rate[rssidx];
16835 break;
16836 }
16837 }
16838 /* Update MAX rate */
16839 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16840 }
16841
16842 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016843 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
16844 ExtendedRates, &ERLeng))
16845 {
16846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16847 /*To keep GUI happy*/
16848 return 0;
16849 }
16850
Jeff Johnson295189b2012-06-20 16:38:30 -070016851 for (i = 0; i < ERLeng; i++)
16852 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016853 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016854 {
16855 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
16856 {
16857 currentRate = supported_data_rate[j].supported_rate[rssidx];
16858 break;
16859 }
16860 }
16861 /* Update MAX rate */
16862 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16863 }
c_hpothu79aab322014-07-14 21:11:01 +053016864
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016865 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053016866 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016867 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053016868 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 {
c_hpothu79aab322014-07-14 21:11:01 +053016870 if (rate_flags & eHAL_TX_RATE_VHT80)
16871 mode = 2;
16872 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
16873 mode = 1;
16874 else
16875 mode = 0;
16876
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016877 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
16878 MCSRates, &MCSLeng))
16879 {
16880 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16881 /*To keep GUI happy*/
16882 return 0;
16883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070016885#ifdef WLAN_FEATURE_11AC
16886 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016887 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070016888 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016889 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016890 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070016891 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070016892 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016893 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016895 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016897 maxMCSIdx = 7;
16898 }
16899 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16900 {
16901 maxMCSIdx = 8;
16902 }
16903 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16904 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016905 //VHT20 is supporting 0~8
16906 if (rate_flags & eHAL_TX_RATE_VHT20)
16907 maxMCSIdx = 8;
16908 else
16909 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016910 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016911
c_hpothu79aab322014-07-14 21:11:01 +053016912 if (0 != rssidx)/*check for scaled */
16913 {
16914 //get middle rate MCS index if rssi=1/2
16915 for (i=0; i <= maxMCSIdx; i++)
16916 {
16917 if (sinfo->signal <= rssiMcsTbl[mode][i])
16918 {
16919 maxMCSIdx = i;
16920 break;
16921 }
16922 }
16923 }
16924
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016925 if (rate_flags & eHAL_TX_RATE_VHT80)
16926 {
16927 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16928 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16929 }
16930 else if (rate_flags & eHAL_TX_RATE_VHT40)
16931 {
16932 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
16933 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
16934 }
16935 else if (rate_flags & eHAL_TX_RATE_VHT20)
16936 {
16937 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
16938 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
16939 }
16940
Leo Chang6f8870f2013-03-26 18:11:36 -070016941 maxSpeedMCS = 1;
16942 if (currentRate > maxRate)
16943 {
16944 maxRate = currentRate;
16945 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016946
Leo Chang6f8870f2013-03-26 18:11:36 -070016947 }
16948 else
16949#endif /* WLAN_FEATURE_11AC */
16950 {
16951 if (rate_flags & eHAL_TX_RATE_HT40)
16952 {
16953 rateFlag |= 1;
16954 }
16955 if (rate_flags & eHAL_TX_RATE_SGI)
16956 {
16957 rateFlag |= 2;
16958 }
16959
Girish Gowli01abcee2014-07-31 20:18:55 +053016960 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053016961 if (rssidx == 1 || rssidx == 2)
16962 {
16963 //get middle rate MCS index if rssi=1/2
16964 for (i=0; i <= 7; i++)
16965 {
16966 if (sinfo->signal <= rssiMcsTbl[mode][i])
16967 {
16968 temp = i+1;
16969 break;
16970 }
16971 }
16972 }
c_hpothu79aab322014-07-14 21:11:01 +053016973
16974 for (i = 0; i < MCSLeng; i++)
16975 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016976 for (j = 0; j < temp; j++)
16977 {
16978 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
16979 {
16980 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016981 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016982 break;
16983 }
16984 }
16985 if ((j < temp) && (currentRate > maxRate))
16986 {
16987 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070016988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016989 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016990 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016991 }
16992 }
16993
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016994 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
16995 {
16996 maxRate = myRate;
16997 maxSpeedMCS = 1;
16998 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017000 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053017001 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070017002 {
17003 maxRate = myRate;
17004 if (rate_flags & eHAL_TX_RATE_LEGACY)
17005 {
17006 maxSpeedMCS = 0;
17007 }
17008 else
17009 {
17010 maxSpeedMCS = 1;
17011 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
17012 }
17013 }
17014
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017015 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070017016 {
17017 sinfo->txrate.legacy = maxRate;
17018#ifdef LINKSPEED_DEBUG_ENABLED
17019 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
17020#endif //LINKSPEED_DEBUG_ENABLED
17021 }
17022 else
17023 {
17024 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070017025#ifdef WLAN_FEATURE_11AC
17026 sinfo->txrate.nss = 1;
17027 if (rate_flags & eHAL_TX_RATE_VHT80)
17028 {
17029 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017030 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070017031 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017032 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070017033 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017034 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
17035 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
17036 }
17037 else if (rate_flags & eHAL_TX_RATE_VHT20)
17038 {
17039 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
17040 }
17041#endif /* WLAN_FEATURE_11AC */
17042 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
17043 {
17044 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
17045 if (rate_flags & eHAL_TX_RATE_HT40)
17046 {
17047 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
17048 }
Leo Chang6f8870f2013-03-26 18:11:36 -070017049 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017050 if (rate_flags & eHAL_TX_RATE_SGI)
17051 {
17052 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
17053 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053017054
Jeff Johnson295189b2012-06-20 16:38:30 -070017055#ifdef LINKSPEED_DEBUG_ENABLED
17056 pr_info("Reporting MCS rate %d flags %x\n",
17057 sinfo->txrate.mcs,
17058 sinfo->txrate.flags );
17059#endif //LINKSPEED_DEBUG_ENABLED
17060 }
17061 }
17062 else
17063 {
17064 // report current rate instead of max rate
17065
17066 if (rate_flags & eHAL_TX_RATE_LEGACY)
17067 {
17068 //provide to the UI in units of 100kbps
17069 sinfo->txrate.legacy = myRate;
17070#ifdef LINKSPEED_DEBUG_ENABLED
17071 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
17072#endif //LINKSPEED_DEBUG_ENABLED
17073 }
17074 else
17075 {
17076 //must be MCS
17077 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070017078#ifdef WLAN_FEATURE_11AC
17079 sinfo->txrate.nss = 1;
17080 if (rate_flags & eHAL_TX_RATE_VHT80)
17081 {
17082 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
17083 }
17084 else
17085#endif /* WLAN_FEATURE_11AC */
17086 {
17087 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
17088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017089 if (rate_flags & eHAL_TX_RATE_SGI)
17090 {
17091 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
17092 }
17093 if (rate_flags & eHAL_TX_RATE_HT40)
17094 {
17095 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
17096 }
Leo Chang6f8870f2013-03-26 18:11:36 -070017097#ifdef WLAN_FEATURE_11AC
17098 else if (rate_flags & eHAL_TX_RATE_VHT80)
17099 {
17100 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
17101 }
17102#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070017103#ifdef LINKSPEED_DEBUG_ENABLED
17104 pr_info("Reporting actual MCS rate %d flags %x\n",
17105 sinfo->txrate.mcs,
17106 sinfo->txrate.flags );
17107#endif //LINKSPEED_DEBUG_ENABLED
17108 }
17109 }
17110 sinfo->filled |= STATION_INFO_TX_BITRATE;
17111
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070017112 sinfo->tx_packets =
17113 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
17114 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
17115 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
17116 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
17117
17118 sinfo->tx_retries =
17119 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
17120 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
17121 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
17122 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
17123
17124 sinfo->tx_failed =
17125 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
17126 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
17127 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
17128 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
17129
17130 sinfo->filled |=
17131 STATION_INFO_TX_PACKETS |
17132 STATION_INFO_TX_RETRIES |
17133 STATION_INFO_TX_FAILED;
17134
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053017135 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
17136 sinfo->filled |= STATION_INFO_RX_PACKETS;
17137
17138 if (rate_flags & eHAL_TX_RATE_LEGACY)
17139 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
17140 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
17141 sinfo->rx_packets);
17142 else
17143 hddLog(LOG1,
17144 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
17145 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
17146 sinfo->tx_packets, sinfo->rx_packets);
17147
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017148 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17149 TRACE_CODE_HDD_CFG80211_GET_STA,
17150 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070017151 EXIT();
17152 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017153}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017154#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17155static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
17156 const u8* mac, struct station_info *sinfo)
17157#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017158static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
17159 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017160#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017161{
17162 int ret;
17163
17164 vos_ssr_protect(__func__);
17165 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
17166 vos_ssr_unprotect(__func__);
17167
17168 return ret;
17169}
17170
17171static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070017172 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070017173{
17174 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017175 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017177 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017178
Jeff Johnsone7245742012-09-05 17:12:55 -070017179 ENTER();
17180
Jeff Johnson295189b2012-06-20 16:38:30 -070017181 if (NULL == pAdapter)
17182 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017184 return -ENODEV;
17185 }
17186
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017187 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17188 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
17189 pAdapter->sessionId, timeout));
17190
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017191 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017192 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017193 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017194 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017195 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017196 }
17197
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017198 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
17199 (TRUE == pHddCtx->hdd_wlan_suspended) &&
17200 (pHddCtx->cfg_ini->fhostArpOffload) &&
17201 (eConnectionState_Associated ==
17202 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
17203 {
Amar Singhald53568e2013-09-26 11:03:45 -070017204
17205 hddLog(VOS_TRACE_LEVEL_INFO,
17206 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053017207 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017208 if (!VOS_IS_STATUS_SUCCESS(vos_status))
17209 {
17210 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017211 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053017212 __func__, vos_status);
17213 }
17214 }
17215
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 /**The get power cmd from the supplicant gets updated by the nl only
17217 *on successful execution of the function call
17218 *we are oppositely mapped w.r.t mode in the driver
17219 **/
17220 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
17221
17222 if (VOS_STATUS_E_FAILURE == vos_status)
17223 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017224 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17225 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017226 return -EINVAL;
17227 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017228 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070017229 return 0;
17230}
17231
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017232static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
17233 struct net_device *dev, bool mode, int timeout)
17234{
17235 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070017236
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017237 vos_ssr_protect(__func__);
17238 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
17239 vos_ssr_unprotect(__func__);
17240
17241 return ret;
17242}
Sushant Kaushik084f6592015-09-10 13:11:56 +053017243
Jeff Johnson295189b2012-06-20 16:38:30 -070017244#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017245static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
17246 struct net_device *netdev,
17247 u8 key_index)
17248{
17249 ENTER();
17250 return 0;
17251}
17252
Jeff Johnson295189b2012-06-20 16:38:30 -070017253static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017254 struct net_device *netdev,
17255 u8 key_index)
17256{
17257 int ret;
17258 vos_ssr_protect(__func__);
17259 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
17260 vos_ssr_unprotect(__func__);
17261 return ret;
17262}
17263#endif //LINUX_VERSION_CODE
17264
17265#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
17266static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
17267 struct net_device *dev,
17268 struct ieee80211_txq_params *params)
17269{
17270 ENTER();
17271 return 0;
17272}
17273#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
17274static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
17275 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070017276{
Jeff Johnsone7245742012-09-05 17:12:55 -070017277 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070017278 return 0;
17279}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017280#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070017281
17282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
17283static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017284 struct net_device *dev,
17285 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070017286{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017287 int ret;
17288
17289 vos_ssr_protect(__func__);
17290 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
17291 vos_ssr_unprotect(__func__);
17292 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070017293}
17294#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
17295static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
17296 struct ieee80211_txq_params *params)
17297{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017298 int ret;
17299
17300 vos_ssr_protect(__func__);
17301 ret = __wlan_hdd_set_txq_params(wiphy, params);
17302 vos_ssr_unprotect(__func__);
17303 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070017304}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017305#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017306
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017307static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017308 struct net_device *dev,
17309 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070017310{
17311 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017312 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017313 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017314 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017315 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017316 v_CONTEXT_t pVosContext = NULL;
17317 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017318
Jeff Johnsone7245742012-09-05 17:12:55 -070017319 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017320
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017321 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070017322 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017323 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070017324 return -EINVAL;
17325 }
17326
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017327 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17328 TRACE_CODE_HDD_CFG80211_DEL_STA,
17329 pAdapter->sessionId, pAdapter->device_mode));
17330
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017331 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17332 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017333 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017334 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017335 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017336 }
17337
Jeff Johnson295189b2012-06-20 16:38:30 -070017338 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070017339 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070017340 )
17341 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017342 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
17343 pSapCtx = VOS_GET_SAP_CB(pVosContext);
17344 if(pSapCtx == NULL){
17345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17346 FL("psapCtx is NULL"));
17347 return -ENOENT;
17348 }
Agrawal Ashish306b75f2017-01-11 19:16:25 +053017349 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
17350 {
17351 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
17352 "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload");
17353 pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
17354 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017355 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070017356 {
17357 v_U16_t i;
17358 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
17359 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017360 if ((pSapCtx->aStaInfo[i].isUsed) &&
17361 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070017362 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017363 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017364 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017365 ETHER_ADDR_LEN);
17366
Jeff Johnson295189b2012-06-20 16:38:30 -070017367 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080017368 "%s: Delete STA with MAC::"
17369 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017370 __func__,
17371 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
17372 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070017373 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017374 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017375 }
17376 }
17377 }
17378 else
17379 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017380
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017381 vos_status = hdd_softap_GetStaId(pAdapter,
17382 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017383 if (!VOS_IS_STATUS_SUCCESS(vos_status))
17384 {
17385 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080017386 "%s: Skip this DEL STA as this is not used::"
17387 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017388 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017389 return -ENOENT;
17390 }
17391
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017392 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017393 {
17394 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080017395 "%s: Skip this DEL STA as deauth is in progress::"
17396 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017397 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017398 return -ENOENT;
17399 }
17400
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017401 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017402
Jeff Johnson295189b2012-06-20 16:38:30 -070017403 hddLog(VOS_TRACE_LEVEL_INFO,
17404 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080017405 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070017406 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017407 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017408
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017409 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017410 if (!VOS_IS_STATUS_SUCCESS(vos_status))
17411 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053017412 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017413 hddLog(VOS_TRACE_LEVEL_INFO,
17414 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080017415 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017416 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017417 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080017418 return -ENOENT;
17419 }
17420
Jeff Johnson295189b2012-06-20 16:38:30 -070017421 }
17422 }
17423
17424 EXIT();
17425
17426 return 0;
17427}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017428
17429#ifdef CFG80211_DEL_STA_V2
Kapil Gupta137ef892016-12-13 19:38:00 +053017430int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017431 struct net_device *dev,
17432 struct station_del_parameters *param)
17433#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017434#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
Kapil Gupta137ef892016-12-13 19:38:00 +053017435int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017436 struct net_device *dev, const u8 *mac)
17437#else
Kapil Gupta137ef892016-12-13 19:38:00 +053017438int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017439 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017440#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017441#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017442{
17443 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017444 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070017445
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017446 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017447
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017448#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017449 if (NULL == param) {
17450 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017451 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017452 return -EINVAL;
17453 }
17454
17455 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
17456 param->subtype, &delStaParams);
17457
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017458#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053017459 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017460 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053017461#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053017462 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
17463
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017464 vos_ssr_unprotect(__func__);
17465
17466 return ret;
17467}
17468
17469static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017470 struct net_device *dev,
17471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17472 const u8 *mac,
17473#else
17474 u8 *mac,
17475#endif
17476 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017477{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017478 hdd_adapter_t *pAdapter;
17479 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017480 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017481#ifdef FEATURE_WLAN_TDLS
17482 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017483
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017484 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017485
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017486 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17487 if (NULL == pAdapter)
17488 {
17489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17490 "%s: Adapter is NULL",__func__);
17491 return -EINVAL;
17492 }
17493 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17494 status = wlan_hdd_validate_context(pHddCtx);
17495 if (0 != status)
17496 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017497 return status;
17498 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017499
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017500 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17501 TRACE_CODE_HDD_CFG80211_ADD_STA,
17502 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017503 mask = params->sta_flags_mask;
17504
17505 set = params->sta_flags_set;
17506
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017508 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
17509 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017510
17511 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
17512 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080017513 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017514 }
17515 }
17516#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017517 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017518 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017519}
17520
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017521#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17522static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
17523 struct net_device *dev, const u8 *mac,
17524 struct station_parameters *params)
17525#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017526static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
17527 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053017528#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017529{
17530 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017531
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017532 vos_ssr_protect(__func__);
17533 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
17534 vos_ssr_unprotect(__func__);
17535
17536 return ret;
17537}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017538#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070017539
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017540static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070017541 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017542{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17544 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017545 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017546 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017547 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017548 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070017549
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017550 ENTER();
17551
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017552 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017553 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017554 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017555 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017556 return -EINVAL;
17557 }
17558
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017559 if (!pmksa) {
17560 hddLog(LOGE, FL("pmksa is NULL"));
17561 return -EINVAL;
17562 }
17563
17564 if (!pmksa->bssid || !pmksa->pmkid) {
17565 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
17566 pmksa->bssid, pmksa->pmkid);
17567 return -EINVAL;
17568 }
17569
17570 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
17571 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17572
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017573 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17574 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017575 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017576 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017577 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017578 }
17579
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017580 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017581 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17582
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017583 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
17584 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017585
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017586 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017587 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017588 &pmk_id, 1, FALSE);
17589
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017590 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17591 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
17592 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017593
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017594 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017595 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017596}
17597
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017598static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
17599 struct cfg80211_pmksa *pmksa)
17600{
17601 int ret;
17602
17603 vos_ssr_protect(__func__);
17604 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
17605 vos_ssr_unprotect(__func__);
17606
17607 return ret;
17608}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017609
Wilson Yang6507c4e2013-10-01 20:11:19 -070017610
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017611static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070017612 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017613{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017614 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17615 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017616 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017617 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017618
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017619 ENTER();
17620
Wilson Yang6507c4e2013-10-01 20:11:19 -070017621 /* Validate pAdapter */
17622 if (NULL == pAdapter)
17623 {
17624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
17625 return -EINVAL;
17626 }
17627
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017628 if (!pmksa) {
17629 hddLog(LOGE, FL("pmksa is NULL"));
17630 return -EINVAL;
17631 }
17632
17633 if (!pmksa->bssid) {
17634 hddLog(LOGE, FL("pmksa->bssid is NULL"));
17635 return -EINVAL;
17636 }
17637
Kiet Lam98c46a12014-10-31 15:34:57 -070017638 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
17639 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
17640
Wilson Yang6507c4e2013-10-01 20:11:19 -070017641 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17642 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017643 if (0 != status)
17644 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017645 return status;
17646 }
17647
17648 /*Retrieve halHandle*/
17649 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17650
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017651 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17652 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
17653 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017654 /* Delete the PMKID CSR cache */
17655 if (eHAL_STATUS_SUCCESS !=
17656 sme_RoamDelPMKIDfromCache(halHandle,
17657 pAdapter->sessionId, pmksa->bssid, FALSE)) {
17658 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
17659 MAC_ADDR_ARRAY(pmksa->bssid));
17660 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017661 }
17662
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017663 EXIT();
17664 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017665}
17666
Wilson Yang6507c4e2013-10-01 20:11:19 -070017667
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017668static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
17669 struct cfg80211_pmksa *pmksa)
17670{
17671 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017672
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017673 vos_ssr_protect(__func__);
17674 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
17675 vos_ssr_unprotect(__func__);
17676
17677 return ret;
17678
17679}
17680
17681static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017682{
Wilson Yang6507c4e2013-10-01 20:11:19 -070017683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17684 tHalHandle halHandle;
17685 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080017686 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017688 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070017689
17690 /* Validate pAdapter */
17691 if (NULL == pAdapter)
17692 {
17693 hddLog(VOS_TRACE_LEVEL_ERROR,
17694 "%s: Invalid Adapter" ,__func__);
17695 return -EINVAL;
17696 }
17697
17698 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17699 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070017700 if (0 != status)
17701 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070017702 return status;
17703 }
17704
17705 /*Retrieve halHandle*/
17706 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
17707
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053017708 /* Flush the PMKID cache in CSR */
17709 if (eHAL_STATUS_SUCCESS !=
17710 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
17711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
17712 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070017713 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017714 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080017715 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017716}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053017717
17718static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
17719{
17720 int ret;
17721
17722 vos_ssr_protect(__func__);
17723 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
17724 vos_ssr_unprotect(__func__);
17725
17726 return ret;
17727}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017728#endif
17729
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017730#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017731static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17732 struct net_device *dev,
17733 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017734{
17735 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17736 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017737 hdd_context_t *pHddCtx;
17738 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017740 ENTER();
17741
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017742 if (NULL == pAdapter)
17743 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017745 return -ENODEV;
17746 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017747 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17748 ret = wlan_hdd_validate_context(pHddCtx);
17749 if (0 != ret)
17750 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017751 return ret;
17752 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017753 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017754 if (NULL == pHddStaCtx)
17755 {
17756 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
17757 return -EINVAL;
17758 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017759
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017760 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17761 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
17762 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017763 // Added for debug on reception of Re-assoc Req.
17764 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
17765 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080017766 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017767 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080017768 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017769 }
17770
17771#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080017772 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017773 ftie->ie_len);
17774#endif
17775
17776 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053017777 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
17778 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017779 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017780
17781 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017782 return 0;
17783}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017784
17785static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
17786 struct net_device *dev,
17787 struct cfg80211_update_ft_ies_params *ftie)
17788{
17789 int ret;
17790
17791 vos_ssr_protect(__func__);
17792 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
17793 vos_ssr_unprotect(__func__);
17794
17795 return ret;
17796}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017797#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017798
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017799#ifdef FEATURE_WLAN_SCAN_PNO
17800
17801void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
17802 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
17803{
17804 int ret;
17805 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
17806 hdd_context_t *pHddCtx;
17807
Nirav Shah80830bf2013-12-31 16:35:12 +053017808 ENTER();
17809
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017810 if (NULL == pAdapter)
17811 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053017812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017813 "%s: HDD adapter is Null", __func__);
17814 return ;
17815 }
17816
17817 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17818 if (NULL == pHddCtx)
17819 {
17820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17821 "%s: HDD context is Null!!!", __func__);
17822 return ;
17823 }
17824
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017825 spin_lock(&pHddCtx->schedScan_lock);
17826 if (TRUE == pHddCtx->isWiphySuspended)
17827 {
17828 pHddCtx->isSchedScanUpdatePending = TRUE;
17829 spin_unlock(&pHddCtx->schedScan_lock);
17830 hddLog(VOS_TRACE_LEVEL_INFO,
17831 "%s: Update cfg80211 scan database after it resume", __func__);
17832 return ;
17833 }
17834 spin_unlock(&pHddCtx->schedScan_lock);
17835
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017836 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
17837
17838 if (0 > ret)
17839 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053017840 else
17841 {
17842 /* Acquire wakelock to handle the case where APP's tries to suspend
17843 * immediatly after the driver gets connect request(i.e after pno)
17844 * from supplicant, this result in app's is suspending and not able
17845 * to process the connect request to AP */
17846 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
17847 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017848 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17850 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017851}
17852
17853/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017854 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017855 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017856 */
17857static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
17858{
17859 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
17860 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017861 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017862 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17863 int status = 0;
Agrawal Ashishcff31692016-12-16 17:17:50 +053017864
17865 if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
17866 {
17867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17868 "%s: PNO is allowed only in STA interface", __func__);
17869 return eHAL_STATUS_FAILURE;
17870 }
17871
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017872 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
17873
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017874 /* The current firmware design does not allow PNO during any
Agrawal Ashishcff31692016-12-16 17:17:50 +053017875 * active sessions. PNO is allowed only in case when sap session
17876 * is present and sapo auth offload feature enabled in firmare.
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017877 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017878 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
17879 {
17880 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017881 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017882
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017883 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
17884 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
17885 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
17886 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
Agrawal Ashishcff31692016-12-16 17:17:50 +053017887 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode &&
17888 !pHddCtx->cfg_ini->enable_sap_auth_offload)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053017889 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017890 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017891 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017892 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017893 }
17894 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17895 pAdapterNode = pNext;
17896 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017897 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017898}
17899
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017900void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
17901{
17902 hdd_adapter_t *pAdapter = callbackContext;
17903 hdd_context_t *pHddCtx;
17904
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017905 ENTER();
17906
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017907 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
17908 {
17909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17910 FL("Invalid adapter or adapter has invalid magic"));
17911 return;
17912 }
17913
17914 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17915 if (0 != wlan_hdd_validate_context(pHddCtx))
17916 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017917 return;
17918 }
17919
c_hpothub53c45d2014-08-18 16:53:14 +053017920 if (VOS_STATUS_SUCCESS != status)
17921 {
17922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017923 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017924 pHddCtx->isPnoEnable = FALSE;
17925 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017926
17927 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
17928 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017929 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017930}
17931
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017932#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \
17933 defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT)
17934/**
17935 * hdd_config_sched_scan_plan() - configures the sched scan plans
17936 * from the framework.
17937 * @pno_req: pointer to PNO scan request
17938 * @request: pointer to scan request from framework
17939 *
17940 * Return: None
17941 */
17942static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
17943 struct cfg80211_sched_scan_request *request,
17944 hdd_context_t *hdd_ctx)
17945{
17946 v_U32_t i = 0;
17947
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017948 pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017949 for (i = 0; i < request->n_scan_plans; i++)
17950 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017951 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
17952 request->scan_plans[i].iterations;
17953 pno_req->scanTimers.aTimerValues[i].uTimerValue =
17954 request->scan_plans[i].interval;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017955 }
17956}
17957#else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017958static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req,
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017959 struct cfg80211_sched_scan_request *request,
17960 hdd_context_t *hdd_ctx)
17961{
17962 v_U32_t i, temp_int;
17963 /* Driver gets only one time interval which is hardcoded in
17964 * supplicant for 10000ms. Taking power consumption into account 6
17965 * timers will be used, Timervalue is increased exponentially
17966 * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each
17967 * timer is configurable through INI param gPNOScanTimerRepeatValue.
17968 * If it is set to 0 only one timer will be used and PNO scan cycle
17969 * will be repeated after each interval specified by supplicant
17970 * till PNO is disabled.
17971 */
17972 if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue)
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017973 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017974 HDD_PNO_SCAN_TIMERS_SET_ONE;
17975 else
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017976 pno_req->scanTimers.ucScanTimersCount =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017977 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17978
17979 temp_int = (request->interval)/1000;
17980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17981 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17982 temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue);
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017983 for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++)
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017984 {
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017985 pno_req->scanTimers.aTimerValues[i].uTimerRepeat =
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017986 hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue;
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017987 pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017988 temp_int *= 2;
17989 }
17990 //Repeat last timer until pno disabled.
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053017991 pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053017992}
17993#endif
17994
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017995/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017996 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
17997 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017998 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017999static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018000 struct net_device *dev, struct cfg80211_sched_scan_request *request)
18001{
18002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018003 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018004 hdd_context_t *pHddCtx;
18005 tHalHandle hHal;
Anurag Chouhan343af7e2016-12-16 13:11:19 +053018006 v_U32_t i, indx, num_ch, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053018007 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
18008 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018009 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
18010 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018011 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018012 hdd_config_t *pConfig = NULL;
18013 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018014
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018015 ENTER();
18016
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018017 if (NULL == pAdapter)
18018 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018020 "%s: HDD adapter is Null", __func__);
18021 return -ENODEV;
18022 }
18023
18024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018025 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018026
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018027 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018028 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018029 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018030 }
18031
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018032 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018033 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18034 if (NULL == hHal)
18035 {
18036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18037 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018038 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018039 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018040 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18041 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
18042 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053018043 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053018044 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053018045 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053018046 {
18047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18048 "%s: aborting the existing scan is unsuccessfull", __func__);
18049 return -EBUSY;
18050 }
18051
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053018052 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053018053 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053018054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053018055 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053018056 return -EBUSY;
18057 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018058
c_hpothu37f21312014-04-09 21:49:54 +053018059 if (TRUE == pHddCtx->isPnoEnable)
18060 {
18061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
18062 FL("already PNO is enabled"));
18063 return -EBUSY;
18064 }
c_hpothu225aa7c2014-10-22 17:45:13 +053018065
18066 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
18067 {
18068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18069 "%s: abort ROC failed ", __func__);
18070 return -EBUSY;
18071 }
18072
c_hpothu37f21312014-04-09 21:49:54 +053018073 pHddCtx->isPnoEnable = TRUE;
18074
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018075 pnoRequest.enable = 1; /*Enable PNO */
18076 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018077
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018078 if (( !pnoRequest.ucNetworksCount ) ||
18079 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018080 {
18081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053018082 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018083 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053018084 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018085 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018086 goto error;
18087 }
18088
18089 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
18090 {
18091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053018092 "%s: Incorrect number of channels %d",
18093 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018094 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018095 goto error;
18096 }
18097
18098 /* Framework provides one set of channels(all)
18099 * common for all saved profile */
18100 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
18101 channels_allowed, &num_channels_allowed))
18102 {
18103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18104 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018105 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018106 goto error;
18107 }
18108 /* Checking each channel against allowed channel list */
18109 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053018110 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018111 {
Nirav Shah80830bf2013-12-31 16:35:12 +053018112 char chList [(request->n_channels*5)+1];
18113 int len;
18114 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018115 {
Nirav Shah80830bf2013-12-31 16:35:12 +053018116 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018117 {
Nirav Shah80830bf2013-12-31 16:35:12 +053018118 if (request->channels[i]->hw_value == channels_allowed[indx])
18119 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018120 if ((!pConfig->enableDFSPnoChnlScan) &&
18121 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
18122 {
18123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18124 "%s : Dropping DFS channel : %d",
18125 __func__,channels_allowed[indx]);
18126 num_ignore_dfs_ch++;
18127 break;
18128 }
18129
Nirav Shah80830bf2013-12-31 16:35:12 +053018130 valid_ch[num_ch++] = request->channels[i]->hw_value;
18131 len += snprintf(chList+len, 5, "%d ",
18132 request->channels[i]->hw_value);
18133 break ;
18134 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018135 }
18136 }
Nirav Shah80830bf2013-12-31 16:35:12 +053018137 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018138
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053018139 /*If all channels are DFS and dropped, then ignore the PNO request*/
18140 if (num_ignore_dfs_ch == request->n_channels)
18141 {
18142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18143 "%s : All requested channels are DFS channels", __func__);
18144 ret = -EINVAL;
18145 goto error;
18146 }
18147 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018148
18149 pnoRequest.aNetworks =
18150 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
18151 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018152 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018153 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18154 FL("failed to allocate memory aNetworks %u"),
18155 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
18156 goto error;
18157 }
18158 vos_mem_zero(pnoRequest.aNetworks,
18159 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
18160
18161 /* Filling per profile params */
18162 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
18163 {
18164 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018165 request->match_sets[i].ssid.ssid_len;
18166
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018167 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
18168 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018169 {
18170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053018171 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018172 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018173 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018174 goto error;
18175 }
18176
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018177 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018178 request->match_sets[i].ssid.ssid,
18179 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053018180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18181 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018182 i, pnoRequest.aNetworks[i].ssId.ssId);
18183 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
18184 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
18185 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018186
18187 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018188 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
18189 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018190
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018191 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018192 }
18193
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018194 for (i = 0; i < request->n_ssids; i++)
18195 {
18196 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018197 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018198 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018199 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018200 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018201 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018202 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018203 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018204 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018205 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053018206 break;
18207 }
18208 j++;
18209 }
18210 }
18211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18212 "Number of hidden networks being Configured = %d",
18213 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080018215 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018216
18217 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
18218 if (pnoRequest.p24GProbeTemplate == NULL)
18219 {
18220 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18221 FL("failed to allocate memory p24GProbeTemplate %u"),
18222 SIR_PNO_MAX_PB_REQ_SIZE);
18223 goto error;
18224 }
18225
18226 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
18227 if (pnoRequest.p5GProbeTemplate == NULL)
18228 {
18229 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18230 FL("failed to allocate memory p5GProbeTemplate %u"),
18231 SIR_PNO_MAX_PB_REQ_SIZE);
18232 goto error;
18233 }
18234
18235 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
18236 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
18237
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053018238 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
18239 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018240 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018241 pnoRequest.us24GProbeTemplateLen = request->ie_len;
18242 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
18243 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018244
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018245 pnoRequest.us5GProbeTemplateLen = request->ie_len;
18246 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
18247 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053018248 }
18249
Anurag Chouhanf3e52b72016-12-21 11:33:37 +053018250 hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx);
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053018251
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018252 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018253
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018254 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018255 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
18256 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018257 pAdapter->pno_req_status = 0;
18258
Nirav Shah80830bf2013-12-31 16:35:12 +053018259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18260 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018261 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
18262 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053018263
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018264 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018265 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018266 hdd_cfg80211_sched_scan_done_callback, pAdapter);
18267 if (eHAL_STATUS_SUCCESS != status)
18268 {
18269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053018270 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018271 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018272 goto error;
18273 }
18274
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018275 ret = wait_for_completion_timeout(
18276 &pAdapter->pno_comp_var,
18277 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
18278 if (0 >= ret)
18279 {
18280 // Did not receive the response for PNO enable in time.
18281 // Assuming the PNO enable was success.
18282 // Returning error from here, because we timeout, results
18283 // in side effect of Wifi (Wifi Setting) not to work.
18284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18285 FL("Timed out waiting for PNO to be Enabled"));
18286 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018287 }
18288
18289 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053018290 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018291
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018292error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18294 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053018295 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018296 if (pnoRequest.aNetworks)
18297 vos_mem_free(pnoRequest.aNetworks);
18298 if (pnoRequest.p24GProbeTemplate)
18299 vos_mem_free(pnoRequest.p24GProbeTemplate);
18300 if (pnoRequest.p5GProbeTemplate)
18301 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018302
18303 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018304 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018305}
18306
18307/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018308 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
18309 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018310 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018311static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
18312 struct net_device *dev, struct cfg80211_sched_scan_request *request)
18313{
18314 int ret;
18315
18316 vos_ssr_protect(__func__);
18317 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
18318 vos_ssr_unprotect(__func__);
18319
18320 return ret;
18321}
18322
18323/*
18324 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
18325 * Function to disable PNO
18326 */
18327static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018328 struct net_device *dev)
18329{
18330 eHalStatus status = eHAL_STATUS_FAILURE;
18331 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18332 hdd_context_t *pHddCtx;
18333 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018334 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018335 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018336
18337 ENTER();
18338
18339 if (NULL == pAdapter)
18340 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018342 "%s: HDD adapter is Null", __func__);
18343 return -ENODEV;
18344 }
18345
18346 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018347
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018348 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018349 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018351 "%s: HDD context is Null", __func__);
18352 return -ENODEV;
18353 }
18354
18355 /* The return 0 is intentional when isLogpInProgress and
18356 * isLoadUnloadInProgress. We did observe a crash due to a return of
18357 * failure in sched_scan_stop , especially for a case where the unload
18358 * of the happens at the same time. The function __cfg80211_stop_sched_scan
18359 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
18360 * success. If it returns a failure , then its next invocation due to the
18361 * clean up of the second interface will have the dev pointer corresponding
18362 * to the first one leading to a crash.
18363 */
18364 if (pHddCtx->isLogpInProgress)
18365 {
18366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18367 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053018368 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018369 return ret;
18370 }
18371
Mihir Shete18156292014-03-11 15:38:30 +053018372 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018373 {
18374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18375 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
18376 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018377 }
18378
18379 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18380 if (NULL == hHal)
18381 {
18382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18383 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018384 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018385 }
18386
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018387 pnoRequest.enable = 0; /* Disable PNO */
18388 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018389
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018390 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18391 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
18392 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053018393
18394 INIT_COMPLETION(pAdapter->pno_comp_var);
18395 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
18396 pnoRequest.callbackContext = pAdapter;
18397 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053018398 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018399 pAdapter->sessionId,
18400 NULL, pAdapter);
18401 if (eHAL_STATUS_SUCCESS != status)
18402 {
18403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18404 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018405 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018406 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018407 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053018408 ret = wait_for_completion_timeout(
18409 &pAdapter->pno_comp_var,
18410 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
18411 if (0 >= ret)
18412 {
18413 // Did not receive the response for PNO disable in time.
18414 // Assuming the PNO disable was success.
18415 // Returning error from here, because we timeout, results
18416 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053018417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053018418 FL("Timed out waiting for PNO to be disabled"));
18419 ret = 0;
18420 }
18421
18422 ret = pAdapter->pno_req_status;
18423 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018424
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018425error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053018426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053018427 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018428
18429 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053018430 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018431}
18432
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053018433/*
18434 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
18435 * NL interface to disable PNO
18436 */
18437static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
18438 struct net_device *dev)
18439{
18440 int ret;
18441
18442 vos_ssr_protect(__func__);
18443 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
18444 vos_ssr_unprotect(__func__);
18445
18446 return ret;
18447}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053018448#endif /*FEATURE_WLAN_SCAN_PNO*/
18449
18450
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018451#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018452#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018453static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18454 struct net_device *dev,
18455 u8 *peer, u8 action_code,
18456 u8 dialog_token,
18457 u16 status_code, u32 peer_capability,
18458 const u8 *buf, size_t len)
18459#else /* TDLS_MGMT_VERSION2 */
18460#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18461static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18462 struct net_device *dev,
18463 const u8 *peer, u8 action_code,
18464 u8 dialog_token, u16 status_code,
18465 u32 peer_capability, bool initiator,
18466 const u8 *buf, size_t len)
18467#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18468static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18469 struct net_device *dev,
18470 const u8 *peer, u8 action_code,
18471 u8 dialog_token, u16 status_code,
18472 u32 peer_capability, const u8 *buf,
18473 size_t len)
18474#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18475static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18476 struct net_device *dev,
18477 u8 *peer, u8 action_code,
18478 u8 dialog_token,
18479 u16 status_code, u32 peer_capability,
18480 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018481#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018482static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18483 struct net_device *dev,
18484 u8 *peer, u8 action_code,
18485 u8 dialog_token,
18486 u16 status_code, const u8 *buf,
18487 size_t len)
18488#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018489#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018490{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018491 hdd_adapter_t *pAdapter;
18492 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018493 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070018494 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080018495 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070018496 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018497 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018498 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018499#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018500 u32 peer_capability = 0;
18501#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018502 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018503 hdd_station_ctx_t *pHddStaCtx = NULL;
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018504 tdlsCtx_t *pHddTdlsCtx;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018505
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018506 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18507 if (NULL == pAdapter)
18508 {
18509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18510 "%s: Adapter is NULL",__func__);
18511 return -EINVAL;
18512 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018513 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18514 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
18515 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018516
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018517 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018518 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018519 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053018520 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018521 "Invalid arguments");
18522 return -EINVAL;
18523 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018524
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018525 if (pHddCtx->isLogpInProgress)
18526 {
18527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18528 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053018529 wlan_hdd_tdls_set_link_status(pAdapter,
18530 peer,
18531 eTDLS_LINK_IDLE,
18532 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018533 return -EBUSY;
18534 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018535
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053018536 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
18537 {
18538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18539 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
18540 return -EAGAIN;
18541 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018542
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018543 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
18544 if (!pHddTdlsCtx) {
18545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18546 "%s: pHddTdlsCtx not valid.", __func__);
18547 }
18548
Hoonki Lee27511902013-03-14 18:19:06 -070018549 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018550 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070018552 "%s: TDLS mode is disabled OR not enabled in FW."
18553 MAC_ADDRESS_STR " action %d declined.",
18554 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018555 return -ENOTSUPP;
18556 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018557
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018558 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18559
18560 if( NULL == pHddStaCtx )
18561 {
18562 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18563 "%s: HDD station context NULL ",__func__);
18564 return -EINVAL;
18565 }
18566
18567 /* STA should be connected and authenticated
18568 * before sending any TDLS frames
18569 */
18570 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
18571 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
18572 {
18573 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18574 "STA is not connected or unauthenticated. "
18575 "connState %u, uIsAuthenticated %u",
18576 pHddStaCtx->conn_info.connState,
18577 pHddStaCtx->conn_info.uIsAuthenticated);
18578 return -EAGAIN;
18579 }
18580
Hoonki Lee27511902013-03-14 18:19:06 -070018581 /* other than teardown frame, other mgmt frames are not sent if disabled */
18582 if (SIR_MAC_TDLS_TEARDOWN != action_code)
18583 {
18584 /* if tdls_mode is disabled to respond to peer's request */
18585 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
18586 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070018588 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018589 " TDLS mode is disabled. action %d declined.",
18590 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070018591
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018592 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070018593 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053018594
18595 if (vos_max_concurrent_connections_reached())
18596 {
18597 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
18598 return -EINVAL;
18599 }
Hoonki Lee27511902013-03-14 18:19:06 -070018600 }
18601
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018602 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
18603 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053018604 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018605 {
18606 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018607 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018608 " TDLS setup is ongoing. action %d declined.",
18609 __func__, MAC_ADDR_ARRAY(peer), action_code);
18610 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018611 }
18612 }
18613
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018614 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
18615 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080018616 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018617 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18618 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018619 {
18620 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
18621 we return error code at 'add_station()'. Hence we have this
18622 check again in addtion to add_station().
18623 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018624 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080018625 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18627 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018628 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
18629 __func__, MAC_ADDR_ARRAY(peer), action_code,
18630 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053018631 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080018632 }
18633 else
18634 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018635 /* maximum reached. tweak to send error code to peer and return
18636 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018637 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18639 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053018640 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
18641 __func__, MAC_ADDR_ARRAY(peer), status_code,
18642 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070018643 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018644 /* fall through to send setup resp with failure status
18645 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080018646 }
18647 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018648 else
18649 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018650 mutex_lock(&pHddCtx->tdls_lock);
18651 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018652 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018653 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018654 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018655 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070018656 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
18657 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018658 return -EPERM;
18659 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018660 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018661 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018662 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018663
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018665 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018666 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
18667 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018668
Hoonki Leea34dd892013-02-05 22:56:02 -080018669 /*Except teardown responder will not be used so just make 0*/
18670 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080018671 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080018672 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018673
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018674 mutex_lock(&pHddCtx->tdls_lock);
18675 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018676
18677 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
18678 responder = pTdlsPeer->is_responder;
18679 else
Hoonki Leea34dd892013-02-05 22:56:02 -080018680 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053018682 "%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 -070018683 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
18684 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018685 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070018686 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080018687 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018688 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018689 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018690
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053018691 /* Discard TDLS setup if peer is removed by user app */
18692 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
18693 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18694 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
18695 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
18696
18697 mutex_lock(&pHddCtx->tdls_lock);
18698 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18699 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
18700 mutex_unlock(&pHddCtx->tdls_lock);
18701 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
18702 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
18703 MAC_ADDR_ARRAY(peer), action_code);
18704 return -EINVAL;
18705 }
18706 mutex_unlock(&pHddCtx->tdls_lock);
18707 }
18708
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018709 /* For explicit trigger of DIS_REQ come out of BMPS for
18710 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070018711 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053018712 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053018713 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
18714 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070018715 {
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018716 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053018717 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018718 "%s: Sending frame action_code %u.Disable BMPS", __func__,
18719 action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018720 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
18721 if (status != VOS_STATUS_SUCCESS) {
18722 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
Ganesh Kondabattini17e60662017-05-25 12:36:07 +053018723 } else {
18724 pHddTdlsCtx->is_tdls_disabled_bmps = true;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018725 }
Hoonki Lee14621352013-04-16 17:51:19 -070018726 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018727 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018728 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018729 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
18730 }
18731 }
Hoonki Lee14621352013-04-16 17:51:19 -070018732 }
18733
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018734 /* make sure doesn't call send_mgmt() while it is pending */
18735 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
18736 {
18737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080018738 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018739 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018740 ret = -EBUSY;
18741 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018742 }
18743
18744 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018745 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
18746
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018747 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
18748 pAdapter->sessionId, peer, action_code, dialog_token,
18749 status_code, peer_capability, (tANI_U8 *)buf, len,
18750 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018751
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018752 if (VOS_STATUS_SUCCESS != status)
18753 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18755 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018756 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018757 ret = -EINVAL;
18758 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018759 }
18760
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18762 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
18763 WAIT_TIME_TDLS_MGMT);
18764
Hoonki Leed37cbb32013-04-20 00:31:14 -070018765 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
18766 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
18767
18768 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018769 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070018770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070018771 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070018772 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018773 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080018774
18775 if (pHddCtx->isLogpInProgress)
18776 {
18777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18778 "%s: LOGP in Progress. Ignore!!!", __func__);
18779 return -EAGAIN;
18780 }
Abhishek Singh837adf22015-10-01 17:37:37 +053018781 if (rc <= 0)
18782 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
18783 WLAN_LOG_INDICATOR_HOST_DRIVER,
18784 WLAN_LOG_REASON_HDD_TIME_OUT,
18785 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080018786
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018787 ret = -EINVAL;
18788 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018789 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053018790 else
18791 {
18792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18793 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
18794 __func__, rc, pAdapter->mgmtTxCompletionStatus);
18795 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018796
Gopichand Nakkala05922802013-03-14 12:23:19 -070018797 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070018798 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018799 ret = max_sta_failed;
18800 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070018801 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018802
Hoonki Leea34dd892013-02-05 22:56:02 -080018803 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
18804 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018805 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018806 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18807 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018808 }
18809 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
18810 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018811 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
18813 }
Hoonki Leea34dd892013-02-05 22:56:02 -080018814 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018815
18816 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053018817
18818tx_failed:
18819 /* add_station will be called before sending TDLS_SETUP_REQ and
18820 * TDLS_SETUP_RSP and as part of add_station driver will enable
18821 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
18822 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
18823 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
18824 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
18825 */
18826
18827 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
18828 (SIR_MAC_TDLS_SETUP_RSP == action_code))
18829 wlan_hdd_tdls_check_bmps(pAdapter);
18830 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018831}
18832
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018833#if TDLS_MGMT_VERSION2
18834static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18835 u8 *peer, u8 action_code, u8 dialog_token,
18836 u16 status_code, u32 peer_capability,
18837 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018838#else /* TDLS_MGMT_VERSION2 */
18839#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18840static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18841 struct net_device *dev,
18842 const u8 *peer, u8 action_code,
18843 u8 dialog_token, u16 status_code,
18844 u32 peer_capability, bool initiator,
18845 const u8 *buf, size_t len)
18846#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18847static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18848 struct net_device *dev,
18849 const u8 *peer, u8 action_code,
18850 u8 dialog_token, u16 status_code,
18851 u32 peer_capability, const u8 *buf,
18852 size_t len)
18853#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18854static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
18855 struct net_device *dev,
18856 u8 *peer, u8 action_code,
18857 u8 dialog_token,
18858 u16 status_code, u32 peer_capability,
18859 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018860#else
18861static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
18862 u8 *peer, u8 action_code, u8 dialog_token,
18863 u16 status_code, const u8 *buf, size_t len)
18864#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018865#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018866{
18867 int ret;
18868
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018869 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018870#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018871 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18872 dialog_token, status_code,
18873 peer_capability, buf, len);
18874#else /* TDLS_MGMT_VERSION2 */
18875#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
18876 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18877 dialog_token, status_code,
18878 peer_capability, initiator,
18879 buf, len);
18880#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
18881 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18882 dialog_token, status_code,
18883 peer_capability, buf, len);
18884#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
18885 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18886 dialog_token, status_code,
18887 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018888#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018889 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
18890 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018891#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018892#endif
18893 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018894
Anand N Sunkad9f80b742015-07-30 20:05:51 +053018895 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018896}
Atul Mittal115287b2014-07-08 13:26:33 +053018897
18898int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018899#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18900 const u8 *peer,
18901#else
Atul Mittal115287b2014-07-08 13:26:33 +053018902 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018903#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018904 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053018905 cfg80211_exttdls_callback callback)
18906{
18907
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018908 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053018909 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018910 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053018911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18912 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
18913 __func__, MAC_ADDR_ARRAY(peer));
18914
18915 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18916 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18917
18918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018919 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18920 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18921 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018922 return -ENOTSUPP;
18923 }
18924
18925 /* To cater the requirement of establishing the TDLS link
18926 * irrespective of the data traffic , get an entry of TDLS peer.
18927 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018928 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018929 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
18930 if (pTdlsPeer == NULL) {
18931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18932 "%s: peer " MAC_ADDRESS_STR " not existing",
18933 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018934 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018935 return -EINVAL;
18936 }
18937
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018938 /* check FW TDLS Off Channel capability */
18939 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018940 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018941 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018942 {
18943 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
18944 pTdlsPeer->peerParams.global_operating_class =
18945 tdls_peer_params->global_operating_class;
18946 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
18947 pTdlsPeer->peerParams.min_bandwidth_kbps =
18948 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018949 /* check configured channel is valid, non dfs and
18950 * not current operating channel */
18951 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
18952 tdls_peer_params->channel)) &&
18953 (pHddStaCtx) &&
18954 (tdls_peer_params->channel !=
18955 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018956 {
18957 pTdlsPeer->isOffChannelConfigured = TRUE;
18958 }
18959 else
18960 {
18961 pTdlsPeer->isOffChannelConfigured = FALSE;
18962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18963 "%s: Configured Tdls Off Channel is not valid", __func__);
18964
18965 }
18966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018967 "%s: tdls_off_channel %d isOffChannelConfigured %d "
18968 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018969 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018970 pTdlsPeer->isOffChannelConfigured,
18971 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018972 }
18973 else
18974 {
18975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018976 "%s: TDLS off channel FW capability %d, "
18977 "host capab %d or Invalid TDLS Peer Params", __func__,
18978 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
18979 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018980 }
18981
Atul Mittal115287b2014-07-08 13:26:33 +053018982 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
18983
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018984 mutex_unlock(&pHddCtx->tdls_lock);
18985
Atul Mittal115287b2014-07-08 13:26:33 +053018986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18987 " %s TDLS Add Force Peer Failed",
18988 __func__);
18989 return -EINVAL;
18990 }
18991 /*EXT TDLS*/
18992
18993 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018994 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18996 " %s TDLS set callback Failed",
18997 __func__);
18998 return -EINVAL;
18999 }
19000
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019001 mutex_unlock(&pHddCtx->tdls_lock);
19002
Atul Mittal115287b2014-07-08 13:26:33 +053019003 return(0);
19004
19005}
19006
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019007int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
19008#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19009 const u8 *peer
19010#else
19011 u8 *peer
19012#endif
19013)
Atul Mittal115287b2014-07-08 13:26:33 +053019014{
19015
19016 hddTdlsPeer_t *pTdlsPeer;
19017 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053019018
Atul Mittal115287b2014-07-08 13:26:33 +053019019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19020 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
19021 __func__, MAC_ADDR_ARRAY(peer));
19022
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053019023 if (0 != wlan_hdd_validate_context(pHddCtx)) {
19024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
19025 return -EINVAL;
19026 }
19027
Atul Mittal115287b2014-07-08 13:26:33 +053019028 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
19029 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
19030
19031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019032 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
19033 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
19034 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053019035 return -ENOTSUPP;
19036 }
19037
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019038 mutex_lock(&pHddCtx->tdls_lock);
19039 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053019040
19041 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019042 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019043 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019044 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053019045 __func__, MAC_ADDR_ARRAY(peer));
19046 return -EINVAL;
19047 }
19048 else {
19049 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
19050 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053019051 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
19052 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019053 /* if channel switch is configured, reset
19054 the channel for this peer */
19055 if (TRUE == pTdlsPeer->isOffChannelConfigured)
19056 {
19057 pTdlsPeer->peerParams.channel = 0;
19058 pTdlsPeer->isOffChannelConfigured = FALSE;
19059 }
Atul Mittal115287b2014-07-08 13:26:33 +053019060 }
19061
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019062 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019063 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019064 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053019065 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019066 }
Atul Mittal115287b2014-07-08 13:26:33 +053019067
19068 /*EXT TDLS*/
19069
19070 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019071 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053019072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19073 " %s TDLS set callback Failed",
19074 __func__);
19075 return -EINVAL;
19076 }
Atul Mittal115287b2014-07-08 13:26:33 +053019077
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019078 mutex_unlock(&pHddCtx->tdls_lock);
19079
19080 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053019081}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019082static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019083#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19084 const u8 *peer,
19085#else
19086 u8 *peer,
19087#endif
19088 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019089{
19090 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19091 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019092 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070019093 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019094
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019095 ENTER();
19096
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053019097 if (!pAdapter) {
19098 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
19099 return -EINVAL;
19100 }
19101
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019102 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19103 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
19104 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019105 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019106 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080019107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070019108 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019109 return -EINVAL;
19110 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080019111
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019112 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019113 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080019114 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019115 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080019116 }
19117
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019118
19119 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080019120 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019121 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080019122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019123 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
19124 "Cannot process TDLS commands",
19125 pHddCtx->cfg_ini->fEnableTDLSSupport,
19126 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019127 return -ENOTSUPP;
19128 }
19129
19130 switch (oper) {
19131 case NL80211_TDLS_ENABLE_LINK:
19132 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019133 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019134 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053019135 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
19136 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053019137 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019138 tANI_U16 numCurrTdlsPeers = 0;
19139 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019140 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019141 tSirMacAddr peerMac;
19142 int channel;
19143 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019144
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19146 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
19147 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019148
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019149 mutex_lock(&pHddCtx->tdls_lock);
19150 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053019151 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053019152 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019153 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019154 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
19155 " (oper %d) not exsting. ignored",
19156 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19157 return -EINVAL;
19158 }
19159
19160 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19161 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
19162 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
19163 "NL80211_TDLS_ENABLE_LINK");
19164
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070019165 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
19166 {
19167 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
19168 MAC_ADDRESS_STR " failed",
19169 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019170 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070019171 return -EINVAL;
19172 }
19173
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053019174 /* before starting tdls connection, set tdls
19175 * off channel established status to default value */
19176 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019177
19178 mutex_unlock(&pHddCtx->tdls_lock);
19179
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053019180 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019181 /* TDLS Off Channel, Disable tdls channel switch,
19182 when there are more than one tdls link */
19183 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053019184 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019185 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019186 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019187 /* get connected peer and send disable tdls off chan */
19188 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019189 if ((connPeer) &&
19190 (connPeer->isOffChannelSupported == TRUE) &&
19191 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019192 {
19193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19194 "%s: More then one peer connected, Disable "
19195 "TDLS channel switch", __func__);
19196
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019197 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019198 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
19199 channel = connPeer->peerParams.channel;
19200
19201 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019202
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019203 ret = sme_SendTdlsChanSwitchReq(
19204 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019205 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019206 peerMac,
19207 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019208 TDLS_OFF_CHANNEL_BW_OFFSET,
19209 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019210 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019211 hddLog(VOS_TRACE_LEVEL_ERROR,
19212 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019213 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019214 }
19215 else
19216 {
19217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19218 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019219 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019220 "isOffChannelConfigured %d",
19221 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019222 (connPeer ? (connPeer->isOffChannelSupported)
19223 : -1),
19224 (connPeer ? (connPeer->isOffChannelConfigured)
19225 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019226 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019227 }
19228 }
19229
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019230 mutex_lock(&pHddCtx->tdls_lock);
19231 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19232 if ( NULL == pTdlsPeer ) {
19233 mutex_unlock(&pHddCtx->tdls_lock);
19234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19235 "%s: " MAC_ADDRESS_STR
19236 " (oper %d) peer got freed in other context. ignored",
19237 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19238 return -EINVAL;
19239 }
19240 peer_status = pTdlsPeer->link_status;
19241 mutex_unlock(&pHddCtx->tdls_lock);
19242
19243 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019244 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019245 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053019246
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019247 if (0 != wlan_hdd_tdls_get_link_establish_params(
19248 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019250 return -EINVAL;
19251 }
19252 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019253
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019254 ret = sme_SendTdlsLinkEstablishParams(
19255 WLAN_HDD_GET_HAL_CTX(pAdapter),
19256 pAdapter->sessionId, peer,
19257 &tdlsLinkEstablishParams);
19258 if (ret != VOS_STATUS_SUCCESS) {
19259 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
19260 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019261 /* Send TDLS peer UAPSD capabilities to the firmware and
19262 * register with the TL on after the response for this operation
19263 * is received .
19264 */
19265 ret = wait_for_completion_interruptible_timeout(
19266 &pAdapter->tdls_link_establish_req_comp,
19267 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053019268
19269 mutex_lock(&pHddCtx->tdls_lock);
19270 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19271 if ( NULL == pTdlsPeer ) {
19272 mutex_unlock(&pHddCtx->tdls_lock);
19273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19274 "%s %d: " MAC_ADDRESS_STR
19275 " (oper %d) peer got freed in other context. ignored",
19276 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
19277 (int)oper);
19278 return -EINVAL;
19279 }
19280 peer_status = pTdlsPeer->link_status;
19281 mutex_unlock(&pHddCtx->tdls_lock);
19282
19283 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019284 {
19285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019286 FL("Link Establish Request Failed Status %ld"),
19287 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053019288 return -EINVAL;
19289 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019290 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053019291
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019292 mutex_lock(&pHddCtx->tdls_lock);
19293 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19294 if ( NULL == pTdlsPeer ) {
19295 mutex_unlock(&pHddCtx->tdls_lock);
19296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19297 "%s: " MAC_ADDRESS_STR
19298 " (oper %d) peer got freed in other context. ignored",
19299 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19300 return -EINVAL;
19301 }
19302
Atul Mittal115287b2014-07-08 13:26:33 +053019303 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
19304 eTDLS_LINK_CONNECTED,
19305 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053019306 staDesc.ucSTAId = pTdlsPeer->staId;
19307 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053019308
19309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19310 "%s: tdlsLinkEstablishParams of peer "
19311 MAC_ADDRESS_STR "uapsdQueues: %d"
19312 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
19313 "isResponder: %d peerstaId: %d",
19314 __func__,
19315 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
19316 tdlsLinkEstablishParams.uapsdQueues,
19317 tdlsLinkEstablishParams.qos,
19318 tdlsLinkEstablishParams.maxSp,
19319 tdlsLinkEstablishParams.isBufSta,
19320 tdlsLinkEstablishParams.isOffChannelSupported,
19321 tdlsLinkEstablishParams.isResponder,
19322 pTdlsPeer->staId);
19323
19324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19325 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
19326 __func__,
19327 staDesc.ucSTAId,
19328 staDesc.ucQosEnabled);
19329
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019330 ret = WLANTL_UpdateTdlsSTAClient(
19331 pHddCtx->pvosContext,
19332 &staDesc);
19333 if (ret != VOS_STATUS_SUCCESS) {
19334 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
19335 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053019336
Gopichand Nakkala471708b2013-06-04 20:03:01 +053019337 /* Mark TDLS client Authenticated .*/
19338 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
19339 pTdlsPeer->staId,
19340 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070019341 if (VOS_STATUS_SUCCESS == status)
19342 {
Hoonki Lee14621352013-04-16 17:51:19 -070019343 if (pTdlsPeer->is_responder == 0)
19344 {
19345 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053019346 tdlsConnInfo_t *tdlsInfo;
19347
19348 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
19349
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053019350 if (!vos_timer_is_initialized(
19351 &pTdlsPeer->initiatorWaitTimeoutTimer))
19352 {
19353 /* Initialize initiator wait callback */
19354 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053019355 &pTdlsPeer->initiatorWaitTimeoutTimer,
19356 VOS_TIMER_TYPE_SW,
19357 wlan_hdd_tdls_initiator_wait_cb,
19358 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053019359 }
Hoonki Lee14621352013-04-16 17:51:19 -070019360 wlan_hdd_tdls_timer_restart(pAdapter,
19361 &pTdlsPeer->initiatorWaitTimeoutTimer,
19362 WAIT_TIME_TDLS_INITIATOR);
19363 /* suspend initiator TX until it receives direct packet from the
19364 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019365 ret = WLANTL_SuspendDataTx(
19366 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
19367 &staId, NULL);
19368 if (ret != VOS_STATUS_SUCCESS) {
19369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
19370 }
Hoonki Lee14621352013-04-16 17:51:19 -070019371 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019372
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019373 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019374 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019375 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019376 suppChannelLen =
19377 tdlsLinkEstablishParams.supportedChannelsLen;
19378
19379 if ((suppChannelLen > 0) &&
19380 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
19381 {
19382 tANI_U8 suppPeerChannel = 0;
19383 int i = 0;
19384 for (i = 0U; i < suppChannelLen; i++)
19385 {
19386 suppPeerChannel =
19387 tdlsLinkEstablishParams.supportedChannels[i];
19388
19389 pTdlsPeer->isOffChannelSupported = FALSE;
19390 if (suppPeerChannel ==
19391 pTdlsPeer->peerParams.channel)
19392 {
19393 pTdlsPeer->isOffChannelSupported = TRUE;
19394 break;
19395 }
19396 }
19397 }
19398 else
19399 {
19400 pTdlsPeer->isOffChannelSupported = FALSE;
19401 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019402 }
19403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19404 "%s: TDLS channel switch request for channel "
19405 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019406 "%d isOffChannelSupported %d", __func__,
19407 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019408 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053019409 suppChannelLen,
19410 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053019411
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019412 /* TDLS Off Channel, Enable tdls channel switch,
19413 when their is only one tdls link and it supports */
19414 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
19415 if ((numCurrTdlsPeers == 1) &&
19416 (TRUE == pTdlsPeer->isOffChannelSupported) &&
19417 (TRUE == pTdlsPeer->isOffChannelConfigured))
19418 {
19419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19420 "%s: Send TDLS channel switch request for channel %d",
19421 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019422
19423 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019424 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
19425 channel = pTdlsPeer->peerParams.channel;
19426
19427 mutex_unlock(&pHddCtx->tdls_lock);
19428
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019429 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
19430 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019431 peerMac,
19432 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019433 TDLS_OFF_CHANNEL_BW_OFFSET,
19434 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019435 if (ret != VOS_STATUS_SUCCESS) {
19436 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
19437 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019438 }
19439 else
19440 {
19441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19442 "%s: TDLS channel switch request not sent"
19443 " numCurrTdlsPeers %d "
19444 "isOffChannelSupported %d "
19445 "isOffChannelConfigured %d",
19446 __func__, numCurrTdlsPeers,
19447 pTdlsPeer->isOffChannelSupported,
19448 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019449 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019450 }
19451
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070019452 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019453 else
19454 mutex_unlock(&pHddCtx->tdls_lock);
19455
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019456 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019457
19458 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053019459 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
19460 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019461 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053019462 int ac;
19463 uint8 ucAc[4] = { WLANTL_AC_VO,
19464 WLANTL_AC_VI,
19465 WLANTL_AC_BK,
19466 WLANTL_AC_BE };
19467 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
19468 for(ac=0; ac < 4; ac++)
19469 {
19470 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
19471 pTdlsPeer->staId, ucAc[ac],
19472 tlTid[ac], tlTid[ac], 0, 0,
19473 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019474 if (status != VOS_STATUS_SUCCESS) {
19475 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
19476 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053019477 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053019478 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019479 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053019480
Bhargav Shah66896792015-10-01 18:17:37 +053019481 /* stop TCP delack timer if TDLS is enable */
19482 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
19483 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053019484 hdd_wlan_tdls_enable_link_event(peer,
19485 pTdlsPeer->isOffChannelSupported,
19486 pTdlsPeer->isOffChannelConfigured,
19487 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019488 }
19489 break;
19490 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080019491 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019492 tANI_U16 numCurrTdlsPeers = 0;
19493 hddTdlsPeer_t *connPeer = NULL;
19494
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19496 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
19497 __func__, MAC_ADDR_ARRAY(peer));
19498
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019499 mutex_lock(&pHddCtx->tdls_lock);
19500 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019501
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019502
Sunil Dutt41de4e22013-11-14 18:09:02 +053019503 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019504 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019505 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
19506 " (oper %d) not exsting. ignored",
19507 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
19508 return -EINVAL;
19509 }
19510
19511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19512 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
19513 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
19514 "NL80211_TDLS_DISABLE_LINK");
19515
Hoonki Lee5305c3a2013-04-29 23:28:59 -070019516 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080019517 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019518 long status;
19519
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053019520 /* set tdls off channel status to false for this peer */
19521 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053019522 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
19523 eTDLS_LINK_TEARING,
19524 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
19525 eTDLS_LINK_UNSPECIFIED:
19526 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019527 mutex_unlock(&pHddCtx->tdls_lock);
19528
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019529 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
19530
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019531 status = sme_DeleteTdlsPeerSta(
19532 WLAN_HDD_GET_HAL_CTX(pAdapter),
19533 pAdapter->sessionId, peer );
19534 if (status != VOS_STATUS_SUCCESS) {
19535 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
19536 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019537
19538 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
19539 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019540
19541 mutex_lock(&pHddCtx->tdls_lock);
19542 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
19543 if ( NULL == pTdlsPeer ) {
19544 mutex_unlock(&pHddCtx->tdls_lock);
19545 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
19546 " peer was freed in other context",
19547 __func__, MAC_ADDR_ARRAY(peer));
19548 return -EINVAL;
19549 }
19550
Atul Mittal271a7652014-09-12 13:18:22 +053019551 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053019552 eTDLS_LINK_IDLE,
19553 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019554 mutex_unlock(&pHddCtx->tdls_lock);
19555
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019556 if (status <= 0)
19557 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070019558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19559 "%s: Del station failed status %ld",
19560 __func__, status);
19561 return -EPERM;
19562 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019563
19564 /* TDLS Off Channel, Enable tdls channel switch,
19565 when their is only one tdls link and it supports */
19566 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
19567 if (numCurrTdlsPeers == 1)
19568 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019569 tSirMacAddr peerMac;
19570 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019571
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019572 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019573 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053019574
19575 if (connPeer == NULL) {
19576 mutex_unlock(&pHddCtx->tdls_lock);
19577 hddLog(VOS_TRACE_LEVEL_ERROR,
19578 "%s connPeer is NULL", __func__);
19579 return -EINVAL;
19580 }
19581
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019582 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
19583 channel = connPeer->peerParams.channel;
19584
19585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19586 "%s: TDLS channel switch "
19587 "isOffChannelSupported %d "
19588 "isOffChannelConfigured %d "
19589 "isOffChannelEstablished %d",
19590 __func__,
19591 (connPeer ? connPeer->isOffChannelSupported : -1),
19592 (connPeer ? connPeer->isOffChannelConfigured : -1),
19593 (connPeer ? connPeer->isOffChannelEstablished : -1));
19594
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019595 if ((connPeer) &&
19596 (connPeer->isOffChannelSupported == TRUE) &&
19597 (connPeer->isOffChannelConfigured == TRUE))
19598 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053019599 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019600 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019601 status = sme_SendTdlsChanSwitchReq(
19602 WLAN_HDD_GET_HAL_CTX(pAdapter),
19603 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019604 peerMac,
19605 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053019606 TDLS_OFF_CHANNEL_BW_OFFSET,
19607 TDLS_CHANNEL_SWITCH_ENABLE);
19608 if (status != VOS_STATUS_SUCCESS) {
19609 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
19610 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019611 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019612 else
19613 mutex_unlock(&pHddCtx->tdls_lock);
19614 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019615 else
19616 {
19617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19618 "%s: TDLS channel switch request not sent "
19619 "numCurrTdlsPeers %d ",
19620 __func__, numCurrTdlsPeers);
19621 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019622 }
19623 else
19624 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053019625 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19627 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080019628 }
Bhargav Shah66896792015-10-01 18:17:37 +053019629 if (numCurrTdlsPeers == 0) {
19630 /* start TCP delack timer if TDLS is disable */
19631 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
19632 hdd_manage_delack_timer(pHddCtx);
19633 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080019634 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070019635 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019636 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019637 {
Atul Mittal115287b2014-07-08 13:26:33 +053019638 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019639
Atul Mittal115287b2014-07-08 13:26:33 +053019640 if (0 != status)
19641 {
19642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019643 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053019644 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019645 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053019646 break;
19647 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019648 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053019649 {
Atul Mittal115287b2014-07-08 13:26:33 +053019650 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
19651 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053019652 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053019653 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053019654
Atul Mittal115287b2014-07-08 13:26:33 +053019655 if (0 != status)
19656 {
19657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019658 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053019659 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053019660 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053019661 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053019662 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019663 case NL80211_TDLS_DISCOVERY_REQ:
19664 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053019666 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019667 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019668 return -ENOTSUPP;
19669 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19671 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019672 return -ENOTSUPP;
19673 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019674
19675 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019676 return 0;
19677}
Chilam NG571c65a2013-01-19 12:27:36 +053019678
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019679static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019680#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
19681 const u8 *peer,
19682#else
19683 u8 *peer,
19684#endif
19685 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019686{
19687 int ret;
19688
19689 vos_ssr_protect(__func__);
19690 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
19691 vos_ssr_unprotect(__func__);
19692
19693 return ret;
19694}
19695
Chilam NG571c65a2013-01-19 12:27:36 +053019696int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
19697 struct net_device *dev, u8 *peer)
19698{
Arif Hussaina7c8e412013-11-20 11:06:42 -080019699 hddLog(VOS_TRACE_LEVEL_INFO,
19700 "tdls send discover req: "MAC_ADDRESS_STR,
19701 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019702#if TDLS_MGMT_VERSION2
19703 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19704 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19705#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019706#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
19707 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19708 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
19709#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
19710 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19711 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19712#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
19713 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19714 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
19715#else
Chilam NG571c65a2013-01-19 12:27:36 +053019716 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
19717 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053019718#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053019719#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053019720}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019721#endif
19722
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019723#ifdef WLAN_FEATURE_GTK_OFFLOAD
19724/*
19725 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
19726 * Callback rountine called upon receiving response for
19727 * get offload info
19728 */
19729void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
19730 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
19731{
19732
19733 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019734 tANI_U8 tempReplayCounter[8];
19735 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019736
19737 ENTER();
19738
19739 if (NULL == pAdapter)
19740 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053019741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019742 "%s: HDD adapter is Null", __func__);
19743 return ;
19744 }
19745
19746 if (NULL == pGtkOffloadGetInfoRsp)
19747 {
19748 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19749 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
19750 return ;
19751 }
19752
19753 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
19754 {
19755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19756 "%s: wlan Failed to get replay counter value",
19757 __func__);
19758 return ;
19759 }
19760
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019761 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19762 /* Update replay counter */
19763 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
19764 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19765
19766 {
19767 /* changing from little to big endian since supplicant
19768 * works on big endian format
19769 */
19770 int i;
19771 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
19772
19773 for (i = 0; i < 8; i++)
19774 {
19775 tempReplayCounter[7-i] = (tANI_U8)p[i];
19776 }
19777 }
19778
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019779 /* Update replay counter to NL */
19780 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019781 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019782}
19783
19784/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019785 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019786 * This function is used to offload GTK rekeying job to the firmware.
19787 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019788int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019789 struct cfg80211_gtk_rekey_data *data)
19790{
19791 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19792 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19793 hdd_station_ctx_t *pHddStaCtx;
19794 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019795 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019796 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019797 eHalStatus status = eHAL_STATUS_FAILURE;
19798
19799 ENTER();
19800
19801 if (NULL == pAdapter)
19802 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053019803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019804 "%s: HDD adapter is Null", __func__);
19805 return -ENODEV;
19806 }
19807
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053019808 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19809 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
19810 pAdapter->sessionId, pAdapter->device_mode));
19811
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019812 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019813 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019814 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053019815 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019816 }
19817
19818 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19819 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
19820 if (NULL == hHal)
19821 {
19822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19823 "%s: HAL context is Null!!!", __func__);
19824 return -EAGAIN;
19825 }
19826
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019827 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
19828 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
19829 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
19830 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019831 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019832 {
19833 /* changing from big to little endian since driver
19834 * works on little endian format
19835 */
19836 tANI_U8 *p =
19837 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
19838 int i;
19839
19840 for (i = 0; i < 8; i++)
19841 {
19842 p[7-i] = data->replay_ctr[i];
19843 }
19844 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019845
19846 if (TRUE == pHddCtx->hdd_wlan_suspended)
19847 {
19848 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019849 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
19850 sizeof (tSirGtkOffloadParams));
19851 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019852 pAdapter->sessionId);
19853
19854 if (eHAL_STATUS_SUCCESS != status)
19855 {
19856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19857 "%s: sme_SetGTKOffload failed, returned %d",
19858 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019859
19860 /* Need to clear any trace of key value in the memory.
19861 * Thus zero out the memory even though it is local
19862 * variable.
19863 */
19864 vos_mem_zero(&hddGtkOffloadReqParams,
19865 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019866 return status;
19867 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19869 "%s: sme_SetGTKOffload successfull", __func__);
19870 }
19871 else
19872 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19874 "%s: wlan not suspended GTKOffload request is stored",
19875 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019876 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019877
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053019878 /* Need to clear any trace of key value in the memory.
19879 * Thus zero out the memory even though it is local
19880 * variable.
19881 */
19882 vos_mem_zero(&hddGtkOffloadReqParams,
19883 sizeof(hddGtkOffloadReqParams));
19884
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019885 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053019886 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019887}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019888
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019889int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
19890 struct cfg80211_gtk_rekey_data *data)
19891{
19892 int ret;
19893
19894 vos_ssr_protect(__func__);
19895 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
19896 vos_ssr_unprotect(__func__);
19897
19898 return ret;
19899}
19900#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019901/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019902 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019903 * This function is used to set access control policy
19904 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019905static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19906 struct net_device *dev,
19907 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019908{
19909 int i;
19910 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19911 hdd_hostapd_state_t *pHostapdState;
19912 tsap_Config_t *pConfig;
19913 v_CONTEXT_t pVosContext = NULL;
19914 hdd_context_t *pHddCtx;
19915 int status;
19916
19917 ENTER();
19918
19919 if (NULL == pAdapter)
19920 {
19921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19922 "%s: HDD adapter is Null", __func__);
19923 return -ENODEV;
19924 }
19925
19926 if (NULL == params)
19927 {
19928 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19929 "%s: params is Null", __func__);
19930 return -EINVAL;
19931 }
19932
19933 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19934 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019935 if (0 != status)
19936 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019937 return status;
19938 }
19939
19940 pVosContext = pHddCtx->pvosContext;
19941 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
19942
19943 if (NULL == pHostapdState)
19944 {
19945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19946 "%s: pHostapdState is Null", __func__);
19947 return -EINVAL;
19948 }
19949
19950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
19951 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019952 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19953 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
19954 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019955
19956 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
19957 {
19958 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
19959
19960 /* default value */
19961 pConfig->num_accept_mac = 0;
19962 pConfig->num_deny_mac = 0;
19963
19964 /**
19965 * access control policy
19966 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
19967 * listed in hostapd.deny file.
19968 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
19969 * listed in hostapd.accept file.
19970 */
19971 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
19972 {
19973 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
19974 }
19975 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
19976 {
19977 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
19978 }
19979 else
19980 {
19981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19982 "%s:Acl Policy : %d is not supported",
19983 __func__, params->acl_policy);
19984 return -ENOTSUPP;
19985 }
19986
19987 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
19988 {
19989 pConfig->num_accept_mac = params->n_acl_entries;
19990 for (i = 0; i < params->n_acl_entries; i++)
19991 {
19992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19993 "** Add ACL MAC entry %i in WhiletList :"
19994 MAC_ADDRESS_STR, i,
19995 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19996
19997 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
19998 sizeof(qcmacaddr));
19999 }
20000 }
20001 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
20002 {
20003 pConfig->num_deny_mac = params->n_acl_entries;
20004 for (i = 0; i < params->n_acl_entries; i++)
20005 {
20006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20007 "** Add ACL MAC entry %i in BlackList :"
20008 MAC_ADDRESS_STR, i,
20009 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
20010
20011 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
20012 sizeof(qcmacaddr));
20013 }
20014 }
20015
20016 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
20017 {
20018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20019 "%s: SAP Set Mac Acl fail", __func__);
20020 return -EINVAL;
20021 }
20022 }
20023 else
20024 {
20025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053020026 "%s: Invalid device_mode = %s (%d)",
20027 __func__, hdd_device_modetoString(pAdapter->device_mode),
20028 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020029 return -EINVAL;
20030 }
20031
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020032 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020033 return 0;
20034}
20035
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053020036static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
20037 struct net_device *dev,
20038 const struct cfg80211_acl_data *params)
20039{
20040 int ret;
20041 vos_ssr_protect(__func__);
20042 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
20043 vos_ssr_unprotect(__func__);
20044
20045 return ret;
20046}
20047
Leo Chang9056f462013-08-01 19:21:11 -070020048#ifdef WLAN_NL80211_TESTMODE
20049#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070020050void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070020051(
20052 void *pAdapter,
20053 void *indCont
20054)
20055{
Leo Changd9df8aa2013-09-26 13:32:26 -070020056 tSirLPHBInd *lphbInd;
20057 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053020058 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070020059
20060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070020061 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070020062
c_hpothu73f35e62014-04-18 13:40:08 +053020063 if (pAdapter == NULL)
20064 {
20065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20066 "%s: pAdapter is NULL\n",__func__);
20067 return;
20068 }
20069
Leo Chang9056f462013-08-01 19:21:11 -070020070 if (NULL == indCont)
20071 {
20072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070020073 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070020074 return;
20075 }
20076
c_hpothu73f35e62014-04-18 13:40:08 +053020077 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070020078 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070020079 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053020080 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070020081 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070020082 GFP_ATOMIC);
20083 if (!skb)
20084 {
20085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20086 "LPHB timeout, NL buffer alloc fail");
20087 return;
20088 }
20089
Leo Changac3ba772013-10-07 09:47:04 -070020090 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070020091 {
20092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20093 "WLAN_HDD_TM_ATTR_CMD put fail");
20094 goto nla_put_failure;
20095 }
Leo Changac3ba772013-10-07 09:47:04 -070020096 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070020097 {
20098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20099 "WLAN_HDD_TM_ATTR_TYPE put fail");
20100 goto nla_put_failure;
20101 }
Leo Changac3ba772013-10-07 09:47:04 -070020102 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070020103 sizeof(tSirLPHBInd), lphbInd))
20104 {
20105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20106 "WLAN_HDD_TM_ATTR_DATA put fail");
20107 goto nla_put_failure;
20108 }
Leo Chang9056f462013-08-01 19:21:11 -070020109 cfg80211_testmode_event(skb, GFP_ATOMIC);
20110 return;
20111
20112nla_put_failure:
20113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20114 "NLA Put fail");
20115 kfree_skb(skb);
20116
20117 return;
20118}
20119#endif /* FEATURE_WLAN_LPHB */
20120
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020121static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070020122{
20123 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
20124 int err = 0;
20125#ifdef FEATURE_WLAN_LPHB
20126 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070020127 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020128
20129 ENTER();
20130
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020131 err = wlan_hdd_validate_context(pHddCtx);
20132 if (0 != err)
20133 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020134 return err;
20135 }
Leo Chang9056f462013-08-01 19:21:11 -070020136#endif /* FEATURE_WLAN_LPHB */
20137
20138 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
20139 if (err)
20140 {
20141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20142 "%s Testmode INV ATTR", __func__);
20143 return err;
20144 }
20145
20146 if (!tb[WLAN_HDD_TM_ATTR_CMD])
20147 {
20148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20149 "%s Testmode INV CMD", __func__);
20150 return -EINVAL;
20151 }
20152
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020153 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20154 TRACE_CODE_HDD_CFG80211_TESTMODE,
20155 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070020156 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
20157 {
20158#ifdef FEATURE_WLAN_LPHB
20159 /* Low Power Heartbeat configuration request */
20160 case WLAN_HDD_TM_CMD_WLAN_HB:
20161 {
20162 int buf_len;
20163 void *buf;
20164 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080020165 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070020166
20167 if (!tb[WLAN_HDD_TM_ATTR_DATA])
20168 {
20169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20170 "%s Testmode INV DATA", __func__);
20171 return -EINVAL;
20172 }
20173
20174 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
20175 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080020176
Manjeet Singh3c577442017-02-10 19:03:38 +053020177 if (buf_len > sizeof(*hb_params)) {
20178 hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"),
20179 buf_len);
20180 return -ERANGE;
20181 }
20182
Amar Singhal05852702014-02-04 14:40:00 -080020183 hb_params_temp =(tSirLPHBReq *)buf;
20184 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
20185 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
20186 return -EINVAL;
20187
Leo Chang9056f462013-08-01 19:21:11 -070020188 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
20189 if (NULL == hb_params)
20190 {
20191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20192 "%s Request Buffer Alloc Fail", __func__);
20193 return -EINVAL;
20194 }
20195
20196 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070020197 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
20198 hb_params,
20199 wlan_hdd_cfg80211_lphb_ind_handler);
20200 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070020201 {
Leo Changd9df8aa2013-09-26 13:32:26 -070020202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20203 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070020204 vos_mem_free(hb_params);
20205 }
Leo Chang9056f462013-08-01 19:21:11 -070020206 return 0;
20207 }
20208#endif /* FEATURE_WLAN_LPHB */
20209 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053020210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
20211 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070020212 return -EOPNOTSUPP;
20213 }
20214
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020215 EXIT();
20216 return err;
Leo Chang9056f462013-08-01 19:21:11 -070020217}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020218
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053020219static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
20220#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
20221 struct wireless_dev *wdev,
20222#endif
20223 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020224{
20225 int ret;
20226
20227 vos_ssr_protect(__func__);
20228 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
20229 vos_ssr_unprotect(__func__);
20230
20231 return ret;
20232}
Leo Chang9056f462013-08-01 19:21:11 -070020233#endif /* CONFIG_NL80211_TESTMODE */
20234
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020235extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020236static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020237 struct net_device *dev,
20238 int idx, struct survey_info *survey)
20239{
20240 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
20241 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053020242 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020243 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053020244 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020245 v_S7_t snr,rssi;
20246 int status, i, j, filled = 0;
20247
20248 ENTER();
20249
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020250 if (NULL == pAdapter)
20251 {
20252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
20253 "%s: HDD adapter is Null", __func__);
20254 return -ENODEV;
20255 }
20256
20257 if (NULL == wiphy)
20258 {
20259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
20260 "%s: wiphy is Null", __func__);
20261 return -ENODEV;
20262 }
20263
20264 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
20265 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020266 if (0 != status)
20267 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020268 return status;
20269 }
20270
Mihir Sheted9072e02013-08-21 17:02:29 +053020271 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
20272
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020273 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053020274 0 != pAdapter->survey_idx ||
20275 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020276 {
20277 /* The survey dump ops when implemented completely is expected to
20278 * return a survey of all channels and the ops is called by the
20279 * kernel with incremental values of the argument 'idx' till it
20280 * returns -ENONET. But we can only support the survey for the
20281 * operating channel for now. survey_idx is used to track
20282 * that the ops is called only once and then return -ENONET for
20283 * the next iteration
20284 */
20285 pAdapter->survey_idx = 0;
20286 return -ENONET;
20287 }
20288
Mukul Sharma9d5233b2015-06-11 20:28:20 +053020289 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
20290 {
20291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20292 "%s: Roaming in progress, hence return ", __func__);
20293 return -ENONET;
20294 }
20295
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020296 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
20297
20298 wlan_hdd_get_snr(pAdapter, &snr);
20299 wlan_hdd_get_rssi(pAdapter, &rssi);
20300
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020301 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20302 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
20303 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020304 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
20305 hdd_wlan_get_freq(channel, &freq);
20306
20307
20308 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
20309 {
20310 if (NULL == wiphy->bands[i])
20311 {
20312 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
20313 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
20314 continue;
20315 }
20316
20317 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
20318 {
20319 struct ieee80211_supported_band *band = wiphy->bands[i];
20320
20321 if (band->channels[j].center_freq == (v_U16_t)freq)
20322 {
20323 survey->channel = &band->channels[j];
20324 /* The Rx BDs contain SNR values in dB for the received frames
20325 * while the supplicant expects noise. So we calculate and
20326 * return the value of noise (dBm)
20327 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
20328 */
20329 survey->noise = rssi - snr;
20330 survey->filled = SURVEY_INFO_NOISE_DBM;
20331 filled = 1;
20332 }
20333 }
20334 }
20335
20336 if (filled)
20337 pAdapter->survey_idx = 1;
20338 else
20339 {
20340 pAdapter->survey_idx = 0;
20341 return -ENONET;
20342 }
20343
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020344 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020345 return 0;
20346}
20347
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053020348static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
20349 struct net_device *dev,
20350 int idx, struct survey_info *survey)
20351{
20352 int ret;
20353
20354 vos_ssr_protect(__func__);
20355 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
20356 vos_ssr_unprotect(__func__);
20357
20358 return ret;
20359}
20360
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020361/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020362 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020363 * this is called when cfg80211 driver resume
20364 * driver updates latest sched_scan scan result(if any) to cfg80211 database
20365 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020366int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020367{
20368 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
20369 hdd_adapter_t *pAdapter;
20370 hdd_adapter_list_node_t *pAdapterNode, *pNext;
20371 VOS_STATUS status = VOS_STATUS_SUCCESS;
20372
20373 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020374
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053020375 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020376 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020377 return 0;
20378 }
20379
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020380 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
20381 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020382
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053020383 if (pHddCtx->is_ap_mode_wow_supported)
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020384 {
20385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20386 "%s: Resume SoftAP", __func__);
20387 hdd_set_wlan_suspend_mode(false);
20388 }
20389
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020390 spin_lock(&pHddCtx->schedScan_lock);
20391 pHddCtx->isWiphySuspended = FALSE;
20392 if (TRUE != pHddCtx->isSchedScanUpdatePending)
20393 {
20394 spin_unlock(&pHddCtx->schedScan_lock);
20395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20396 "%s: Return resume is not due to PNO indication", __func__);
20397 return 0;
20398 }
20399 // Reset flag to avoid updatating cfg80211 data old results again
20400 pHddCtx->isSchedScanUpdatePending = FALSE;
20401 spin_unlock(&pHddCtx->schedScan_lock);
20402
20403 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
20404
20405 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
20406 {
20407 pAdapter = pAdapterNode->pAdapter;
20408 if ( (NULL != pAdapter) &&
20409 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
20410 {
20411 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020412 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
20414 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020415 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020416 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020417 {
20418 /* Acquire wakelock to handle the case where APP's tries to
20419 * suspend immediately after updating the scan results. Whis
20420 * results in app's is in suspended state and not able to
20421 * process the connect request to AP
20422 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053020423 hdd_prevent_suspend_timeout(2000,
20424 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020425 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053020426 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020427
20428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20429 "%s : cfg80211 scan result database updated", __func__);
20430
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020431 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020432 return 0;
20433
20434 }
20435 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
20436 pAdapterNode = pNext;
20437 }
20438
20439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20440 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020441 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020442 return 0;
20443}
20444
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020445int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
20446{
20447 int ret;
20448
20449 vos_ssr_protect(__func__);
20450 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
20451 vos_ssr_unprotect(__func__);
20452
20453 return ret;
20454}
20455
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020456/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020457 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020458 * this is called when cfg80211 driver suspends
20459 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020460int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020461 struct cfg80211_wowlan *wow)
20462{
20463 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020464 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020465
20466 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053020467
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020468 ret = wlan_hdd_validate_context(pHddCtx);
20469 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020470 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020471 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020472 }
20473
Nishank Aggarwalc11826c2016-12-15 18:54:10 +053020474 if (pHddCtx->is_ap_mode_wow_supported) {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053020475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
20476 "%s: Suspend SoftAP", __func__);
20477 hdd_set_wlan_suspend_mode(true);
20478 }
20479
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053020480
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053020481 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
20482 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
20483 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020484 pHddCtx->isWiphySuspended = TRUE;
20485
20486 EXIT();
20487
20488 return 0;
20489}
20490
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053020491int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
20492 struct cfg80211_wowlan *wow)
20493{
20494 int ret;
20495
20496 vos_ssr_protect(__func__);
20497 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
20498 vos_ssr_unprotect(__func__);
20499
20500 return ret;
20501}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020502
20503#ifdef FEATURE_OEM_DATA_SUPPORT
20504static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020505 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020506{
20507 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
20508
20509 ENTER();
20510
20511 if (wlan_hdd_validate_context(pHddCtx)) {
20512 return;
20513 }
20514 if (!pMsg)
20515 {
20516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
20517 return;
20518 }
20519
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020520 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020521
20522 EXIT();
20523 return;
20524
20525}
20526
20527void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020528 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020529{
20530 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
20531
20532 ENTER();
20533
20534 if (wlan_hdd_validate_context(pHddCtx)) {
20535 return;
20536 }
20537
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020538 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020539
20540 switch(evType) {
20541 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053020542 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053020543 break;
20544 default:
20545 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
20546 break;
20547 }
20548 EXIT();
20549}
20550#endif
20551
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020552#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
20553 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020554/**
20555 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
20556 * @wiphy: Pointer to wiphy
20557 * @wdev: Pointer to wireless device structure
20558 *
20559 * This function is used to abort an ongoing scan
20560 *
20561 * Return: None
20562 */
20563static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20564 struct wireless_dev *wdev)
20565{
20566 struct net_device *dev = wdev->netdev;
20567 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
20568 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
20569 int ret;
20570
20571 ENTER();
20572
20573 if (NULL == adapter) {
20574 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
20575 return;
20576 }
20577
20578 ret = wlan_hdd_validate_context(hdd_ctx);
20579 if (0 != ret)
20580 return;
20581
20582 wlan_hdd_scan_abort(adapter);
20583
20584 return;
20585}
20586
20587/**
20588 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
20589 * @wiphy: Pointer to wiphy
20590 * @wdev: Pointer to wireless device structure
20591 *
20592 * Return: None
20593 */
20594void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
20595 struct wireless_dev *wdev)
20596{
20597 vos_ssr_protect(__func__);
20598 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
20599 vos_ssr_unprotect(__func__);
20600
20601 return;
20602}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020603#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020604
Jeff Johnson295189b2012-06-20 16:38:30 -070020605/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053020606static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070020607{
20608 .add_virtual_intf = wlan_hdd_add_virtual_intf,
20609 .del_virtual_intf = wlan_hdd_del_virtual_intf,
20610 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
20611 .change_station = wlan_hdd_change_station,
20612#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
20613 .add_beacon = wlan_hdd_cfg80211_add_beacon,
20614 .del_beacon = wlan_hdd_cfg80211_del_beacon,
20615 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020616#else
20617 .start_ap = wlan_hdd_cfg80211_start_ap,
20618 .change_beacon = wlan_hdd_cfg80211_change_beacon,
20619 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070020620#endif
20621 .change_bss = wlan_hdd_cfg80211_change_bss,
20622 .add_key = wlan_hdd_cfg80211_add_key,
20623 .get_key = wlan_hdd_cfg80211_get_key,
20624 .del_key = wlan_hdd_cfg80211_del_key,
20625 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020626#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070020627 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080020628#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020629 .scan = wlan_hdd_cfg80211_scan,
20630 .connect = wlan_hdd_cfg80211_connect,
20631 .disconnect = wlan_hdd_cfg80211_disconnect,
20632 .join_ibss = wlan_hdd_cfg80211_join_ibss,
20633 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
20634 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
20635 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
20636 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070020637 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
20638 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053020639 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070020640#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
20641 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
20642 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
20643 .set_txq_params = wlan_hdd_set_txq_params,
20644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020645 .get_station = wlan_hdd_cfg80211_get_station,
20646 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
20647 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070020648 .add_station = wlan_hdd_cfg80211_add_station,
20649#ifdef FEATURE_WLAN_LFR
20650 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
20651 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
20652 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
20653#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070020654#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
20655 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
20656#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080020657#ifdef FEATURE_WLAN_TDLS
20658 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
20659 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
20660#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053020661#ifdef WLAN_FEATURE_GTK_OFFLOAD
20662 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
20663#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053020664#ifdef FEATURE_WLAN_SCAN_PNO
20665 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
20666 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
20667#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053020668 .resume = wlan_hdd_cfg80211_resume_wlan,
20669 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053020670 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070020671#ifdef WLAN_NL80211_TESTMODE
20672 .testmode_cmd = wlan_hdd_cfg80211_testmode,
20673#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053020674 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020675#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
20676 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053020677 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053020678#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070020679};
20680