blob: 39e1b2c8b85cf4c2dab103d34d3a6dfd94e55944 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Masti, Narayanraddie1892a52015-12-15 15:01:01 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +053098#include "qwlan_version.h"
c_manjeecfd1efb2015-09-25 19:32:34 +053099#include "wlan_logging_sock_svc.h"
Agrawal Ashishcfe83282016-09-29 13:03:45 +0530100#include "wlan_hdd_misc.h"
Sushant Kaushik084f6592015-09-10 13:11:56 +0530101
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103#define g_mode_rates_size (12)
104#define a_mode_rates_size (8)
105#define FREQ_BASE_80211G (2407)
106#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700107#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530108#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800110 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700111
112#define HDD2GHZCHAN(freq, chan, flag) { \
113 .band = IEEE80211_BAND_2GHZ, \
114 .center_freq = (freq), \
115 .hw_value = (chan),\
116 .flags = (flag), \
117 .max_antenna_gain = 0 ,\
118 .max_power = 30, \
119}
120
121#define HDD5GHZCHAN(freq, chan, flag) { \
122 .band = IEEE80211_BAND_5GHZ, \
123 .center_freq = (freq), \
124 .hw_value = (chan),\
125 .flags = (flag), \
126 .max_antenna_gain = 0 ,\
127 .max_power = 30, \
128}
129
130#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
131{\
132 .bitrate = rate, \
133 .hw_value = rate_id, \
134 .flags = flag, \
135}
136
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530137#ifdef WLAN_FEATURE_VOWIFI_11R
138#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
139#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
140#endif
141
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530142#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530143#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144
Sunil Duttc69bccb2014-05-26 21:30:20 +0530145#ifdef WLAN_FEATURE_LINK_LAYER_STATS
146/*
147 * Used to allocate the size of 4096 for the link layer stats.
148 * The size of 4096 is considered assuming that all data per
149 * respective event fit with in the limit.Please take a call
150 * on the limit based on the data requirements on link layer
151 * statistics.
152 */
153#define LL_STATS_EVENT_BUF_SIZE 4096
154#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530155#ifdef WLAN_FEATURE_EXTSCAN
156/*
157 * Used to allocate the size of 4096 for the EXTScan NL data.
158 * The size of 4096 is considered assuming that all data per
159 * respective event fit with in the limit.Please take a call
160 * on the limit based on the data requirements.
161 */
162
163#define EXTSCAN_EVENT_BUF_SIZE 4096
164#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
165#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530166
Atul Mittal115287b2014-07-08 13:26:33 +0530167/*EXT TDLS*/
168/*
169 * Used to allocate the size of 4096 for the TDLS.
170 * The size of 4096 is considered assuming that all data per
171 * respective event fit with in the limit.Please take a call
172 * on the limit based on the data requirements on link layer
173 * statistics.
174 */
175#define EXTTDLS_EVENT_BUF_SIZE 4096
176
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530177/*
178 * Values for Mac spoofing feature
179 *
180 */
181#define MAC_ADDR_SPOOFING_FW_HOST_DISABLE 0
182#define MAC_ADDR_SPOOFING_FW_HOST_ENABLE 1
183#define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE 2
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +0530184#define MAC_ADDR_SPOOFING_DEFER_INTERVAL 10 //in ms
185
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530186
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530187static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700188{
189 WLAN_CIPHER_SUITE_WEP40,
190 WLAN_CIPHER_SUITE_WEP104,
191 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800192#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700193#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
194 WLAN_CIPHER_SUITE_KRK,
195 WLAN_CIPHER_SUITE_CCMP,
196#else
197 WLAN_CIPHER_SUITE_CCMP,
198#endif
199#ifdef FEATURE_WLAN_WAPI
200 WLAN_CIPHER_SUITE_SMS4,
201#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700202#ifdef WLAN_FEATURE_11W
203 WLAN_CIPHER_SUITE_AES_CMAC,
204#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700205};
206
207static inline int is_broadcast_ether_addr(const u8 *addr)
208{
209 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
210 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
211}
212
Agrawal Ashish97dec502015-11-26 20:20:58 +0530213const static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530214{
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 HDD2GHZCHAN(2412, 1, 0) ,
216 HDD2GHZCHAN(2417, 2, 0) ,
217 HDD2GHZCHAN(2422, 3, 0) ,
218 HDD2GHZCHAN(2427, 4, 0) ,
219 HDD2GHZCHAN(2432, 5, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2442, 7, 0) ,
222 HDD2GHZCHAN(2447, 8, 0) ,
223 HDD2GHZCHAN(2452, 9, 0) ,
224 HDD2GHZCHAN(2457, 10, 0) ,
225 HDD2GHZCHAN(2462, 11, 0) ,
226 HDD2GHZCHAN(2467, 12, 0) ,
227 HDD2GHZCHAN(2472, 13, 0) ,
228 HDD2GHZCHAN(2484, 14, 0) ,
229};
230
Agrawal Ashish97dec502015-11-26 20:20:58 +0530231const static struct ieee80211_channel hdd_channels_5_GHZ[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700232{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700233 HDD5GHZCHAN(4920, 240, 0) ,
234 HDD5GHZCHAN(4940, 244, 0) ,
235 HDD5GHZCHAN(4960, 248, 0) ,
236 HDD5GHZCHAN(4980, 252, 0) ,
237 HDD5GHZCHAN(5040, 208, 0) ,
238 HDD5GHZCHAN(5060, 212, 0) ,
239 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 HDD5GHZCHAN(5180, 36, 0) ,
241 HDD5GHZCHAN(5200, 40, 0) ,
242 HDD5GHZCHAN(5220, 44, 0) ,
243 HDD5GHZCHAN(5240, 48, 0) ,
244 HDD5GHZCHAN(5260, 52, 0) ,
245 HDD5GHZCHAN(5280, 56, 0) ,
246 HDD5GHZCHAN(5300, 60, 0) ,
247 HDD5GHZCHAN(5320, 64, 0) ,
248 HDD5GHZCHAN(5500,100, 0) ,
249 HDD5GHZCHAN(5520,104, 0) ,
250 HDD5GHZCHAN(5540,108, 0) ,
251 HDD5GHZCHAN(5560,112, 0) ,
252 HDD5GHZCHAN(5580,116, 0) ,
253 HDD5GHZCHAN(5600,120, 0) ,
254 HDD5GHZCHAN(5620,124, 0) ,
255 HDD5GHZCHAN(5640,128, 0) ,
256 HDD5GHZCHAN(5660,132, 0) ,
257 HDD5GHZCHAN(5680,136, 0) ,
258 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800259#ifdef FEATURE_WLAN_CH144
260 HDD5GHZCHAN(5720,144, 0) ,
261#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 HDD5GHZCHAN(5745,149, 0) ,
263 HDD5GHZCHAN(5765,153, 0) ,
264 HDD5GHZCHAN(5785,157, 0) ,
265 HDD5GHZCHAN(5805,161, 0) ,
266 HDD5GHZCHAN(5825,165, 0) ,
267};
268
269static struct ieee80211_rate g_mode_rates[] =
270{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530271 HDD_G_MODE_RATETAB(10, 0x1, 0),
272 HDD_G_MODE_RATETAB(20, 0x2, 0),
273 HDD_G_MODE_RATETAB(55, 0x4, 0),
274 HDD_G_MODE_RATETAB(110, 0x8, 0),
275 HDD_G_MODE_RATETAB(60, 0x10, 0),
276 HDD_G_MODE_RATETAB(90, 0x20, 0),
277 HDD_G_MODE_RATETAB(120, 0x40, 0),
278 HDD_G_MODE_RATETAB(180, 0x80, 0),
279 HDD_G_MODE_RATETAB(240, 0x100, 0),
280 HDD_G_MODE_RATETAB(360, 0x200, 0),
281 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530283};
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285static struct ieee80211_rate a_mode_rates[] =
286{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530287 HDD_G_MODE_RATETAB(60, 0x10, 0),
288 HDD_G_MODE_RATETAB(90, 0x20, 0),
289 HDD_G_MODE_RATETAB(120, 0x40, 0),
290 HDD_G_MODE_RATETAB(180, 0x80, 0),
291 HDD_G_MODE_RATETAB(240, 0x100, 0),
292 HDD_G_MODE_RATETAB(360, 0x200, 0),
293 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 HDD_G_MODE_RATETAB(540, 0x800, 0),
295};
296
297static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
298{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530299 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
301 .band = IEEE80211_BAND_2GHZ,
302 .bitrates = g_mode_rates,
303 .n_bitrates = g_mode_rates_size,
304 .ht_cap.ht_supported = 1,
305 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
306 | IEEE80211_HT_CAP_GRN_FLD
307 | IEEE80211_HT_CAP_DSSSCCK40
308 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
309 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
310 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
311 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
312 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
313 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
314};
315
Jeff Johnson295189b2012-06-20 16:38:30 -0700316static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
317{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530318 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
320 .band = IEEE80211_BAND_5GHZ,
321 .bitrates = a_mode_rates,
322 .n_bitrates = a_mode_rates_size,
323 .ht_cap.ht_supported = 1,
324 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
325 | IEEE80211_HT_CAP_GRN_FLD
326 | IEEE80211_HT_CAP_DSSSCCK40
327 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
328 | IEEE80211_HT_CAP_SGI_40
329 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
330 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
331 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
332 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
333 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
334 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
335};
336
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530337/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 TX/RX direction for each kind of interface */
339static const struct ieee80211_txrx_stypes
340wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
341 [NL80211_IFTYPE_STATION] = {
342 .tx = 0xffff,
343 .rx = BIT(SIR_MAC_MGMT_ACTION) |
344 BIT(SIR_MAC_MGMT_PROBE_REQ),
345 },
346 [NL80211_IFTYPE_AP] = {
347 .tx = 0xffff,
348 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
350 BIT(SIR_MAC_MGMT_PROBE_REQ) |
351 BIT(SIR_MAC_MGMT_DISASSOC) |
352 BIT(SIR_MAC_MGMT_AUTH) |
353 BIT(SIR_MAC_MGMT_DEAUTH) |
354 BIT(SIR_MAC_MGMT_ACTION),
355 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700356 [NL80211_IFTYPE_ADHOC] = {
357 .tx = 0xffff,
358 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
359 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
360 BIT(SIR_MAC_MGMT_PROBE_REQ) |
361 BIT(SIR_MAC_MGMT_DISASSOC) |
362 BIT(SIR_MAC_MGMT_AUTH) |
363 BIT(SIR_MAC_MGMT_DEAUTH) |
364 BIT(SIR_MAC_MGMT_ACTION),
365 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 [NL80211_IFTYPE_P2P_CLIENT] = {
367 .tx = 0xffff,
368 .rx = BIT(SIR_MAC_MGMT_ACTION) |
369 BIT(SIR_MAC_MGMT_PROBE_REQ),
370 },
371 [NL80211_IFTYPE_P2P_GO] = {
372 /* This is also same as for SoftAP */
373 .tx = 0xffff,
374 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
375 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
376 BIT(SIR_MAC_MGMT_PROBE_REQ) |
377 BIT(SIR_MAC_MGMT_DISASSOC) |
378 BIT(SIR_MAC_MGMT_AUTH) |
379 BIT(SIR_MAC_MGMT_DEAUTH) |
380 BIT(SIR_MAC_MGMT_ACTION),
381 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700382};
383
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800384#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800385static const struct ieee80211_iface_limit
386wlan_hdd_iface_limit[] = {
387 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800388 /* max = 3 ; Our driver create two interfaces during driver init
389 * wlan0 and p2p0 interfaces. p2p0 is considered as station
390 * interface until a group is formed. In JB architecture, once the
391 * group is formed, interface type of p2p0 is changed to P2P GO or
392 * Client.
393 * When supplicant remove the group, it first issue a set interface
394 * cmd to change the mode back to Station. In JB this works fine as
395 * we advertize two station type interface during driver init.
396 * Some vendors create separate interface for P2P GO/Client,
397 * after group formation(Third one). But while group remove
398 * supplicant first tries to change the mode(3rd interface) to STATION
399 * But as we advertized only two sta type interfaces nl80211 was
400 * returning error for the third one which was leading to failure in
401 * delete interface. Ideally while removing the group, supplicant
402 * should not try to change the 3rd interface mode to Station type.
403 * Till we get a fix in wpa_supplicant, we advertize max STA
404 * interface type to 3
405 */
406 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800407 .types = BIT(NL80211_IFTYPE_STATION),
408 },
409 {
410 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700411 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800412 },
413 {
414 .max = 1,
415 .types = BIT(NL80211_IFTYPE_P2P_GO) |
416 BIT(NL80211_IFTYPE_P2P_CLIENT),
417 },
418};
419
420/* By default, only single channel concurrency is allowed */
421static struct ieee80211_iface_combination
422wlan_hdd_iface_combination = {
423 .limits = wlan_hdd_iface_limit,
424 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800425 /*
426 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
427 * and p2p0 interfaces during driver init
428 * Some vendors create separate interface for P2P operations.
429 * wlan0: STA interface
430 * p2p0: P2P Device interface, action frames goes
431 * through this interface.
432 * p2p-xx: P2P interface, After GO negotiation this interface is
433 * created for p2p operations(GO/CLIENT interface).
434 */
435 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800436 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
437 .beacon_int_infra_match = false,
438};
439#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800440
Jeff Johnson295189b2012-06-20 16:38:30 -0700441static struct cfg80211_ops wlan_hdd_cfg80211_ops;
442
443/* Data rate 100KBPS based on IE Index */
444struct index_data_rate_type
445{
446 v_U8_t beacon_rate_index;
447 v_U16_t supported_rate[4];
448};
449
450/* 11B, 11G Rate table include Basic rate and Extended rate
451 The IDX field is the rate index
452 The HI field is the rate when RSSI is strong or being ignored
453 (in this case we report actual rate)
454 The MID field is the rate when RSSI is moderate
455 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
456 The LO field is the rate when RSSI is low
457 (in this case we don't report rates, actual current rate used)
458 */
459static const struct
460{
461 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700462 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700463} supported_data_rate[] =
464{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700465/* IDX HI HM LM LO (RSSI-based index */
466 {2, { 10, 10, 10, 0}},
467 {4, { 20, 20, 10, 0}},
468 {11, { 55, 20, 10, 0}},
469 {12, { 60, 55, 20, 0}},
470 {18, { 90, 55, 20, 0}},
471 {22, {110, 55, 20, 0}},
472 {24, {120, 90, 60, 0}},
473 {36, {180, 120, 60, 0}},
474 {44, {220, 180, 60, 0}},
475 {48, {240, 180, 90, 0}},
476 {66, {330, 180, 90, 0}},
477 {72, {360, 240, 90, 0}},
478 {96, {480, 240, 120, 0}},
479 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700480};
481
482/* MCS Based rate table */
483static struct index_data_rate_type supported_mcs_rate[] =
484{
485/* MCS L20 L40 S20 S40 */
486 {0, {65, 135, 72, 150}},
487 {1, {130, 270, 144, 300}},
488 {2, {195, 405, 217, 450}},
489 {3, {260, 540, 289, 600}},
490 {4, {390, 810, 433, 900}},
491 {5, {520, 1080, 578, 1200}},
492 {6, {585, 1215, 650, 1350}},
493 {7, {650, 1350, 722, 1500}}
494};
495
Leo Chang6f8870f2013-03-26 18:11:36 -0700496#ifdef WLAN_FEATURE_11AC
497
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530498#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700499
500struct index_vht_data_rate_type
501{
502 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530503 v_U16_t supported_VHT80_rate[2];
504 v_U16_t supported_VHT40_rate[2];
505 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700506};
507
508typedef enum
509{
510 DATA_RATE_11AC_MAX_MCS_7,
511 DATA_RATE_11AC_MAX_MCS_8,
512 DATA_RATE_11AC_MAX_MCS_9,
513 DATA_RATE_11AC_MAX_MCS_NA
514} eDataRate11ACMaxMcs;
515
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530516/* SSID broadcast type */
517typedef enum eSSIDBcastType
518{
519 eBCAST_UNKNOWN = 0,
520 eBCAST_NORMAL = 1,
521 eBCAST_HIDDEN = 2,
522} tSSIDBcastType;
523
Leo Chang6f8870f2013-03-26 18:11:36 -0700524/* MCS Based VHT rate table */
525static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
526{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530527/* MCS L80 S80 L40 S40 L20 S40*/
528 {0, {293, 325}, {135, 150}, {65, 72}},
529 {1, {585, 650}, {270, 300}, {130, 144}},
530 {2, {878, 975}, {405, 450}, {195, 217}},
531 {3, {1170, 1300}, {540, 600}, {260, 289}},
532 {4, {1755, 1950}, {810, 900}, {390, 433}},
533 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
534 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
535 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
536 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
537 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700538};
539#endif /* WLAN_FEATURE_11AC */
540
c_hpothu79aab322014-07-14 21:11:01 +0530541/*array index points to MCS and array value points respective rssi*/
542static int rssiMcsTbl[][10] =
543{
544/*MCS 0 1 2 3 4 5 6 7 8 9*/
545 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
546 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
547 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
548};
549
Jeff Johnson295189b2012-06-20 16:38:30 -0700550extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530551#ifdef FEATURE_WLAN_SCAN_PNO
552static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700554
Leo Chang9056f462013-08-01 19:21:11 -0700555#ifdef WLAN_NL80211_TESTMODE
556enum wlan_hdd_tm_attr
557{
558 WLAN_HDD_TM_ATTR_INVALID = 0,
559 WLAN_HDD_TM_ATTR_CMD = 1,
560 WLAN_HDD_TM_ATTR_DATA = 2,
561 WLAN_HDD_TM_ATTR_TYPE = 3,
562 /* keep last */
563 WLAN_HDD_TM_ATTR_AFTER_LAST,
564 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
565};
566
567enum wlan_hdd_tm_cmd
568{
569 WLAN_HDD_TM_CMD_WLAN_HB = 1,
570};
571
572#define WLAN_HDD_TM_DATA_MAX_LEN 5000
573
574static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
575{
576 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
577 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
578 .len = WLAN_HDD_TM_DATA_MAX_LEN },
579};
580#endif /* WLAN_NL80211_TESTMODE */
581
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800582#ifdef FEATURE_WLAN_CH_AVOID
583/*
584 * FUNCTION: wlan_hdd_send_avoid_freq_event
585 * This is called when wlan driver needs to send vendor specific
586 * avoid frequency range event to userspace
587 */
588int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
589 tHddAvoidFreqList *pAvoidFreqList)
590{
591 struct sk_buff *vendor_event;
592
593 ENTER();
594
595 if (!pHddCtx)
596 {
597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
598 "%s: HDD context is null", __func__);
599 return -1;
600 }
601
602 if (!pAvoidFreqList)
603 {
604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
605 "%s: pAvoidFreqList is null", __func__);
606 return -1;
607 }
608
609 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530610#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
611 NULL,
612#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800613 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530614 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800615 GFP_KERNEL);
616 if (!vendor_event)
617 {
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
619 "%s: cfg80211_vendor_event_alloc failed", __func__);
620 return -1;
621 }
622
623 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
624 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
625
626 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
627
628 EXIT();
629 return 0;
630}
631#endif /* FEATURE_WLAN_CH_AVOID */
632
Srinivas Dasari030bad32015-02-18 23:23:54 +0530633/*
634 * FUNCTION: __wlan_hdd_cfg80211_nan_request
635 * This is called when wlan driver needs to send vendor specific
636 * nan request event.
637 */
638static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
639 struct wireless_dev *wdev,
640 const void *data, int data_len)
641{
642 tNanRequestReq nan_req;
643 VOS_STATUS status;
644 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530645 struct net_device *dev = wdev->netdev;
646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
647 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530648 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
649
650 if (0 == data_len)
651 {
652 hddLog(VOS_TRACE_LEVEL_ERROR,
653 FL("NAN - Invalid Request, length = 0"));
654 return ret_val;
655 }
656
657 if (NULL == data)
658 {
659 hddLog(VOS_TRACE_LEVEL_ERROR,
660 FL("NAN - Invalid Request, data is NULL"));
661 return ret_val;
662 }
663
664 status = wlan_hdd_validate_context(pHddCtx);
665 if (0 != status)
666 {
667 hddLog(VOS_TRACE_LEVEL_ERROR,
668 FL("HDD context is not valid"));
669 return -EINVAL;
670 }
671
672 hddLog(LOG1, FL("Received NAN command"));
673 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
674 (tANI_U8 *)data, data_len);
675
676 /* check the NAN Capability */
677 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("NAN is not supported by Firmware"));
681 return -EINVAL;
682 }
683
684 nan_req.request_data_len = data_len;
685 nan_req.request_data = data;
686
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530687 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530688 if (VOS_STATUS_SUCCESS == status)
689 {
690 ret_val = 0;
691 }
692 return ret_val;
693}
694
695/*
696 * FUNCTION: wlan_hdd_cfg80211_nan_request
697 * Wrapper to protect the nan vendor command from ssr
698 */
699static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
700 struct wireless_dev *wdev,
701 const void *data, int data_len)
702{
703 int ret;
704
705 vos_ssr_protect(__func__);
706 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
707 vos_ssr_unprotect(__func__);
708
709 return ret;
710}
711
712/*
713 * FUNCTION: wlan_hdd_cfg80211_nan_callback
714 * This is a callback function and it gets called
715 * when we need to report nan response event to
716 * upper layers.
717 */
718static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
719{
720 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
721 struct sk_buff *vendor_event;
722 int status;
723 tSirNanEvent *data;
724
725 ENTER();
726 if (NULL == msg)
727 {
728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
729 FL(" msg received here is null"));
730 return;
731 }
732 data = msg;
733
734 status = wlan_hdd_validate_context(pHddCtx);
735
736 if (0 != status)
737 {
738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
739 FL("HDD context is not valid"));
740 return;
741 }
742
743 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530744#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
745 NULL,
746#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530747 data->event_data_len +
748 NLMSG_HDRLEN,
749 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
750 GFP_KERNEL);
751
752 if (!vendor_event)
753 {
754 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
755 FL("cfg80211_vendor_event_alloc failed"));
756 return;
757 }
758 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
759 data->event_data_len, data->event_data))
760 {
761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
762 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
763 kfree_skb(vendor_event);
764 return;
765 }
766 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
767 EXIT();
768}
769
770/*
771 * FUNCTION: wlan_hdd_cfg80211_nan_init
772 * This function is called to register the callback to sme layer
773 */
774inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
775{
776 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
777}
778
779
Sunil Duttc69bccb2014-05-26 21:30:20 +0530780#ifdef WLAN_FEATURE_LINK_LAYER_STATS
781
782static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
783 struct sk_buff *vendor_event)
784{
785 if (nla_put_u8(vendor_event,
786 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
787 stats->rate.preamble) ||
788 nla_put_u8(vendor_event,
789 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
790 stats->rate.nss) ||
791 nla_put_u8(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
793 stats->rate.bw) ||
794 nla_put_u8(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
796 stats->rate.rateMcsIdx) ||
797 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
798 stats->rate.bitrate ) ||
799 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
800 stats->txMpdu ) ||
801 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
802 stats->rxMpdu ) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
804 stats->mpduLost ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
806 stats->retries) ||
807 nla_put_u32(vendor_event,
808 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
809 stats->retriesShort ) ||
810 nla_put_u32(vendor_event,
811 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
812 stats->retriesLong))
813 {
814 hddLog(VOS_TRACE_LEVEL_ERROR,
815 FL("QCA_WLAN_VENDOR_ATTR put fail"));
816 return FALSE;
817 }
818 return TRUE;
819}
820
821static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
822 struct sk_buff *vendor_event)
823{
824 u32 i = 0;
825 struct nlattr *rateInfo;
826 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
827 stats->type) ||
828 nla_put(vendor_event,
829 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
830 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
831 nla_put_u32(vendor_event,
832 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
833 stats->capabilities) ||
834 nla_put_u32(vendor_event,
835 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
836 stats->numRate))
837 {
838 hddLog(VOS_TRACE_LEVEL_ERROR,
839 FL("QCA_WLAN_VENDOR_ATTR put fail"));
840 goto error;
841 }
842
843 rateInfo = nla_nest_start(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530845 if(!rateInfo)
846 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530847 for (i = 0; i < stats->numRate; i++)
848 {
849 struct nlattr *rates;
850 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
851 stats->rateStats +
852 (i * sizeof(tSirWifiRateStat)));
853 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530854 if(!rates)
855 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530856
857 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
858 {
859 hddLog(VOS_TRACE_LEVEL_ERROR,
860 FL("QCA_WLAN_VENDOR_ATTR put fail"));
861 return FALSE;
862 }
863 nla_nest_end(vendor_event, rates);
864 }
865 nla_nest_end(vendor_event, rateInfo);
866
867 return TRUE;
868error:
869 return FALSE;
870}
871
872static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
873 struct sk_buff *vendor_event)
874{
875 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
876 stats->ac ) ||
877 nla_put_u32(vendor_event,
878 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
879 stats->txMpdu ) ||
880 nla_put_u32(vendor_event,
881 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
882 stats->rxMpdu ) ||
883 nla_put_u32(vendor_event,
884 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
885 stats->txMcast ) ||
886 nla_put_u32(vendor_event,
887 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
888 stats->rxMcast ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
891 stats->rxAmpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
894 stats->txAmpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
897 stats->mpduLost )||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
900 stats->retries ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
903 stats->retriesShort ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
906 stats->retriesLong ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
909 stats->contentionTimeMin ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
912 stats->contentionTimeMax ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
915 stats->contentionTimeAvg ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
918 stats->contentionNumSamples ))
919 {
920 hddLog(VOS_TRACE_LEVEL_ERROR,
921 FL("QCA_WLAN_VENDOR_ATTR put fail") );
922 return FALSE;
923 }
924 return TRUE;
925}
926
927static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
928 struct sk_buff *vendor_event)
929{
Dino Myclec8f3f332014-07-21 16:48:27 +0530930 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530931 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
932 nla_put(vendor_event,
933 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
934 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
935 nla_put_u32(vendor_event,
936 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
937 stats->state ) ||
938 nla_put_u32(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
940 stats->roaming ) ||
941 nla_put_u32(vendor_event,
942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
943 stats->capabilities ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
946 strlen(stats->ssid), stats->ssid) ||
947 nla_put(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
949 WNI_CFG_BSSID_LEN, stats->bssid) ||
950 nla_put(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
952 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
953 nla_put(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
955 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
956 )
957 {
958 hddLog(VOS_TRACE_LEVEL_ERROR,
959 FL("QCA_WLAN_VENDOR_ATTR put fail") );
960 return FALSE;
961 }
962 return TRUE;
963}
964
Dino Mycle3b9536d2014-07-09 22:05:24 +0530965static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
966 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530967 struct sk_buff *vendor_event)
968{
969 int i = 0;
970 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530971 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
972 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530973 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530974
Sunil Duttc69bccb2014-05-26 21:30:20 +0530975 if (FALSE == put_wifi_interface_info(
976 &pWifiIfaceStat->info,
977 vendor_event))
978 {
979 hddLog(VOS_TRACE_LEVEL_ERROR,
980 FL("QCA_WLAN_VENDOR_ATTR put fail") );
981 return FALSE;
982
983 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530984 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
985 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
986 if (NULL == pWifiIfaceStatTL)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
989 return FALSE;
990 }
991
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530992 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
993 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
994 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
995 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
996
997 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
998 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1000 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301001
1002 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1003 {
1004 if (VOS_STATUS_SUCCESS ==
1005 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1006 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1007 {
1008 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1009 * obtained from TL structure
1010 */
1011
1012 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1013 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301014 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1015
Srinivas Dasari98947432014-11-07 19:41:24 +05301016 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1017 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1018 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1019 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1020 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1021 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1022 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301024
Srinivas Dasari98947432014-11-07 19:41:24 +05301025 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1026 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1027 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1028 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1029 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1030 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1031 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301033
Srinivas Dasari98947432014-11-07 19:41:24 +05301034 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1036 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1037 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1038 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1039 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1040 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301042 }
1043 else
1044 {
1045 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1046 }
1047
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1049 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1051 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1053 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1054 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1056 }
1057 else
1058 {
1059 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1060 }
1061
1062
Sunil Duttc69bccb2014-05-26 21:30:20 +05301063
1064 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301065 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1066 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1067 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301068 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1069 pWifiIfaceStat->beaconRx) ||
1070 nla_put_u32(vendor_event,
1071 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1072 pWifiIfaceStat->mgmtRx) ||
1073 nla_put_u32(vendor_event,
1074 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1075 pWifiIfaceStat->mgmtActionRx) ||
1076 nla_put_u32(vendor_event,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1078 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301079 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1081 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301082 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1084 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301085 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1087 pWifiIfaceStat->rssiAck))
1088 {
1089 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301090 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1091 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 return FALSE;
1093 }
1094
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301095#ifdef FEATURE_EXT_LL_STAT
1096 /*
1097 * Ensure when EXT_LL_STAT is supported by both host and fwr,
1098 * then host should send Leaky AP stats to upper layer,
1099 * otherwise no need to send these stats.
1100 */
1101 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
1102 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
1103 )
1104 {
1105 hddLog(VOS_TRACE_LEVEL_INFO,
1106 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
1107 pWifiIfaceStat->leakyApStat.is_leaky_ap,
1108 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
1109 pWifiIfaceStat->leakyApStat.rx_leak_window,
1110 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
1111 if (nla_put_u32(vendor_event,
1112 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
1113 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
1114 nla_put_u32(vendor_event,
1115 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
1116 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
1117 nla_put_u32(vendor_event,
1118 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
1119 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
1120 nla_put_u64(vendor_event,
1121 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
1122 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
1123 {
1124 hddLog(VOS_TRACE_LEVEL_ERROR,
1125 FL("EXT_LL_STAT put fail"));
1126 vos_mem_free(pWifiIfaceStatTL);
1127 return FALSE;
1128 }
1129 }
1130#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301131 wmmInfo = nla_nest_start(vendor_event,
1132 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301133 if(!wmmInfo)
1134 {
1135 vos_mem_free(pWifiIfaceStatTL);
1136 return FALSE;
1137 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301138 for (i = 0; i < WIFI_AC_MAX; i++)
1139 {
1140 struct nlattr *wmmStats;
1141 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301142 if(!wmmStats)
1143 {
1144 vos_mem_free(pWifiIfaceStatTL);
1145 return FALSE;
1146 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301147 if (FALSE == put_wifi_wmm_ac_stat(
1148 &pWifiIfaceStat->AccessclassStats[i],
1149 vendor_event))
1150 {
1151 hddLog(VOS_TRACE_LEVEL_ERROR,
1152 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301153 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301154 return FALSE;
1155 }
1156
1157 nla_nest_end(vendor_event, wmmStats);
1158 }
1159 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301160 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301161 return TRUE;
1162}
1163
1164static tSirWifiInterfaceMode
1165 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1166{
1167 switch (deviceMode)
1168 {
1169 case WLAN_HDD_INFRA_STATION:
1170 return WIFI_INTERFACE_STA;
1171 case WLAN_HDD_SOFTAP:
1172 return WIFI_INTERFACE_SOFTAP;
1173 case WLAN_HDD_P2P_CLIENT:
1174 return WIFI_INTERFACE_P2P_CLIENT;
1175 case WLAN_HDD_P2P_GO:
1176 return WIFI_INTERFACE_P2P_GO;
1177 case WLAN_HDD_IBSS:
1178 return WIFI_INTERFACE_IBSS;
1179 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301180 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301181 }
1182}
1183
1184static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1185 tpSirWifiInterfaceInfo pInfo)
1186{
1187 v_U8_t *staMac = NULL;
1188 hdd_station_ctx_t *pHddStaCtx;
1189 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1190 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1191
1192 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1193
1194 vos_mem_copy(pInfo->macAddr,
1195 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1196
1197 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1198 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1199 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1200 {
1201 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1202 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1203 {
1204 pInfo->state = WIFI_DISCONNECTED;
1205 }
1206 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1207 {
1208 hddLog(VOS_TRACE_LEVEL_ERROR,
1209 "%s: Session ID %d, Connection is in progress", __func__,
1210 pAdapter->sessionId);
1211 pInfo->state = WIFI_ASSOCIATING;
1212 }
1213 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1214 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1215 {
1216 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1217 hddLog(VOS_TRACE_LEVEL_ERROR,
1218 "%s: client " MAC_ADDRESS_STR
1219 " is in the middle of WPS/EAPOL exchange.", __func__,
1220 MAC_ADDR_ARRAY(staMac));
1221 pInfo->state = WIFI_AUTHENTICATING;
1222 }
1223 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1224 {
1225 pInfo->state = WIFI_ASSOCIATED;
1226 vos_mem_copy(pInfo->bssid,
1227 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1228 vos_mem_copy(pInfo->ssid,
1229 pHddStaCtx->conn_info.SSID.SSID.ssId,
1230 pHddStaCtx->conn_info.SSID.SSID.length);
1231 //NULL Terminate the string.
1232 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1233 }
1234 }
1235 vos_mem_copy(pInfo->countryStr,
1236 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1237
1238 vos_mem_copy(pInfo->apCountryStr,
1239 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1240
1241 return TRUE;
1242}
1243
1244/*
1245 * hdd_link_layer_process_peer_stats () - This function is called after
1246 * receiving Link Layer Peer statistics from FW.This function converts
1247 * the firmware data to the NL data and sends the same to the kernel/upper
1248 * layers.
1249 */
1250static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1251 v_VOID_t *pData)
1252{
1253 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301254 tpSirWifiPeerStat pWifiPeerStat;
1255 tpSirWifiPeerInfo pWifiPeerInfo;
1256 struct nlattr *peerInfo;
1257 struct sk_buff *vendor_event;
1258 int status, i;
1259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301260 ENTER();
1261
Sunil Duttc69bccb2014-05-26 21:30:20 +05301262 status = wlan_hdd_validate_context(pHddCtx);
1263 if (0 != status)
1264 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301265 return;
1266 }
1267
1268 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1269
1270 hddLog(VOS_TRACE_LEVEL_INFO,
1271 "LL_STATS_PEER_ALL : numPeers %u",
1272 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301273 /*
1274 * Allocate a size of 4096 for the peer stats comprising
1275 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1276 * sizeof (tSirWifiRateStat).Each field is put with an
1277 * NL attribute.The size of 4096 is considered assuming
1278 * that number of rates shall not exceed beyond 50 with
1279 * the sizeof (tSirWifiRateStat) being 32.
1280 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301281 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1282 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301283 if (!vendor_event)
1284 {
1285 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301286 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301287 __func__);
1288 return;
1289 }
1290 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301291 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1292 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1293 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301294 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1295 pWifiPeerStat->numPeers))
1296 {
1297 hddLog(VOS_TRACE_LEVEL_ERROR,
1298 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1299 kfree_skb(vendor_event);
1300 return;
1301 }
1302
1303 peerInfo = nla_nest_start(vendor_event,
1304 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301305 if(!peerInfo)
1306 {
1307 hddLog(VOS_TRACE_LEVEL_ERROR,
1308 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1309 __func__);
1310 kfree_skb(vendor_event);
1311 return;
1312 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301313
1314 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1315 pWifiPeerStat->peerInfo);
1316
1317 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1318 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301319 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301320 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301321
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301322 if(!peers)
1323 {
1324 hddLog(VOS_TRACE_LEVEL_ERROR,
1325 "%s: peer stats put fail",
1326 __func__);
1327 kfree_skb(vendor_event);
1328 return;
1329 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301330 if (FALSE == put_wifi_peer_info(
1331 pWifiPeerInfo, vendor_event))
1332 {
1333 hddLog(VOS_TRACE_LEVEL_ERROR,
1334 "%s: put_wifi_peer_info put fail", __func__);
1335 kfree_skb(vendor_event);
1336 return;
1337 }
1338
1339 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1340 pWifiPeerStat->peerInfo +
1341 (i * sizeof(tSirWifiPeerInfo)) +
1342 (numRate * sizeof (tSirWifiRateStat)));
1343 nla_nest_end(vendor_event, peers);
1344 }
1345 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301346 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301347 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301348}
1349
1350/*
1351 * hdd_link_layer_process_iface_stats () - This function is called after
1352 * receiving Link Layer Interface statistics from FW.This function converts
1353 * the firmware data to the NL data and sends the same to the kernel/upper
1354 * layers.
1355 */
1356static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1357 v_VOID_t *pData)
1358{
1359 tpSirWifiIfaceStat pWifiIfaceStat;
1360 struct sk_buff *vendor_event;
1361 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1362 int status;
1363
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301364 ENTER();
1365
Sunil Duttc69bccb2014-05-26 21:30:20 +05301366 status = wlan_hdd_validate_context(pHddCtx);
1367 if (0 != status)
1368 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301369 return;
1370 }
1371 /*
1372 * Allocate a size of 4096 for the interface stats comprising
1373 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1374 * assuming that all these fit with in the limit.Please take
1375 * a call on the limit based on the data requirements on
1376 * interface statistics.
1377 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301378 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1379 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301380 if (!vendor_event)
1381 {
1382 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301383 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301384 return;
1385 }
1386
1387 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1388
Dino Mycle3b9536d2014-07-09 22:05:24 +05301389
1390 if (FALSE == hdd_get_interface_info( pAdapter,
1391 &pWifiIfaceStat->info))
1392 {
1393 hddLog(VOS_TRACE_LEVEL_ERROR,
1394 FL("hdd_get_interface_info get fail") );
1395 kfree_skb(vendor_event);
1396 return;
1397 }
1398
1399 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1400 vendor_event))
1401 {
1402 hddLog(VOS_TRACE_LEVEL_ERROR,
1403 FL("put_wifi_iface_stats fail") );
1404 kfree_skb(vendor_event);
1405 return;
1406 }
1407
Sunil Duttc69bccb2014-05-26 21:30:20 +05301408 hddLog(VOS_TRACE_LEVEL_INFO,
1409 "WMI_LINK_STATS_IFACE Data");
1410
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301411 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301412
1413 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301414}
1415
1416/*
1417 * hdd_link_layer_process_radio_stats () - This function is called after
1418 * receiving Link Layer Radio statistics from FW.This function converts
1419 * the firmware data to the NL data and sends the same to the kernel/upper
1420 * layers.
1421 */
1422static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1423 v_VOID_t *pData)
1424{
1425 int status, i;
1426 tpSirWifiRadioStat pWifiRadioStat;
1427 tpSirWifiChannelStats pWifiChannelStats;
1428 struct sk_buff *vendor_event;
1429 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1430 struct nlattr *chList;
1431
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301432 ENTER();
1433
Sunil Duttc69bccb2014-05-26 21:30:20 +05301434 status = wlan_hdd_validate_context(pHddCtx);
1435 if (0 != status)
1436 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301437 return;
1438 }
1439 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1440
1441 hddLog(VOS_TRACE_LEVEL_INFO,
1442 "LL_STATS_RADIO"
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301443 " number of radios = %u"
Sunil Duttc69bccb2014-05-26 21:30:20 +05301444 " radio is %d onTime is %u "
1445 " txTime is %u rxTime is %u "
1446 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301447 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301448 " onTimePnoScan is %u onTimeHs20 is %u "
1449 " numChannels is %u",
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301450 NUM_RADIOS,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301451 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1452 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1453 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301454 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301455 pWifiRadioStat->onTimeRoamScan,
1456 pWifiRadioStat->onTimePnoScan,
1457 pWifiRadioStat->onTimeHs20,
1458 pWifiRadioStat->numChannels);
1459 /*
1460 * Allocate a size of 4096 for the Radio stats comprising
1461 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1462 * (tSirWifiChannelStats).Each channel data is put with an
1463 * NL attribute.The size of 4096 is considered assuming that
1464 * number of channels shall not exceed beyond 60 with the
1465 * sizeof (tSirWifiChannelStats) being 24 bytes.
1466 */
1467
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301468 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1469 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301470 if (!vendor_event)
1471 {
1472 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301473 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301474 return;
1475 }
1476
1477 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301478 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1479 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1480 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301481 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1482 pWifiRadioStat->radio) ||
1483 nla_put_u32(vendor_event,
Ravi Kumar Bokka93065922016-10-27 13:52:34 +05301484 QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS,
1485 NUM_RADIOS) ||
1486 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301487 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1488 pWifiRadioStat->onTime) ||
1489 nla_put_u32(vendor_event,
1490 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1491 pWifiRadioStat->txTime) ||
1492 nla_put_u32(vendor_event,
1493 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1494 pWifiRadioStat->rxTime) ||
1495 nla_put_u32(vendor_event,
1496 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1497 pWifiRadioStat->onTimeScan) ||
1498 nla_put_u32(vendor_event,
1499 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1500 pWifiRadioStat->onTimeNbd) ||
1501 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301502 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1503 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301504 nla_put_u32(vendor_event,
1505 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1506 pWifiRadioStat->onTimeRoamScan) ||
1507 nla_put_u32(vendor_event,
1508 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1509 pWifiRadioStat->onTimePnoScan) ||
1510 nla_put_u32(vendor_event,
1511 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1512 pWifiRadioStat->onTimeHs20) ||
1513 nla_put_u32(vendor_event,
1514 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1515 pWifiRadioStat->numChannels))
1516 {
1517 hddLog(VOS_TRACE_LEVEL_ERROR,
1518 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1519 kfree_skb(vendor_event);
1520 return ;
1521 }
1522
1523 chList = nla_nest_start(vendor_event,
1524 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301525 if(!chList)
1526 {
1527 hddLog(VOS_TRACE_LEVEL_ERROR,
1528 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1529 __func__);
1530 kfree_skb(vendor_event);
1531 return;
1532 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301533 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1534 {
1535 struct nlattr *chInfo;
1536
1537 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1538 pWifiRadioStat->channels +
1539 (i * sizeof(tSirWifiChannelStats)));
1540
Sunil Duttc69bccb2014-05-26 21:30:20 +05301541 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301542 if(!chInfo)
1543 {
1544 hddLog(VOS_TRACE_LEVEL_ERROR,
1545 "%s: failed to put chInfo",
1546 __func__);
1547 kfree_skb(vendor_event);
1548 return;
1549 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301550
1551 if (nla_put_u32(vendor_event,
1552 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1553 pWifiChannelStats->channel.width) ||
1554 nla_put_u32(vendor_event,
1555 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1556 pWifiChannelStats->channel.centerFreq) ||
1557 nla_put_u32(vendor_event,
1558 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1559 pWifiChannelStats->channel.centerFreq0) ||
1560 nla_put_u32(vendor_event,
1561 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1562 pWifiChannelStats->channel.centerFreq1) ||
1563 nla_put_u32(vendor_event,
1564 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1565 pWifiChannelStats->onTime) ||
1566 nla_put_u32(vendor_event,
1567 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1568 pWifiChannelStats->ccaBusyTime))
1569 {
1570 hddLog(VOS_TRACE_LEVEL_ERROR,
1571 FL("cfg80211_vendor_event_alloc failed") );
1572 kfree_skb(vendor_event);
1573 return ;
1574 }
1575 nla_nest_end(vendor_event, chInfo);
1576 }
1577 nla_nest_end(vendor_event, chList);
1578
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301579 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301580
1581 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301582 return;
1583}
1584
1585/*
1586 * hdd_link_layer_stats_ind_callback () - This function is called after
1587 * receiving Link Layer indications from FW.This callback converts the firmware
1588 * data to the NL data and send the same to the kernel/upper layers.
1589 */
1590static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1591 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301592 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301593{
Dino Mycled3d50022014-07-07 12:58:25 +05301594 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1595 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301596 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301597 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301598 int status;
1599
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301600 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301601
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301602 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301603 if (0 != status)
1604 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301605 return;
1606 }
1607
Dino Mycled3d50022014-07-07 12:58:25 +05301608 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1609 if (NULL == pAdapter)
1610 {
1611 hddLog(VOS_TRACE_LEVEL_ERROR,
1612 FL(" MAC address %pM does not exist with host"),
1613 macAddr);
1614 return;
1615 }
1616
Sunil Duttc69bccb2014-05-26 21:30:20 +05301617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301618 "%s: Interface: %s LLStats indType: %d", __func__,
1619 pAdapter->dev->name, indType);
1620
Sunil Duttc69bccb2014-05-26 21:30:20 +05301621 switch (indType)
1622 {
1623 case SIR_HAL_LL_STATS_RESULTS_RSP:
1624 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301625 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301626 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
1627 "respId = %u, moreResultToFollow = %u",
1628 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
1629 macAddr, linkLayerStatsResults->respId,
1630 linkLayerStatsResults->moreResultToFollow);
1631
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301632 spin_lock(&hdd_context_lock);
1633 context = &pHddCtx->ll_stats_context;
1634 /* validate response received from target */
1635 if ((context->request_id != linkLayerStatsResults->respId) ||
1636 !(context->request_bitmap & linkLayerStatsResults->paramId))
1637 {
1638 spin_unlock(&hdd_context_lock);
1639 hddLog(LOGE,
1640 FL("Error : Request id %d response id %d request bitmap 0x%x"
1641 "response bitmap 0x%x"),
1642 context->request_id, linkLayerStatsResults->respId,
1643 context->request_bitmap, linkLayerStatsResults->paramId);
1644 return;
1645 }
1646 spin_unlock(&hdd_context_lock);
1647
Sunil Duttc69bccb2014-05-26 21:30:20 +05301648 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1649 {
1650 hdd_link_layer_process_radio_stats(pAdapter,
1651 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301652 spin_lock(&hdd_context_lock);
1653 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1654 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301655 }
1656 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1657 {
1658 hdd_link_layer_process_iface_stats(pAdapter,
1659 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301660 spin_lock(&hdd_context_lock);
1661 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1662 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301663 }
1664 else if ( linkLayerStatsResults->paramId &
1665 WMI_LINK_STATS_ALL_PEER )
1666 {
1667 hdd_link_layer_process_peer_stats(pAdapter,
1668 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301669 spin_lock(&hdd_context_lock);
1670 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1671 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301672 } /* WMI_LINK_STATS_ALL_PEER */
1673 else
1674 {
1675 hddLog(VOS_TRACE_LEVEL_ERROR,
1676 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1677 }
1678
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301679 spin_lock(&hdd_context_lock);
1680 /* complete response event if all requests are completed */
1681 if (0 == context->request_bitmap)
1682 complete(&context->response_event);
1683 spin_unlock(&hdd_context_lock);
1684
Sunil Duttc69bccb2014-05-26 21:30:20 +05301685 break;
1686 }
1687 default:
1688 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1689 break;
1690 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301691
1692 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301693 return;
1694}
1695
1696const struct
1697nla_policy
1698qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1699{
1700 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1701 { .type = NLA_U32 },
1702 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1703 { .type = NLA_U32 },
1704};
1705
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301706static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1707 struct wireless_dev *wdev,
1708 const void *data,
1709 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301710{
1711 int status;
1712 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301713 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301714 struct net_device *dev = wdev->netdev;
1715 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1716 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1717
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301718 ENTER();
1719
Sunil Duttc69bccb2014-05-26 21:30:20 +05301720 status = wlan_hdd_validate_context(pHddCtx);
1721 if (0 != status)
1722 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301723 return -EINVAL;
1724 }
1725
1726 if (NULL == pAdapter)
1727 {
1728 hddLog(VOS_TRACE_LEVEL_ERROR,
1729 FL("HDD adapter is Null"));
1730 return -ENODEV;
1731 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301732 /* check the LLStats Capability */
1733 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1734 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1735 {
Anurag Chouhan65ea6dc2016-10-25 19:59:14 +05301736 hddLog(VOS_TRACE_LEVEL_WARN,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301737 FL("Link Layer Statistics not supported by Firmware"));
1738 return -EINVAL;
1739 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301740
1741 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1742 (struct nlattr *)data,
1743 data_len, qca_wlan_vendor_ll_set_policy))
1744 {
1745 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1746 return -EINVAL;
1747 }
1748 if (!tb_vendor
1749 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1752 return -EINVAL;
1753 }
1754 if (!tb_vendor[
1755 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1756 {
1757 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1758 return -EINVAL;
1759 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301760 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301761 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301762
Dino Mycledf0a5d92014-07-04 09:41:55 +05301763 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301764 nla_get_u32(
1765 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1766
Dino Mycledf0a5d92014-07-04 09:41:55 +05301767 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301768 nla_get_u32(
1769 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1770
Dino Mycled3d50022014-07-07 12:58:25 +05301771 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1772 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773
1774
1775 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301776 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
1777 "Statistics Gathering = %d ",
1778 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
1779 linkLayerStatsSetReq.mpduSizeThreshold,
1780 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301781
1782 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1783 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301784 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301785 {
1786 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1787 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301788 return -EINVAL;
1789
1790 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301791
Sunil Duttc69bccb2014-05-26 21:30:20 +05301792 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301793 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301794 {
1795 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1796 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301797 return -EINVAL;
1798 }
1799
1800 pAdapter->isLinkLayerStatsSet = 1;
1801
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301802 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301803 return 0;
1804}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301805static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1806 struct wireless_dev *wdev,
1807 const void *data,
1808 int data_len)
1809{
1810 int ret = 0;
1811
1812 vos_ssr_protect(__func__);
1813 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1814 vos_ssr_unprotect(__func__);
1815
1816 return ret;
1817}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301818
1819const struct
1820nla_policy
1821qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1822{
1823 /* Unsigned 32bit value provided by the caller issuing the GET stats
1824 * command. When reporting
1825 * the stats results, the driver uses the same value to indicate
1826 * which GET request the results
1827 * correspond to.
1828 */
1829 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1830
1831 /* Unsigned 32bit value . bit mask to identify what statistics are
1832 requested for retrieval */
1833 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1834};
1835
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301836static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1837 struct wireless_dev *wdev,
1838 const void *data,
1839 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301840{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301841 unsigned long rc;
1842 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1844 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301845 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301846 struct net_device *dev = wdev->netdev;
1847 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05301848 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301849 int status;
1850
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301851 ENTER();
1852
Sunil Duttc69bccb2014-05-26 21:30:20 +05301853 status = wlan_hdd_validate_context(pHddCtx);
1854 if (0 != status)
1855 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301856 return -EINVAL ;
1857 }
1858
1859 if (NULL == pAdapter)
1860 {
1861 hddLog(VOS_TRACE_LEVEL_FATAL,
1862 "%s: HDD adapter is Null", __func__);
1863 return -ENODEV;
1864 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05301865
1866 if (pHddStaCtx == NULL)
1867 {
1868 hddLog(VOS_TRACE_LEVEL_FATAL,
1869 "%s: HddStaCtx is Null", __func__);
1870 return -ENODEV;
1871 }
1872
Dino Mycledf0a5d92014-07-04 09:41:55 +05301873 /* check the LLStats Capability */
1874 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1875 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1876 {
1877 hddLog(VOS_TRACE_LEVEL_ERROR,
1878 FL("Link Layer Statistics not supported by Firmware"));
1879 return -EINVAL;
1880 }
1881
Sunil Duttc69bccb2014-05-26 21:30:20 +05301882
1883 if (!pAdapter->isLinkLayerStatsSet)
1884 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05301885 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301886 "%s: isLinkLayerStatsSet : %d",
1887 __func__, pAdapter->isLinkLayerStatsSet);
1888 return -EINVAL;
1889 }
1890
Mukul Sharma10313ba2015-07-29 19:14:39 +05301891 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1892 {
1893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1894 "%s: Roaming in progress, so unable to proceed this request", __func__);
1895 return -EBUSY;
1896 }
1897
Sunil Duttc69bccb2014-05-26 21:30:20 +05301898 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1899 (struct nlattr *)data,
1900 data_len, qca_wlan_vendor_ll_get_policy))
1901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1903 return -EINVAL;
1904 }
1905
1906 if (!tb_vendor
1907 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1908 {
1909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1910 return -EINVAL;
1911 }
1912
1913 if (!tb_vendor
1914 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1915 {
1916 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1917 return -EINVAL;
1918 }
1919
Sunil Duttc69bccb2014-05-26 21:30:20 +05301920
Dino Mycledf0a5d92014-07-04 09:41:55 +05301921 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301922 nla_get_u32( tb_vendor[
1923 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301924 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 nla_get_u32( tb_vendor[
1926 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1927
Dino Mycled3d50022014-07-07 12:58:25 +05301928 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1929 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301930
1931 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301932 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
1933 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301936 spin_lock(&hdd_context_lock);
1937 context = &pHddCtx->ll_stats_context;
1938 context->request_id = linkLayerStatsGetReq.reqId;
1939 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
1940 INIT_COMPLETION(context->response_event);
1941 spin_unlock(&hdd_context_lock);
1942
Sunil Duttc69bccb2014-05-26 21:30:20 +05301943 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301944 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301945 {
1946 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1947 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 return -EINVAL;
1949 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301950
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301951 rc = wait_for_completion_timeout(&context->response_event,
1952 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
1953 if (!rc)
1954 {
1955 hddLog(LOGE,
1956 FL("Target response timed out request id %d request bitmap 0x%x"),
1957 context->request_id, context->request_bitmap);
1958 return -ETIMEDOUT;
1959 }
1960
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301961 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301962 return 0;
1963}
1964
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301965static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1966 struct wireless_dev *wdev,
1967 const void *data,
1968 int data_len)
1969{
1970 int ret = 0;
1971
1972 vos_ssr_protect(__func__);
1973 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
1974 vos_ssr_unprotect(__func__);
1975
1976 return ret;
1977}
1978
Sunil Duttc69bccb2014-05-26 21:30:20 +05301979const struct
1980nla_policy
1981qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1982{
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1984 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1985 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1986 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1987};
1988
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301989static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1990 struct wireless_dev *wdev,
1991 const void *data,
1992 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301993{
1994 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1995 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301996 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 struct net_device *dev = wdev->netdev;
1998 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1999 u32 statsClearReqMask;
2000 u8 stopReq;
2001 int status;
2002
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302003 ENTER();
2004
Sunil Duttc69bccb2014-05-26 21:30:20 +05302005 status = wlan_hdd_validate_context(pHddCtx);
2006 if (0 != status)
2007 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302008 return -EINVAL;
2009 }
2010
2011 if (NULL == pAdapter)
2012 {
2013 hddLog(VOS_TRACE_LEVEL_FATAL,
2014 "%s: HDD adapter is Null", __func__);
2015 return -ENODEV;
2016 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302017 /* check the LLStats Capability */
2018 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2019 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2020 {
2021 hddLog(VOS_TRACE_LEVEL_ERROR,
2022 FL("Enable LLStats Capability"));
2023 return -EINVAL;
2024 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302025
2026 if (!pAdapter->isLinkLayerStatsSet)
2027 {
2028 hddLog(VOS_TRACE_LEVEL_FATAL,
2029 "%s: isLinkLayerStatsSet : %d",
2030 __func__, pAdapter->isLinkLayerStatsSet);
2031 return -EINVAL;
2032 }
2033
2034 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2035 (struct nlattr *)data,
2036 data_len, qca_wlan_vendor_ll_clr_policy))
2037 {
2038 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2039 return -EINVAL;
2040 }
2041
2042 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2043
2044 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2045 {
2046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2047 return -EINVAL;
2048
2049 }
2050
Sunil Duttc69bccb2014-05-26 21:30:20 +05302051
Dino Mycledf0a5d92014-07-04 09:41:55 +05302052 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302053 nla_get_u32(
2054 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2055
Dino Mycledf0a5d92014-07-04 09:41:55 +05302056 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302057 nla_get_u8(
2058 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2059
2060 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302061 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302062
Dino Mycled3d50022014-07-07 12:58:25 +05302063 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2064 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302065
2066 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302067 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
2068 "statsClearReqMask = 0x%X, stopReq = %d",
2069 linkLayerStatsClearReq.reqId,
2070 linkLayerStatsClearReq.macAddr,
2071 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302072 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302073
2074 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 {
2077 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302078 hdd_station_ctx_t *pHddStaCtx;
2079
2080 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2081 if (VOS_STATUS_SUCCESS !=
2082 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2083 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2084 {
2085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2086 "WLANTL_ClearInterfaceStats Failed", __func__);
2087 return -EINVAL;
2088 }
2089 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2090 (statsClearReqMask & WIFI_STATS_IFACE)) {
2091 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2092 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2093 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2094 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2095 }
2096
Sunil Duttc69bccb2014-05-26 21:30:20 +05302097 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2098 2 * sizeof(u32) +
2099 NLMSG_HDRLEN);
2100
2101 if (temp_skbuff != NULL)
2102 {
2103
2104 if (nla_put_u32(temp_skbuff,
2105 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2106 statsClearReqMask) ||
2107 nla_put_u32(temp_skbuff,
2108 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2109 stopReq))
2110 {
2111 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2112 kfree_skb(temp_skbuff);
2113 return -EINVAL;
2114 }
2115 /* If the ask is to stop the stats collection as part of clear
2116 * (stopReq = 1) , ensure that no further requests of get
2117 * go to the firmware by having isLinkLayerStatsSet set to 0.
2118 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302119 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302120 * case the firmware is just asked to clear the statistics.
2121 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302122 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302123 pAdapter->isLinkLayerStatsSet = 0;
2124 return cfg80211_vendor_cmd_reply(temp_skbuff);
2125 }
2126 return -ENOMEM;
2127 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302128
2129 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302130 return -EINVAL;
2131}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302132static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2133 struct wireless_dev *wdev,
2134 const void *data,
2135 int data_len)
2136{
2137 int ret = 0;
2138
2139 vos_ssr_protect(__func__);
2140 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2141 vos_ssr_unprotect(__func__);
2142
2143 return ret;
2144
2145
2146}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302147#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2148
Dino Mycle6fb96c12014-06-10 11:52:40 +05302149#ifdef WLAN_FEATURE_EXTSCAN
2150static const struct nla_policy
2151wlan_hdd_extscan_config_policy
2152 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2153{
2154 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2155 { .type = NLA_U32 },
2156 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2157 { .type = NLA_U32 },
2158 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2159 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2160 { .type = NLA_U32 },
2161 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2162 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2163
2164 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2165 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2166 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2167 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2168 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302169 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2170 { .type = NLA_U32 },
2171 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2172 { .type = NLA_U32 },
2173 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2174 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302175 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2176 { .type = NLA_U32 },
2177 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2178 { .type = NLA_U32 },
2179 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2180 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302181 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2182 { .type = NLA_U8 },
2183 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302184 { .type = NLA_U8 },
2185 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2186 { .type = NLA_U8 },
2187 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2188 { .type = NLA_U8 },
2189
2190 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2191 { .type = NLA_U32 },
2192 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2193 { .type = NLA_UNSPEC },
2194 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2195 { .type = NLA_S32 },
2196 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2197 { .type = NLA_S32 },
2198 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2199 { .type = NLA_U32 },
2200 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2201 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302202 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2203 { .type = NLA_U32 },
2204 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2205 { .type = NLA_BINARY,
2206 .len = IEEE80211_MAX_SSID_LEN + 1 },
2207 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302208 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302209 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2210 { .type = NLA_U32 },
2211 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2212 { .type = NLA_U8 },
2213 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2214 { .type = NLA_S32 },
2215 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2216 { .type = NLA_S32 },
2217 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2218 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302219};
2220
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302221/**
2222 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2223 * @ctx: hdd global context
2224 * @data: capabilities data
2225 *
2226 * Return: none
2227 */
2228static void
2229wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302230{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302231 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302232 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302233 tSirEXTScanCapabilitiesEvent *data =
2234 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302235
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302236 ENTER();
2237
2238 if (wlan_hdd_validate_context(pHddCtx))
2239 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302240 return;
2241 }
2242
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302243 if (!pMsg)
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2246 return;
2247 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302248
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302249 vos_spin_lock_acquire(&hdd_context_lock);
2250
2251 context = &pHddCtx->ext_scan_context;
2252 /* validate response received from target*/
2253 if (context->request_id != data->requestId)
2254 {
2255 vos_spin_lock_release(&hdd_context_lock);
2256 hddLog(LOGE,
2257 FL("Target response id did not match: request_id %d resposne_id %d"),
2258 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302259 return;
2260 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302261 else
2262 {
2263 context->capability_response = *data;
2264 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302265 }
2266
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302267 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302268
Dino Mycle6fb96c12014-06-10 11:52:40 +05302269 return;
2270}
2271
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302272/*
2273 * define short names for the global vendor params
2274 * used by wlan_hdd_send_ext_scan_capability()
2275 */
2276#define PARAM_REQUEST_ID \
2277 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2278#define PARAM_STATUS \
2279 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2280#define MAX_SCAN_CACHE_SIZE \
2281 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2282#define MAX_SCAN_BUCKETS \
2283 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2284#define MAX_AP_CACHE_PER_SCAN \
2285 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2286#define MAX_RSSI_SAMPLE_SIZE \
2287 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2288#define MAX_SCAN_RPT_THRHOLD \
2289 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2290#define MAX_HOTLIST_BSSIDS \
2291 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2292#define MAX_BSSID_HISTORY_ENTRIES \
2293 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2294#define MAX_HOTLIST_SSIDS \
2295 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302296#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2297 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302298
2299static int wlan_hdd_send_ext_scan_capability(void *ctx)
2300{
2301 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2302 struct sk_buff *skb = NULL;
2303 int ret;
2304 tSirEXTScanCapabilitiesEvent *data;
2305 tANI_U32 nl_buf_len;
2306
2307 ret = wlan_hdd_validate_context(pHddCtx);
2308 if (0 != ret)
2309 {
2310 return ret;
2311 }
2312
2313 data = &(pHddCtx->ext_scan_context.capability_response);
2314
2315 nl_buf_len = NLMSG_HDRLEN;
2316 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2317 (sizeof(data->status) + NLA_HDRLEN) +
2318 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2319 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2320 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2321 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2322 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2323 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2324 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2325 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2326
2327 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2328
2329 if (!skb)
2330 {
2331 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2332 return -ENOMEM;
2333 }
2334
2335 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2336 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2337 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2338 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2339 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2340 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2341 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2342 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2343
2344 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2345 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2346 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2347 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2348 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2349 data->maxApPerScan) ||
2350 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2351 data->maxRssiSampleSize) ||
2352 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2353 data->maxScanReportingThreshold) ||
2354 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2355 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2356 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302357 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2358 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302359 {
2360 hddLog(LOGE, FL("nla put fail"));
2361 goto nla_put_failure;
2362 }
2363
2364 cfg80211_vendor_cmd_reply(skb);
2365 return 0;
2366
2367nla_put_failure:
2368 kfree_skb(skb);
2369 return -EINVAL;;
2370}
2371
2372/*
2373 * done with short names for the global vendor params
2374 * used by wlan_hdd_send_ext_scan_capability()
2375 */
2376#undef PARAM_REQUEST_ID
2377#undef PARAM_STATUS
2378#undef MAX_SCAN_CACHE_SIZE
2379#undef MAX_SCAN_BUCKETS
2380#undef MAX_AP_CACHE_PER_SCAN
2381#undef MAX_RSSI_SAMPLE_SIZE
2382#undef MAX_SCAN_RPT_THRHOLD
2383#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302384#undef MAX_BSSID_HISTORY_ENTRIES
2385#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302386
2387static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2388{
2389 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2390 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302391 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302392 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302393
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302394 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302395
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302396 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302397 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302398
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302399 if (!pMsg)
2400 {
2401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302402 return;
2403 }
2404
Dino Mycle6fb96c12014-06-10 11:52:40 +05302405 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2406 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2407
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302408 context = &pHddCtx->ext_scan_context;
2409 spin_lock(&hdd_context_lock);
2410 if (context->request_id == pData->requestId) {
2411 context->response_status = pData->status ? -EINVAL : 0;
2412 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302413 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302414 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302415
2416 /*
2417 * Store the Request ID for comparing with the requestID obtained
2418 * in other requests.HDD shall return a failure is the extscan_stop
2419 * request is issued with a different requestId as that of the
2420 * extscan_start request. Also, This requestId shall be used while
2421 * indicating the full scan results to the upper layers.
2422 * The requestId is stored with the assumption that the firmware
2423 * shall return the ext scan start request's requestId in ext scan
2424 * start response.
2425 */
2426 if (pData->status == 0)
2427 pMac->sme.extScanStartReqId = pData->requestId;
2428
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302429 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302430 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302431}
2432
2433
2434static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2435{
2436 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2437 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302438 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302439
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302440 ENTER();
2441
2442 if (wlan_hdd_validate_context(pHddCtx)){
2443 return;
2444 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302445
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302446 if (!pMsg)
2447 {
2448 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302449 return;
2450 }
2451
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302452 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2453 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302454
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302455 context = &pHddCtx->ext_scan_context;
2456 spin_lock(&hdd_context_lock);
2457 if (context->request_id == pData->requestId) {
2458 context->response_status = pData->status ? -EINVAL : 0;
2459 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302460 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302461 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302462
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302463 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302464 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302465}
2466
Dino Mycle6fb96c12014-06-10 11:52:40 +05302467static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2468 void *pMsg)
2469{
2470 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302471 tpSirEXTScanSetBssidHotListRspParams pData =
2472 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302473 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302474
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302475 ENTER();
2476
2477 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302478 return;
2479 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302480
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302481 if (!pMsg)
2482 {
2483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2484 return;
2485 }
2486
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302487 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2488 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302489
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302490 context = &pHddCtx->ext_scan_context;
2491 spin_lock(&hdd_context_lock);
2492 if (context->request_id == pData->requestId) {
2493 context->response_status = pData->status ? -EINVAL : 0;
2494 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302495 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302496 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302497
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302498 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302499 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302500}
2501
2502static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2503 void *pMsg)
2504{
2505 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302506 tpSirEXTScanResetBssidHotlistRspParams pData =
2507 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302508 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302509
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302510 ENTER();
2511
2512 if (wlan_hdd_validate_context(pHddCtx)) {
2513 return;
2514 }
2515 if (!pMsg)
2516 {
2517 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302518 return;
2519 }
2520
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302521 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2522 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302523
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302524 context = &pHddCtx->ext_scan_context;
2525 spin_lock(&hdd_context_lock);
2526 if (context->request_id == pData->requestId) {
2527 context->response_status = pData->status ? -EINVAL : 0;
2528 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302529 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302530 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302531
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302532 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302533 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302534}
2535
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05302536static void wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(void *ctx,
2537 void *pMsg)
2538{
2539 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2540 tpSirEXTScanSetSsidHotListRspParams pData =
2541 (tpSirEXTScanSetSsidHotListRspParams) pMsg;
2542 struct hdd_ext_scan_context *context;
2543
2544 if (wlan_hdd_validate_context(pHddCtx)){
2545 return;
2546 }
2547
2548 if (!pMsg)
2549 {
2550 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2551 return;
2552 }
2553
2554 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2555 pData->status);
2556
2557 context = &pHddCtx->ext_scan_context;
2558 spin_lock(&hdd_context_lock);
2559 if (context->request_id == pData->requestId) {
2560 context->response_status = pData->status ? -EINVAL : 0;
2561 complete(&context->response_event);
2562 }
2563 spin_unlock(&hdd_context_lock);
2564
2565 return;
2566}
2567
2568static void wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(void *ctx,
2569 void *pMsg)
2570{
2571 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2572 tpSirEXTScanResetSsidHotlistRspParams pData =
2573 (tpSirEXTScanResetSsidHotlistRspParams) pMsg;
2574 struct hdd_ext_scan_context *context;
2575
2576 if (wlan_hdd_validate_context(pHddCtx)) {
2577 return;
2578 }
2579 if (!pMsg)
2580 {
2581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2582 return;
2583 }
2584
2585 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2586 pData->status);
2587
2588 context = &pHddCtx->ext_scan_context;
2589 spin_lock(&hdd_context_lock);
2590 if (context->request_id == pData->requestId) {
2591 context->response_status = pData->status ? -EINVAL : 0;
2592 complete(&context->response_event);
2593 }
2594 spin_unlock(&hdd_context_lock);
2595
2596 return;
2597}
2598
2599
Dino Mycle6fb96c12014-06-10 11:52:40 +05302600static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2601 void *pMsg)
2602{
2603 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2604 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302605 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302606 tANI_S32 totalResults;
2607 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302608 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
2609 struct hdd_ext_scan_context *context;
2610 bool ignore_cached_results = false;
2611 tExtscanCachedScanResult *result;
2612 struct nlattr *nla_results;
2613 tANI_U16 ieLength= 0;
2614 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302615
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302616 ENTER();
2617
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302618 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302619 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302620
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302621 if (!pMsg)
2622 {
2623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2624 return;
2625 }
2626
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302627 spin_lock(&hdd_context_lock);
2628 context = &pHddCtx->ext_scan_context;
2629 ignore_cached_results = context->ignore_cached_results;
2630 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302631
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302632 if (ignore_cached_results) {
2633 hddLog(LOGE,
2634 FL("Ignore the cached results received after timeout"));
2635 return;
2636 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302637
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302638 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
2639 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302640
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302641 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302642
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302643 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
2644 scan_id_index++) {
2645 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302646
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302647 totalResults = result->num_results;
2648 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
2649 result->scan_id, result->flags, totalResults);
2650 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302651
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302652 do{
2653 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2654 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2655 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302656
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302657 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2658 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
2659
2660 if (!skb) {
2661 hddLog(VOS_TRACE_LEVEL_ERROR,
2662 FL("cfg80211_vendor_event_alloc failed"));
2663 return;
2664 }
2665
2666 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2667
2668 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2669 pData->requestId) ||
2670 nla_put_u32(skb,
2671 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2672 resultsPerEvent)) {
2673 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2674 goto fail;
2675 }
2676 if (nla_put_u8(skb,
2677 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2678 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302679 {
2680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2681 goto fail;
2682 }
2683
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302684 if (nla_put_u32(skb,
2685 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2686 result->scan_id)) {
2687 hddLog(LOGE, FL("put fail"));
2688 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302689 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302690
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302691 nla_results = nla_nest_start(skb,
2692 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
2693 if (!nla_results)
2694 goto fail;
2695
2696 if (resultsPerEvent) {
2697 struct nlattr *aps;
2698 struct nlattr *nla_result;
2699
2700 nla_result = nla_nest_start(skb, scan_id_index);
2701 if(!nla_result)
2702 goto fail;
2703
2704 if (nla_put_u32(skb,
2705 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2706 result->scan_id) ||
2707 nla_put_u32(skb,
2708 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
2709 result->flags) ||
2710 nla_put_u32(skb,
2711 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2712 totalResults)) {
2713 hddLog(LOGE, FL("put fail"));
2714 goto fail;
2715 }
2716
2717 aps = nla_nest_start(skb,
2718 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2719 if (!aps)
2720 {
2721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2722 goto fail;
2723 }
2724
2725 head_ptr = (tpSirWifiScanResult) &(result->ap);
2726
2727 for (j = 0; j < resultsPerEvent; j++, i++) {
2728 struct nlattr *ap;
2729 pSirWifiScanResult = head_ptr + i;
2730
2731 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05302732 * Firmware returns timestamp from extscan_start till
2733 * BSSID was cached (in micro seconds). Add this with
2734 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302735 * to derive the time since boot when the
2736 * BSSID was cached.
2737 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05302738 pSirWifiScanResult->ts +=
2739 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302740 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2741 "Ssid (%s)"
2742 "Bssid: %pM "
2743 "Channel (%u)"
2744 "Rssi (%d)"
2745 "RTT (%u)"
2746 "RTT_SD (%u)"
2747 "Beacon Period %u"
2748 "Capability 0x%x "
2749 "Ie length %d",
2750 i,
2751 pSirWifiScanResult->ts,
2752 pSirWifiScanResult->ssid,
2753 pSirWifiScanResult->bssid,
2754 pSirWifiScanResult->channel,
2755 pSirWifiScanResult->rssi,
2756 pSirWifiScanResult->rtt,
2757 pSirWifiScanResult->rtt_sd,
2758 pSirWifiScanResult->beaconPeriod,
2759 pSirWifiScanResult->capability,
2760 ieLength);
2761
2762 ap = nla_nest_start(skb, j + 1);
2763 if (!ap)
2764 {
2765 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2766 goto fail;
2767 }
2768
2769 if (nla_put_u64(skb,
2770 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2771 pSirWifiScanResult->ts) )
2772 {
2773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2774 goto fail;
2775 }
2776 if (nla_put(skb,
2777 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2778 sizeof(pSirWifiScanResult->ssid),
2779 pSirWifiScanResult->ssid) )
2780 {
2781 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2782 goto fail;
2783 }
2784 if (nla_put(skb,
2785 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2786 sizeof(pSirWifiScanResult->bssid),
2787 pSirWifiScanResult->bssid) )
2788 {
2789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2790 goto fail;
2791 }
2792 if (nla_put_u32(skb,
2793 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2794 pSirWifiScanResult->channel) )
2795 {
2796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2797 goto fail;
2798 }
2799 if (nla_put_s32(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2801 pSirWifiScanResult->rssi) )
2802 {
2803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2804 goto fail;
2805 }
2806 if (nla_put_u32(skb,
2807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2808 pSirWifiScanResult->rtt) )
2809 {
2810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2811 goto fail;
2812 }
2813 if (nla_put_u32(skb,
2814 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2815 pSirWifiScanResult->rtt_sd))
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2818 goto fail;
2819 }
2820 if (nla_put_u32(skb,
2821 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2822 pSirWifiScanResult->beaconPeriod))
2823 {
2824 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2825 goto fail;
2826 }
2827 if (nla_put_u32(skb,
2828 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2829 pSirWifiScanResult->capability))
2830 {
2831 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2832 goto fail;
2833 }
2834 if (nla_put_u32(skb,
2835 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2836 ieLength))
2837 {
2838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2839 goto fail;
2840 }
2841
2842 if (ieLength)
2843 if (nla_put(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2845 ieLength, ie)) {
2846 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2847 goto fail;
2848 }
2849
2850 nla_nest_end(skb, ap);
2851 }
2852 nla_nest_end(skb, aps);
2853 nla_nest_end(skb, nla_result);
2854 }
2855
2856 nla_nest_end(skb, nla_results);
2857
2858 cfg80211_vendor_cmd_reply(skb);
2859
2860 } while (totalResults > 0);
2861 }
2862
2863 if (!pData->moreData) {
2864 spin_lock(&hdd_context_lock);
2865 context->response_status = 0;
2866 complete(&context->response_event);
2867 spin_unlock(&hdd_context_lock);
2868 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302869
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302870 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302871 return;
2872fail:
2873 kfree_skb(skb);
2874 return;
2875}
2876
2877static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2878 void *pMsg)
2879{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302880 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302881 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2882 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302883 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302884
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302885 ENTER();
2886
2887 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302888 hddLog(LOGE,
2889 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302890 return;
2891 }
2892 if (!pMsg)
2893 {
2894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302895 return;
2896 }
2897
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302898 if (pData->bss_found)
2899 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2900 else
2901 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2902
Dino Mycle6fb96c12014-06-10 11:52:40 +05302903 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302904#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2905 NULL,
2906#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302907 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302908 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302909
2910 if (!skb) {
2911 hddLog(VOS_TRACE_LEVEL_ERROR,
2912 FL("cfg80211_vendor_event_alloc failed"));
2913 return;
2914 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302915
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302916 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2917 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2918 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2919 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2920
2921 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302922 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2923 "Ssid (%s) "
2924 "Bssid (" MAC_ADDRESS_STR ") "
2925 "Channel (%u) "
2926 "Rssi (%d) "
2927 "RTT (%u) "
2928 "RTT_SD (%u) ",
2929 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302930 pData->bssHotlist[i].ts,
2931 pData->bssHotlist[i].ssid,
2932 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2933 pData->bssHotlist[i].channel,
2934 pData->bssHotlist[i].rssi,
2935 pData->bssHotlist[i].rtt,
2936 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302937 }
2938
2939 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2940 pData->requestId) ||
2941 nla_put_u32(skb,
2942 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302943 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302944 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2945 goto fail;
2946 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302947 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302948 struct nlattr *aps;
2949
2950 aps = nla_nest_start(skb,
2951 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2952 if (!aps)
2953 goto fail;
2954
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302955 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302956 struct nlattr *ap;
2957
2958 ap = nla_nest_start(skb, i + 1);
2959 if (!ap)
2960 goto fail;
2961
2962 if (nla_put_u64(skb,
2963 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302964 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302965 nla_put(skb,
2966 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302967 sizeof(pData->bssHotlist[i].ssid),
2968 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 nla_put(skb,
2970 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302971 sizeof(pData->bssHotlist[i].bssid),
2972 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302973 nla_put_u32(skb,
2974 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302975 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302976 nla_put_s32(skb,
2977 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302978 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302979 nla_put_u32(skb,
2980 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302981 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302982 nla_put_u32(skb,
2983 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302984 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302985 goto fail;
2986
2987 nla_nest_end(skb, ap);
2988 }
2989 nla_nest_end(skb, aps);
2990
2991 if (nla_put_u8(skb,
2992 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2993 pData->moreData))
2994 goto fail;
2995 }
2996
2997 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302998 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302999 return;
3000
3001fail:
3002 kfree_skb(skb);
3003 return;
3004
3005}
Dino Mycle6fb96c12014-06-10 11:52:40 +05303006
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303007/**
3008 * wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind() -
3009 * Handle an SSID hotlist match event
3010 * @ctx: HDD context registered with SME
3011 * @event: The SSID hotlist match event
3012 *
3013 * This function will take an SSID match event that was generated by
3014 * firmware and will convert it into a cfg80211 vendor event which is
3015 * sent to userspace.
3016 *
3017 * Return: none
3018 */
3019static void
3020wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(void *ctx,
3021 void *pMsg)
3022{
3023 hdd_context_t *hdd_ctx = ctx;
3024 struct sk_buff *skb;
3025 tANI_U32 i, index;
3026 tpSirEXTScanSsidHotlistMatch pData = (tpSirEXTScanSsidHotlistMatch) pMsg;
3027
3028 ENTER();
3029
3030 if (wlan_hdd_validate_context(hdd_ctx)) {
3031 hddLog(LOGE,
3032 FL("HDD context is not valid or response"));
3033 return;
3034 }
3035 if (!pMsg)
3036 {
3037 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3038 return;
3039 }
3040
3041 if (pData->ssid_found) {
3042 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX;
3043 hddLog(LOG1, "SSID hotlist found");
3044 } else {
3045 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX;
3046 hddLog(LOG1, "SSID hotlist lost");
3047 }
3048
3049 skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
3050#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3051 NULL,
3052#endif
3053 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3054 index, GFP_KERNEL);
3055
3056 if (!skb) {
3057 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
3058 return;
3059 }
3060 hddLog(LOG1, "Req Id %u, Num of SSIDs %u, More Data (%u)",
3061 pData->requestId, pData->numHotlistSsid, pData->moreData);
3062
3063 for (i = 0; i < pData->numHotlistSsid; i++) {
3064 hddLog(LOG1, "[i=%d] Timestamp %llu "
3065 "Ssid: %s "
3066 "Bssid (" MAC_ADDRESS_STR ") "
3067 "Channel %u "
3068 "Rssi %d "
3069 "RTT %u "
3070 "RTT_SD %u",
3071 i,
3072 pData->ssidHotlist[i].ts,
3073 pData->ssidHotlist[i].ssid,
3074 MAC_ADDR_ARRAY(pData->ssidHotlist[i].bssid),
3075 pData->ssidHotlist[i].channel,
3076 pData->ssidHotlist[i].rssi,
3077 pData->ssidHotlist[i].rtt,
3078 pData->ssidHotlist[i].rtt_sd);
3079 }
3080
3081 if (nla_put_u32(skb,
3082 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3083 pData->requestId) ||
3084 nla_put_u32(skb,
3085 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3086 pData->numHotlistSsid)) {
3087 hddLog(LOGE, FL("put fail"));
3088 goto fail;
3089 }
3090
3091 if (pData->numHotlistSsid) {
3092 struct nlattr *aps;
3093 aps = nla_nest_start(skb,
3094 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3095 if (!aps) {
3096 hddLog(LOGE, FL("nest fail"));
3097 goto fail;
3098 }
3099
3100 for (i = 0; i < pData->numHotlistSsid; i++) {
3101 struct nlattr *ap;
3102
3103 ap = nla_nest_start(skb, i);
3104 if (!ap) {
3105 hddLog(LOGE, FL("nest fail"));
3106 goto fail;
3107 }
3108
3109 if (nla_put_u64(skb,
3110 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3111 pData->ssidHotlist[i].ts) ||
3112 nla_put(skb,
3113 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3114 sizeof(pData->ssidHotlist[i].ssid),
3115 pData->ssidHotlist[i].ssid) ||
3116 nla_put(skb,
3117 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3118 sizeof(pData->ssidHotlist[i].bssid),
3119 pData->ssidHotlist[i].bssid) ||
3120 nla_put_u32(skb,
3121 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3122 pData->ssidHotlist[i].channel) ||
3123 nla_put_s32(skb,
3124 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3125 pData->ssidHotlist[i].rssi) ||
3126 nla_put_u32(skb,
3127 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3128 pData->ssidHotlist[i].rtt) ||
3129 nla_put_u32(skb,
3130 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3131 pData->ssidHotlist[i].rtt_sd)) {
3132 hddLog(LOGE, FL("put fail"));
3133 goto fail;
3134 }
3135 nla_nest_end(skb, ap);
3136 }
3137 nla_nest_end(skb, aps);
3138
3139 if (nla_put_u8(skb,
3140 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3141 pData->moreData)) {
3142 hddLog(LOGE, FL("put fail"));
3143 goto fail;
3144 }
3145 }
3146
3147 cfg80211_vendor_event(skb, GFP_KERNEL);
3148 return;
3149
3150fail:
3151 kfree_skb(skb);
3152 return;
3153
3154}
3155
3156
Dino Mycle6fb96c12014-06-10 11:52:40 +05303157static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3158 void *pMsg)
3159{
3160 struct sk_buff *skb;
3161 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3162 tpSirWifiFullScanResultEvent pData =
3163 (tpSirWifiFullScanResultEvent) (pMsg);
3164
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303165 ENTER();
3166
3167 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303168 hddLog(LOGE,
3169 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303170 return;
3171 }
3172 if (!pMsg)
3173 {
3174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303175 return;
3176 }
3177
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303178 /*
3179 * If the full scan result including IE data exceeds NL 4K size
3180 * limitation, drop that beacon/probe rsp frame.
3181 */
3182 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
3183 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
3184 return;
3185 }
3186
Dino Mycle6fb96c12014-06-10 11:52:40 +05303187 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303188#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3189 NULL,
3190#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303191 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3192 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3193 GFP_KERNEL);
3194
3195 if (!skb) {
3196 hddLog(VOS_TRACE_LEVEL_ERROR,
3197 FL("cfg80211_vendor_event_alloc failed"));
3198 return;
3199 }
3200
Dino Mycle6fb96c12014-06-10 11:52:40 +05303201 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3202 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3203 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3204 "Ssid (%s)"
3205 "Bssid (" MAC_ADDRESS_STR ")"
3206 "Channel (%u)"
3207 "Rssi (%d)"
3208 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303209 "RTT_SD (%u)"
3210 "Bcn Period %d"
3211 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303212 pData->ap.ts,
3213 pData->ap.ssid,
3214 MAC_ADDR_ARRAY(pData->ap.bssid),
3215 pData->ap.channel,
3216 pData->ap.rssi,
3217 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303218 pData->ap.rtt_sd,
3219 pData->ap.beaconPeriod,
3220 pData->ap.capability);
3221
Dino Mycle6fb96c12014-06-10 11:52:40 +05303222 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3223 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3224 pData->requestId) ||
3225 nla_put_u64(skb,
3226 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3227 pData->ap.ts) ||
3228 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3229 sizeof(pData->ap.ssid),
3230 pData->ap.ssid) ||
3231 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3232 WNI_CFG_BSSID_LEN,
3233 pData->ap.bssid) ||
3234 nla_put_u32(skb,
3235 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3236 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303237 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303238 pData->ap.rssi) ||
3239 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3240 pData->ap.rtt) ||
3241 nla_put_u32(skb,
3242 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3243 pData->ap.rtt_sd) ||
3244 nla_put_u16(skb,
3245 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3246 pData->ap.beaconPeriod) ||
3247 nla_put_u16(skb,
3248 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3249 pData->ap.capability) ||
3250 nla_put_u32(skb,
3251 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303252 pData->ieLength) ||
3253 nla_put_u8(skb,
3254 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3255 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303256 {
3257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3258 goto nla_put_failure;
3259 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303260
3261 if (pData->ieLength) {
3262 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3263 pData->ieLength,
3264 pData->ie))
3265 {
3266 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3267 goto nla_put_failure;
3268 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303269 }
3270
3271 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303272 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303273 return;
3274
3275nla_put_failure:
3276 kfree_skb(skb);
3277 return;
3278}
3279
3280static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3281 void *pMsg)
3282{
3283 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3284 struct sk_buff *skb = NULL;
3285 tpSirEXTScanResultsAvailableIndParams pData =
3286 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3287
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303288 ENTER();
3289
3290 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303291 hddLog(LOGE,
3292 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303293 return;
3294 }
3295 if (!pMsg)
3296 {
3297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303298 return;
3299 }
3300
3301 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303302#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3303 NULL,
3304#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303305 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3306 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3307 GFP_KERNEL);
3308
3309 if (!skb) {
3310 hddLog(VOS_TRACE_LEVEL_ERROR,
3311 FL("cfg80211_vendor_event_alloc failed"));
3312 return;
3313 }
3314
Dino Mycle6fb96c12014-06-10 11:52:40 +05303315 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3316 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3317 pData->numResultsAvailable);
3318 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3319 pData->requestId) ||
3320 nla_put_u32(skb,
3321 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3322 pData->numResultsAvailable)) {
3323 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3324 goto nla_put_failure;
3325 }
3326
3327 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303328 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303329 return;
3330
3331nla_put_failure:
3332 kfree_skb(skb);
3333 return;
3334}
3335
3336static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3337{
3338 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3339 struct sk_buff *skb = NULL;
3340 tpSirEXTScanProgressIndParams pData =
3341 (tpSirEXTScanProgressIndParams) pMsg;
3342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303343 ENTER();
3344
3345 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303346 hddLog(LOGE,
3347 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303348 return;
3349 }
3350 if (!pMsg)
3351 {
3352 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303353 return;
3354 }
3355
3356 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3358 NULL,
3359#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303360 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3361 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3362 GFP_KERNEL);
3363
3364 if (!skb) {
3365 hddLog(VOS_TRACE_LEVEL_ERROR,
3366 FL("cfg80211_vendor_event_alloc failed"));
3367 return;
3368 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303369 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303370 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3371 pData->extScanEventType);
3372 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3373 pData->status);
3374
3375 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3376 pData->extScanEventType) ||
3377 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303378 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3379 pData->requestId) ||
3380 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303381 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3382 pData->status)) {
3383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3384 goto nla_put_failure;
3385 }
3386
3387 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303388 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303389 return;
3390
3391nla_put_failure:
3392 kfree_skb(skb);
3393 return;
3394}
3395
3396void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3397 void *pMsg)
3398{
3399 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3400
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303401 ENTER();
3402
Dino Mycle6fb96c12014-06-10 11:52:40 +05303403 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303404 return;
3405 }
3406
3407 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3408
3409
3410 switch(evType) {
3411 case SIR_HAL_EXTSCAN_START_RSP:
3412 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3413 break;
3414
3415 case SIR_HAL_EXTSCAN_STOP_RSP:
3416 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3417 break;
3418 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3419 /* There is no need to send this response to upper layer
3420 Just log the message */
3421 hddLog(VOS_TRACE_LEVEL_INFO,
3422 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3423 break;
3424 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3425 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3426 break;
3427
3428 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3429 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3430 break;
3431
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303432 case SIR_HAL_EXTSCAN_SET_SSID_HOTLIST_RSP:
3433 wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(ctx, pMsg);
3434 break;
3435
3436 case SIR_HAL_EXTSCAN_RESET_SSID_HOTLIST_RSP:
3437 wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(ctx, pMsg);
3438 break;
3439
Dino Mycle6fb96c12014-06-10 11:52:40 +05303440 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303441 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303442 break;
3443 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3444 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3445 break;
3446 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3447 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3448 break;
3449 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3450 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3451 break;
3452 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3453 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3454 break;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303455 case SIR_HAL_EXTSCAN_SSID_HOTLIST_MATCH_IND:
3456 wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(ctx, pMsg);
3457 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303458 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3459 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3460 break;
3461 default:
3462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3463 break;
3464 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303465 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466}
3467
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303468static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3469 struct wireless_dev *wdev,
3470 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303471{
Dino Myclee8843b32014-07-04 14:21:45 +05303472 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303473 struct net_device *dev = wdev->netdev;
3474 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3475 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3476 struct nlattr
3477 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3478 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303479 struct hdd_ext_scan_context *context;
3480 unsigned long rc;
3481 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303482
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303483 ENTER();
3484
Dino Mycle6fb96c12014-06-10 11:52:40 +05303485 status = wlan_hdd_validate_context(pHddCtx);
3486 if (0 != status)
3487 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303488 return -EINVAL;
3489 }
Dino Myclee8843b32014-07-04 14:21:45 +05303490 /* check the EXTScan Capability */
3491 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303492 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3493 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303494 {
3495 hddLog(VOS_TRACE_LEVEL_ERROR,
3496 FL("EXTScan not enabled/supported by Firmware"));
3497 return -EINVAL;
3498 }
3499
Dino Mycle6fb96c12014-06-10 11:52:40 +05303500 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3501 data, dataLen,
3502 wlan_hdd_extscan_config_policy)) {
3503 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3504 return -EINVAL;
3505 }
3506
3507 /* Parse and fetch request Id */
3508 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3509 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3510 return -EINVAL;
3511 }
3512
Dino Myclee8843b32014-07-04 14:21:45 +05303513 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303514 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303515 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303516
Dino Myclee8843b32014-07-04 14:21:45 +05303517 reqMsg.sessionId = pAdapter->sessionId;
3518 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303519
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303520 vos_spin_lock_acquire(&hdd_context_lock);
3521 context = &pHddCtx->ext_scan_context;
3522 context->request_id = reqMsg.requestId;
3523 INIT_COMPLETION(context->response_event);
3524 vos_spin_lock_release(&hdd_context_lock);
3525
Dino Myclee8843b32014-07-04 14:21:45 +05303526 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303527 if (!HAL_STATUS_SUCCESS(status)) {
3528 hddLog(VOS_TRACE_LEVEL_ERROR,
3529 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303530 return -EINVAL;
3531 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303532
3533 rc = wait_for_completion_timeout(&context->response_event,
3534 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3535 if (!rc) {
3536 hddLog(LOGE, FL("Target response timed out"));
3537 return -ETIMEDOUT;
3538 }
3539
3540 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3541 if (ret)
3542 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3543
3544 return ret;
3545
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303546 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303547 return 0;
3548}
3549
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303550static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3551 struct wireless_dev *wdev,
3552 const void *data, int dataLen)
3553{
3554 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303555
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303556 vos_ssr_protect(__func__);
3557 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3558 vos_ssr_unprotect(__func__);
3559
3560 return ret;
3561}
3562
3563static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3564 struct wireless_dev *wdev,
3565 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303566{
Dino Myclee8843b32014-07-04 14:21:45 +05303567 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303568 struct net_device *dev = wdev->netdev;
3569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3570 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3571 struct nlattr
3572 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3573 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303574 struct hdd_ext_scan_context *context;
3575 unsigned long rc;
3576 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303578 ENTER();
3579
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303580 if (VOS_FTM_MODE == hdd_get_conparam()) {
3581 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3582 return -EINVAL;
3583 }
3584
Dino Mycle6fb96c12014-06-10 11:52:40 +05303585 status = wlan_hdd_validate_context(pHddCtx);
3586 if (0 != status)
3587 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303588 return -EINVAL;
3589 }
Dino Myclee8843b32014-07-04 14:21:45 +05303590 /* check the EXTScan Capability */
3591 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303592 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3593 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303594 {
3595 hddLog(VOS_TRACE_LEVEL_ERROR,
3596 FL("EXTScan not enabled/supported by Firmware"));
3597 return -EINVAL;
3598 }
3599
Dino Mycle6fb96c12014-06-10 11:52:40 +05303600 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3601 data, dataLen,
3602 wlan_hdd_extscan_config_policy)) {
3603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3604 return -EINVAL;
3605 }
3606 /* Parse and fetch request Id */
3607 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3609 return -EINVAL;
3610 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303611
Dino Myclee8843b32014-07-04 14:21:45 +05303612 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303613 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3614
Dino Myclee8843b32014-07-04 14:21:45 +05303615 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303616
Dino Myclee8843b32014-07-04 14:21:45 +05303617 reqMsg.sessionId = pAdapter->sessionId;
3618 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619
3620 /* Parse and fetch flush parameter */
3621 if (!tb
3622 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3623 {
3624 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3625 goto failed;
3626 }
Dino Myclee8843b32014-07-04 14:21:45 +05303627 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303628 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3629
Dino Myclee8843b32014-07-04 14:21:45 +05303630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303631
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303632 spin_lock(&hdd_context_lock);
3633 context = &pHddCtx->ext_scan_context;
3634 context->request_id = reqMsg.requestId;
3635 context->ignore_cached_results = false;
3636 INIT_COMPLETION(context->response_event);
3637 spin_unlock(&hdd_context_lock);
3638
Dino Myclee8843b32014-07-04 14:21:45 +05303639 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303640 if (!HAL_STATUS_SUCCESS(status)) {
3641 hddLog(VOS_TRACE_LEVEL_ERROR,
3642 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303643 return -EINVAL;
3644 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303645
3646 rc = wait_for_completion_timeout(&context->response_event,
3647 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3648 if (!rc) {
3649 hddLog(LOGE, FL("Target response timed out"));
3650 retval = -ETIMEDOUT;
3651 spin_lock(&hdd_context_lock);
3652 context->ignore_cached_results = true;
3653 spin_unlock(&hdd_context_lock);
3654 } else {
3655 spin_lock(&hdd_context_lock);
3656 retval = context->response_status;
3657 spin_unlock(&hdd_context_lock);
3658 }
3659
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303660 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303661 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303662
3663failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303664 return -EINVAL;
3665}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303666static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3667 struct wireless_dev *wdev,
3668 const void *data, int dataLen)
3669{
3670 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303672 vos_ssr_protect(__func__);
3673 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3674 vos_ssr_unprotect(__func__);
3675
3676 return ret;
3677}
3678
3679static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303680 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303681 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303682{
3683 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3684 struct net_device *dev = wdev->netdev;
3685 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3686 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3687 struct nlattr
3688 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3689 struct nlattr
3690 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3691 struct nlattr *apTh;
3692 eHalStatus status;
3693 tANI_U8 i = 0;
3694 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303695 struct hdd_ext_scan_context *context;
3696 tANI_U32 request_id;
3697 unsigned long rc;
3698 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303699
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303700 ENTER();
3701
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303702 if (VOS_FTM_MODE == hdd_get_conparam()) {
3703 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3704 return -EINVAL;
3705 }
3706
Dino Mycle6fb96c12014-06-10 11:52:40 +05303707 status = wlan_hdd_validate_context(pHddCtx);
3708 if (0 != status)
3709 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303710 return -EINVAL;
3711 }
Dino Myclee8843b32014-07-04 14:21:45 +05303712 /* check the EXTScan Capability */
3713 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303714 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3715 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303716 {
3717 hddLog(VOS_TRACE_LEVEL_ERROR,
3718 FL("EXTScan not enabled/supported by Firmware"));
3719 return -EINVAL;
3720 }
3721
Dino Mycle6fb96c12014-06-10 11:52:40 +05303722 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3723 data, dataLen,
3724 wlan_hdd_extscan_config_policy)) {
3725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3726 return -EINVAL;
3727 }
3728
3729 /* Parse and fetch request Id */
3730 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3731 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3732 return -EINVAL;
3733 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303734 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3735 vos_mem_malloc(sizeof(*pReqMsg));
3736 if (!pReqMsg) {
3737 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3738 return -ENOMEM;
3739 }
3740
Dino Myclee8843b32014-07-04 14:21:45 +05303741
Dino Mycle6fb96c12014-06-10 11:52:40 +05303742 pReqMsg->requestId = nla_get_u32(
3743 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3744 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3745
3746 /* Parse and fetch number of APs */
3747 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3749 goto fail;
3750 }
3751
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303752 /* Parse and fetch lost ap sample size */
3753 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3754 hddLog(LOGE, FL("attr lost ap sample size failed"));
3755 goto fail;
3756 }
3757
3758 pReqMsg->lostBssidSampleSize = nla_get_u32(
3759 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3760 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3761
Dino Mycle6fb96c12014-06-10 11:52:40 +05303762 pReqMsg->sessionId = pAdapter->sessionId;
3763 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3764
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303765 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303766 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303767 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303768
3769 nla_for_each_nested(apTh,
3770 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3771 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3772 nla_data(apTh), nla_len(apTh),
3773 NULL)) {
3774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3775 goto fail;
3776 }
3777
3778 /* Parse and fetch MAC address */
3779 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3780 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3781 goto fail;
3782 }
3783 memcpy(pReqMsg->ap[i].bssid, nla_data(
3784 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3785 sizeof(tSirMacAddr));
3786 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3787
3788 /* Parse and fetch low RSSI */
3789 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3791 goto fail;
3792 }
3793 pReqMsg->ap[i].low = nla_get_s32(
3794 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3795 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3796
3797 /* Parse and fetch high RSSI */
3798 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3799 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3800 goto fail;
3801 }
3802 pReqMsg->ap[i].high = nla_get_s32(
3803 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3804 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3805 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303806 i++;
3807 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303808
3809 context = &pHddCtx->ext_scan_context;
3810 spin_lock(&hdd_context_lock);
3811 INIT_COMPLETION(context->response_event);
3812 context->request_id = request_id = pReqMsg->requestId;
3813 spin_unlock(&hdd_context_lock);
3814
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3816 if (!HAL_STATUS_SUCCESS(status)) {
3817 hddLog(VOS_TRACE_LEVEL_ERROR,
3818 FL("sme_SetBssHotlist failed(err=%d)"), status);
3819 vos_mem_free(pReqMsg);
3820 return -EINVAL;
3821 }
3822
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303823 /* request was sent -- wait for the response */
3824 rc = wait_for_completion_timeout(&context->response_event,
3825 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3826
3827 if (!rc) {
3828 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3829 retval = -ETIMEDOUT;
3830 } else {
3831 spin_lock(&hdd_context_lock);
3832 if (context->request_id == request_id)
3833 retval = context->response_status;
3834 else
3835 retval = -EINVAL;
3836 spin_unlock(&hdd_context_lock);
3837 }
3838
Dino Myclee8843b32014-07-04 14:21:45 +05303839 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303840 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303841 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303842
3843fail:
3844 vos_mem_free(pReqMsg);
3845 return -EINVAL;
3846}
3847
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303848static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3849 struct wireless_dev *wdev,
3850 const void *data, int dataLen)
3851{
3852 int ret = 0;
3853
3854 vos_ssr_protect(__func__);
3855 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3856 dataLen);
3857 vos_ssr_unprotect(__func__);
3858
3859 return ret;
3860}
3861
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303862/*
3863 * define short names for the global vendor params
3864 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3865 */
3866#define PARAM_MAX \
3867QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3868#define PARAM_REQUEST_ID \
3869QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3870#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3871QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3872#define PARAMS_NUM_SSID \
3873QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3874#define THRESHOLD_PARAM \
3875QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3876#define PARAM_SSID \
3877QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3878#define PARAM_BAND \
3879QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3880#define PARAM_RSSI_LOW \
3881QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3882#define PARAM_RSSI_HIGH \
3883QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3884
3885/**
3886 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3887 * @wiphy: Pointer to wireless phy
3888 * @wdev: Pointer to wireless device
3889 * @data: Pointer to data
3890 * @data_len: Data length
3891 *
3892 * Return: 0 on success, negative errno on failure
3893 */
3894static int
3895__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3896 struct wireless_dev *wdev,
3897 const void *data,
3898 int data_len)
3899{
3900 tSirEXTScanSetSsidHotListReqParams *request;
3901 struct net_device *dev = wdev->netdev;
3902 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3903 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3904 struct nlattr *tb[PARAM_MAX + 1];
3905 struct nlattr *tb2[PARAM_MAX + 1];
3906 struct nlattr *ssids;
3907 struct hdd_ext_scan_context *context;
3908 uint32_t request_id;
3909 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3910 int ssid_len;
Anurag Chouhand64d5232016-08-29 17:01:38 +05303911 int ssid_length;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303912 eHalStatus status;
3913 int i, rem, retval;
3914 unsigned long rc;
3915
3916 ENTER();
3917
3918 if (VOS_FTM_MODE == hdd_get_conparam()) {
3919 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3920 return -EINVAL;
3921 }
3922
3923 retval = wlan_hdd_validate_context(hdd_ctx);
3924 if (0 != retval) {
3925 hddLog(LOGE, FL("HDD context is not valid"));
3926 return -EINVAL;
3927 }
3928
3929 /* check the EXTScan Capability */
3930 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303931 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3932 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303933 {
3934 hddLog(VOS_TRACE_LEVEL_ERROR,
3935 FL("EXTScan not enabled/supported by Firmware"));
3936 return -EINVAL;
3937 }
3938
3939 if (nla_parse(tb, PARAM_MAX,
3940 data, data_len,
3941 wlan_hdd_extscan_config_policy)) {
3942 hddLog(LOGE, FL("Invalid ATTR"));
3943 return -EINVAL;
3944 }
3945
3946 request = vos_mem_malloc(sizeof(*request));
3947 if (!request) {
3948 hddLog(LOGE, FL("vos_mem_malloc failed"));
3949 return -ENOMEM;
3950 }
3951
3952 /* Parse and fetch request Id */
3953 if (!tb[PARAM_REQUEST_ID]) {
3954 hddLog(LOGE, FL("attr request id failed"));
3955 goto fail;
3956 }
3957
3958 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3959 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3960
3961 /* Parse and fetch lost SSID sample size */
3962 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3963 hddLog(LOGE, FL("attr number of Ssid failed"));
3964 goto fail;
3965 }
3966 request->lost_ssid_sample_size =
3967 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3968 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3969 request->lost_ssid_sample_size);
3970
3971 /* Parse and fetch number of hotlist SSID */
3972 if (!tb[PARAMS_NUM_SSID]) {
3973 hddLog(LOGE, FL("attr number of Ssid failed"));
3974 goto fail;
3975 }
3976 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3977 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3978
3979 request->session_id = adapter->sessionId;
3980 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
3981
3982 i = 0;
3983 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
3984 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
3985 hddLog(LOGE,
3986 FL("Too Many SSIDs, %d exceeds %d"),
3987 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
3988 break;
3989 }
3990 if (nla_parse(tb2, PARAM_MAX,
3991 nla_data(ssids), nla_len(ssids),
3992 wlan_hdd_extscan_config_policy)) {
3993 hddLog(LOGE, FL("nla_parse failed"));
3994 goto fail;
3995 }
3996
3997 /* Parse and fetch SSID */
3998 if (!tb2[PARAM_SSID]) {
3999 hddLog(LOGE, FL("attr ssid failed"));
4000 goto fail;
4001 }
Anurag Chouhand64d5232016-08-29 17:01:38 +05304002 ssid_length = nla_strlcpy(ssid_string, tb2[PARAM_SSID],
4003 sizeof(ssid_string));
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304004 hddLog(LOG1, FL("SSID %s"),
4005 ssid_string);
4006 ssid_len = strlen(ssid_string);
Anurag Chouhand64d5232016-08-29 17:01:38 +05304007 if (ssid_length > SIR_MAC_MAX_SSID_LENGTH) {
4008 hddLog(LOGE, FL("Invalid ssid length"));
4009 goto fail;
4010 }
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304011 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
4012 request->ssid[i].ssid.length = ssid_len;
4013 request->ssid[i].ssid.ssId[ssid_len] = '\0';
4014 hddLog(LOG1, FL("After copying SSID %s"),
4015 request->ssid[i].ssid.ssId);
4016 hddLog(LOG1, FL("After copying length: %d"),
4017 ssid_len);
4018
4019 /* Parse and fetch low RSSI */
4020 if (!tb2[PARAM_BAND]) {
4021 hddLog(LOGE, FL("attr band failed"));
4022 goto fail;
4023 }
4024 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
4025 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
4026
4027 /* Parse and fetch low RSSI */
4028 if (!tb2[PARAM_RSSI_LOW]) {
4029 hddLog(LOGE, FL("attr low RSSI failed"));
4030 goto fail;
4031 }
4032 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
4033 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
4034
4035 /* Parse and fetch high RSSI */
4036 if (!tb2[PARAM_RSSI_HIGH]) {
4037 hddLog(LOGE, FL("attr high RSSI failed"));
4038 goto fail;
4039 }
4040 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4041 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4042 i++;
4043 }
4044
4045 context = &hdd_ctx->ext_scan_context;
4046 spin_lock(&hdd_context_lock);
4047 INIT_COMPLETION(context->response_event);
4048 context->request_id = request_id = request->request_id;
4049 spin_unlock(&hdd_context_lock);
4050
4051 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4052 if (!HAL_STATUS_SUCCESS(status)) {
4053 hddLog(LOGE,
4054 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4055 goto fail;
4056 }
4057
4058 vos_mem_free(request);
4059
4060 /* request was sent -- wait for the response */
4061 rc = wait_for_completion_timeout(&context->response_event,
4062 msecs_to_jiffies
4063 (WLAN_WAIT_TIME_EXTSCAN));
4064 if (!rc) {
4065 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4066 retval = -ETIMEDOUT;
4067 } else {
4068 spin_lock(&hdd_context_lock);
4069 if (context->request_id == request_id)
4070 retval = context->response_status;
4071 else
4072 retval = -EINVAL;
4073 spin_unlock(&hdd_context_lock);
4074 }
4075
4076 return retval;
4077
4078fail:
4079 vos_mem_free(request);
4080 return -EINVAL;
4081}
4082
4083/*
4084 * done with short names for the global vendor params
4085 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4086 */
4087#undef PARAM_MAX
4088#undef PARAM_REQUEST_ID
4089#undef PARAMS_NUM_SSID
4090#undef THRESHOLD_PARAM
4091#undef PARAM_SSID
4092#undef PARAM_BAND
4093#undef PARAM_RSSI_LOW
4094#undef PARAM_RSSI_HIGH
4095
4096static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4097 struct wireless_dev *wdev,
4098 const void *data, int dataLen)
4099{
4100 int ret = 0;
4101
4102 vos_ssr_protect(__func__);
4103 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4104 dataLen);
4105 vos_ssr_unprotect(__func__);
4106
4107 return ret;
4108}
4109
4110static int
4111__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4112 struct wireless_dev *wdev,
4113 const void *data,
4114 int data_len)
4115{
4116 tSirEXTScanResetSsidHotlistReqParams request;
4117 struct net_device *dev = wdev->netdev;
4118 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4119 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4120 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4121 struct hdd_ext_scan_context *context;
4122 uint32_t request_id;
4123 eHalStatus status;
4124 int retval;
4125 unsigned long rc;
4126
4127 ENTER();
4128
4129 if (VOS_FTM_MODE == hdd_get_conparam()) {
4130 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4131 return -EINVAL;
4132 }
4133
4134 retval = wlan_hdd_validate_context(hdd_ctx);
4135 if (0 != retval) {
4136 hddLog(LOGE, FL("HDD context is not valid"));
4137 return -EINVAL;
4138 }
4139
4140 /* check the EXTScan Capability */
4141 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304142 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4143 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304144 {
4145 hddLog(LOGE,
4146 FL("EXTScan not enabled/supported by Firmware"));
4147 return -EINVAL;
4148 }
4149
4150 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4151 data, data_len,
4152 wlan_hdd_extscan_config_policy)) {
4153 hddLog(LOGE, FL("Invalid ATTR"));
4154 return -EINVAL;
4155 }
4156
4157 /* Parse and fetch request Id */
4158 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4159 hddLog(LOGE, FL("attr request id failed"));
4160 return -EINVAL;
4161 }
4162
4163 request.requestId = nla_get_u32(
4164 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4165 request.sessionId = adapter->sessionId;
4166 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4167 request.sessionId);
4168
4169 context = &hdd_ctx->ext_scan_context;
4170 spin_lock(&hdd_context_lock);
4171 INIT_COMPLETION(context->response_event);
4172 context->request_id = request_id = request.requestId;
4173 spin_unlock(&hdd_context_lock);
4174
4175 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4176 if (!HAL_STATUS_SUCCESS(status)) {
4177 hddLog(LOGE,
4178 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4179 return -EINVAL;
4180 }
4181
4182 /* request was sent -- wait for the response */
4183 rc = wait_for_completion_timeout(&context->response_event,
4184 msecs_to_jiffies
4185 (WLAN_WAIT_TIME_EXTSCAN));
4186 if (!rc) {
4187 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4188 retval = -ETIMEDOUT;
4189 } else {
4190 spin_lock(&hdd_context_lock);
4191 if (context->request_id == request_id)
4192 retval = context->response_status;
4193 else
4194 retval = -EINVAL;
4195 spin_unlock(&hdd_context_lock);
4196 }
4197
4198 return retval;
4199}
4200
4201static int
4202wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4203 struct wireless_dev *wdev,
4204 const void *data,
4205 int data_len)
4206{
4207 int ret;
4208
4209 vos_ssr_protect(__func__);
4210 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4211 data, data_len);
4212 vos_ssr_unprotect(__func__);
4213
4214 return ret;
4215}
4216
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304217static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304219 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304220{
Agrawal Ashish16abf782016-08-18 22:42:59 +05304221 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4222 struct net_device *dev = wdev->netdev;
4223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4224 uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4225 uint8_t num_channels = 0;
4226 uint8_t num_chan_new = 0;
4227 uint8_t buf[256] = {0};
Dino Mycle6fb96c12014-06-10 11:52:40 +05304228 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304229 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304230 tWifiBand wifiBand;
4231 eHalStatus status;
4232 struct sk_buff *replySkb;
Agrawal Ashish16abf782016-08-18 22:42:59 +05304233 tANI_U8 i,j,k;
4234 int ret,len = 0;;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304235
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304236 ENTER();
4237
Dino Mycle6fb96c12014-06-10 11:52:40 +05304238 status = wlan_hdd_validate_context(pHddCtx);
4239 if (0 != status)
4240 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304241 return -EINVAL;
4242 }
Dino Myclee8843b32014-07-04 14:21:45 +05304243
Dino Mycle6fb96c12014-06-10 11:52:40 +05304244 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4245 data, dataLen,
4246 wlan_hdd_extscan_config_policy)) {
4247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4248 return -EINVAL;
4249 }
4250
4251 /* Parse and fetch request Id */
4252 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4253 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4254 return -EINVAL;
4255 }
4256 requestId = nla_get_u32(
4257 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4258 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4259
4260 /* Parse and fetch wifi band */
4261 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4262 {
4263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4264 return -EINVAL;
4265 }
4266 wifiBand = nla_get_u32(
4267 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4268 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4269
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304270 /* Parse and fetch max channels */
4271 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4272 {
4273 hddLog(LOGE, FL("attr max channels failed"));
4274 return -EINVAL;
4275 }
4276 maxChannels = nla_get_u32(
4277 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4278 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4279
Dino Mycle6fb96c12014-06-10 11:52:40 +05304280 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
Agrawal Ashish16abf782016-08-18 22:42:59 +05304281 wifiBand, chan_list,
4282 &num_channels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304283 if (eHAL_STATUS_SUCCESS != status) {
4284 hddLog(VOS_TRACE_LEVEL_ERROR,
4285 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4286 return -EINVAL;
4287 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304288
Agrawal Ashish16abf782016-08-18 22:42:59 +05304289 num_channels = VOS_MIN(num_channels, maxChannels);
4290 num_chan_new = num_channels;
4291 /* remove the indoor only channels if iface is SAP */
4292 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
4293 {
4294 num_chan_new = 0;
4295 for (i = 0; i < num_channels; i++)
4296 for (j = 0; j < IEEE80211_NUM_BANDS; j++) {
4297 if (wiphy->bands[j] == NULL)
4298 continue;
4299 for (k = 0; k < wiphy->bands[j]->n_channels; k++) {
4300 if ((chan_list[i] ==
4301 wiphy->bands[j]->channels[k].center_freq) &&
4302 (!(wiphy->bands[j]->channels[k].flags &
4303 IEEE80211_CHAN_INDOOR_ONLY))) {
4304 chan_list[num_chan_new] = chan_list[i];
4305 num_chan_new++;
4306 }
4307 }
4308 }
4309 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304310
Agrawal Ashish16abf782016-08-18 22:42:59 +05304311 hddLog(LOG1, FL("Number of channels: %d"), num_chan_new);
4312 for (i = 0; i < num_chan_new; i++)
4313 len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]);
4314 hddLog(LOG1, "Channels: %s", buf);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304315
4316 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
Agrawal Ashish16abf782016-08-18 22:42:59 +05304317 sizeof(u32) * num_chan_new +
Dino Mycle6fb96c12014-06-10 11:52:40 +05304318 NLMSG_HDRLEN);
4319
4320 if (!replySkb) {
4321 hddLog(VOS_TRACE_LEVEL_ERROR,
4322 FL("valid channels: buffer alloc fail"));
4323 return -EINVAL;
4324 }
4325 if (nla_put_u32(replySkb,
4326 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304327 num_chan_new) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05304328 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
Agrawal Ashish16abf782016-08-18 22:42:59 +05304329 sizeof(u32) * num_chan_new, chan_list)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304330
4331 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4332 kfree_skb(replySkb);
4333 return -EINVAL;
4334 }
4335
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304336 ret = cfg80211_vendor_cmd_reply(replySkb);
4337
4338 EXIT();
4339 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304340}
4341
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304342static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4343 struct wireless_dev *wdev,
4344 const void *data, int dataLen)
4345{
4346 int ret = 0;
4347
4348 vos_ssr_protect(__func__);
4349 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4350 dataLen);
4351 vos_ssr_unprotect(__func__);
4352
4353 return ret;
4354}
4355
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304356static int hdd_extscan_start_fill_bucket_channel_spec(
4357 hdd_context_t *pHddCtx,
4358 tpSirEXTScanStartReqParams pReqMsg,
4359 struct nlattr **tb)
4360{
4361 struct nlattr *bucket[
4362 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4363 struct nlattr *channel[
4364 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4365 struct nlattr *buckets;
4366 struct nlattr *channels;
4367 int rem1, rem2;
4368 eHalStatus status;
4369 tANI_U8 bktIndex, j, numChannels;
4370 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4371 tANI_U32 passive_max_chn_time, active_max_chn_time;
4372
4373 bktIndex = 0;
4374
4375 nla_for_each_nested(buckets,
4376 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4377 if (nla_parse(bucket,
4378 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4379 nla_data(buckets), nla_len(buckets), NULL)) {
4380 hddLog(LOGE, FL("nla_parse failed"));
4381 return -EINVAL;
4382 }
4383
4384 /* Parse and fetch bucket spec */
4385 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4386 hddLog(LOGE, FL("attr bucket index failed"));
4387 return -EINVAL;
4388 }
4389 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4390 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4391 hddLog(LOG1, FL("Bucket spec Index %d"),
4392 pReqMsg->buckets[bktIndex].bucket);
4393
4394 /* Parse and fetch wifi band */
4395 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4396 hddLog(LOGE, FL("attr wifi band failed"));
4397 return -EINVAL;
4398 }
4399 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4400 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4401 hddLog(LOG1, FL("Wifi band %d"),
4402 pReqMsg->buckets[bktIndex].band);
4403
4404 /* Parse and fetch period */
4405 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4406 hddLog(LOGE, FL("attr period failed"));
4407 return -EINVAL;
4408 }
4409 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4410 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4411 hddLog(LOG1, FL("period %d"),
4412 pReqMsg->buckets[bktIndex].period);
4413
4414 /* Parse and fetch report events */
4415 if (!bucket[
4416 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4417 hddLog(LOGE, FL("attr report events failed"));
4418 return -EINVAL;
4419 }
4420 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4421 bucket[
4422 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4423 hddLog(LOG1, FL("report events %d"),
4424 pReqMsg->buckets[bktIndex].reportEvents);
4425
4426 /* Parse and fetch max period */
4427 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4428 hddLog(LOGE, FL("attr max period failed"));
4429 return -EINVAL;
4430 }
4431 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4432 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4433 hddLog(LOG1, FL("max period %u"),
4434 pReqMsg->buckets[bktIndex].max_period);
4435
4436 /* Parse and fetch exponent */
4437 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4438 hddLog(LOGE, FL("attr exponent failed"));
4439 return -EINVAL;
4440 }
4441 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4442 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4443 hddLog(LOG1, FL("exponent %u"),
4444 pReqMsg->buckets[bktIndex].exponent);
4445
4446 /* Parse and fetch step count */
4447 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4448 hddLog(LOGE, FL("attr step count failed"));
4449 return -EINVAL;
4450 }
4451 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4452 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4453 hddLog(LOG1, FL("Step count %u"),
4454 pReqMsg->buckets[bktIndex].step_count);
4455
4456 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4457 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4458
4459 /* Framework shall pass the channel list if the input WiFi band is
4460 * WIFI_BAND_UNSPECIFIED.
4461 * If the input WiFi band is specified (any value other than
4462 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4463 */
4464 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4465 numChannels = 0;
4466 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4467 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4468 pReqMsg->buckets[bktIndex].band,
4469 chanList, &numChannels);
4470 if (!HAL_STATUS_SUCCESS(status)) {
4471 hddLog(LOGE,
4472 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4473 status);
4474 return -EINVAL;
4475 }
4476
4477 pReqMsg->buckets[bktIndex].numChannels =
4478 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4479 hddLog(LOG1, FL("Num channels %d"),
4480 pReqMsg->buckets[bktIndex].numChannels);
4481
4482 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4483 j++) {
4484 pReqMsg->buckets[bktIndex].channels[j].channel =
4485 chanList[j];
4486 pReqMsg->buckets[bktIndex].channels[j].
4487 chnlClass = 0;
4488 if (CSR_IS_CHANNEL_DFS(
4489 vos_freq_to_chan(chanList[j]))) {
4490 pReqMsg->buckets[bktIndex].channels[j].
4491 passive = 1;
4492 pReqMsg->buckets[bktIndex].channels[j].
4493 dwellTimeMs = passive_max_chn_time;
4494 } else {
4495 pReqMsg->buckets[bktIndex].channels[j].
4496 passive = 0;
4497 pReqMsg->buckets[bktIndex].channels[j].
4498 dwellTimeMs = active_max_chn_time;
4499 }
4500
4501 hddLog(LOG1,
4502 "Channel %u Passive %u Dwell time %u ms",
4503 pReqMsg->buckets[bktIndex].channels[j].channel,
4504 pReqMsg->buckets[bktIndex].channels[j].passive,
4505 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4506 }
4507
4508 bktIndex++;
4509 continue;
4510 }
4511
4512 /* Parse and fetch number of channels */
4513 if (!bucket[
4514 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4515 hddLog(LOGE, FL("attr num channels failed"));
4516 return -EINVAL;
4517 }
4518
4519 pReqMsg->buckets[bktIndex].numChannels =
4520 nla_get_u32(bucket[
4521 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4522 hddLog(LOG1, FL("num channels %d"),
4523 pReqMsg->buckets[bktIndex].numChannels);
4524
4525 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4526 hddLog(LOGE, FL("attr channel spec failed"));
4527 return -EINVAL;
4528 }
4529
4530 j = 0;
4531 nla_for_each_nested(channels,
4532 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4533 if (nla_parse(channel,
4534 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4535 nla_data(channels), nla_len(channels),
4536 wlan_hdd_extscan_config_policy)) {
4537 hddLog(LOGE, FL("nla_parse failed"));
4538 return -EINVAL;
4539 }
4540
4541 /* Parse and fetch channel */
4542 if (!channel[
4543 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4544 hddLog(LOGE, FL("attr channel failed"));
4545 return -EINVAL;
4546 }
4547 pReqMsg->buckets[bktIndex].channels[j].channel =
4548 nla_get_u32(channel[
4549 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4550 hddLog(LOG1, FL("channel %u"),
4551 pReqMsg->buckets[bktIndex].channels[j].channel);
4552
4553 /* Parse and fetch dwell time */
4554 if (!channel[
4555 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4556 hddLog(LOGE, FL("attr dwelltime failed"));
4557 return -EINVAL;
4558 }
4559 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4560 nla_get_u32(channel[
4561 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4562
4563 hddLog(LOG1, FL("Dwell time (%u ms)"),
4564 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4565
4566
4567 /* Parse and fetch channel spec passive */
4568 if (!channel[
4569 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4570 hddLog(LOGE,
4571 FL("attr channel spec passive failed"));
4572 return -EINVAL;
4573 }
4574 pReqMsg->buckets[bktIndex].channels[j].passive =
4575 nla_get_u8(channel[
4576 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4577 hddLog(LOG1, FL("Chnl spec passive %u"),
4578 pReqMsg->buckets[bktIndex].channels[j].passive);
4579
4580 j++;
4581 }
4582
4583 bktIndex++;
4584 }
4585
4586 return 0;
4587}
4588
4589
4590/*
4591 * define short names for the global vendor params
4592 * used by wlan_hdd_cfg80211_extscan_start()
4593 */
4594#define PARAM_MAX \
4595QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4596#define PARAM_REQUEST_ID \
4597QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4598#define PARAM_BASE_PERIOD \
4599QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4600#define PARAM_MAX_AP_PER_SCAN \
4601QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4602#define PARAM_RPT_THRHLD_PERCENT \
4603QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4604#define PARAM_RPT_THRHLD_NUM_SCANS \
4605QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4606#define PARAM_NUM_BUCKETS \
4607QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4608
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304609static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304610 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304611 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304612{
Dino Myclee8843b32014-07-04 14:21:45 +05304613 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304614 struct net_device *dev = wdev->netdev;
4615 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4616 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4617 struct nlattr *tb[PARAM_MAX + 1];
4618 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304619 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304620 tANI_U32 request_id;
4621 struct hdd_ext_scan_context *context;
4622 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304623
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304624 ENTER();
4625
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304626 if (VOS_FTM_MODE == hdd_get_conparam()) {
4627 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4628 return -EINVAL;
4629 }
4630
Dino Mycle6fb96c12014-06-10 11:52:40 +05304631 status = wlan_hdd_validate_context(pHddCtx);
4632 if (0 != status)
4633 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304634 return -EINVAL;
4635 }
Dino Myclee8843b32014-07-04 14:21:45 +05304636 /* check the EXTScan Capability */
4637 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304638 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4639 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304640 {
4641 hddLog(VOS_TRACE_LEVEL_ERROR,
4642 FL("EXTScan not enabled/supported by Firmware"));
4643 return -EINVAL;
4644 }
4645
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304646 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304647 data, dataLen,
4648 wlan_hdd_extscan_config_policy)) {
4649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4650 return -EINVAL;
4651 }
4652
4653 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304654 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304655 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4656 return -EINVAL;
4657 }
4658
Dino Myclee8843b32014-07-04 14:21:45 +05304659 pReqMsg = (tpSirEXTScanStartReqParams)
4660 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304661 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304662 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4663 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304664 }
4665
4666 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304667 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304668 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4669
4670 pReqMsg->sessionId = pAdapter->sessionId;
4671 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4672
4673 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304674 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4676 goto fail;
4677 }
4678 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304679 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304680 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4681 pReqMsg->basePeriod);
4682
4683 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304684 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4686 goto fail;
4687 }
4688 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304689 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304690 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4691 pReqMsg->maxAPperScan);
4692
4693 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304694 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4696 goto fail;
4697 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304698 pReqMsg->reportThresholdPercent = nla_get_u8(
4699 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304700 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304701 pReqMsg->reportThresholdPercent);
4702
4703 /* Parse and fetch report threshold num scans */
4704 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4705 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4706 goto fail;
4707 }
4708 pReqMsg->reportThresholdNumScans = nla_get_u8(
4709 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4710 hddLog(LOG1, FL("Report Threshold num scans %d"),
4711 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304712
4713 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304714 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4716 goto fail;
4717 }
4718 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304719 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304720 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4721 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4722 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4723 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4724 }
4725 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4726 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304727
Dino Mycle6fb96c12014-06-10 11:52:40 +05304728 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4729 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4730 goto fail;
4731 }
4732
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304733 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304734
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304735 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4736 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304737
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304738 context = &pHddCtx->ext_scan_context;
4739 spin_lock(&hdd_context_lock);
4740 INIT_COMPLETION(context->response_event);
4741 context->request_id = request_id = pReqMsg->requestId;
4742 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304743
Dino Mycle6fb96c12014-06-10 11:52:40 +05304744 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4745 if (!HAL_STATUS_SUCCESS(status)) {
4746 hddLog(VOS_TRACE_LEVEL_ERROR,
4747 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304748 goto fail;
4749 }
4750
Srinivas Dasari91727c12016-03-23 17:59:06 +05304751 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
4752
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304753 /* request was sent -- wait for the response */
4754 rc = wait_for_completion_timeout(&context->response_event,
4755 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4756
4757 if (!rc) {
4758 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4759 retval = -ETIMEDOUT;
4760 } else {
4761 spin_lock(&hdd_context_lock);
4762 if (context->request_id == request_id)
4763 retval = context->response_status;
4764 else
4765 retval = -EINVAL;
4766 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304767 }
4768
Dino Myclee8843b32014-07-04 14:21:45 +05304769 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304770 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304771 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304772
4773fail:
4774 vos_mem_free(pReqMsg);
4775 return -EINVAL;
4776}
4777
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304778/*
4779 * done with short names for the global vendor params
4780 * used by wlan_hdd_cfg80211_extscan_start()
4781 */
4782#undef PARAM_MAX
4783#undef PARAM_REQUEST_ID
4784#undef PARAM_BASE_PERIOD
4785#undef PARAMS_MAX_AP_PER_SCAN
4786#undef PARAMS_RPT_THRHLD_PERCENT
4787#undef PARAMS_RPT_THRHLD_NUM_SCANS
4788#undef PARAMS_NUM_BUCKETS
4789
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304790static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4791 struct wireless_dev *wdev,
4792 const void *data, int dataLen)
4793{
4794 int ret = 0;
4795
4796 vos_ssr_protect(__func__);
4797 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4798 vos_ssr_unprotect(__func__);
4799
4800 return ret;
4801}
4802
4803static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304804 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304805 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304806{
Dino Myclee8843b32014-07-04 14:21:45 +05304807 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304808 struct net_device *dev = wdev->netdev;
4809 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4810 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4811 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4812 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304813 int retval;
4814 unsigned long rc;
4815 struct hdd_ext_scan_context *context;
4816 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304817
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304818 ENTER();
4819
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304820 if (VOS_FTM_MODE == hdd_get_conparam()) {
4821 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4822 return -EINVAL;
4823 }
4824
Dino Mycle6fb96c12014-06-10 11:52:40 +05304825 status = wlan_hdd_validate_context(pHddCtx);
4826 if (0 != status)
4827 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304828 return -EINVAL;
4829 }
Dino Myclee8843b32014-07-04 14:21:45 +05304830 /* check the EXTScan Capability */
4831 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304832 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4833 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304834 {
4835 hddLog(VOS_TRACE_LEVEL_ERROR,
4836 FL("EXTScan not enabled/supported by Firmware"));
4837 return -EINVAL;
4838 }
4839
Dino Mycle6fb96c12014-06-10 11:52:40 +05304840 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4841 data, dataLen,
4842 wlan_hdd_extscan_config_policy)) {
4843 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4844 return -EINVAL;
4845 }
4846
4847 /* Parse and fetch request Id */
4848 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4849 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4850 return -EINVAL;
4851 }
4852
Dino Myclee8843b32014-07-04 14:21:45 +05304853 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304854 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304855 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304856
Dino Myclee8843b32014-07-04 14:21:45 +05304857 reqMsg.sessionId = pAdapter->sessionId;
4858 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304859
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304860 context = &pHddCtx->ext_scan_context;
4861 spin_lock(&hdd_context_lock);
4862 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05304863 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304864 spin_unlock(&hdd_context_lock);
4865
Dino Myclee8843b32014-07-04 14:21:45 +05304866 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304867 if (!HAL_STATUS_SUCCESS(status)) {
4868 hddLog(VOS_TRACE_LEVEL_ERROR,
4869 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304870 return -EINVAL;
4871 }
4872
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304873 /* request was sent -- wait for the response */
4874 rc = wait_for_completion_timeout(&context->response_event,
4875 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4876
4877 if (!rc) {
4878 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4879 retval = -ETIMEDOUT;
4880 } else {
4881 spin_lock(&hdd_context_lock);
4882 if (context->request_id == request_id)
4883 retval = context->response_status;
4884 else
4885 retval = -EINVAL;
4886 spin_unlock(&hdd_context_lock);
4887 }
4888
4889 return retval;
4890
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304891 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304892 return 0;
4893}
4894
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304895static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4896 struct wireless_dev *wdev,
4897 const void *data, int dataLen)
4898{
4899 int ret = 0;
4900
4901 vos_ssr_protect(__func__);
4902 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4903 vos_ssr_unprotect(__func__);
4904
4905 return ret;
4906}
4907
4908static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304909 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304910 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304911{
Dino Myclee8843b32014-07-04 14:21:45 +05304912 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304913 struct net_device *dev = wdev->netdev;
4914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4915 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4916 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4917 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304918 struct hdd_ext_scan_context *context;
4919 tANI_U32 request_id;
4920 unsigned long rc;
4921 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304922
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304923 ENTER();
4924
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304925 if (VOS_FTM_MODE == hdd_get_conparam()) {
4926 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4927 return -EINVAL;
4928 }
4929
Dino Mycle6fb96c12014-06-10 11:52:40 +05304930 status = wlan_hdd_validate_context(pHddCtx);
4931 if (0 != status)
4932 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304933 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304934 return -EINVAL;
4935 }
Dino Myclee8843b32014-07-04 14:21:45 +05304936 /* check the EXTScan Capability */
4937 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304938 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4939 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304940 {
4941 hddLog(VOS_TRACE_LEVEL_ERROR,
4942 FL("EXTScan not enabled/supported by Firmware"));
4943 return -EINVAL;
4944 }
4945
Dino Mycle6fb96c12014-06-10 11:52:40 +05304946 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4947 data, dataLen,
4948 wlan_hdd_extscan_config_policy)) {
4949 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4950 return -EINVAL;
4951 }
4952
4953 /* Parse and fetch request Id */
4954 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4955 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4956 return -EINVAL;
4957 }
4958
Dino Myclee8843b32014-07-04 14:21:45 +05304959 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304960 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304961 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304962
Dino Myclee8843b32014-07-04 14:21:45 +05304963 reqMsg.sessionId = pAdapter->sessionId;
4964 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304965
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304966 context = &pHddCtx->ext_scan_context;
4967 spin_lock(&hdd_context_lock);
4968 INIT_COMPLETION(context->response_event);
4969 context->request_id = request_id = reqMsg.requestId;
4970 spin_unlock(&hdd_context_lock);
4971
Dino Myclee8843b32014-07-04 14:21:45 +05304972 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304973 if (!HAL_STATUS_SUCCESS(status)) {
4974 hddLog(VOS_TRACE_LEVEL_ERROR,
4975 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304976 return -EINVAL;
4977 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304978
4979 /* request was sent -- wait for the response */
4980 rc = wait_for_completion_timeout(&context->response_event,
4981 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4982 if (!rc) {
4983 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4984 retval = -ETIMEDOUT;
4985 } else {
4986 spin_lock(&hdd_context_lock);
4987 if (context->request_id == request_id)
4988 retval = context->response_status;
4989 else
4990 retval = -EINVAL;
4991 spin_unlock(&hdd_context_lock);
4992 }
4993
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304994 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304995 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304996}
4997
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304998static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4999 struct wireless_dev *wdev,
5000 const void *data, int dataLen)
5001{
5002 int ret = 0;
5003
5004 vos_ssr_protect(__func__);
5005 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
5006 vos_ssr_unprotect(__func__);
5007
5008 return ret;
5009}
Dino Mycle6fb96c12014-06-10 11:52:40 +05305010#endif /* WLAN_FEATURE_EXTSCAN */
5011
Atul Mittal115287b2014-07-08 13:26:33 +05305012/*EXT TDLS*/
5013static const struct nla_policy
5014wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
5015{
5016 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
5017 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
5018 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
5019 {.type = NLA_S32 },
5020 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
5021 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
5022
5023};
5024
5025static const struct nla_policy
5026wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
5027{
5028 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
5029
5030};
5031
5032static const struct nla_policy
5033wlan_hdd_tdls_config_state_change_policy[
5034 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5035{
5036 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
5037 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5038 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305039 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5040 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5041 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305042
5043};
5044
5045static const struct nla_policy
5046wlan_hdd_tdls_config_get_status_policy[
5047 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5048{
5049 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
5050 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5051 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305052 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5053 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5054 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305055
5056};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305057
5058static const struct nla_policy
5059wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5060{
5061 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
5062};
5063
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305064static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305065 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305066 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305067 int data_len)
5068{
5069
5070 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5071 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5072
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305073 ENTER();
5074
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305075 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305076 return -EINVAL;
5077 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305078 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305079 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305080 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305081 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305082 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305083 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305084 return -ENOTSUPP;
5085 }
5086
5087 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5088 data, data_len, wlan_hdd_mac_config)) {
5089 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5090 return -EINVAL;
5091 }
5092
5093 /* Parse and fetch mac address */
5094 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5095 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5096 return -EINVAL;
5097 }
5098
5099 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5100 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5101 VOS_MAC_ADDR_LAST_3_BYTES);
5102
Siddharth Bhal76972212014-10-15 16:22:51 +05305103 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5104
5105 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305106 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5107 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305108 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5109 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5110 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5111 {
5112 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5113 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5114 VOS_MAC_ADDRESS_LEN);
5115 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305116 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305117
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305118 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5119 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305120
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305121 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305122 return 0;
5123}
5124
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305125static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5126 struct wireless_dev *wdev,
5127 const void *data,
5128 int data_len)
5129{
5130 int ret = 0;
5131
5132 vos_ssr_protect(__func__);
5133 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5134 vos_ssr_unprotect(__func__);
5135
5136 return ret;
5137}
5138
5139static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305140 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305141 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305142 int data_len)
5143{
5144 u8 peer[6] = {0};
5145 struct net_device *dev = wdev->netdev;
5146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5147 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5148 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5149 eHalStatus ret;
5150 tANI_S32 state;
5151 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305152 tANI_S32 global_operating_class = 0;
5153 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305154 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305155 int retVal;
5156
5157 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305158
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305159 if (!pAdapter) {
5160 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5161 return -EINVAL;
5162 }
5163
Atul Mittal115287b2014-07-08 13:26:33 +05305164 ret = wlan_hdd_validate_context(pHddCtx);
5165 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305167 return -EINVAL;
5168 }
5169 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305170 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305171 return -ENOTSUPP;
5172 }
5173 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5174 data, data_len,
5175 wlan_hdd_tdls_config_get_status_policy)) {
5176 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5177 return -EINVAL;
5178 }
5179
5180 /* Parse and fetch mac address */
5181 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5182 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5183 return -EINVAL;
5184 }
5185
5186 memcpy(peer, nla_data(
5187 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5188 sizeof(peer));
5189 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5190
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305191 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305192
Atul Mittal115287b2014-07-08 13:26:33 +05305193 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305194 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305195 NLMSG_HDRLEN);
5196
5197 if (!skb) {
5198 hddLog(VOS_TRACE_LEVEL_ERROR,
5199 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5200 return -EINVAL;
5201 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305202 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 +05305203 reason,
5204 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305205 global_operating_class,
5206 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305207 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305208 if (nla_put_s32(skb,
5209 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5210 state) ||
5211 nla_put_s32(skb,
5212 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5213 reason) ||
5214 nla_put_s32(skb,
5215 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5216 global_operating_class) ||
5217 nla_put_s32(skb,
5218 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5219 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305220
5221 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5222 goto nla_put_failure;
5223 }
5224
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305225 retVal = cfg80211_vendor_cmd_reply(skb);
5226 EXIT();
5227 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305228
5229nla_put_failure:
5230 kfree_skb(skb);
5231 return -EINVAL;
5232}
5233
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305234static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5235 struct wireless_dev *wdev,
5236 const void *data,
5237 int data_len)
5238{
5239 int ret = 0;
5240
5241 vos_ssr_protect(__func__);
5242 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5243 vos_ssr_unprotect(__func__);
5244
5245 return ret;
5246}
5247
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305248static int wlan_hdd_cfg80211_exttdls_callback(
5249#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5250 const tANI_U8* mac,
5251#else
5252 tANI_U8* mac,
5253#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305254 tANI_S32 state,
5255 tANI_S32 reason,
5256 void *ctx)
5257{
5258 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305259 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305260 tANI_S32 global_operating_class = 0;
5261 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305262 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305263
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305264 ENTER();
5265
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305266 if (!pAdapter) {
5267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5268 return -EINVAL;
5269 }
5270
5271 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305272 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305273 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305274 return -EINVAL;
5275 }
5276
5277 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305278 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305279 return -ENOTSUPP;
5280 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305281 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5283 NULL,
5284#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305285 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5286 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5287 GFP_KERNEL);
5288
5289 if (!skb) {
5290 hddLog(VOS_TRACE_LEVEL_ERROR,
5291 FL("cfg80211_vendor_event_alloc failed"));
5292 return -EINVAL;
5293 }
5294 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305295 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5296 reason,
5297 state,
5298 global_operating_class,
5299 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305300 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5301 MAC_ADDR_ARRAY(mac));
5302
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305303 if (nla_put(skb,
5304 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5305 VOS_MAC_ADDR_SIZE, mac) ||
5306 nla_put_s32(skb,
5307 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5308 state) ||
5309 nla_put_s32(skb,
5310 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5311 reason) ||
5312 nla_put_s32(skb,
5313 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5314 channel) ||
5315 nla_put_s32(skb,
5316 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5317 global_operating_class)
5318 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5320 goto nla_put_failure;
5321 }
5322
5323 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305324 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305325 return (0);
5326
5327nla_put_failure:
5328 kfree_skb(skb);
5329 return -EINVAL;
5330}
5331
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305332static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305333 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305334 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305335 int data_len)
5336{
5337 u8 peer[6] = {0};
5338 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305339 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5340 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5341 eHalStatus status;
5342 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305343 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305344 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305345
5346 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305347
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305348 if (!dev) {
5349 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5350 return -EINVAL;
5351 }
5352
5353 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5354 if (!pAdapter) {
5355 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5356 return -EINVAL;
5357 }
5358
Atul Mittal115287b2014-07-08 13:26:33 +05305359 status = wlan_hdd_validate_context(pHddCtx);
5360 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305361 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305362 return -EINVAL;
5363 }
5364 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305365 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305366 return -ENOTSUPP;
5367 }
5368 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5369 data, data_len,
5370 wlan_hdd_tdls_config_enable_policy)) {
5371 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5372 return -EINVAL;
5373 }
5374
5375 /* Parse and fetch mac address */
5376 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5378 return -EINVAL;
5379 }
5380
5381 memcpy(peer, nla_data(
5382 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5383 sizeof(peer));
5384 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5385
5386 /* Parse and fetch channel */
5387 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5388 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5389 return -EINVAL;
5390 }
5391 pReqMsg.channel = nla_get_s32(
5392 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5393 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5394
5395 /* Parse and fetch global operating class */
5396 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5398 return -EINVAL;
5399 }
5400 pReqMsg.global_operating_class = nla_get_s32(
5401 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5402 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5403 pReqMsg.global_operating_class);
5404
5405 /* Parse and fetch latency ms */
5406 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5408 return -EINVAL;
5409 }
5410 pReqMsg.max_latency_ms = nla_get_s32(
5411 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5412 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5413 pReqMsg.max_latency_ms);
5414
5415 /* Parse and fetch required bandwidth kbps */
5416 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5417 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5418 return -EINVAL;
5419 }
5420
5421 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5422 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5423 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5424 pReqMsg.min_bandwidth_kbps);
5425
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305426 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305427 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305428 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305429 wlan_hdd_cfg80211_exttdls_callback);
5430
5431 EXIT();
5432 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305433}
5434
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305435static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5436 struct wireless_dev *wdev,
5437 const void *data,
5438 int data_len)
5439{
5440 int ret = 0;
5441
5442 vos_ssr_protect(__func__);
5443 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5444 vos_ssr_unprotect(__func__);
5445
5446 return ret;
5447}
5448
5449static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305450 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305451 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305452 int data_len)
5453{
5454 u8 peer[6] = {0};
5455 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305456 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5457 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5458 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305459 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305460 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305461
5462 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305463
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305464 if (!dev) {
5465 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5466 return -EINVAL;
5467 }
5468
5469 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5470 if (!pAdapter) {
5471 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5472 return -EINVAL;
5473 }
5474
Atul Mittal115287b2014-07-08 13:26:33 +05305475 status = wlan_hdd_validate_context(pHddCtx);
5476 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305477 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305478 return -EINVAL;
5479 }
5480 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305482 return -ENOTSUPP;
5483 }
5484 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5485 data, data_len,
5486 wlan_hdd_tdls_config_disable_policy)) {
5487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5488 return -EINVAL;
5489 }
5490 /* Parse and fetch mac address */
5491 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5493 return -EINVAL;
5494 }
5495
5496 memcpy(peer, nla_data(
5497 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5498 sizeof(peer));
5499 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5500
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305501 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5502
5503 EXIT();
5504 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305505}
5506
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305507static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5508 struct wireless_dev *wdev,
5509 const void *data,
5510 int data_len)
5511{
5512 int ret = 0;
5513
5514 vos_ssr_protect(__func__);
5515 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5516 vos_ssr_unprotect(__func__);
5517
5518 return ret;
5519}
5520
Dasari Srinivas7875a302014-09-26 17:50:57 +05305521static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305522__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305523 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305524 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305525{
5526 struct net_device *dev = wdev->netdev;
5527 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5528 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5529 struct sk_buff *skb = NULL;
5530 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305531 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305533 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305534
5535 ret = wlan_hdd_validate_context(pHddCtx);
5536 if (0 != ret)
5537 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305538 return ret;
5539 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305540 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5541 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5542 fset |= WIFI_FEATURE_INFRA;
5543 }
5544
5545 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5546 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5547 fset |= WIFI_FEATURE_INFRA_5G;
5548 }
5549
5550#ifdef WLAN_FEATURE_P2P
5551 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5552 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5553 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5554 fset |= WIFI_FEATURE_P2P;
5555 }
5556#endif
5557
5558 /* Soft-AP is supported currently by default */
5559 fset |= WIFI_FEATURE_SOFT_AP;
5560
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305561 /* HOTSPOT is a supplicant feature, enable it by default */
5562 fset |= WIFI_FEATURE_HOTSPOT;
5563
Dasari Srinivas7875a302014-09-26 17:50:57 +05305564#ifdef WLAN_FEATURE_EXTSCAN
5565 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305566 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5567 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5568 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305569 fset |= WIFI_FEATURE_EXTSCAN;
5570 }
5571#endif
5572
Dasari Srinivas7875a302014-09-26 17:50:57 +05305573 if (sme_IsFeatureSupportedByFW(NAN)) {
5574 hddLog(LOG1, FL("NAN is supported by firmware"));
5575 fset |= WIFI_FEATURE_NAN;
5576 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305577
5578 /* D2D RTT is not supported currently by default */
5579 if (sme_IsFeatureSupportedByFW(RTT)) {
5580 hddLog(LOG1, FL("RTT is supported by firmware"));
5581 fset |= WIFI_FEATURE_D2AP_RTT;
5582 }
5583
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305584 if (sme_IsFeatureSupportedByFW(RTT3)) {
5585 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5586 fset |= WIFI_FEATURE_RTT3;
5587 }
5588
Dasari Srinivas7875a302014-09-26 17:50:57 +05305589#ifdef FEATURE_WLAN_BATCH_SCAN
5590 if (fset & WIFI_FEATURE_EXTSCAN) {
5591 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5592 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5593 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5594 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5595 fset |= WIFI_FEATURE_BATCH_SCAN;
5596 }
5597#endif
5598
5599#ifdef FEATURE_WLAN_SCAN_PNO
5600 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5601 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5602 hddLog(LOG1, FL("PNO is supported by firmware"));
5603 fset |= WIFI_FEATURE_PNO;
5604 }
5605#endif
5606
5607 /* STA+STA is supported currently by default */
5608 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5609
5610#ifdef FEATURE_WLAN_TDLS
5611 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5612 sme_IsFeatureSupportedByFW(TDLS)) {
5613 hddLog(LOG1, FL("TDLS is supported by firmware"));
5614 fset |= WIFI_FEATURE_TDLS;
5615 }
5616
5617 /* TDLS_OFFCHANNEL is not supported currently by default */
5618#endif
5619
5620#ifdef WLAN_AP_STA_CONCURRENCY
5621 /* AP+STA concurrency is supported currently by default */
5622 fset |= WIFI_FEATURE_AP_STA;
5623#endif
5624
Mukul Sharma5add0532015-08-17 15:57:47 +05305625#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5626 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5627 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5628#endif
5629
Dasari Srinivas7875a302014-09-26 17:50:57 +05305630 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5631 NLMSG_HDRLEN);
5632
5633 if (!skb) {
5634 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5635 return -EINVAL;
5636 }
5637 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5638
5639 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5640 hddLog(LOGE, FL("nla put fail"));
5641 goto nla_put_failure;
5642 }
5643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305644 ret = cfg80211_vendor_cmd_reply(skb);
5645 EXIT();
5646 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305647
5648nla_put_failure:
5649 kfree_skb(skb);
5650 return -EINVAL;
5651}
5652
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305653static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305654wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5655 struct wireless_dev *wdev,
5656 const void *data, int data_len)
5657{
5658 int ret = 0;
5659
5660 vos_ssr_protect(__func__);
5661 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5662 vos_ssr_unprotect(__func__);
5663
5664 return ret;
5665}
5666
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305667
5668static const struct
5669nla_policy
5670qca_wlan_vendor_wifi_logger_get_ring_data_policy
5671[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5672 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5673 = {.type = NLA_U32 },
5674};
5675
5676static int
5677 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5678 struct wireless_dev *wdev,
5679 const void *data,
5680 int data_len)
5681{
5682 int ret;
5683 VOS_STATUS status;
5684 uint32_t ring_id;
5685 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5686 struct nlattr *tb
5687 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5688
5689 ENTER();
5690
5691 ret = wlan_hdd_validate_context(hdd_ctx);
5692 if (0 != ret) {
5693 return ret;
5694 }
5695
5696 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5697 data, data_len,
5698 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5699 hddLog(LOGE, FL("Invalid attribute"));
5700 return -EINVAL;
5701 }
5702
5703 /* Parse and fetch ring id */
5704 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5705 hddLog(LOGE, FL("attr ATTR failed"));
5706 return -EINVAL;
5707 }
5708
5709 ring_id = nla_get_u32(
5710 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5711
5712 hddLog(LOG1, FL("Bug report triggered by framework"));
5713
5714 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5715 WLAN_LOG_INDICATOR_FRAMEWORK,
5716 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305717 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305718 );
5719 if (VOS_STATUS_SUCCESS != status) {
5720 hddLog(LOGE, FL("Failed to trigger bug report"));
5721
5722 return -EINVAL;
5723 }
5724
5725 return 0;
5726
5727
5728}
5729
5730
5731static int
5732 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5733 struct wireless_dev *wdev,
5734 const void *data,
5735 int data_len)
5736{
5737 int ret = 0;
5738
5739 vos_ssr_protect(__func__);
5740 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5741 wdev, data, data_len);
5742 vos_ssr_unprotect(__func__);
5743
5744 return ret;
5745
5746}
5747
5748
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305749static int
5750__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305751 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305752 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305753{
5754 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5755 uint8_t i, feature_sets, max_feature_sets;
5756 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5757 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305758 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5759 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305760
5761 ENTER();
5762
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305763 ret = wlan_hdd_validate_context(pHddCtx);
5764 if (0 != ret)
5765 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305766 return ret;
5767 }
5768
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305769 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5770 data, data_len, NULL)) {
5771 hddLog(LOGE, FL("Invalid ATTR"));
5772 return -EINVAL;
5773 }
5774
5775 /* Parse and fetch max feature set */
5776 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5777 hddLog(LOGE, FL("Attr max feature set size failed"));
5778 return -EINVAL;
5779 }
5780 max_feature_sets = nla_get_u32(
5781 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5782 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5783
5784 /* Fill feature combination matrix */
5785 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305786 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5787 WIFI_FEATURE_P2P;
5788
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305789 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5790 WIFI_FEATURE_SOFT_AP;
5791
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305792 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5793 WIFI_FEATURE_SOFT_AP;
5794
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305795 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5796 WIFI_FEATURE_SOFT_AP |
5797 WIFI_FEATURE_P2P;
5798
5799 /* Add more feature combinations here */
5800
5801 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5802 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5803 hddLog(LOG1, "Feature set matrix");
5804 for (i = 0; i < feature_sets; i++)
5805 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5806
5807 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5808 sizeof(u32) * feature_sets +
5809 NLMSG_HDRLEN);
5810
5811 if (reply_skb) {
5812 if (nla_put_u32(reply_skb,
5813 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5814 feature_sets) ||
5815 nla_put(reply_skb,
5816 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5817 sizeof(u32) * feature_sets, feature_set_matrix)) {
5818 hddLog(LOGE, FL("nla put fail"));
5819 kfree_skb(reply_skb);
5820 return -EINVAL;
5821 }
5822
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305823 ret = cfg80211_vendor_cmd_reply(reply_skb);
5824 EXIT();
5825 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305826 }
5827 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5828 return -ENOMEM;
5829
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305830}
5831
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305832static int
5833wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5834 struct wireless_dev *wdev,
5835 const void *data, int data_len)
5836{
5837 int ret = 0;
5838
5839 vos_ssr_protect(__func__);
5840 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5841 data_len);
5842 vos_ssr_unprotect(__func__);
5843
5844 return ret;
5845}
5846
c_manjeecfd1efb2015-09-25 19:32:34 +05305847
5848static int
5849__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5850 struct wireless_dev *wdev,
5851 const void *data, int data_len)
5852{
5853 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5854 int ret;
5855 ENTER();
5856
5857 ret = wlan_hdd_validate_context(pHddCtx);
5858 if (0 != ret)
5859 {
5860 return ret;
5861 }
5862
5863 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5864 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5865 {
5866 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5867 return -EINVAL;
5868 }
5869 /*call common API for FW mem dump req*/
5870 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5871
Abhishek Singhc783fa72015-12-09 18:07:34 +05305872 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305873 {
5874 /*indicate to userspace the status of fw mem dump */
5875 wlan_indicate_mem_dump_complete(true);
5876 }
5877 else
5878 {
5879 /*else send failure to userspace */
5880 wlan_indicate_mem_dump_complete(false);
5881 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305882 EXIT();
5883 return ret;
5884}
5885
5886/**
5887 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5888 * @wiphy: pointer to wireless wiphy structure.
5889 * @wdev: pointer to wireless_dev structure.
5890 * @data: Pointer to the NL data.
5891 * @data_len:Length of @data
5892 *
5893 * This is called when wlan driver needs to get the firmware memory dump
5894 * via vendor specific command.
5895 *
5896 * Return: 0 on success, error number otherwise.
5897 */
5898
5899static int
5900wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5901 struct wireless_dev *wdev,
5902 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305903{
5904 int ret = 0;
5905 vos_ssr_protect(__func__);
5906 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5907 data_len);
5908 vos_ssr_unprotect(__func__);
5909 return ret;
5910}
c_manjeecfd1efb2015-09-25 19:32:34 +05305911
Sushant Kaushik8e644982015-09-23 12:18:54 +05305912static const struct
5913nla_policy
5914qca_wlan_vendor_wifi_logger_start_policy
5915[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5916 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5917 = {.type = NLA_U32 },
5918 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5919 = {.type = NLA_U32 },
5920 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5921 = {.type = NLA_U32 },
5922};
5923
5924/**
5925 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5926 * or disable the collection of packet statistics from the firmware
5927 * @wiphy: WIPHY structure pointer
5928 * @wdev: Wireless device structure pointer
5929 * @data: Pointer to the data received
5930 * @data_len: Length of the data received
5931 *
5932 * This function is used to enable or disable the collection of packet
5933 * statistics from the firmware
5934 *
5935 * Return: 0 on success and errno on failure
5936 */
5937static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5938 struct wireless_dev *wdev,
5939 const void *data,
5940 int data_len)
5941{
5942 eHalStatus status;
5943 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5944 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5945 tAniWifiStartLog start_log;
5946
5947 status = wlan_hdd_validate_context(hdd_ctx);
5948 if (0 != status) {
5949 return -EINVAL;
5950 }
5951
5952 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5953 data, data_len,
5954 qca_wlan_vendor_wifi_logger_start_policy)) {
5955 hddLog(LOGE, FL("Invalid attribute"));
5956 return -EINVAL;
5957 }
5958
5959 /* Parse and fetch ring id */
5960 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5961 hddLog(LOGE, FL("attr ATTR failed"));
5962 return -EINVAL;
5963 }
5964 start_log.ringId = nla_get_u32(
5965 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5966 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5967
5968 /* Parse and fetch verbose level */
5969 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5970 hddLog(LOGE, FL("attr verbose_level failed"));
5971 return -EINVAL;
5972 }
5973 start_log.verboseLevel = nla_get_u32(
5974 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5975 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5976
5977 /* Parse and fetch flag */
5978 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5979 hddLog(LOGE, FL("attr flag failed"));
5980 return -EINVAL;
5981 }
5982 start_log.flag = nla_get_u32(
5983 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5984 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5985
5986 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305987 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5988 !vos_isPktStatsEnabled()))
5989
Sushant Kaushik8e644982015-09-23 12:18:54 +05305990 {
5991 hddLog(LOGE, FL("per pkt stats not enabled"));
5992 return -EINVAL;
5993 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305994
Sushant Kaushik33200572015-08-05 16:46:20 +05305995 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305996 return 0;
5997}
5998
5999/**
6000 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
6001 * or disable the collection of packet statistics from the firmware
6002 * @wiphy: WIPHY structure pointer
6003 * @wdev: Wireless device structure pointer
6004 * @data: Pointer to the data received
6005 * @data_len: Length of the data received
6006 *
6007 * This function is used to enable or disable the collection of packet
6008 * statistics from the firmware
6009 *
6010 * Return: 0 on success and errno on failure
6011 */
6012static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
6013 struct wireless_dev *wdev,
6014 const void *data,
6015 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05306016{
6017 int ret = 0;
6018
6019 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05306020
6021 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
6022 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05306023 vos_ssr_unprotect(__func__);
6024
6025 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05306026}
6027
6028
Agarwal Ashish738843c2014-09-25 12:27:56 +05306029static const struct nla_policy
6030wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
6031 +1] =
6032{
6033 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
6034};
6035
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306036static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306037 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306038 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306039 int data_len)
6040{
6041 struct net_device *dev = wdev->netdev;
6042 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6043 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6044 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6045 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6046 eHalStatus status;
6047 u32 dfsFlag = 0;
6048
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306049 ENTER();
6050
Agarwal Ashish738843c2014-09-25 12:27:56 +05306051 status = wlan_hdd_validate_context(pHddCtx);
6052 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306053 return -EINVAL;
6054 }
6055 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6056 data, data_len,
6057 wlan_hdd_set_no_dfs_flag_config_policy)) {
6058 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6059 return -EINVAL;
6060 }
6061
6062 /* Parse and fetch required bandwidth kbps */
6063 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6064 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6065 return -EINVAL;
6066 }
6067
6068 dfsFlag = nla_get_u32(
6069 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6070 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6071 dfsFlag);
6072
6073 pHddCtx->disable_dfs_flag = dfsFlag;
6074
6075 sme_disable_dfs_channel(hHal, dfsFlag);
6076 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306077
6078 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306079 return 0;
6080}
Atul Mittal115287b2014-07-08 13:26:33 +05306081
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306082static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6083 struct wireless_dev *wdev,
6084 const void *data,
6085 int data_len)
6086{
6087 int ret = 0;
6088
6089 vos_ssr_protect(__func__);
6090 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6091 vos_ssr_unprotect(__func__);
6092
6093 return ret;
6094
6095}
6096
Mukul Sharma2a271632014-10-13 14:59:01 +05306097const struct
6098nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6099{
6100 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6101 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6102};
6103
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306104static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306105 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306106{
6107
6108 u8 bssid[6] = {0};
6109 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6110 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6111 eHalStatus status = eHAL_STATUS_SUCCESS;
6112 v_U32_t isFwrRoamEnabled = FALSE;
6113 int ret;
6114
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306115 ENTER();
6116
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306117 ret = wlan_hdd_validate_context(pHddCtx);
6118 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306119 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306120 }
6121
6122 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6123 data, data_len,
6124 qca_wlan_vendor_attr);
6125 if (ret){
6126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6127 return -EINVAL;
6128 }
6129
6130 /* Parse and fetch Enable flag */
6131 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6133 return -EINVAL;
6134 }
6135
6136 isFwrRoamEnabled = nla_get_u32(
6137 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6138
6139 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6140
6141 /* Parse and fetch bssid */
6142 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6144 return -EINVAL;
6145 }
6146
6147 memcpy(bssid, nla_data(
6148 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6149 sizeof(bssid));
6150 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6151
6152 //Update roaming
6153 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306154 if (!HAL_STATUS_SUCCESS(status)) {
6155 hddLog(LOGE,
6156 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6157 return -EINVAL;
6158 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306159 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306160 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306161}
6162
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306163static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6164 struct wireless_dev *wdev, const void *data, int data_len)
6165{
6166 int ret = 0;
6167
6168 vos_ssr_protect(__func__);
6169 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6170 vos_ssr_unprotect(__func__);
6171
6172 return ret;
6173}
6174
Sushant Kaushik847890c2015-09-28 16:05:17 +05306175static const struct
6176nla_policy
6177qca_wlan_vendor_get_wifi_info_policy[
6178 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6179 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6180 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6181};
6182
6183
6184/**
6185 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6186 * @wiphy: pointer to wireless wiphy structure.
6187 * @wdev: pointer to wireless_dev structure.
6188 * @data: Pointer to the data to be passed via vendor interface
6189 * @data_len:Length of the data to be passed
6190 *
6191 * This is called when wlan driver needs to send wifi driver related info
6192 * (driver/fw version) to the user space application upon request.
6193 *
6194 * Return: Return the Success or Failure code.
6195 */
6196static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6197 struct wireless_dev *wdev,
6198 const void *data, int data_len)
6199{
6200 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6201 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6202 tSirVersionString version;
6203 uint32 version_len;
6204 uint8 attr;
6205 int status;
6206 struct sk_buff *reply_skb = NULL;
6207
6208 if (VOS_FTM_MODE == hdd_get_conparam()) {
6209 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6210 return -EINVAL;
6211 }
6212
6213 status = wlan_hdd_validate_context(hdd_ctx);
6214 if (0 != status) {
6215 hddLog(LOGE, FL("HDD context is not valid"));
6216 return -EINVAL;
6217 }
6218
6219 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6220 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6221 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6222 return -EINVAL;
6223 }
6224
6225 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6226 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6227 QWLAN_VERSIONSTR);
6228 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6229 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6230 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6231 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6232 hdd_ctx->fw_Version);
6233 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6234 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6235 } else {
6236 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6237 return -EINVAL;
6238 }
6239
6240 version_len = strlen(version);
6241 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6242 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6243 if (!reply_skb) {
6244 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6245 return -ENOMEM;
6246 }
6247
6248 if (nla_put(reply_skb, attr, version_len, version)) {
6249 hddLog(LOGE, FL("nla put fail"));
6250 kfree_skb(reply_skb);
6251 return -EINVAL;
6252 }
6253
6254 return cfg80211_vendor_cmd_reply(reply_skb);
6255}
6256
6257/**
6258 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6259 * @wiphy: pointer to wireless wiphy structure.
6260 * @wdev: pointer to wireless_dev structure.
6261 * @data: Pointer to the data to be passed via vendor interface
6262 * @data_len:Length of the data to be passed
6263 * @data_len: Length of the data received
6264 *
6265 * This function is used to enable or disable the collection of packet
6266 * statistics from the firmware
6267 *
6268 * Return: 0 on success and errno on failure
6269 */
6270
6271static int
6272wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6273 struct wireless_dev *wdev,
6274 const void *data, int data_len)
6275
6276
6277{
6278 int ret = 0;
6279
6280 vos_ssr_protect(__func__);
6281 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6282 wdev, data, data_len);
6283 vos_ssr_unprotect(__func__);
6284
6285 return ret;
6286}
6287
6288
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306289/*
6290 * define short names for the global vendor params
6291 * used by __wlan_hdd_cfg80211_monitor_rssi()
6292 */
6293#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6294#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6295#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6296#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6297#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6298
6299/**---------------------------------------------------------------------------
6300
6301 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6302 monitor start is completed successfully.
6303
6304 \return - None
6305
6306 --------------------------------------------------------------------------*/
6307void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6308{
6309 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6310
6311 if (NULL == pHddCtx)
6312 {
6313 hddLog(VOS_TRACE_LEVEL_ERROR,
6314 "%s: HDD context is NULL",__func__);
6315 return;
6316 }
6317
6318 if (VOS_STATUS_SUCCESS == status)
6319 {
6320 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6321 }
6322 else
6323 {
6324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6325 }
6326
6327 return;
6328}
6329
6330/**---------------------------------------------------------------------------
6331
6332 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6333 stop is completed successfully.
6334
6335 \return - None
6336
6337 --------------------------------------------------------------------------*/
6338void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6339{
6340 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6341
6342 if (NULL == pHddCtx)
6343 {
6344 hddLog(VOS_TRACE_LEVEL_ERROR,
6345 "%s: HDD context is NULL",__func__);
6346 return;
6347 }
6348
6349 if (VOS_STATUS_SUCCESS == status)
6350 {
6351 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6352 }
6353 else
6354 {
6355 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6356 }
6357
6358 return;
6359}
6360
6361/**
6362 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6363 * @wiphy: Pointer to wireless phy
6364 * @wdev: Pointer to wireless device
6365 * @data: Pointer to data
6366 * @data_len: Data length
6367 *
6368 * Return: 0 on success, negative errno on failure
6369 */
6370
6371static int
6372__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6373 struct wireless_dev *wdev,
6374 const void *data,
6375 int data_len)
6376{
6377 struct net_device *dev = wdev->netdev;
6378 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6379 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6380 hdd_station_ctx_t *pHddStaCtx;
6381 struct nlattr *tb[PARAM_MAX + 1];
6382 tpSirRssiMonitorReq pReq;
6383 eHalStatus status;
6384 int ret;
6385 uint32_t control;
6386 static const struct nla_policy policy[PARAM_MAX + 1] = {
6387 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6388 [PARAM_CONTROL] = { .type = NLA_U32 },
6389 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6390 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6391 };
6392
6393 ENTER();
6394
6395 ret = wlan_hdd_validate_context(hdd_ctx);
6396 if (0 != ret) {
6397 return -EINVAL;
6398 }
6399
6400 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6401 hddLog(LOGE, FL("Not in Connected state!"));
6402 return -ENOTSUPP;
6403 }
6404
6405 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6406 hddLog(LOGE, FL("Invalid ATTR"));
6407 return -EINVAL;
6408 }
6409
6410 if (!tb[PARAM_REQUEST_ID]) {
6411 hddLog(LOGE, FL("attr request id failed"));
6412 return -EINVAL;
6413 }
6414
6415 if (!tb[PARAM_CONTROL]) {
6416 hddLog(LOGE, FL("attr control failed"));
6417 return -EINVAL;
6418 }
6419
6420 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6421
6422 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6423 if(NULL == pReq)
6424 {
6425 hddLog(LOGE,
6426 FL("vos_mem_alloc failed "));
6427 return eHAL_STATUS_FAILED_ALLOC;
6428 }
6429 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6430
6431 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6432 pReq->sessionId = pAdapter->sessionId;
6433 pReq->rssiMonitorCbContext = hdd_ctx;
6434 control = nla_get_u32(tb[PARAM_CONTROL]);
6435 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6436
6437 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6438 pReq->requestId, pReq->sessionId, control);
6439
6440 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6441 if (!tb[PARAM_MIN_RSSI]) {
6442 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306443 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306444 }
6445
6446 if (!tb[PARAM_MAX_RSSI]) {
6447 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306448 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306449 }
6450
6451 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6452 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6453 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6454
6455 if (!(pReq->minRssi < pReq->maxRssi)) {
6456 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6457 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306458 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306459 }
6460 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6461 pReq->minRssi, pReq->maxRssi);
6462 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6463
6464 }
6465 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6466 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6467 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6468 }
6469 else {
6470 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306471 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306472 }
6473
6474 if (!HAL_STATUS_SUCCESS(status)) {
6475 hddLog(LOGE,
6476 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306477 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306478 }
6479
6480 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306481fail:
6482 vos_mem_free(pReq);
6483 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306484}
6485
6486/*
6487 * done with short names for the global vendor params
6488 * used by __wlan_hdd_cfg80211_monitor_rssi()
6489 */
6490#undef PARAM_MAX
6491#undef PARAM_CONTROL
6492#undef PARAM_REQUEST_ID
6493#undef PARAM_MAX_RSSI
6494#undef PARAM_MIN_RSSI
6495
6496/**
6497 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6498 * @wiphy: wiphy structure pointer
6499 * @wdev: Wireless device structure pointer
6500 * @data: Pointer to the data received
6501 * @data_len: Length of @data
6502 *
6503 * Return: 0 on success; errno on failure
6504 */
6505static int
6506wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6507 const void *data, int data_len)
6508{
6509 int ret;
6510
6511 vos_ssr_protect(__func__);
6512 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6513 vos_ssr_unprotect(__func__);
6514
6515 return ret;
6516}
6517
6518/**
6519 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6520 * @hddctx: HDD context
6521 * @data: rssi breached event data
6522 *
6523 * This function reads the rssi breached event %data and fill in the skb with
6524 * NL attributes and send up the NL event.
6525 * This callback execute in atomic context and must not invoke any
6526 * blocking calls.
6527 *
6528 * Return: none
6529 */
6530void hdd_rssi_threshold_breached_cb(void *hddctx,
6531 struct rssi_breach_event *data)
6532{
6533 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6534 int status;
6535 struct sk_buff *skb;
6536
6537 ENTER();
6538 status = wlan_hdd_validate_context(pHddCtx);
6539
6540 if (0 != status) {
6541 return;
6542 }
6543
6544 if (!data) {
6545 hddLog(LOGE, FL("data is null"));
6546 return;
6547 }
6548
6549 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6550#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6551 NULL,
6552#endif
6553 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6554 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6555 GFP_KERNEL);
6556
6557 if (!skb) {
6558 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6559 return;
6560 }
6561
6562 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6563 data->request_id, data->curr_rssi);
6564 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6565 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6566
6567 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6568 data->request_id) ||
6569 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6570 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6571 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6572 data->curr_rssi)) {
6573 hddLog(LOGE, FL("nla put fail"));
6574 goto fail;
6575 }
6576
6577 cfg80211_vendor_event(skb, GFP_KERNEL);
6578 return;
6579
6580fail:
6581 kfree_skb(skb);
6582 return;
6583}
6584
6585
6586
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306587/**
6588 * __wlan_hdd_cfg80211_setband() - set band
6589 * @wiphy: Pointer to wireless phy
6590 * @wdev: Pointer to wireless device
6591 * @data: Pointer to data
6592 * @data_len: Data length
6593 *
6594 * Return: 0 on success, negative errno on failure
6595 */
6596static int
6597__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6598 struct wireless_dev *wdev,
6599 const void *data,
6600 int data_len)
6601{
6602 struct net_device *dev = wdev->netdev;
6603 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6604 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6605 int ret;
6606 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6607 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6608
6609 ENTER();
6610
6611 ret = wlan_hdd_validate_context(hdd_ctx);
6612 if (0 != ret) {
6613 hddLog(LOGE, FL("HDD context is not valid"));
6614 return ret;
6615 }
6616
6617 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6618 policy)) {
6619 hddLog(LOGE, FL("Invalid ATTR"));
6620 return -EINVAL;
6621 }
6622
6623 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6624 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6625 return -EINVAL;
6626 }
6627
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306628 hdd_ctx->isSetBandByNL = TRUE;
6629 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306630 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306631 hdd_ctx->isSetBandByNL = FALSE;
6632
6633 EXIT();
6634 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306635}
6636
6637/**
6638 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6639 * @wiphy: wiphy structure pointer
6640 * @wdev: Wireless device structure pointer
6641 * @data: Pointer to the data received
6642 * @data_len: Length of @data
6643 *
6644 * Return: 0 on success; errno on failure
6645 */
6646static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6647 struct wireless_dev *wdev,
6648 const void *data,
6649 int data_len)
6650{
6651 int ret = 0;
6652
6653 vos_ssr_protect(__func__);
6654 ret = __wlan_hdd_cfg80211_setband(wiphy,
6655 wdev, data, data_len);
6656 vos_ssr_unprotect(__func__);
6657
6658 return ret;
6659}
6660
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306661#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6662/**
6663 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6664 * @hdd_ctx: HDD context
6665 * @request_id: [input] request id
6666 * @pattern_id: [output] pattern id
6667 *
6668 * This function loops through request id to pattern id array
6669 * if the slot is available, store the request id and return pattern id
6670 * if entry exists, return the pattern id
6671 *
6672 * Return: 0 on success and errno on failure
6673 */
6674static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6675 uint32_t request_id,
6676 uint8_t *pattern_id)
6677{
6678 uint32_t i;
6679
6680 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6681 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6682 {
6683 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6684 {
6685 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6686 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6687 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6688 return 0;
6689 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6690 request_id) {
6691 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6692 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6693 return 0;
6694 }
6695 }
6696 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6697 return -EINVAL;
6698}
6699
6700/**
6701 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6702 * @hdd_ctx: HDD context
6703 * @request_id: [input] request id
6704 * @pattern_id: [output] pattern id
6705 *
6706 * This function loops through request id to pattern id array
6707 * reset request id to 0 (slot available again) and
6708 * return pattern id
6709 *
6710 * Return: 0 on success and errno on failure
6711 */
6712static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6713 uint32_t request_id,
6714 uint8_t *pattern_id)
6715{
6716 uint32_t i;
6717
6718 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6719 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6720 {
6721 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6722 {
6723 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6724 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6725 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6726 return 0;
6727 }
6728 }
6729 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6730 return -EINVAL;
6731}
6732
6733
6734/*
6735 * define short names for the global vendor params
6736 * used by __wlan_hdd_cfg80211_offloaded_packets()
6737 */
6738#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6739#define PARAM_REQUEST_ID \
6740 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6741#define PARAM_CONTROL \
6742 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6743#define PARAM_IP_PACKET \
6744 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6745#define PARAM_SRC_MAC_ADDR \
6746 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6747#define PARAM_DST_MAC_ADDR \
6748 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6749#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6750
6751/**
6752 * wlan_hdd_add_tx_ptrn() - add tx pattern
6753 * @adapter: adapter pointer
6754 * @hdd_ctx: hdd context
6755 * @tb: nl attributes
6756 *
6757 * This function reads the NL attributes and forms a AddTxPtrn message
6758 * posts it to SME.
6759 *
6760 */
6761static int
6762wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6763 struct nlattr **tb)
6764{
6765 struct sSirAddPeriodicTxPtrn *add_req;
6766 eHalStatus status;
6767 uint32_t request_id, ret, len;
6768 uint8_t pattern_id = 0;
6769 v_MACADDR_t dst_addr;
6770 uint16_t eth_type = htons(ETH_P_IP);
6771
6772 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6773 {
6774 hddLog(LOGE, FL("Not in Connected state!"));
6775 return -ENOTSUPP;
6776 }
6777
6778 add_req = vos_mem_malloc(sizeof(*add_req));
6779 if (!add_req)
6780 {
6781 hddLog(LOGE, FL("memory allocation failed"));
6782 return -ENOMEM;
6783 }
6784
6785 /* Parse and fetch request Id */
6786 if (!tb[PARAM_REQUEST_ID])
6787 {
6788 hddLog(LOGE, FL("attr request id failed"));
6789 goto fail;
6790 }
6791
6792 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6793 hddLog(LOG1, FL("Request Id: %u"), request_id);
6794 if (request_id == 0)
6795 {
6796 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306797 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306798 }
6799
6800 if (!tb[PARAM_PERIOD])
6801 {
6802 hddLog(LOGE, FL("attr period failed"));
6803 goto fail;
6804 }
6805 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6806 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6807 if (add_req->usPtrnIntervalMs == 0)
6808 {
6809 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6810 goto fail;
6811 }
6812
6813 if (!tb[PARAM_SRC_MAC_ADDR])
6814 {
6815 hddLog(LOGE, FL("attr source mac address failed"));
6816 goto fail;
6817 }
6818 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6819 VOS_MAC_ADDR_SIZE);
6820 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6821 MAC_ADDR_ARRAY(add_req->macAddress));
6822
6823 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6824 VOS_MAC_ADDR_SIZE))
6825 {
6826 hddLog(LOGE,
6827 FL("input src mac address and connected ap bssid are different"));
6828 goto fail;
6829 }
6830
6831 if (!tb[PARAM_DST_MAC_ADDR])
6832 {
6833 hddLog(LOGE, FL("attr dst mac address failed"));
6834 goto fail;
6835 }
6836 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6837 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6838 MAC_ADDR_ARRAY(dst_addr.bytes));
6839
6840 if (!tb[PARAM_IP_PACKET])
6841 {
6842 hddLog(LOGE, FL("attr ip packet failed"));
6843 goto fail;
6844 }
6845 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6846 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6847
6848 if (add_req->ucPtrnSize < 0 ||
6849 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6850 HDD_ETH_HEADER_LEN))
6851 {
6852 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6853 add_req->ucPtrnSize);
6854 goto fail;
6855 }
6856
6857 len = 0;
6858 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6859 len += VOS_MAC_ADDR_SIZE;
6860 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6861 VOS_MAC_ADDR_SIZE);
6862 len += VOS_MAC_ADDR_SIZE;
6863 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6864 len += 2;
6865
6866 /*
6867 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6868 * ------------------------------------------------------------
6869 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6870 * ------------------------------------------------------------
6871 */
6872 vos_mem_copy(&add_req->ucPattern[len],
6873 nla_data(tb[PARAM_IP_PACKET]),
6874 add_req->ucPtrnSize);
6875 add_req->ucPtrnSize += len;
6876
6877 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6878 add_req->ucPattern, add_req->ucPtrnSize);
6879
6880 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6881 if (ret)
6882 {
6883 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6884 goto fail;
6885 }
6886 add_req->ucPtrnId = pattern_id;
6887 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6888
6889 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6890 if (!HAL_STATUS_SUCCESS(status))
6891 {
6892 hddLog(LOGE,
6893 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6894 goto fail;
6895 }
6896
6897 EXIT();
6898 vos_mem_free(add_req);
6899 return 0;
6900
6901fail:
6902 vos_mem_free(add_req);
6903 return -EINVAL;
6904}
6905
6906/**
6907 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6908 * @adapter: adapter pointer
6909 * @hdd_ctx: hdd context
6910 * @tb: nl attributes
6911 *
6912 * This function reads the NL attributes and forms a DelTxPtrn message
6913 * posts it to SME.
6914 *
6915 */
6916static int
6917wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6918 struct nlattr **tb)
6919{
6920 struct sSirDelPeriodicTxPtrn *del_req;
6921 eHalStatus status;
6922 uint32_t request_id, ret;
6923 uint8_t pattern_id = 0;
6924
6925 /* Parse and fetch request Id */
6926 if (!tb[PARAM_REQUEST_ID])
6927 {
6928 hddLog(LOGE, FL("attr request id failed"));
6929 return -EINVAL;
6930 }
6931 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6932 if (request_id == 0)
6933 {
6934 hddLog(LOGE, FL("request_id cannot be zero"));
6935 return -EINVAL;
6936 }
6937
6938 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6939 if (ret)
6940 {
6941 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6942 return -EINVAL;
6943 }
6944
6945 del_req = vos_mem_malloc(sizeof(*del_req));
6946 if (!del_req)
6947 {
6948 hddLog(LOGE, FL("memory allocation failed"));
6949 return -ENOMEM;
6950 }
6951
6952 vos_mem_set(del_req, sizeof(*del_req), 0);
6953 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6954 VOS_MAC_ADDR_SIZE);
6955 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6956 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6957 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6958 request_id, pattern_id, del_req->ucPatternIdBitmap);
6959
6960 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6961 if (!HAL_STATUS_SUCCESS(status))
6962 {
6963 hddLog(LOGE,
6964 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6965 goto fail;
6966 }
6967
6968 EXIT();
6969 vos_mem_free(del_req);
6970 return 0;
6971
6972fail:
6973 vos_mem_free(del_req);
6974 return -EINVAL;
6975}
6976
6977
6978/**
6979 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6980 * @wiphy: Pointer to wireless phy
6981 * @wdev: Pointer to wireless device
6982 * @data: Pointer to data
6983 * @data_len: Data length
6984 *
6985 * Return: 0 on success, negative errno on failure
6986 */
6987static int
6988__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6989 struct wireless_dev *wdev,
6990 const void *data,
6991 int data_len)
6992{
6993 struct net_device *dev = wdev->netdev;
6994 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6995 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6996 struct nlattr *tb[PARAM_MAX + 1];
6997 uint8_t control;
6998 int ret;
6999 static const struct nla_policy policy[PARAM_MAX + 1] =
7000 {
7001 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
7002 [PARAM_CONTROL] = { .type = NLA_U32 },
7003 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
7004 .len = VOS_MAC_ADDR_SIZE },
7005 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
7006 .len = VOS_MAC_ADDR_SIZE },
7007 [PARAM_PERIOD] = { .type = NLA_U32 },
7008 };
7009
7010 ENTER();
7011
7012 ret = wlan_hdd_validate_context(hdd_ctx);
7013 if (0 != ret)
7014 {
7015 hddLog(LOGE, FL("HDD context is not valid"));
7016 return ret;
7017 }
7018
7019 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
7020 {
7021 hddLog(LOGE,
7022 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
7023 return -ENOTSUPP;
7024 }
7025
7026 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
7027 {
7028 hddLog(LOGE, FL("Invalid ATTR"));
7029 return -EINVAL;
7030 }
7031
7032 if (!tb[PARAM_CONTROL])
7033 {
7034 hddLog(LOGE, FL("attr control failed"));
7035 return -EINVAL;
7036 }
7037 control = nla_get_u32(tb[PARAM_CONTROL]);
7038 hddLog(LOG1, FL("Control: %d"), control);
7039
7040 if (control == WLAN_START_OFFLOADED_PACKETS)
7041 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7042 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7043 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7044 else
7045 {
7046 hddLog(LOGE, FL("Invalid control: %d"), control);
7047 return -EINVAL;
7048 }
7049}
7050
7051/*
7052 * done with short names for the global vendor params
7053 * used by __wlan_hdd_cfg80211_offloaded_packets()
7054 */
7055#undef PARAM_MAX
7056#undef PARAM_REQUEST_ID
7057#undef PARAM_CONTROL
7058#undef PARAM_IP_PACKET
7059#undef PARAM_SRC_MAC_ADDR
7060#undef PARAM_DST_MAC_ADDR
7061#undef PARAM_PERIOD
7062
7063/**
7064 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7065 * @wiphy: wiphy structure pointer
7066 * @wdev: Wireless device structure pointer
7067 * @data: Pointer to the data received
7068 * @data_len: Length of @data
7069 *
7070 * Return: 0 on success; errno on failure
7071 */
7072static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7073 struct wireless_dev *wdev,
7074 const void *data,
7075 int data_len)
7076{
7077 int ret = 0;
7078
7079 vos_ssr_protect(__func__);
7080 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7081 wdev, data, data_len);
7082 vos_ssr_unprotect(__func__);
7083
7084 return ret;
7085}
7086#endif
7087
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307088static const struct
7089nla_policy
7090qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
7091 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
7092};
7093
7094/**
7095 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7096 * get link properties like nss, rate flags and operating frequency for
7097 * the connection with the given peer.
7098 * @wiphy: WIPHY structure pointer
7099 * @wdev: Wireless device structure pointer
7100 * @data: Pointer to the data received
7101 * @data_len: Length of the data received
7102 *
7103 * This function return the above link properties on success.
7104 *
7105 * Return: 0 on success and errno on failure
7106 */
7107static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7108 struct wireless_dev *wdev,
7109 const void *data,
7110 int data_len)
7111{
7112 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7113 struct net_device *dev = wdev->netdev;
7114 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7115 hdd_station_ctx_t *hdd_sta_ctx;
7116 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7117 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7118 uint32_t sta_id;
7119 struct sk_buff *reply_skb;
7120 uint32_t rate_flags = 0;
7121 uint8_t nss;
7122 uint8_t final_rate_flags = 0;
7123 uint32_t freq;
7124 v_CONTEXT_t pVosContext = NULL;
7125 ptSapContext pSapCtx = NULL;
7126
7127 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7128 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7129 return -EINVAL;
7130 }
7131
7132 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7133 qca_wlan_vendor_attr_policy)) {
7134 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7135 return -EINVAL;
7136 }
7137
7138 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7139 hddLog(VOS_TRACE_LEVEL_ERROR,
7140 FL("Attribute peerMac not provided for mode=%d"),
7141 adapter->device_mode);
7142 return -EINVAL;
7143 }
7144
7145 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7146 sizeof(peer_mac));
7147 hddLog(VOS_TRACE_LEVEL_INFO,
7148 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7149 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7150
7151 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7152 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7153 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7154 if ((hdd_sta_ctx->conn_info.connState !=
7155 eConnectionState_Associated) ||
7156 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7157 VOS_MAC_ADDRESS_LEN)) {
7158 hddLog(VOS_TRACE_LEVEL_ERROR,
7159 FL("Not Associated to mac "MAC_ADDRESS_STR),
7160 MAC_ADDR_ARRAY(peer_mac));
7161 return -EINVAL;
7162 }
7163
7164 nss = 1; //pronto supports only one spatial stream
7165 freq = vos_chan_to_freq(
7166 hdd_sta_ctx->conn_info.operationChannel);
7167 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7168
7169 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7170 adapter->device_mode == WLAN_HDD_SOFTAP) {
7171
7172 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7173 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7174 if(pSapCtx == NULL){
7175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7176 FL("psapCtx is NULL"));
7177 return -ENOENT;
7178 }
7179
7180
7181 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7182 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7183 !vos_is_macaddr_broadcast(
7184 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7185 vos_mem_compare(
7186 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7187 peer_mac, VOS_MAC_ADDRESS_LEN))
7188 break;
7189 }
7190
7191 if (WLAN_MAX_STA_COUNT == sta_id) {
7192 hddLog(VOS_TRACE_LEVEL_ERROR,
7193 FL("No active peer with mac="MAC_ADDRESS_STR),
7194 MAC_ADDR_ARRAY(peer_mac));
7195 return -EINVAL;
7196 }
7197
7198 nss = 1; //pronto supports only one spatial stream
7199 freq = vos_chan_to_freq(
7200 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7201 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7202 } else {
7203 hddLog(VOS_TRACE_LEVEL_ERROR,
7204 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7205 MAC_ADDR_ARRAY(peer_mac));
7206 return -EINVAL;
7207 }
7208
7209 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7210 if (rate_flags & eHAL_TX_RATE_VHT80) {
7211 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7212 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7213 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7214 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7215 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7216 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7217 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7218 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7219 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7220 if (rate_flags & eHAL_TX_RATE_HT40)
7221 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7222 }
7223
7224 if (rate_flags & eHAL_TX_RATE_SGI) {
7225 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7226 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7227 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7228 }
7229 }
7230
7231 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7232 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7233
7234 if (NULL == reply_skb) {
7235 hddLog(VOS_TRACE_LEVEL_ERROR,
7236 FL("getLinkProperties: skb alloc failed"));
7237 return -EINVAL;
7238 }
7239
7240 if (nla_put_u8(reply_skb,
7241 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7242 nss) ||
7243 nla_put_u8(reply_skb,
7244 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7245 final_rate_flags) ||
7246 nla_put_u32(reply_skb,
7247 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7248 freq)) {
7249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7250 kfree_skb(reply_skb);
7251 return -EINVAL;
7252 }
7253
7254 return cfg80211_vendor_cmd_reply(reply_skb);
7255}
7256
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307257#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7258#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7259#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7260#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307261#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7262 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307263
7264/**
7265 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7266 * vendor command
7267 *
7268 * @wiphy: wiphy device pointer
7269 * @wdev: wireless device pointer
7270 * @data: Vendor command data buffer
7271 * @data_len: Buffer length
7272 *
7273 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7274 *
7275 * Return: EOK or other error codes.
7276 */
7277
7278static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7279 struct wireless_dev *wdev,
7280 const void *data,
7281 int data_len)
7282{
7283 struct net_device *dev = wdev->netdev;
7284 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7285 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7286 hdd_station_ctx_t *pHddStaCtx;
7287 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7288 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307289 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307290 eHalStatus status;
7291 int ret_val;
7292 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7293 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7294 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307295 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7296 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7297 { .type = NLA_U32},
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307298 };
7299
7300 ENTER();
7301
7302 if (VOS_FTM_MODE == hdd_get_conparam()) {
7303 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7304 return -EINVAL;
7305 }
7306
7307 ret_val = wlan_hdd_validate_context(pHddCtx);
7308 if (ret_val) {
7309 return ret_val;
7310 }
7311
7312 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7313
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307314 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7315 hddLog(LOGE, FL("Invalid ATTR"));
7316 return -EINVAL;
7317 }
7318
7319 /* check the Wifi Capability */
7320 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7321 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7322 {
7323 hddLog(VOS_TRACE_LEVEL_ERROR,
7324 FL("WIFICONFIG not supported by Firmware"));
7325 return -EINVAL;
7326 }
7327
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307328 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7329 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7330 modifyRoamParamsReq.value =
7331 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7332
7333 if (eHAL_STATUS_SUCCESS !=
7334 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7335 {
7336 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7337 ret_val = -EINVAL;
7338 }
7339 return ret_val;
7340 }
7341
7342 /* Moved this down in order to provide provision to set beacon
7343 * miss penalty count irrespective of connection state.
7344 */
7345 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7346 hddLog(LOGE, FL("Not in Connected state!"));
7347 return -ENOTSUPP;
7348 }
7349
7350 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307351
7352 if (!pReq) {
7353 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7354 "%s: Not able to allocate memory for tSetWifiConfigParams",
7355 __func__);
7356 return eHAL_STATUS_E_MALLOC_FAILED;
7357 }
7358
7359 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7360
7361 pReq->sessionId = pAdapter->sessionId;
7362 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7363
7364 if (tb[PARAM_MODULATED_DTIM]) {
7365 pReq->paramValue = nla_get_u32(
7366 tb[PARAM_MODULATED_DTIM]);
7367 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7368 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307369 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307370 hdd_set_pwrparams(pHddCtx);
7371 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7372 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7373
7374 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7375 iw_full_power_cbfn, pAdapter,
7376 eSME_FULL_PWR_NEEDED_BY_HDD);
7377 }
7378 else
7379 {
7380 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7381 }
7382 }
7383
7384 if (tb[PARAM_STATS_AVG_FACTOR]) {
7385 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7386 pReq->paramValue = nla_get_u16(
7387 tb[PARAM_STATS_AVG_FACTOR]);
7388 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7389 pReq->paramType, pReq->paramValue);
7390 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7391
7392 if (eHAL_STATUS_SUCCESS != status)
7393 {
7394 vos_mem_free(pReq);
7395 pReq = NULL;
7396 ret_val = -EPERM;
7397 return ret_val;
7398 }
7399 }
7400
7401
7402 if (tb[PARAM_GUARD_TIME]) {
7403 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7404 pReq->paramValue = nla_get_u32(
7405 tb[PARAM_GUARD_TIME]);
7406 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7407 pReq->paramType, pReq->paramValue);
7408 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7409
7410 if (eHAL_STATUS_SUCCESS != status)
7411 {
7412 vos_mem_free(pReq);
7413 pReq = NULL;
7414 ret_val = -EPERM;
7415 return ret_val;
7416 }
7417
7418 }
7419
7420 EXIT();
7421 return ret_val;
7422}
7423
7424/**
7425 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7426 * vendor command
7427 *
7428 * @wiphy: wiphy device pointer
7429 * @wdev: wireless device pointer
7430 * @data: Vendor command data buffer
7431 * @data_len: Buffer length
7432 *
7433 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7434 *
7435 * Return: EOK or other error codes.
7436 */
7437static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7438 struct wireless_dev *wdev,
7439 const void *data,
7440 int data_len)
7441{
7442 int ret;
7443
7444 vos_ssr_protect(__func__);
7445 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
7446 data, data_len);
7447 vos_ssr_unprotect(__func__);
7448
7449 return ret;
7450}
Sunil Duttc69bccb2014-05-26 21:30:20 +05307451const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7452{
Mukul Sharma2a271632014-10-13 14:59:01 +05307453 {
7454 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7455 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7456 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7457 WIPHY_VENDOR_CMD_NEED_NETDEV |
7458 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307459 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307460 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307461
7462 {
7463 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7464 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7465 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7466 WIPHY_VENDOR_CMD_NEED_NETDEV |
7467 WIPHY_VENDOR_CMD_NEED_RUNNING,
7468 .doit = wlan_hdd_cfg80211_nan_request
7469 },
7470
Sunil Duttc69bccb2014-05-26 21:30:20 +05307471#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7472 {
7473 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7474 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7475 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7476 WIPHY_VENDOR_CMD_NEED_NETDEV |
7477 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307478 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307479 },
7480
7481 {
7482 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7483 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7484 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7485 WIPHY_VENDOR_CMD_NEED_NETDEV |
7486 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307487 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307488 },
7489
7490 {
7491 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7492 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7493 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7494 WIPHY_VENDOR_CMD_NEED_NETDEV |
7495 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307496 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307497 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307498#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307499#ifdef WLAN_FEATURE_EXTSCAN
7500 {
7501 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7502 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7503 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7504 WIPHY_VENDOR_CMD_NEED_NETDEV |
7505 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307506 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307507 },
7508 {
7509 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7510 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7511 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7512 WIPHY_VENDOR_CMD_NEED_NETDEV |
7513 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307514 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307515 },
7516 {
7517 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7518 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7519 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7520 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307521 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307522 },
7523 {
7524 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7525 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7526 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7527 WIPHY_VENDOR_CMD_NEED_NETDEV |
7528 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307529 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307530 },
7531 {
7532 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7533 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7534 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7535 WIPHY_VENDOR_CMD_NEED_NETDEV |
7536 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307537 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307538 },
7539 {
7540 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7541 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7542 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7543 WIPHY_VENDOR_CMD_NEED_NETDEV |
7544 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307545 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307546 },
7547 {
7548 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7549 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7550 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7551 WIPHY_VENDOR_CMD_NEED_NETDEV |
7552 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307553 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307554 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307555 {
7556 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7557 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
7558 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7559 WIPHY_VENDOR_CMD_NEED_NETDEV |
7560 WIPHY_VENDOR_CMD_NEED_RUNNING,
7561 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
7562 },
7563 {
7564 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7565 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
7566 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7567 WIPHY_VENDOR_CMD_NEED_NETDEV |
7568 WIPHY_VENDOR_CMD_NEED_RUNNING,
7569 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
7570 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307571#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307572/*EXT TDLS*/
7573 {
7574 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7575 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7576 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7577 WIPHY_VENDOR_CMD_NEED_NETDEV |
7578 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307579 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307580 },
7581 {
7582 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7583 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7584 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7585 WIPHY_VENDOR_CMD_NEED_NETDEV |
7586 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307587 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307588 },
7589 {
7590 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7591 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7592 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7593 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307594 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307595 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307596 {
7597 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7598 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7599 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7600 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307601 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307602 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307603 {
7604 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7605 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7606 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7607 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307608 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307609 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307610 {
7611 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7612 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7613 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7614 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307615 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307616 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307617 {
7618 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7619 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7620 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7621 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307622 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307623 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307624 {
7625 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307626 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7627 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7628 WIPHY_VENDOR_CMD_NEED_NETDEV |
7629 WIPHY_VENDOR_CMD_NEED_RUNNING,
7630 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7631 },
7632 {
7633 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307634 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7635 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7636 WIPHY_VENDOR_CMD_NEED_NETDEV |
7637 WIPHY_VENDOR_CMD_NEED_RUNNING,
7638 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307639 },
7640 {
7641 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7642 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7643 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7644 WIPHY_VENDOR_CMD_NEED_NETDEV,
7645 .doit = wlan_hdd_cfg80211_wifi_logger_start
7646 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307647 {
7648 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7649 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7650 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7651 WIPHY_VENDOR_CMD_NEED_NETDEV|
7652 WIPHY_VENDOR_CMD_NEED_RUNNING,
7653 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307654 },
7655 {
7656 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7657 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7658 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7659 WIPHY_VENDOR_CMD_NEED_NETDEV |
7660 WIPHY_VENDOR_CMD_NEED_RUNNING,
7661 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307662 },
7663 {
7664 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7665 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7666 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7667 WIPHY_VENDOR_CMD_NEED_NETDEV |
7668 WIPHY_VENDOR_CMD_NEED_RUNNING,
7669 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307670 },
7671#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7672 {
7673 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7674 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7675 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7676 WIPHY_VENDOR_CMD_NEED_NETDEV |
7677 WIPHY_VENDOR_CMD_NEED_RUNNING,
7678 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307679 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307680#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307681 {
7682 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7683 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7684 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7685 WIPHY_VENDOR_CMD_NEED_NETDEV |
7686 WIPHY_VENDOR_CMD_NEED_RUNNING,
7687 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307688 },
7689 {
7690 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7691 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
7692 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7693 WIPHY_VENDOR_CMD_NEED_NETDEV |
7694 WIPHY_VENDOR_CMD_NEED_RUNNING,
7695 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307696 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05307697};
7698
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007699/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307700static const
7701struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007702{
7703#ifdef FEATURE_WLAN_CH_AVOID
7704 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307705 .vendor_id = QCA_NL80211_VENDOR_ID,
7706 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007707 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307708#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7709#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7710 {
7711 /* Index = 1*/
7712 .vendor_id = QCA_NL80211_VENDOR_ID,
7713 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7714 },
7715 {
7716 /* Index = 2*/
7717 .vendor_id = QCA_NL80211_VENDOR_ID,
7718 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7719 },
7720 {
7721 /* Index = 3*/
7722 .vendor_id = QCA_NL80211_VENDOR_ID,
7723 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7724 },
7725 {
7726 /* Index = 4*/
7727 .vendor_id = QCA_NL80211_VENDOR_ID,
7728 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7729 },
7730 {
7731 /* Index = 5*/
7732 .vendor_id = QCA_NL80211_VENDOR_ID,
7733 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7734 },
7735 {
7736 /* Index = 6*/
7737 .vendor_id = QCA_NL80211_VENDOR_ID,
7738 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7739 },
7740#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307741#ifdef WLAN_FEATURE_EXTSCAN
7742 {
7743 .vendor_id = QCA_NL80211_VENDOR_ID,
7744 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7745 },
7746 {
7747 .vendor_id = QCA_NL80211_VENDOR_ID,
7748 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7749 },
7750 {
7751 .vendor_id = QCA_NL80211_VENDOR_ID,
7752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7753 },
7754 {
7755 .vendor_id = QCA_NL80211_VENDOR_ID,
7756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7757 },
7758 {
7759 .vendor_id = QCA_NL80211_VENDOR_ID,
7760 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7761 },
7762 {
7763 .vendor_id = QCA_NL80211_VENDOR_ID,
7764 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7765 },
7766 {
7767 .vendor_id = QCA_NL80211_VENDOR_ID,
7768 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7769 },
7770 {
7771 .vendor_id = QCA_NL80211_VENDOR_ID,
7772 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7773 },
7774 {
7775 .vendor_id = QCA_NL80211_VENDOR_ID,
7776 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7777 },
7778 {
7779 .vendor_id = QCA_NL80211_VENDOR_ID,
7780 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7781 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307782 {
7783 .vendor_id = QCA_NL80211_VENDOR_ID,
7784 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
7785 },
7786 {
7787 .vendor_id = QCA_NL80211_VENDOR_ID,
7788 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
7789 },
7790 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
7791 .vendor_id = QCA_NL80211_VENDOR_ID,
7792 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
7793 },
7794 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
7795 .vendor_id = QCA_NL80211_VENDOR_ID,
7796 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
7797 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307798#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307799/*EXT TDLS*/
7800 {
7801 .vendor_id = QCA_NL80211_VENDOR_ID,
7802 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7803 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307804 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7805 .vendor_id = QCA_NL80211_VENDOR_ID,
7806 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7807 },
7808
Srinivas Dasari030bad32015-02-18 23:23:54 +05307809
7810 {
7811 .vendor_id = QCA_NL80211_VENDOR_ID,
7812 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7813 },
7814
Sushant Kaushik084f6592015-09-10 13:11:56 +05307815 {
7816 .vendor_id = QCA_NL80211_VENDOR_ID,
7817 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307818 },
7819 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7820 .vendor_id = QCA_NL80211_VENDOR_ID,
7821 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7822 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05307823 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
7824 .vendor_id = QCA_NL80211_VENDOR_ID,
7825 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
7826 },
Sushant Kaushik084f6592015-09-10 13:11:56 +05307827
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007828};
7829
Jeff Johnson295189b2012-06-20 16:38:30 -07007830/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307831 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307832 * This function is called by hdd_wlan_startup()
7833 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307834 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307836struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007837{
7838 struct wiphy *wiphy;
7839 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307840 /*
7841 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 */
7843 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7844
7845 if (!wiphy)
7846 {
7847 /* Print error and jump into err label and free the memory */
7848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7849 return NULL;
7850 }
7851
Sunil Duttc69bccb2014-05-26 21:30:20 +05307852
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 return wiphy;
7854}
7855
7856/*
7857 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307858 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 * private ioctl to change the band value
7860 */
7861int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7862{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307863 int i, j;
7864 eNVChannelEnabledType channelEnabledState;
7865
Jeff Johnsone7245742012-09-05 17:12:55 -07007866 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307867
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307868 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307870
7871 if (NULL == wiphy->bands[i])
7872 {
7873 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7874 __func__, i);
7875 continue;
7876 }
7877
7878 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7879 {
7880 struct ieee80211_supported_band *band = wiphy->bands[i];
7881
7882 channelEnabledState = vos_nv_getChannelEnabledState(
7883 band->channels[j].hw_value);
7884
7885 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7886 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307887 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307888 continue;
7889 }
7890 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7891 {
7892 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7893 continue;
7894 }
7895
7896 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7897 NV_CHANNEL_INVALID == channelEnabledState)
7898 {
7899 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7900 }
7901 else if (NV_CHANNEL_DFS == channelEnabledState)
7902 {
7903 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7904 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7905 }
7906 else
7907 {
7908 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7909 |IEEE80211_CHAN_RADAR);
7910 }
7911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 }
7913 return 0;
7914}
7915/*
7916 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307917 * This function is called by hdd_wlan_startup()
7918 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 * This function is used to initialize and register wiphy structure.
7920 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307921int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 struct wiphy *wiphy,
7923 hdd_config_t *pCfg
7924 )
7925{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307926 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307927 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7928
Jeff Johnsone7245742012-09-05 17:12:55 -07007929 ENTER();
7930
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 /* Now bind the underlying wlan device with wiphy */
7932 set_wiphy_dev(wiphy, dev);
7933
7934 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007935
Kiet Lam6c583332013-10-14 05:37:09 +05307936#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007937 /* the flag for the other case would be initialzed in
7938 vos_init_wiphy_from_nv_bin */
Manjeet Singh9e19de62016-08-18 18:26:41 +05307939#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7940 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
7941#else
Amar Singhal0a402232013-10-11 20:57:16 -07007942 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307943#endif
Manjeet Singh9e19de62016-08-18 18:26:41 +05307944#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007945
Amar Singhalfddc28c2013-09-05 13:03:40 -07007946 /* This will disable updating of NL channels from passive to
7947 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307948#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7949 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7950#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007951 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307952#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007953
Amar Singhala49cbc52013-10-08 18:37:44 -07007954
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007955#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007956 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7957 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7958 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007959 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307960#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Rajeev Kumar Sirasanagandla0d6dd752016-08-17 15:01:39 +05307961 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307962#else
7963 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7964#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007965#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007966
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007967#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007968 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007969#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007970 || pCfg->isFastRoamIniFeatureEnabled
7971#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007972#ifdef FEATURE_WLAN_ESE
7973 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007974#endif
7975 )
7976 {
7977 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7978 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007979#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007980#ifdef FEATURE_WLAN_TDLS
7981 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7982 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7983#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307984#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307985 if (pCfg->configPNOScanSupport)
7986 {
7987 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7988 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7989 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7990 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7991 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307992#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007993
Abhishek Singh10d85972015-04-17 10:27:23 +05307994#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7995 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7996#endif
7997
Amar Singhalfddc28c2013-09-05 13:03:40 -07007998#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007999 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
8000 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07008001 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07008002 driver need to determine what to do with both
8003 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07008004
8005 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07008006#else
8007 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07008008#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008009
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308010 wiphy->max_scan_ssids = MAX_SCAN_SSID;
8011
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05308012 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07008013
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308014 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
8015
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05308017 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
8018 | BIT(NL80211_IFTYPE_ADHOC)
8019 | BIT(NL80211_IFTYPE_P2P_CLIENT)
8020 | BIT(NL80211_IFTYPE_P2P_GO)
8021 | BIT(NL80211_IFTYPE_AP);
8022
8023 if (VOS_MONITOR_MODE == hdd_get_conparam())
8024 {
8025 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
8026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008027
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308028 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008029 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308030#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
8031 if( pCfg->enableMCC )
8032 {
8033 /* Currently, supports up to two channels */
8034 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008035
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308036 if( !pCfg->allowMCCGODiffBI )
8037 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008038
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308039 }
8040 wiphy->iface_combinations = &wlan_hdd_iface_combination;
8041 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008042#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308043 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008044
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 /* Before registering we need to update the ht capabilitied based
8046 * on ini values*/
8047 if( !pCfg->ShortGI20MhzEnable )
8048 {
8049 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8050 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 }
8052
8053 if( !pCfg->ShortGI40MhzEnable )
8054 {
8055 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8056 }
8057
8058 if( !pCfg->nChannelBondingMode5GHz )
8059 {
8060 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8061 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308062 /*
8063 * In case of static linked driver at the time of driver unload,
8064 * module exit doesn't happens. Module cleanup helps in cleaning
8065 * of static memory.
8066 * If driver load happens statically, at the time of driver unload,
8067 * wiphy flags don't get reset because of static memory.
8068 * It's better not to store channel in static memory.
8069 */
8070 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8071 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8072 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8073 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8074 {
8075 hddLog(VOS_TRACE_LEVEL_ERROR,
8076 FL("Not enough memory to allocate channels"));
8077 return -ENOMEM;
8078 }
8079 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8080 &hdd_channels_2_4_GHZ[0],
8081 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008082
Agrawal Ashish97dec502015-11-26 20:20:58 +05308083 if (true == hdd_is_5g_supported(pHddCtx))
8084 {
8085 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8086 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8087 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8088 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8089 {
8090 hddLog(VOS_TRACE_LEVEL_ERROR,
8091 FL("Not enough memory to allocate channels"));
8092 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8093 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8094 return -ENOMEM;
8095 }
8096 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8097 &hdd_channels_5_GHZ[0],
8098 sizeof(hdd_channels_5_GHZ));
8099 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308100
8101 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8102 {
8103
8104 if (NULL == wiphy->bands[i])
8105 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308106 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308107 __func__, i);
8108 continue;
8109 }
8110
8111 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8112 {
8113 struct ieee80211_supported_band *band = wiphy->bands[i];
8114
8115 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8116 {
8117 // Enable social channels for P2P
8118 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8119 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8120 else
8121 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8122 continue;
8123 }
8124 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8125 {
8126 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8127 continue;
8128 }
8129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 }
8131 /*Initialise the supported cipher suite details*/
8132 wiphy->cipher_suites = hdd_cipher_suites;
8133 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8134
8135 /*signal strength in mBm (100*dBm) */
8136 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8137
8138#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308139 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008141
Sunil Duttc69bccb2014-05-26 21:30:20 +05308142 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8143 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008144 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8145 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8146
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308147 EXIT();
8148 return 0;
8149}
8150
8151/* In this function we are registering wiphy. */
8152int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8153{
8154 ENTER();
8155 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 if (0 > wiphy_register(wiphy))
8157 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308158 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8160 return -EIO;
8161 }
8162
8163 EXIT();
8164 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308165}
Jeff Johnson295189b2012-06-20 16:38:30 -07008166
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308167/* In this function we are updating channel list when,
8168 regulatory domain is FCC and country code is US.
8169 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8170 As per FCC smart phone is not a indoor device.
8171 GO should not opeate on indoor channels */
8172void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8173{
8174 int j;
8175 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8176 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8177 //Default counrtycode from NV at the time of wiphy initialization.
8178 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8179 &defaultCountryCode[0]))
8180 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008181 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308182 }
8183 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8184 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308185 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8186 {
8187 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8188 return;
8189 }
8190 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8191 {
8192 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8193 // Mark UNII -1 band channel as passive
8194 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8195 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8196 }
8197 }
8198}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308199/* This function registers for all frame which supplicant is interested in */
8200void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008201{
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8203 /* Register for all P2P action, public action etc frames */
8204 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008205 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308206 /* Register frame indication call back */
8207 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 /* Right now we are registering these frame when driver is getting
8209 initialized. Once we will move to 2.6.37 kernel, in which we have
8210 frame register ops, we will move this code as a part of that */
8211 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308212 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8214
8215 /* GAS Initial Response */
8216 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8217 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308218
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 /* GAS Comeback Request */
8220 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8221 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8222
8223 /* GAS Comeback Response */
8224 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8225 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8226
8227 /* P2P Public Action */
8228 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308229 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 P2P_PUBLIC_ACTION_FRAME_SIZE );
8231
8232 /* P2P Action */
8233 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8234 (v_U8_t*)P2P_ACTION_FRAME,
8235 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008236
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308237 /* WNM BSS Transition Request frame */
8238 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8239 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8240 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008241
8242 /* WNM-Notification */
8243 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8244 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8245 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008246}
8247
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308248void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008249{
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8251 /* Register for all P2P action, public action etc frames */
8252 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8253
Jeff Johnsone7245742012-09-05 17:12:55 -07008254 ENTER();
8255
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 /* Right now we are registering these frame when driver is getting
8257 initialized. Once we will move to 2.6.37 kernel, in which we have
8258 frame register ops, we will move this code as a part of that */
8259 /* GAS Initial Request */
8260
8261 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8262 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8263
8264 /* GAS Initial Response */
8265 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8266 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308267
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 /* GAS Comeback Request */
8269 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8270 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8271
8272 /* GAS Comeback Response */
8273 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8274 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8275
8276 /* P2P Public Action */
8277 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308278 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 P2P_PUBLIC_ACTION_FRAME_SIZE );
8280
8281 /* P2P Action */
8282 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8283 (v_U8_t*)P2P_ACTION_FRAME,
8284 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008285 /* WNM-Notification */
8286 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8287 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8288 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008289}
8290
8291#ifdef FEATURE_WLAN_WAPI
8292void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308293 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008294{
8295 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8296 tCsrRoamSetKey setKey;
8297 v_BOOL_t isConnected = TRUE;
8298 int status = 0;
8299 v_U32_t roamId= 0xFF;
8300 tANI_U8 *pKeyPtr = NULL;
8301 int n = 0;
8302
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308303 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8304 __func__, hdd_device_modetoString(pAdapter->device_mode),
8305 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008306
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308307 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 setKey.keyId = key_index; // Store Key ID
8309 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8310 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8311 setKey.paeRole = 0 ; // the PAE role
8312 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8313 {
8314 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8315 }
8316 else
8317 {
8318 isConnected = hdd_connIsConnected(pHddStaCtx);
8319 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8320 }
8321 setKey.keyLength = key_Len;
8322 pKeyPtr = setKey.Key;
8323 memcpy( pKeyPtr, key, key_Len);
8324
Arif Hussain6d2a3322013-11-17 19:50:10 -08008325 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 __func__, key_Len);
8327 for (n = 0 ; n < key_Len; n++)
8328 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8329 __func__,n,setKey.Key[n]);
8330
8331 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8332 if ( isConnected )
8333 {
8334 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8335 pAdapter->sessionId, &setKey, &roamId );
8336 }
8337 if ( status != 0 )
8338 {
8339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8340 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8341 __LINE__, status );
8342 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8343 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308344 /* Need to clear any trace of key value in the memory.
8345 * Thus zero out the memory even though it is local
8346 * variable.
8347 */
8348 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008349}
8350#endif /* FEATURE_WLAN_WAPI*/
8351
8352#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308353int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 beacon_data_t **ppBeacon,
8355 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008356#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308357int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008358 beacon_data_t **ppBeacon,
8359 struct cfg80211_beacon_data *params,
8360 int dtim_period)
8361#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308362{
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 int size;
8364 beacon_data_t *beacon = NULL;
8365 beacon_data_t *old = NULL;
8366 int head_len,tail_len;
8367
Jeff Johnsone7245742012-09-05 17:12:55 -07008368 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308370 {
8371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8372 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008375
8376 old = pAdapter->sessionCtx.ap.beacon;
8377
8378 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308379 {
8380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8381 FL("session(%d) old and new heads points to NULL"),
8382 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308384 }
8385
8386 if (params->tail && !params->tail_len)
8387 {
8388 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8389 FL("tail_len is zero but tail is not NULL"));
8390 return -EINVAL;
8391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008392
Jeff Johnson295189b2012-06-20 16:38:30 -07008393#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8394 /* Kernel 3.0 is not updating dtim_period for set beacon */
8395 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308396 {
8397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8398 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008401#endif
8402
8403 if(params->head)
8404 head_len = params->head_len;
8405 else
8406 head_len = old->head_len;
8407
8408 if(params->tail || !old)
8409 tail_len = params->tail_len;
8410 else
8411 tail_len = old->tail_len;
8412
8413 size = sizeof(beacon_data_t) + head_len + tail_len;
8414
8415 beacon = kzalloc(size, GFP_KERNEL);
8416
8417 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308418 {
8419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8420 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008423
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008424#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 if(params->dtim_period || !old )
8426 beacon->dtim_period = params->dtim_period;
8427 else
8428 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008429#else
8430 if(dtim_period || !old )
8431 beacon->dtim_period = dtim_period;
8432 else
8433 beacon->dtim_period = old->dtim_period;
8434#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308435
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8437 beacon->tail = beacon->head + head_len;
8438 beacon->head_len = head_len;
8439 beacon->tail_len = tail_len;
8440
8441 if(params->head) {
8442 memcpy (beacon->head,params->head,beacon->head_len);
8443 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308444 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 if(old)
8446 memcpy (beacon->head,old->head,beacon->head_len);
8447 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308448
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 if(params->tail) {
8450 memcpy (beacon->tail,params->tail,beacon->tail_len);
8451 }
8452 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308453 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 memcpy (beacon->tail,old->tail,beacon->tail_len);
8455 }
8456
8457 *ppBeacon = beacon;
8458
8459 kfree(old);
8460
8461 return 0;
8462
8463}
Jeff Johnson295189b2012-06-20 16:38:30 -07008464
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308465v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8466#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8467 const v_U8_t *pIes,
8468#else
8469 v_U8_t *pIes,
8470#endif
8471 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008472{
8473 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308474 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308476
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308478 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 elem_id = ptr[0];
8480 elem_len = ptr[1];
8481 left -= 2;
8482 if(elem_len > left)
8483 {
8484 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008485 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 eid,elem_len,left);
8487 return NULL;
8488 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308489 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 {
8491 return ptr;
8492 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308493
Jeff Johnson295189b2012-06-20 16:38:30 -07008494 left -= elem_len;
8495 ptr += (elem_len + 2);
8496 }
8497 return NULL;
8498}
8499
Jeff Johnson295189b2012-06-20 16:38:30 -07008500/* Check if rate is 11g rate or not */
8501static int wlan_hdd_rate_is_11g(u8 rate)
8502{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008503 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 u8 i;
8505 for (i = 0; i < 8; i++)
8506 {
8507 if(rate == gRateArray[i])
8508 return TRUE;
8509 }
8510 return FALSE;
8511}
8512
8513/* Check for 11g rate and set proper 11g only mode */
8514static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8515 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8516{
8517 u8 i, num_rates = pIe[0];
8518
8519 pIe += 1;
8520 for ( i = 0; i < num_rates; i++)
8521 {
8522 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8523 {
8524 /* If rate set have 11g rate than change the mode to 11G */
8525 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8526 if (pIe[i] & BASIC_RATE_MASK)
8527 {
8528 /* If we have 11g rate as basic rate, it means mode
8529 is 11g only mode.
8530 */
8531 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8532 *pCheckRatesfor11g = FALSE;
8533 }
8534 }
8535 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8536 {
8537 *require_ht = TRUE;
8538 }
8539 }
8540 return;
8541}
8542
8543static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8544{
8545 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8546 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8547 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8548 u8 checkRatesfor11g = TRUE;
8549 u8 require_ht = FALSE;
8550 u8 *pIe=NULL;
8551
8552 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8553
8554 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8555 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8556 if (pIe != NULL)
8557 {
8558 pIe += 1;
8559 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8560 &pConfig->SapHw_mode);
8561 }
8562
8563 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8564 WLAN_EID_EXT_SUPP_RATES);
8565 if (pIe != NULL)
8566 {
8567
8568 pIe += 1;
8569 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8570 &pConfig->SapHw_mode);
8571 }
8572
8573 if( pConfig->channel > 14 )
8574 {
8575 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8576 }
8577
8578 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8579 WLAN_EID_HT_CAPABILITY);
8580
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308581 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 {
8583 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8584 if(require_ht)
8585 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8586 }
8587}
8588
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308589static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8590 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8591{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008592 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308593 v_U8_t *pIe = NULL;
8594 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8595
8596 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8597 pBeacon->tail, pBeacon->tail_len);
8598
8599 if (pIe)
8600 {
8601 ielen = pIe[1] + 2;
8602 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8603 {
8604 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8605 }
8606 else
8607 {
8608 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8609 return -EINVAL;
8610 }
8611 *total_ielen += ielen;
8612 }
8613 return 0;
8614}
8615
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008616static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8617 v_U8_t *genie, v_U8_t *total_ielen)
8618{
8619 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8620 int left = pBeacon->tail_len;
8621 v_U8_t *ptr = pBeacon->tail;
8622 v_U8_t elem_id, elem_len;
8623 v_U16_t ielen = 0;
8624
8625 if ( NULL == ptr || 0 == left )
8626 return;
8627
8628 while (left >= 2)
8629 {
8630 elem_id = ptr[0];
8631 elem_len = ptr[1];
8632 left -= 2;
8633 if (elem_len > left)
8634 {
8635 hddLog( VOS_TRACE_LEVEL_ERROR,
8636 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8637 elem_id, elem_len, left);
8638 return;
8639 }
8640 if (IE_EID_VENDOR == elem_id)
8641 {
8642 /* skipping the VSIE's which we don't want to include or
8643 * it will be included by existing code
8644 */
8645 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8646#ifdef WLAN_FEATURE_WFD
8647 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8648#endif
8649 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8650 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8651 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8652 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8653 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8654 {
8655 ielen = ptr[1] + 2;
8656 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8657 {
8658 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8659 *total_ielen += ielen;
8660 }
8661 else
8662 {
8663 hddLog( VOS_TRACE_LEVEL_ERROR,
8664 "IE Length is too big "
8665 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8666 elem_id, elem_len, *total_ielen);
8667 }
8668 }
8669 }
8670
8671 left -= elem_len;
8672 ptr += (elem_len + 2);
8673 }
8674 return;
8675}
8676
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008677#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008678static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8679 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008680#else
8681static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8682 struct cfg80211_beacon_data *params)
8683#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008684{
8685 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308686 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008688 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008689
8690 genie = vos_mem_malloc(MAX_GENIE_LEN);
8691
8692 if(genie == NULL) {
8693
8694 return -ENOMEM;
8695 }
8696
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308697 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8698 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308700 hddLog(LOGE,
8701 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308702 ret = -EINVAL;
8703 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 }
8705
8706#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308707 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8708 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8709 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308710 hddLog(LOGE,
8711 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308712 ret = -EINVAL;
8713 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 }
8715#endif
8716
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308717 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8718 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308720 hddLog(LOGE,
8721 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308722 ret = -EINVAL;
8723 goto done;
8724 }
8725
8726 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8727 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008728 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008730
8731 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8732 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8733 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8734 {
8735 hddLog(LOGE,
8736 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008737 ret = -EINVAL;
8738 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 }
8740
8741 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8742 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8743 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8744 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8745 ==eHAL_STATUS_FAILURE)
8746 {
8747 hddLog(LOGE,
8748 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008749 ret = -EINVAL;
8750 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 }
8752
8753 // Added for ProResp IE
8754 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
8755 {
8756 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
8757 u8 probe_rsp_ie_len[3] = {0};
8758 u8 counter = 0;
8759 /* Check Probe Resp Length if it is greater then 255 then Store
8760 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8761 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8762 Store More then 255 bytes into One Variable.
8763 */
8764 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8765 {
8766 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8767 {
8768 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8769 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8770 }
8771 else
8772 {
8773 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8774 rem_probe_resp_ie_len = 0;
8775 }
8776 }
8777
8778 rem_probe_resp_ie_len = 0;
8779
8780 if (probe_rsp_ie_len[0] > 0)
8781 {
8782 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8783 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
8784 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8785 probe_rsp_ie_len[0], NULL,
8786 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8787 {
8788 hddLog(LOGE,
8789 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008790 ret = -EINVAL;
8791 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008792 }
8793 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8794 }
8795
8796 if (probe_rsp_ie_len[1] > 0)
8797 {
8798 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8799 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
8800 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8801 probe_rsp_ie_len[1], NULL,
8802 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8803 {
8804 hddLog(LOGE,
8805 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008806 ret = -EINVAL;
8807 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 }
8809 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8810 }
8811
8812 if (probe_rsp_ie_len[2] > 0)
8813 {
8814 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8815 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
8816 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8817 probe_rsp_ie_len[2], NULL,
8818 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8819 {
8820 hddLog(LOGE,
8821 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008822 ret = -EINVAL;
8823 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 }
8825 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8826 }
8827
8828 if (probe_rsp_ie_len[1] == 0 )
8829 {
8830 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8831 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8832 eANI_BOOLEAN_FALSE) )
8833 {
8834 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008835 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 }
8837 }
8838
8839 if (probe_rsp_ie_len[2] == 0 )
8840 {
8841 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8842 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8843 eANI_BOOLEAN_FALSE) )
8844 {
8845 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008846 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 }
8848 }
8849
8850 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8851 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8852 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8853 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8854 == eHAL_STATUS_FAILURE)
8855 {
8856 hddLog(LOGE,
8857 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008858 ret = -EINVAL;
8859 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 }
8861 }
8862 else
8863 {
8864 // Reset WNI_CFG_PROBE_RSP Flags
8865 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8866
8867 hddLog(VOS_TRACE_LEVEL_INFO,
8868 "%s: No Probe Response IE received in set beacon",
8869 __func__);
8870 }
8871
8872 // Added for AssocResp IE
8873 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
8874 {
8875 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8876 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
8877 params->assocresp_ies_len, NULL,
8878 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8879 {
8880 hddLog(LOGE,
8881 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008882 ret = -EINVAL;
8883 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 }
8885
8886 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8887 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8888 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8889 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8890 == eHAL_STATUS_FAILURE)
8891 {
8892 hddLog(LOGE,
8893 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008894 ret = -EINVAL;
8895 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 }
8897 }
8898 else
8899 {
8900 hddLog(VOS_TRACE_LEVEL_INFO,
8901 "%s: No Assoc Response IE received in set beacon",
8902 __func__);
8903
8904 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8905 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8906 eANI_BOOLEAN_FALSE) )
8907 {
8908 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008909 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 }
8911 }
8912
Jeff Johnsone7245742012-09-05 17:12:55 -07008913done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308915 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008916}
Jeff Johnson295189b2012-06-20 16:38:30 -07008917
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308918/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 * FUNCTION: wlan_hdd_validate_operation_channel
8920 * called by wlan_hdd_cfg80211_start_bss() and
8921 * wlan_hdd_cfg80211_set_channel()
8922 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308923 * channel list.
8924 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008925VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008926{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308927
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 v_U32_t num_ch = 0;
8929 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8930 u32 indx = 0;
8931 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308932 v_U8_t fValidChannel = FALSE, count = 0;
8933 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308934
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8936
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308937 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308939 /* Validate the channel */
8940 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308942 if ( channel == rfChannels[count].channelNum )
8943 {
8944 fValidChannel = TRUE;
8945 break;
8946 }
8947 }
8948 if (fValidChannel != TRUE)
8949 {
8950 hddLog(VOS_TRACE_LEVEL_ERROR,
8951 "%s: Invalid Channel [%d]", __func__, channel);
8952 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008953 }
8954 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308955 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308957 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8958 valid_ch, &num_ch))
8959 {
8960 hddLog(VOS_TRACE_LEVEL_ERROR,
8961 "%s: failed to get valid channel list", __func__);
8962 return VOS_STATUS_E_FAILURE;
8963 }
8964 for (indx = 0; indx < num_ch; indx++)
8965 {
8966 if (channel == valid_ch[indx])
8967 {
8968 break;
8969 }
8970 }
8971
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308972 if (indx >= num_ch)
8973 {
8974 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8975 {
8976 eCsrBand band;
8977 unsigned int freq;
8978
8979 sme_GetFreqBand(hHal, &band);
8980
8981 if (eCSR_BAND_5G == band)
8982 {
8983#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8984 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8985 {
8986 freq = ieee80211_channel_to_frequency(channel,
8987 IEEE80211_BAND_2GHZ);
8988 }
8989 else
8990 {
8991 freq = ieee80211_channel_to_frequency(channel,
8992 IEEE80211_BAND_5GHZ);
8993 }
8994#else
8995 freq = ieee80211_channel_to_frequency(channel);
8996#endif
8997 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8998 return VOS_STATUS_SUCCESS;
8999 }
9000 }
9001
9002 hddLog(VOS_TRACE_LEVEL_ERROR,
9003 "%s: Invalid Channel [%d]", __func__, channel);
9004 return VOS_STATUS_E_FAILURE;
9005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009006 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05309007
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309009
Jeff Johnson295189b2012-06-20 16:38:30 -07009010}
9011
Viral Modi3a32cc52013-02-08 11:14:52 -08009012/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309013 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08009014 * This function is used to set the channel number
9015 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309016static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08009017 struct ieee80211_channel *chan,
9018 enum nl80211_channel_type channel_type
9019 )
9020{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309021 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08009022 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07009023 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08009024 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309025 hdd_context_t *pHddCtx;
9026 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009027
9028 ENTER();
9029
9030 if( NULL == dev )
9031 {
9032 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009033 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009034 return -ENODEV;
9035 }
9036 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309037
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309038 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9039 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9040 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009041 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309042 "%s: device_mode = %s (%d) freq = %d", __func__,
9043 hdd_device_modetoString(pAdapter->device_mode),
9044 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309045
9046 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9047 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309048 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009049 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309050 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009051 }
9052
9053 /*
9054 * Do freq to chan conversion
9055 * TODO: for 11a
9056 */
9057
9058 channel = ieee80211_frequency_to_channel(freq);
9059
9060 /* Check freq range */
9061 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9062 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9063 {
9064 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009065 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009066 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9067 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9068 return -EINVAL;
9069 }
9070
9071 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9072
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309073 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9074 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009075 {
9076 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9077 {
9078 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009079 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009080 return -EINVAL;
9081 }
9082 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9083 "%s: set channel to [%d] for device mode =%d",
9084 __func__, channel,pAdapter->device_mode);
9085 }
9086 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009087 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009088 )
9089 {
9090 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9091 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9092 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9093
9094 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9095 {
9096 /* Link is up then return cant set channel*/
9097 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009098 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009099 return -EINVAL;
9100 }
9101
9102 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9103 pHddStaCtx->conn_info.operationChannel = channel;
9104 pRoamProfile->ChannelInfo.ChannelList =
9105 &pHddStaCtx->conn_info.operationChannel;
9106 }
9107 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009108 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009109 )
9110 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309111 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9112 {
9113 if(VOS_STATUS_SUCCESS !=
9114 wlan_hdd_validate_operation_channel(pAdapter,channel))
9115 {
9116 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009117 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309118 return -EINVAL;
9119 }
9120 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9121 }
9122 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009123 {
9124 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9125
9126 /* If auto channel selection is configured as enable/ 1 then ignore
9127 channel set by supplicant
9128 */
9129 if ( cfg_param->apAutoChannelSelection )
9130 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309131 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9132 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009133 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309134 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9135 __func__, hdd_device_modetoString(pAdapter->device_mode),
9136 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009137 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309138 else
9139 {
9140 if(VOS_STATUS_SUCCESS !=
9141 wlan_hdd_validate_operation_channel(pAdapter,channel))
9142 {
9143 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009144 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309145 return -EINVAL;
9146 }
9147 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9148 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009149 }
9150 }
9151 else
9152 {
9153 hddLog(VOS_TRACE_LEVEL_FATAL,
9154 "%s: Invalid device mode failed to set valid channel", __func__);
9155 return -EINVAL;
9156 }
9157 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309158 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009159}
9160
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309161static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9162 struct net_device *dev,
9163 struct ieee80211_channel *chan,
9164 enum nl80211_channel_type channel_type
9165 )
9166{
9167 int ret;
9168
9169 vos_ssr_protect(__func__);
9170 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9171 vos_ssr_unprotect(__func__);
9172
9173 return ret;
9174}
9175
Jeff Johnson295189b2012-06-20 16:38:30 -07009176#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9177static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9178 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009179#else
9180static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9181 struct cfg80211_beacon_data *params,
9182 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309183 enum nl80211_hidden_ssid hidden_ssid,
9184 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009185#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009186{
9187 tsap_Config_t *pConfig;
9188 beacon_data_t *pBeacon = NULL;
9189 struct ieee80211_mgmt *pMgmt_frame;
9190 v_U8_t *pIe=NULL;
9191 v_U16_t capab_info;
9192 eCsrAuthType RSNAuthType;
9193 eCsrEncryptionType RSNEncryptType;
9194 eCsrEncryptionType mcRSNEncryptType;
9195 int status = VOS_STATUS_SUCCESS;
9196 tpWLAN_SAPEventCB pSapEventCallback;
9197 hdd_hostapd_state_t *pHostapdState;
9198 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
9199 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309200 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309202 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009204 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309205 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009206 v_BOOL_t MFPCapable = VOS_FALSE;
9207 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309208 v_BOOL_t sapEnable11AC =
9209 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 ENTER();
9211
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309212 iniConfig = pHddCtx->cfg_ini;
9213
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9215
9216 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9217
9218 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9219
9220 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9221
9222 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9223
9224 //channel is already set in the set_channel Call back
9225 //pConfig->channel = pCommitConfig->channel;
9226
9227 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309228 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9230
9231 pConfig->dtim_period = pBeacon->dtim_period;
9232
Arif Hussain6d2a3322013-11-17 19:50:10 -08009233 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 pConfig->dtim_period);
9235
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009236 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009237 {
9238 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309240 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9241 {
9242 tANI_BOOLEAN restartNeeded;
9243 pConfig->ieee80211d = 1;
9244 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9245 sme_setRegInfo(hHal, pConfig->countryCode);
9246 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9247 }
9248 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009250 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009251 pConfig->ieee80211d = 1;
9252 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9253 sme_setRegInfo(hHal, pConfig->countryCode);
9254 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009256 else
9257 {
9258 pConfig->ieee80211d = 0;
9259 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309260 /*
9261 * If auto channel is configured i.e. channel is 0,
9262 * so skip channel validation.
9263 */
9264 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9265 {
9266 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9267 {
9268 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009269 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309270 return -EINVAL;
9271 }
9272 }
9273 else
9274 {
9275 if(1 != pHddCtx->is_dynamic_channel_range_set)
9276 {
9277 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9278 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9279 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9280 }
9281 pHddCtx->is_dynamic_channel_range_set = 0;
9282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009284 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 {
9286 pConfig->ieee80211d = 0;
9287 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309288
9289#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9290 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9291 pConfig->authType = eSAP_OPEN_SYSTEM;
9292 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9293 pConfig->authType = eSAP_SHARED_KEY;
9294 else
9295 pConfig->authType = eSAP_AUTO_SWITCH;
9296#else
9297 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9298 pConfig->authType = eSAP_OPEN_SYSTEM;
9299 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9300 pConfig->authType = eSAP_SHARED_KEY;
9301 else
9302 pConfig->authType = eSAP_AUTO_SWITCH;
9303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009304
9305 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309306
9307 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009308 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05309309#ifdef SAP_AUTH_OFFLOAD
9310 /* In case of sap offload, hostapd.conf is configuted with open mode and
9311 * security is configured from ini file. Due to open mode in hostapd.conf
9312 * privacy bit is set to false which will result in not sending,
9313 * data packets as encrypted.
9314 * If enable_sap_auth_offload is enabled in ini and
9315 * sap_auth_offload_sec_type is type of WPA2-PSK,
9316 * driver will set privacy bit to 1.
9317 */
9318 if (pHddCtx->cfg_ini->enable_sap_auth_offload &&
9319 pHddCtx->cfg_ini->sap_auth_offload_sec_type)
9320 pConfig->privacy = VOS_TRUE;
9321#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009322
9323 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9324
9325 /*Set wps station to configured*/
9326 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9327
9328 if(pIe)
9329 {
9330 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9331 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009332 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 return -EINVAL;
9334 }
9335 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9336 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009337 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 /* Check 15 bit of WPS IE as it contain information for wps state
9339 * WPS state
9340 */
9341 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9342 {
9343 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9344 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9345 {
9346 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9347 }
9348 }
9349 }
9350 else
9351 {
9352 pConfig->wps_state = SAP_WPS_DISABLED;
9353 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309354 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009355
c_hpothufe599e92014-06-16 11:38:55 +05309356 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9357 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9358 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9359 eCSR_ENCRYPT_TYPE_NONE;
9360
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 pConfig->RSNWPAReqIELength = 0;
9362 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309363 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 WLAN_EID_RSN);
9365 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309366 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9368 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9369 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309370 /* The actual processing may eventually be more extensive than
9371 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 * by the app.
9373 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309374 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9376 &RSNEncryptType,
9377 &mcRSNEncryptType,
9378 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009379 &MFPCapable,
9380 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009381 pConfig->pRSNWPAReqIE[1]+2,
9382 pConfig->pRSNWPAReqIE );
9383
9384 if( VOS_STATUS_SUCCESS == status )
9385 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309386 /* Now copy over all the security attributes you have
9387 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009388 * */
9389 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9390 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9391 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9392 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309393 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009394 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9396 }
9397 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309398
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9400 pBeacon->tail, pBeacon->tail_len);
9401
9402 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9403 {
9404 if (pConfig->pRSNWPAReqIE)
9405 {
9406 /*Mixed mode WPA/WPA2*/
9407 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
9408 pConfig->RSNWPAReqIELength += pIe[1] + 2;
9409 }
9410 else
9411 {
9412 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9413 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9414 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309415 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9417 &RSNEncryptType,
9418 &mcRSNEncryptType,
9419 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009420 &MFPCapable,
9421 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 pConfig->pRSNWPAReqIE[1]+2,
9423 pConfig->pRSNWPAReqIE );
9424
9425 if( VOS_STATUS_SUCCESS == status )
9426 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309427 /* Now copy over all the security attributes you have
9428 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 * */
9430 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9431 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9432 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9433 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309434 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009435 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9437 }
9438 }
9439 }
9440
Jeff Johnson4416a782013-03-25 14:17:50 -07009441 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
9442 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9443 return -EINVAL;
9444 }
9445
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9447
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009448#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 if (params->ssid != NULL)
9450 {
9451 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9452 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9453 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9454 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9455 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009456#else
9457 if (ssid != NULL)
9458 {
9459 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9460 pConfig->SSIDinfo.ssid.length = ssid_len;
9461 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9462 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9463 }
9464#endif
9465
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309466 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309468
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 /* default value */
9470 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9471 pConfig->num_accept_mac = 0;
9472 pConfig->num_deny_mac = 0;
9473
9474 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9475 pBeacon->tail, pBeacon->tail_len);
9476
9477 /* pIe for black list is following form:
9478 type : 1 byte
9479 length : 1 byte
9480 OUI : 4 bytes
9481 acl type : 1 byte
9482 no of mac addr in black list: 1 byte
9483 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309484 */
9485 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 {
9487 pConfig->SapMacaddr_acl = pIe[6];
9488 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009489 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309491 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9492 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9494 for (i = 0; i < pConfig->num_deny_mac; i++)
9495 {
9496 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9497 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 }
9500 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9501 pBeacon->tail, pBeacon->tail_len);
9502
9503 /* pIe for white list is following form:
9504 type : 1 byte
9505 length : 1 byte
9506 OUI : 4 bytes
9507 acl type : 1 byte
9508 no of mac addr in white list: 1 byte
9509 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309510 */
9511 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 {
9513 pConfig->SapMacaddr_acl = pIe[6];
9514 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009515 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309517 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9518 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9520 for (i = 0; i < pConfig->num_accept_mac; i++)
9521 {
9522 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9523 acl_entry++;
9524 }
9525 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309526
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9528
Jeff Johnsone7245742012-09-05 17:12:55 -07009529#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009530 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309531 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9532 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309533 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9534 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009535 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9536 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309537 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9538 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009539 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309540 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009541 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309542 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009543
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309544 /* If ACS disable and selected channel <= 14
9545 * OR
9546 * ACS enabled and ACS operating band is choosen as 2.4
9547 * AND
9548 * VHT in 2.4G Disabled
9549 * THEN
9550 * Fallback to 11N mode
9551 */
9552 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9553 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309554 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309555 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009556 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309557 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9558 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009559 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9560 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009561 }
9562#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309563
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 // ht_capab is not what the name conveys,this is used for protection bitmap
9565 pConfig->ht_capab =
9566 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9567
9568 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9569 {
9570 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9571 return -EINVAL;
9572 }
9573
9574 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309575 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9577 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309578 pConfig->obssProtEnabled =
9579 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009580
Chet Lanctot8cecea22014-02-11 19:09:36 -08009581#ifdef WLAN_FEATURE_11W
9582 pConfig->mfpCapable = MFPCapable;
9583 pConfig->mfpRequired = MFPRequired;
9584 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9585 pConfig->mfpCapable, pConfig->mfpRequired);
9586#endif
9587
Arif Hussain6d2a3322013-11-17 19:50:10 -08009588 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009590 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9591 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9592 (int)pConfig->channel);
9593 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9594 pConfig->SapHw_mode, pConfig->privacy,
9595 pConfig->authType);
9596 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9597 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9598 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9599 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009600
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309601 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 {
9603 //Bss already started. just return.
9604 //TODO Probably it should update some beacon params.
9605 hddLog( LOGE, "Bss Already started...Ignore the request");
9606 EXIT();
9607 return 0;
9608 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309609
Agarwal Ashish51325b52014-06-16 16:50:49 +05309610 if (vos_max_concurrent_connections_reached()) {
9611 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9612 return -EINVAL;
9613 }
9614
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 pConfig->persona = pHostapdAdapter->device_mode;
9616
Peng Xu2446a892014-09-05 17:21:18 +05309617 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9618 if ( NULL != psmeConfig)
9619 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309620 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309621 sme_GetConfigParam(hHal, psmeConfig);
9622 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309623#ifdef WLAN_FEATURE_AP_HT40_24G
9624 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9625 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9626 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9627 {
9628 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9629 sme_UpdateConfig (hHal, psmeConfig);
9630 }
9631#endif
Peng Xu2446a892014-09-05 17:21:18 +05309632 vos_mem_free(psmeConfig);
9633 }
Peng Xuafc34e32014-09-25 13:23:55 +05309634 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309635
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 pSapEventCallback = hdd_hostapd_SAPEventCB;
9637 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9638 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9639 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009640 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 return -EINVAL;
9642 }
9643
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309644 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9646
9647 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309650 {
9651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009652 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009653 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009654 VOS_ASSERT(0);
9655 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309656
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309658 /* Initialize WMM configuation */
9659 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309660 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009661
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009662#ifdef WLAN_FEATURE_P2P_DEBUG
9663 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9664 {
9665 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9666 {
9667 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9668 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009669 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009670 }
9671 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9672 {
9673 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9674 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009675 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009676 }
9677 }
9678#endif
9679
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 pHostapdState->bCommit = TRUE;
9681 EXIT();
9682
9683 return 0;
9684}
9685
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009686#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309687static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309688 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 struct beacon_parameters *params)
9690{
9691 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309692 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309693 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009694
9695 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309696
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309697 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9698 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9699 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309700 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9701 hdd_device_modetoString(pAdapter->device_mode),
9702 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009703
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309704 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9705 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309706 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009707 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309708 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009709 }
9710
Agarwal Ashish51325b52014-06-16 16:50:49 +05309711 if (vos_max_concurrent_connections_reached()) {
9712 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9713 return -EINVAL;
9714 }
9715
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309716 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 )
9719 {
9720 beacon_data_t *old,*new;
9721
9722 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309723
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309725 {
9726 hddLog(VOS_TRACE_LEVEL_WARN,
9727 FL("already beacon info added to session(%d)"),
9728 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009729 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009731
9732 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9733
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309734 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 {
9736 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009737 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009738 return -EINVAL;
9739 }
9740
9741 pAdapter->sessionCtx.ap.beacon = new;
9742
9743 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9744 }
9745
9746 EXIT();
9747 return status;
9748}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309749
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309750static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9751 struct net_device *dev,
9752 struct beacon_parameters *params)
9753{
9754 int ret;
9755
9756 vos_ssr_protect(__func__);
9757 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9758 vos_ssr_unprotect(__func__);
9759
9760 return ret;
9761}
9762
9763static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 struct net_device *dev,
9765 struct beacon_parameters *params)
9766{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309767 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309768 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9769 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309770 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009771
9772 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309773
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309774 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9775 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9776 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9777 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9778 __func__, hdd_device_modetoString(pAdapter->device_mode),
9779 pAdapter->device_mode);
9780
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9782 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309783 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009784 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309785 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009786 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309787
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309788 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009789 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309790 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 {
9792 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309793
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309795
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309797 {
9798 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9799 FL("session(%d) old and new heads points to NULL"),
9800 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009803
9804 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9805
9806 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309807 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009808 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009809 return -EINVAL;
9810 }
9811
9812 pAdapter->sessionCtx.ap.beacon = new;
9813
9814 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9815 }
9816
9817 EXIT();
9818 return status;
9819}
9820
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309821static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
9822 struct net_device *dev,
9823 struct beacon_parameters *params)
9824{
9825 int ret;
9826
9827 vos_ssr_protect(__func__);
9828 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
9829 vos_ssr_unprotect(__func__);
9830
9831 return ret;
9832}
9833
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009834#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9835
9836#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309837static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009839#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309840static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009841 struct net_device *dev)
9842#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009843{
9844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07009845 hdd_context_t *pHddCtx = NULL;
9846 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309847 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309848 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009849
9850 ENTER();
9851
9852 if (NULL == pAdapter)
9853 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009855 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 return -ENODEV;
9857 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009858
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309859 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9860 TRACE_CODE_HDD_CFG80211_STOP_AP,
9861 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309862 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9863 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309864 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009865 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309866 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07009867 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009868
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009869 pScanInfo = &pHddCtx->scan_info;
9870
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309871 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9872 __func__, hdd_device_modetoString(pAdapter->device_mode),
9873 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009874
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309875 ret = wlan_hdd_scan_abort(pAdapter);
9876
Girish Gowli4bf7a632014-06-12 13:42:11 +05309877 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07009878 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309879 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9880 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309881
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309882 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07009883 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9885 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08009886
Jeff Johnsone7245742012-09-05 17:12:55 -07009887 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309888 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07009889 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309890 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009891 }
9892
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309893 /* Delete all associated STAs before stopping AP/P2P GO */
9894 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05309895 hdd_hostapd_stop(dev);
9896
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 )
9900 {
9901 beacon_data_t *old;
9902
9903 old = pAdapter->sessionCtx.ap.beacon;
9904
9905 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309906 {
9907 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9908 FL("session(%d) beacon data points to NULL"),
9909 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009912
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009914
9915 mutex_lock(&pHddCtx->sap_lock);
9916 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9917 {
Jeff Johnson4416a782013-03-25 14:17:50 -07009918 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 {
9920 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9921
9922 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
9923
9924 if (!VOS_IS_STATUS_SUCCESS(status))
9925 {
9926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009927 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309929 }
9930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309932 /* BSS stopped, clear the active sessions for this device mode */
9933 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 }
9935 mutex_unlock(&pHddCtx->sap_lock);
9936
9937 if(status != VOS_STATUS_SUCCESS)
9938 {
9939 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009940 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 return -EINVAL;
9942 }
9943
Jeff Johnson4416a782013-03-25 14:17:50 -07009944 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
9946 ==eHAL_STATUS_FAILURE)
9947 {
9948 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009949 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 }
9951
Jeff Johnson4416a782013-03-25 14:17:50 -07009952 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9954 eANI_BOOLEAN_FALSE) )
9955 {
9956 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009957 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 }
9959
9960 // Reset WNI_CFG_PROBE_RSP Flags
9961 wlan_hdd_reset_prob_rspies(pAdapter);
9962
9963 pAdapter->sessionCtx.ap.beacon = NULL;
9964 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009965#ifdef WLAN_FEATURE_P2P_DEBUG
9966 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
9967 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
9968 {
9969 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
9970 "GO got removed");
9971 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
9972 }
9973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 }
9975 EXIT();
9976 return status;
9977}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009978
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309979#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9980static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
9981 struct net_device *dev)
9982{
9983 int ret;
9984
9985 vos_ssr_protect(__func__);
9986 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
9987 vos_ssr_unprotect(__func__);
9988
9989 return ret;
9990}
9991#else
9992static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
9993 struct net_device *dev)
9994{
9995 int ret;
9996
9997 vos_ssr_protect(__func__);
9998 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
9999 vos_ssr_unprotect(__func__);
10000
10001 return ret;
10002}
10003#endif
10004
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010005#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
10006
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010007static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010008 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010009 struct cfg80211_ap_settings *params)
10010{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010011 hdd_adapter_t *pAdapter;
10012 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010013 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010014
10015 ENTER();
10016
Girish Gowlib143d7a2015-02-18 19:39:55 +053010017 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010018 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010020 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010021 return -ENODEV;
10022 }
10023
10024 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10025 if (NULL == pAdapter)
10026 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010028 "%s: HDD adapter is Null", __func__);
10029 return -ENODEV;
10030 }
10031
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010032 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10033 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10034 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010035 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10036 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010038 "%s: HDD adapter magic is invalid", __func__);
10039 return -ENODEV;
10040 }
10041
10042 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010043 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010044 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010045 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010046 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010047 }
10048
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010049 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10050 __func__, hdd_device_modetoString(pAdapter->device_mode),
10051 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010052
10053 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010054 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010055 )
10056 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010057 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010058
10059 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010060
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010061 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010062 {
10063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10064 FL("already beacon info added to session(%d)"),
10065 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010066 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010067 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010068
Girish Gowlib143d7a2015-02-18 19:39:55 +053010069#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10070 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10071 &new,
10072 &params->beacon);
10073#else
10074 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10075 &new,
10076 &params->beacon,
10077 params->dtim_period);
10078#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010079
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010080 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010081 {
10082 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010083 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010084 return -EINVAL;
10085 }
10086 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010087#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010088 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10089#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10090 params->channel, params->channel_type);
10091#else
10092 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10093#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010094#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010095 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010096 params->ssid_len, params->hidden_ssid,
10097 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010098 }
10099
10100 EXIT();
10101 return status;
10102}
10103
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010104static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10105 struct net_device *dev,
10106 struct cfg80211_ap_settings *params)
10107{
10108 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010109
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010110 vos_ssr_protect(__func__);
10111 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10112 vos_ssr_unprotect(__func__);
10113
10114 return ret;
10115}
10116
10117static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010118 struct net_device *dev,
10119 struct cfg80211_beacon_data *params)
10120{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010122 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010123 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010124
10125 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010126
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010127 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10128 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10129 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010130 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010131 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010132
10133 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10134 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010135 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010136 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010137 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010138 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010139
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010140 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010141 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010142 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010143 {
10144 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010145
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010146 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010147
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010148 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010149 {
10150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10151 FL("session(%d) beacon data points to NULL"),
10152 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010153 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010154 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010155
10156 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10157
10158 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010159 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010160 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010161 return -EINVAL;
10162 }
10163
10164 pAdapter->sessionCtx.ap.beacon = new;
10165
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010166 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10167 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010168 }
10169
10170 EXIT();
10171 return status;
10172}
10173
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010174static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10175 struct net_device *dev,
10176 struct cfg80211_beacon_data *params)
10177{
10178 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010179
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010180 vos_ssr_protect(__func__);
10181 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10182 vos_ssr_unprotect(__func__);
10183
10184 return ret;
10185}
10186
10187#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010188
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010189static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010190 struct net_device *dev,
10191 struct bss_parameters *params)
10192{
10193 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010194 hdd_context_t *pHddCtx;
10195 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010196
10197 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010198
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010199 if (NULL == pAdapter)
10200 {
10201 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10202 "%s: HDD adapter is Null", __func__);
10203 return -ENODEV;
10204 }
10205 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010206 ret = wlan_hdd_validate_context(pHddCtx);
10207 if (0 != ret)
10208 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010209 return ret;
10210 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010211 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10212 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10213 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010214 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10215 __func__, hdd_device_modetoString(pAdapter->device_mode),
10216 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010217
10218 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010220 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 {
10222 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10223 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010224 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 {
10226 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 }
10229
10230 EXIT();
10231 return 0;
10232}
10233
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010234static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10235 struct net_device *dev,
10236 struct bss_parameters *params)
10237{
10238 int ret;
10239
10240 vos_ssr_protect(__func__);
10241 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10242 vos_ssr_unprotect(__func__);
10243
10244 return ret;
10245}
Kiet Lam10841362013-11-01 11:36:50 +053010246/* FUNCTION: wlan_hdd_change_country_code_cd
10247* to wait for contry code completion
10248*/
10249void* wlan_hdd_change_country_code_cb(void *pAdapter)
10250{
10251 hdd_adapter_t *call_back_pAdapter = pAdapter;
10252 complete(&call_back_pAdapter->change_country_code);
10253 return NULL;
10254}
10255
Jeff Johnson295189b2012-06-20 16:38:30 -070010256/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010257 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10259 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010260int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 struct net_device *ndev,
10262 enum nl80211_iftype type,
10263 u32 *flags,
10264 struct vif_params *params
10265 )
10266{
10267 struct wireless_dev *wdev;
10268 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010269 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010270 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 tCsrRoamProfile *pRoamProfile = NULL;
10272 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010273 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 eMib_dot11DesiredBssType connectedBssType;
10275 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010276 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010277
10278 ENTER();
10279
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010280 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010281 {
10282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10283 "%s: Adapter context is null", __func__);
10284 return VOS_STATUS_E_FAILURE;
10285 }
10286
10287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10288 if (!pHddCtx)
10289 {
10290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10291 "%s: HDD context is null", __func__);
10292 return VOS_STATUS_E_FAILURE;
10293 }
10294
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010295 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10296 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10297 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010298 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010299 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010301 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 }
10303
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010304 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10305 __func__, hdd_device_modetoString(pAdapter->device_mode),
10306 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010307
Agarwal Ashish51325b52014-06-16 16:50:49 +053010308 if (vos_max_concurrent_connections_reached()) {
10309 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10310 return -EINVAL;
10311 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010312 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010313 wdev = ndev->ieee80211_ptr;
10314
10315#ifdef WLAN_BTAMP_FEATURE
10316 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10317 (NL80211_IFTYPE_ADHOC == type)||
10318 (NL80211_IFTYPE_AP == type)||
10319 (NL80211_IFTYPE_P2P_GO == type))
10320 {
10321 pHddCtx->isAmpAllowed = VOS_FALSE;
10322 // stop AMP traffic
10323 status = WLANBAP_StopAmp();
10324 if(VOS_STATUS_SUCCESS != status )
10325 {
10326 pHddCtx->isAmpAllowed = VOS_TRUE;
10327 hddLog(VOS_TRACE_LEVEL_FATAL,
10328 "%s: Failed to stop AMP", __func__);
10329 return -EINVAL;
10330 }
10331 }
10332#endif //WLAN_BTAMP_FEATURE
10333 /* Reset the current device mode bit mask*/
10334 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10335
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010336 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10337 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10338 (type == NL80211_IFTYPE_P2P_GO)))
10339 {
10340 /* Notify Mode change in case of concurrency.
10341 * Below function invokes TDLS teardown Functionality Since TDLS is
10342 * not Supported in case of concurrency i.e Once P2P session
10343 * is detected disable offchannel and teardown TDLS links
10344 */
10345 hddLog(LOG1,
10346 FL("Device mode = %d Interface type = %d"),
10347 pAdapter->device_mode, type);
10348 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10349 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010350
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010353 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 )
10355 {
10356 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010357 if (!pWextState)
10358 {
10359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10360 "%s: pWextState is null", __func__);
10361 return VOS_STATUS_E_FAILURE;
10362 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010363 pRoamProfile = &pWextState->roamProfile;
10364 LastBSSType = pRoamProfile->BSSType;
10365
10366 switch (type)
10367 {
10368 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010369 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 hddLog(VOS_TRACE_LEVEL_INFO,
10371 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10372 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010373#ifdef WLAN_FEATURE_11AC
10374 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10375 {
10376 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10377 }
10378#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010379 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010380 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010381 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010382 //Check for sub-string p2p to confirm its a p2p interface
10383 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010384 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010385#ifdef FEATURE_WLAN_TDLS
10386 mutex_lock(&pHddCtx->tdls_lock);
10387 wlan_hdd_tdls_exit(pAdapter, TRUE);
10388 mutex_unlock(&pHddCtx->tdls_lock);
10389#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010390 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10391 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10392 }
10393 else
10394 {
10395 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010399
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 case NL80211_IFTYPE_ADHOC:
10401 hddLog(VOS_TRACE_LEVEL_INFO,
10402 "%s: setting interface Type to ADHOC", __func__);
10403 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10404 pRoamProfile->phyMode =
10405 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010406 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010408 hdd_set_ibss_ops( pAdapter );
10409 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010410
10411 status = hdd_sta_id_hash_attach(pAdapter);
10412 if (VOS_STATUS_SUCCESS != status) {
10413 hddLog(VOS_TRACE_LEVEL_ERROR,
10414 FL("Failed to initialize hash for IBSS"));
10415 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 break;
10417
10418 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 {
10421 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10422 "%s: setting interface Type to %s", __func__,
10423 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10424
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010425 //Cancel any remain on channel for GO mode
10426 if (NL80211_IFTYPE_P2P_GO == type)
10427 {
10428 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10429 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010430 if (NL80211_IFTYPE_AP == type)
10431 {
10432 /* As Loading WLAN Driver one interface being created for p2p device
10433 * address. This will take one HW STA and the max number of clients
10434 * that can connect to softAP will be reduced by one. so while changing
10435 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10436 * interface as it is not required in SoftAP mode.
10437 */
10438
10439 // Get P2P Adapter
10440 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10441
10442 if (pP2pAdapter)
10443 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010444 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010445 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010446 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10447 }
10448 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010449 //Disable IMPS & BMPS for SAP/GO
10450 if(VOS_STATUS_E_FAILURE ==
10451 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10452 {
10453 //Fail to Exit BMPS
10454 VOS_ASSERT(0);
10455 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010456
10457 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10458
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010459#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010460
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010461 /* A Mutex Lock is introduced while changing the mode to
10462 * protect the concurrent access for the Adapters by TDLS
10463 * module.
10464 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010465 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010468 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10471 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010472#ifdef FEATURE_WLAN_TDLS
10473 mutex_unlock(&pHddCtx->tdls_lock);
10474#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010475 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10476 (pConfig->apRandomBssidEnabled))
10477 {
10478 /* To meet Android requirements create a randomized
10479 MAC address of the form 02:1A:11:Fx:xx:xx */
10480 get_random_bytes(&ndev->dev_addr[3], 3);
10481 ndev->dev_addr[0] = 0x02;
10482 ndev->dev_addr[1] = 0x1A;
10483 ndev->dev_addr[2] = 0x11;
10484 ndev->dev_addr[3] |= 0xF0;
10485 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10486 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010487 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10488 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010489 }
10490
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 hdd_set_ap_ops( pAdapter->dev );
10492
Kiet Lam10841362013-11-01 11:36:50 +053010493 /* This is for only SAP mode where users can
10494 * control country through ini.
10495 * P2P GO follows station country code
10496 * acquired during the STA scanning. */
10497 if((NL80211_IFTYPE_AP == type) &&
10498 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10499 {
10500 int status = 0;
10501 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10502 "%s: setting country code from INI ", __func__);
10503 init_completion(&pAdapter->change_country_code);
10504 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10505 (void *)(tSmeChangeCountryCallback)
10506 wlan_hdd_change_country_code_cb,
10507 pConfig->apCntryCode, pAdapter,
10508 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010509 eSIR_FALSE,
10510 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010511 if (eHAL_STATUS_SUCCESS == status)
10512 {
10513 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010514 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010515 &pAdapter->change_country_code,
10516 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010517 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010518 {
10519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010520 FL("SME Timed out while setting country code %ld"),
10521 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010522
10523 if (pHddCtx->isLogpInProgress)
10524 {
10525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10526 "%s: LOGP in Progress. Ignore!!!", __func__);
10527 return -EAGAIN;
10528 }
Kiet Lam10841362013-11-01 11:36:50 +053010529 }
10530 }
10531 else
10532 {
10533 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010534 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010535 return -EINVAL;
10536 }
10537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 status = hdd_init_ap_mode(pAdapter);
10539 if(status != VOS_STATUS_SUCCESS)
10540 {
10541 hddLog(VOS_TRACE_LEVEL_FATAL,
10542 "%s: Error initializing the ap mode", __func__);
10543 return -EINVAL;
10544 }
10545 hdd_set_conparam(1);
10546
Nirav Shah7e3c8132015-06-22 23:51:42 +053010547 status = hdd_sta_id_hash_attach(pAdapter);
10548 if (VOS_STATUS_SUCCESS != status)
10549 {
10550 hddLog(VOS_TRACE_LEVEL_ERROR,
10551 FL("Failed to initialize hash for AP"));
10552 return -EINVAL;
10553 }
10554
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 /*interface type changed update in wiphy structure*/
10556 if(wdev)
10557 {
10558 wdev->iftype = type;
10559 pHddCtx->change_iface = type;
10560 }
10561 else
10562 {
10563 hddLog(VOS_TRACE_LEVEL_ERROR,
10564 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10565 return -EINVAL;
10566 }
10567 goto done;
10568 }
10569
10570 default:
10571 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10572 __func__);
10573 return -EOPNOTSUPP;
10574 }
10575 }
10576 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 )
10579 {
10580 switch(type)
10581 {
10582 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010585
10586 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010587#ifdef FEATURE_WLAN_TDLS
10588
10589 /* A Mutex Lock is introduced while changing the mode to
10590 * protect the concurrent access for the Adapters by TDLS
10591 * module.
10592 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010593 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010594#endif
c_hpothu002231a2015-02-05 14:58:51 +053010595 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010597 //Check for sub-string p2p to confirm its a p2p interface
10598 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010599 {
10600 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10601 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10602 }
10603 else
10604 {
10605 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010607 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053010608
10609 /* set con_mode to STA only when no SAP concurrency mode */
10610 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
10611 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010612 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10614 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010615#ifdef FEATURE_WLAN_TDLS
10616 mutex_unlock(&pHddCtx->tdls_lock);
10617#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010618 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 if( VOS_STATUS_SUCCESS != status )
10620 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010621 /* In case of JB, for P2P-GO, only change interface will be called,
10622 * This is the right place to enable back bmps_imps()
10623 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010624 if (pHddCtx->hdd_wlan_suspended)
10625 {
10626 hdd_set_pwrparams(pHddCtx);
10627 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010628 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 goto done;
10630 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010631 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010633 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10634 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010635 goto done;
10636 default:
10637 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10638 __func__);
10639 return -EOPNOTSUPP;
10640
10641 }
10642
10643 }
10644 else
10645 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010646 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10647 __func__, hdd_device_modetoString(pAdapter->device_mode),
10648 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 return -EOPNOTSUPP;
10650 }
10651
10652
10653 if(pRoamProfile)
10654 {
10655 if ( LastBSSType != pRoamProfile->BSSType )
10656 {
10657 /*interface type changed update in wiphy structure*/
10658 wdev->iftype = type;
10659
10660 /*the BSS mode changed, We need to issue disconnect
10661 if connected or in IBSS disconnect state*/
10662 if ( hdd_connGetConnectedBssType(
10663 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10664 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10665 {
10666 /*need to issue a disconnect to CSR.*/
10667 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10668 if( eHAL_STATUS_SUCCESS ==
10669 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10670 pAdapter->sessionId,
10671 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10672 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010673 ret = wait_for_completion_interruptible_timeout(
10674 &pAdapter->disconnect_comp_var,
10675 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10676 if (ret <= 0)
10677 {
10678 hddLog(VOS_TRACE_LEVEL_ERROR,
10679 FL("wait on disconnect_comp_var failed %ld"), ret);
10680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010681 }
10682 }
10683 }
10684 }
10685
10686done:
10687 /*set bitmask based on updated value*/
10688 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010689
10690 /* Only STA mode support TM now
10691 * all other mode, TM feature should be disabled */
10692 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10693 (~VOS_STA & pHddCtx->concurrency_mode) )
10694 {
10695 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10696 }
10697
Jeff Johnson295189b2012-06-20 16:38:30 -070010698#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010699 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010700 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 {
10702 //we are ok to do AMP
10703 pHddCtx->isAmpAllowed = VOS_TRUE;
10704 }
10705#endif //WLAN_BTAMP_FEATURE
10706 EXIT();
10707 return 0;
10708}
10709
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010710/*
10711 * FUNCTION: wlan_hdd_cfg80211_change_iface
10712 * wrapper function to protect the actual implementation from SSR.
10713 */
10714int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10715 struct net_device *ndev,
10716 enum nl80211_iftype type,
10717 u32 *flags,
10718 struct vif_params *params
10719 )
10720{
10721 int ret;
10722
10723 vos_ssr_protect(__func__);
10724 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10725 vos_ssr_unprotect(__func__);
10726
10727 return ret;
10728}
10729
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010730#ifdef FEATURE_WLAN_TDLS
10731static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010732 struct net_device *dev,
10733#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10734 const u8 *mac,
10735#else
10736 u8 *mac,
10737#endif
10738 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010739{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010740 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010741 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010742 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010743 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010744 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010745 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010746
10747 ENTER();
10748
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010749 if (!dev) {
10750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10751 return -EINVAL;
10752 }
10753
10754 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10755 if (!pAdapter) {
10756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10757 return -EINVAL;
10758 }
10759
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010760 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010761 {
10762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10763 "Invalid arguments");
10764 return -EINVAL;
10765 }
Hoonki Lee27511902013-03-14 18:19:06 -070010766
10767 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10768 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10769 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010770 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010771 "%s: TDLS mode is disabled OR not enabled in FW."
10772 MAC_ADDRESS_STR " Request declined.",
10773 __func__, MAC_ADDR_ARRAY(mac));
10774 return -ENOTSUPP;
10775 }
10776
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010777 if (pHddCtx->isLogpInProgress)
10778 {
10779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10780 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010781 wlan_hdd_tdls_set_link_status(pAdapter,
10782 mac,
10783 eTDLS_LINK_IDLE,
10784 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010785 return -EBUSY;
10786 }
10787
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010788 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010789 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010790
10791 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010792 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010793 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10794 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010795 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010796 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010797 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010798
10799 /* in add station, we accept existing valid staId if there is */
10800 if ((0 == update) &&
10801 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10802 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010803 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010805 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010806 " link_status %d. staId %d. add station ignored.",
10807 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010808 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010809 return 0;
10810 }
10811 /* in change station, we accept only when staId is valid */
10812 if ((1 == update) &&
10813 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
10814 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
10815 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010816 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010818 "%s: " MAC_ADDRESS_STR
10819 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010820 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
10821 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
10822 mutex_unlock(&pHddCtx->tdls_lock);
10823 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010824 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010825 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010826
10827 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053010828 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010829 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10831 "%s: " MAC_ADDRESS_STR
10832 " TDLS setup is ongoing. Request declined.",
10833 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070010834 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010835 }
10836
10837 /* first to check if we reached to maximum supported TDLS peer.
10838 TODO: for now, return -EPERM looks working fine,
10839 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010840 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10841 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010842 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10844 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010845 " TDLS Max peer already connected. Request declined."
10846 " Num of peers (%d), Max allowed (%d).",
10847 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
10848 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010849 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010850 }
10851 else
10852 {
10853 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010854 mutex_lock(&pHddCtx->tdls_lock);
10855 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010856 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010857 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010858 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010859 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10860 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
10861 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010862 return -EPERM;
10863 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010864 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010865 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010866 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053010867 wlan_hdd_tdls_set_link_status(pAdapter,
10868 mac,
10869 eTDLS_LINK_CONNECTING,
10870 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010871
Jeff Johnsond75fe012013-04-06 10:53:06 -070010872 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010873 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010874 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010876 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010877 if(StaParams->htcap_present)
10878 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010880 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010882 "ht_capa->extended_capabilities: %0x",
10883 StaParams->HTCap.extendedHtCapInfo);
10884 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010886 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010888 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010889 if(StaParams->vhtcap_present)
10890 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010892 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
10893 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
10894 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
10895 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010896 {
10897 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010898 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010899 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010901 "[%d]: %x ", i, StaParams->supported_rates[i]);
10902 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070010903 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010904 else if ((1 == update) && (NULL == StaParams))
10905 {
10906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10907 "%s : update is true, but staParams is NULL. Error!", __func__);
10908 return -EPERM;
10909 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010910
10911 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
10912
10913 if (!update)
10914 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010915 /*Before adding sta make sure that device exited from BMPS*/
10916 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10917 {
10918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10919 "%s: Adding tdls peer sta. Disable BMPS", __func__);
10920 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10921 if (status != VOS_STATUS_SUCCESS) {
10922 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
10923 }
10924 }
10925
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010926 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010927 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010928 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010929 hddLog(VOS_TRACE_LEVEL_ERROR,
10930 FL("Failed to add TDLS peer STA. Enable Bmps"));
10931 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010932 return -EPERM;
10933 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010934 }
10935 else
10936 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010937 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010938 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010939 if (ret != eHAL_STATUS_SUCCESS) {
10940 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
10941 return -EPERM;
10942 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010943 }
10944
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010945 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010946 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
10947
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053010948 mutex_lock(&pHddCtx->tdls_lock);
10949 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
10950
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010951 if ((pTdlsPeer != NULL) &&
10952 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010953 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010954 hddLog(VOS_TRACE_LEVEL_ERROR,
10955 FL("peer link status %u"), pTdlsPeer->link_status);
10956 mutex_unlock(&pHddCtx->tdls_lock);
10957 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010958 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053010959 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010960
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010961 if (ret <= 0)
10962 {
10963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10964 "%s: timeout waiting for tdls add station indication %ld",
10965 __func__, ret);
10966 goto error;
10967 }
10968
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010969 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
10970 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010972 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010973 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010974 }
10975
10976 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010977
10978error:
Atul Mittal115287b2014-07-08 13:26:33 +053010979 wlan_hdd_tdls_set_link_status(pAdapter,
10980 mac,
10981 eTDLS_LINK_IDLE,
10982 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010983 return -EPERM;
10984
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010985}
10986#endif
10987
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010988static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010990#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10991 const u8 *mac,
10992#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010993 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010994#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010995 struct station_parameters *params)
10996{
10997 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010998 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010999 hdd_context_t *pHddCtx;
11000 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011002 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011003#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011004 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011005 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011006 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011007 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011008#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011009
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011010 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011011
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053011012 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011013 if ((NULL == pAdapter))
11014 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011016 "invalid adapter ");
11017 return -EINVAL;
11018 }
11019
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011020 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11021 TRACE_CODE_HDD_CHANGE_STATION,
11022 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011023 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011024
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011025 ret = wlan_hdd_validate_context(pHddCtx);
11026 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011027 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011028 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011029 }
11030
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011031 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11032
11033 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011034 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11036 "invalid HDD station context");
11037 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11040
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011041 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11042 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011044 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011046 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 WLANTL_STA_AUTHENTICATED);
11048
Gopichand Nakkala29149562013-05-10 21:43:41 +053011049 if (status != VOS_STATUS_SUCCESS)
11050 {
11051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11052 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11053 return -EINVAL;
11054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 }
11056 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011057 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11058 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011059#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011060 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11061 StaParams.capability = params->capability;
11062 StaParams.uapsd_queues = params->uapsd_queues;
11063 StaParams.max_sp = params->max_sp;
11064
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011065 /* Convert (first channel , number of channels) tuple to
11066 * the total list of channels. This goes with the assumption
11067 * that if the first channel is < 14, then the next channels
11068 * are an incremental of 1 else an incremental of 4 till the number
11069 * of channels.
11070 */
11071 if (0 != params->supported_channels_len) {
11072 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11073 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11074 {
11075 int wifi_chan_index;
11076 StaParams.supported_channels[j] = params->supported_channels[i];
11077 wifi_chan_index =
11078 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11079 no_of_channels = params->supported_channels[i+1];
11080 for(k=1; k <= no_of_channels; k++)
11081 {
11082 StaParams.supported_channels[j+1] =
11083 StaParams.supported_channels[j] + wifi_chan_index;
11084 j+=1;
11085 }
11086 }
11087 StaParams.supported_channels_len = j;
11088 }
11089 vos_mem_copy(StaParams.supported_oper_classes,
11090 params->supported_oper_classes,
11091 params->supported_oper_classes_len);
11092 StaParams.supported_oper_classes_len =
11093 params->supported_oper_classes_len;
11094
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011095 if (0 != params->ext_capab_len)
11096 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
11097 sizeof(StaParams.extn_capability));
11098
11099 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011100 {
11101 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011102 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011103 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011104
11105 StaParams.supported_rates_len = params->supported_rates_len;
11106
11107 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11108 * The supported_rates array , for all the structures propogating till Add Sta
11109 * to the firmware has to be modified , if the supplicant (ieee80211) is
11110 * modified to send more rates.
11111 */
11112
11113 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11114 */
11115 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11116 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11117
11118 if (0 != StaParams.supported_rates_len) {
11119 int i = 0;
11120 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11121 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011123 "Supported Rates with Length %d", StaParams.supported_rates_len);
11124 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011126 "[%d]: %0x", i, StaParams.supported_rates[i]);
11127 }
11128
11129 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011130 {
11131 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011132 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011133 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011134
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011135 if (0 != params->ext_capab_len ) {
11136 /*Define A Macro : TODO Sunil*/
11137 if ((1<<4) & StaParams.extn_capability[3]) {
11138 isBufSta = 1;
11139 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011140 /* TDLS Channel Switching Support */
11141 if ((1<<6) & StaParams.extn_capability[3]) {
11142 isOffChannelSupported = 1;
11143 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011144 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011145
11146 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011147 (params->ht_capa || params->vht_capa ||
11148 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011149 /* TDLS Peer is WME/QoS capable */
11150 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011151
11152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11153 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11154 __func__, isQosWmmSta, StaParams.htcap_present);
11155
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011156 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11157 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011158 isOffChannelSupported,
11159 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011160
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011161 if (VOS_STATUS_SUCCESS != status) {
11162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11163 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11164 return -EINVAL;
11165 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011166 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11167
11168 if (VOS_STATUS_SUCCESS != status) {
11169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11170 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11171 return -EINVAL;
11172 }
11173 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011174#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011175 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011176 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 return status;
11178}
11179
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011180#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11181static int wlan_hdd_change_station(struct wiphy *wiphy,
11182 struct net_device *dev,
11183 const u8 *mac,
11184 struct station_parameters *params)
11185#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011186static int wlan_hdd_change_station(struct wiphy *wiphy,
11187 struct net_device *dev,
11188 u8 *mac,
11189 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011190#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011191{
11192 int ret;
11193
11194 vos_ssr_protect(__func__);
11195 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11196 vos_ssr_unprotect(__func__);
11197
11198 return ret;
11199}
11200
Jeff Johnson295189b2012-06-20 16:38:30 -070011201/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011202 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011203 * This function is used to initialize the key information
11204 */
11205#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011206static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011207 struct net_device *ndev,
11208 u8 key_index, bool pairwise,
11209 const u8 *mac_addr,
11210 struct key_params *params
11211 )
11212#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011213static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 struct net_device *ndev,
11215 u8 key_index, const u8 *mac_addr,
11216 struct key_params *params
11217 )
11218#endif
11219{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 tCsrRoamSetKey setKey;
11222 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011223 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011224 v_U32_t roamId= 0xFF;
11225 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 hdd_hostapd_state_t *pHostapdState;
11227 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011228 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011229 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011230
11231 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011232
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011233 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11234 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11235 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011236 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11237 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011238 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011239 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011240 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011241 }
11242
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011243 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11244 __func__, hdd_device_modetoString(pAdapter->device_mode),
11245 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011246
11247 if (CSR_MAX_NUM_KEY <= key_index)
11248 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 key_index);
11251
11252 return -EINVAL;
11253 }
11254
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011255 if (CSR_MAX_KEY_LEN < params->key_len)
11256 {
11257 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11258 params->key_len);
11259
11260 return -EINVAL;
11261 }
11262
11263 hddLog(VOS_TRACE_LEVEL_INFO,
11264 "%s: called with key index = %d & key length %d",
11265 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011266
11267 /*extract key idx, key len and key*/
11268 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11269 setKey.keyId = key_index;
11270 setKey.keyLength = params->key_len;
11271 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11272
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011273 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 {
11275 case WLAN_CIPHER_SUITE_WEP40:
11276 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11277 break;
11278
11279 case WLAN_CIPHER_SUITE_WEP104:
11280 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11281 break;
11282
11283 case WLAN_CIPHER_SUITE_TKIP:
11284 {
11285 u8 *pKey = &setKey.Key[0];
11286 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11287
11288 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11289
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011290 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011291
11292 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011293 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 |--------------|----------|----------|
11295 <---16bytes---><--8bytes--><--8bytes-->
11296
11297 */
11298 /*Sme expects the 32 bytes key to be in the below order
11299
11300 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011301 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 |--------------|----------|----------|
11303 <---16bytes---><--8bytes--><--8bytes-->
11304 */
11305 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011306 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011307
11308 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011309 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011310
11311 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011312 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011313
11314
11315 break;
11316 }
11317
11318 case WLAN_CIPHER_SUITE_CCMP:
11319 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11320 break;
11321
11322#ifdef FEATURE_WLAN_WAPI
11323 case WLAN_CIPHER_SUITE_SMS4:
11324 {
11325 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11326 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11327 params->key, params->key_len);
11328 return 0;
11329 }
11330#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011331
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011332#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 case WLAN_CIPHER_SUITE_KRK:
11334 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11335 break;
11336#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011337
11338#ifdef WLAN_FEATURE_11W
11339 case WLAN_CIPHER_SUITE_AES_CMAC:
11340 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011341 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011342#endif
11343
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011345 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011346 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011347 status = -EOPNOTSUPP;
11348 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 }
11350
11351 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11352 __func__, setKey.encType);
11353
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011354 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011355#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11356 (!pairwise)
11357#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011358 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011359#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011360 )
11361 {
11362 /* set group key*/
11363 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11364 "%s- %d: setting Broadcast key",
11365 __func__, __LINE__);
11366 setKey.keyDirection = eSIR_RX_ONLY;
11367 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11368 }
11369 else
11370 {
11371 /* set pairwise key*/
11372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11373 "%s- %d: setting pairwise key",
11374 __func__, __LINE__);
11375 setKey.keyDirection = eSIR_TX_RX;
11376 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11377 }
11378 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11379 {
11380 setKey.keyDirection = eSIR_TX_RX;
11381 /*Set the group key*/
11382 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11383 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011384
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011385 if ( 0 != status )
11386 {
11387 hddLog(VOS_TRACE_LEVEL_ERROR,
11388 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011389 status = -EINVAL;
11390 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011391 }
11392 /*Save the keys here and call sme_RoamSetKey for setting
11393 the PTK after peer joins the IBSS network*/
11394 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11395 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011396 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011397 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011398 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11399 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11400 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011402 if( pHostapdState->bssState == BSS_START )
11403 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011404 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11405 vos_status = wlan_hdd_check_ula_done(pAdapter);
11406
11407 if ( vos_status != VOS_STATUS_SUCCESS )
11408 {
11409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11410 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11411 __LINE__, vos_status );
11412
11413 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11414
11415 status = -EINVAL;
11416 goto end;
11417 }
11418
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11420
11421 if ( status != eHAL_STATUS_SUCCESS )
11422 {
11423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11424 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11425 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011426 status = -EINVAL;
11427 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011428 }
11429 }
11430
11431 /* Saving WEP keys */
11432 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11433 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11434 {
11435 //Save the wep key in ap context. Issue setkey after the BSS is started.
11436 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11437 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11438 }
11439 else
11440 {
11441 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011442 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011443 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11444 }
11445 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011446 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11447 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 {
11449 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11450 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11451
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011452#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11453 if (!pairwise)
11454#else
11455 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11456#endif
11457 {
11458 /* set group key*/
11459 if (pHddStaCtx->roam_info.deferKeyComplete)
11460 {
11461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11462 "%s- %d: Perform Set key Complete",
11463 __func__, __LINE__);
11464 hdd_PerformRoamSetKeyComplete(pAdapter);
11465 }
11466 }
11467
Jeff Johnson295189b2012-06-20 16:38:30 -070011468 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11469
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011470 pWextState->roamProfile.Keys.defaultIndex = key_index;
11471
11472
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011473 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 params->key, params->key_len);
11475
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011476
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11478
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011479 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011481 __func__, setKey.peerMac[0], setKey.peerMac[1],
11482 setKey.peerMac[2], setKey.peerMac[3],
11483 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 setKey.keyDirection);
11485
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011486 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011487
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011488 if ( vos_status != VOS_STATUS_SUCCESS )
11489 {
11490 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11492 __LINE__, vos_status );
11493
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011494 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011495
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011496 status = -EINVAL;
11497 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011498
11499 }
11500
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011501#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011502 /* The supplicant may attempt to set the PTK once pre-authentication
11503 is done. Save the key in the UMAC and include it in the ADD BSS
11504 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011505 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011506 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011507 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011508 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11509 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011510 status = 0;
11511 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011512 }
11513 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11514 {
11515 hddLog(VOS_TRACE_LEVEL_ERROR,
11516 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011517 status = -EINVAL;
11518 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011519 }
11520#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011521
11522 /* issue set key request to SME*/
11523 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11524 pAdapter->sessionId, &setKey, &roamId );
11525
11526 if ( 0 != status )
11527 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011528 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11530 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011531 status = -EINVAL;
11532 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 }
11534
11535
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011536 /* in case of IBSS as there was no information available about WEP keys during
11537 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011539 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11540 !( ( IW_AUTH_KEY_MGMT_802_1X
11541 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11543 )
11544 &&
11545 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11546 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11547 )
11548 )
11549 {
11550 setKey.keyDirection = eSIR_RX_ONLY;
11551 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11552
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011553 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011555 __func__, setKey.peerMac[0], setKey.peerMac[1],
11556 setKey.peerMac[2], setKey.peerMac[3],
11557 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 setKey.keyDirection);
11559
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011560 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011561 pAdapter->sessionId, &setKey, &roamId );
11562
11563 if ( 0 != status )
11564 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011565 hddLog(VOS_TRACE_LEVEL_ERROR,
11566 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 __func__, status);
11568 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011569 status = -EINVAL;
11570 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 }
11572 }
11573 }
11574
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011575end:
11576 /* Need to clear any trace of key value in the memory.
11577 * Thus zero out the memory even though it is local
11578 * variable.
11579 */
11580 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011581 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011582 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011583}
11584
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011585#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11586static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11587 struct net_device *ndev,
11588 u8 key_index, bool pairwise,
11589 const u8 *mac_addr,
11590 struct key_params *params
11591 )
11592#else
11593static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11594 struct net_device *ndev,
11595 u8 key_index, const u8 *mac_addr,
11596 struct key_params *params
11597 )
11598#endif
11599{
11600 int ret;
11601 vos_ssr_protect(__func__);
11602#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11603 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11604 mac_addr, params);
11605#else
11606 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11607 params);
11608#endif
11609 vos_ssr_unprotect(__func__);
11610
11611 return ret;
11612}
11613
Jeff Johnson295189b2012-06-20 16:38:30 -070011614/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011615 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 * This function is used to get the key information
11617 */
11618#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011619static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011620 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011621 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011622 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 const u8 *mac_addr, void *cookie,
11624 void (*callback)(void *cookie, struct key_params*)
11625 )
11626#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011627static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011628 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 struct net_device *ndev,
11630 u8 key_index, const u8 *mac_addr, void *cookie,
11631 void (*callback)(void *cookie, struct key_params*)
11632 )
11633#endif
11634{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011635 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011636 hdd_wext_state_t *pWextState = NULL;
11637 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011639 hdd_context_t *pHddCtx;
11640 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011641
11642 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011643
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011644 if (NULL == pAdapter)
11645 {
11646 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11647 "%s: HDD adapter is Null", __func__);
11648 return -ENODEV;
11649 }
11650
11651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11652 ret = wlan_hdd_validate_context(pHddCtx);
11653 if (0 != ret)
11654 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011655 return ret;
11656 }
11657
11658 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11659 pRoamProfile = &(pWextState->roamProfile);
11660
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011661 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11662 __func__, hdd_device_modetoString(pAdapter->device_mode),
11663 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011664
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 memset(&params, 0, sizeof(params));
11666
11667 if (CSR_MAX_NUM_KEY <= key_index)
11668 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011669 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011671 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011672
11673 switch(pRoamProfile->EncryptionType.encryptionType[0])
11674 {
11675 case eCSR_ENCRYPT_TYPE_NONE:
11676 params.cipher = IW_AUTH_CIPHER_NONE;
11677 break;
11678
11679 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11680 case eCSR_ENCRYPT_TYPE_WEP40:
11681 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11682 break;
11683
11684 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11685 case eCSR_ENCRYPT_TYPE_WEP104:
11686 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11687 break;
11688
11689 case eCSR_ENCRYPT_TYPE_TKIP:
11690 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11691 break;
11692
11693 case eCSR_ENCRYPT_TYPE_AES:
11694 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11695 break;
11696
11697 default:
11698 params.cipher = IW_AUTH_CIPHER_NONE;
11699 break;
11700 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011701
c_hpothuaaf19692014-05-17 17:01:48 +053011702 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11703 TRACE_CODE_HDD_CFG80211_GET_KEY,
11704 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011705
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11707 params.seq_len = 0;
11708 params.seq = NULL;
11709 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11710 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011711 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 return 0;
11713}
11714
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011715#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11716static int wlan_hdd_cfg80211_get_key(
11717 struct wiphy *wiphy,
11718 struct net_device *ndev,
11719 u8 key_index, bool pairwise,
11720 const u8 *mac_addr, void *cookie,
11721 void (*callback)(void *cookie, struct key_params*)
11722 )
11723#else
11724static int wlan_hdd_cfg80211_get_key(
11725 struct wiphy *wiphy,
11726 struct net_device *ndev,
11727 u8 key_index, const u8 *mac_addr, void *cookie,
11728 void (*callback)(void *cookie, struct key_params*)
11729 )
11730#endif
11731{
11732 int ret;
11733
11734 vos_ssr_protect(__func__);
11735#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11736 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11737 mac_addr, cookie, callback);
11738#else
11739 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11740 callback);
11741#endif
11742 vos_ssr_unprotect(__func__);
11743
11744 return ret;
11745}
11746
Jeff Johnson295189b2012-06-20 16:38:30 -070011747/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011748 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 * This function is used to delete the key information
11750 */
11751#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011752static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011754 u8 key_index,
11755 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 const u8 *mac_addr
11757 )
11758#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011759static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 struct net_device *ndev,
11761 u8 key_index,
11762 const u8 *mac_addr
11763 )
11764#endif
11765{
11766 int status = 0;
11767
11768 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011769 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 //it is observed that this is invalidating peer
11771 //key index whenever re-key is done. This is affecting data link.
11772 //It should be ok to ignore del_key.
11773#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11775 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011776 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11777 tCsrRoamSetKey setKey;
11778 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011779
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 ENTER();
11781
11782 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11783 __func__,pAdapter->device_mode);
11784
11785 if (CSR_MAX_NUM_KEY <= key_index)
11786 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011787 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 key_index);
11789
11790 return -EINVAL;
11791 }
11792
11793 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11794 setKey.keyId = key_index;
11795
11796 if (mac_addr)
11797 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11798 else
11799 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11800
11801 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11802
11803 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011805 )
11806 {
11807
11808 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11810 if( pHostapdState->bssState == BSS_START)
11811 {
11812 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011813
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 if ( status != eHAL_STATUS_SUCCESS )
11815 {
11816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11817 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11818 __LINE__, status );
11819 }
11820 }
11821 }
11822 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011823 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 )
11825 {
11826 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11827
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011828 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11829
11830 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011832 __func__, setKey.peerMac[0], setKey.peerMac[1],
11833 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011835 if(pAdapter->sessionCtx.station.conn_info.connState ==
11836 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011838 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011840
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 if ( 0 != status )
11842 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011843 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 "%s: sme_RoamSetKey failure, returned %d",
11845 __func__, status);
11846 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11847 return -EINVAL;
11848 }
11849 }
11850 }
11851#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011852 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011853 return status;
11854}
11855
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011856#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11857static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11858 struct net_device *ndev,
11859 u8 key_index,
11860 bool pairwise,
11861 const u8 *mac_addr
11862 )
11863#else
11864static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11865 struct net_device *ndev,
11866 u8 key_index,
11867 const u8 *mac_addr
11868 )
11869#endif
11870{
11871 int ret;
11872
11873 vos_ssr_protect(__func__);
11874#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11875 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
11876 mac_addr);
11877#else
11878 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
11879#endif
11880 vos_ssr_unprotect(__func__);
11881
11882 return ret;
11883}
11884
Jeff Johnson295189b2012-06-20 16:38:30 -070011885/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011886 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 * This function is used to set the default tx key index
11888 */
11889#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011890static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011891 struct net_device *ndev,
11892 u8 key_index,
11893 bool unicast, bool multicast)
11894#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011895static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011896 struct net_device *ndev,
11897 u8 key_index)
11898#endif
11899{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011900 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011901 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011902 hdd_wext_state_t *pWextState;
11903 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011904 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011905
11906 ENTER();
11907
Gopichand Nakkala29149562013-05-10 21:43:41 +053011908 if ((NULL == pAdapter))
11909 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011911 "invalid adapter");
11912 return -EINVAL;
11913 }
11914
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011915 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11916 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
11917 pAdapter->sessionId, key_index));
11918
Gopichand Nakkala29149562013-05-10 21:43:41 +053011919 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11920 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11921
11922 if ((NULL == pWextState) || (NULL == pHddStaCtx))
11923 {
11924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11925 "invalid Wext state or HDD context");
11926 return -EINVAL;
11927 }
11928
Arif Hussain6d2a3322013-11-17 19:50:10 -080011929 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011931
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 if (CSR_MAX_NUM_KEY <= key_index)
11933 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011934 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 key_index);
11936
11937 return -EINVAL;
11938 }
11939
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011940 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11941 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011942 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011943 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011944 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011945 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011946
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011949 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011951 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080011952 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011953 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080011954 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011956 {
11957 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011959
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 tCsrRoamSetKey setKey;
11961 v_U32_t roamId= 0xFF;
11962 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011963
11964 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011966
Jeff Johnson295189b2012-06-20 16:38:30 -070011967 Keys->defaultIndex = (u8)key_index;
11968 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11969 setKey.keyId = key_index;
11970 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011971
11972 vos_mem_copy(&setKey.Key[0],
11973 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011975
Gopichand Nakkala29149562013-05-10 21:43:41 +053011976 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011977
11978 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 &pHddStaCtx->conn_info.bssId[0],
11980 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011981
Gopichand Nakkala29149562013-05-10 21:43:41 +053011982 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
11983 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
11984 eCSR_ENCRYPT_TYPE_WEP104)
11985 {
11986 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
11987 even though ap is configured for WEP-40 encryption. In this canse the key length
11988 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
11989 type(104) and switching encryption type to 40*/
11990 pWextState->roamProfile.EncryptionType.encryptionType[0] =
11991 eCSR_ENCRYPT_TYPE_WEP40;
11992 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
11993 eCSR_ENCRYPT_TYPE_WEP40;
11994 }
11995
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011996 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011998
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012000 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012002
Jeff Johnson295189b2012-06-20 16:38:30 -070012003 if ( 0 != status )
12004 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012005 hddLog(VOS_TRACE_LEVEL_ERROR,
12006 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 status);
12008 return -EINVAL;
12009 }
12010 }
12011 }
12012
12013 /* In SoftAp mode setting key direction for default mode */
12014 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12015 {
12016 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12017 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12018 (eCSR_ENCRYPT_TYPE_AES !=
12019 pWextState->roamProfile.EncryptionType.encryptionType[0])
12020 )
12021 {
12022 /* Saving key direction for default key index to TX default */
12023 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12024 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12025 }
12026 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012027 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 return status;
12029}
12030
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012031#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12032static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12033 struct net_device *ndev,
12034 u8 key_index,
12035 bool unicast, bool multicast)
12036#else
12037static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12038 struct net_device *ndev,
12039 u8 key_index)
12040#endif
12041{
12042 int ret;
12043 vos_ssr_protect(__func__);
12044#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12045 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12046 multicast);
12047#else
12048 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12049#endif
12050 vos_ssr_unprotect(__func__);
12051
12052 return ret;
12053}
12054
Jeff Johnson295189b2012-06-20 16:38:30 -070012055/*
12056 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12057 * This function is used to inform the BSS details to nl80211 interface.
12058 */
12059static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12060 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12061{
12062 struct net_device *dev = pAdapter->dev;
12063 struct wireless_dev *wdev = dev->ieee80211_ptr;
12064 struct wiphy *wiphy = wdev->wiphy;
12065 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12066 int chan_no;
12067 int ie_length;
12068 const char *ie;
12069 unsigned int freq;
12070 struct ieee80211_channel *chan;
12071 int rssi = 0;
12072 struct cfg80211_bss *bss = NULL;
12073
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 if( NULL == pBssDesc )
12075 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012076 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 return bss;
12078 }
12079
12080 chan_no = pBssDesc->channelId;
12081 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12082 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12083
12084 if( NULL == ie )
12085 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012086 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 return bss;
12088 }
12089
12090#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12091 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12092 {
12093 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12094 }
12095 else
12096 {
12097 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12098 }
12099#else
12100 freq = ieee80211_channel_to_frequency(chan_no);
12101#endif
12102
12103 chan = __ieee80211_get_channel(wiphy, freq);
12104
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012105 if (!chan) {
12106 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12107 return NULL;
12108 }
12109
Abhishek Singhaee43942014-06-16 18:55:47 +053012110 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012111
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012112 return cfg80211_inform_bss(wiphy, chan,
12113#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12114 CFG80211_BSS_FTYPE_UNKNOWN,
12115#endif
12116 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012117 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 pBssDesc->capabilityInfo,
12119 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012120 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012121}
12122
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012123/*
12124 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12125 * interface that BSS might have been lost.
12126 * @pAdapter: adaptor
12127 * @bssid: bssid which might have been lost
12128 *
12129 * Return: bss which is unlinked from kernel cache
12130 */
12131struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12132 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12133{
12134 struct net_device *dev = pAdapter->dev;
12135 struct wireless_dev *wdev = dev->ieee80211_ptr;
12136 struct wiphy *wiphy = wdev->wiphy;
12137 struct cfg80211_bss *bss = NULL;
12138
12139 bss = cfg80211_get_bss(wiphy, NULL, bssid,
12140 NULL,
12141 0,
12142#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS) \
12143 && !defined(IEEE80211_PRIVACY)
12144 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
12145#else
12146 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
12147#endif
12148 if (bss == NULL) {
12149 hddLog(LOGE, FL("BSS not present"));
12150 } else {
12151 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12152 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12153 cfg80211_unlink_bss(wiphy, bss);
12154 }
12155 return bss;
12156}
Jeff Johnson295189b2012-06-20 16:38:30 -070012157
12158
12159/*
12160 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12161 * This function is used to inform the BSS details to nl80211 interface.
12162 */
12163struct cfg80211_bss*
12164wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12165 tSirBssDescription *bss_desc
12166 )
12167{
12168 /*
12169 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12170 already exists in bss data base of cfg80211 for that particular BSS ID.
12171 Using cfg80211_inform_bss_frame to update the bss entry instead of
12172 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12173 now there is no possibility to get the mgmt(probe response) frame from PE,
12174 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12175 cfg80211_inform_bss_frame.
12176 */
12177 struct net_device *dev = pAdapter->dev;
12178 struct wireless_dev *wdev = dev->ieee80211_ptr;
12179 struct wiphy *wiphy = wdev->wiphy;
12180 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012181#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12182 qcom_ie_age *qie_age = NULL;
12183 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12184#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 const char *ie =
12188 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12189 unsigned int freq;
12190 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012191 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 struct cfg80211_bss *bss_status = NULL;
12193 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12194 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012195 hdd_context_t *pHddCtx;
12196 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012197#ifdef WLAN_OPEN_SOURCE
12198 struct timespec ts;
12199#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012201
Wilson Yangf80a0542013-10-07 13:02:37 -070012202 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12203 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012204 if (0 != status)
12205 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012206 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012207 }
12208
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012209 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012210 if (!mgmt)
12211 {
12212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12213 "%s: memory allocation failed ", __func__);
12214 return NULL;
12215 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012216
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012218
12219#ifdef WLAN_OPEN_SOURCE
12220 /* Android does not want the timestamp from the frame.
12221 Instead it wants a monotonic increasing value */
12222 get_monotonic_boottime(&ts);
12223 mgmt->u.probe_resp.timestamp =
12224 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12225#else
12226 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12228 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012229
12230#endif
12231
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12233 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012234
12235#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12236 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12237 /* Assuming this is the last IE, copy at the end */
12238 ie_length -=sizeof(qcom_ie_age);
12239 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12240 qie_age->element_id = QCOM_VENDOR_IE_ID;
12241 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12242 qie_age->oui_1 = QCOM_OUI1;
12243 qie_age->oui_2 = QCOM_OUI2;
12244 qie_age->oui_3 = QCOM_OUI3;
12245 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053012246 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
12247 * bss related timestamp is in units of ms. Due to this when scan results
12248 * are sent to lowi the scan age is high.To address this, send age in units
12249 * of 1/10 ms.
12250 */
12251 qie_age->age = (vos_timer_get_system_time() -
12252 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012253#endif
12254
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012256 if (bss_desc->fProbeRsp)
12257 {
12258 mgmt->frame_control |=
12259 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12260 }
12261 else
12262 {
12263 mgmt->frame_control |=
12264 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012266
12267#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012268 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12270 {
12271 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12272 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012273 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12275
12276 {
12277 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12278 }
12279 else
12280 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012281 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12282 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 kfree(mgmt);
12284 return NULL;
12285 }
12286#else
12287 freq = ieee80211_channel_to_frequency(chan_no);
12288#endif
12289 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012290 /*when the band is changed on the fly using the GUI, three things are done
12291 * 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)
12292 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12293 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12294 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12295 * and discards the channels correponding to previous band and calls back with zero bss results.
12296 * 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
12297 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12298 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12299 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12300 * So drop the bss and continue to next bss.
12301 */
12302 if(chan == NULL)
12303 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053012304 hddLog(VOS_TRACE_LEVEL_ERROR,
12305 FL("chan pointer is NULL, chan_no: %d freq: %d"),
12306 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070012307 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012308 return NULL;
12309 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012310 /*To keep the rssi icon of the connected AP in the scan window
12311 *and the rssi icon of the wireless networks in sync
12312 * */
12313 if (( eConnectionState_Associated ==
12314 pAdapter->sessionCtx.station.conn_info.connState ) &&
12315 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12316 pAdapter->sessionCtx.station.conn_info.bssId,
12317 WNI_CFG_BSSID_LEN)) &&
12318 (pHddCtx->hdd_wlan_suspended == FALSE))
12319 {
12320 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12321 rssi = (pAdapter->rssi * 100);
12322 }
12323 else
12324 {
12325 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012327
Nirav Shah20ac06f2013-12-12 18:14:06 +053012328 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012329 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12330 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012331
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12333 frame_len, rssi, GFP_KERNEL);
12334 kfree(mgmt);
12335 return bss_status;
12336}
12337
12338/*
12339 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12340 * This function is used to update the BSS data base of CFG8011
12341 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012342struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 tCsrRoamInfo *pRoamInfo
12344 )
12345{
12346 tCsrRoamConnectedProfile roamProfile;
12347 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12348 struct cfg80211_bss *bss = NULL;
12349
12350 ENTER();
12351
12352 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12353 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12354
12355 if (NULL != roamProfile.pBssDesc)
12356 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012357 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12358 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012359
12360 if (NULL == bss)
12361 {
12362 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12363 __func__);
12364 }
12365
12366 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12367 }
12368 else
12369 {
12370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12371 __func__);
12372 }
12373 return bss;
12374}
12375
12376/*
12377 * FUNCTION: wlan_hdd_cfg80211_update_bss
12378 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012379static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12380 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012382{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012383 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 tCsrScanResultInfo *pScanResult;
12385 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012386 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 tScanResultHandle pResult;
12388 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012389 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012390 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012392
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012393 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12394 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12395 NO_SESSION, pAdapter->sessionId));
12396
Wilson Yangf80a0542013-10-07 13:02:37 -070012397 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012398 ret = wlan_hdd_validate_context(pHddCtx);
12399 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012401 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070012402 }
12403
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012404 if (pAdapter->request != NULL)
12405 {
12406 if ((pAdapter->request->n_ssids == 1)
12407 && (pAdapter->request->ssids != NULL)
12408 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12409 is_p2p_scan = true;
12410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012411 /*
12412 * start getting scan results and populate cgf80211 BSS database
12413 */
12414 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12415
12416 /* no scan results */
12417 if (NULL == pResult)
12418 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012419 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12420 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012421 wlan_hdd_get_frame_logs(pAdapter,
12422 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 return status;
12424 }
12425
12426 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12427
12428 while (pScanResult)
12429 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012430 /*
12431 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12432 * entry already exists in bss data base of cfg80211 for that
12433 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12434 * bss entry instead of cfg80211_inform_bss, But this call expects
12435 * mgmt packet as input. As of now there is no possibility to get
12436 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 * ieee80211_mgmt(probe response) and passing to c
12438 * fg80211_inform_bss_frame.
12439 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012440 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12441 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12442 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012443 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12444 continue; //Skip the non p2p bss entries
12445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12447 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012448
Jeff Johnson295189b2012-06-20 16:38:30 -070012449
12450 if (NULL == bss_status)
12451 {
12452 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012453 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 }
12455 else
12456 {
Yue Maf49ba872013-08-19 12:04:25 -070012457 cfg80211_put_bss(
12458#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12459 wiphy,
12460#endif
12461 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 }
12463
12464 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12465 }
12466
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012467 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012468 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012469 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012470}
12471
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012472void
12473hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12474{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012475 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012476 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012477} /****** end hddPrintMacAddr() ******/
12478
12479void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012480hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012481{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012482 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012483 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012484 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12485 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12486 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012487} /****** end hddPrintPmkId() ******/
12488
12489//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12490//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12491
12492//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12493//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12494
12495#define dump_bssid(bssid) \
12496 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012497 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12498 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012499 }
12500
12501#define dump_pmkid(pMac, pmkid) \
12502 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012503 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12504 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012505 }
12506
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012507#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012508/*
12509 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12510 * This function is used to notify the supplicant of a new PMKSA candidate.
12511 */
12512int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012513 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012514 int index, bool preauth )
12515{
Jeff Johnsone7245742012-09-05 17:12:55 -070012516#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012517 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012518 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012519
12520 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012521 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012522
12523 if( NULL == pRoamInfo )
12524 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012525 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012526 return -EINVAL;
12527 }
12528
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012529 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12530 {
12531 dump_bssid(pRoamInfo->bssid);
12532 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012533 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012534 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012535#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012536 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012537}
12538#endif //FEATURE_WLAN_LFR
12539
Yue Maef608272013-04-08 23:09:17 -070012540#ifdef FEATURE_WLAN_LFR_METRICS
12541/*
12542 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12543 * 802.11r/LFR metrics reporting function to report preauth initiation
12544 *
12545 */
12546#define MAX_LFR_METRICS_EVENT_LENGTH 100
12547VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12548 tCsrRoamInfo *pRoamInfo)
12549{
12550 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12551 union iwreq_data wrqu;
12552
12553 ENTER();
12554
12555 if (NULL == pAdapter)
12556 {
12557 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12558 return VOS_STATUS_E_FAILURE;
12559 }
12560
12561 /* create the event */
12562 memset(&wrqu, 0, sizeof(wrqu));
12563 memset(metrics_notification, 0, sizeof(metrics_notification));
12564
12565 wrqu.data.pointer = metrics_notification;
12566 wrqu.data.length = scnprintf(metrics_notification,
12567 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12568 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12569
12570 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12571
12572 EXIT();
12573
12574 return VOS_STATUS_SUCCESS;
12575}
12576
12577/*
12578 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12579 * 802.11r/LFR metrics reporting function to report preauth completion
12580 * or failure
12581 */
12582VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12583 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12584{
12585 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12586 union iwreq_data wrqu;
12587
12588 ENTER();
12589
12590 if (NULL == pAdapter)
12591 {
12592 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12593 return VOS_STATUS_E_FAILURE;
12594 }
12595
12596 /* create the event */
12597 memset(&wrqu, 0, sizeof(wrqu));
12598 memset(metrics_notification, 0, sizeof(metrics_notification));
12599
12600 scnprintf(metrics_notification, sizeof(metrics_notification),
12601 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12602 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12603
12604 if (1 == preauth_status)
12605 strncat(metrics_notification, " TRUE", 5);
12606 else
12607 strncat(metrics_notification, " FALSE", 6);
12608
12609 wrqu.data.pointer = metrics_notification;
12610 wrqu.data.length = strlen(metrics_notification);
12611
12612 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12613
12614 EXIT();
12615
12616 return VOS_STATUS_SUCCESS;
12617}
12618
12619/*
12620 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12621 * 802.11r/LFR metrics reporting function to report handover initiation
12622 *
12623 */
12624VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12625 tCsrRoamInfo *pRoamInfo)
12626{
12627 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12628 union iwreq_data wrqu;
12629
12630 ENTER();
12631
12632 if (NULL == pAdapter)
12633 {
12634 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12635 return VOS_STATUS_E_FAILURE;
12636 }
12637
12638 /* create the event */
12639 memset(&wrqu, 0, sizeof(wrqu));
12640 memset(metrics_notification, 0, sizeof(metrics_notification));
12641
12642 wrqu.data.pointer = metrics_notification;
12643 wrqu.data.length = scnprintf(metrics_notification,
12644 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12645 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12646
12647 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12648
12649 EXIT();
12650
12651 return VOS_STATUS_SUCCESS;
12652}
12653#endif
12654
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012655
12656/**
12657 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
12658 * @scan_req: scan request to be checked
12659 *
12660 * Return: true or false
12661 */
12662#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
12663static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12664 cfg80211_scan_request
12665 *scan_req)
12666{
12667 if (!scan_req || !scan_req->wiphy) {
12668 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12669 return false;
12670 }
12671 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
12672 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
12673 return false;
12674 }
12675 return true;
12676}
12677#else
12678static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12679 cfg80211_scan_request
12680 *scan_req)
12681{
12682 if (!scan_req || !scan_req->wiphy) {
12683 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12684 return false;
12685 }
12686 return true;
12687}
12688#endif
12689
12690
Jeff Johnson295189b2012-06-20 16:38:30 -070012691/*
12692 * FUNCTION: hdd_cfg80211_scan_done_callback
12693 * scanning callback function, called after finishing scan
12694 *
12695 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012696static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12698{
12699 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012700 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012702 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 struct cfg80211_scan_request *req = NULL;
12704 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012705 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012706#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12707 bool iface_down = false;
12708#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012709 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012710 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012711 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012712
12713 ENTER();
12714
c_manjee1b4ab9a2016-10-26 11:36:55 +053012715 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
12716 !pAdapter->dev) {
12717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
12718 return 0;
12719 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012720 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012721 if (NULL == pHddCtx) {
12722 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012723 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012724 }
12725
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012726#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12727 if (!(pAdapter->dev->flags & IFF_UP))
12728 {
12729 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012730 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012731 }
12732#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012733 pScanInfo = &pHddCtx->scan_info;
12734
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 hddLog(VOS_TRACE_LEVEL_INFO,
12736 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012737 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 __func__, halHandle, pContext, (int) scanId, (int) status);
12739
Kiet Lamac06e2c2013-10-23 16:25:07 +053012740 pScanInfo->mScanPendingCounter = 0;
12741
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012743 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 &pScanInfo->scan_req_completion_event,
12745 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012746 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012748 hddLog(VOS_TRACE_LEVEL_ERROR,
12749 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012751 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 }
12753
Yue Maef608272013-04-08 23:09:17 -070012754 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 {
12756 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012757 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 }
12759
12760 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012761 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 {
12763 hddLog(VOS_TRACE_LEVEL_INFO,
12764 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012765 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 (int) scanId);
12767 }
12768
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012769#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012770 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012771#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012772 {
12773 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
12774 pAdapter);
12775 if (0 > ret)
12776 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012777 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012778
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 /* If any client wait scan result through WEXT
12780 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012781 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 {
12783 /* The other scan request waiting for current scan finish
12784 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012785 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012787 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 }
12789 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012790 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 {
12792 struct net_device *dev = pAdapter->dev;
12793 union iwreq_data wrqu;
12794 int we_event;
12795 char *msg;
12796
12797 memset(&wrqu, '\0', sizeof(wrqu));
12798 we_event = SIOCGIWSCAN;
12799 msg = NULL;
12800 wireless_send_event(dev, we_event, &wrqu, msg);
12801 }
12802 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012803 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012804
12805 /* Get the Scan Req */
12806 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053012807 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012808
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012809 /* Scan is no longer pending */
12810 pScanInfo->mScanPending = VOS_FALSE;
12811
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012812 if (!wlan_hdd_cfg80211_validate_scan_req(req))
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012814#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12815 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
12816 iface_down ? "up" : "down");
12817#endif
12818
12819 if (pAdapter->dev) {
12820 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
12821 pAdapter->dev->name);
12822 }
mukul sharmae7041822015-12-03 15:09:21 +053012823 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070012824 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 }
12826
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012827 /* last_scan_timestamp is used to decide if new scan
12828 * is needed or not on station interface. If last station
12829 * scan time and new station scan time is less then
12830 * last_scan_timestamp ; driver will return cached scan.
12831 */
12832 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
12833 {
12834 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
12835
12836 if ( req->n_channels )
12837 {
12838 for (i = 0; i < req->n_channels ; i++ )
12839 {
12840 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
12841 }
12842 /* store no of channel scanned */
12843 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
12844 }
12845
12846 }
12847
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070012848 /*
12849 * cfg80211_scan_done informing NL80211 about completion
12850 * of scanning
12851 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012852 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
12853 {
12854 aborted = true;
12855 }
mukul sharmae7041822015-12-03 15:09:21 +053012856
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012857#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12858 if (!iface_down)
12859#endif
12860 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053012861
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080012862 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070012863
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012864allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053012865 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
12866 ) && (pHddCtx->spoofMacAddr.isEnabled
12867 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053012868 /* Generate new random mac addr for next scan */
12869 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053012870
12871 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
12872 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053012873 }
12874
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012875 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012876 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012877
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012878 /* Acquire wakelock to handle the case where APP's tries to suspend
12879 * immediatly after the driver gets connect request(i.e after scan)
12880 * from supplicant, this result in app's is suspending and not able
12881 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012882 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012883
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012884#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12885 if (!iface_down)
12886#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012887#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012888 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012889#endif
12890
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 EXIT();
12892 return 0;
12893}
12894
12895/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053012896 * FUNCTION: hdd_isConnectionInProgress
12897 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012898 *
12899 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012900v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
12901 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012902{
12903 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12904 hdd_station_ctx_t *pHddStaCtx = NULL;
12905 hdd_adapter_t *pAdapter = NULL;
12906 VOS_STATUS status = 0;
12907 v_U8_t staId = 0;
12908 v_U8_t *staMac = NULL;
12909
12910 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
12911
12912 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
12913 {
12914 pAdapter = pAdapterNode->pAdapter;
12915
12916 if( pAdapter )
12917 {
12918 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012919 "%s: Adapter with device mode %s (%d) exists",
12920 __func__, hdd_device_modetoString(pAdapter->device_mode),
12921 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012922 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053012923 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12924 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
12925 (eConnectionState_Connecting ==
12926 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12927 {
12928 hddLog(VOS_TRACE_LEVEL_ERROR,
12929 "%s: %p(%d) Connection is in progress", __func__,
12930 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012931 if (session_id && reason)
12932 {
12933 *session_id = pAdapter->sessionId;
12934 *reason = eHDD_CONNECTION_IN_PROGRESS;
12935 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012936 return VOS_TRUE;
12937 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012938 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053012939 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012940 {
12941 hddLog(VOS_TRACE_LEVEL_ERROR,
12942 "%s: %p(%d) Reassociation is in progress", __func__,
12943 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012944 if (session_id && reason)
12945 {
12946 *session_id = pAdapter->sessionId;
12947 *reason = eHDD_REASSOC_IN_PROGRESS;
12948 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012949 return VOS_TRUE;
12950 }
12951 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012952 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12953 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012954 {
12955 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12956 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012957 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012958 {
12959 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
12960 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012961 "%s: client " MAC_ADDRESS_STR
12962 " is in the middle of WPS/EAPOL exchange.", __func__,
12963 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012964 if (session_id && reason)
12965 {
12966 *session_id = pAdapter->sessionId;
12967 *reason = eHDD_EAPOL_IN_PROGRESS;
12968 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012969 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012970 }
12971 }
12972 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
12973 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
12974 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012975 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12976 ptSapContext pSapCtx = NULL;
12977 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12978 if(pSapCtx == NULL){
12979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12980 FL("psapCtx is NULL"));
12981 return VOS_FALSE;
12982 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012983 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
12984 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012985 if ((pSapCtx->aStaInfo[staId].isUsed) &&
12986 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012987 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012988 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012989
12990 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012991 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
12992 "middle of WPS/EAPOL exchange.", __func__,
12993 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012994 if (session_id && reason)
12995 {
12996 *session_id = pAdapter->sessionId;
12997 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
12998 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012999 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013000 }
13001 }
13002 }
13003 }
13004 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13005 pAdapterNode = pNext;
13006 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053013007 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013008}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013009
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013010/**
13011 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
13012 * to the Scan request
13013 * @scanRequest: Pointer to the csr scan request
13014 * @request: Pointer to the scan request from supplicant
13015 *
13016 * Return: None
13017 */
13018#ifdef CFG80211_SCAN_BSSID
13019static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13020 struct cfg80211_scan_request *request)
13021{
13022 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13023}
13024#else
13025static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13026 struct cfg80211_scan_request *request)
13027{
13028}
13029#endif
13030
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013031/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013032 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 * this scan respond to scan trigger and update cfg80211 scan database
13034 * later, scan dump command can be used to recieve scan results
13035 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013036int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013037#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13038 struct net_device *dev,
13039#endif
13040 struct cfg80211_scan_request *request)
13041{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013042 hdd_adapter_t *pAdapter = NULL;
13043 hdd_context_t *pHddCtx = NULL;
13044 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013045 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 tCsrScanRequest scanRequest;
13047 tANI_U8 *channelList = NULL, i;
13048 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013049 int status;
13050 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013052 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013053 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013054 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013055 v_U8_t curr_session_id;
13056 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013057
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013058#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13059 struct net_device *dev = NULL;
13060 if (NULL == request)
13061 {
13062 hddLog(VOS_TRACE_LEVEL_ERROR,
13063 "%s: scan req param null", __func__);
13064 return -EINVAL;
13065 }
13066 dev = request->wdev->netdev;
13067#endif
13068
13069 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13070 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13071 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13072
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 ENTER();
13074
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013075 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13076 __func__, hdd_device_modetoString(pAdapter->device_mode),
13077 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013078
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013079 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013080 if (0 != status)
13081 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013082 return status;
13083 }
13084
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013085 if (NULL == pwextBuf)
13086 {
13087 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13088 __func__);
13089 return -EIO;
13090 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013091 cfg_param = pHddCtx->cfg_ini;
13092 pScanInfo = &pHddCtx->scan_info;
13093
Jeff Johnson295189b2012-06-20 16:38:30 -070013094#ifdef WLAN_BTAMP_FEATURE
13095 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013096 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013098 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 "%s: No scanning when AMP is on", __func__);
13100 return -EOPNOTSUPP;
13101 }
13102#endif
13103 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013104 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013106 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013107 "%s: Not scanning on device_mode = %s (%d)",
13108 __func__, hdd_device_modetoString(pAdapter->device_mode),
13109 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 return -EOPNOTSUPP;
13111 }
13112
13113 if (TRUE == pScanInfo->mScanPending)
13114 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013115 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13116 {
13117 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13118 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013119 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 }
13121
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013122 // Don't allow scan if PNO scan is going on.
13123 if (pHddCtx->isPnoEnable)
13124 {
13125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13126 FL("pno scan in progress"));
13127 return -EBUSY;
13128 }
13129
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013130 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013131 //Channel and action frame is pending
13132 //Otherwise Cancel Remain On Channel and allow Scan
13133 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013134 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013135 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013136 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013137 return -EBUSY;
13138 }
13139
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13141 {
13142 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013143 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13147 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013148 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 "%s: MAX TM Level Scan not allowed", __func__);
13150 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013151 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013152 }
13153 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13154
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013155 /* Check if scan is allowed at this point of time.
13156 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013157 if (TRUE == pHddCtx->btCoexModeSet)
13158 {
13159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13160 FL("BTCoex Mode operation in progress"));
13161 return -EBUSY;
13162 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013163 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013164 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013165 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013166 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
13167 pHddCtx->last_scan_reject_reason != curr_reason ||
13168 !pHddCtx->last_scan_reject_timestamp)
13169 {
13170 pHddCtx->last_scan_reject_session_id = curr_session_id;
13171 pHddCtx->last_scan_reject_reason = curr_reason;
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053013172 pHddCtx->last_scan_reject_timestamp = jiffies_to_msecs(jiffies);
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013173 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013174 else {
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +053013175 if ((jiffies_to_msecs(jiffies) -
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013176 pHddCtx->last_scan_reject_timestamp) >=
13177 SCAN_REJECT_THRESHOLD_TIME)
13178 {
13179 pHddCtx->last_scan_reject_timestamp = 0;
13180 if (pHddCtx->cfg_ini->enableFatalEvent)
13181 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
13182 WLAN_LOG_INDICATOR_HOST_DRIVER,
13183 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
13184 FALSE, FALSE);
13185 else
13186 {
13187 hddLog(LOGE, FL("Triggering SSR"));
13188 vos_wlanRestart();
13189 }
13190 }
13191 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013192 return -EBUSY;
13193 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013194 pHddCtx->last_scan_reject_timestamp = 0;
13195 pHddCtx->last_scan_reject_session_id = 0xFF;
13196 pHddCtx->last_scan_reject_reason = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013197
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 vos_mem_zero( &scanRequest, sizeof(scanRequest));
13199
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013200 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
13201 * Becasue of this, driver is assuming that this is not wildcard scan and so
13202 * is not aging out the scan results.
13203 */
13204 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013206 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013208
13209 if ((request->ssids) && (0 < request->n_ssids))
13210 {
13211 tCsrSSIDInfo *SsidInfo;
13212 int j;
13213 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
13214 /* Allocate num_ssid tCsrSSIDInfo structure */
13215 SsidInfo = scanRequest.SSIDs.SSIDList =
13216 ( tCsrSSIDInfo *)vos_mem_malloc(
13217 request->n_ssids*sizeof(tCsrSSIDInfo));
13218
13219 if(NULL == scanRequest.SSIDs.SSIDList)
13220 {
13221 hddLog(VOS_TRACE_LEVEL_ERROR,
13222 "%s: memory alloc failed SSIDInfo buffer", __func__);
13223 return -ENOMEM;
13224 }
13225
13226 /* copy all the ssid's and their length */
13227 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
13228 {
13229 /* get the ssid length */
13230 SsidInfo->SSID.length = request->ssids[j].ssid_len;
13231 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
13232 SsidInfo->SSID.length);
13233 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
13234 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
13235 j, SsidInfo->SSID.ssId);
13236 }
13237 /* set the scan type to active */
13238 scanRequest.scanType = eSIR_ACTIVE_SCAN;
13239 }
13240 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013242 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13243 TRACE_CODE_HDD_CFG80211_SCAN,
13244 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 /* set the scan type to active */
13246 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013248 else
13249 {
13250 /*Set the scan type to default type, in this case it is ACTIVE*/
13251 scanRequest.scanType = pScanInfo->scan_mode;
13252 }
13253 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13254 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013255
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013256 csr_scan_request_assign_bssid(&scanRequest, request);
13257
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 /* set BSSType to default type */
13259 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13260
13261 /*TODO: scan the requested channels only*/
13262
13263 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013264 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013266 hddLog(VOS_TRACE_LEVEL_WARN,
13267 "No of Scan Channels exceeded limit: %d", request->n_channels);
13268 request->n_channels = MAX_CHANNEL;
13269 }
13270
13271 hddLog(VOS_TRACE_LEVEL_INFO,
13272 "No of Scan Channels: %d", request->n_channels);
13273
13274
13275 if( request->n_channels )
13276 {
13277 char chList [(request->n_channels*5)+1];
13278 int len;
13279 channelList = vos_mem_malloc( request->n_channels );
13280 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013281 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013282 hddLog(VOS_TRACE_LEVEL_ERROR,
13283 "%s: memory alloc failed channelList", __func__);
13284 status = -ENOMEM;
13285 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013286 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013287
13288 for( i = 0, len = 0; i < request->n_channels ; i++ )
13289 {
13290 channelList[i] = request->channels[i]->hw_value;
13291 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13292 }
13293
Nirav Shah20ac06f2013-12-12 18:14:06 +053013294 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013295 "Channel-List: %s ", chList);
13296 }
c_hpothu53512302014-04-15 18:49:53 +053013297
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013298 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13299 scanRequest.ChannelInfo.ChannelList = channelList;
13300
13301 /* set requestType to full scan */
13302 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13303
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013304 /* if there is back to back scan happening in driver with in
13305 * nDeferScanTimeInterval interval driver should defer new scan request
13306 * and should provide last cached scan results instead of new channel list.
13307 * This rule is not applicable if scan is p2p scan.
13308 * This condition will work only in case when last request no of channels
13309 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013310 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013311 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013312 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013313
Sushant Kaushik86592172015-04-27 16:35:03 +053013314 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13315 /* if wps ie is NULL , then only defer scan */
13316 if ( pWpsIe == NULL &&
13317 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013318 {
13319 if ( pScanInfo->last_scan_timestamp !=0 &&
13320 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13321 {
13322 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13323 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13324 vos_mem_compare(pScanInfo->last_scan_channelList,
13325 channelList, pScanInfo->last_scan_numChannels))
13326 {
13327 hddLog(VOS_TRACE_LEVEL_WARN,
13328 " New and old station scan time differ is less then %u",
13329 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13330
13331 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013332 pAdapter);
13333
Agarwal Ashish57e84372014-12-05 18:26:53 +053013334 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013335 "Return old cached scan as all channels and no of channels are same");
13336
Agarwal Ashish57e84372014-12-05 18:26:53 +053013337 if (0 > ret)
13338 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013339
Agarwal Ashish57e84372014-12-05 18:26:53 +053013340 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013341
13342 status = eHAL_STATUS_SUCCESS;
13343 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013344 }
13345 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013346 }
13347
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013348 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13349 * search (Flush on both full scan and social scan but not on single
13350 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13351 */
13352
13353 /* Supplicant does single channel scan after 8-way handshake
13354 * and in that case driver shoudnt flush scan results. If
13355 * driver flushes the scan results here and unfortunately if
13356 * the AP doesnt respond to our probe req then association
13357 * fails which is not desired
13358 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013359 if ((request->n_ssids == 1)
13360 && (request->ssids != NULL)
13361 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13362 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013363
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013364 if( is_p2p_scan ||
13365 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013366 {
13367 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13368 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13369 pAdapter->sessionId );
13370 }
13371
13372 if( request->ie_len )
13373 {
13374 /* save this for future association (join requires this) */
13375 /*TODO: Array needs to be converted to dynamic allocation,
13376 * as multiple ie.s can be sent in cfg80211_scan_request structure
13377 * CR 597966
13378 */
13379 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13380 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13381 pScanInfo->scanAddIE.length = request->ie_len;
13382
13383 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13384 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13385 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013387 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013389 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13390 memcpy( pwextBuf->roamProfile.addIEScan,
13391 request->ie, request->ie_len);
13392 }
13393 else
13394 {
13395 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13396 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 }
13398
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013399 }
13400 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13401 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13402
13403 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13404 request->ie_len);
13405 if (pP2pIe != NULL)
13406 {
13407#ifdef WLAN_FEATURE_P2P_DEBUG
13408 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13409 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13410 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013411 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013412 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13413 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13414 "Go nego completed to Connection is started");
13415 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13416 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013417 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013418 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13419 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013421 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13422 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13423 "Disconnected state to Connection is started");
13424 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13425 "for 4way Handshake");
13426 }
13427#endif
13428
13429 /* no_cck will be set during p2p find to disable 11b rates */
13430 if(TRUE == request->no_cck)
13431 {
13432 hddLog(VOS_TRACE_LEVEL_INFO,
13433 "%s: This is a P2P Search", __func__);
13434 scanRequest.p2pSearch = 1;
13435
13436 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013437 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013438 /* set requestType to P2P Discovery */
13439 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13440 }
13441
13442 /*
13443 Skip Dfs Channel in case of P2P Search
13444 if it is set in ini file
13445 */
13446 if(cfg_param->skipDfsChnlInP2pSearch)
13447 {
13448 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013449 }
13450 else
13451 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013452 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013454
Agarwal Ashish4f616132013-12-30 23:32:50 +053013455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 }
13457 }
13458
13459 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13460
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013461#ifdef FEATURE_WLAN_TDLS
13462 /* if tdls disagree scan right now, return immediately.
13463 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13464 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13465 */
13466 status = wlan_hdd_tdls_scan_callback (pAdapter,
13467 wiphy,
13468#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13469 dev,
13470#endif
13471 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013472 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013473 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053013474 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013475 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13476 "scan rejected %d", __func__, status);
13477 else
13478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13479 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013480 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053013481 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013482 }
13483#endif
13484
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013485 /* acquire the wakelock to avoid the apps suspend during the scan. To
13486 * address the following issues.
13487 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13488 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13489 * for long time, this result in apps running at full power for long time.
13490 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13491 * be stuck in full power because of resume BMPS
13492 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013493 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013494
Nirav Shah20ac06f2013-12-12 18:14:06 +053013495 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13496 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013497 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13498 scanRequest.requestType, scanRequest.scanType,
13499 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013500 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13501
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013502 if (pHddCtx->spoofMacAddr.isEnabled &&
13503 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013504 {
13505 hddLog(VOS_TRACE_LEVEL_INFO,
13506 "%s: MAC Spoofing enabled for current scan", __func__);
13507 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13508 * to fill TxBds for probe request during current scan
13509 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013510 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013511 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013512
13513 if(status != VOS_STATUS_SUCCESS)
13514 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013515 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013516 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013517#ifdef FEATURE_WLAN_TDLS
13518 wlan_hdd_tdls_scan_done_callback(pAdapter);
13519#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013520 goto free_mem;
13521 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013522 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013523 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013524 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 pAdapter->sessionId, &scanRequest, &scanId,
13526 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013527
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 if (eHAL_STATUS_SUCCESS != status)
13529 {
13530 hddLog(VOS_TRACE_LEVEL_ERROR,
13531 "%s: sme_ScanRequest returned error %d", __func__, status);
13532 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013533 if(eHAL_STATUS_RESOURCES == status)
13534 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013535 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13536 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013537 status = -EBUSY;
13538 } else {
13539 status = -EIO;
13540 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013541 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013542
13543#ifdef FEATURE_WLAN_TDLS
13544 wlan_hdd_tdls_scan_done_callback(pAdapter);
13545#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 goto free_mem;
13547 }
13548
13549 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013550 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 pAdapter->request = request;
13552 pScanInfo->scanId = scanId;
13553
13554 complete(&pScanInfo->scan_req_completion_event);
13555
13556free_mem:
13557 if( scanRequest.SSIDs.SSIDList )
13558 {
13559 vos_mem_free(scanRequest.SSIDs.SSIDList);
13560 }
13561
13562 if( channelList )
13563 vos_mem_free( channelList );
13564
13565 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 return status;
13567}
13568
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013569int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13570#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13571 struct net_device *dev,
13572#endif
13573 struct cfg80211_scan_request *request)
13574{
13575 int ret;
13576
13577 vos_ssr_protect(__func__);
13578 ret = __wlan_hdd_cfg80211_scan(wiphy,
13579#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13580 dev,
13581#endif
13582 request);
13583 vos_ssr_unprotect(__func__);
13584
13585 return ret;
13586}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013587
13588void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13589{
13590 v_U8_t iniDot11Mode =
13591 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13592 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13593
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013594 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13595 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013596 switch ( iniDot11Mode )
13597 {
13598 case eHDD_DOT11_MODE_AUTO:
13599 case eHDD_DOT11_MODE_11ac:
13600 case eHDD_DOT11_MODE_11ac_ONLY:
13601#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013602 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13603 sme_IsFeatureSupportedByFW(DOT11AC) )
13604 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13605 else
13606 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013607#else
13608 hddDot11Mode = eHDD_DOT11_MODE_11n;
13609#endif
13610 break;
13611 case eHDD_DOT11_MODE_11n:
13612 case eHDD_DOT11_MODE_11n_ONLY:
13613 hddDot11Mode = eHDD_DOT11_MODE_11n;
13614 break;
13615 default:
13616 hddDot11Mode = iniDot11Mode;
13617 break;
13618 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013619#ifdef WLAN_FEATURE_AP_HT40_24G
13620 if (operationChannel > SIR_11B_CHANNEL_END)
13621#endif
13622 {
13623 /* This call decides required channel bonding mode */
13624 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013625 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13626 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013627 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013628}
13629
Jeff Johnson295189b2012-06-20 16:38:30 -070013630/*
13631 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013632 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013634int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013635 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13636 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013637{
13638 int status = 0;
13639 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013640 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 v_U32_t roamId;
13642 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013644 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013645
13646 ENTER();
13647
13648 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013649 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13650
13651 status = wlan_hdd_validate_context(pHddCtx);
13652 if (status)
13653 {
Yue Mae36e3552014-03-05 17:06:20 -080013654 return status;
13655 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013656
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13658 {
13659 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13660 return -EINVAL;
13661 }
13662
13663 pRoamProfile = &pWextState->roamProfile;
13664
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013665 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013667 hdd_station_ctx_t *pHddStaCtx;
13668 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013669
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013670 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13671
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013672 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13674 {
13675 /*QoS not enabled in cfg file*/
13676 pRoamProfile->uapsd_mask = 0;
13677 }
13678 else
13679 {
13680 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013681 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13683 }
13684
13685 pRoamProfile->SSIDs.numOfSSIDs = 1;
13686 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13687 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013688 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13690 ssid, ssid_len);
13691
13692 if (bssid)
13693 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013694 pValidBssid = bssid;
13695 }
13696 else if (bssid_hint)
13697 {
13698 pValidBssid = bssid_hint;
13699 }
13700 if (pValidBssid)
13701 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013703 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013705 /* Save BSSID in seperate variable as well, as RoamProfile
13706 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 case of join failure we should send valid BSSID to supplicant
13708 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013709 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 WNI_CFG_BSSID_LEN);
13711 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070013712 else
13713 {
13714 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
13715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013716
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013717 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13718 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13720 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013721 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 /*set gen ie*/
13723 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13724 /*set auth*/
13725 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013727#ifdef FEATURE_WLAN_WAPI
13728 if (pAdapter->wapi_info.nWapiMode)
13729 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013730 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 switch (pAdapter->wapi_info.wapiAuthMode)
13732 {
13733 case WAPI_AUTH_MODE_PSK:
13734 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013735 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 pAdapter->wapi_info.wapiAuthMode);
13737 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13738 break;
13739 }
13740 case WAPI_AUTH_MODE_CERT:
13741 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013742 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 pAdapter->wapi_info.wapiAuthMode);
13744 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13745 break;
13746 }
13747 } // End of switch
13748 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13749 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13750 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013751 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 pRoamProfile->AuthType.numEntries = 1;
13753 pRoamProfile->EncryptionType.numEntries = 1;
13754 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13755 pRoamProfile->mcEncryptionType.numEntries = 1;
13756 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13757 }
13758 }
13759#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013760#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013761 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013762 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13763 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13764 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013765 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13766 sizeof (tSirGtkOffloadParams));
13767 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013768 }
13769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 pRoamProfile->csrPersona = pAdapter->device_mode;
13771
Jeff Johnson32d95a32012-09-10 13:15:23 -070013772 if( operatingChannel )
13773 {
13774 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13775 pRoamProfile->ChannelInfo.numOfChannels = 1;
13776 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013777 else
13778 {
13779 pRoamProfile->ChannelInfo.ChannelList = NULL;
13780 pRoamProfile->ChannelInfo.numOfChannels = 0;
13781 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013782 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13783 {
13784 hdd_select_cbmode(pAdapter,operatingChannel);
13785 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013786
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013787 /*
13788 * Change conn_state to connecting before sme_RoamConnect(),
13789 * because sme_RoamConnect() has a direct path to call
13790 * hdd_smeRoamCallback(), which will change the conn_state
13791 * If direct path, conn_state will be accordingly changed
13792 * to NotConnected or Associated by either
13793 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13794 * in sme_RoamCallback()
13795 * if sme_RomConnect is to be queued,
13796 * Connecting state will remain until it is completed.
13797 * If connection state is not changed,
13798 * connection state will remain in eConnectionState_NotConnected state.
13799 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13800 * if conn state is eConnectionState_NotConnected.
13801 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13802 * informed of connect result indication which is an issue.
13803 */
13804
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013805 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13806 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013807 {
13808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013809 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013810 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
13811 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053013812 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013813 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 pAdapter->sessionId, pRoamProfile, &roamId);
13815
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013816 if ((eHAL_STATUS_SUCCESS != status) &&
13817 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13818 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013819
13820 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013821 hddLog(VOS_TRACE_LEVEL_ERROR,
13822 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
13823 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013824 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013825 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013826 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013827 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013828
13829 pRoamProfile->ChannelInfo.ChannelList = NULL;
13830 pRoamProfile->ChannelInfo.numOfChannels = 0;
13831
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 }
13833 else
13834 {
13835 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
13836 return -EINVAL;
13837 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013838 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 return status;
13840}
13841
13842/*
13843 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
13844 * This function is used to set the authentication type (OPEN/SHARED).
13845 *
13846 */
13847static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
13848 enum nl80211_auth_type auth_type)
13849{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013850 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13852
13853 ENTER();
13854
13855 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013856 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013859 hddLog(VOS_TRACE_LEVEL_INFO,
13860 "%s: set authentication type to AUTOSWITCH", __func__);
13861 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
13862 break;
13863
13864 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013865#ifdef WLAN_FEATURE_VOWIFI_11R
13866 case NL80211_AUTHTYPE_FT:
13867#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013868 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 "%s: set authentication type to OPEN", __func__);
13870 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13871 break;
13872
13873 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013874 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 "%s: set authentication type to SHARED", __func__);
13876 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
13877 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013878#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013880 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 "%s: set authentication type to CCKM WPA", __func__);
13882 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
13883 break;
13884#endif
13885
13886
13887 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013888 hddLog(VOS_TRACE_LEVEL_ERROR,
13889 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 auth_type);
13891 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
13892 return -EINVAL;
13893 }
13894
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013895 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 pHddStaCtx->conn_info.authType;
13897 return 0;
13898}
13899
13900/*
13901 * FUNCTION: wlan_hdd_set_akm_suite
13902 * This function is used to set the key mgmt type(PSK/8021x).
13903 *
13904 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013905static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 u32 key_mgmt
13907 )
13908{
13909 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13910 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053013911 /* Should be in ieee802_11_defs.h */
13912#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
13913#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 /*set key mgmt type*/
13915 switch(key_mgmt)
13916 {
13917 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053013918 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013919#ifdef WLAN_FEATURE_VOWIFI_11R
13920 case WLAN_AKM_SUITE_FT_PSK:
13921#endif
13922 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 __func__);
13924 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
13925 break;
13926
13927 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053013928 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013929#ifdef WLAN_FEATURE_VOWIFI_11R
13930 case WLAN_AKM_SUITE_FT_8021X:
13931#endif
13932 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 __func__);
13934 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13935 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013936#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013937#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
13938#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
13939 case WLAN_AKM_SUITE_CCKM:
13940 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
13941 __func__);
13942 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
13943 break;
13944#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070013945#ifndef WLAN_AKM_SUITE_OSEN
13946#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
13947 case WLAN_AKM_SUITE_OSEN:
13948 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
13949 __func__);
13950 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13951 break;
13952#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013953
13954 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013955 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 __func__, key_mgmt);
13957 return -EINVAL;
13958
13959 }
13960 return 0;
13961}
13962
13963/*
13964 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013965 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 * (NONE/WEP40/WEP104/TKIP/CCMP).
13967 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013968static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
13969 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 bool ucast
13971 )
13972{
13973 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013974 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13976
13977 ENTER();
13978
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013979 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013981 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 __func__, cipher);
13983 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13984 }
13985 else
13986 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013987
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013989 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 {
13991 case IW_AUTH_CIPHER_NONE:
13992 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13993 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013994
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013996 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013998
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053014000 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014002
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 case WLAN_CIPHER_SUITE_TKIP:
14004 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
14005 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014006
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 case WLAN_CIPHER_SUITE_CCMP:
14008 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14009 break;
14010#ifdef FEATURE_WLAN_WAPI
14011 case WLAN_CIPHER_SUITE_SMS4:
14012 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14013 break;
14014#endif
14015
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014016#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 case WLAN_CIPHER_SUITE_KRK:
14018 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14019 break;
14020#endif
14021 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014022 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 __func__, cipher);
14024 return -EOPNOTSUPP;
14025 }
14026 }
14027
14028 if (ucast)
14029 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014030 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 __func__, encryptionType);
14032 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14033 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014034 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 encryptionType;
14036 }
14037 else
14038 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014039 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 __func__, encryptionType);
14041 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14042 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14043 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14044 }
14045
14046 return 0;
14047}
14048
14049
14050/*
14051 * FUNCTION: wlan_hdd_cfg80211_set_ie
14052 * This function is used to parse WPA/RSN IE's.
14053 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014054int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014055#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14056 const u8 *ie,
14057#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014058 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014059#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 size_t ie_len
14061 )
14062{
14063 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014064#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14065 const u8 *genie = ie;
14066#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014068#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 v_U16_t remLen = ie_len;
14070#ifdef FEATURE_WLAN_WAPI
14071 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14072 u16 *tmp;
14073 v_U16_t akmsuiteCount;
14074 int *akmlist;
14075#endif
14076 ENTER();
14077
14078 /* clear previous assocAddIE */
14079 pWextState->assocAddIE.length = 0;
14080 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014081 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014082
14083 while (remLen >= 2)
14084 {
14085 v_U16_t eLen = 0;
14086 v_U8_t elementId;
14087 elementId = *genie++;
14088 eLen = *genie++;
14089 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014090
Arif Hussain6d2a3322013-11-17 19:50:10 -080014091 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014093
14094 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014096 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014097 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 -070014098 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014099 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 "%s: Invalid WPA IE", __func__);
14101 return -EINVAL;
14102 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014103 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 {
14105 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014106 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014108
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014109 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014111 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14112 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 VOS_ASSERT(0);
14114 return -ENOMEM;
14115 }
14116 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14117 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14118 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014119
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14121 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14122 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14123 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014124 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14125 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14127 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14128 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14129 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14130 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14131 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014132 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014133 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 {
14135 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014136 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014138
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014139 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014141 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14142 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 VOS_ASSERT(0);
14144 return -ENOMEM;
14145 }
14146 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14147 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14148 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014149
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14151 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014153#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014154 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
14155 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 /*Consider WFD IE, only for P2P Client */
14157 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
14158 {
14159 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014160 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014162
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014163 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014165 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14166 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 VOS_ASSERT(0);
14168 return -ENOMEM;
14169 }
14170 // WFD IE is saved to Additional IE ; it should be accumulated to handle
14171 // WPS IE + P2P IE + WFD IE
14172 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14173 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014174
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14176 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14177 }
14178#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014179 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014180 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014181 HS20_OUI_TYPE_SIZE)) )
14182 {
14183 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014184 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014185 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014186
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014187 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014188 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014189 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14190 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014191 VOS_ASSERT(0);
14192 return -ENOMEM;
14193 }
14194 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14195 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014196
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014197 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14198 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14199 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014200 /* Appending OSEN Information Element in Assiciation Request */
14201 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
14202 OSEN_OUI_TYPE_SIZE)) )
14203 {
14204 v_U16_t curAddIELen = pWextState->assocAddIE.length;
14205 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
14206 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014207
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014208 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014209 {
14210 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14211 "Need bigger buffer space");
14212 VOS_ASSERT(0);
14213 return -ENOMEM;
14214 }
14215 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14216 pWextState->assocAddIE.length += eLen + 2;
14217
14218 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
14219 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14220 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14221 }
14222
Abhishek Singh4322e622015-06-10 15:42:54 +053014223 /* Update only for WPA IE */
14224 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
14225 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014226
14227 /* populating as ADDIE in beacon frames */
14228 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014229 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014230 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
14231 {
14232 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14233 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
14234 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14235 {
14236 hddLog(LOGE,
14237 "Coldn't pass "
14238 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
14239 }
14240 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
14241 else
14242 hddLog(LOGE,
14243 "Could not pass on "
14244 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
14245
14246 /* IBSS mode doesn't contain params->proberesp_ies still
14247 beaconIE's need to be populated in probe response frames */
14248 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
14249 {
14250 u16 rem_probe_resp_ie_len = eLen + 2;
14251 u8 probe_rsp_ie_len[3] = {0};
14252 u8 counter = 0;
14253
14254 /* Check Probe Resp Length if it is greater then 255 then
14255 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14256 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14257 not able Store More then 255 bytes into One Variable */
14258
14259 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14260 {
14261 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14262 {
14263 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14264 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14265 }
14266 else
14267 {
14268 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14269 rem_probe_resp_ie_len = 0;
14270 }
14271 }
14272
14273 rem_probe_resp_ie_len = 0;
14274
14275 if (probe_rsp_ie_len[0] > 0)
14276 {
14277 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14278 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14279 (tANI_U8*)(genie - 2),
14280 probe_rsp_ie_len[0], NULL,
14281 eANI_BOOLEAN_FALSE)
14282 == eHAL_STATUS_FAILURE)
14283 {
14284 hddLog(LOGE,
14285 "Could not pass"
14286 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14287 }
14288 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14289 }
14290
14291 if (probe_rsp_ie_len[1] > 0)
14292 {
14293 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14294 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14295 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14296 probe_rsp_ie_len[1], NULL,
14297 eANI_BOOLEAN_FALSE)
14298 == eHAL_STATUS_FAILURE)
14299 {
14300 hddLog(LOGE,
14301 "Could not pass"
14302 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14303 }
14304 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14305 }
14306
14307 if (probe_rsp_ie_len[2] > 0)
14308 {
14309 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14310 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14311 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14312 probe_rsp_ie_len[2], NULL,
14313 eANI_BOOLEAN_FALSE)
14314 == eHAL_STATUS_FAILURE)
14315 {
14316 hddLog(LOGE,
14317 "Could not pass"
14318 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14319 }
14320 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14321 }
14322
14323 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14324 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14325 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14326 {
14327 hddLog(LOGE,
14328 "Could not pass"
14329 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14330 }
14331 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014332 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 break;
14334 case DOT11F_EID_RSN:
14335 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14336 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14337 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14338 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14339 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14340 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014341
Abhishek Singhb16f3562016-01-20 11:08:32 +053014342 /* Appending extended capabilities with Interworking or
14343 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053014344 *
14345 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053014346 * interworkingService or bsstransition bit is set to 1.
14347 * Driver is only interested in interworkingService and
14348 * bsstransition capability from supplicant.
14349 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053014350 * required from supplicat, it needs to be handled while
14351 * sending Assoc Req in LIM.
14352 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014353 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014354 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014355 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014356 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014357 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014358
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014359 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014360 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014361 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14362 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014363 VOS_ASSERT(0);
14364 return -ENOMEM;
14365 }
14366 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14367 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014368
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014369 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14370 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14371 break;
14372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014373#ifdef FEATURE_WLAN_WAPI
14374 case WLAN_EID_WAPI:
14375 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014376 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 pAdapter->wapi_info.nWapiMode);
14378 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014379 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014380 akmsuiteCount = WPA_GET_LE16(tmp);
14381 tmp = tmp + 1;
14382 akmlist = (int *)(tmp);
14383 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14384 {
14385 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14386 }
14387 else
14388 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014389 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 VOS_ASSERT(0);
14391 return -EINVAL;
14392 }
14393
14394 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14395 {
14396 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014397 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014401 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014402 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014403 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14405 }
14406 break;
14407#endif
14408 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014409 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014411 /* when Unknown IE is received we should break and continue
14412 * to the next IE in the buffer instead we were returning
14413 * so changing this to break */
14414 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014415 }
14416 genie += eLen;
14417 remLen -= eLen;
14418 }
14419 EXIT();
14420 return 0;
14421}
14422
14423/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014424 * FUNCTION: hdd_isWPAIEPresent
14425 * Parse the received IE to find the WPA IE
14426 *
14427 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014428static bool hdd_isWPAIEPresent(
14429#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14430 const u8 *ie,
14431#else
14432 u8 *ie,
14433#endif
14434 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014435{
14436 v_U8_t eLen = 0;
14437 v_U16_t remLen = ie_len;
14438 v_U8_t elementId = 0;
14439
14440 while (remLen >= 2)
14441 {
14442 elementId = *ie++;
14443 eLen = *ie++;
14444 remLen -= 2;
14445 if (eLen > remLen)
14446 {
14447 hddLog(VOS_TRACE_LEVEL_ERROR,
14448 "%s: IE length is wrong %d", __func__, eLen);
14449 return FALSE;
14450 }
14451 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14452 {
14453 /* OUI - 0x00 0X50 0XF2
14454 WPA Information Element - 0x01
14455 WPA version - 0x01*/
14456 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14457 return TRUE;
14458 }
14459 ie += eLen;
14460 remLen -= eLen;
14461 }
14462 return FALSE;
14463}
14464
14465/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014467 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014468 * parameters during connect operation.
14469 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014470int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014471 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014472 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014473{
14474 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014475 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014476 ENTER();
14477
14478 /*set wpa version*/
14479 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14480
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014481 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014483 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 {
14485 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14486 }
14487 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14488 {
14489 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14490 }
14491 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014492
14493 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 pWextState->wpaVersion);
14495
14496 /*set authentication type*/
14497 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14498
14499 if (0 > status)
14500 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014501 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014502 "%s: failed to set authentication type ", __func__);
14503 return status;
14504 }
14505
14506 /*set key mgmt type*/
14507 if (req->crypto.n_akm_suites)
14508 {
14509 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14510 if (0 > status)
14511 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014512 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 __func__);
14514 return status;
14515 }
14516 }
14517
14518 /*set pairwise cipher type*/
14519 if (req->crypto.n_ciphers_pairwise)
14520 {
14521 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14522 req->crypto.ciphers_pairwise[0], true);
14523 if (0 > status)
14524 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014525 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 "%s: failed to set unicast cipher type", __func__);
14527 return status;
14528 }
14529 }
14530 else
14531 {
14532 /*Reset previous cipher suite to none*/
14533 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14534 if (0 > status)
14535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014536 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 "%s: failed to set unicast cipher type", __func__);
14538 return status;
14539 }
14540 }
14541
14542 /*set group cipher type*/
14543 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14544 false);
14545
14546 if (0 > status)
14547 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014548 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 __func__);
14550 return status;
14551 }
14552
Chet Lanctot186b5732013-03-18 10:26:30 -070014553#ifdef WLAN_FEATURE_11W
14554 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14555#endif
14556
Jeff Johnson295189b2012-06-20 16:38:30 -070014557 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14558 if (req->ie_len)
14559 {
14560 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14561 if ( 0 > status)
14562 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 __func__);
14565 return status;
14566 }
14567 }
14568
14569 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014570 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 {
14572 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14573 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14574 )
14575 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014576 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14578 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 __func__);
14581 return -EOPNOTSUPP;
14582 }
14583 else
14584 {
14585 u8 key_len = req->key_len;
14586 u8 key_idx = req->key_idx;
14587
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014588 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 && (CSR_MAX_NUM_KEY > key_idx)
14590 )
14591 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014592 hddLog(VOS_TRACE_LEVEL_INFO,
14593 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 __func__, key_idx, key_len);
14595 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014596 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014598 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 (u8)key_len;
14600 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14601 }
14602 }
14603 }
14604 }
14605
14606 return status;
14607}
14608
14609/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014610 * FUNCTION: wlan_hdd_try_disconnect
14611 * This function is used to disconnect from previous
14612 * connection
14613 */
14614static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
14615{
14616 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014617 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014618 hdd_station_ctx_t *pHddStaCtx;
14619 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014620 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014621
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014622 ret = wlan_hdd_validate_context(pHddCtx);
14623 if (0 != ret)
14624 {
14625 return ret;
14626 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014627 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14628
14629 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14630
14631 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14632 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014633 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014634 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14635 {
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014636 spin_lock_bh(&pAdapter->lock_for_active_session);
14637 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14638 {
14639 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14640 }
14641 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014642 hdd_connSetConnectionState(pHddStaCtx,
14643 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014644 /* Issue disconnect to CSR */
14645 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014646 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014647 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014648 eCSR_DISCONNECT_REASON_UNSPECIFIED);
14649 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
14650 hddLog(LOG1,
14651 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
14652 } else if ( 0 != status ) {
14653 hddLog(LOGE,
14654 FL("csrRoamDisconnect failure, returned %d"),
14655 (int)status );
14656 result = -EINVAL;
14657 goto disconnected;
14658 }
14659 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014660 &pAdapter->disconnect_comp_var,
14661 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014662 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
14663 hddLog(LOGE,
14664 "%s: Failed to disconnect, timed out", __func__);
14665 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014666 }
14667 }
14668 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14669 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014670 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014671 &pAdapter->disconnect_comp_var,
14672 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014673 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014674 {
14675 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014676 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014677 }
14678 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014679disconnected:
14680 hddLog(LOG1,
14681 FL("Set HDD connState to eConnectionState_NotConnected"));
14682 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14683 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014684}
14685
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014686/**
14687 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
14688 * @adapter: Pointer to the HDD adapter
14689 * @req: Pointer to the structure cfg_connect_params receieved from user space
14690 *
14691 * This function will start reassociation if bssid hint, channel hint and
14692 * previous bssid parameters are present in the connect request
14693 *
14694 * Return: success if reassociation is happening
14695 * Error code if reassociation is not permitted or not happening
14696 */
14697#ifdef CFG80211_CONNECT_PREV_BSSID
14698static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14699 struct cfg80211_connect_params *req)
14700{
14701 int status = -EPERM;
14702 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
14703 hddLog(VOS_TRACE_LEVEL_INFO,
14704 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
14705 req->channel_hint->hw_value,
14706 MAC_ADDR_ARRAY(req->bssid_hint));
14707 status = hdd_reassoc(adapter, req->bssid_hint,
14708 req->channel_hint->hw_value,
14709 CONNECT_CMD_USERSPACE);
14710 }
14711 return status;
14712}
14713#else
14714static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14715 struct cfg80211_connect_params *req)
14716{
14717 return -EPERM;
14718}
14719#endif
14720
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014721/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053014722 * FUNCTION: __wlan_hdd_cfg80211_connect
14723 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014724 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014725static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 struct net_device *ndev,
14727 struct cfg80211_connect_params *req
14728 )
14729{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014730 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014731 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053014732#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
14733 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014734 const u8 *bssid_hint = req->bssid_hint;
14735#else
14736 const u8 *bssid_hint = NULL;
14737#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014738 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053014740 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014741
14742 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014743
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014744 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14745 TRACE_CODE_HDD_CFG80211_CONNECT,
14746 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014747 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014748 "%s: device_mode = %s (%d)", __func__,
14749 hdd_device_modetoString(pAdapter->device_mode),
14750 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014751
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014753 if (!pHddCtx)
14754 {
14755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14756 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053014757 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014758 }
14759
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014760 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014761 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014763 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014764 }
14765
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014766 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
14767 if (0 == status)
14768 return status;
14769
Agarwal Ashish51325b52014-06-16 16:50:49 +053014770
Jeff Johnson295189b2012-06-20 16:38:30 -070014771#ifdef WLAN_BTAMP_FEATURE
14772 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014773 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014775 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014776 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080014777 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 }
14779#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014780
14781 //If Device Mode is Station Concurrent Sessions Exit BMps
14782 //P2P Mode will be taken care in Open/close adapter
14783 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053014784 (vos_concurrent_open_sessions_running())) {
14785 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14786 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014787 }
14788
14789 /*Try disconnecting if already in connected state*/
14790 status = wlan_hdd_try_disconnect(pAdapter);
14791 if ( 0 > status)
14792 {
14793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14794 " connection"));
14795 return -EALREADY;
14796 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053014797 /* Check for max concurrent connections after doing disconnect if any*/
14798 if (vos_max_concurrent_connections_reached()) {
14799 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14800 return -ECONNREFUSED;
14801 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014802
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014804 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014805
14806 if ( 0 > status)
14807 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014808 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 __func__);
14810 return status;
14811 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053014812
14813 if (pHddCtx->spoofMacAddr.isEnabled)
14814 {
14815 hddLog(VOS_TRACE_LEVEL_INFO,
14816 "%s: MAC Spoofing enabled ", __func__);
14817 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
14818 * to fill TxBds for probe request during SSID scan which may happen
14819 * as part of connect command
14820 */
14821 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
14822 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
14823 if (status != VOS_STATUS_SUCCESS)
14824 return -ECONNREFUSED;
14825 }
14826
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014827 if (req->channel)
14828 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070014829 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014830 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053014831
14832 /* Abort if any scan is going on */
14833 status = wlan_hdd_scan_abort(pAdapter);
14834 if (0 != status)
14835 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
14836
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014837 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
14838 req->ssid_len, req->bssid,
14839 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014840
Sushant Kaushikd7083982015-03-18 14:33:24 +053014841 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014842 {
14843 //ReEnable BMPS if disabled
14844 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
14845 (NULL != pHddCtx))
14846 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053014847 if (pHddCtx->hdd_wlan_suspended)
14848 {
14849 hdd_set_pwrparams(pHddCtx);
14850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 //ReEnable Bmps and Imps back
14852 hdd_enable_bmps_imps(pHddCtx);
14853 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053014854 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 return status;
14856 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014857 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 EXIT();
14859 return status;
14860}
14861
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014862static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
14863 struct net_device *ndev,
14864 struct cfg80211_connect_params *req)
14865{
14866 int ret;
14867 vos_ssr_protect(__func__);
14868 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
14869 vos_ssr_unprotect(__func__);
14870
14871 return ret;
14872}
Jeff Johnson295189b2012-06-20 16:38:30 -070014873
14874/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014875 * FUNCTION: wlan_hdd_disconnect
14876 * This function is used to issue a disconnect request to SME
14877 */
14878int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
14879{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014880 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014881 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014882 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014883 long ret;
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053014884 eConnectionState prev_conn_state;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014885
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014886 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014887
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014888 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014889 if (0 != status)
14890 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014891 return status;
14892 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053014893 /* Indicate sme of disconnect so that in progress connection or preauth
14894 * can be aborted
14895 */
14896 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053014897 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014898 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014899
Agarwal Ashish47d18112014-08-04 19:55:07 +053014900 /* Need to apply spin lock before decreasing active sessions
14901 * as there can be chance for double decrement if context switch
14902 * Calls hdd_DisConnectHandler.
14903 */
14904
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053014905 prev_conn_state = pHddStaCtx->conn_info.connState;
14906
Agarwal Ashish47d18112014-08-04 19:55:07 +053014907 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014908 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14909 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014910 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14911 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053014912 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
14913 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014914
Abhishek Singhf4669da2014-05-26 15:07:49 +053014915 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053014916 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
14917
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014918 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014919
Mihir Shete182a0b22014-08-18 16:08:48 +053014920 /*
14921 * stop tx queues before deleting STA/BSS context from the firmware.
14922 * tx has to be disabled because the firmware can get busy dropping
14923 * the tx frames after BSS/STA has been deleted and will not send
14924 * back a response resulting in WDI timeout
14925 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053014926 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053014927 netif_tx_disable(pAdapter->dev);
14928 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014929
Mihir Shete182a0b22014-08-18 16:08:48 +053014930 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014931 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14932 pAdapter->sessionId, reason);
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053014933 if((eHAL_STATUS_CMD_NOT_QUEUED == status) &&
14934 prev_conn_state != eConnectionState_Connecting)
14935 {
14936 hddLog(LOG1,
14937 FL("status = %d, already disconnected"), status);
14938 result = 0;
14939 goto disconnected;
14940 }
14941 /*
14942 * Wait here instead of returning directly, this will block the next
14943 * connect command and allow processing of the scan for ssid and
14944 * the previous connect command in CSR. Else we might hit some
14945 * race conditions leading to SME and HDD out of sync.
14946 */
14947 else if(eHAL_STATUS_CMD_NOT_QUEUED == status)
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014948 {
14949 hddLog(LOG1,
14950 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014951 }
14952 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014953 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014954 hddLog(LOGE,
14955 FL("csrRoamDisconnect failure, returned %d"),
14956 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014957 result = -EINVAL;
14958 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014959 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014960 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014961 &pAdapter->disconnect_comp_var,
14962 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014963 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014964 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014965 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014966 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014967 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014968 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014969disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014970 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014971 FL("Set HDD connState to eConnectionState_NotConnected"));
14972 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053014973#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
14974 /* Sending disconnect event to userspace for kernel version < 3.11
14975 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
14976 */
14977 hddLog(LOG1, FL("Send disconnected event to userspace"));
14978
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053014979 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053014980 WLAN_REASON_UNSPECIFIED);
14981#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014982
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014983 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014984 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014985}
14986
14987
14988/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014989 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 * This function is used to issue a disconnect request to SME
14991 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014992static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 struct net_device *dev,
14994 u16 reason
14995 )
14996{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014997 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014998 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014999 tCsrRoamProfile *pRoamProfile;
15000 hdd_station_ctx_t *pHddStaCtx;
15001 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015002#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015003 tANI_U8 staIdx;
15004#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015005
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015007
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015008 if (!pAdapter) {
15009 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15010 return -EINVAL;
15011 }
15012
15013 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15014 if (!pHddStaCtx) {
15015 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
15016 return -EINVAL;
15017 }
15018
15019 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15020 status = wlan_hdd_validate_context(pHddCtx);
15021 if (0 != status)
15022 {
15023 return status;
15024 }
15025
15026 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
15027
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015028 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15029 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15030 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015031 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15032 __func__, hdd_device_modetoString(pAdapter->device_mode),
15033 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015034
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015035 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15036 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015037
Jeff Johnson295189b2012-06-20 16:38:30 -070015038 if (NULL != pRoamProfile)
15039 {
15040 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015041 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15042 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015044 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015046 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015047 switch(reason)
15048 {
15049 case WLAN_REASON_MIC_FAILURE:
15050 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15051 break;
15052
15053 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15054 case WLAN_REASON_DISASSOC_AP_BUSY:
15055 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15056 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15057 break;
15058
15059 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15060 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015061 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15063 break;
15064
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 default:
15066 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15067 break;
15068 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015069 pScanInfo = &pHddCtx->scan_info;
15070 if (pScanInfo->mScanPending)
15071 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015072 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015073 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015074 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015075 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015076 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015077 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015078#ifdef FEATURE_WLAN_TDLS
15079 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015080 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015081 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015082 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15083 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015084 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015085 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015086 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015088 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015089 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015090 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015091 status = sme_DeleteTdlsPeerSta(
15092 WLAN_HDD_GET_HAL_CTX(pAdapter),
15093 pAdapter->sessionId,
15094 mac);
15095 if (status != eHAL_STATUS_SUCCESS) {
15096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15097 return -EPERM;
15098 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015099 }
15100 }
15101#endif
Padma, Santhosh Kumar5f7d10e2016-12-05 18:55:06 +053015102
15103 hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"),
15104 reasonCode,
15105 pHddStaCtx->conn_info.connState);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015106 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15107 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 {
15109 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015110 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 __func__, (int)status );
15112 return -EINVAL;
15113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015115 else
15116 {
15117 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15118 "called while in %d state", __func__,
15119 pHddStaCtx->conn_info.connState);
15120 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015121 }
15122 else
15123 {
15124 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15125 }
15126
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015127 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015128 return status;
15129}
15130
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015131static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15132 struct net_device *dev,
15133 u16 reason
15134 )
15135{
15136 int ret;
15137 vos_ssr_protect(__func__);
15138 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15139 vos_ssr_unprotect(__func__);
15140
15141 return ret;
15142}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015143
Jeff Johnson295189b2012-06-20 16:38:30 -070015144/*
15145 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015146 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 * settings in IBSS mode.
15148 */
15149static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015150 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 struct cfg80211_ibss_params *params
15152 )
15153{
15154 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015155 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
15157 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015158
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 ENTER();
15160
15161 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070015162 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070015163
15164 if (params->ie_len && ( NULL != params->ie) )
15165 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015166 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15167 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015168 {
15169 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15170 encryptionType = eCSR_ENCRYPT_TYPE_AES;
15171 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015172 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015173 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015174 tDot11fIEWPA dot11WPAIE;
15175 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015176 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015177
Wilson Yang00256342013-10-10 23:13:38 -070015178 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015179 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15180 params->ie_len, DOT11F_EID_WPA);
15181 if ( NULL != ie )
15182 {
15183 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15184 // Unpack the WPA IE
15185 //Skip past the EID byte and length byte - and four byte WiFi OUI
15186 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
15187 &ie[2+4],
15188 ie[1] - 4,
15189 &dot11WPAIE);
15190 /*Extract the multicast cipher, the encType for unicast
15191 cipher for wpa-none is none*/
15192 encryptionType =
15193 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
15194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015196
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
15198
15199 if (0 > status)
15200 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015201 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015202 __func__);
15203 return status;
15204 }
15205 }
15206
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015207 pWextState->roamProfile.AuthType.authType[0] =
15208 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 eCSR_AUTH_TYPE_OPEN_SYSTEM;
15210
15211 if (params->privacy)
15212 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015213 /* Security enabled IBSS, At this time there is no information available
15214 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015216 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070015217 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015218 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070015219 *enable privacy bit in beacons */
15220
15221 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
15222 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015223 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
15224 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
15226 pWextState->roamProfile.EncryptionType.numEntries = 1;
15227 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 return status;
15229}
15230
15231/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015232 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015233 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015235static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 struct net_device *dev,
15237 struct cfg80211_ibss_params *params
15238 )
15239{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015240 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15242 tCsrRoamProfile *pRoamProfile;
15243 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015244 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15245 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015246 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070015247
15248 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015249
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015250 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15251 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
15252 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015253 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015254 "%s: device_mode = %s (%d)", __func__,
15255 hdd_device_modetoString(pAdapter->device_mode),
15256 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015257
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015258 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015259 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015260 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015261 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015262 }
15263
15264 if (NULL == pWextState)
15265 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015266 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 __func__);
15268 return -EIO;
15269 }
15270
Agarwal Ashish51325b52014-06-16 16:50:49 +053015271 if (vos_max_concurrent_connections_reached()) {
15272 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15273 return -ECONNREFUSED;
15274 }
15275
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015276 /*Try disconnecting if already in connected state*/
15277 status = wlan_hdd_try_disconnect(pAdapter);
15278 if ( 0 > status)
15279 {
15280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15281 " IBSS connection"));
15282 return -EALREADY;
15283 }
15284
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 pRoamProfile = &pWextState->roamProfile;
15286
15287 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
15288 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015289 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015290 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 return -EINVAL;
15292 }
15293
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015294 /* BSSID is provided by upper layers hence no need to AUTO generate */
15295 if (NULL != params->bssid) {
15296 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15297 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
15298 hddLog (VOS_TRACE_LEVEL_ERROR,
15299 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15300 return -EIO;
15301 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015302 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015303 }
krunal sonie9002db2013-11-25 14:24:17 -080015304 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
15305 {
15306 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15307 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
15308 {
15309 hddLog (VOS_TRACE_LEVEL_ERROR,
15310 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15311 return -EIO;
15312 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015313
15314 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080015315 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015316 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080015317 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015318
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070015320 if (NULL !=
15321#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15322 params->chandef.chan)
15323#else
15324 params->channel)
15325#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015326 {
15327 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015328 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
15329 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
15330 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15331 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015332
15333 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015334 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070015335 ieee80211_frequency_to_channel(
15336#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15337 params->chandef.chan->center_freq);
15338#else
15339 params->channel->center_freq);
15340#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015341
15342 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15343 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015345 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15346 __func__);
15347 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015349
15350 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015352 if (channelNum == validChan[indx])
15353 {
15354 break;
15355 }
15356 }
15357 if (indx >= numChans)
15358 {
15359 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 __func__, channelNum);
15361 return -EINVAL;
15362 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015363 /* Set the Operational Channel */
15364 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15365 channelNum);
15366 pRoamProfile->ChannelInfo.numOfChannels = 1;
15367 pHddStaCtx->conn_info.operationChannel = channelNum;
15368 pRoamProfile->ChannelInfo.ChannelList =
15369 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 }
15371
15372 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015373 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015374 if (status < 0)
15375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015376 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 __func__);
15378 return status;
15379 }
15380
15381 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015382 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015383 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015384 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015385
15386 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015387 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015388
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015389 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015390 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015391}
15392
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015393static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15394 struct net_device *dev,
15395 struct cfg80211_ibss_params *params
15396 )
15397{
15398 int ret = 0;
15399
15400 vos_ssr_protect(__func__);
15401 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15402 vos_ssr_unprotect(__func__);
15403
15404 return ret;
15405}
15406
Jeff Johnson295189b2012-06-20 16:38:30 -070015407/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015408 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015409 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015411static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015412 struct net_device *dev
15413 )
15414{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015415 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015416 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15417 tCsrRoamProfile *pRoamProfile;
15418 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015419 int status;
Abhishek Singh69de3302016-11-11 16:44:32 +053015420 eHalStatus hal_status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015421#ifdef WLAN_FEATURE_RMC
15422 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
15423#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015424
15425 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015426
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015427 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15428 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15429 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015430 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015431 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015432 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015433 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015434 }
15435
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015436 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15437 hdd_device_modetoString(pAdapter->device_mode),
15438 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 if (NULL == pWextState)
15440 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015441 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 __func__);
15443 return -EIO;
15444 }
15445
15446 pRoamProfile = &pWextState->roamProfile;
15447
15448 /* Issue disconnect only if interface type is set to IBSS */
15449 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15450 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015451 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015452 __func__);
15453 return -EINVAL;
15454 }
15455
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015456#ifdef WLAN_FEATURE_RMC
15457 /* Clearing add IE of beacon */
15458 if (ccmCfgSetStr(pHddCtx->hHal,
15459 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
15460 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
15461 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15462 {
15463 hddLog (VOS_TRACE_LEVEL_ERROR,
15464 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
15465 return -EINVAL;
15466 }
15467 if (ccmCfgSetInt(pHddCtx->hHal,
15468 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
15469 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15470 {
15471 hddLog (VOS_TRACE_LEVEL_ERROR,
15472 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
15473 __func__);
15474 return -EINVAL;
15475 }
15476
15477 // Reset WNI_CFG_PROBE_RSP Flags
15478 wlan_hdd_reset_prob_rspies(pAdapter);
15479
15480 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15481 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
15482 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15483 {
15484 hddLog (VOS_TRACE_LEVEL_ERROR,
15485 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
15486 __func__);
15487 return -EINVAL;
15488 }
15489#endif
15490
Jeff Johnson295189b2012-06-20 16:38:30 -070015491 /* Issue Disconnect request */
15492 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singh69de3302016-11-11 16:44:32 +053015493 hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
15494 pAdapter->sessionId,
15495 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15496 if (!HAL_STATUS_SUCCESS(hal_status)) {
15497 hddLog(LOGE,
15498 FL("sme_RoamDisconnect failed hal_status(%d)"),
15499 hal_status);
15500 return -EAGAIN;
15501 }
15502 status = wait_for_completion_timeout(
15503 &pAdapter->disconnect_comp_var,
15504 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
15505 if (!status) {
15506 hddLog(LOGE,
15507 FL("wait on disconnect_comp_var failed"));
15508 return -ETIMEDOUT;
15509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015510
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015511 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 return 0;
15513}
15514
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015515static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15516 struct net_device *dev
15517 )
15518{
15519 int ret = 0;
15520
15521 vos_ssr_protect(__func__);
15522 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15523 vos_ssr_unprotect(__func__);
15524
15525 return ret;
15526}
15527
Jeff Johnson295189b2012-06-20 16:38:30 -070015528/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015529 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 * This function is used to set the phy parameters
15531 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15532 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015533static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015534 u32 changed)
15535{
15536 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15537 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015538 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015539
15540 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015541
15542 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015543 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15544 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015545
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015546 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015547 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015548 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015549 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015550 }
15551
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15553 {
15554 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15555 WNI_CFG_RTS_THRESHOLD_STAMAX :
15556 wiphy->rts_threshold;
15557
15558 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015559 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015560 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015561 hddLog(VOS_TRACE_LEVEL_ERROR,
15562 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015563 __func__, rts_threshold);
15564 return -EINVAL;
15565 }
15566
15567 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15568 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015569 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015571 hddLog(VOS_TRACE_LEVEL_ERROR,
15572 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 __func__, rts_threshold);
15574 return -EIO;
15575 }
15576
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015577 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015578 rts_threshold);
15579 }
15580
15581 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15582 {
15583 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15584 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15585 wiphy->frag_threshold;
15586
15587 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015588 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015589 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015590 hddLog(VOS_TRACE_LEVEL_ERROR,
15591 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015592 frag_threshold);
15593 return -EINVAL;
15594 }
15595
15596 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15597 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015598 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015599 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015600 hddLog(VOS_TRACE_LEVEL_ERROR,
15601 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 __func__, frag_threshold);
15603 return -EIO;
15604 }
15605
15606 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15607 frag_threshold);
15608 }
15609
15610 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15611 || (changed & WIPHY_PARAM_RETRY_LONG))
15612 {
15613 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15614 wiphy->retry_short :
15615 wiphy->retry_long;
15616
15617 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15618 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15619 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015620 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 __func__, retry_value);
15622 return -EINVAL;
15623 }
15624
15625 if (changed & WIPHY_PARAM_RETRY_SHORT)
15626 {
15627 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15628 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015629 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015630 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015631 hddLog(VOS_TRACE_LEVEL_ERROR,
15632 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 __func__, retry_value);
15634 return -EIO;
15635 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015636 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015637 __func__, retry_value);
15638 }
15639 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15640 {
15641 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15642 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015643 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015645 hddLog(VOS_TRACE_LEVEL_ERROR,
15646 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 __func__, retry_value);
15648 return -EIO;
15649 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015650 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 __func__, retry_value);
15652 }
15653 }
15654
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015655 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015656 return 0;
15657}
15658
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015659static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15660 u32 changed)
15661{
15662 int ret;
15663
15664 vos_ssr_protect(__func__);
15665 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15666 vos_ssr_unprotect(__func__);
15667
15668 return ret;
15669}
15670
Jeff Johnson295189b2012-06-20 16:38:30 -070015671/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015672 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 * This function is used to set the txpower
15674 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015675static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015676#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15677 struct wireless_dev *wdev,
15678#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015679#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015680 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015681#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015682 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015683#endif
15684 int dbm)
15685{
15686 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015687 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15689 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015690 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015691
15692 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015693
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015694 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15695 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15696 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015697 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015698 if (0 != status)
15699 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015700 return status;
15701 }
15702
15703 hHal = pHddCtx->hHal;
15704
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015705 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15706 dbm, ccmCfgSetCallback,
15707 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015709 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015710 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15711 return -EIO;
15712 }
15713
15714 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15715 dbm);
15716
15717 switch(type)
15718 {
15719 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
15720 /* Fall through */
15721 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
15722 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
15723 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015724 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
15725 __func__);
15726 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070015727 }
15728 break;
15729 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015730 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 __func__);
15732 return -EOPNOTSUPP;
15733 break;
15734 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015735 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
15736 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070015737 return -EIO;
15738 }
15739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015740 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 return 0;
15742}
15743
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015744static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
15745#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15746 struct wireless_dev *wdev,
15747#endif
15748#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15749 enum tx_power_setting type,
15750#else
15751 enum nl80211_tx_power_setting type,
15752#endif
15753 int dbm)
15754{
15755 int ret;
15756 vos_ssr_protect(__func__);
15757 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
15758#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15759 wdev,
15760#endif
15761#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15762 type,
15763#else
15764 type,
15765#endif
15766 dbm);
15767 vos_ssr_unprotect(__func__);
15768
15769 return ret;
15770}
15771
Jeff Johnson295189b2012-06-20 16:38:30 -070015772/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015773 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015774 * This function is used to read the txpower
15775 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015776static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015777#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15778 struct wireless_dev *wdev,
15779#endif
15780 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070015781{
15782
15783 hdd_adapter_t *pAdapter;
15784 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015785 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015786
Jeff Johnsone7245742012-09-05 17:12:55 -070015787 ENTER();
15788
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015789 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015790 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015791 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015792 *dbm = 0;
15793 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015794 }
15795
Jeff Johnson295189b2012-06-20 16:38:30 -070015796 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
15797 if (NULL == pAdapter)
15798 {
15799 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
15800 return -ENOENT;
15801 }
15802
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015803 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15804 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
15805 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070015806 wlan_hdd_get_classAstats(pAdapter);
15807 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
15808
Jeff Johnsone7245742012-09-05 17:12:55 -070015809 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 return 0;
15811}
15812
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015813static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
15814#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15815 struct wireless_dev *wdev,
15816#endif
15817 int *dbm)
15818{
15819 int ret;
15820
15821 vos_ssr_protect(__func__);
15822 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
15823#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15824 wdev,
15825#endif
15826 dbm);
15827 vos_ssr_unprotect(__func__);
15828
15829 return ret;
15830}
15831
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015832static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015833#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15834 const u8* mac,
15835#else
15836 u8* mac,
15837#endif
15838 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070015839{
15840 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15842 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053015843 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015844
15845 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
15846 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070015847
15848 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
15849 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
15850 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
15851 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
15852 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
15853 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
15854 tANI_U16 maxRate = 0;
15855 tANI_U16 myRate;
15856 tANI_U16 currentRate = 0;
15857 tANI_U8 maxSpeedMCS = 0;
15858 tANI_U8 maxMCSIdx = 0;
15859 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053015860 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070015861 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015862 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015863
Leo Chang6f8870f2013-03-26 18:11:36 -070015864#ifdef WLAN_FEATURE_11AC
15865 tANI_U32 vht_mcs_map;
15866 eDataRate11ACMaxMcs vhtMaxMcs;
15867#endif /* WLAN_FEATURE_11AC */
15868
Jeff Johnsone7245742012-09-05 17:12:55 -070015869 ENTER();
15870
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15872 (0 == ssidlen))
15873 {
15874 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
15875 " Invalid ssidlen, %d", __func__, ssidlen);
15876 /*To keep GUI happy*/
15877 return 0;
15878 }
15879
Mukul Sharma811205f2014-07-09 21:07:30 +053015880 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
15881 {
15882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15883 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053015884 /* return a cached value */
15885 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053015886 return 0;
15887 }
15888
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015889 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015890 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015891 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015892 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015893 }
15894
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053015895 wlan_hdd_get_station_stats(pAdapter);
15896 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015897
Kiet Lam3b17fc82013-09-27 05:24:08 +053015898 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
15899 sinfo->filled |= STATION_INFO_SIGNAL;
15900
c_hpothu09f19542014-05-30 21:53:31 +053015901 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053015902 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
15903 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053015904 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053015905 {
15906 rate_flags = pAdapter->maxRateFlags;
15907 }
c_hpothu44ff4e02014-05-08 00:13:57 +053015908
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 //convert to the UI units of 100kbps
15910 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
15911
15912#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070015913 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 -070015914 sinfo->signal,
15915 pCfg->reportMaxLinkSpeed,
15916 myRate,
15917 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015918 (int) pCfg->linkSpeedRssiMid,
15919 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070015920 (int) rate_flags,
15921 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070015922#endif //LINKSPEED_DEBUG_ENABLED
15923
15924 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
15925 {
15926 // we do not want to necessarily report the current speed
15927 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
15928 {
15929 // report the max possible speed
15930 rssidx = 0;
15931 }
15932 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
15933 {
15934 // report the max possible speed with RSSI scaling
15935 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
15936 {
15937 // report the max possible speed
15938 rssidx = 0;
15939 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015940 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 {
15942 // report middle speed
15943 rssidx = 1;
15944 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015945 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
15946 {
15947 // report middle speed
15948 rssidx = 2;
15949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015950 else
15951 {
15952 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015953 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 }
15955 }
15956 else
15957 {
15958 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
15959 hddLog(VOS_TRACE_LEVEL_ERROR,
15960 "%s: Invalid value for reportMaxLinkSpeed: %u",
15961 __func__, pCfg->reportMaxLinkSpeed);
15962 rssidx = 0;
15963 }
15964
15965 maxRate = 0;
15966
15967 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015968 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
15969 OperationalRates, &ORLeng))
15970 {
15971 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15972 /*To keep GUI happy*/
15973 return 0;
15974 }
15975
Jeff Johnson295189b2012-06-20 16:38:30 -070015976 for (i = 0; i < ORLeng; i++)
15977 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015978 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015979 {
15980 /* Validate Rate Set */
15981 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
15982 {
15983 currentRate = supported_data_rate[j].supported_rate[rssidx];
15984 break;
15985 }
15986 }
15987 /* Update MAX rate */
15988 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15989 }
15990
15991 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015992 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
15993 ExtendedRates, &ERLeng))
15994 {
15995 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15996 /*To keep GUI happy*/
15997 return 0;
15998 }
15999
Jeff Johnson295189b2012-06-20 16:38:30 -070016000 for (i = 0; i < ERLeng; i++)
16001 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016002 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070016003 {
16004 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
16005 {
16006 currentRate = supported_data_rate[j].supported_rate[rssidx];
16007 break;
16008 }
16009 }
16010 /* Update MAX rate */
16011 maxRate = (currentRate > maxRate)?currentRate:maxRate;
16012 }
c_hpothu79aab322014-07-14 21:11:01 +053016013
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016014 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053016015 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053016016 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053016017 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070016018 {
c_hpothu79aab322014-07-14 21:11:01 +053016019 if (rate_flags & eHAL_TX_RATE_VHT80)
16020 mode = 2;
16021 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
16022 mode = 1;
16023 else
16024 mode = 0;
16025
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053016026 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
16027 MCSRates, &MCSLeng))
16028 {
16029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
16030 /*To keep GUI happy*/
16031 return 0;
16032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070016034#ifdef WLAN_FEATURE_11AC
16035 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016036 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070016037 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016038 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016039 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070016040 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016042 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016044 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070016045 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016046 maxMCSIdx = 7;
16047 }
16048 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16049 {
16050 maxMCSIdx = 8;
16051 }
16052 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16053 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016054 //VHT20 is supporting 0~8
16055 if (rate_flags & eHAL_TX_RATE_VHT20)
16056 maxMCSIdx = 8;
16057 else
16058 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016059 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016060
c_hpothu79aab322014-07-14 21:11:01 +053016061 if (0 != rssidx)/*check for scaled */
16062 {
16063 //get middle rate MCS index if rssi=1/2
16064 for (i=0; i <= maxMCSIdx; i++)
16065 {
16066 if (sinfo->signal <= rssiMcsTbl[mode][i])
16067 {
16068 maxMCSIdx = i;
16069 break;
16070 }
16071 }
16072 }
16073
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016074 if (rate_flags & eHAL_TX_RATE_VHT80)
16075 {
16076 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16077 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16078 }
16079 else if (rate_flags & eHAL_TX_RATE_VHT40)
16080 {
16081 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
16082 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
16083 }
16084 else if (rate_flags & eHAL_TX_RATE_VHT20)
16085 {
16086 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
16087 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
16088 }
16089
Leo Chang6f8870f2013-03-26 18:11:36 -070016090 maxSpeedMCS = 1;
16091 if (currentRate > maxRate)
16092 {
16093 maxRate = currentRate;
16094 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016095
Leo Chang6f8870f2013-03-26 18:11:36 -070016096 }
16097 else
16098#endif /* WLAN_FEATURE_11AC */
16099 {
16100 if (rate_flags & eHAL_TX_RATE_HT40)
16101 {
16102 rateFlag |= 1;
16103 }
16104 if (rate_flags & eHAL_TX_RATE_SGI)
16105 {
16106 rateFlag |= 2;
16107 }
16108
Girish Gowli01abcee2014-07-31 20:18:55 +053016109 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053016110 if (rssidx == 1 || rssidx == 2)
16111 {
16112 //get middle rate MCS index if rssi=1/2
16113 for (i=0; i <= 7; i++)
16114 {
16115 if (sinfo->signal <= rssiMcsTbl[mode][i])
16116 {
16117 temp = i+1;
16118 break;
16119 }
16120 }
16121 }
c_hpothu79aab322014-07-14 21:11:01 +053016122
16123 for (i = 0; i < MCSLeng; i++)
16124 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016125 for (j = 0; j < temp; j++)
16126 {
16127 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
16128 {
16129 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016130 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016131 break;
16132 }
16133 }
16134 if ((j < temp) && (currentRate > maxRate))
16135 {
16136 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070016137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016138 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016139 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016140 }
16141 }
16142
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016143 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
16144 {
16145 maxRate = myRate;
16146 maxSpeedMCS = 1;
16147 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016149 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053016150 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070016151 {
16152 maxRate = myRate;
16153 if (rate_flags & eHAL_TX_RATE_LEGACY)
16154 {
16155 maxSpeedMCS = 0;
16156 }
16157 else
16158 {
16159 maxSpeedMCS = 1;
16160 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16161 }
16162 }
16163
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016164 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 {
16166 sinfo->txrate.legacy = maxRate;
16167#ifdef LINKSPEED_DEBUG_ENABLED
16168 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
16169#endif //LINKSPEED_DEBUG_ENABLED
16170 }
16171 else
16172 {
16173 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070016174#ifdef WLAN_FEATURE_11AC
16175 sinfo->txrate.nss = 1;
16176 if (rate_flags & eHAL_TX_RATE_VHT80)
16177 {
16178 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016179 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070016180 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016181 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070016182 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016183 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16184 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16185 }
16186 else if (rate_flags & eHAL_TX_RATE_VHT20)
16187 {
16188 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16189 }
16190#endif /* WLAN_FEATURE_11AC */
16191 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
16192 {
16193 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16194 if (rate_flags & eHAL_TX_RATE_HT40)
16195 {
16196 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16197 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 if (rate_flags & eHAL_TX_RATE_SGI)
16200 {
16201 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16202 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016203
Jeff Johnson295189b2012-06-20 16:38:30 -070016204#ifdef LINKSPEED_DEBUG_ENABLED
16205 pr_info("Reporting MCS rate %d flags %x\n",
16206 sinfo->txrate.mcs,
16207 sinfo->txrate.flags );
16208#endif //LINKSPEED_DEBUG_ENABLED
16209 }
16210 }
16211 else
16212 {
16213 // report current rate instead of max rate
16214
16215 if (rate_flags & eHAL_TX_RATE_LEGACY)
16216 {
16217 //provide to the UI in units of 100kbps
16218 sinfo->txrate.legacy = myRate;
16219#ifdef LINKSPEED_DEBUG_ENABLED
16220 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
16221#endif //LINKSPEED_DEBUG_ENABLED
16222 }
16223 else
16224 {
16225 //must be MCS
16226 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016227#ifdef WLAN_FEATURE_11AC
16228 sinfo->txrate.nss = 1;
16229 if (rate_flags & eHAL_TX_RATE_VHT80)
16230 {
16231 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16232 }
16233 else
16234#endif /* WLAN_FEATURE_11AC */
16235 {
16236 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016238 if (rate_flags & eHAL_TX_RATE_SGI)
16239 {
16240 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16241 }
16242 if (rate_flags & eHAL_TX_RATE_HT40)
16243 {
16244 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16245 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016246#ifdef WLAN_FEATURE_11AC
16247 else if (rate_flags & eHAL_TX_RATE_VHT80)
16248 {
16249 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
16250 }
16251#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070016252#ifdef LINKSPEED_DEBUG_ENABLED
16253 pr_info("Reporting actual MCS rate %d flags %x\n",
16254 sinfo->txrate.mcs,
16255 sinfo->txrate.flags );
16256#endif //LINKSPEED_DEBUG_ENABLED
16257 }
16258 }
16259 sinfo->filled |= STATION_INFO_TX_BITRATE;
16260
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016261 sinfo->tx_packets =
16262 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
16263 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
16264 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
16265 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
16266
16267 sinfo->tx_retries =
16268 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
16269 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
16270 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
16271 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
16272
16273 sinfo->tx_failed =
16274 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
16275 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
16276 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
16277 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
16278
16279 sinfo->filled |=
16280 STATION_INFO_TX_PACKETS |
16281 STATION_INFO_TX_RETRIES |
16282 STATION_INFO_TX_FAILED;
16283
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053016284 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
16285 sinfo->filled |= STATION_INFO_RX_PACKETS;
16286
16287 if (rate_flags & eHAL_TX_RATE_LEGACY)
16288 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
16289 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
16290 sinfo->rx_packets);
16291 else
16292 hddLog(LOG1,
16293 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
16294 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
16295 sinfo->tx_packets, sinfo->rx_packets);
16296
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016297 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16298 TRACE_CODE_HDD_CFG80211_GET_STA,
16299 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016300 EXIT();
16301 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016302}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016303#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16304static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16305 const u8* mac, struct station_info *sinfo)
16306#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016307static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16308 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016309#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016310{
16311 int ret;
16312
16313 vos_ssr_protect(__func__);
16314 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
16315 vos_ssr_unprotect(__func__);
16316
16317 return ret;
16318}
16319
16320static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070016321 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070016322{
16323 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016324 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016325 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016326 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016327
Jeff Johnsone7245742012-09-05 17:12:55 -070016328 ENTER();
16329
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 if (NULL == pAdapter)
16331 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016332 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 return -ENODEV;
16334 }
16335
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016336 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16337 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
16338 pAdapter->sessionId, timeout));
16339
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016340 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016341 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016342 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016343 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016344 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016345 }
16346
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016347 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
16348 (TRUE == pHddCtx->hdd_wlan_suspended) &&
16349 (pHddCtx->cfg_ini->fhostArpOffload) &&
16350 (eConnectionState_Associated ==
16351 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
16352 {
Amar Singhald53568e2013-09-26 11:03:45 -070016353
16354 hddLog(VOS_TRACE_LEVEL_INFO,
16355 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053016356 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016357 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16358 {
16359 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016360 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016361 __func__, vos_status);
16362 }
16363 }
16364
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 /**The get power cmd from the supplicant gets updated by the nl only
16366 *on successful execution of the function call
16367 *we are oppositely mapped w.r.t mode in the driver
16368 **/
16369 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
16370
16371 if (VOS_STATUS_E_FAILURE == vos_status)
16372 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016373 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16374 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016375 return -EINVAL;
16376 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016377 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016378 return 0;
16379}
16380
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016381static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16382 struct net_device *dev, bool mode, int timeout)
16383{
16384 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016385
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016386 vos_ssr_protect(__func__);
16387 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
16388 vos_ssr_unprotect(__func__);
16389
16390 return ret;
16391}
Sushant Kaushik084f6592015-09-10 13:11:56 +053016392
Jeff Johnson295189b2012-06-20 16:38:30 -070016393#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016394static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
16395 struct net_device *netdev,
16396 u8 key_index)
16397{
16398 ENTER();
16399 return 0;
16400}
16401
Jeff Johnson295189b2012-06-20 16:38:30 -070016402static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016403 struct net_device *netdev,
16404 u8 key_index)
16405{
16406 int ret;
16407 vos_ssr_protect(__func__);
16408 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16409 vos_ssr_unprotect(__func__);
16410 return ret;
16411}
16412#endif //LINUX_VERSION_CODE
16413
16414#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16415static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16416 struct net_device *dev,
16417 struct ieee80211_txq_params *params)
16418{
16419 ENTER();
16420 return 0;
16421}
16422#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16423static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16424 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016425{
Jeff Johnsone7245742012-09-05 17:12:55 -070016426 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 return 0;
16428}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016429#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016430
16431#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16432static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016433 struct net_device *dev,
16434 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016435{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016436 int ret;
16437
16438 vos_ssr_protect(__func__);
16439 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16440 vos_ssr_unprotect(__func__);
16441 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016442}
16443#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16444static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16445 struct ieee80211_txq_params *params)
16446{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016447 int ret;
16448
16449 vos_ssr_protect(__func__);
16450 ret = __wlan_hdd_set_txq_params(wiphy, params);
16451 vos_ssr_unprotect(__func__);
16452 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016453}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016455
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016456static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016457 struct net_device *dev,
16458 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016459{
16460 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016461 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016462 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016463 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016464 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016465 v_CONTEXT_t pVosContext = NULL;
16466 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016467
Jeff Johnsone7245742012-09-05 17:12:55 -070016468 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016469
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016470 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016472 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016473 return -EINVAL;
16474 }
16475
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016476 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16477 TRACE_CODE_HDD_CFG80211_DEL_STA,
16478 pAdapter->sessionId, pAdapter->device_mode));
16479
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016480 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16481 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016482 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016483 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016484 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016485 }
16486
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 )
16490 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016491 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16492 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16493 if(pSapCtx == NULL){
16494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16495 FL("psapCtx is NULL"));
16496 return -ENOENT;
16497 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016498 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 {
16500 v_U16_t i;
16501 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16502 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016503 if ((pSapCtx->aStaInfo[i].isUsed) &&
16504 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016506 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016507 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016508 ETHER_ADDR_LEN);
16509
Jeff Johnson295189b2012-06-20 16:38:30 -070016510 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016511 "%s: Delete STA with MAC::"
16512 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016513 __func__,
16514 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16515 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016516 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016517 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016518 }
16519 }
16520 }
16521 else
16522 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016523
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016524 vos_status = hdd_softap_GetStaId(pAdapter,
16525 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016526 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16527 {
16528 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016529 "%s: Skip this DEL STA as this is not used::"
16530 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016531 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016532 return -ENOENT;
16533 }
16534
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016535 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016536 {
16537 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016538 "%s: Skip this DEL STA as deauth is in progress::"
16539 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016540 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016541 return -ENOENT;
16542 }
16543
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016544 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016545
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 hddLog(VOS_TRACE_LEVEL_INFO,
16547 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016548 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016549 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016550 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016551
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016552 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016553 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16554 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016555 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016556 hddLog(VOS_TRACE_LEVEL_INFO,
16557 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016558 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016559 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016560 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016561 return -ENOENT;
16562 }
16563
Jeff Johnson295189b2012-06-20 16:38:30 -070016564 }
16565 }
16566
16567 EXIT();
16568
16569 return 0;
16570}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016571
16572#ifdef CFG80211_DEL_STA_V2
16573static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16574 struct net_device *dev,
16575 struct station_del_parameters *param)
16576#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016577#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16578static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16579 struct net_device *dev, const u8 *mac)
16580#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016581static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16582 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016583#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016584#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016585{
16586 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016587 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016588
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016589 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016590
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016591#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016592 if (NULL == param) {
16593 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016594 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016595 return -EINVAL;
16596 }
16597
16598 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16599 param->subtype, &delStaParams);
16600
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016601#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016602 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016603 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016604#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016605 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16606
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016607 vos_ssr_unprotect(__func__);
16608
16609 return ret;
16610}
16611
16612static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016613 struct net_device *dev,
16614#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16615 const u8 *mac,
16616#else
16617 u8 *mac,
16618#endif
16619 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016620{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016621 hdd_adapter_t *pAdapter;
16622 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016623 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016624#ifdef FEATURE_WLAN_TDLS
16625 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016626
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016627 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016628
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016629 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16630 if (NULL == pAdapter)
16631 {
16632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16633 "%s: Adapter is NULL",__func__);
16634 return -EINVAL;
16635 }
16636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16637 status = wlan_hdd_validate_context(pHddCtx);
16638 if (0 != status)
16639 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016640 return status;
16641 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016642
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016643 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16644 TRACE_CODE_HDD_CFG80211_ADD_STA,
16645 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016646 mask = params->sta_flags_mask;
16647
16648 set = params->sta_flags_set;
16649
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016651 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16652 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016653
16654 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16655 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016656 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016657 }
16658 }
16659#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016660 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016661 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016662}
16663
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016664#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16665static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16666 struct net_device *dev, const u8 *mac,
16667 struct station_parameters *params)
16668#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016669static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16670 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016671#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016672{
16673 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016674
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016675 vos_ssr_protect(__func__);
16676 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16677 vos_ssr_unprotect(__func__);
16678
16679 return ret;
16680}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016681#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016682
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016683static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016684 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016685{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016686 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16687 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016688 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016689 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016690 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016691 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016692
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016693 ENTER();
16694
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016695 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016696 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016697 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016698 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016699 return -EINVAL;
16700 }
16701
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016702 if (!pmksa) {
16703 hddLog(LOGE, FL("pmksa is NULL"));
16704 return -EINVAL;
16705 }
16706
16707 if (!pmksa->bssid || !pmksa->pmkid) {
16708 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
16709 pmksa->bssid, pmksa->pmkid);
16710 return -EINVAL;
16711 }
16712
16713 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
16714 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16715
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016716 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16717 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016718 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016719 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016720 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016721 }
16722
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016723 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016724 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16725
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016726 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
16727 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016728
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016729 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016730 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016731 &pmk_id, 1, FALSE);
16732
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016733 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16734 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
16735 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016736
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016737 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016738 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016739}
16740
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016741static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
16742 struct cfg80211_pmksa *pmksa)
16743{
16744 int ret;
16745
16746 vos_ssr_protect(__func__);
16747 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
16748 vos_ssr_unprotect(__func__);
16749
16750 return ret;
16751}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016752
Wilson Yang6507c4e2013-10-01 20:11:19 -070016753
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016754static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070016755 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016756{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016757 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16758 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016759 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016760 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016761
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016762 ENTER();
16763
Wilson Yang6507c4e2013-10-01 20:11:19 -070016764 /* Validate pAdapter */
16765 if (NULL == pAdapter)
16766 {
16767 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
16768 return -EINVAL;
16769 }
16770
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016771 if (!pmksa) {
16772 hddLog(LOGE, FL("pmksa is NULL"));
16773 return -EINVAL;
16774 }
16775
16776 if (!pmksa->bssid) {
16777 hddLog(LOGE, FL("pmksa->bssid is NULL"));
16778 return -EINVAL;
16779 }
16780
Kiet Lam98c46a12014-10-31 15:34:57 -070016781 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
16782 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16783
Wilson Yang6507c4e2013-10-01 20:11:19 -070016784 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16785 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016786 if (0 != status)
16787 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016788 return status;
16789 }
16790
16791 /*Retrieve halHandle*/
16792 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16793
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016794 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16795 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
16796 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016797 /* Delete the PMKID CSR cache */
16798 if (eHAL_STATUS_SUCCESS !=
16799 sme_RoamDelPMKIDfromCache(halHandle,
16800 pAdapter->sessionId, pmksa->bssid, FALSE)) {
16801 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
16802 MAC_ADDR_ARRAY(pmksa->bssid));
16803 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016804 }
16805
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016806 EXIT();
16807 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016808}
16809
Wilson Yang6507c4e2013-10-01 20:11:19 -070016810
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016811static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
16812 struct cfg80211_pmksa *pmksa)
16813{
16814 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016815
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016816 vos_ssr_protect(__func__);
16817 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
16818 vos_ssr_unprotect(__func__);
16819
16820 return ret;
16821
16822}
16823
16824static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016825{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16827 tHalHandle halHandle;
16828 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016829 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016830
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016831 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070016832
16833 /* Validate pAdapter */
16834 if (NULL == pAdapter)
16835 {
16836 hddLog(VOS_TRACE_LEVEL_ERROR,
16837 "%s: Invalid Adapter" ,__func__);
16838 return -EINVAL;
16839 }
16840
16841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16842 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016843 if (0 != status)
16844 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016845 return status;
16846 }
16847
16848 /*Retrieve halHandle*/
16849 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16850
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016851 /* Flush the PMKID cache in CSR */
16852 if (eHAL_STATUS_SUCCESS !=
16853 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
16854 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
16855 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016856 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016857 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080016858 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016859}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016860
16861static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
16862{
16863 int ret;
16864
16865 vos_ssr_protect(__func__);
16866 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
16867 vos_ssr_unprotect(__func__);
16868
16869 return ret;
16870}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016871#endif
16872
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016873#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016874static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16875 struct net_device *dev,
16876 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016877{
16878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16879 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016880 hdd_context_t *pHddCtx;
16881 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016882
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016883 ENTER();
16884
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016885 if (NULL == pAdapter)
16886 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016887 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016888 return -ENODEV;
16889 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016890 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16891 ret = wlan_hdd_validate_context(pHddCtx);
16892 if (0 != ret)
16893 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016894 return ret;
16895 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016896 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016897 if (NULL == pHddStaCtx)
16898 {
16899 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
16900 return -EINVAL;
16901 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016902
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016903 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16904 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
16905 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016906 // Added for debug on reception of Re-assoc Req.
16907 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
16908 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016909 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016910 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080016911 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016912 }
16913
16914#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080016915 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016916 ftie->ie_len);
16917#endif
16918
16919 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016920 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
16921 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016922 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016923
16924 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016925 return 0;
16926}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016927
16928static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16929 struct net_device *dev,
16930 struct cfg80211_update_ft_ies_params *ftie)
16931{
16932 int ret;
16933
16934 vos_ssr_protect(__func__);
16935 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
16936 vos_ssr_unprotect(__func__);
16937
16938 return ret;
16939}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016940#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016941
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016942#ifdef FEATURE_WLAN_SCAN_PNO
16943
16944void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
16945 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
16946{
16947 int ret;
16948 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
16949 hdd_context_t *pHddCtx;
16950
Nirav Shah80830bf2013-12-31 16:35:12 +053016951 ENTER();
16952
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016953 if (NULL == pAdapter)
16954 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016956 "%s: HDD adapter is Null", __func__);
16957 return ;
16958 }
16959
16960 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16961 if (NULL == pHddCtx)
16962 {
16963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16964 "%s: HDD context is Null!!!", __func__);
16965 return ;
16966 }
16967
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016968 spin_lock(&pHddCtx->schedScan_lock);
16969 if (TRUE == pHddCtx->isWiphySuspended)
16970 {
16971 pHddCtx->isSchedScanUpdatePending = TRUE;
16972 spin_unlock(&pHddCtx->schedScan_lock);
16973 hddLog(VOS_TRACE_LEVEL_INFO,
16974 "%s: Update cfg80211 scan database after it resume", __func__);
16975 return ;
16976 }
16977 spin_unlock(&pHddCtx->schedScan_lock);
16978
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016979 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
16980
16981 if (0 > ret)
16982 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053016983 else
16984 {
16985 /* Acquire wakelock to handle the case where APP's tries to suspend
16986 * immediatly after the driver gets connect request(i.e after pno)
16987 * from supplicant, this result in app's is suspending and not able
16988 * to process the connect request to AP */
16989 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
16990 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016991 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16993 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016994}
16995
16996/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016997 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016998 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016999 */
17000static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
17001{
17002 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
17003 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017004 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017005 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17006 int status = 0;
17007 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
17008
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017009 /* The current firmware design does not allow PNO during any
17010 * active sessions. Hence, determine the active sessions
17011 * and return a failure.
17012 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017013 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
17014 {
17015 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017016 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017017
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017018 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
17019 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
17020 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
17021 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
17022 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053017023 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017024 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017025 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017026 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017027 }
17028 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17029 pAdapterNode = pNext;
17030 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017031 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017032}
17033
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017034void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
17035{
17036 hdd_adapter_t *pAdapter = callbackContext;
17037 hdd_context_t *pHddCtx;
17038
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017039 ENTER();
17040
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017041 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
17042 {
17043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17044 FL("Invalid adapter or adapter has invalid magic"));
17045 return;
17046 }
17047
17048 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17049 if (0 != wlan_hdd_validate_context(pHddCtx))
17050 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017051 return;
17052 }
17053
c_hpothub53c45d2014-08-18 16:53:14 +053017054 if (VOS_STATUS_SUCCESS != status)
17055 {
17056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017057 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017058 pHddCtx->isPnoEnable = FALSE;
17059 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017060
17061 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
17062 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017063 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017064}
17065
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017066/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017067 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
17068 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017069 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017070static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017071 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17072{
17073 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017074 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017075 hdd_context_t *pHddCtx;
17076 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017077 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053017078 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
17079 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017080 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17081 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017082 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017083 hdd_config_t *pConfig = NULL;
17084 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017085
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017086 ENTER();
17087
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017088 if (NULL == pAdapter)
17089 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017091 "%s: HDD adapter is Null", __func__);
17092 return -ENODEV;
17093 }
17094
17095 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017096 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017097
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017098 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017099 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017100 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017101 }
17102
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017103 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017104 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17105 if (NULL == hHal)
17106 {
17107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17108 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017109 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017110 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017111 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17112 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
17113 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053017114 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017115 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053017116 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017117 {
17118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17119 "%s: aborting the existing scan is unsuccessfull", __func__);
17120 return -EBUSY;
17121 }
17122
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017123 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017124 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017126 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017127 return -EBUSY;
17128 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017129
c_hpothu37f21312014-04-09 21:49:54 +053017130 if (TRUE == pHddCtx->isPnoEnable)
17131 {
17132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
17133 FL("already PNO is enabled"));
17134 return -EBUSY;
17135 }
c_hpothu225aa7c2014-10-22 17:45:13 +053017136
17137 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
17138 {
17139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17140 "%s: abort ROC failed ", __func__);
17141 return -EBUSY;
17142 }
17143
c_hpothu37f21312014-04-09 21:49:54 +053017144 pHddCtx->isPnoEnable = TRUE;
17145
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017146 pnoRequest.enable = 1; /*Enable PNO */
17147 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017148
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017149 if (( !pnoRequest.ucNetworksCount ) ||
17150 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017151 {
17152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017153 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017154 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017155 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017156 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017157 goto error;
17158 }
17159
17160 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
17161 {
17162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017163 "%s: Incorrect number of channels %d",
17164 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017165 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017166 goto error;
17167 }
17168
17169 /* Framework provides one set of channels(all)
17170 * common for all saved profile */
17171 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17172 channels_allowed, &num_channels_allowed))
17173 {
17174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17175 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017176 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017177 goto error;
17178 }
17179 /* Checking each channel against allowed channel list */
17180 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053017181 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017182 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017183 char chList [(request->n_channels*5)+1];
17184 int len;
17185 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017186 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017187 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017188 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017189 if (request->channels[i]->hw_value == channels_allowed[indx])
17190 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017191 if ((!pConfig->enableDFSPnoChnlScan) &&
17192 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
17193 {
17194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17195 "%s : Dropping DFS channel : %d",
17196 __func__,channels_allowed[indx]);
17197 num_ignore_dfs_ch++;
17198 break;
17199 }
17200
Nirav Shah80830bf2013-12-31 16:35:12 +053017201 valid_ch[num_ch++] = request->channels[i]->hw_value;
17202 len += snprintf(chList+len, 5, "%d ",
17203 request->channels[i]->hw_value);
17204 break ;
17205 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017206 }
17207 }
Nirav Shah80830bf2013-12-31 16:35:12 +053017208 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017209
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017210 /*If all channels are DFS and dropped, then ignore the PNO request*/
17211 if (num_ignore_dfs_ch == request->n_channels)
17212 {
17213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17214 "%s : All requested channels are DFS channels", __func__);
17215 ret = -EINVAL;
17216 goto error;
17217 }
17218 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017219
17220 pnoRequest.aNetworks =
17221 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17222 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017223 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017224 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17225 FL("failed to allocate memory aNetworks %u"),
17226 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17227 goto error;
17228 }
17229 vos_mem_zero(pnoRequest.aNetworks,
17230 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17231
17232 /* Filling per profile params */
17233 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
17234 {
17235 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017236 request->match_sets[i].ssid.ssid_len;
17237
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017238 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
17239 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017240 {
17241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017242 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017243 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017244 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017245 goto error;
17246 }
17247
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017248 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017249 request->match_sets[i].ssid.ssid,
17250 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17252 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017253 i, pnoRequest.aNetworks[i].ssId.ssId);
17254 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
17255 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
17256 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017257
17258 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017259 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
17260 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017261
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017262 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017263 }
17264
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017265 for (i = 0; i < request->n_ssids; i++)
17266 {
17267 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017268 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017269 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017270 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017271 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017272 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017273 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017274 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017275 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017276 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017277 break;
17278 }
17279 j++;
17280 }
17281 }
17282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17283 "Number of hidden networks being Configured = %d",
17284 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080017286 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017287
17288 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17289 if (pnoRequest.p24GProbeTemplate == NULL)
17290 {
17291 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17292 FL("failed to allocate memory p24GProbeTemplate %u"),
17293 SIR_PNO_MAX_PB_REQ_SIZE);
17294 goto error;
17295 }
17296
17297 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17298 if (pnoRequest.p5GProbeTemplate == NULL)
17299 {
17300 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17301 FL("failed to allocate memory p5GProbeTemplate %u"),
17302 SIR_PNO_MAX_PB_REQ_SIZE);
17303 goto error;
17304 }
17305
17306 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17307 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17308
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053017309 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
17310 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017311 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017312 pnoRequest.us24GProbeTemplateLen = request->ie_len;
17313 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
17314 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017315
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017316 pnoRequest.us5GProbeTemplateLen = request->ie_len;
17317 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
17318 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017319 }
17320
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017321 /* Driver gets only one time interval which is hardcoded in
17322 * supplicant for 10000ms. Taking power consumption into account 6 timers
17323 * will be used, Timervalue is increased exponentially i.e 10,20,40,
17324 * 80,160,320 secs. And number of scan cycle for each timer
17325 * is configurable through INI param gPNOScanTimerRepeatValue.
17326 * If it is set to 0 only one timer will be used and PNO scan cycle
17327 * will be repeated after each interval specified by supplicant
17328 * till PNO is disabled.
17329 */
17330 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017331 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017332 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017333 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017334 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17335
17336 tempInterval = (request->interval)/1000;
17337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17338 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17339 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017340 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017341 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017342 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017343 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017344 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017345 tempInterval *= 2;
17346 }
17347 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017348 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017349
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017350 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017351
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017352 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017353 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17354 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017355 pAdapter->pno_req_status = 0;
17356
Nirav Shah80830bf2013-12-31 16:35:12 +053017357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17358 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017359 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
17360 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053017361
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017362 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017363 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017364 hdd_cfg80211_sched_scan_done_callback, pAdapter);
17365 if (eHAL_STATUS_SUCCESS != status)
17366 {
17367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017368 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017369 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017370 goto error;
17371 }
17372
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017373 ret = wait_for_completion_timeout(
17374 &pAdapter->pno_comp_var,
17375 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17376 if (0 >= ret)
17377 {
17378 // Did not receive the response for PNO enable in time.
17379 // Assuming the PNO enable was success.
17380 // Returning error from here, because we timeout, results
17381 // in side effect of Wifi (Wifi Setting) not to work.
17382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17383 FL("Timed out waiting for PNO to be Enabled"));
17384 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017385 }
17386
17387 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053017388 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017389
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017390error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17392 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053017393 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017394 if (pnoRequest.aNetworks)
17395 vos_mem_free(pnoRequest.aNetworks);
17396 if (pnoRequest.p24GProbeTemplate)
17397 vos_mem_free(pnoRequest.p24GProbeTemplate);
17398 if (pnoRequest.p5GProbeTemplate)
17399 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017400
17401 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017402 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017403}
17404
17405/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017406 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17407 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017408 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017409static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17410 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17411{
17412 int ret;
17413
17414 vos_ssr_protect(__func__);
17415 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17416 vos_ssr_unprotect(__func__);
17417
17418 return ret;
17419}
17420
17421/*
17422 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17423 * Function to disable PNO
17424 */
17425static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017426 struct net_device *dev)
17427{
17428 eHalStatus status = eHAL_STATUS_FAILURE;
17429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17430 hdd_context_t *pHddCtx;
17431 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017432 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017433 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017434
17435 ENTER();
17436
17437 if (NULL == pAdapter)
17438 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017440 "%s: HDD adapter is Null", __func__);
17441 return -ENODEV;
17442 }
17443
17444 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017445
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017446 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017447 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017449 "%s: HDD context is Null", __func__);
17450 return -ENODEV;
17451 }
17452
17453 /* The return 0 is intentional when isLogpInProgress and
17454 * isLoadUnloadInProgress. We did observe a crash due to a return of
17455 * failure in sched_scan_stop , especially for a case where the unload
17456 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17457 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17458 * success. If it returns a failure , then its next invocation due to the
17459 * clean up of the second interface will have the dev pointer corresponding
17460 * to the first one leading to a crash.
17461 */
17462 if (pHddCtx->isLogpInProgress)
17463 {
17464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17465 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017466 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017467 return ret;
17468 }
17469
Mihir Shete18156292014-03-11 15:38:30 +053017470 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017471 {
17472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17473 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17474 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017475 }
17476
17477 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17478 if (NULL == hHal)
17479 {
17480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17481 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017482 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017483 }
17484
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017485 pnoRequest.enable = 0; /* Disable PNO */
17486 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017487
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017488 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17489 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17490 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017491
17492 INIT_COMPLETION(pAdapter->pno_comp_var);
17493 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17494 pnoRequest.callbackContext = pAdapter;
17495 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017496 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017497 pAdapter->sessionId,
17498 NULL, pAdapter);
17499 if (eHAL_STATUS_SUCCESS != status)
17500 {
17501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17502 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017503 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017504 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017505 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017506 ret = wait_for_completion_timeout(
17507 &pAdapter->pno_comp_var,
17508 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17509 if (0 >= ret)
17510 {
17511 // Did not receive the response for PNO disable in time.
17512 // Assuming the PNO disable was success.
17513 // Returning error from here, because we timeout, results
17514 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053017515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017516 FL("Timed out waiting for PNO to be disabled"));
17517 ret = 0;
17518 }
17519
17520 ret = pAdapter->pno_req_status;
17521 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017522
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017523error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017524 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017525 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017526
17527 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017528 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017529}
17530
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017531/*
17532 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17533 * NL interface to disable PNO
17534 */
17535static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17536 struct net_device *dev)
17537{
17538 int ret;
17539
17540 vos_ssr_protect(__func__);
17541 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17542 vos_ssr_unprotect(__func__);
17543
17544 return ret;
17545}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017546#endif /*FEATURE_WLAN_SCAN_PNO*/
17547
17548
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017549#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017550#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017551static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17552 struct net_device *dev,
17553 u8 *peer, u8 action_code,
17554 u8 dialog_token,
17555 u16 status_code, u32 peer_capability,
17556 const u8 *buf, size_t len)
17557#else /* TDLS_MGMT_VERSION2 */
17558#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17559static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17560 struct net_device *dev,
17561 const u8 *peer, u8 action_code,
17562 u8 dialog_token, u16 status_code,
17563 u32 peer_capability, bool initiator,
17564 const u8 *buf, size_t len)
17565#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17566static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17567 struct net_device *dev,
17568 const u8 *peer, u8 action_code,
17569 u8 dialog_token, u16 status_code,
17570 u32 peer_capability, const u8 *buf,
17571 size_t len)
17572#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17573static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17574 struct net_device *dev,
17575 u8 *peer, u8 action_code,
17576 u8 dialog_token,
17577 u16 status_code, u32 peer_capability,
17578 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017579#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017580static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17581 struct net_device *dev,
17582 u8 *peer, u8 action_code,
17583 u8 dialog_token,
17584 u16 status_code, const u8 *buf,
17585 size_t len)
17586#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017587#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017588{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017589 hdd_adapter_t *pAdapter;
17590 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017591 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017592 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017593 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017594 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017595 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017596 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017597#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017598 u32 peer_capability = 0;
17599#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017600 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017601 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017602
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17604 if (NULL == pAdapter)
17605 {
17606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17607 "%s: Adapter is NULL",__func__);
17608 return -EINVAL;
17609 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017610 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17611 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17612 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017613
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017614 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017615 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017616 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017618 "Invalid arguments");
17619 return -EINVAL;
17620 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017621
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017622 if (pHddCtx->isLogpInProgress)
17623 {
17624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17625 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017626 wlan_hdd_tdls_set_link_status(pAdapter,
17627 peer,
17628 eTDLS_LINK_IDLE,
17629 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017630 return -EBUSY;
17631 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017632
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017633 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17634 {
17635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17636 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17637 return -EAGAIN;
17638 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017639
Hoonki Lee27511902013-03-14 18:19:06 -070017640 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017641 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017643 "%s: TDLS mode is disabled OR not enabled in FW."
17644 MAC_ADDRESS_STR " action %d declined.",
17645 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017646 return -ENOTSUPP;
17647 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017648
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017649 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17650
17651 if( NULL == pHddStaCtx )
17652 {
17653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17654 "%s: HDD station context NULL ",__func__);
17655 return -EINVAL;
17656 }
17657
17658 /* STA should be connected and authenticated
17659 * before sending any TDLS frames
17660 */
17661 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
17662 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
17663 {
17664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17665 "STA is not connected or unauthenticated. "
17666 "connState %u, uIsAuthenticated %u",
17667 pHddStaCtx->conn_info.connState,
17668 pHddStaCtx->conn_info.uIsAuthenticated);
17669 return -EAGAIN;
17670 }
17671
Hoonki Lee27511902013-03-14 18:19:06 -070017672 /* other than teardown frame, other mgmt frames are not sent if disabled */
17673 if (SIR_MAC_TDLS_TEARDOWN != action_code)
17674 {
17675 /* if tdls_mode is disabled to respond to peer's request */
17676 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
17677 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017678 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017679 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017680 " TDLS mode is disabled. action %d declined.",
17681 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070017682
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017683 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070017684 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053017685
17686 if (vos_max_concurrent_connections_reached())
17687 {
17688 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17689 return -EINVAL;
17690 }
Hoonki Lee27511902013-03-14 18:19:06 -070017691 }
17692
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017693 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
17694 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053017695 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017696 {
17697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017698 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017699 " TDLS setup is ongoing. action %d declined.",
17700 __func__, MAC_ADDR_ARRAY(peer), action_code);
17701 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017702 }
17703 }
17704
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017705 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
17706 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080017707 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017708 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17709 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017710 {
17711 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
17712 we return error code at 'add_station()'. Hence we have this
17713 check again in addtion to add_station().
17714 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017715 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017716 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017717 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17718 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017719 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
17720 __func__, MAC_ADDR_ARRAY(peer), action_code,
17721 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053017722 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080017723 }
17724 else
17725 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017726 /* maximum reached. tweak to send error code to peer and return
17727 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017728 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17730 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017731 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
17732 __func__, MAC_ADDR_ARRAY(peer), status_code,
17733 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070017734 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017735 /* fall through to send setup resp with failure status
17736 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017737 }
17738 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017739 else
17740 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017741 mutex_lock(&pHddCtx->tdls_lock);
17742 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017743 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017744 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017745 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017747 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
17748 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017749 return -EPERM;
17750 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017751 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017752 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017753 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017754
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017756 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017757 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
17758 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017759
Hoonki Leea34dd892013-02-05 22:56:02 -080017760 /*Except teardown responder will not be used so just make 0*/
17761 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017762 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080017763 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017764
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017765 mutex_lock(&pHddCtx->tdls_lock);
17766 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017767
17768 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
17769 responder = pTdlsPeer->is_responder;
17770 else
Hoonki Leea34dd892013-02-05 22:56:02 -080017771 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017773 "%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 -070017774 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
17775 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017776 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017777 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080017778 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017779 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017780 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017781
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017782 /* Discard TDLS setup if peer is removed by user app */
17783 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
17784 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17785 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
17786 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
17787
17788 mutex_lock(&pHddCtx->tdls_lock);
17789 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17790 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
17791 mutex_unlock(&pHddCtx->tdls_lock);
17792 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
17793 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
17794 MAC_ADDR_ARRAY(peer), action_code);
17795 return -EINVAL;
17796 }
17797 mutex_unlock(&pHddCtx->tdls_lock);
17798 }
17799
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017800 /* For explicit trigger of DIS_REQ come out of BMPS for
17801 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070017802 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053017803 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017804 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
17805 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070017806 {
17807 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
17808 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017810 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017811 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
17812 if (status != VOS_STATUS_SUCCESS) {
17813 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
17814 }
Hoonki Lee14621352013-04-16 17:51:19 -070017815 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017816 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017817 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
17819 }
17820 }
Hoonki Lee14621352013-04-16 17:51:19 -070017821 }
17822
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017823 /* make sure doesn't call send_mgmt() while it is pending */
17824 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
17825 {
17826 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017827 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017828 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017829 ret = -EBUSY;
17830 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017831 }
17832
17833 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017834 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
17835
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017836 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
17837 pAdapter->sessionId, peer, action_code, dialog_token,
17838 status_code, peer_capability, (tANI_U8 *)buf, len,
17839 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017840
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017841 if (VOS_STATUS_SUCCESS != status)
17842 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17844 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017845 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017846 ret = -EINVAL;
17847 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017848 }
17849
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17851 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
17852 WAIT_TIME_TDLS_MGMT);
17853
Hoonki Leed37cbb32013-04-20 00:31:14 -070017854 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
17855 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
17856
17857 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017858 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070017859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070017860 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070017861 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017862 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080017863
17864 if (pHddCtx->isLogpInProgress)
17865 {
17866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17867 "%s: LOGP in Progress. Ignore!!!", __func__);
17868 return -EAGAIN;
17869 }
Abhishek Singh837adf22015-10-01 17:37:37 +053017870 if (rc <= 0)
17871 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
17872 WLAN_LOG_INDICATOR_HOST_DRIVER,
17873 WLAN_LOG_REASON_HDD_TIME_OUT,
17874 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080017875
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017876 ret = -EINVAL;
17877 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017878 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017879 else
17880 {
17881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17882 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
17883 __func__, rc, pAdapter->mgmtTxCompletionStatus);
17884 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017885
Gopichand Nakkala05922802013-03-14 12:23:19 -070017886 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070017887 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017888 ret = max_sta_failed;
17889 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070017890 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017891
Hoonki Leea34dd892013-02-05 22:56:02 -080017892 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
17893 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017894 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017895 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17896 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017897 }
17898 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
17899 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017900 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17902 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017903 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017904
17905 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017906
17907tx_failed:
17908 /* add_station will be called before sending TDLS_SETUP_REQ and
17909 * TDLS_SETUP_RSP and as part of add_station driver will enable
17910 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
17911 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
17912 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
17913 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
17914 */
17915
17916 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17917 (SIR_MAC_TDLS_SETUP_RSP == action_code))
17918 wlan_hdd_tdls_check_bmps(pAdapter);
17919 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017920}
17921
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017922#if TDLS_MGMT_VERSION2
17923static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17924 u8 *peer, u8 action_code, u8 dialog_token,
17925 u16 status_code, u32 peer_capability,
17926 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017927#else /* TDLS_MGMT_VERSION2 */
17928#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17929static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17930 struct net_device *dev,
17931 const u8 *peer, u8 action_code,
17932 u8 dialog_token, u16 status_code,
17933 u32 peer_capability, bool initiator,
17934 const u8 *buf, size_t len)
17935#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17936static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17937 struct net_device *dev,
17938 const u8 *peer, u8 action_code,
17939 u8 dialog_token, u16 status_code,
17940 u32 peer_capability, const u8 *buf,
17941 size_t len)
17942#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17943static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17944 struct net_device *dev,
17945 u8 *peer, u8 action_code,
17946 u8 dialog_token,
17947 u16 status_code, u32 peer_capability,
17948 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017949#else
17950static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17951 u8 *peer, u8 action_code, u8 dialog_token,
17952 u16 status_code, const u8 *buf, size_t len)
17953#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017954#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017955{
17956 int ret;
17957
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017958 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017959#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017960 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17961 dialog_token, status_code,
17962 peer_capability, buf, len);
17963#else /* TDLS_MGMT_VERSION2 */
17964#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17965 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17966 dialog_token, status_code,
17967 peer_capability, initiator,
17968 buf, len);
17969#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17970 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17971 dialog_token, status_code,
17972 peer_capability, buf, len);
17973#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17974 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17975 dialog_token, status_code,
17976 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017977#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017978 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17979 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017980#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017981#endif
17982 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017983
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017984 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017985}
Atul Mittal115287b2014-07-08 13:26:33 +053017986
17987int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017988#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17989 const u8 *peer,
17990#else
Atul Mittal115287b2014-07-08 13:26:33 +053017991 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017992#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017993 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053017994 cfg80211_exttdls_callback callback)
17995{
17996
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017997 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053017998 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017999 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053018000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18001 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
18002 __func__, MAC_ADDR_ARRAY(peer));
18003
18004 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18005 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18006
18007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018008 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18009 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18010 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018011 return -ENOTSUPP;
18012 }
18013
18014 /* To cater the requirement of establishing the TDLS link
18015 * irrespective of the data traffic , get an entry of TDLS peer.
18016 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018017 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018018 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
18019 if (pTdlsPeer == NULL) {
18020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18021 "%s: peer " MAC_ADDRESS_STR " not existing",
18022 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053018023 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018024 return -EINVAL;
18025 }
18026
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018027 /* check FW TDLS Off Channel capability */
18028 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018029 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053018030 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018031 {
18032 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
18033 pTdlsPeer->peerParams.global_operating_class =
18034 tdls_peer_params->global_operating_class;
18035 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
18036 pTdlsPeer->peerParams.min_bandwidth_kbps =
18037 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018038 /* check configured channel is valid, non dfs and
18039 * not current operating channel */
18040 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
18041 tdls_peer_params->channel)) &&
18042 (pHddStaCtx) &&
18043 (tdls_peer_params->channel !=
18044 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018045 {
18046 pTdlsPeer->isOffChannelConfigured = TRUE;
18047 }
18048 else
18049 {
18050 pTdlsPeer->isOffChannelConfigured = FALSE;
18051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18052 "%s: Configured Tdls Off Channel is not valid", __func__);
18053
18054 }
18055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018056 "%s: tdls_off_channel %d isOffChannelConfigured %d "
18057 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018058 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018059 pTdlsPeer->isOffChannelConfigured,
18060 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018061 }
18062 else
18063 {
18064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018065 "%s: TDLS off channel FW capability %d, "
18066 "host capab %d or Invalid TDLS Peer Params", __func__,
18067 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
18068 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018069 }
18070
Atul Mittal115287b2014-07-08 13:26:33 +053018071 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
18072
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018073 mutex_unlock(&pHddCtx->tdls_lock);
18074
Atul Mittal115287b2014-07-08 13:26:33 +053018075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18076 " %s TDLS Add Force Peer Failed",
18077 __func__);
18078 return -EINVAL;
18079 }
18080 /*EXT TDLS*/
18081
18082 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018083 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18085 " %s TDLS set callback Failed",
18086 __func__);
18087 return -EINVAL;
18088 }
18089
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018090 mutex_unlock(&pHddCtx->tdls_lock);
18091
Atul Mittal115287b2014-07-08 13:26:33 +053018092 return(0);
18093
18094}
18095
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018096int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
18097#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18098 const u8 *peer
18099#else
18100 u8 *peer
18101#endif
18102)
Atul Mittal115287b2014-07-08 13:26:33 +053018103{
18104
18105 hddTdlsPeer_t *pTdlsPeer;
18106 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018107
Atul Mittal115287b2014-07-08 13:26:33 +053018108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18109 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
18110 __func__, MAC_ADDR_ARRAY(peer));
18111
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018112 if (0 != wlan_hdd_validate_context(pHddCtx)) {
18113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
18114 return -EINVAL;
18115 }
18116
Atul Mittal115287b2014-07-08 13:26:33 +053018117 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18118 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18119
18120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018121 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18122 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18123 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018124 return -ENOTSUPP;
18125 }
18126
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018127 mutex_lock(&pHddCtx->tdls_lock);
18128 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053018129
18130 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018131 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018132 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018133 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053018134 __func__, MAC_ADDR_ARRAY(peer));
18135 return -EINVAL;
18136 }
18137 else {
18138 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
18139 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018140 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
18141 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018142 /* if channel switch is configured, reset
18143 the channel for this peer */
18144 if (TRUE == pTdlsPeer->isOffChannelConfigured)
18145 {
18146 pTdlsPeer->peerParams.channel = 0;
18147 pTdlsPeer->isOffChannelConfigured = FALSE;
18148 }
Atul Mittal115287b2014-07-08 13:26:33 +053018149 }
18150
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018151 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018152 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053018154 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018155 }
Atul Mittal115287b2014-07-08 13:26:33 +053018156
18157 /*EXT TDLS*/
18158
18159 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018160 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18162 " %s TDLS set callback Failed",
18163 __func__);
18164 return -EINVAL;
18165 }
Atul Mittal115287b2014-07-08 13:26:33 +053018166
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018167 mutex_unlock(&pHddCtx->tdls_lock);
18168
18169 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053018170}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018171static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018172#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18173 const u8 *peer,
18174#else
18175 u8 *peer,
18176#endif
18177 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018178{
18179 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18180 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018181 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018182 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018183
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018184 ENTER();
18185
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018186 if (!pAdapter) {
18187 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
18188 return -EINVAL;
18189 }
18190
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018191 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18192 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
18193 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018194 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018195 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018196 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070018197 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018198 return -EINVAL;
18199 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018200
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018201 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018202 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018203 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018204 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018205 }
18206
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018207
18208 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018209 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018210 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018211 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018212 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
18213 "Cannot process TDLS commands",
18214 pHddCtx->cfg_ini->fEnableTDLSSupport,
18215 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018216 return -ENOTSUPP;
18217 }
18218
18219 switch (oper) {
18220 case NL80211_TDLS_ENABLE_LINK:
18221 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018222 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018223 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053018224 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
18225 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053018226 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018227 tANI_U16 numCurrTdlsPeers = 0;
18228 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018229 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018230 tSirMacAddr peerMac;
18231 int channel;
18232 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018233
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18235 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
18236 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018237
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018238 mutex_lock(&pHddCtx->tdls_lock);
18239 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018240 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053018241 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018242 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018243 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18244 " (oper %d) not exsting. ignored",
18245 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18246 return -EINVAL;
18247 }
18248
18249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18250 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18251 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18252 "NL80211_TDLS_ENABLE_LINK");
18253
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018254 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
18255 {
18256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
18257 MAC_ADDRESS_STR " failed",
18258 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018259 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018260 return -EINVAL;
18261 }
18262
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018263 /* before starting tdls connection, set tdls
18264 * off channel established status to default value */
18265 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018266
18267 mutex_unlock(&pHddCtx->tdls_lock);
18268
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053018269 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018270 /* TDLS Off Channel, Disable tdls channel switch,
18271 when there are more than one tdls link */
18272 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053018273 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018274 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018275 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018276 /* get connected peer and send disable tdls off chan */
18277 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018278 if ((connPeer) &&
18279 (connPeer->isOffChannelSupported == TRUE) &&
18280 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018281 {
18282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18283 "%s: More then one peer connected, Disable "
18284 "TDLS channel switch", __func__);
18285
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018286 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018287 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
18288 channel = connPeer->peerParams.channel;
18289
18290 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018291
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018292 ret = sme_SendTdlsChanSwitchReq(
18293 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018294 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018295 peerMac,
18296 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018297 TDLS_OFF_CHANNEL_BW_OFFSET,
18298 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018299 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018300 hddLog(VOS_TRACE_LEVEL_ERROR,
18301 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018302 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018303 }
18304 else
18305 {
18306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18307 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018308 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018309 "isOffChannelConfigured %d",
18310 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018311 (connPeer ? (connPeer->isOffChannelSupported)
18312 : -1),
18313 (connPeer ? (connPeer->isOffChannelConfigured)
18314 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018315 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018316 }
18317 }
18318
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018319 mutex_lock(&pHddCtx->tdls_lock);
18320 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18321 if ( NULL == pTdlsPeer ) {
18322 mutex_unlock(&pHddCtx->tdls_lock);
18323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18324 "%s: " MAC_ADDRESS_STR
18325 " (oper %d) peer got freed in other context. ignored",
18326 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18327 return -EINVAL;
18328 }
18329 peer_status = pTdlsPeer->link_status;
18330 mutex_unlock(&pHddCtx->tdls_lock);
18331
18332 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018333 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018334 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053018335
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018336 if (0 != wlan_hdd_tdls_get_link_establish_params(
18337 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018338 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018339 return -EINVAL;
18340 }
18341 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018342
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018343 ret = sme_SendTdlsLinkEstablishParams(
18344 WLAN_HDD_GET_HAL_CTX(pAdapter),
18345 pAdapter->sessionId, peer,
18346 &tdlsLinkEstablishParams);
18347 if (ret != VOS_STATUS_SUCCESS) {
18348 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
18349 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018350 /* Send TDLS peer UAPSD capabilities to the firmware and
18351 * register with the TL on after the response for this operation
18352 * is received .
18353 */
18354 ret = wait_for_completion_interruptible_timeout(
18355 &pAdapter->tdls_link_establish_req_comp,
18356 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053018357
18358 mutex_lock(&pHddCtx->tdls_lock);
18359 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18360 if ( NULL == pTdlsPeer ) {
18361 mutex_unlock(&pHddCtx->tdls_lock);
18362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18363 "%s %d: " MAC_ADDRESS_STR
18364 " (oper %d) peer got freed in other context. ignored",
18365 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
18366 (int)oper);
18367 return -EINVAL;
18368 }
18369 peer_status = pTdlsPeer->link_status;
18370 mutex_unlock(&pHddCtx->tdls_lock);
18371
18372 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018373 {
18374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018375 FL("Link Establish Request Failed Status %ld"),
18376 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018377 return -EINVAL;
18378 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018379 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018380
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018381 mutex_lock(&pHddCtx->tdls_lock);
18382 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18383 if ( NULL == pTdlsPeer ) {
18384 mutex_unlock(&pHddCtx->tdls_lock);
18385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18386 "%s: " MAC_ADDRESS_STR
18387 " (oper %d) peer got freed in other context. ignored",
18388 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18389 return -EINVAL;
18390 }
18391
Atul Mittal115287b2014-07-08 13:26:33 +053018392 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18393 eTDLS_LINK_CONNECTED,
18394 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018395 staDesc.ucSTAId = pTdlsPeer->staId;
18396 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018397
18398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18399 "%s: tdlsLinkEstablishParams of peer "
18400 MAC_ADDRESS_STR "uapsdQueues: %d"
18401 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18402 "isResponder: %d peerstaId: %d",
18403 __func__,
18404 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18405 tdlsLinkEstablishParams.uapsdQueues,
18406 tdlsLinkEstablishParams.qos,
18407 tdlsLinkEstablishParams.maxSp,
18408 tdlsLinkEstablishParams.isBufSta,
18409 tdlsLinkEstablishParams.isOffChannelSupported,
18410 tdlsLinkEstablishParams.isResponder,
18411 pTdlsPeer->staId);
18412
18413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18414 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18415 __func__,
18416 staDesc.ucSTAId,
18417 staDesc.ucQosEnabled);
18418
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018419 ret = WLANTL_UpdateTdlsSTAClient(
18420 pHddCtx->pvosContext,
18421 &staDesc);
18422 if (ret != VOS_STATUS_SUCCESS) {
18423 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18424 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018425
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018426 /* Mark TDLS client Authenticated .*/
18427 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18428 pTdlsPeer->staId,
18429 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018430 if (VOS_STATUS_SUCCESS == status)
18431 {
Hoonki Lee14621352013-04-16 17:51:19 -070018432 if (pTdlsPeer->is_responder == 0)
18433 {
18434 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018435 tdlsConnInfo_t *tdlsInfo;
18436
18437 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18438
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018439 if (!vos_timer_is_initialized(
18440 &pTdlsPeer->initiatorWaitTimeoutTimer))
18441 {
18442 /* Initialize initiator wait callback */
18443 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018444 &pTdlsPeer->initiatorWaitTimeoutTimer,
18445 VOS_TIMER_TYPE_SW,
18446 wlan_hdd_tdls_initiator_wait_cb,
18447 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018448 }
Hoonki Lee14621352013-04-16 17:51:19 -070018449 wlan_hdd_tdls_timer_restart(pAdapter,
18450 &pTdlsPeer->initiatorWaitTimeoutTimer,
18451 WAIT_TIME_TDLS_INITIATOR);
18452 /* suspend initiator TX until it receives direct packet from the
18453 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018454 ret = WLANTL_SuspendDataTx(
18455 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18456 &staId, NULL);
18457 if (ret != VOS_STATUS_SUCCESS) {
18458 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18459 }
Hoonki Lee14621352013-04-16 17:51:19 -070018460 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018461
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018462 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018463 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018464 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018465 suppChannelLen =
18466 tdlsLinkEstablishParams.supportedChannelsLen;
18467
18468 if ((suppChannelLen > 0) &&
18469 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18470 {
18471 tANI_U8 suppPeerChannel = 0;
18472 int i = 0;
18473 for (i = 0U; i < suppChannelLen; i++)
18474 {
18475 suppPeerChannel =
18476 tdlsLinkEstablishParams.supportedChannels[i];
18477
18478 pTdlsPeer->isOffChannelSupported = FALSE;
18479 if (suppPeerChannel ==
18480 pTdlsPeer->peerParams.channel)
18481 {
18482 pTdlsPeer->isOffChannelSupported = TRUE;
18483 break;
18484 }
18485 }
18486 }
18487 else
18488 {
18489 pTdlsPeer->isOffChannelSupported = FALSE;
18490 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018491 }
18492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18493 "%s: TDLS channel switch request for channel "
18494 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018495 "%d isOffChannelSupported %d", __func__,
18496 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018497 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018498 suppChannelLen,
18499 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018500
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018501 /* TDLS Off Channel, Enable tdls channel switch,
18502 when their is only one tdls link and it supports */
18503 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18504 if ((numCurrTdlsPeers == 1) &&
18505 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18506 (TRUE == pTdlsPeer->isOffChannelConfigured))
18507 {
18508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18509 "%s: Send TDLS channel switch request for channel %d",
18510 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018511
18512 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018513 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18514 channel = pTdlsPeer->peerParams.channel;
18515
18516 mutex_unlock(&pHddCtx->tdls_lock);
18517
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018518 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18519 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018520 peerMac,
18521 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018522 TDLS_OFF_CHANNEL_BW_OFFSET,
18523 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018524 if (ret != VOS_STATUS_SUCCESS) {
18525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18526 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018527 }
18528 else
18529 {
18530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18531 "%s: TDLS channel switch request not sent"
18532 " numCurrTdlsPeers %d "
18533 "isOffChannelSupported %d "
18534 "isOffChannelConfigured %d",
18535 __func__, numCurrTdlsPeers,
18536 pTdlsPeer->isOffChannelSupported,
18537 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018538 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018539 }
18540
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018541 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018542 else
18543 mutex_unlock(&pHddCtx->tdls_lock);
18544
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018545 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018546
18547 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018548 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18549 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018550 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018551 int ac;
18552 uint8 ucAc[4] = { WLANTL_AC_VO,
18553 WLANTL_AC_VI,
18554 WLANTL_AC_BK,
18555 WLANTL_AC_BE };
18556 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18557 for(ac=0; ac < 4; ac++)
18558 {
18559 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18560 pTdlsPeer->staId, ucAc[ac],
18561 tlTid[ac], tlTid[ac], 0, 0,
18562 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018563 if (status != VOS_STATUS_SUCCESS) {
18564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18565 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018566 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018567 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018568 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018569
Bhargav Shah66896792015-10-01 18:17:37 +053018570 /* stop TCP delack timer if TDLS is enable */
18571 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18572 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053018573 hdd_wlan_tdls_enable_link_event(peer,
18574 pTdlsPeer->isOffChannelSupported,
18575 pTdlsPeer->isOffChannelConfigured,
18576 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018577 }
18578 break;
18579 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018580 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018581 tANI_U16 numCurrTdlsPeers = 0;
18582 hddTdlsPeer_t *connPeer = NULL;
18583
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18585 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18586 __func__, MAC_ADDR_ARRAY(peer));
18587
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018588 mutex_lock(&pHddCtx->tdls_lock);
18589 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018590
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018591
Sunil Dutt41de4e22013-11-14 18:09:02 +053018592 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018593 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018594 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18595 " (oper %d) not exsting. ignored",
18596 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18597 return -EINVAL;
18598 }
18599
18600 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18601 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18602 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18603 "NL80211_TDLS_DISABLE_LINK");
18604
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018605 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018606 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018607 long status;
18608
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018609 /* set tdls off channel status to false for this peer */
18610 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018611 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18612 eTDLS_LINK_TEARING,
18613 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18614 eTDLS_LINK_UNSPECIFIED:
18615 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018616 mutex_unlock(&pHddCtx->tdls_lock);
18617
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018618 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18619
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018620 status = sme_DeleteTdlsPeerSta(
18621 WLAN_HDD_GET_HAL_CTX(pAdapter),
18622 pAdapter->sessionId, peer );
18623 if (status != VOS_STATUS_SUCCESS) {
18624 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18625 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018626
18627 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18628 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018629
18630 mutex_lock(&pHddCtx->tdls_lock);
18631 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18632 if ( NULL == pTdlsPeer ) {
18633 mutex_unlock(&pHddCtx->tdls_lock);
18634 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18635 " peer was freed in other context",
18636 __func__, MAC_ADDR_ARRAY(peer));
18637 return -EINVAL;
18638 }
18639
Atul Mittal271a7652014-09-12 13:18:22 +053018640 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018641 eTDLS_LINK_IDLE,
18642 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018643 mutex_unlock(&pHddCtx->tdls_lock);
18644
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018645 if (status <= 0)
18646 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18648 "%s: Del station failed status %ld",
18649 __func__, status);
18650 return -EPERM;
18651 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018652
18653 /* TDLS Off Channel, Enable tdls channel switch,
18654 when their is only one tdls link and it supports */
18655 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18656 if (numCurrTdlsPeers == 1)
18657 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018658 tSirMacAddr peerMac;
18659 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018660
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018661 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018662 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018663
18664 if (connPeer == NULL) {
18665 mutex_unlock(&pHddCtx->tdls_lock);
18666 hddLog(VOS_TRACE_LEVEL_ERROR,
18667 "%s connPeer is NULL", __func__);
18668 return -EINVAL;
18669 }
18670
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018671 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
18672 channel = connPeer->peerParams.channel;
18673
18674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18675 "%s: TDLS channel switch "
18676 "isOffChannelSupported %d "
18677 "isOffChannelConfigured %d "
18678 "isOffChannelEstablished %d",
18679 __func__,
18680 (connPeer ? connPeer->isOffChannelSupported : -1),
18681 (connPeer ? connPeer->isOffChannelConfigured : -1),
18682 (connPeer ? connPeer->isOffChannelEstablished : -1));
18683
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018684 if ((connPeer) &&
18685 (connPeer->isOffChannelSupported == TRUE) &&
18686 (connPeer->isOffChannelConfigured == TRUE))
18687 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018688 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018689 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018690 status = sme_SendTdlsChanSwitchReq(
18691 WLAN_HDD_GET_HAL_CTX(pAdapter),
18692 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018693 peerMac,
18694 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018695 TDLS_OFF_CHANNEL_BW_OFFSET,
18696 TDLS_CHANNEL_SWITCH_ENABLE);
18697 if (status != VOS_STATUS_SUCCESS) {
18698 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
18699 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018700 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018701 else
18702 mutex_unlock(&pHddCtx->tdls_lock);
18703 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018704 else
18705 {
18706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18707 "%s: TDLS channel switch request not sent "
18708 "numCurrTdlsPeers %d ",
18709 __func__, numCurrTdlsPeers);
18710 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018711 }
18712 else
18713 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018714 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18716 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080018717 }
Bhargav Shah66896792015-10-01 18:17:37 +053018718 if (numCurrTdlsPeers == 0) {
18719 /* start TCP delack timer if TDLS is disable */
18720 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18721 hdd_manage_delack_timer(pHddCtx);
18722 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018723 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018724 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018725 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018726 {
Atul Mittal115287b2014-07-08 13:26:33 +053018727 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018728
Atul Mittal115287b2014-07-08 13:26:33 +053018729 if (0 != status)
18730 {
18731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018732 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053018733 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018734 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053018735 break;
18736 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018737 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018738 {
Atul Mittal115287b2014-07-08 13:26:33 +053018739 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
18740 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018741 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053018742 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018743
Atul Mittal115287b2014-07-08 13:26:33 +053018744 if (0 != status)
18745 {
18746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018747 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053018748 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053018749 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053018750 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018751 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018752 case NL80211_TDLS_DISCOVERY_REQ:
18753 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018755 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018756 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018757 return -ENOTSUPP;
18758 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18760 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018761 return -ENOTSUPP;
18762 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018763
18764 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018765 return 0;
18766}
Chilam NG571c65a2013-01-19 12:27:36 +053018767
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018768static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018769#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18770 const u8 *peer,
18771#else
18772 u8 *peer,
18773#endif
18774 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018775{
18776 int ret;
18777
18778 vos_ssr_protect(__func__);
18779 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
18780 vos_ssr_unprotect(__func__);
18781
18782 return ret;
18783}
18784
Chilam NG571c65a2013-01-19 12:27:36 +053018785int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
18786 struct net_device *dev, u8 *peer)
18787{
Arif Hussaina7c8e412013-11-20 11:06:42 -080018788 hddLog(VOS_TRACE_LEVEL_INFO,
18789 "tdls send discover req: "MAC_ADDRESS_STR,
18790 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018791#if TDLS_MGMT_VERSION2
18792 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18793 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18794#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018795#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18796 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18797 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
18798#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18799 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18800 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18801#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18802 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18803 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18804#else
Chilam NG571c65a2013-01-19 12:27:36 +053018805 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18806 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018807#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018808#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053018809}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018810#endif
18811
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018812#ifdef WLAN_FEATURE_GTK_OFFLOAD
18813/*
18814 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
18815 * Callback rountine called upon receiving response for
18816 * get offload info
18817 */
18818void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
18819 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
18820{
18821
18822 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018823 tANI_U8 tempReplayCounter[8];
18824 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018825
18826 ENTER();
18827
18828 if (NULL == pAdapter)
18829 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053018830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018831 "%s: HDD adapter is Null", __func__);
18832 return ;
18833 }
18834
18835 if (NULL == pGtkOffloadGetInfoRsp)
18836 {
18837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18838 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
18839 return ;
18840 }
18841
18842 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
18843 {
18844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18845 "%s: wlan Failed to get replay counter value",
18846 __func__);
18847 return ;
18848 }
18849
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018850 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18851 /* Update replay counter */
18852 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
18853 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18854
18855 {
18856 /* changing from little to big endian since supplicant
18857 * works on big endian format
18858 */
18859 int i;
18860 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18861
18862 for (i = 0; i < 8; i++)
18863 {
18864 tempReplayCounter[7-i] = (tANI_U8)p[i];
18865 }
18866 }
18867
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018868 /* Update replay counter to NL */
18869 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018870 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018871}
18872
18873/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018874 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018875 * This function is used to offload GTK rekeying job to the firmware.
18876 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018877int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018878 struct cfg80211_gtk_rekey_data *data)
18879{
18880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18881 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18882 hdd_station_ctx_t *pHddStaCtx;
18883 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018884 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018885 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018886 eHalStatus status = eHAL_STATUS_FAILURE;
18887
18888 ENTER();
18889
18890 if (NULL == pAdapter)
18891 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018892 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018893 "%s: HDD adapter is Null", __func__);
18894 return -ENODEV;
18895 }
18896
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018897 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18898 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
18899 pAdapter->sessionId, pAdapter->device_mode));
18900
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018901 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018902 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018903 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018904 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018905 }
18906
18907 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18908 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18909 if (NULL == hHal)
18910 {
18911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18912 "%s: HAL context is Null!!!", __func__);
18913 return -EAGAIN;
18914 }
18915
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018916 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
18917 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
18918 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
18919 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018920 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018921 {
18922 /* changing from big to little endian since driver
18923 * works on little endian format
18924 */
18925 tANI_U8 *p =
18926 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
18927 int i;
18928
18929 for (i = 0; i < 8; i++)
18930 {
18931 p[7-i] = data->replay_ctr[i];
18932 }
18933 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018934
18935 if (TRUE == pHddCtx->hdd_wlan_suspended)
18936 {
18937 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018938 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
18939 sizeof (tSirGtkOffloadParams));
18940 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018941 pAdapter->sessionId);
18942
18943 if (eHAL_STATUS_SUCCESS != status)
18944 {
18945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18946 "%s: sme_SetGTKOffload failed, returned %d",
18947 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018948
18949 /* Need to clear any trace of key value in the memory.
18950 * Thus zero out the memory even though it is local
18951 * variable.
18952 */
18953 vos_mem_zero(&hddGtkOffloadReqParams,
18954 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018955 return status;
18956 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18958 "%s: sme_SetGTKOffload successfull", __func__);
18959 }
18960 else
18961 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18963 "%s: wlan not suspended GTKOffload request is stored",
18964 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018965 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018966
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018967 /* Need to clear any trace of key value in the memory.
18968 * Thus zero out the memory even though it is local
18969 * variable.
18970 */
18971 vos_mem_zero(&hddGtkOffloadReqParams,
18972 sizeof(hddGtkOffloadReqParams));
18973
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018974 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018975 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018976}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018977
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018978int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
18979 struct cfg80211_gtk_rekey_data *data)
18980{
18981 int ret;
18982
18983 vos_ssr_protect(__func__);
18984 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
18985 vos_ssr_unprotect(__func__);
18986
18987 return ret;
18988}
18989#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018990/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018991 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018992 * This function is used to set access control policy
18993 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018994static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18995 struct net_device *dev,
18996 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018997{
18998 int i;
18999 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19000 hdd_hostapd_state_t *pHostapdState;
19001 tsap_Config_t *pConfig;
19002 v_CONTEXT_t pVosContext = NULL;
19003 hdd_context_t *pHddCtx;
19004 int status;
19005
19006 ENTER();
19007
19008 if (NULL == pAdapter)
19009 {
19010 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19011 "%s: HDD adapter is Null", __func__);
19012 return -ENODEV;
19013 }
19014
19015 if (NULL == params)
19016 {
19017 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19018 "%s: params is Null", __func__);
19019 return -EINVAL;
19020 }
19021
19022 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19023 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019024 if (0 != status)
19025 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019026 return status;
19027 }
19028
19029 pVosContext = pHddCtx->pvosContext;
19030 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
19031
19032 if (NULL == pHostapdState)
19033 {
19034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19035 "%s: pHostapdState is Null", __func__);
19036 return -EINVAL;
19037 }
19038
19039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
19040 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019041 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19042 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
19043 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019044
19045 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
19046 {
19047 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
19048
19049 /* default value */
19050 pConfig->num_accept_mac = 0;
19051 pConfig->num_deny_mac = 0;
19052
19053 /**
19054 * access control policy
19055 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
19056 * listed in hostapd.deny file.
19057 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
19058 * listed in hostapd.accept file.
19059 */
19060 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
19061 {
19062 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
19063 }
19064 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
19065 {
19066 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
19067 }
19068 else
19069 {
19070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19071 "%s:Acl Policy : %d is not supported",
19072 __func__, params->acl_policy);
19073 return -ENOTSUPP;
19074 }
19075
19076 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
19077 {
19078 pConfig->num_accept_mac = params->n_acl_entries;
19079 for (i = 0; i < params->n_acl_entries; i++)
19080 {
19081 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19082 "** Add ACL MAC entry %i in WhiletList :"
19083 MAC_ADDRESS_STR, i,
19084 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19085
19086 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
19087 sizeof(qcmacaddr));
19088 }
19089 }
19090 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
19091 {
19092 pConfig->num_deny_mac = params->n_acl_entries;
19093 for (i = 0; i < params->n_acl_entries; i++)
19094 {
19095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19096 "** Add ACL MAC entry %i in BlackList :"
19097 MAC_ADDRESS_STR, i,
19098 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19099
19100 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
19101 sizeof(qcmacaddr));
19102 }
19103 }
19104
19105 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
19106 {
19107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19108 "%s: SAP Set Mac Acl fail", __func__);
19109 return -EINVAL;
19110 }
19111 }
19112 else
19113 {
19114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053019115 "%s: Invalid device_mode = %s (%d)",
19116 __func__, hdd_device_modetoString(pAdapter->device_mode),
19117 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019118 return -EINVAL;
19119 }
19120
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019121 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019122 return 0;
19123}
19124
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019125static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19126 struct net_device *dev,
19127 const struct cfg80211_acl_data *params)
19128{
19129 int ret;
19130 vos_ssr_protect(__func__);
19131 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
19132 vos_ssr_unprotect(__func__);
19133
19134 return ret;
19135}
19136
Leo Chang9056f462013-08-01 19:21:11 -070019137#ifdef WLAN_NL80211_TESTMODE
19138#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070019139void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070019140(
19141 void *pAdapter,
19142 void *indCont
19143)
19144{
Leo Changd9df8aa2013-09-26 13:32:26 -070019145 tSirLPHBInd *lphbInd;
19146 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053019147 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070019148
19149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019150 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070019151
c_hpothu73f35e62014-04-18 13:40:08 +053019152 if (pAdapter == NULL)
19153 {
19154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19155 "%s: pAdapter is NULL\n",__func__);
19156 return;
19157 }
19158
Leo Chang9056f462013-08-01 19:21:11 -070019159 if (NULL == indCont)
19160 {
19161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019162 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070019163 return;
19164 }
19165
c_hpothu73f35e62014-04-18 13:40:08 +053019166 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070019167 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070019168 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053019169 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070019170 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070019171 GFP_ATOMIC);
19172 if (!skb)
19173 {
19174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19175 "LPHB timeout, NL buffer alloc fail");
19176 return;
19177 }
19178
Leo Changac3ba772013-10-07 09:47:04 -070019179 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070019180 {
19181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19182 "WLAN_HDD_TM_ATTR_CMD put fail");
19183 goto nla_put_failure;
19184 }
Leo Changac3ba772013-10-07 09:47:04 -070019185 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070019186 {
19187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19188 "WLAN_HDD_TM_ATTR_TYPE put fail");
19189 goto nla_put_failure;
19190 }
Leo Changac3ba772013-10-07 09:47:04 -070019191 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070019192 sizeof(tSirLPHBInd), lphbInd))
19193 {
19194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19195 "WLAN_HDD_TM_ATTR_DATA put fail");
19196 goto nla_put_failure;
19197 }
Leo Chang9056f462013-08-01 19:21:11 -070019198 cfg80211_testmode_event(skb, GFP_ATOMIC);
19199 return;
19200
19201nla_put_failure:
19202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19203 "NLA Put fail");
19204 kfree_skb(skb);
19205
19206 return;
19207}
19208#endif /* FEATURE_WLAN_LPHB */
19209
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019210static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070019211{
19212 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
19213 int err = 0;
19214#ifdef FEATURE_WLAN_LPHB
19215 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070019216 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019217
19218 ENTER();
19219
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019220 err = wlan_hdd_validate_context(pHddCtx);
19221 if (0 != err)
19222 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019223 return err;
19224 }
Leo Chang9056f462013-08-01 19:21:11 -070019225#endif /* FEATURE_WLAN_LPHB */
19226
19227 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
19228 if (err)
19229 {
19230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19231 "%s Testmode INV ATTR", __func__);
19232 return err;
19233 }
19234
19235 if (!tb[WLAN_HDD_TM_ATTR_CMD])
19236 {
19237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19238 "%s Testmode INV CMD", __func__);
19239 return -EINVAL;
19240 }
19241
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019242 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19243 TRACE_CODE_HDD_CFG80211_TESTMODE,
19244 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070019245 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
19246 {
19247#ifdef FEATURE_WLAN_LPHB
19248 /* Low Power Heartbeat configuration request */
19249 case WLAN_HDD_TM_CMD_WLAN_HB:
19250 {
19251 int buf_len;
19252 void *buf;
19253 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080019254 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070019255
19256 if (!tb[WLAN_HDD_TM_ATTR_DATA])
19257 {
19258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19259 "%s Testmode INV DATA", __func__);
19260 return -EINVAL;
19261 }
19262
19263 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
19264 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080019265
19266 hb_params_temp =(tSirLPHBReq *)buf;
19267 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
19268 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
19269 return -EINVAL;
19270
Leo Chang9056f462013-08-01 19:21:11 -070019271 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
19272 if (NULL == hb_params)
19273 {
19274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19275 "%s Request Buffer Alloc Fail", __func__);
19276 return -EINVAL;
19277 }
19278
19279 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070019280 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
19281 hb_params,
19282 wlan_hdd_cfg80211_lphb_ind_handler);
19283 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070019284 {
Leo Changd9df8aa2013-09-26 13:32:26 -070019285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19286 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070019287 vos_mem_free(hb_params);
19288 }
Leo Chang9056f462013-08-01 19:21:11 -070019289 return 0;
19290 }
19291#endif /* FEATURE_WLAN_LPHB */
19292 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19294 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070019295 return -EOPNOTSUPP;
19296 }
19297
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019298 EXIT();
19299 return err;
Leo Chang9056f462013-08-01 19:21:11 -070019300}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019301
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053019302static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
19303#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
19304 struct wireless_dev *wdev,
19305#endif
19306 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019307{
19308 int ret;
19309
19310 vos_ssr_protect(__func__);
19311 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
19312 vos_ssr_unprotect(__func__);
19313
19314 return ret;
19315}
Leo Chang9056f462013-08-01 19:21:11 -070019316#endif /* CONFIG_NL80211_TESTMODE */
19317
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019318extern void hdd_set_wlan_suspend_mode(bool suspend);
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019319static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019320 struct net_device *dev,
19321 int idx, struct survey_info *survey)
19322{
19323 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19324 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053019325 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019326 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053019327 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019328 v_S7_t snr,rssi;
19329 int status, i, j, filled = 0;
19330
19331 ENTER();
19332
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019333 if (NULL == pAdapter)
19334 {
19335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19336 "%s: HDD adapter is Null", __func__);
19337 return -ENODEV;
19338 }
19339
19340 if (NULL == wiphy)
19341 {
19342 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19343 "%s: wiphy is Null", __func__);
19344 return -ENODEV;
19345 }
19346
19347 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19348 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019349 if (0 != status)
19350 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019351 return status;
19352 }
19353
Mihir Sheted9072e02013-08-21 17:02:29 +053019354 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19355
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019356 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053019357 0 != pAdapter->survey_idx ||
19358 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019359 {
19360 /* The survey dump ops when implemented completely is expected to
19361 * return a survey of all channels and the ops is called by the
19362 * kernel with incremental values of the argument 'idx' till it
19363 * returns -ENONET. But we can only support the survey for the
19364 * operating channel for now. survey_idx is used to track
19365 * that the ops is called only once and then return -ENONET for
19366 * the next iteration
19367 */
19368 pAdapter->survey_idx = 0;
19369 return -ENONET;
19370 }
19371
Mukul Sharma9d5233b2015-06-11 20:28:20 +053019372 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
19373 {
19374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19375 "%s: Roaming in progress, hence return ", __func__);
19376 return -ENONET;
19377 }
19378
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019379 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19380
19381 wlan_hdd_get_snr(pAdapter, &snr);
19382 wlan_hdd_get_rssi(pAdapter, &rssi);
19383
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019384 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19385 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
19386 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019387 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
19388 hdd_wlan_get_freq(channel, &freq);
19389
19390
19391 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
19392 {
19393 if (NULL == wiphy->bands[i])
19394 {
19395 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19396 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19397 continue;
19398 }
19399
19400 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19401 {
19402 struct ieee80211_supported_band *band = wiphy->bands[i];
19403
19404 if (band->channels[j].center_freq == (v_U16_t)freq)
19405 {
19406 survey->channel = &band->channels[j];
19407 /* The Rx BDs contain SNR values in dB for the received frames
19408 * while the supplicant expects noise. So we calculate and
19409 * return the value of noise (dBm)
19410 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19411 */
19412 survey->noise = rssi - snr;
19413 survey->filled = SURVEY_INFO_NOISE_DBM;
19414 filled = 1;
19415 }
19416 }
19417 }
19418
19419 if (filled)
19420 pAdapter->survey_idx = 1;
19421 else
19422 {
19423 pAdapter->survey_idx = 0;
19424 return -ENONET;
19425 }
19426
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019427 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019428 return 0;
19429}
19430
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019431static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19432 struct net_device *dev,
19433 int idx, struct survey_info *survey)
19434{
19435 int ret;
19436
19437 vos_ssr_protect(__func__);
19438 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19439 vos_ssr_unprotect(__func__);
19440
19441 return ret;
19442}
19443
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019444/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019445 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019446 * this is called when cfg80211 driver resume
19447 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19448 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019449int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019450{
19451 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19452 hdd_adapter_t *pAdapter;
19453 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19454 VOS_STATUS status = VOS_STATUS_SUCCESS;
19455
19456 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019457
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019458 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019459 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019460 return 0;
19461 }
19462
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019463 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19464 NO_SESSION, pHddCtx->isWiphySuspended));
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019465
19466 if ((VOS_STA_SAP_MODE == hdd_get_conparam()) &&
19467 pHddCtx->is_ap_mode_wow_supported)
19468 {
19469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19470 "%s: Resume SoftAP", __func__);
19471 hdd_set_wlan_suspend_mode(false);
19472 }
19473
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019474 spin_lock(&pHddCtx->schedScan_lock);
19475 pHddCtx->isWiphySuspended = FALSE;
19476 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19477 {
19478 spin_unlock(&pHddCtx->schedScan_lock);
19479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19480 "%s: Return resume is not due to PNO indication", __func__);
19481 return 0;
19482 }
19483 // Reset flag to avoid updatating cfg80211 data old results again
19484 pHddCtx->isSchedScanUpdatePending = FALSE;
19485 spin_unlock(&pHddCtx->schedScan_lock);
19486
19487 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19488
19489 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19490 {
19491 pAdapter = pAdapterNode->pAdapter;
19492 if ( (NULL != pAdapter) &&
19493 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19494 {
19495 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019496 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19498 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019499 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019500 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019501 {
19502 /* Acquire wakelock to handle the case where APP's tries to
19503 * suspend immediately after updating the scan results. Whis
19504 * results in app's is in suspended state and not able to
19505 * process the connect request to AP
19506 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019507 hdd_prevent_suspend_timeout(2000,
19508 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019509 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019510 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019511
19512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19513 "%s : cfg80211 scan result database updated", __func__);
19514
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019515 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019516 return 0;
19517
19518 }
19519 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19520 pAdapterNode = pNext;
19521 }
19522
19523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19524 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019525 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019526 return 0;
19527}
19528
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019529int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19530{
19531 int ret;
19532
19533 vos_ssr_protect(__func__);
19534 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19535 vos_ssr_unprotect(__func__);
19536
19537 return ret;
19538}
19539
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019540/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019541 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019542 * this is called when cfg80211 driver suspends
19543 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019544int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019545 struct cfg80211_wowlan *wow)
19546{
19547 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019548 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019549
19550 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019551
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019552 ret = wlan_hdd_validate_context(pHddCtx);
19553 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019554 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019555 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019556 }
19557
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053019558 if ((VOS_STA_SAP_MODE == hdd_get_conparam()) &&
19559 (pHddCtx->is_ap_mode_wow_supported)) {
19560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19561 "%s: Suspend SoftAP", __func__);
19562 hdd_set_wlan_suspend_mode(true);
19563 }
19564
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019565
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019566 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19567 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19568 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019569 pHddCtx->isWiphySuspended = TRUE;
19570
19571 EXIT();
19572
19573 return 0;
19574}
19575
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019576int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19577 struct cfg80211_wowlan *wow)
19578{
19579 int ret;
19580
19581 vos_ssr_protect(__func__);
19582 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19583 vos_ssr_unprotect(__func__);
19584
19585 return ret;
19586}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019587
19588#ifdef FEATURE_OEM_DATA_SUPPORT
19589static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019590 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019591{
19592 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19593
19594 ENTER();
19595
19596 if (wlan_hdd_validate_context(pHddCtx)) {
19597 return;
19598 }
19599 if (!pMsg)
19600 {
19601 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19602 return;
19603 }
19604
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019605 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019606
19607 EXIT();
19608 return;
19609
19610}
19611
19612void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019613 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019614{
19615 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19616
19617 ENTER();
19618
19619 if (wlan_hdd_validate_context(pHddCtx)) {
19620 return;
19621 }
19622
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019623 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019624
19625 switch(evType) {
19626 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019627 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019628 break;
19629 default:
19630 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19631 break;
19632 }
19633 EXIT();
19634}
19635#endif
19636
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019637#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19638 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019639/**
19640 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
19641 * @wiphy: Pointer to wiphy
19642 * @wdev: Pointer to wireless device structure
19643 *
19644 * This function is used to abort an ongoing scan
19645 *
19646 * Return: None
19647 */
19648static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19649 struct wireless_dev *wdev)
19650{
19651 struct net_device *dev = wdev->netdev;
19652 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19653 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19654 int ret;
19655
19656 ENTER();
19657
19658 if (NULL == adapter) {
19659 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
19660 return;
19661 }
19662
19663 ret = wlan_hdd_validate_context(hdd_ctx);
19664 if (0 != ret)
19665 return;
19666
19667 wlan_hdd_scan_abort(adapter);
19668
19669 return;
19670}
19671
19672/**
19673 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
19674 * @wiphy: Pointer to wiphy
19675 * @wdev: Pointer to wireless device structure
19676 *
19677 * Return: None
19678 */
19679void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19680 struct wireless_dev *wdev)
19681{
19682 vos_ssr_protect(__func__);
19683 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
19684 vos_ssr_unprotect(__func__);
19685
19686 return;
19687}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019688#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019689
Jeff Johnson295189b2012-06-20 16:38:30 -070019690/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019691static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070019692{
19693 .add_virtual_intf = wlan_hdd_add_virtual_intf,
19694 .del_virtual_intf = wlan_hdd_del_virtual_intf,
19695 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
19696 .change_station = wlan_hdd_change_station,
19697#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
19698 .add_beacon = wlan_hdd_cfg80211_add_beacon,
19699 .del_beacon = wlan_hdd_cfg80211_del_beacon,
19700 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019701#else
19702 .start_ap = wlan_hdd_cfg80211_start_ap,
19703 .change_beacon = wlan_hdd_cfg80211_change_beacon,
19704 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070019705#endif
19706 .change_bss = wlan_hdd_cfg80211_change_bss,
19707 .add_key = wlan_hdd_cfg80211_add_key,
19708 .get_key = wlan_hdd_cfg80211_get_key,
19709 .del_key = wlan_hdd_cfg80211_del_key,
19710 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019711#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070019712 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019714 .scan = wlan_hdd_cfg80211_scan,
19715 .connect = wlan_hdd_cfg80211_connect,
19716 .disconnect = wlan_hdd_cfg80211_disconnect,
19717 .join_ibss = wlan_hdd_cfg80211_join_ibss,
19718 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
19719 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
19720 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
19721 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070019722 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
19723 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053019724 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070019725#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19726 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
19727 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
19728 .set_txq_params = wlan_hdd_set_txq_params,
19729#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019730 .get_station = wlan_hdd_cfg80211_get_station,
19731 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
19732 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019733 .add_station = wlan_hdd_cfg80211_add_station,
19734#ifdef FEATURE_WLAN_LFR
19735 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
19736 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
19737 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
19738#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019739#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
19740 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
19741#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019742#ifdef FEATURE_WLAN_TDLS
19743 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
19744 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
19745#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019746#ifdef WLAN_FEATURE_GTK_OFFLOAD
19747 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
19748#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019749#ifdef FEATURE_WLAN_SCAN_PNO
19750 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
19751 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
19752#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019753 .resume = wlan_hdd_cfg80211_resume_wlan,
19754 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019755 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070019756#ifdef WLAN_NL80211_TESTMODE
19757 .testmode_cmd = wlan_hdd_cfg80211_testmode,
19758#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019759 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019760#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19761 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019762 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019763#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019764};
19765