blob: 51afef517859eb59e8574a10927a13cf0865ceae [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;
9309
9310 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9311
9312 /*Set wps station to configured*/
9313 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9314
9315 if(pIe)
9316 {
9317 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9318 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009319 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 return -EINVAL;
9321 }
9322 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9323 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009324 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009325 /* Check 15 bit of WPS IE as it contain information for wps state
9326 * WPS state
9327 */
9328 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9329 {
9330 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9331 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9332 {
9333 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9334 }
9335 }
9336 }
9337 else
9338 {
9339 pConfig->wps_state = SAP_WPS_DISABLED;
9340 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309341 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009342
c_hpothufe599e92014-06-16 11:38:55 +05309343 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9344 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9345 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9346 eCSR_ENCRYPT_TYPE_NONE;
9347
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 pConfig->RSNWPAReqIELength = 0;
9349 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309350 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 WLAN_EID_RSN);
9352 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309353 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9355 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9356 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309357 /* The actual processing may eventually be more extensive than
9358 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 * by the app.
9360 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309361 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9363 &RSNEncryptType,
9364 &mcRSNEncryptType,
9365 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009366 &MFPCapable,
9367 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 pConfig->pRSNWPAReqIE[1]+2,
9369 pConfig->pRSNWPAReqIE );
9370
9371 if( VOS_STATUS_SUCCESS == status )
9372 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309373 /* Now copy over all the security attributes you have
9374 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 * */
9376 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9377 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9378 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9379 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309380 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009381 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9383 }
9384 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309385
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9387 pBeacon->tail, pBeacon->tail_len);
9388
9389 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9390 {
9391 if (pConfig->pRSNWPAReqIE)
9392 {
9393 /*Mixed mode WPA/WPA2*/
9394 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
9395 pConfig->RSNWPAReqIELength += pIe[1] + 2;
9396 }
9397 else
9398 {
9399 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9400 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9401 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309402 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9404 &RSNEncryptType,
9405 &mcRSNEncryptType,
9406 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009407 &MFPCapable,
9408 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 pConfig->pRSNWPAReqIE[1]+2,
9410 pConfig->pRSNWPAReqIE );
9411
9412 if( VOS_STATUS_SUCCESS == status )
9413 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309414 /* Now copy over all the security attributes you have
9415 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 * */
9417 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9418 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9419 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9420 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309421 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009422 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9424 }
9425 }
9426 }
9427
Jeff Johnson4416a782013-03-25 14:17:50 -07009428 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
9429 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9430 return -EINVAL;
9431 }
9432
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9434
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009435#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 if (params->ssid != NULL)
9437 {
9438 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9439 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9440 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9441 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9442 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009443#else
9444 if (ssid != NULL)
9445 {
9446 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9447 pConfig->SSIDinfo.ssid.length = ssid_len;
9448 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9449 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9450 }
9451#endif
9452
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309453 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309455
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 /* default value */
9457 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9458 pConfig->num_accept_mac = 0;
9459 pConfig->num_deny_mac = 0;
9460
9461 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9462 pBeacon->tail, pBeacon->tail_len);
9463
9464 /* pIe for black list is following form:
9465 type : 1 byte
9466 length : 1 byte
9467 OUI : 4 bytes
9468 acl type : 1 byte
9469 no of mac addr in black list: 1 byte
9470 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309471 */
9472 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 {
9474 pConfig->SapMacaddr_acl = pIe[6];
9475 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009476 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309478 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9479 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9481 for (i = 0; i < pConfig->num_deny_mac; i++)
9482 {
9483 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9484 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 }
9487 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9488 pBeacon->tail, pBeacon->tail_len);
9489
9490 /* pIe for white list is following form:
9491 type : 1 byte
9492 length : 1 byte
9493 OUI : 4 bytes
9494 acl type : 1 byte
9495 no of mac addr in white list: 1 byte
9496 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309497 */
9498 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 {
9500 pConfig->SapMacaddr_acl = pIe[6];
9501 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009502 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309504 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9505 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9507 for (i = 0; i < pConfig->num_accept_mac; i++)
9508 {
9509 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9510 acl_entry++;
9511 }
9512 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309513
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9515
Jeff Johnsone7245742012-09-05 17:12:55 -07009516#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009517 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309518 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9519 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309520 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9521 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009522 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9523 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309524 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9525 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009526 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309527 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009528 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309529 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009530
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309531 /* If ACS disable and selected channel <= 14
9532 * OR
9533 * ACS enabled and ACS operating band is choosen as 2.4
9534 * AND
9535 * VHT in 2.4G Disabled
9536 * THEN
9537 * Fallback to 11N mode
9538 */
9539 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9540 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309541 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309542 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009543 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309544 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9545 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009546 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9547 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009548 }
9549#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309550
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 // ht_capab is not what the name conveys,this is used for protection bitmap
9552 pConfig->ht_capab =
9553 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9554
9555 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9556 {
9557 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9558 return -EINVAL;
9559 }
9560
9561 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309562 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9564 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565 pConfig->obssProtEnabled =
9566 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009567
Chet Lanctot8cecea22014-02-11 19:09:36 -08009568#ifdef WLAN_FEATURE_11W
9569 pConfig->mfpCapable = MFPCapable;
9570 pConfig->mfpRequired = MFPRequired;
9571 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9572 pConfig->mfpCapable, pConfig->mfpRequired);
9573#endif
9574
Arif Hussain6d2a3322013-11-17 19:50:10 -08009575 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009577 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9578 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9579 (int)pConfig->channel);
9580 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9581 pConfig->SapHw_mode, pConfig->privacy,
9582 pConfig->authType);
9583 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9584 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9585 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9586 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009587
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309588 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 {
9590 //Bss already started. just return.
9591 //TODO Probably it should update some beacon params.
9592 hddLog( LOGE, "Bss Already started...Ignore the request");
9593 EXIT();
9594 return 0;
9595 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309596
Agarwal Ashish51325b52014-06-16 16:50:49 +05309597 if (vos_max_concurrent_connections_reached()) {
9598 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9599 return -EINVAL;
9600 }
9601
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 pConfig->persona = pHostapdAdapter->device_mode;
9603
Peng Xu2446a892014-09-05 17:21:18 +05309604 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9605 if ( NULL != psmeConfig)
9606 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309607 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309608 sme_GetConfigParam(hHal, psmeConfig);
9609 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309610#ifdef WLAN_FEATURE_AP_HT40_24G
9611 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9612 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9613 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9614 {
9615 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9616 sme_UpdateConfig (hHal, psmeConfig);
9617 }
9618#endif
Peng Xu2446a892014-09-05 17:21:18 +05309619 vos_mem_free(psmeConfig);
9620 }
Peng Xuafc34e32014-09-25 13:23:55 +05309621 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309622
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 pSapEventCallback = hdd_hostapd_SAPEventCB;
9624 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9625 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9626 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009627 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 return -EINVAL;
9629 }
9630
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309631 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9633
9634 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309635
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309637 {
9638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009639 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009640 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 VOS_ASSERT(0);
9642 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309643
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309645 /* Initialize WMM configuation */
9646 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309647 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009648
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009649#ifdef WLAN_FEATURE_P2P_DEBUG
9650 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9651 {
9652 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9653 {
9654 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9655 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009656 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009657 }
9658 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9659 {
9660 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9661 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009662 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009663 }
9664 }
9665#endif
9666
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 pHostapdState->bCommit = TRUE;
9668 EXIT();
9669
9670 return 0;
9671}
9672
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009673#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309674static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309675 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 struct beacon_parameters *params)
9677{
9678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309679 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309680 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009681
9682 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309683
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309684 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9685 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9686 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309687 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9688 hdd_device_modetoString(pAdapter->device_mode),
9689 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009690
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9692 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309693 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009694 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309695 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009696 }
9697
Agarwal Ashish51325b52014-06-16 16:50:49 +05309698 if (vos_max_concurrent_connections_reached()) {
9699 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9700 return -EINVAL;
9701 }
9702
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309703 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 )
9706 {
9707 beacon_data_t *old,*new;
9708
9709 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309710
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309712 {
9713 hddLog(VOS_TRACE_LEVEL_WARN,
9714 FL("already beacon info added to session(%d)"),
9715 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009718
9719 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9720
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309721 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 {
9723 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009724 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 return -EINVAL;
9726 }
9727
9728 pAdapter->sessionCtx.ap.beacon = new;
9729
9730 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9731 }
9732
9733 EXIT();
9734 return status;
9735}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309736
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309737static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9738 struct net_device *dev,
9739 struct beacon_parameters *params)
9740{
9741 int ret;
9742
9743 vos_ssr_protect(__func__);
9744 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9745 vos_ssr_unprotect(__func__);
9746
9747 return ret;
9748}
9749
9750static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 struct net_device *dev,
9752 struct beacon_parameters *params)
9753{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309754 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309755 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9756 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309757 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
9759 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309760
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309761 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9762 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9763 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9764 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9765 __func__, hdd_device_modetoString(pAdapter->device_mode),
9766 pAdapter->device_mode);
9767
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9769 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309770 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009771 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309772 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009773 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309774
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309775 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309777 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 {
9779 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309780
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309782
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309784 {
9785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9786 FL("session(%d) old and new heads points to NULL"),
9787 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009790
9791 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9792
9793 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309794 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009795 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 return -EINVAL;
9797 }
9798
9799 pAdapter->sessionCtx.ap.beacon = new;
9800
9801 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9802 }
9803
9804 EXIT();
9805 return status;
9806}
9807
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309808static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
9809 struct net_device *dev,
9810 struct beacon_parameters *params)
9811{
9812 int ret;
9813
9814 vos_ssr_protect(__func__);
9815 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
9816 vos_ssr_unprotect(__func__);
9817
9818 return ret;
9819}
9820
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009821#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9822
9823#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309824static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009826#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309827static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009828 struct net_device *dev)
9829#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009830{
9831 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07009832 hdd_context_t *pHddCtx = NULL;
9833 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309834 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309835 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009836
9837 ENTER();
9838
9839 if (NULL == pAdapter)
9840 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009842 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 return -ENODEV;
9844 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009845
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309846 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9847 TRACE_CODE_HDD_CFG80211_STOP_AP,
9848 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309849 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9850 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309851 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009852 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309853 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07009854 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009855
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009856 pScanInfo = &pHddCtx->scan_info;
9857
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309858 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9859 __func__, hdd_device_modetoString(pAdapter->device_mode),
9860 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009861
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309862 ret = wlan_hdd_scan_abort(pAdapter);
9863
Girish Gowli4bf7a632014-06-12 13:42:11 +05309864 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07009865 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309866 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9867 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309868
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309869 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07009870 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9872 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08009873
Jeff Johnsone7245742012-09-05 17:12:55 -07009874 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309875 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07009876 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309877 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009878 }
9879
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309880 /* Delete all associated STAs before stopping AP/P2P GO */
9881 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05309882 hdd_hostapd_stop(dev);
9883
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 )
9887 {
9888 beacon_data_t *old;
9889
9890 old = pAdapter->sessionCtx.ap.beacon;
9891
9892 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309893 {
9894 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9895 FL("session(%d) beacon data points to NULL"),
9896 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009899
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009901
9902 mutex_lock(&pHddCtx->sap_lock);
9903 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9904 {
Jeff Johnson4416a782013-03-25 14:17:50 -07009905 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 {
9907 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9908
9909 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
9910
9911 if (!VOS_IS_STATUS_SUCCESS(status))
9912 {
9913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009914 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309916 }
9917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309919 /* BSS stopped, clear the active sessions for this device mode */
9920 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009921 }
9922 mutex_unlock(&pHddCtx->sap_lock);
9923
9924 if(status != VOS_STATUS_SUCCESS)
9925 {
9926 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009927 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 return -EINVAL;
9929 }
9930
Jeff Johnson4416a782013-03-25 14:17:50 -07009931 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
9933 ==eHAL_STATUS_FAILURE)
9934 {
9935 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009936 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009937 }
9938
Jeff Johnson4416a782013-03-25 14:17:50 -07009939 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9941 eANI_BOOLEAN_FALSE) )
9942 {
9943 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009944 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 }
9946
9947 // Reset WNI_CFG_PROBE_RSP Flags
9948 wlan_hdd_reset_prob_rspies(pAdapter);
9949
9950 pAdapter->sessionCtx.ap.beacon = NULL;
9951 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009952#ifdef WLAN_FEATURE_P2P_DEBUG
9953 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
9954 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
9955 {
9956 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
9957 "GO got removed");
9958 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
9959 }
9960#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009961 }
9962 EXIT();
9963 return status;
9964}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009965
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309966#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9967static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
9968 struct net_device *dev)
9969{
9970 int ret;
9971
9972 vos_ssr_protect(__func__);
9973 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
9974 vos_ssr_unprotect(__func__);
9975
9976 return ret;
9977}
9978#else
9979static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
9980 struct net_device *dev)
9981{
9982 int ret;
9983
9984 vos_ssr_protect(__func__);
9985 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
9986 vos_ssr_unprotect(__func__);
9987
9988 return ret;
9989}
9990#endif
9991
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009992#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
9993
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309994static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309995 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009996 struct cfg80211_ap_settings *params)
9997{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309998 hdd_adapter_t *pAdapter;
9999 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010000 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010001
10002 ENTER();
10003
Girish Gowlib143d7a2015-02-18 19:39:55 +053010004 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010005 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +053010007 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010008 return -ENODEV;
10009 }
10010
10011 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10012 if (NULL == pAdapter)
10013 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010015 "%s: HDD adapter is Null", __func__);
10016 return -ENODEV;
10017 }
10018
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010019 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10020 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
10021 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010022 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
10023 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010025 "%s: HDD adapter magic is invalid", __func__);
10026 return -ENODEV;
10027 }
10028
10029 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010030 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010031 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010032 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010033 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010034 }
10035
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
10037 __func__, hdd_device_modetoString(pAdapter->device_mode),
10038 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010039
10040 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010041 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010042 )
10043 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010044 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010045
10046 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010047
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010048 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010049 {
10050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10051 FL("already beacon info added to session(%d)"),
10052 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010053 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010054 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010055
Girish Gowlib143d7a2015-02-18 19:39:55 +053010056#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10057 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10058 &new,
10059 &params->beacon);
10060#else
10061 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10062 &new,
10063 &params->beacon,
10064 params->dtim_period);
10065#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010066
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010067 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010068 {
10069 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010070 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010071 return -EINVAL;
10072 }
10073 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010074#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010075 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10076#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10077 params->channel, params->channel_type);
10078#else
10079 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10080#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010081#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010082 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010083 params->ssid_len, params->hidden_ssid,
10084 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010085 }
10086
10087 EXIT();
10088 return status;
10089}
10090
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010091static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10092 struct net_device *dev,
10093 struct cfg80211_ap_settings *params)
10094{
10095 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010096
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010097 vos_ssr_protect(__func__);
10098 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10099 vos_ssr_unprotect(__func__);
10100
10101 return ret;
10102}
10103
10104static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010105 struct net_device *dev,
10106 struct cfg80211_beacon_data *params)
10107{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010109 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010110 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010111
10112 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010113
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010114 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10115 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10116 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010117 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010118 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010119
10120 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10121 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010122 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010123 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010124 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010125 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010126
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010127 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010128 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010129 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010130 {
10131 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010132
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010133 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010134
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010135 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010136 {
10137 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10138 FL("session(%d) beacon data points to NULL"),
10139 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010140 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010141 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010142
10143 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10144
10145 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010146 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010147 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010148 return -EINVAL;
10149 }
10150
10151 pAdapter->sessionCtx.ap.beacon = new;
10152
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010153 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10154 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010155 }
10156
10157 EXIT();
10158 return status;
10159}
10160
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010161static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10162 struct net_device *dev,
10163 struct cfg80211_beacon_data *params)
10164{
10165 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010166
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010167 vos_ssr_protect(__func__);
10168 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10169 vos_ssr_unprotect(__func__);
10170
10171 return ret;
10172}
10173
10174#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010175
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010176static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 struct net_device *dev,
10178 struct bss_parameters *params)
10179{
10180 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010181 hdd_context_t *pHddCtx;
10182 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010183
10184 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010185
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010186 if (NULL == pAdapter)
10187 {
10188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10189 "%s: HDD adapter is Null", __func__);
10190 return -ENODEV;
10191 }
10192 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010193 ret = wlan_hdd_validate_context(pHddCtx);
10194 if (0 != ret)
10195 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010196 return ret;
10197 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010198 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10199 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10200 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010201 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10202 __func__, hdd_device_modetoString(pAdapter->device_mode),
10203 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010204
10205 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010207 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 {
10209 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10210 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010211 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 {
10213 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 }
10216
10217 EXIT();
10218 return 0;
10219}
10220
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010221static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10222 struct net_device *dev,
10223 struct bss_parameters *params)
10224{
10225 int ret;
10226
10227 vos_ssr_protect(__func__);
10228 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10229 vos_ssr_unprotect(__func__);
10230
10231 return ret;
10232}
Kiet Lam10841362013-11-01 11:36:50 +053010233/* FUNCTION: wlan_hdd_change_country_code_cd
10234* to wait for contry code completion
10235*/
10236void* wlan_hdd_change_country_code_cb(void *pAdapter)
10237{
10238 hdd_adapter_t *call_back_pAdapter = pAdapter;
10239 complete(&call_back_pAdapter->change_country_code);
10240 return NULL;
10241}
10242
Jeff Johnson295189b2012-06-20 16:38:30 -070010243/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010244 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10246 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010247int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 struct net_device *ndev,
10249 enum nl80211_iftype type,
10250 u32 *flags,
10251 struct vif_params *params
10252 )
10253{
10254 struct wireless_dev *wdev;
10255 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010256 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010257 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 tCsrRoamProfile *pRoamProfile = NULL;
10259 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010260 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 eMib_dot11DesiredBssType connectedBssType;
10262 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010263 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010264
10265 ENTER();
10266
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010267 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010268 {
10269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10270 "%s: Adapter context is null", __func__);
10271 return VOS_STATUS_E_FAILURE;
10272 }
10273
10274 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10275 if (!pHddCtx)
10276 {
10277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10278 "%s: HDD context is null", __func__);
10279 return VOS_STATUS_E_FAILURE;
10280 }
10281
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010282 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10283 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10284 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010285 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010286 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010288 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 }
10290
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10292 __func__, hdd_device_modetoString(pAdapter->device_mode),
10293 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010294
Agarwal Ashish51325b52014-06-16 16:50:49 +053010295 if (vos_max_concurrent_connections_reached()) {
10296 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10297 return -EINVAL;
10298 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010299 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 wdev = ndev->ieee80211_ptr;
10301
10302#ifdef WLAN_BTAMP_FEATURE
10303 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10304 (NL80211_IFTYPE_ADHOC == type)||
10305 (NL80211_IFTYPE_AP == type)||
10306 (NL80211_IFTYPE_P2P_GO == type))
10307 {
10308 pHddCtx->isAmpAllowed = VOS_FALSE;
10309 // stop AMP traffic
10310 status = WLANBAP_StopAmp();
10311 if(VOS_STATUS_SUCCESS != status )
10312 {
10313 pHddCtx->isAmpAllowed = VOS_TRUE;
10314 hddLog(VOS_TRACE_LEVEL_FATAL,
10315 "%s: Failed to stop AMP", __func__);
10316 return -EINVAL;
10317 }
10318 }
10319#endif //WLAN_BTAMP_FEATURE
10320 /* Reset the current device mode bit mask*/
10321 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10322
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010323 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10324 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10325 (type == NL80211_IFTYPE_P2P_GO)))
10326 {
10327 /* Notify Mode change in case of concurrency.
10328 * Below function invokes TDLS teardown Functionality Since TDLS is
10329 * not Supported in case of concurrency i.e Once P2P session
10330 * is detected disable offchannel and teardown TDLS links
10331 */
10332 hddLog(LOG1,
10333 FL("Device mode = %d Interface type = %d"),
10334 pAdapter->device_mode, type);
10335 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10336 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010337
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010340 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010341 )
10342 {
10343 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010344 if (!pWextState)
10345 {
10346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10347 "%s: pWextState is null", __func__);
10348 return VOS_STATUS_E_FAILURE;
10349 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 pRoamProfile = &pWextState->roamProfile;
10351 LastBSSType = pRoamProfile->BSSType;
10352
10353 switch (type)
10354 {
10355 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 hddLog(VOS_TRACE_LEVEL_INFO,
10358 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10359 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010360#ifdef WLAN_FEATURE_11AC
10361 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10362 {
10363 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10364 }
10365#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010366 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010367 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010369 //Check for sub-string p2p to confirm its a p2p interface
10370 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010371 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010372#ifdef FEATURE_WLAN_TDLS
10373 mutex_lock(&pHddCtx->tdls_lock);
10374 wlan_hdd_tdls_exit(pAdapter, TRUE);
10375 mutex_unlock(&pHddCtx->tdls_lock);
10376#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010377 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10378 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10379 }
10380 else
10381 {
10382 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010386
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 case NL80211_IFTYPE_ADHOC:
10388 hddLog(VOS_TRACE_LEVEL_INFO,
10389 "%s: setting interface Type to ADHOC", __func__);
10390 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10391 pRoamProfile->phyMode =
10392 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010393 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010394 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010395 hdd_set_ibss_ops( pAdapter );
10396 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010397
10398 status = hdd_sta_id_hash_attach(pAdapter);
10399 if (VOS_STATUS_SUCCESS != status) {
10400 hddLog(VOS_TRACE_LEVEL_ERROR,
10401 FL("Failed to initialize hash for IBSS"));
10402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 break;
10404
10405 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 {
10408 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10409 "%s: setting interface Type to %s", __func__,
10410 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10411
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010412 //Cancel any remain on channel for GO mode
10413 if (NL80211_IFTYPE_P2P_GO == type)
10414 {
10415 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10416 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010417 if (NL80211_IFTYPE_AP == type)
10418 {
10419 /* As Loading WLAN Driver one interface being created for p2p device
10420 * address. This will take one HW STA and the max number of clients
10421 * that can connect to softAP will be reduced by one. so while changing
10422 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10423 * interface as it is not required in SoftAP mode.
10424 */
10425
10426 // Get P2P Adapter
10427 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10428
10429 if (pP2pAdapter)
10430 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010431 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010432 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010433 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10434 }
10435 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010436 //Disable IMPS & BMPS for SAP/GO
10437 if(VOS_STATUS_E_FAILURE ==
10438 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10439 {
10440 //Fail to Exit BMPS
10441 VOS_ASSERT(0);
10442 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010443
10444 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10445
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010446#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010447
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010448 /* A Mutex Lock is introduced while changing the mode to
10449 * protect the concurrent access for the Adapters by TDLS
10450 * module.
10451 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010452 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010453#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010454 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010455 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010456 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10458 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010459#ifdef FEATURE_WLAN_TDLS
10460 mutex_unlock(&pHddCtx->tdls_lock);
10461#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010462 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10463 (pConfig->apRandomBssidEnabled))
10464 {
10465 /* To meet Android requirements create a randomized
10466 MAC address of the form 02:1A:11:Fx:xx:xx */
10467 get_random_bytes(&ndev->dev_addr[3], 3);
10468 ndev->dev_addr[0] = 0x02;
10469 ndev->dev_addr[1] = 0x1A;
10470 ndev->dev_addr[2] = 0x11;
10471 ndev->dev_addr[3] |= 0xF0;
10472 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10473 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010474 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10475 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010476 }
10477
Jeff Johnson295189b2012-06-20 16:38:30 -070010478 hdd_set_ap_ops( pAdapter->dev );
10479
Kiet Lam10841362013-11-01 11:36:50 +053010480 /* This is for only SAP mode where users can
10481 * control country through ini.
10482 * P2P GO follows station country code
10483 * acquired during the STA scanning. */
10484 if((NL80211_IFTYPE_AP == type) &&
10485 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10486 {
10487 int status = 0;
10488 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10489 "%s: setting country code from INI ", __func__);
10490 init_completion(&pAdapter->change_country_code);
10491 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10492 (void *)(tSmeChangeCountryCallback)
10493 wlan_hdd_change_country_code_cb,
10494 pConfig->apCntryCode, pAdapter,
10495 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010496 eSIR_FALSE,
10497 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010498 if (eHAL_STATUS_SUCCESS == status)
10499 {
10500 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010501 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010502 &pAdapter->change_country_code,
10503 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010504 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010505 {
10506 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010507 FL("SME Timed out while setting country code %ld"),
10508 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010509
10510 if (pHddCtx->isLogpInProgress)
10511 {
10512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10513 "%s: LOGP in Progress. Ignore!!!", __func__);
10514 return -EAGAIN;
10515 }
Kiet Lam10841362013-11-01 11:36:50 +053010516 }
10517 }
10518 else
10519 {
10520 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010521 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010522 return -EINVAL;
10523 }
10524 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 status = hdd_init_ap_mode(pAdapter);
10526 if(status != VOS_STATUS_SUCCESS)
10527 {
10528 hddLog(VOS_TRACE_LEVEL_FATAL,
10529 "%s: Error initializing the ap mode", __func__);
10530 return -EINVAL;
10531 }
10532 hdd_set_conparam(1);
10533
Nirav Shah7e3c8132015-06-22 23:51:42 +053010534 status = hdd_sta_id_hash_attach(pAdapter);
10535 if (VOS_STATUS_SUCCESS != status)
10536 {
10537 hddLog(VOS_TRACE_LEVEL_ERROR,
10538 FL("Failed to initialize hash for AP"));
10539 return -EINVAL;
10540 }
10541
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 /*interface type changed update in wiphy structure*/
10543 if(wdev)
10544 {
10545 wdev->iftype = type;
10546 pHddCtx->change_iface = type;
10547 }
10548 else
10549 {
10550 hddLog(VOS_TRACE_LEVEL_ERROR,
10551 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10552 return -EINVAL;
10553 }
10554 goto done;
10555 }
10556
10557 default:
10558 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10559 __func__);
10560 return -EOPNOTSUPP;
10561 }
10562 }
10563 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 )
10566 {
10567 switch(type)
10568 {
10569 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010572
10573 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010574#ifdef FEATURE_WLAN_TDLS
10575
10576 /* A Mutex Lock is introduced while changing the mode to
10577 * protect the concurrent access for the Adapters by TDLS
10578 * module.
10579 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010580 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010581#endif
c_hpothu002231a2015-02-05 14:58:51 +053010582 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010584 //Check for sub-string p2p to confirm its a p2p interface
10585 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010586 {
10587 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10588 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10589 }
10590 else
10591 {
10592 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010594 }
Agrawal Ashishcfe83282016-09-29 13:03:45 +053010595
10596 /* set con_mode to STA only when no SAP concurrency mode */
10597 if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO)))
10598 hdd_set_conparam(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10601 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010602#ifdef FEATURE_WLAN_TDLS
10603 mutex_unlock(&pHddCtx->tdls_lock);
10604#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010605 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 if( VOS_STATUS_SUCCESS != status )
10607 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010608 /* In case of JB, for P2P-GO, only change interface will be called,
10609 * This is the right place to enable back bmps_imps()
10610 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010611 if (pHddCtx->hdd_wlan_suspended)
10612 {
10613 hdd_set_pwrparams(pHddCtx);
10614 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010615 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 goto done;
10617 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10621 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010622 goto done;
10623 default:
10624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10625 __func__);
10626 return -EOPNOTSUPP;
10627
10628 }
10629
10630 }
10631 else
10632 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010633 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10634 __func__, hdd_device_modetoString(pAdapter->device_mode),
10635 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010636 return -EOPNOTSUPP;
10637 }
10638
10639
10640 if(pRoamProfile)
10641 {
10642 if ( LastBSSType != pRoamProfile->BSSType )
10643 {
10644 /*interface type changed update in wiphy structure*/
10645 wdev->iftype = type;
10646
10647 /*the BSS mode changed, We need to issue disconnect
10648 if connected or in IBSS disconnect state*/
10649 if ( hdd_connGetConnectedBssType(
10650 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10651 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10652 {
10653 /*need to issue a disconnect to CSR.*/
10654 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10655 if( eHAL_STATUS_SUCCESS ==
10656 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10657 pAdapter->sessionId,
10658 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10659 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010660 ret = wait_for_completion_interruptible_timeout(
10661 &pAdapter->disconnect_comp_var,
10662 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10663 if (ret <= 0)
10664 {
10665 hddLog(VOS_TRACE_LEVEL_ERROR,
10666 FL("wait on disconnect_comp_var failed %ld"), ret);
10667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010668 }
10669 }
10670 }
10671 }
10672
10673done:
10674 /*set bitmask based on updated value*/
10675 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010676
10677 /* Only STA mode support TM now
10678 * all other mode, TM feature should be disabled */
10679 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10680 (~VOS_STA & pHddCtx->concurrency_mode) )
10681 {
10682 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10683 }
10684
Jeff Johnson295189b2012-06-20 16:38:30 -070010685#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010686 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010687 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 {
10689 //we are ok to do AMP
10690 pHddCtx->isAmpAllowed = VOS_TRUE;
10691 }
10692#endif //WLAN_BTAMP_FEATURE
10693 EXIT();
10694 return 0;
10695}
10696
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010697/*
10698 * FUNCTION: wlan_hdd_cfg80211_change_iface
10699 * wrapper function to protect the actual implementation from SSR.
10700 */
10701int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10702 struct net_device *ndev,
10703 enum nl80211_iftype type,
10704 u32 *flags,
10705 struct vif_params *params
10706 )
10707{
10708 int ret;
10709
10710 vos_ssr_protect(__func__);
10711 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10712 vos_ssr_unprotect(__func__);
10713
10714 return ret;
10715}
10716
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010717#ifdef FEATURE_WLAN_TDLS
10718static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010719 struct net_device *dev,
10720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10721 const u8 *mac,
10722#else
10723 u8 *mac,
10724#endif
10725 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010726{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010727 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010728 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010729 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010730 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010731 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010732 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010733
10734 ENTER();
10735
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010736 if (!dev) {
10737 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10738 return -EINVAL;
10739 }
10740
10741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10742 if (!pAdapter) {
10743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10744 return -EINVAL;
10745 }
10746
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010747 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010748 {
10749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10750 "Invalid arguments");
10751 return -EINVAL;
10752 }
Hoonki Lee27511902013-03-14 18:19:06 -070010753
10754 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10755 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10756 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010757 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010758 "%s: TDLS mode is disabled OR not enabled in FW."
10759 MAC_ADDRESS_STR " Request declined.",
10760 __func__, MAC_ADDR_ARRAY(mac));
10761 return -ENOTSUPP;
10762 }
10763
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010764 if (pHddCtx->isLogpInProgress)
10765 {
10766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10767 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010768 wlan_hdd_tdls_set_link_status(pAdapter,
10769 mac,
10770 eTDLS_LINK_IDLE,
10771 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010772 return -EBUSY;
10773 }
10774
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010775 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010776 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010777
10778 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010780 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10781 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010782 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010783 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010784 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010785
10786 /* in add station, we accept existing valid staId if there is */
10787 if ((0 == update) &&
10788 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10789 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010790 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010792 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010793 " link_status %d. staId %d. add station ignored.",
10794 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010795 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010796 return 0;
10797 }
10798 /* in change station, we accept only when staId is valid */
10799 if ((1 == update) &&
10800 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
10801 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
10802 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010803 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010805 "%s: " MAC_ADDRESS_STR
10806 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010807 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
10808 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
10809 mutex_unlock(&pHddCtx->tdls_lock);
10810 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010811 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010812 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010813
10814 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053010815 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010816 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10818 "%s: " MAC_ADDRESS_STR
10819 " TDLS setup is ongoing. Request declined.",
10820 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070010821 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010822 }
10823
10824 /* first to check if we reached to maximum supported TDLS peer.
10825 TODO: for now, return -EPERM looks working fine,
10826 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010827 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10828 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
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
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010832 " TDLS Max peer already connected. Request declined."
10833 " Num of peers (%d), Max allowed (%d).",
10834 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
10835 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010836 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010837 }
10838 else
10839 {
10840 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010841 mutex_lock(&pHddCtx->tdls_lock);
10842 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010843 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010844 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010845 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10847 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
10848 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010849 return -EPERM;
10850 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010851 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010852 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010853 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053010854 wlan_hdd_tdls_set_link_status(pAdapter,
10855 mac,
10856 eTDLS_LINK_CONNECTING,
10857 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010858
Jeff Johnsond75fe012013-04-06 10:53:06 -070010859 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010860 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010861 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010863 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010864 if(StaParams->htcap_present)
10865 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010867 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010869 "ht_capa->extended_capabilities: %0x",
10870 StaParams->HTCap.extendedHtCapInfo);
10871 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010873 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010875 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010876 if(StaParams->vhtcap_present)
10877 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010879 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
10880 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
10881 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
10882 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010883 {
10884 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010885 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010886 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010888 "[%d]: %x ", i, StaParams->supported_rates[i]);
10889 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070010890 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010891 else if ((1 == update) && (NULL == StaParams))
10892 {
10893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10894 "%s : update is true, but staParams is NULL. Error!", __func__);
10895 return -EPERM;
10896 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010897
10898 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
10899
10900 if (!update)
10901 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010902 /*Before adding sta make sure that device exited from BMPS*/
10903 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10904 {
10905 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10906 "%s: Adding tdls peer sta. Disable BMPS", __func__);
10907 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10908 if (status != VOS_STATUS_SUCCESS) {
10909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
10910 }
10911 }
10912
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010913 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010914 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010915 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010916 hddLog(VOS_TRACE_LEVEL_ERROR,
10917 FL("Failed to add TDLS peer STA. Enable Bmps"));
10918 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010919 return -EPERM;
10920 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010921 }
10922 else
10923 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010924 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010925 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010926 if (ret != eHAL_STATUS_SUCCESS) {
10927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
10928 return -EPERM;
10929 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010930 }
10931
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010932 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010933 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
10934
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053010935 mutex_lock(&pHddCtx->tdls_lock);
10936 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
10937
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010938 if ((pTdlsPeer != NULL) &&
10939 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010940 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010941 hddLog(VOS_TRACE_LEVEL_ERROR,
10942 FL("peer link status %u"), pTdlsPeer->link_status);
10943 mutex_unlock(&pHddCtx->tdls_lock);
10944 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010945 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053010946 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010947
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010948 if (ret <= 0)
10949 {
10950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10951 "%s: timeout waiting for tdls add station indication %ld",
10952 __func__, ret);
10953 goto error;
10954 }
10955
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010956 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
10957 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010959 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010960 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010961 }
10962
10963 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010964
10965error:
Atul Mittal115287b2014-07-08 13:26:33 +053010966 wlan_hdd_tdls_set_link_status(pAdapter,
10967 mac,
10968 eTDLS_LINK_IDLE,
10969 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010970 return -EPERM;
10971
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010972}
10973#endif
10974
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010975static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010977#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10978 const u8 *mac,
10979#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010981#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010982 struct station_parameters *params)
10983{
10984 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010985 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010986 hdd_context_t *pHddCtx;
10987 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010989 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010990#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010991 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010992 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010993 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053010994 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010995#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010996
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010997 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010998
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010999 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011000 if ((NULL == pAdapter))
11001 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011003 "invalid adapter ");
11004 return -EINVAL;
11005 }
11006
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011007 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11008 TRACE_CODE_HDD_CHANGE_STATION,
11009 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053011010 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053011011
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011012 ret = wlan_hdd_validate_context(pHddCtx);
11013 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053011014 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011015 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011016 }
11017
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011018 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11019
11020 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011021 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11023 "invalid HDD station context");
11024 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
11027
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011028 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
11029 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070011030 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011031 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070011032 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011033 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 WLANTL_STA_AUTHENTICATED);
11035
Gopichand Nakkala29149562013-05-10 21:43:41 +053011036 if (status != VOS_STATUS_SUCCESS)
11037 {
11038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11039 "%s: Not able to change TL state to AUTHENTICATED", __func__);
11040 return -EINVAL;
11041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 }
11043 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011044 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11045 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011046#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011047 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11048 StaParams.capability = params->capability;
11049 StaParams.uapsd_queues = params->uapsd_queues;
11050 StaParams.max_sp = params->max_sp;
11051
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011052 /* Convert (first channel , number of channels) tuple to
11053 * the total list of channels. This goes with the assumption
11054 * that if the first channel is < 14, then the next channels
11055 * are an incremental of 1 else an incremental of 4 till the number
11056 * of channels.
11057 */
11058 if (0 != params->supported_channels_len) {
11059 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11060 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11061 {
11062 int wifi_chan_index;
11063 StaParams.supported_channels[j] = params->supported_channels[i];
11064 wifi_chan_index =
11065 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11066 no_of_channels = params->supported_channels[i+1];
11067 for(k=1; k <= no_of_channels; k++)
11068 {
11069 StaParams.supported_channels[j+1] =
11070 StaParams.supported_channels[j] + wifi_chan_index;
11071 j+=1;
11072 }
11073 }
11074 StaParams.supported_channels_len = j;
11075 }
11076 vos_mem_copy(StaParams.supported_oper_classes,
11077 params->supported_oper_classes,
11078 params->supported_oper_classes_len);
11079 StaParams.supported_oper_classes_len =
11080 params->supported_oper_classes_len;
11081
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011082 if (0 != params->ext_capab_len)
11083 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
11084 sizeof(StaParams.extn_capability));
11085
11086 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011087 {
11088 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011089 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011090 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011091
11092 StaParams.supported_rates_len = params->supported_rates_len;
11093
11094 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11095 * The supported_rates array , for all the structures propogating till Add Sta
11096 * to the firmware has to be modified , if the supplicant (ieee80211) is
11097 * modified to send more rates.
11098 */
11099
11100 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11101 */
11102 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11103 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11104
11105 if (0 != StaParams.supported_rates_len) {
11106 int i = 0;
11107 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11108 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011109 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011110 "Supported Rates with Length %d", StaParams.supported_rates_len);
11111 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011113 "[%d]: %0x", i, StaParams.supported_rates[i]);
11114 }
11115
11116 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011117 {
11118 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011119 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011120 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011121
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011122 if (0 != params->ext_capab_len ) {
11123 /*Define A Macro : TODO Sunil*/
11124 if ((1<<4) & StaParams.extn_capability[3]) {
11125 isBufSta = 1;
11126 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011127 /* TDLS Channel Switching Support */
11128 if ((1<<6) & StaParams.extn_capability[3]) {
11129 isOffChannelSupported = 1;
11130 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011131 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011132
11133 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
Nitesh Shah48df4c02016-08-12 16:27:33 +053011134 (params->ht_capa || params->vht_capa ||
11135 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))))
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011136 /* TDLS Peer is WME/QoS capable */
11137 isQosWmmSta = TRUE;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011138
11139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11140 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11141 __func__, isQosWmmSta, StaParams.htcap_present);
11142
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011143 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11144 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011145 isOffChannelSupported,
11146 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011147
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011148 if (VOS_STATUS_SUCCESS != status) {
11149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11150 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11151 return -EINVAL;
11152 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011153 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11154
11155 if (VOS_STATUS_SUCCESS != status) {
11156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11157 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11158 return -EINVAL;
11159 }
11160 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011161#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011162 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011163 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011164 return status;
11165}
11166
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011167#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11168static int wlan_hdd_change_station(struct wiphy *wiphy,
11169 struct net_device *dev,
11170 const u8 *mac,
11171 struct station_parameters *params)
11172#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011173static int wlan_hdd_change_station(struct wiphy *wiphy,
11174 struct net_device *dev,
11175 u8 *mac,
11176 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011177#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011178{
11179 int ret;
11180
11181 vos_ssr_protect(__func__);
11182 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11183 vos_ssr_unprotect(__func__);
11184
11185 return ret;
11186}
11187
Jeff Johnson295189b2012-06-20 16:38:30 -070011188/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011189 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 * This function is used to initialize the key information
11191 */
11192#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011193static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011194 struct net_device *ndev,
11195 u8 key_index, bool pairwise,
11196 const u8 *mac_addr,
11197 struct key_params *params
11198 )
11199#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011200static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011201 struct net_device *ndev,
11202 u8 key_index, const u8 *mac_addr,
11203 struct key_params *params
11204 )
11205#endif
11206{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011207 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 tCsrRoamSetKey setKey;
11209 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011210 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011211 v_U32_t roamId= 0xFF;
11212 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 hdd_hostapd_state_t *pHostapdState;
11214 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011215 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011216 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011217
11218 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011219
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011220 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11221 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11222 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011223 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11224 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011225 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011226 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011227 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011228 }
11229
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011230 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11231 __func__, hdd_device_modetoString(pAdapter->device_mode),
11232 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011233
11234 if (CSR_MAX_NUM_KEY <= key_index)
11235 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011236 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011237 key_index);
11238
11239 return -EINVAL;
11240 }
11241
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011242 if (CSR_MAX_KEY_LEN < params->key_len)
11243 {
11244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11245 params->key_len);
11246
11247 return -EINVAL;
11248 }
11249
11250 hddLog(VOS_TRACE_LEVEL_INFO,
11251 "%s: called with key index = %d & key length %d",
11252 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011253
11254 /*extract key idx, key len and key*/
11255 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11256 setKey.keyId = key_index;
11257 setKey.keyLength = params->key_len;
11258 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11259
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011260 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 {
11262 case WLAN_CIPHER_SUITE_WEP40:
11263 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11264 break;
11265
11266 case WLAN_CIPHER_SUITE_WEP104:
11267 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11268 break;
11269
11270 case WLAN_CIPHER_SUITE_TKIP:
11271 {
11272 u8 *pKey = &setKey.Key[0];
11273 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11274
11275 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11276
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011277 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011278
11279 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011280 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 |--------------|----------|----------|
11282 <---16bytes---><--8bytes--><--8bytes-->
11283
11284 */
11285 /*Sme expects the 32 bytes key to be in the below order
11286
11287 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011288 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 |--------------|----------|----------|
11290 <---16bytes---><--8bytes--><--8bytes-->
11291 */
11292 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011293 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011294
11295 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011296 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011297
11298 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011299 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011300
11301
11302 break;
11303 }
11304
11305 case WLAN_CIPHER_SUITE_CCMP:
11306 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11307 break;
11308
11309#ifdef FEATURE_WLAN_WAPI
11310 case WLAN_CIPHER_SUITE_SMS4:
11311 {
11312 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11313 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11314 params->key, params->key_len);
11315 return 0;
11316 }
11317#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011318
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011319#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 case WLAN_CIPHER_SUITE_KRK:
11321 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11322 break;
11323#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011324
11325#ifdef WLAN_FEATURE_11W
11326 case WLAN_CIPHER_SUITE_AES_CMAC:
11327 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011328 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011329#endif
11330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011332 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011334 status = -EOPNOTSUPP;
11335 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011336 }
11337
11338 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11339 __func__, setKey.encType);
11340
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011341 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011342#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11343 (!pairwise)
11344#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011345 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011346#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011347 )
11348 {
11349 /* set group key*/
11350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11351 "%s- %d: setting Broadcast key",
11352 __func__, __LINE__);
11353 setKey.keyDirection = eSIR_RX_ONLY;
11354 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11355 }
11356 else
11357 {
11358 /* set pairwise key*/
11359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11360 "%s- %d: setting pairwise key",
11361 __func__, __LINE__);
11362 setKey.keyDirection = eSIR_TX_RX;
11363 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11364 }
11365 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11366 {
11367 setKey.keyDirection = eSIR_TX_RX;
11368 /*Set the group key*/
11369 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11370 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011371
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011372 if ( 0 != status )
11373 {
11374 hddLog(VOS_TRACE_LEVEL_ERROR,
11375 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011376 status = -EINVAL;
11377 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011378 }
11379 /*Save the keys here and call sme_RoamSetKey for setting
11380 the PTK after peer joins the IBSS network*/
11381 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11382 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011383 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011384 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011385 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11386 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11387 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011389 if( pHostapdState->bssState == BSS_START )
11390 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011391 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11392 vos_status = wlan_hdd_check_ula_done(pAdapter);
11393
11394 if ( vos_status != VOS_STATUS_SUCCESS )
11395 {
11396 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11397 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11398 __LINE__, vos_status );
11399
11400 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11401
11402 status = -EINVAL;
11403 goto end;
11404 }
11405
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11407
11408 if ( status != eHAL_STATUS_SUCCESS )
11409 {
11410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11411 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11412 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011413 status = -EINVAL;
11414 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 }
11416 }
11417
11418 /* Saving WEP keys */
11419 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11420 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11421 {
11422 //Save the wep key in ap context. Issue setkey after the BSS is started.
11423 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11424 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11425 }
11426 else
11427 {
11428 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011429 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11431 }
11432 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011433 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11434 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 {
11436 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11437 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11438
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011439#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11440 if (!pairwise)
11441#else
11442 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11443#endif
11444 {
11445 /* set group key*/
11446 if (pHddStaCtx->roam_info.deferKeyComplete)
11447 {
11448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11449 "%s- %d: Perform Set key Complete",
11450 __func__, __LINE__);
11451 hdd_PerformRoamSetKeyComplete(pAdapter);
11452 }
11453 }
11454
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11456
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011457 pWextState->roamProfile.Keys.defaultIndex = key_index;
11458
11459
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011460 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 params->key, params->key_len);
11462
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011463
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11465
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011466 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011467 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011468 __func__, setKey.peerMac[0], setKey.peerMac[1],
11469 setKey.peerMac[2], setKey.peerMac[3],
11470 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 setKey.keyDirection);
11472
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011473 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011474
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011475 if ( vos_status != VOS_STATUS_SUCCESS )
11476 {
11477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11479 __LINE__, vos_status );
11480
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011481 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011482
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011483 status = -EINVAL;
11484 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011485
11486 }
11487
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011488#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011489 /* The supplicant may attempt to set the PTK once pre-authentication
11490 is done. Save the key in the UMAC and include it in the ADD BSS
11491 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011492 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011493 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011494 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011495 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11496 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011497 status = 0;
11498 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011499 }
11500 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11501 {
11502 hddLog(VOS_TRACE_LEVEL_ERROR,
11503 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011504 status = -EINVAL;
11505 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011506 }
11507#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011508
11509 /* issue set key request to SME*/
11510 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11511 pAdapter->sessionId, &setKey, &roamId );
11512
11513 if ( 0 != status )
11514 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011515 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11517 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011518 status = -EINVAL;
11519 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 }
11521
11522
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011523 /* in case of IBSS as there was no information available about WEP keys during
11524 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011526 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11527 !( ( IW_AUTH_KEY_MGMT_802_1X
11528 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11530 )
11531 &&
11532 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11533 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11534 )
11535 )
11536 {
11537 setKey.keyDirection = eSIR_RX_ONLY;
11538 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11539
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011540 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011542 __func__, setKey.peerMac[0], setKey.peerMac[1],
11543 setKey.peerMac[2], setKey.peerMac[3],
11544 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 setKey.keyDirection);
11546
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011547 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011548 pAdapter->sessionId, &setKey, &roamId );
11549
11550 if ( 0 != status )
11551 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011552 hddLog(VOS_TRACE_LEVEL_ERROR,
11553 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 __func__, status);
11555 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011556 status = -EINVAL;
11557 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 }
11559 }
11560 }
11561
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011562end:
11563 /* Need to clear any trace of key value in the memory.
11564 * Thus zero out the memory even though it is local
11565 * variable.
11566 */
11567 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011568 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011569 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011570}
11571
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011572#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11573static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11574 struct net_device *ndev,
11575 u8 key_index, bool pairwise,
11576 const u8 *mac_addr,
11577 struct key_params *params
11578 )
11579#else
11580static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11581 struct net_device *ndev,
11582 u8 key_index, const u8 *mac_addr,
11583 struct key_params *params
11584 )
11585#endif
11586{
11587 int ret;
11588 vos_ssr_protect(__func__);
11589#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11590 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11591 mac_addr, params);
11592#else
11593 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11594 params);
11595#endif
11596 vos_ssr_unprotect(__func__);
11597
11598 return ret;
11599}
11600
Jeff Johnson295189b2012-06-20 16:38:30 -070011601/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011602 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 * This function is used to get the key information
11604 */
11605#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011606static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011607 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011609 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 const u8 *mac_addr, void *cookie,
11611 void (*callback)(void *cookie, struct key_params*)
11612 )
11613#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011614static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011615 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 struct net_device *ndev,
11617 u8 key_index, const u8 *mac_addr, void *cookie,
11618 void (*callback)(void *cookie, struct key_params*)
11619 )
11620#endif
11621{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011622 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011623 hdd_wext_state_t *pWextState = NULL;
11624 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011625 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011626 hdd_context_t *pHddCtx;
11627 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011628
11629 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011630
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011631 if (NULL == pAdapter)
11632 {
11633 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11634 "%s: HDD adapter is Null", __func__);
11635 return -ENODEV;
11636 }
11637
11638 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11639 ret = wlan_hdd_validate_context(pHddCtx);
11640 if (0 != ret)
11641 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011642 return ret;
11643 }
11644
11645 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11646 pRoamProfile = &(pWextState->roamProfile);
11647
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011648 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11649 __func__, hdd_device_modetoString(pAdapter->device_mode),
11650 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011651
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 memset(&params, 0, sizeof(params));
11653
11654 if (CSR_MAX_NUM_KEY <= key_index)
11655 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011656 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011658 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011659
11660 switch(pRoamProfile->EncryptionType.encryptionType[0])
11661 {
11662 case eCSR_ENCRYPT_TYPE_NONE:
11663 params.cipher = IW_AUTH_CIPHER_NONE;
11664 break;
11665
11666 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11667 case eCSR_ENCRYPT_TYPE_WEP40:
11668 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11669 break;
11670
11671 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11672 case eCSR_ENCRYPT_TYPE_WEP104:
11673 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11674 break;
11675
11676 case eCSR_ENCRYPT_TYPE_TKIP:
11677 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11678 break;
11679
11680 case eCSR_ENCRYPT_TYPE_AES:
11681 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11682 break;
11683
11684 default:
11685 params.cipher = IW_AUTH_CIPHER_NONE;
11686 break;
11687 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011688
c_hpothuaaf19692014-05-17 17:01:48 +053011689 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11690 TRACE_CODE_HDD_CFG80211_GET_KEY,
11691 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011692
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11694 params.seq_len = 0;
11695 params.seq = NULL;
11696 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11697 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011698 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 return 0;
11700}
11701
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011702#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11703static int wlan_hdd_cfg80211_get_key(
11704 struct wiphy *wiphy,
11705 struct net_device *ndev,
11706 u8 key_index, bool pairwise,
11707 const u8 *mac_addr, void *cookie,
11708 void (*callback)(void *cookie, struct key_params*)
11709 )
11710#else
11711static int wlan_hdd_cfg80211_get_key(
11712 struct wiphy *wiphy,
11713 struct net_device *ndev,
11714 u8 key_index, const u8 *mac_addr, void *cookie,
11715 void (*callback)(void *cookie, struct key_params*)
11716 )
11717#endif
11718{
11719 int ret;
11720
11721 vos_ssr_protect(__func__);
11722#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11723 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11724 mac_addr, cookie, callback);
11725#else
11726 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11727 callback);
11728#endif
11729 vos_ssr_unprotect(__func__);
11730
11731 return ret;
11732}
11733
Jeff Johnson295189b2012-06-20 16:38:30 -070011734/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011735 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 * This function is used to delete the key information
11737 */
11738#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011739static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011741 u8 key_index,
11742 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 const u8 *mac_addr
11744 )
11745#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011746static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 struct net_device *ndev,
11748 u8 key_index,
11749 const u8 *mac_addr
11750 )
11751#endif
11752{
11753 int status = 0;
11754
11755 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011756 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 //it is observed that this is invalidating peer
11758 //key index whenever re-key is done. This is affecting data link.
11759 //It should be ok to ignore del_key.
11760#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011761 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11762 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011763 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11764 tCsrRoamSetKey setKey;
11765 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011766
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 ENTER();
11768
11769 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11770 __func__,pAdapter->device_mode);
11771
11772 if (CSR_MAX_NUM_KEY <= key_index)
11773 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011774 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 key_index);
11776
11777 return -EINVAL;
11778 }
11779
11780 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11781 setKey.keyId = key_index;
11782
11783 if (mac_addr)
11784 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11785 else
11786 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11787
11788 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11789
11790 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011792 )
11793 {
11794
11795 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11797 if( pHostapdState->bssState == BSS_START)
11798 {
11799 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011800
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 if ( status != eHAL_STATUS_SUCCESS )
11802 {
11803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11804 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11805 __LINE__, status );
11806 }
11807 }
11808 }
11809 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011810 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 )
11812 {
11813 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11814
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011815 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11816
11817 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011819 __func__, setKey.peerMac[0], setKey.peerMac[1],
11820 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011822 if(pAdapter->sessionCtx.station.conn_info.connState ==
11823 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011825 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011827
Jeff Johnson295189b2012-06-20 16:38:30 -070011828 if ( 0 != status )
11829 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011830 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 "%s: sme_RoamSetKey failure, returned %d",
11832 __func__, status);
11833 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11834 return -EINVAL;
11835 }
11836 }
11837 }
11838#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011839 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011840 return status;
11841}
11842
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011843#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11844static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11845 struct net_device *ndev,
11846 u8 key_index,
11847 bool pairwise,
11848 const u8 *mac_addr
11849 )
11850#else
11851static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11852 struct net_device *ndev,
11853 u8 key_index,
11854 const u8 *mac_addr
11855 )
11856#endif
11857{
11858 int ret;
11859
11860 vos_ssr_protect(__func__);
11861#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11862 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
11863 mac_addr);
11864#else
11865 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
11866#endif
11867 vos_ssr_unprotect(__func__);
11868
11869 return ret;
11870}
11871
Jeff Johnson295189b2012-06-20 16:38:30 -070011872/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011873 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011874 * This function is used to set the default tx key index
11875 */
11876#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011877static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 struct net_device *ndev,
11879 u8 key_index,
11880 bool unicast, bool multicast)
11881#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011882static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011883 struct net_device *ndev,
11884 u8 key_index)
11885#endif
11886{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011888 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011889 hdd_wext_state_t *pWextState;
11890 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011891 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011892
11893 ENTER();
11894
Gopichand Nakkala29149562013-05-10 21:43:41 +053011895 if ((NULL == pAdapter))
11896 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011898 "invalid adapter");
11899 return -EINVAL;
11900 }
11901
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011902 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11903 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
11904 pAdapter->sessionId, key_index));
11905
Gopichand Nakkala29149562013-05-10 21:43:41 +053011906 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11907 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11908
11909 if ((NULL == pWextState) || (NULL == pHddStaCtx))
11910 {
11911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11912 "invalid Wext state or HDD context");
11913 return -EINVAL;
11914 }
11915
Arif Hussain6d2a3322013-11-17 19:50:10 -080011916 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011918
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 if (CSR_MAX_NUM_KEY <= key_index)
11920 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011921 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011922 key_index);
11923
11924 return -EINVAL;
11925 }
11926
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011927 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11928 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011929 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011930 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011931 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011932 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011933
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011936 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011937 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011938 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080011939 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011940 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080011941 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070011942 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011943 {
11944 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070011945 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011946
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 tCsrRoamSetKey setKey;
11948 v_U32_t roamId= 0xFF;
11949 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011950
11951 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011953
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 Keys->defaultIndex = (u8)key_index;
11955 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11956 setKey.keyId = key_index;
11957 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011958
11959 vos_mem_copy(&setKey.Key[0],
11960 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011962
Gopichand Nakkala29149562013-05-10 21:43:41 +053011963 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011964
11965 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 &pHddStaCtx->conn_info.bssId[0],
11967 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011968
Gopichand Nakkala29149562013-05-10 21:43:41 +053011969 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
11970 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
11971 eCSR_ENCRYPT_TYPE_WEP104)
11972 {
11973 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
11974 even though ap is configured for WEP-40 encryption. In this canse the key length
11975 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
11976 type(104) and switching encryption type to 40*/
11977 pWextState->roamProfile.EncryptionType.encryptionType[0] =
11978 eCSR_ENCRYPT_TYPE_WEP40;
11979 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
11980 eCSR_ENCRYPT_TYPE_WEP40;
11981 }
11982
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011983 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011984 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011985
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011987 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011989
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 if ( 0 != status )
11991 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011992 hddLog(VOS_TRACE_LEVEL_ERROR,
11993 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 status);
11995 return -EINVAL;
11996 }
11997 }
11998 }
11999
12000 /* In SoftAp mode setting key direction for default mode */
12001 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
12002 {
12003 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
12004 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
12005 (eCSR_ENCRYPT_TYPE_AES !=
12006 pWextState->roamProfile.EncryptionType.encryptionType[0])
12007 )
12008 {
12009 /* Saving key direction for default key index to TX default */
12010 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
12011 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
12012 }
12013 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012014 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 return status;
12016}
12017
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053012018#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12019static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12020 struct net_device *ndev,
12021 u8 key_index,
12022 bool unicast, bool multicast)
12023#else
12024static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
12025 struct net_device *ndev,
12026 u8 key_index)
12027#endif
12028{
12029 int ret;
12030 vos_ssr_protect(__func__);
12031#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12032 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
12033 multicast);
12034#else
12035 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
12036#endif
12037 vos_ssr_unprotect(__func__);
12038
12039 return ret;
12040}
12041
Jeff Johnson295189b2012-06-20 16:38:30 -070012042/*
12043 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12044 * This function is used to inform the BSS details to nl80211 interface.
12045 */
12046static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12047 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12048{
12049 struct net_device *dev = pAdapter->dev;
12050 struct wireless_dev *wdev = dev->ieee80211_ptr;
12051 struct wiphy *wiphy = wdev->wiphy;
12052 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12053 int chan_no;
12054 int ie_length;
12055 const char *ie;
12056 unsigned int freq;
12057 struct ieee80211_channel *chan;
12058 int rssi = 0;
12059 struct cfg80211_bss *bss = NULL;
12060
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 if( NULL == pBssDesc )
12062 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012063 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 return bss;
12065 }
12066
12067 chan_no = pBssDesc->channelId;
12068 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12069 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12070
12071 if( NULL == ie )
12072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012073 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 return bss;
12075 }
12076
12077#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12078 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12079 {
12080 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12081 }
12082 else
12083 {
12084 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12085 }
12086#else
12087 freq = ieee80211_channel_to_frequency(chan_no);
12088#endif
12089
12090 chan = __ieee80211_get_channel(wiphy, freq);
12091
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012092 if (!chan) {
12093 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12094 return NULL;
12095 }
12096
Abhishek Singhaee43942014-06-16 18:55:47 +053012097 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012098
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012099 return cfg80211_inform_bss(wiphy, chan,
12100#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12101 CFG80211_BSS_FTYPE_UNKNOWN,
12102#endif
12103 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012104 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012105 pBssDesc->capabilityInfo,
12106 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012107 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012108}
12109
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012110/*
12111 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12112 * interface that BSS might have been lost.
12113 * @pAdapter: adaptor
12114 * @bssid: bssid which might have been lost
12115 *
12116 * Return: bss which is unlinked from kernel cache
12117 */
12118struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12119 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12120{
12121 struct net_device *dev = pAdapter->dev;
12122 struct wireless_dev *wdev = dev->ieee80211_ptr;
12123 struct wiphy *wiphy = wdev->wiphy;
12124 struct cfg80211_bss *bss = NULL;
12125
12126 bss = cfg80211_get_bss(wiphy, NULL, bssid,
12127 NULL,
12128 0,
12129#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS) \
12130 && !defined(IEEE80211_PRIVACY)
12131 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
12132#else
12133 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
12134#endif
12135 if (bss == NULL) {
12136 hddLog(LOGE, FL("BSS not present"));
12137 } else {
12138 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12139 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12140 cfg80211_unlink_bss(wiphy, bss);
12141 }
12142 return bss;
12143}
Jeff Johnson295189b2012-06-20 16:38:30 -070012144
12145
12146/*
12147 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12148 * This function is used to inform the BSS details to nl80211 interface.
12149 */
12150struct cfg80211_bss*
12151wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12152 tSirBssDescription *bss_desc
12153 )
12154{
12155 /*
12156 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12157 already exists in bss data base of cfg80211 for that particular BSS ID.
12158 Using cfg80211_inform_bss_frame to update the bss entry instead of
12159 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12160 now there is no possibility to get the mgmt(probe response) frame from PE,
12161 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12162 cfg80211_inform_bss_frame.
12163 */
12164 struct net_device *dev = pAdapter->dev;
12165 struct wireless_dev *wdev = dev->ieee80211_ptr;
12166 struct wiphy *wiphy = wdev->wiphy;
12167 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012168#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12169 qcom_ie_age *qie_age = NULL;
12170 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12171#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012173#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 const char *ie =
12175 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12176 unsigned int freq;
12177 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012178 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 struct cfg80211_bss *bss_status = NULL;
12180 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12181 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012182 hdd_context_t *pHddCtx;
12183 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012184#ifdef WLAN_OPEN_SOURCE
12185 struct timespec ts;
12186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012187
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012188
Wilson Yangf80a0542013-10-07 13:02:37 -070012189 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12190 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012191 if (0 != status)
12192 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012193 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012194 }
12195
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012196 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012197 if (!mgmt)
12198 {
12199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12200 "%s: memory allocation failed ", __func__);
12201 return NULL;
12202 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012203
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012205
12206#ifdef WLAN_OPEN_SOURCE
12207 /* Android does not want the timestamp from the frame.
12208 Instead it wants a monotonic increasing value */
12209 get_monotonic_boottime(&ts);
12210 mgmt->u.probe_resp.timestamp =
12211 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12212#else
12213 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12215 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012216
12217#endif
12218
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12220 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012221
12222#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12223 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12224 /* Assuming this is the last IE, copy at the end */
12225 ie_length -=sizeof(qcom_ie_age);
12226 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12227 qie_age->element_id = QCOM_VENDOR_IE_ID;
12228 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12229 qie_age->oui_1 = QCOM_OUI1;
12230 qie_age->oui_2 = QCOM_OUI2;
12231 qie_age->oui_3 = QCOM_OUI3;
12232 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Selvaraj, Sridhar4b3a8362016-10-12 12:34:08 +053012233 /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all
12234 * bss related timestamp is in units of ms. Due to this when scan results
12235 * are sent to lowi the scan age is high.To address this, send age in units
12236 * of 1/10 ms.
12237 */
12238 qie_age->age = (vos_timer_get_system_time() -
12239 bss_desc->nReceivedTime)/10;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012240#endif
12241
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012243 if (bss_desc->fProbeRsp)
12244 {
12245 mgmt->frame_control |=
12246 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12247 }
12248 else
12249 {
12250 mgmt->frame_control |=
12251 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012253
12254#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012255 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12257 {
12258 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12259 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012260 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12262
12263 {
12264 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12265 }
12266 else
12267 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012268 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12269 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012270 kfree(mgmt);
12271 return NULL;
12272 }
12273#else
12274 freq = ieee80211_channel_to_frequency(chan_no);
12275#endif
12276 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012277 /*when the band is changed on the fly using the GUI, three things are done
12278 * 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)
12279 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12280 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12281 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12282 * and discards the channels correponding to previous band and calls back with zero bss results.
12283 * 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
12284 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12285 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12286 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12287 * So drop the bss and continue to next bss.
12288 */
12289 if(chan == NULL)
12290 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053012291 hddLog(VOS_TRACE_LEVEL_ERROR,
12292 FL("chan pointer is NULL, chan_no: %d freq: %d"),
12293 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070012294 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012295 return NULL;
12296 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012297 /*To keep the rssi icon of the connected AP in the scan window
12298 *and the rssi icon of the wireless networks in sync
12299 * */
12300 if (( eConnectionState_Associated ==
12301 pAdapter->sessionCtx.station.conn_info.connState ) &&
12302 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12303 pAdapter->sessionCtx.station.conn_info.bssId,
12304 WNI_CFG_BSSID_LEN)) &&
12305 (pHddCtx->hdd_wlan_suspended == FALSE))
12306 {
12307 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12308 rssi = (pAdapter->rssi * 100);
12309 }
12310 else
12311 {
12312 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012314
Nirav Shah20ac06f2013-12-12 18:14:06 +053012315 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012316 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12317 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012318
Jeff Johnson295189b2012-06-20 16:38:30 -070012319 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12320 frame_len, rssi, GFP_KERNEL);
12321 kfree(mgmt);
12322 return bss_status;
12323}
12324
12325/*
12326 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12327 * This function is used to update the BSS data base of CFG8011
12328 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012329struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 tCsrRoamInfo *pRoamInfo
12331 )
12332{
12333 tCsrRoamConnectedProfile roamProfile;
12334 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12335 struct cfg80211_bss *bss = NULL;
12336
12337 ENTER();
12338
12339 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12340 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12341
12342 if (NULL != roamProfile.pBssDesc)
12343 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012344 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12345 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012346
12347 if (NULL == bss)
12348 {
12349 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12350 __func__);
12351 }
12352
12353 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12354 }
12355 else
12356 {
12357 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12358 __func__);
12359 }
12360 return bss;
12361}
12362
12363/*
12364 * FUNCTION: wlan_hdd_cfg80211_update_bss
12365 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012366static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12367 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012369{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012370 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012371 tCsrScanResultInfo *pScanResult;
12372 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012373 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 tScanResultHandle pResult;
12375 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012376 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012377 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012379
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012380 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12381 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12382 NO_SESSION, pAdapter->sessionId));
12383
Wilson Yangf80a0542013-10-07 13:02:37 -070012384 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012385 ret = wlan_hdd_validate_context(pHddCtx);
12386 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012388 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070012389 }
12390
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012391 if (pAdapter->request != NULL)
12392 {
12393 if ((pAdapter->request->n_ssids == 1)
12394 && (pAdapter->request->ssids != NULL)
12395 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12396 is_p2p_scan = true;
12397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 /*
12399 * start getting scan results and populate cgf80211 BSS database
12400 */
12401 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12402
12403 /* no scan results */
12404 if (NULL == pResult)
12405 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012406 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12407 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012408 wlan_hdd_get_frame_logs(pAdapter,
12409 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 return status;
12411 }
12412
12413 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12414
12415 while (pScanResult)
12416 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012417 /*
12418 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12419 * entry already exists in bss data base of cfg80211 for that
12420 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12421 * bss entry instead of cfg80211_inform_bss, But this call expects
12422 * mgmt packet as input. As of now there is no possibility to get
12423 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 * ieee80211_mgmt(probe response) and passing to c
12425 * fg80211_inform_bss_frame.
12426 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012427 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12428 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12429 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012430 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12431 continue; //Skip the non p2p bss entries
12432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12434 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012435
Jeff Johnson295189b2012-06-20 16:38:30 -070012436
12437 if (NULL == bss_status)
12438 {
12439 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012440 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 }
12442 else
12443 {
Yue Maf49ba872013-08-19 12:04:25 -070012444 cfg80211_put_bss(
12445#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12446 wiphy,
12447#endif
12448 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 }
12450
12451 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12452 }
12453
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012454 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012455 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012456 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012457}
12458
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012459void
12460hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12461{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012462 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012463 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012464} /****** end hddPrintMacAddr() ******/
12465
12466void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012467hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012468{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012469 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012470 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012471 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12472 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12473 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012474} /****** end hddPrintPmkId() ******/
12475
12476//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12477//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12478
12479//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12480//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12481
12482#define dump_bssid(bssid) \
12483 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012484 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12485 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012486 }
12487
12488#define dump_pmkid(pMac, pmkid) \
12489 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012490 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12491 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012492 }
12493
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012494#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012495/*
12496 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12497 * This function is used to notify the supplicant of a new PMKSA candidate.
12498 */
12499int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012500 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012501 int index, bool preauth )
12502{
Jeff Johnsone7245742012-09-05 17:12:55 -070012503#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012504 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012505 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012506
12507 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012508 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012509
12510 if( NULL == pRoamInfo )
12511 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012512 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012513 return -EINVAL;
12514 }
12515
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012516 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12517 {
12518 dump_bssid(pRoamInfo->bssid);
12519 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012520 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012521 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012522#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012523 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012524}
12525#endif //FEATURE_WLAN_LFR
12526
Yue Maef608272013-04-08 23:09:17 -070012527#ifdef FEATURE_WLAN_LFR_METRICS
12528/*
12529 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12530 * 802.11r/LFR metrics reporting function to report preauth initiation
12531 *
12532 */
12533#define MAX_LFR_METRICS_EVENT_LENGTH 100
12534VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12535 tCsrRoamInfo *pRoamInfo)
12536{
12537 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12538 union iwreq_data wrqu;
12539
12540 ENTER();
12541
12542 if (NULL == pAdapter)
12543 {
12544 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12545 return VOS_STATUS_E_FAILURE;
12546 }
12547
12548 /* create the event */
12549 memset(&wrqu, 0, sizeof(wrqu));
12550 memset(metrics_notification, 0, sizeof(metrics_notification));
12551
12552 wrqu.data.pointer = metrics_notification;
12553 wrqu.data.length = scnprintf(metrics_notification,
12554 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12555 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12556
12557 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12558
12559 EXIT();
12560
12561 return VOS_STATUS_SUCCESS;
12562}
12563
12564/*
12565 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12566 * 802.11r/LFR metrics reporting function to report preauth completion
12567 * or failure
12568 */
12569VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12570 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12571{
12572 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12573 union iwreq_data wrqu;
12574
12575 ENTER();
12576
12577 if (NULL == pAdapter)
12578 {
12579 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12580 return VOS_STATUS_E_FAILURE;
12581 }
12582
12583 /* create the event */
12584 memset(&wrqu, 0, sizeof(wrqu));
12585 memset(metrics_notification, 0, sizeof(metrics_notification));
12586
12587 scnprintf(metrics_notification, sizeof(metrics_notification),
12588 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12589 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12590
12591 if (1 == preauth_status)
12592 strncat(metrics_notification, " TRUE", 5);
12593 else
12594 strncat(metrics_notification, " FALSE", 6);
12595
12596 wrqu.data.pointer = metrics_notification;
12597 wrqu.data.length = strlen(metrics_notification);
12598
12599 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12600
12601 EXIT();
12602
12603 return VOS_STATUS_SUCCESS;
12604}
12605
12606/*
12607 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12608 * 802.11r/LFR metrics reporting function to report handover initiation
12609 *
12610 */
12611VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12612 tCsrRoamInfo *pRoamInfo)
12613{
12614 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12615 union iwreq_data wrqu;
12616
12617 ENTER();
12618
12619 if (NULL == pAdapter)
12620 {
12621 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12622 return VOS_STATUS_E_FAILURE;
12623 }
12624
12625 /* create the event */
12626 memset(&wrqu, 0, sizeof(wrqu));
12627 memset(metrics_notification, 0, sizeof(metrics_notification));
12628
12629 wrqu.data.pointer = metrics_notification;
12630 wrqu.data.length = scnprintf(metrics_notification,
12631 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12632 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12633
12634 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12635
12636 EXIT();
12637
12638 return VOS_STATUS_SUCCESS;
12639}
12640#endif
12641
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012642
12643/**
12644 * wlan_hdd_cfg80211_validate_scan_req - validate scan request
12645 * @scan_req: scan request to be checked
12646 *
12647 * Return: true or false
12648 */
12649#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
12650static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12651 cfg80211_scan_request
12652 *scan_req)
12653{
12654 if (!scan_req || !scan_req->wiphy) {
12655 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12656 return false;
12657 }
12658 if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) {
12659 hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress");
12660 return false;
12661 }
12662 return true;
12663}
12664#else
12665static inline bool wlan_hdd_cfg80211_validate_scan_req(struct
12666 cfg80211_scan_request
12667 *scan_req)
12668{
12669 if (!scan_req || !scan_req->wiphy) {
12670 hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request");
12671 return false;
12672 }
12673 return true;
12674}
12675#endif
12676
12677
Jeff Johnson295189b2012-06-20 16:38:30 -070012678/*
12679 * FUNCTION: hdd_cfg80211_scan_done_callback
12680 * scanning callback function, called after finishing scan
12681 *
12682 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012683static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12685{
12686 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012687 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012689 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 struct cfg80211_scan_request *req = NULL;
12691 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012692 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012693#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12694 bool iface_down = false;
12695#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012696 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012697 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012698 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012699
12700 ENTER();
12701
c_manjee1b4ab9a2016-10-26 11:36:55 +053012702 if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC ||
12703 !pAdapter->dev) {
12704 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid"));
12705 return 0;
12706 }
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012707 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012708 if (NULL == pHddCtx) {
12709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012710 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012711 }
12712
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012713#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12714 if (!(pAdapter->dev->flags & IFF_UP))
12715 {
12716 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012717 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012718 }
12719#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012720 pScanInfo = &pHddCtx->scan_info;
12721
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 hddLog(VOS_TRACE_LEVEL_INFO,
12723 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012724 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 __func__, halHandle, pContext, (int) scanId, (int) status);
12726
Kiet Lamac06e2c2013-10-23 16:25:07 +053012727 pScanInfo->mScanPendingCounter = 0;
12728
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012730 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 &pScanInfo->scan_req_completion_event,
12732 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012733 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012735 hddLog(VOS_TRACE_LEVEL_ERROR,
12736 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012738 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 }
12740
Yue Maef608272013-04-08 23:09:17 -070012741 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 {
12743 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012744 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 }
12746
12747 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012748 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012749 {
12750 hddLog(VOS_TRACE_LEVEL_INFO,
12751 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012752 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 (int) scanId);
12754 }
12755
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012757 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012758#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012759 {
12760 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
12761 pAdapter);
12762 if (0 > ret)
12763 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012765
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 /* If any client wait scan result through WEXT
12767 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012768 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 {
12770 /* The other scan request waiting for current scan finish
12771 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012772 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012774 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 }
12776 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012777 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012778 {
12779 struct net_device *dev = pAdapter->dev;
12780 union iwreq_data wrqu;
12781 int we_event;
12782 char *msg;
12783
12784 memset(&wrqu, '\0', sizeof(wrqu));
12785 we_event = SIOCGIWSCAN;
12786 msg = NULL;
12787 wireless_send_event(dev, we_event, &wrqu, msg);
12788 }
12789 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012790 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012791
12792 /* Get the Scan Req */
12793 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053012794 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012795
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012796 /* Scan is no longer pending */
12797 pScanInfo->mScanPending = VOS_FALSE;
12798
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012799 if (!wlan_hdd_cfg80211_validate_scan_req(req))
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 {
Manjeet Singhaaee9cd2016-09-13 19:23:30 +053012801#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"),
12803 iface_down ? "up" : "down");
12804#endif
12805
12806 if (pAdapter->dev) {
12807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"),
12808 pAdapter->dev->name);
12809 }
mukul sharmae7041822015-12-03 15:09:21 +053012810 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070012811 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 }
12813
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012814 /* last_scan_timestamp is used to decide if new scan
12815 * is needed or not on station interface. If last station
12816 * scan time and new station scan time is less then
12817 * last_scan_timestamp ; driver will return cached scan.
12818 */
12819 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
12820 {
12821 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
12822
12823 if ( req->n_channels )
12824 {
12825 for (i = 0; i < req->n_channels ; i++ )
12826 {
12827 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
12828 }
12829 /* store no of channel scanned */
12830 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
12831 }
12832
12833 }
12834
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070012835 /*
12836 * cfg80211_scan_done informing NL80211 about completion
12837 * of scanning
12838 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012839 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
12840 {
12841 aborted = true;
12842 }
mukul sharmae7041822015-12-03 15:09:21 +053012843
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012844#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12845 if (!iface_down)
12846#endif
12847 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053012848
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080012849 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070012850
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012851allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053012852 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
12853 ) && (pHddCtx->spoofMacAddr.isEnabled
12854 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053012855 /* Generate new random mac addr for next scan */
12856 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053012857
12858 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
12859 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053012860 }
12861
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012862 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012863 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012864
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012865 /* Acquire wakelock to handle the case where APP's tries to suspend
12866 * immediatly after the driver gets connect request(i.e after scan)
12867 * from supplicant, this result in app's is suspending and not able
12868 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012869 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012870
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012871#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12872 if (!iface_down)
12873#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012874#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012875 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012876#endif
12877
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 EXIT();
12879 return 0;
12880}
12881
12882/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053012883 * FUNCTION: hdd_isConnectionInProgress
12884 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012885 *
12886 */
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012887v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id,
12888 scan_reject_states *reason)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012889{
12890 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12891 hdd_station_ctx_t *pHddStaCtx = NULL;
12892 hdd_adapter_t *pAdapter = NULL;
12893 VOS_STATUS status = 0;
12894 v_U8_t staId = 0;
12895 v_U8_t *staMac = NULL;
12896
12897 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
12898
12899 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
12900 {
12901 pAdapter = pAdapterNode->pAdapter;
12902
12903 if( pAdapter )
12904 {
12905 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012906 "%s: Adapter with device mode %s (%d) exists",
12907 __func__, hdd_device_modetoString(pAdapter->device_mode),
12908 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012909 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053012910 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12911 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
12912 (eConnectionState_Connecting ==
12913 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12914 {
12915 hddLog(VOS_TRACE_LEVEL_ERROR,
12916 "%s: %p(%d) Connection is in progress", __func__,
12917 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012918 if (session_id && reason)
12919 {
12920 *session_id = pAdapter->sessionId;
12921 *reason = eHDD_CONNECTION_IN_PROGRESS;
12922 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012923 return VOS_TRUE;
12924 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012925 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053012926 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012927 {
12928 hddLog(VOS_TRACE_LEVEL_ERROR,
12929 "%s: %p(%d) Reassociation 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_REASSOC_IN_PROGRESS;
12935 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012936 return VOS_TRUE;
12937 }
12938 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012939 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12940 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012941 {
12942 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12943 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012944 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012945 {
12946 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
12947 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012948 "%s: client " MAC_ADDRESS_STR
12949 " is in the middle of WPS/EAPOL exchange.", __func__,
12950 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012951 if (session_id && reason)
12952 {
12953 *session_id = pAdapter->sessionId;
12954 *reason = eHDD_EAPOL_IN_PROGRESS;
12955 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012956 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012957 }
12958 }
12959 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
12960 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
12961 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012962 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12963 ptSapContext pSapCtx = NULL;
12964 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12965 if(pSapCtx == NULL){
12966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12967 FL("psapCtx is NULL"));
12968 return VOS_FALSE;
12969 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012970 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
12971 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012972 if ((pSapCtx->aStaInfo[staId].isUsed) &&
12973 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012974 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012975 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012976
12977 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012978 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
12979 "middle of WPS/EAPOL exchange.", __func__,
12980 MAC_ADDR_ARRAY(staMac));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053012981 if (session_id && reason)
12982 {
12983 *session_id = pAdapter->sessionId;
12984 *reason = eHDD_SAP_EAPOL_IN_PROGRESS;
12985 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012986 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012987 }
12988 }
12989 }
12990 }
12991 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12992 pAdapterNode = pNext;
12993 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012994 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012995}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012996
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053012997/**
12998 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
12999 * to the Scan request
13000 * @scanRequest: Pointer to the csr scan request
13001 * @request: Pointer to the scan request from supplicant
13002 *
13003 * Return: None
13004 */
13005#ifdef CFG80211_SCAN_BSSID
13006static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13007 struct cfg80211_scan_request *request)
13008{
13009 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
13010}
13011#else
13012static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
13013 struct cfg80211_scan_request *request)
13014{
13015}
13016#endif
13017
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013018/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013019 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 * this scan respond to scan trigger and update cfg80211 scan database
13021 * later, scan dump command can be used to recieve scan results
13022 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013023int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013024#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13025 struct net_device *dev,
13026#endif
13027 struct cfg80211_scan_request *request)
13028{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013029 hdd_adapter_t *pAdapter = NULL;
13030 hdd_context_t *pHddCtx = NULL;
13031 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013032 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 tCsrScanRequest scanRequest;
13034 tANI_U8 *channelList = NULL, i;
13035 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013036 int status;
13037 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013039 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053013040 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013041 bool is_p2p_scan = false;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013042 v_U8_t curr_session_id;
13043 scan_reject_states curr_reason;
Jeff Johnson295189b2012-06-20 16:38:30 -070013044
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013045#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
13046 struct net_device *dev = NULL;
13047 if (NULL == request)
13048 {
13049 hddLog(VOS_TRACE_LEVEL_ERROR,
13050 "%s: scan req param null", __func__);
13051 return -EINVAL;
13052 }
13053 dev = request->wdev->netdev;
13054#endif
13055
13056 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13057 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
13058 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13059
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 ENTER();
13061
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013062 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
13063 __func__, hdd_device_modetoString(pAdapter->device_mode),
13064 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013065
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013066 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013067 if (0 != status)
13068 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013069 return status;
13070 }
13071
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013072 if (NULL == pwextBuf)
13073 {
13074 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
13075 __func__);
13076 return -EIO;
13077 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013078 cfg_param = pHddCtx->cfg_ini;
13079 pScanInfo = &pHddCtx->scan_info;
13080
Jeff Johnson295189b2012-06-20 16:38:30 -070013081#ifdef WLAN_BTAMP_FEATURE
13082 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013083 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013085 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 "%s: No scanning when AMP is on", __func__);
13087 return -EOPNOTSUPP;
13088 }
13089#endif
13090 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013091 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013093 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013094 "%s: Not scanning on device_mode = %s (%d)",
13095 __func__, hdd_device_modetoString(pAdapter->device_mode),
13096 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 return -EOPNOTSUPP;
13098 }
13099
13100 if (TRUE == pScanInfo->mScanPending)
13101 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013102 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13103 {
13104 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13105 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013106 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 }
13108
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013109 // Don't allow scan if PNO scan is going on.
13110 if (pHddCtx->isPnoEnable)
13111 {
13112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13113 FL("pno scan in progress"));
13114 return -EBUSY;
13115 }
13116
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013117 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013118 //Channel and action frame is pending
13119 //Otherwise Cancel Remain On Channel and allow Scan
13120 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013121 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013122 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013123 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013124 return -EBUSY;
13125 }
13126
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13128 {
13129 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013130 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13134 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013135 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 "%s: MAX TM Level Scan not allowed", __func__);
13137 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013138 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 }
13140 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13141
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013142 /* Check if scan is allowed at this point of time.
13143 */
Hanumanth Reddy Pothulaec960842016-09-14 19:04:26 +053013144 if (TRUE == pHddCtx->btCoexModeSet)
13145 {
13146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13147 FL("BTCoex Mode operation in progress"));
13148 return -EBUSY;
13149 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013150 if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013151 {
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013152 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed"));
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013153 if (pHddCtx->last_scan_reject_session_id != curr_session_id ||
13154 pHddCtx->last_scan_reject_reason != curr_reason ||
13155 !pHddCtx->last_scan_reject_timestamp)
13156 {
13157 pHddCtx->last_scan_reject_session_id = curr_session_id;
13158 pHddCtx->last_scan_reject_reason = curr_reason;
13159 pHddCtx->last_scan_reject_timestamp = vos_timer_get_system_time();
Agrawal Ashishc932a8d2016-08-17 19:21:02 +053013160 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013161 else {
13162 if ((vos_timer_get_system_time() -
13163 pHddCtx->last_scan_reject_timestamp) >=
13164 SCAN_REJECT_THRESHOLD_TIME)
13165 {
13166 pHddCtx->last_scan_reject_timestamp = 0;
13167 if (pHddCtx->cfg_ini->enableFatalEvent)
13168 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
13169 WLAN_LOG_INDICATOR_HOST_DRIVER,
13170 WLAN_LOG_REASON_SCAN_NOT_ALLOWED,
13171 FALSE, FALSE);
13172 else
13173 {
13174 hddLog(LOGE, FL("Triggering SSR"));
13175 vos_wlanRestart();
13176 }
13177 }
13178 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013179 return -EBUSY;
13180 }
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +053013181 pHddCtx->last_scan_reject_timestamp = 0;
13182 pHddCtx->last_scan_reject_session_id = 0xFF;
13183 pHddCtx->last_scan_reject_reason = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013184
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 vos_mem_zero( &scanRequest, sizeof(scanRequest));
13186
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013187 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
13188 * Becasue of this, driver is assuming that this is not wildcard scan and so
13189 * is not aging out the scan results.
13190 */
13191 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013193 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013195
13196 if ((request->ssids) && (0 < request->n_ssids))
13197 {
13198 tCsrSSIDInfo *SsidInfo;
13199 int j;
13200 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
13201 /* Allocate num_ssid tCsrSSIDInfo structure */
13202 SsidInfo = scanRequest.SSIDs.SSIDList =
13203 ( tCsrSSIDInfo *)vos_mem_malloc(
13204 request->n_ssids*sizeof(tCsrSSIDInfo));
13205
13206 if(NULL == scanRequest.SSIDs.SSIDList)
13207 {
13208 hddLog(VOS_TRACE_LEVEL_ERROR,
13209 "%s: memory alloc failed SSIDInfo buffer", __func__);
13210 return -ENOMEM;
13211 }
13212
13213 /* copy all the ssid's and their length */
13214 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
13215 {
13216 /* get the ssid length */
13217 SsidInfo->SSID.length = request->ssids[j].ssid_len;
13218 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
13219 SsidInfo->SSID.length);
13220 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
13221 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
13222 j, SsidInfo->SSID.ssId);
13223 }
13224 /* set the scan type to active */
13225 scanRequest.scanType = eSIR_ACTIVE_SCAN;
13226 }
13227 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013229 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13230 TRACE_CODE_HDD_CFG80211_SCAN,
13231 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 /* set the scan type to active */
13233 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013235 else
13236 {
13237 /*Set the scan type to default type, in this case it is ACTIVE*/
13238 scanRequest.scanType = pScanInfo->scan_mode;
13239 }
13240 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13241 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013242
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013243 csr_scan_request_assign_bssid(&scanRequest, request);
13244
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 /* set BSSType to default type */
13246 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13247
13248 /*TODO: scan the requested channels only*/
13249
13250 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013251 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013253 hddLog(VOS_TRACE_LEVEL_WARN,
13254 "No of Scan Channels exceeded limit: %d", request->n_channels);
13255 request->n_channels = MAX_CHANNEL;
13256 }
13257
13258 hddLog(VOS_TRACE_LEVEL_INFO,
13259 "No of Scan Channels: %d", request->n_channels);
13260
13261
13262 if( request->n_channels )
13263 {
13264 char chList [(request->n_channels*5)+1];
13265 int len;
13266 channelList = vos_mem_malloc( request->n_channels );
13267 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013268 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013269 hddLog(VOS_TRACE_LEVEL_ERROR,
13270 "%s: memory alloc failed channelList", __func__);
13271 status = -ENOMEM;
13272 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013273 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013274
13275 for( i = 0, len = 0; i < request->n_channels ; i++ )
13276 {
13277 channelList[i] = request->channels[i]->hw_value;
13278 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13279 }
13280
Nirav Shah20ac06f2013-12-12 18:14:06 +053013281 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013282 "Channel-List: %s ", chList);
13283 }
c_hpothu53512302014-04-15 18:49:53 +053013284
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013285 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13286 scanRequest.ChannelInfo.ChannelList = channelList;
13287
13288 /* set requestType to full scan */
13289 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13290
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013291 /* if there is back to back scan happening in driver with in
13292 * nDeferScanTimeInterval interval driver should defer new scan request
13293 * and should provide last cached scan results instead of new channel list.
13294 * This rule is not applicable if scan is p2p scan.
13295 * This condition will work only in case when last request no of channels
13296 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013297 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013298 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013299 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013300
Sushant Kaushik86592172015-04-27 16:35:03 +053013301 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13302 /* if wps ie is NULL , then only defer scan */
13303 if ( pWpsIe == NULL &&
13304 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013305 {
13306 if ( pScanInfo->last_scan_timestamp !=0 &&
13307 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13308 {
13309 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13310 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13311 vos_mem_compare(pScanInfo->last_scan_channelList,
13312 channelList, pScanInfo->last_scan_numChannels))
13313 {
13314 hddLog(VOS_TRACE_LEVEL_WARN,
13315 " New and old station scan time differ is less then %u",
13316 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13317
13318 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013319 pAdapter);
13320
Agarwal Ashish57e84372014-12-05 18:26:53 +053013321 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013322 "Return old cached scan as all channels and no of channels are same");
13323
Agarwal Ashish57e84372014-12-05 18:26:53 +053013324 if (0 > ret)
13325 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013326
Agarwal Ashish57e84372014-12-05 18:26:53 +053013327 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013328
13329 status = eHAL_STATUS_SUCCESS;
13330 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013331 }
13332 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013333 }
13334
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013335 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13336 * search (Flush on both full scan and social scan but not on single
13337 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13338 */
13339
13340 /* Supplicant does single channel scan after 8-way handshake
13341 * and in that case driver shoudnt flush scan results. If
13342 * driver flushes the scan results here and unfortunately if
13343 * the AP doesnt respond to our probe req then association
13344 * fails which is not desired
13345 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013346 if ((request->n_ssids == 1)
13347 && (request->ssids != NULL)
13348 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13349 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013350
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013351 if( is_p2p_scan ||
13352 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013353 {
13354 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13355 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13356 pAdapter->sessionId );
13357 }
13358
13359 if( request->ie_len )
13360 {
13361 /* save this for future association (join requires this) */
13362 /*TODO: Array needs to be converted to dynamic allocation,
13363 * as multiple ie.s can be sent in cfg80211_scan_request structure
13364 * CR 597966
13365 */
13366 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13367 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13368 pScanInfo->scanAddIE.length = request->ie_len;
13369
13370 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13371 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13372 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013374 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013376 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13377 memcpy( pwextBuf->roamProfile.addIEScan,
13378 request->ie, request->ie_len);
13379 }
13380 else
13381 {
13382 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13383 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 }
13385
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013386 }
13387 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13388 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13389
13390 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13391 request->ie_len);
13392 if (pP2pIe != NULL)
13393 {
13394#ifdef WLAN_FEATURE_P2P_DEBUG
13395 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13396 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13397 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013398 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013399 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13400 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13401 "Go nego completed to Connection is started");
13402 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13403 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013404 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013405 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13406 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013408 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13409 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13410 "Disconnected state to Connection is started");
13411 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13412 "for 4way Handshake");
13413 }
13414#endif
13415
13416 /* no_cck will be set during p2p find to disable 11b rates */
13417 if(TRUE == request->no_cck)
13418 {
13419 hddLog(VOS_TRACE_LEVEL_INFO,
13420 "%s: This is a P2P Search", __func__);
13421 scanRequest.p2pSearch = 1;
13422
13423 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013424 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013425 /* set requestType to P2P Discovery */
13426 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13427 }
13428
13429 /*
13430 Skip Dfs Channel in case of P2P Search
13431 if it is set in ini file
13432 */
13433 if(cfg_param->skipDfsChnlInP2pSearch)
13434 {
13435 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013436 }
13437 else
13438 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013439 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013441
Agarwal Ashish4f616132013-12-30 23:32:50 +053013442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 }
13444 }
13445
13446 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13447
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013448#ifdef FEATURE_WLAN_TDLS
13449 /* if tdls disagree scan right now, return immediately.
13450 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13451 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13452 */
13453 status = wlan_hdd_tdls_scan_callback (pAdapter,
13454 wiphy,
13455#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13456 dev,
13457#endif
13458 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013459 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013460 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053013461 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013462 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13463 "scan rejected %d", __func__, status);
13464 else
13465 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13466 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013467 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053013468 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013469 }
13470#endif
13471
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013472 /* acquire the wakelock to avoid the apps suspend during the scan. To
13473 * address the following issues.
13474 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13475 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13476 * for long time, this result in apps running at full power for long time.
13477 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13478 * be stuck in full power because of resume BMPS
13479 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013480 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013481
Nirav Shah20ac06f2013-12-12 18:14:06 +053013482 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13483 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013484 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13485 scanRequest.requestType, scanRequest.scanType,
13486 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013487 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13488
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013489 if (pHddCtx->spoofMacAddr.isEnabled &&
13490 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013491 {
13492 hddLog(VOS_TRACE_LEVEL_INFO,
13493 "%s: MAC Spoofing enabled for current scan", __func__);
13494 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13495 * to fill TxBds for probe request during current scan
13496 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013497 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013498 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013499
13500 if(status != VOS_STATUS_SUCCESS)
13501 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013502 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013503 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013504#ifdef FEATURE_WLAN_TDLS
13505 wlan_hdd_tdls_scan_done_callback(pAdapter);
13506#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013507 goto free_mem;
13508 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013509 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013510 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013511 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 pAdapter->sessionId, &scanRequest, &scanId,
13513 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013514
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 if (eHAL_STATUS_SUCCESS != status)
13516 {
13517 hddLog(VOS_TRACE_LEVEL_ERROR,
13518 "%s: sme_ScanRequest returned error %d", __func__, status);
13519 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013520 if(eHAL_STATUS_RESOURCES == status)
13521 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013522 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13523 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013524 status = -EBUSY;
13525 } else {
13526 status = -EIO;
13527 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013528 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013529
13530#ifdef FEATURE_WLAN_TDLS
13531 wlan_hdd_tdls_scan_done_callback(pAdapter);
13532#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 goto free_mem;
13534 }
13535
13536 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013537 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 pAdapter->request = request;
13539 pScanInfo->scanId = scanId;
13540
13541 complete(&pScanInfo->scan_req_completion_event);
13542
13543free_mem:
13544 if( scanRequest.SSIDs.SSIDList )
13545 {
13546 vos_mem_free(scanRequest.SSIDs.SSIDList);
13547 }
13548
13549 if( channelList )
13550 vos_mem_free( channelList );
13551
13552 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 return status;
13554}
13555
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013556int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13557#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13558 struct net_device *dev,
13559#endif
13560 struct cfg80211_scan_request *request)
13561{
13562 int ret;
13563
13564 vos_ssr_protect(__func__);
13565 ret = __wlan_hdd_cfg80211_scan(wiphy,
13566#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13567 dev,
13568#endif
13569 request);
13570 vos_ssr_unprotect(__func__);
13571
13572 return ret;
13573}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013574
13575void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13576{
13577 v_U8_t iniDot11Mode =
13578 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13579 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13580
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013581 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13582 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013583 switch ( iniDot11Mode )
13584 {
13585 case eHDD_DOT11_MODE_AUTO:
13586 case eHDD_DOT11_MODE_11ac:
13587 case eHDD_DOT11_MODE_11ac_ONLY:
13588#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013589 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13590 sme_IsFeatureSupportedByFW(DOT11AC) )
13591 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13592 else
13593 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013594#else
13595 hddDot11Mode = eHDD_DOT11_MODE_11n;
13596#endif
13597 break;
13598 case eHDD_DOT11_MODE_11n:
13599 case eHDD_DOT11_MODE_11n_ONLY:
13600 hddDot11Mode = eHDD_DOT11_MODE_11n;
13601 break;
13602 default:
13603 hddDot11Mode = iniDot11Mode;
13604 break;
13605 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013606#ifdef WLAN_FEATURE_AP_HT40_24G
13607 if (operationChannel > SIR_11B_CHANNEL_END)
13608#endif
13609 {
13610 /* This call decides required channel bonding mode */
13611 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013612 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13613 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013614 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013615}
13616
Jeff Johnson295189b2012-06-20 16:38:30 -070013617/*
13618 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013619 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013621int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013622 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13623 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013624{
13625 int status = 0;
13626 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013627 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 v_U32_t roamId;
13629 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013631 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013632
13633 ENTER();
13634
13635 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13637
13638 status = wlan_hdd_validate_context(pHddCtx);
13639 if (status)
13640 {
Yue Mae36e3552014-03-05 17:06:20 -080013641 return status;
13642 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013643
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13645 {
13646 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13647 return -EINVAL;
13648 }
13649
13650 pRoamProfile = &pWextState->roamProfile;
13651
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013652 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013654 hdd_station_ctx_t *pHddStaCtx;
13655 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013656
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013657 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13658
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013659 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13661 {
13662 /*QoS not enabled in cfg file*/
13663 pRoamProfile->uapsd_mask = 0;
13664 }
13665 else
13666 {
13667 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013668 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13670 }
13671
13672 pRoamProfile->SSIDs.numOfSSIDs = 1;
13673 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13674 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013675 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13677 ssid, ssid_len);
13678
13679 if (bssid)
13680 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013681 pValidBssid = bssid;
13682 }
13683 else if (bssid_hint)
13684 {
13685 pValidBssid = bssid_hint;
13686 }
13687 if (pValidBssid)
13688 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013690 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013692 /* Save BSSID in seperate variable as well, as RoamProfile
13693 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 case of join failure we should send valid BSSID to supplicant
13695 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013696 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 WNI_CFG_BSSID_LEN);
13698 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070013699 else
13700 {
13701 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
13702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013703
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013704 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13705 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13707 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013708 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 /*set gen ie*/
13710 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13711 /*set auth*/
13712 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13713 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013714#ifdef FEATURE_WLAN_WAPI
13715 if (pAdapter->wapi_info.nWapiMode)
13716 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013717 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 switch (pAdapter->wapi_info.wapiAuthMode)
13719 {
13720 case WAPI_AUTH_MODE_PSK:
13721 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013722 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 pAdapter->wapi_info.wapiAuthMode);
13724 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13725 break;
13726 }
13727 case WAPI_AUTH_MODE_CERT:
13728 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013729 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 pAdapter->wapi_info.wapiAuthMode);
13731 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13732 break;
13733 }
13734 } // End of switch
13735 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13736 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13737 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013738 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 pRoamProfile->AuthType.numEntries = 1;
13740 pRoamProfile->EncryptionType.numEntries = 1;
13741 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13742 pRoamProfile->mcEncryptionType.numEntries = 1;
13743 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13744 }
13745 }
13746#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013747#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013748 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013749 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13750 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13751 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013752 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13753 sizeof (tSirGtkOffloadParams));
13754 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013755 }
13756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 pRoamProfile->csrPersona = pAdapter->device_mode;
13758
Jeff Johnson32d95a32012-09-10 13:15:23 -070013759 if( operatingChannel )
13760 {
13761 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13762 pRoamProfile->ChannelInfo.numOfChannels = 1;
13763 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013764 else
13765 {
13766 pRoamProfile->ChannelInfo.ChannelList = NULL;
13767 pRoamProfile->ChannelInfo.numOfChannels = 0;
13768 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013769 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13770 {
13771 hdd_select_cbmode(pAdapter,operatingChannel);
13772 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013773
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013774 /*
13775 * Change conn_state to connecting before sme_RoamConnect(),
13776 * because sme_RoamConnect() has a direct path to call
13777 * hdd_smeRoamCallback(), which will change the conn_state
13778 * If direct path, conn_state will be accordingly changed
13779 * to NotConnected or Associated by either
13780 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13781 * in sme_RoamCallback()
13782 * if sme_RomConnect is to be queued,
13783 * Connecting state will remain until it is completed.
13784 * If connection state is not changed,
13785 * connection state will remain in eConnectionState_NotConnected state.
13786 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13787 * if conn state is eConnectionState_NotConnected.
13788 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13789 * informed of connect result indication which is an issue.
13790 */
13791
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013792 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13793 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013794 {
13795 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013796 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013797 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
13798 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053013799 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013800 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 pAdapter->sessionId, pRoamProfile, &roamId);
13802
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013803 if ((eHAL_STATUS_SUCCESS != status) &&
13804 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13805 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013806
13807 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013808 hddLog(VOS_TRACE_LEVEL_ERROR,
13809 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
13810 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013811 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013812 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013813 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013814 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013815
13816 pRoamProfile->ChannelInfo.ChannelList = NULL;
13817 pRoamProfile->ChannelInfo.numOfChannels = 0;
13818
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 }
13820 else
13821 {
13822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
13823 return -EINVAL;
13824 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013825 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 return status;
13827}
13828
13829/*
13830 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
13831 * This function is used to set the authentication type (OPEN/SHARED).
13832 *
13833 */
13834static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
13835 enum nl80211_auth_type auth_type)
13836{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013837 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13839
13840 ENTER();
13841
13842 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013843 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013846 hddLog(VOS_TRACE_LEVEL_INFO,
13847 "%s: set authentication type to AUTOSWITCH", __func__);
13848 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
13849 break;
13850
13851 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013852#ifdef WLAN_FEATURE_VOWIFI_11R
13853 case NL80211_AUTHTYPE_FT:
13854#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013855 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 "%s: set authentication type to OPEN", __func__);
13857 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13858 break;
13859
13860 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013861 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 "%s: set authentication type to SHARED", __func__);
13863 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
13864 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013865#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013867 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 "%s: set authentication type to CCKM WPA", __func__);
13869 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
13870 break;
13871#endif
13872
13873
13874 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013875 hddLog(VOS_TRACE_LEVEL_ERROR,
13876 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 auth_type);
13878 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
13879 return -EINVAL;
13880 }
13881
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013882 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 pHddStaCtx->conn_info.authType;
13884 return 0;
13885}
13886
13887/*
13888 * FUNCTION: wlan_hdd_set_akm_suite
13889 * This function is used to set the key mgmt type(PSK/8021x).
13890 *
13891 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013892static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 u32 key_mgmt
13894 )
13895{
13896 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13897 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053013898 /* Should be in ieee802_11_defs.h */
13899#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
13900#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 /*set key mgmt type*/
13902 switch(key_mgmt)
13903 {
13904 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053013905 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013906#ifdef WLAN_FEATURE_VOWIFI_11R
13907 case WLAN_AKM_SUITE_FT_PSK:
13908#endif
13909 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 __func__);
13911 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
13912 break;
13913
13914 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053013915 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013916#ifdef WLAN_FEATURE_VOWIFI_11R
13917 case WLAN_AKM_SUITE_FT_8021X:
13918#endif
13919 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 __func__);
13921 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13922 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013923#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013924#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
13925#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
13926 case WLAN_AKM_SUITE_CCKM:
13927 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
13928 __func__);
13929 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
13930 break;
13931#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070013932#ifndef WLAN_AKM_SUITE_OSEN
13933#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
13934 case WLAN_AKM_SUITE_OSEN:
13935 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
13936 __func__);
13937 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13938 break;
13939#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013940
13941 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 __func__, key_mgmt);
13944 return -EINVAL;
13945
13946 }
13947 return 0;
13948}
13949
13950/*
13951 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013952 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 * (NONE/WEP40/WEP104/TKIP/CCMP).
13954 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013955static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
13956 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 bool ucast
13958 )
13959{
13960 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013961 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13963
13964 ENTER();
13965
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013966 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013968 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 __func__, cipher);
13970 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13971 }
13972 else
13973 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013974
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013976 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 {
13978 case IW_AUTH_CIPHER_NONE:
13979 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13980 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013981
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013983 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013985
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013987 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013989
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 case WLAN_CIPHER_SUITE_TKIP:
13991 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
13992 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013993
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 case WLAN_CIPHER_SUITE_CCMP:
13995 encryptionType = eCSR_ENCRYPT_TYPE_AES;
13996 break;
13997#ifdef FEATURE_WLAN_WAPI
13998 case WLAN_CIPHER_SUITE_SMS4:
13999 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
14000 break;
14001#endif
14002
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014003#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 case WLAN_CIPHER_SUITE_KRK:
14005 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
14006 break;
14007#endif
14008 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014009 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 __func__, cipher);
14011 return -EOPNOTSUPP;
14012 }
14013 }
14014
14015 if (ucast)
14016 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014017 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 __func__, encryptionType);
14019 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14020 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014021 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 encryptionType;
14023 }
14024 else
14025 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014026 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 __func__, encryptionType);
14028 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
14029 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
14030 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
14031 }
14032
14033 return 0;
14034}
14035
14036
14037/*
14038 * FUNCTION: wlan_hdd_cfg80211_set_ie
14039 * This function is used to parse WPA/RSN IE's.
14040 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014041int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014042#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14043 const u8 *ie,
14044#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014045 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014046#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 size_t ie_len
14048 )
14049{
14050 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014051#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14052 const u8 *genie = ie;
14053#else
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 v_U16_t remLen = ie_len;
14057#ifdef FEATURE_WLAN_WAPI
14058 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
14059 u16 *tmp;
14060 v_U16_t akmsuiteCount;
14061 int *akmlist;
14062#endif
14063 ENTER();
14064
14065 /* clear previous assocAddIE */
14066 pWextState->assocAddIE.length = 0;
14067 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014068 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014069
14070 while (remLen >= 2)
14071 {
14072 v_U16_t eLen = 0;
14073 v_U8_t elementId;
14074 elementId = *genie++;
14075 eLen = *genie++;
14076 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014077
Arif Hussain6d2a3322013-11-17 19:50:10 -080014078 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014080
14081 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014083 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014084 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 -070014085 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014086 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 "%s: Invalid WPA IE", __func__);
14088 return -EINVAL;
14089 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014090 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 {
14092 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014093 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014095
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014096 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014098 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
14099 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 VOS_ASSERT(0);
14101 return -ENOMEM;
14102 }
14103 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14104 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14105 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014106
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
14108 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14109 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14110 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014111 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
14112 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
14114 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14115 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
14116 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
14117 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
14118 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014119 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053014120 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 {
14122 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014123 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014125
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014126 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014128 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14129 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 VOS_ASSERT(0);
14131 return -ENOMEM;
14132 }
14133 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
14134 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14135 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014136
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14138 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014140#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014141 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
14142 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 /*Consider WFD IE, only for P2P Client */
14144 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
14145 {
14146 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014147 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014149
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014150 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014152 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14153 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 VOS_ASSERT(0);
14155 return -ENOMEM;
14156 }
14157 // WFD IE is saved to Additional IE ; it should be accumulated to handle
14158 // WPS IE + P2P IE + WFD IE
14159 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14160 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014161
Jeff Johnson295189b2012-06-20 16:38:30 -070014162 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14163 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14164 }
14165#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014166 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014167 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014168 HS20_OUI_TYPE_SIZE)) )
14169 {
14170 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014171 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014172 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014173
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014174 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014175 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014176 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14177 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014178 VOS_ASSERT(0);
14179 return -ENOMEM;
14180 }
14181 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14182 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014183
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014184 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14185 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14186 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014187 /* Appending OSEN Information Element in Assiciation Request */
14188 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
14189 OSEN_OUI_TYPE_SIZE)) )
14190 {
14191 v_U16_t curAddIELen = pWextState->assocAddIE.length;
14192 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
14193 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014194
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014195 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014196 {
14197 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14198 "Need bigger buffer space");
14199 VOS_ASSERT(0);
14200 return -ENOMEM;
14201 }
14202 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14203 pWextState->assocAddIE.length += eLen + 2;
14204
14205 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
14206 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14207 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14208 }
14209
Abhishek Singh4322e622015-06-10 15:42:54 +053014210 /* Update only for WPA IE */
14211 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
14212 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014213
14214 /* populating as ADDIE in beacon frames */
14215 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014216 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014217 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
14218 {
14219 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14220 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
14221 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14222 {
14223 hddLog(LOGE,
14224 "Coldn't pass "
14225 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
14226 }
14227 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
14228 else
14229 hddLog(LOGE,
14230 "Could not pass on "
14231 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
14232
14233 /* IBSS mode doesn't contain params->proberesp_ies still
14234 beaconIE's need to be populated in probe response frames */
14235 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
14236 {
14237 u16 rem_probe_resp_ie_len = eLen + 2;
14238 u8 probe_rsp_ie_len[3] = {0};
14239 u8 counter = 0;
14240
14241 /* Check Probe Resp Length if it is greater then 255 then
14242 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14243 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14244 not able Store More then 255 bytes into One Variable */
14245
14246 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14247 {
14248 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14249 {
14250 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14251 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14252 }
14253 else
14254 {
14255 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14256 rem_probe_resp_ie_len = 0;
14257 }
14258 }
14259
14260 rem_probe_resp_ie_len = 0;
14261
14262 if (probe_rsp_ie_len[0] > 0)
14263 {
14264 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14265 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14266 (tANI_U8*)(genie - 2),
14267 probe_rsp_ie_len[0], NULL,
14268 eANI_BOOLEAN_FALSE)
14269 == eHAL_STATUS_FAILURE)
14270 {
14271 hddLog(LOGE,
14272 "Could not pass"
14273 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14274 }
14275 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14276 }
14277
14278 if (probe_rsp_ie_len[1] > 0)
14279 {
14280 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14281 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14282 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14283 probe_rsp_ie_len[1], NULL,
14284 eANI_BOOLEAN_FALSE)
14285 == eHAL_STATUS_FAILURE)
14286 {
14287 hddLog(LOGE,
14288 "Could not pass"
14289 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14290 }
14291 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14292 }
14293
14294 if (probe_rsp_ie_len[2] > 0)
14295 {
14296 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14297 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14298 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14299 probe_rsp_ie_len[2], NULL,
14300 eANI_BOOLEAN_FALSE)
14301 == eHAL_STATUS_FAILURE)
14302 {
14303 hddLog(LOGE,
14304 "Could not pass"
14305 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14306 }
14307 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14308 }
14309
14310 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14311 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14312 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14313 {
14314 hddLog(LOGE,
14315 "Could not pass"
14316 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14317 }
14318 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014319 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 break;
14321 case DOT11F_EID_RSN:
14322 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14323 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14324 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14325 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14326 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14327 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014328
Abhishek Singhb16f3562016-01-20 11:08:32 +053014329 /* Appending extended capabilities with Interworking or
14330 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053014331 *
14332 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053014333 * interworkingService or bsstransition bit is set to 1.
14334 * Driver is only interested in interworkingService and
14335 * bsstransition capability from supplicant.
14336 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053014337 * required from supplicat, it needs to be handled while
14338 * sending Assoc Req in LIM.
14339 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014340 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014341 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014342 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014343 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014344 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014345
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014346 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014347 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014348 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14349 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014350 VOS_ASSERT(0);
14351 return -ENOMEM;
14352 }
14353 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14354 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014355
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014356 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14357 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14358 break;
14359 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014360#ifdef FEATURE_WLAN_WAPI
14361 case WLAN_EID_WAPI:
14362 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014363 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 pAdapter->wapi_info.nWapiMode);
14365 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014366 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 akmsuiteCount = WPA_GET_LE16(tmp);
14368 tmp = tmp + 1;
14369 akmlist = (int *)(tmp);
14370 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14371 {
14372 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14373 }
14374 else
14375 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014376 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 VOS_ASSERT(0);
14378 return -EINVAL;
14379 }
14380
14381 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14382 {
14383 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014384 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014385 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014387 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014388 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014389 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014390 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014391 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14392 }
14393 break;
14394#endif
14395 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014396 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014398 /* when Unknown IE is received we should break and continue
14399 * to the next IE in the buffer instead we were returning
14400 * so changing this to break */
14401 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014402 }
14403 genie += eLen;
14404 remLen -= eLen;
14405 }
14406 EXIT();
14407 return 0;
14408}
14409
14410/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014411 * FUNCTION: hdd_isWPAIEPresent
14412 * Parse the received IE to find the WPA IE
14413 *
14414 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014415static bool hdd_isWPAIEPresent(
14416#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14417 const u8 *ie,
14418#else
14419 u8 *ie,
14420#endif
14421 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014422{
14423 v_U8_t eLen = 0;
14424 v_U16_t remLen = ie_len;
14425 v_U8_t elementId = 0;
14426
14427 while (remLen >= 2)
14428 {
14429 elementId = *ie++;
14430 eLen = *ie++;
14431 remLen -= 2;
14432 if (eLen > remLen)
14433 {
14434 hddLog(VOS_TRACE_LEVEL_ERROR,
14435 "%s: IE length is wrong %d", __func__, eLen);
14436 return FALSE;
14437 }
14438 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14439 {
14440 /* OUI - 0x00 0X50 0XF2
14441 WPA Information Element - 0x01
14442 WPA version - 0x01*/
14443 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14444 return TRUE;
14445 }
14446 ie += eLen;
14447 remLen -= eLen;
14448 }
14449 return FALSE;
14450}
14451
14452/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014454 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 * parameters during connect operation.
14456 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014457int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014459 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014460{
14461 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014462 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014463 ENTER();
14464
14465 /*set wpa version*/
14466 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14467
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014468 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014469 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014470 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014471 {
14472 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14473 }
14474 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14475 {
14476 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14477 }
14478 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014479
14480 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 pWextState->wpaVersion);
14482
14483 /*set authentication type*/
14484 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14485
14486 if (0 > status)
14487 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014488 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014489 "%s: failed to set authentication type ", __func__);
14490 return status;
14491 }
14492
14493 /*set key mgmt type*/
14494 if (req->crypto.n_akm_suites)
14495 {
14496 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14497 if (0 > status)
14498 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014499 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 __func__);
14501 return status;
14502 }
14503 }
14504
14505 /*set pairwise cipher type*/
14506 if (req->crypto.n_ciphers_pairwise)
14507 {
14508 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14509 req->crypto.ciphers_pairwise[0], true);
14510 if (0 > status)
14511 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014512 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 "%s: failed to set unicast cipher type", __func__);
14514 return status;
14515 }
14516 }
14517 else
14518 {
14519 /*Reset previous cipher suite to none*/
14520 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14521 if (0 > status)
14522 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014523 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014524 "%s: failed to set unicast cipher type", __func__);
14525 return status;
14526 }
14527 }
14528
14529 /*set group cipher type*/
14530 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14531 false);
14532
14533 if (0 > status)
14534 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014535 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 __func__);
14537 return status;
14538 }
14539
Chet Lanctot186b5732013-03-18 10:26:30 -070014540#ifdef WLAN_FEATURE_11W
14541 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14542#endif
14543
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14545 if (req->ie_len)
14546 {
14547 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14548 if ( 0 > status)
14549 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014550 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 __func__);
14552 return status;
14553 }
14554 }
14555
14556 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014557 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 {
14559 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14560 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14561 )
14562 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014563 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14565 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014566 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 __func__);
14568 return -EOPNOTSUPP;
14569 }
14570 else
14571 {
14572 u8 key_len = req->key_len;
14573 u8 key_idx = req->key_idx;
14574
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014575 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 && (CSR_MAX_NUM_KEY > key_idx)
14577 )
14578 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014579 hddLog(VOS_TRACE_LEVEL_INFO,
14580 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 __func__, key_idx, key_len);
14582 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014583 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014585 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 (u8)key_len;
14587 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14588 }
14589 }
14590 }
14591 }
14592
14593 return status;
14594}
14595
14596/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014597 * FUNCTION: wlan_hdd_try_disconnect
14598 * This function is used to disconnect from previous
14599 * connection
14600 */
14601static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
14602{
14603 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014604 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014605 hdd_station_ctx_t *pHddStaCtx;
14606 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014607 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014608
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014609 ret = wlan_hdd_validate_context(pHddCtx);
14610 if (0 != ret)
14611 {
14612 return ret;
14613 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014614 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14615
14616 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14617
14618 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14619 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014620 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014621 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14622 {
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014623 spin_lock_bh(&pAdapter->lock_for_active_session);
14624 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14625 {
14626 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14627 }
14628 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014629 hdd_connSetConnectionState(pHddStaCtx,
14630 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014631 /* Issue disconnect to CSR */
14632 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014633 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014634 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014635 eCSR_DISCONNECT_REASON_UNSPECIFIED);
14636 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
14637 hddLog(LOG1,
14638 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
14639 } else if ( 0 != status ) {
14640 hddLog(LOGE,
14641 FL("csrRoamDisconnect failure, returned %d"),
14642 (int)status );
14643 result = -EINVAL;
14644 goto disconnected;
14645 }
14646 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014647 &pAdapter->disconnect_comp_var,
14648 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014649 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
14650 hddLog(LOGE,
14651 "%s: Failed to disconnect, timed out", __func__);
14652 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014653 }
14654 }
14655 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14656 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014657 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014658 &pAdapter->disconnect_comp_var,
14659 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014660 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014661 {
14662 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014663 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014664 }
14665 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014666disconnected:
14667 hddLog(LOG1,
14668 FL("Set HDD connState to eConnectionState_NotConnected"));
14669 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14670 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014671}
14672
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014673/**
14674 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
14675 * @adapter: Pointer to the HDD adapter
14676 * @req: Pointer to the structure cfg_connect_params receieved from user space
14677 *
14678 * This function will start reassociation if bssid hint, channel hint and
14679 * previous bssid parameters are present in the connect request
14680 *
14681 * Return: success if reassociation is happening
14682 * Error code if reassociation is not permitted or not happening
14683 */
14684#ifdef CFG80211_CONNECT_PREV_BSSID
14685static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14686 struct cfg80211_connect_params *req)
14687{
14688 int status = -EPERM;
14689 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
14690 hddLog(VOS_TRACE_LEVEL_INFO,
14691 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
14692 req->channel_hint->hw_value,
14693 MAC_ADDR_ARRAY(req->bssid_hint));
14694 status = hdd_reassoc(adapter, req->bssid_hint,
14695 req->channel_hint->hw_value,
14696 CONNECT_CMD_USERSPACE);
14697 }
14698 return status;
14699}
14700#else
14701static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14702 struct cfg80211_connect_params *req)
14703{
14704 return -EPERM;
14705}
14706#endif
14707
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014708/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053014709 * FUNCTION: __wlan_hdd_cfg80211_connect
14710 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014712static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 struct net_device *ndev,
14714 struct cfg80211_connect_params *req
14715 )
14716{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014717 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014718 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053014719#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
14720 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014721 const u8 *bssid_hint = req->bssid_hint;
14722#else
14723 const u8 *bssid_hint = NULL;
14724#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014725 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053014727 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014728
14729 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014730
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014731 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14732 TRACE_CODE_HDD_CFG80211_CONNECT,
14733 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014734 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014735 "%s: device_mode = %s (%d)", __func__,
14736 hdd_device_modetoString(pAdapter->device_mode),
14737 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014738
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014740 if (!pHddCtx)
14741 {
14742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14743 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053014744 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014745 }
14746
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014747 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014748 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014750 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 }
14752
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014753 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
14754 if (0 == status)
14755 return status;
14756
Agarwal Ashish51325b52014-06-16 16:50:49 +053014757
Jeff Johnson295189b2012-06-20 16:38:30 -070014758#ifdef WLAN_BTAMP_FEATURE
14759 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014760 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014762 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014763 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080014764 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 }
14766#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014767
14768 //If Device Mode is Station Concurrent Sessions Exit BMps
14769 //P2P Mode will be taken care in Open/close adapter
14770 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053014771 (vos_concurrent_open_sessions_running())) {
14772 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14773 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014774 }
14775
14776 /*Try disconnecting if already in connected state*/
14777 status = wlan_hdd_try_disconnect(pAdapter);
14778 if ( 0 > status)
14779 {
14780 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14781 " connection"));
14782 return -EALREADY;
14783 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053014784 /* Check for max concurrent connections after doing disconnect if any*/
14785 if (vos_max_concurrent_connections_reached()) {
14786 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14787 return -ECONNREFUSED;
14788 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014789
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014791 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014792
14793 if ( 0 > status)
14794 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014795 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014796 __func__);
14797 return status;
14798 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053014799
14800 if (pHddCtx->spoofMacAddr.isEnabled)
14801 {
14802 hddLog(VOS_TRACE_LEVEL_INFO,
14803 "%s: MAC Spoofing enabled ", __func__);
14804 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
14805 * to fill TxBds for probe request during SSID scan which may happen
14806 * as part of connect command
14807 */
14808 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
14809 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
14810 if (status != VOS_STATUS_SUCCESS)
14811 return -ECONNREFUSED;
14812 }
14813
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014814 if (req->channel)
14815 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070014816 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014817 channel = 0;
Kapil Gupta312028a2016-10-25 14:15:20 +053014818
14819 /* Abort if any scan is going on */
14820 status = wlan_hdd_scan_abort(pAdapter);
14821 if (0 != status)
14822 hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed"));
14823
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014824 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
14825 req->ssid_len, req->bssid,
14826 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014827
Sushant Kaushikd7083982015-03-18 14:33:24 +053014828 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 {
14830 //ReEnable BMPS if disabled
14831 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
14832 (NULL != pHddCtx))
14833 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053014834 if (pHddCtx->hdd_wlan_suspended)
14835 {
14836 hdd_set_pwrparams(pHddCtx);
14837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 //ReEnable Bmps and Imps back
14839 hdd_enable_bmps_imps(pHddCtx);
14840 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053014841 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014842 return status;
14843 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014844 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 EXIT();
14846 return status;
14847}
14848
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014849static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
14850 struct net_device *ndev,
14851 struct cfg80211_connect_params *req)
14852{
14853 int ret;
14854 vos_ssr_protect(__func__);
14855 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
14856 vos_ssr_unprotect(__func__);
14857
14858 return ret;
14859}
Jeff Johnson295189b2012-06-20 16:38:30 -070014860
14861/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014862 * FUNCTION: wlan_hdd_disconnect
14863 * This function is used to issue a disconnect request to SME
14864 */
14865int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
14866{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014867 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014868 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014869 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014870 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014871
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014872 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014874 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014875 if (0 != status)
14876 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014877 return status;
14878 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053014879 /* Indicate sme of disconnect so that in progress connection or preauth
14880 * can be aborted
14881 */
14882 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053014883 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014884 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014885
Agarwal Ashish47d18112014-08-04 19:55:07 +053014886 /* Need to apply spin lock before decreasing active sessions
14887 * as there can be chance for double decrement if context switch
14888 * Calls hdd_DisConnectHandler.
14889 */
14890
14891 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014892 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14893 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014894 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14895 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053014896 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
14897 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014898
Abhishek Singhf4669da2014-05-26 15:07:49 +053014899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053014900 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
14901
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014902 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014903
Mihir Shete182a0b22014-08-18 16:08:48 +053014904 /*
14905 * stop tx queues before deleting STA/BSS context from the firmware.
14906 * tx has to be disabled because the firmware can get busy dropping
14907 * the tx frames after BSS/STA has been deleted and will not send
14908 * back a response resulting in WDI timeout
14909 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053014910 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053014911 netif_tx_disable(pAdapter->dev);
14912 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014913
Mihir Shete182a0b22014-08-18 16:08:48 +053014914 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014915 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14916 pAdapter->sessionId, reason);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014917 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
14918 {
14919 hddLog(LOG1,
14920 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014921 }
14922 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014923 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014924 hddLog(LOGE,
14925 FL("csrRoamDisconnect failure, returned %d"),
14926 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014927 result = -EINVAL;
14928 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014929 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014930 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014931 &pAdapter->disconnect_comp_var,
14932 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014933 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014934 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014935 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014936 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014937 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014938 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014939disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014940 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014941 FL("Set HDD connState to eConnectionState_NotConnected"));
14942 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053014943#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
14944 /* Sending disconnect event to userspace for kernel version < 3.11
14945 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
14946 */
14947 hddLog(LOG1, FL("Send disconnected event to userspace"));
14948
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053014949 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053014950 WLAN_REASON_UNSPECIFIED);
14951#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014952
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014953 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014954 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014955}
14956
14957
14958/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014959 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 * This function is used to issue a disconnect request to SME
14961 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014962static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 struct net_device *dev,
14964 u16 reason
14965 )
14966{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014968 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014969 tCsrRoamProfile *pRoamProfile;
14970 hdd_station_ctx_t *pHddStaCtx;
14971 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014972#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014973 tANI_U8 staIdx;
14974#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014975
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014977
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014978 if (!pAdapter) {
14979 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
14980 return -EINVAL;
14981 }
14982
14983 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14984 if (!pHddStaCtx) {
14985 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
14986 return -EINVAL;
14987 }
14988
14989 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14990 status = wlan_hdd_validate_context(pHddCtx);
14991 if (0 != status)
14992 {
14993 return status;
14994 }
14995
14996 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
14997
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014998 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14999 TRACE_CODE_HDD_CFG80211_DISCONNECT,
15000 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015001 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
15002 __func__, hdd_device_modetoString(pAdapter->device_mode),
15003 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015004
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015005 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
15006 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070015007
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 if (NULL != pRoamProfile)
15009 {
15010 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015011 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
15012 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015014 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015016 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 switch(reason)
15018 {
15019 case WLAN_REASON_MIC_FAILURE:
15020 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
15021 break;
15022
15023 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
15024 case WLAN_REASON_DISASSOC_AP_BUSY:
15025 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
15026 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
15027 break;
15028
15029 case WLAN_REASON_PREV_AUTH_NOT_VALID:
15030 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053015031 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
15033 break;
15034
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 default:
15036 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
15037 break;
15038 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015039 pScanInfo = &pHddCtx->scan_info;
15040 if (pScanInfo->mScanPending)
15041 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015042 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015043 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053015044 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053015045 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053015046 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053015047 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015048#ifdef FEATURE_WLAN_TDLS
15049 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015050 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015051 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015052 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
15053 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015054 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015055 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015056 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015058 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080015059 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015060 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015061 status = sme_DeleteTdlsPeerSta(
15062 WLAN_HDD_GET_HAL_CTX(pAdapter),
15063 pAdapter->sessionId,
15064 mac);
15065 if (status != eHAL_STATUS_SUCCESS) {
15066 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15067 return -EPERM;
15068 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080015069 }
15070 }
15071#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053015072 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015073 status = wlan_hdd_disconnect(pAdapter, reasonCode);
15074 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 {
15076 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015077 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 __func__, (int)status );
15079 return -EINVAL;
15080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053015082 else
15083 {
15084 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
15085 "called while in %d state", __func__,
15086 pHddStaCtx->conn_info.connState);
15087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015088 }
15089 else
15090 {
15091 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
15092 }
15093
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015094 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 return status;
15096}
15097
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053015098static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
15099 struct net_device *dev,
15100 u16 reason
15101 )
15102{
15103 int ret;
15104 vos_ssr_protect(__func__);
15105 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
15106 vos_ssr_unprotect(__func__);
15107
15108 return ret;
15109}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053015110
Jeff Johnson295189b2012-06-20 16:38:30 -070015111/*
15112 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015113 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 * settings in IBSS mode.
15115 */
15116static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015117 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 struct cfg80211_ibss_params *params
15119 )
15120{
15121 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015122 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
15124 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015125
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 ENTER();
15127
15128 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070015129 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070015130
15131 if (params->ie_len && ( NULL != params->ie) )
15132 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015133 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15134 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 {
15136 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
15137 encryptionType = eCSR_ENCRYPT_TYPE_AES;
15138 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015139 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015141 tDot11fIEWPA dot11WPAIE;
15142 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015143 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015144
Wilson Yang00256342013-10-10 23:13:38 -070015145 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015146 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15147 params->ie_len, DOT11F_EID_WPA);
15148 if ( NULL != ie )
15149 {
15150 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15151 // Unpack the WPA IE
15152 //Skip past the EID byte and length byte - and four byte WiFi OUI
15153 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
15154 &ie[2+4],
15155 ie[1] - 4,
15156 &dot11WPAIE);
15157 /*Extract the multicast cipher, the encType for unicast
15158 cipher for wpa-none is none*/
15159 encryptionType =
15160 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
15161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015162 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015163
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
15165
15166 if (0 > status)
15167 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015168 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 __func__);
15170 return status;
15171 }
15172 }
15173
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015174 pWextState->roamProfile.AuthType.authType[0] =
15175 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 eCSR_AUTH_TYPE_OPEN_SYSTEM;
15177
15178 if (params->privacy)
15179 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015180 /* Security enabled IBSS, At this time there is no information available
15181 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015183 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015185 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070015186 *enable privacy bit in beacons */
15187
15188 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
15189 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015190 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
15191 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
15193 pWextState->roamProfile.EncryptionType.numEntries = 1;
15194 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 return status;
15196}
15197
15198/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015199 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015200 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015202static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015203 struct net_device *dev,
15204 struct cfg80211_ibss_params *params
15205 )
15206{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015207 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15209 tCsrRoamProfile *pRoamProfile;
15210 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015211 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15212 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015213 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070015214
15215 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015216
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015217 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15218 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
15219 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015220 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015221 "%s: device_mode = %s (%d)", __func__,
15222 hdd_device_modetoString(pAdapter->device_mode),
15223 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015224
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015225 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015226 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015228 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 }
15230
15231 if (NULL == pWextState)
15232 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015233 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 __func__);
15235 return -EIO;
15236 }
15237
Agarwal Ashish51325b52014-06-16 16:50:49 +053015238 if (vos_max_concurrent_connections_reached()) {
15239 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15240 return -ECONNREFUSED;
15241 }
15242
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015243 /*Try disconnecting if already in connected state*/
15244 status = wlan_hdd_try_disconnect(pAdapter);
15245 if ( 0 > status)
15246 {
15247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15248 " IBSS connection"));
15249 return -EALREADY;
15250 }
15251
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 pRoamProfile = &pWextState->roamProfile;
15253
15254 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
15255 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015256 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015257 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015258 return -EINVAL;
15259 }
15260
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015261 /* BSSID is provided by upper layers hence no need to AUTO generate */
15262 if (NULL != params->bssid) {
15263 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15264 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
15265 hddLog (VOS_TRACE_LEVEL_ERROR,
15266 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15267 return -EIO;
15268 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015269 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015270 }
krunal sonie9002db2013-11-25 14:24:17 -080015271 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
15272 {
15273 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15274 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
15275 {
15276 hddLog (VOS_TRACE_LEVEL_ERROR,
15277 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15278 return -EIO;
15279 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015280
15281 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080015282 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015283 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080015284 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015285
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070015287 if (NULL !=
15288#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15289 params->chandef.chan)
15290#else
15291 params->channel)
15292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 {
15294 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015295 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
15296 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
15297 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15298 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015299
15300 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015301 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070015302 ieee80211_frequency_to_channel(
15303#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15304 params->chandef.chan->center_freq);
15305#else
15306 params->channel->center_freq);
15307#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015308
15309 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15310 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015312 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15313 __func__);
15314 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015316
15317 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015319 if (channelNum == validChan[indx])
15320 {
15321 break;
15322 }
15323 }
15324 if (indx >= numChans)
15325 {
15326 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015327 __func__, channelNum);
15328 return -EINVAL;
15329 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015330 /* Set the Operational Channel */
15331 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15332 channelNum);
15333 pRoamProfile->ChannelInfo.numOfChannels = 1;
15334 pHddStaCtx->conn_info.operationChannel = channelNum;
15335 pRoamProfile->ChannelInfo.ChannelList =
15336 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 }
15338
15339 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015340 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 if (status < 0)
15342 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015343 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 __func__);
15345 return status;
15346 }
15347
15348 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015349 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015350 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015351 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015352
15353 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015356 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015357 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015358}
15359
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015360static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15361 struct net_device *dev,
15362 struct cfg80211_ibss_params *params
15363 )
15364{
15365 int ret = 0;
15366
15367 vos_ssr_protect(__func__);
15368 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15369 vos_ssr_unprotect(__func__);
15370
15371 return ret;
15372}
15373
Jeff Johnson295189b2012-06-20 16:38:30 -070015374/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015375 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015376 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015378static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 struct net_device *dev
15380 )
15381{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015382 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015383 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15384 tCsrRoamProfile *pRoamProfile;
15385 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015386 int status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015387#ifdef WLAN_FEATURE_RMC
15388 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
15389#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015390
15391 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015392
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015393 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15394 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15395 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015396 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015397 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015398 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015399 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015400 }
15401
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015402 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15403 hdd_device_modetoString(pAdapter->device_mode),
15404 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 if (NULL == pWextState)
15406 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015407 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 __func__);
15409 return -EIO;
15410 }
15411
15412 pRoamProfile = &pWextState->roamProfile;
15413
15414 /* Issue disconnect only if interface type is set to IBSS */
15415 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15416 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015417 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 __func__);
15419 return -EINVAL;
15420 }
15421
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015422#ifdef WLAN_FEATURE_RMC
15423 /* Clearing add IE of beacon */
15424 if (ccmCfgSetStr(pHddCtx->hHal,
15425 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
15426 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
15427 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15428 {
15429 hddLog (VOS_TRACE_LEVEL_ERROR,
15430 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
15431 return -EINVAL;
15432 }
15433 if (ccmCfgSetInt(pHddCtx->hHal,
15434 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
15435 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15436 {
15437 hddLog (VOS_TRACE_LEVEL_ERROR,
15438 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
15439 __func__);
15440 return -EINVAL;
15441 }
15442
15443 // Reset WNI_CFG_PROBE_RSP Flags
15444 wlan_hdd_reset_prob_rspies(pAdapter);
15445
15446 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15447 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
15448 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15449 {
15450 hddLog (VOS_TRACE_LEVEL_ERROR,
15451 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
15452 __func__);
15453 return -EINVAL;
15454 }
15455#endif
15456
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 /* Issue Disconnect request */
15458 INIT_COMPLETION(pAdapter->disconnect_comp_var);
15459 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
15460 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15461
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015462 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 return 0;
15464}
15465
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015466static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15467 struct net_device *dev
15468 )
15469{
15470 int ret = 0;
15471
15472 vos_ssr_protect(__func__);
15473 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15474 vos_ssr_unprotect(__func__);
15475
15476 return ret;
15477}
15478
Jeff Johnson295189b2012-06-20 16:38:30 -070015479/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015480 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 * This function is used to set the phy parameters
15482 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15483 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015484static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 u32 changed)
15486{
15487 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15488 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015489 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015490
15491 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015492
15493 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015494 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15495 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015496
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015497 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015498 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015499 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015500 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015501 }
15502
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15504 {
15505 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15506 WNI_CFG_RTS_THRESHOLD_STAMAX :
15507 wiphy->rts_threshold;
15508
15509 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015510 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015512 hddLog(VOS_TRACE_LEVEL_ERROR,
15513 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 __func__, rts_threshold);
15515 return -EINVAL;
15516 }
15517
15518 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15519 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015520 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015521 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015522 hddLog(VOS_TRACE_LEVEL_ERROR,
15523 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015524 __func__, rts_threshold);
15525 return -EIO;
15526 }
15527
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015528 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015529 rts_threshold);
15530 }
15531
15532 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15533 {
15534 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15535 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15536 wiphy->frag_threshold;
15537
15538 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015539 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015540 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015541 hddLog(VOS_TRACE_LEVEL_ERROR,
15542 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 frag_threshold);
15544 return -EINVAL;
15545 }
15546
15547 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15548 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015549 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015550 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015551 hddLog(VOS_TRACE_LEVEL_ERROR,
15552 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 __func__, frag_threshold);
15554 return -EIO;
15555 }
15556
15557 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15558 frag_threshold);
15559 }
15560
15561 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15562 || (changed & WIPHY_PARAM_RETRY_LONG))
15563 {
15564 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15565 wiphy->retry_short :
15566 wiphy->retry_long;
15567
15568 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15569 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15570 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015571 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015572 __func__, retry_value);
15573 return -EINVAL;
15574 }
15575
15576 if (changed & WIPHY_PARAM_RETRY_SHORT)
15577 {
15578 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15579 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015580 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015582 hddLog(VOS_TRACE_LEVEL_ERROR,
15583 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015584 __func__, retry_value);
15585 return -EIO;
15586 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015587 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015588 __func__, retry_value);
15589 }
15590 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15591 {
15592 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15593 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015594 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015595 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015596 hddLog(VOS_TRACE_LEVEL_ERROR,
15597 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 __func__, retry_value);
15599 return -EIO;
15600 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015601 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 __func__, retry_value);
15603 }
15604 }
15605
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015606 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 return 0;
15608}
15609
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015610static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15611 u32 changed)
15612{
15613 int ret;
15614
15615 vos_ssr_protect(__func__);
15616 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15617 vos_ssr_unprotect(__func__);
15618
15619 return ret;
15620}
15621
Jeff Johnson295189b2012-06-20 16:38:30 -070015622/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015623 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 * This function is used to set the txpower
15625 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015626static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015627#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15628 struct wireless_dev *wdev,
15629#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015630#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015631 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015632#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015633 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015634#endif
15635 int dbm)
15636{
15637 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015638 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15640 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015641 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015642
15643 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015644
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015645 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15646 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15647 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015648 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015649 if (0 != status)
15650 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015651 return status;
15652 }
15653
15654 hHal = pHddCtx->hHal;
15655
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015656 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15657 dbm, ccmCfgSetCallback,
15658 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015659 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015660 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015661 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15662 return -EIO;
15663 }
15664
15665 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15666 dbm);
15667
15668 switch(type)
15669 {
15670 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
15671 /* Fall through */
15672 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
15673 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
15674 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015675 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
15676 __func__);
15677 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 }
15679 break;
15680 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015681 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015682 __func__);
15683 return -EOPNOTSUPP;
15684 break;
15685 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015686 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
15687 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 return -EIO;
15689 }
15690
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015691 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015692 return 0;
15693}
15694
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015695static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
15696#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15697 struct wireless_dev *wdev,
15698#endif
15699#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15700 enum tx_power_setting type,
15701#else
15702 enum nl80211_tx_power_setting type,
15703#endif
15704 int dbm)
15705{
15706 int ret;
15707 vos_ssr_protect(__func__);
15708 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
15709#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15710 wdev,
15711#endif
15712#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15713 type,
15714#else
15715 type,
15716#endif
15717 dbm);
15718 vos_ssr_unprotect(__func__);
15719
15720 return ret;
15721}
15722
Jeff Johnson295189b2012-06-20 16:38:30 -070015723/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015724 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015725 * This function is used to read the txpower
15726 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015727static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015728#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15729 struct wireless_dev *wdev,
15730#endif
15731 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070015732{
15733
15734 hdd_adapter_t *pAdapter;
15735 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015736 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015737
Jeff Johnsone7245742012-09-05 17:12:55 -070015738 ENTER();
15739
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015740 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015741 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015742 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015743 *dbm = 0;
15744 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015745 }
15746
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
15748 if (NULL == pAdapter)
15749 {
15750 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
15751 return -ENOENT;
15752 }
15753
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015754 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15755 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
15756 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070015757 wlan_hdd_get_classAstats(pAdapter);
15758 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
15759
Jeff Johnsone7245742012-09-05 17:12:55 -070015760 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015761 return 0;
15762}
15763
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015764static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
15765#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15766 struct wireless_dev *wdev,
15767#endif
15768 int *dbm)
15769{
15770 int ret;
15771
15772 vos_ssr_protect(__func__);
15773 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
15774#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15775 wdev,
15776#endif
15777 dbm);
15778 vos_ssr_unprotect(__func__);
15779
15780 return ret;
15781}
15782
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015783static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015784#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15785 const u8* mac,
15786#else
15787 u8* mac,
15788#endif
15789 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070015790{
15791 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15792 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15793 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053015794 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015795
15796 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
15797 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070015798
15799 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
15800 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
15801 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
15802 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
15803 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
15804 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
15805 tANI_U16 maxRate = 0;
15806 tANI_U16 myRate;
15807 tANI_U16 currentRate = 0;
15808 tANI_U8 maxSpeedMCS = 0;
15809 tANI_U8 maxMCSIdx = 0;
15810 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053015811 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070015812 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015813 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015814
Leo Chang6f8870f2013-03-26 18:11:36 -070015815#ifdef WLAN_FEATURE_11AC
15816 tANI_U32 vht_mcs_map;
15817 eDataRate11ACMaxMcs vhtMaxMcs;
15818#endif /* WLAN_FEATURE_11AC */
15819
Jeff Johnsone7245742012-09-05 17:12:55 -070015820 ENTER();
15821
Jeff Johnson295189b2012-06-20 16:38:30 -070015822 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15823 (0 == ssidlen))
15824 {
15825 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
15826 " Invalid ssidlen, %d", __func__, ssidlen);
15827 /*To keep GUI happy*/
15828 return 0;
15829 }
15830
Mukul Sharma811205f2014-07-09 21:07:30 +053015831 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
15832 {
15833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15834 "%s: Roaming in progress, so unable to proceed this request", __func__);
Sachin Ahuja81ab1812016-08-19 21:35:58 +053015835 /* return a cached value */
15836 sinfo->signal = pAdapter->rssi;
Mukul Sharma811205f2014-07-09 21:07:30 +053015837 return 0;
15838 }
15839
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015840 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015841 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015842 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015843 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015844 }
15845
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053015846 wlan_hdd_get_station_stats(pAdapter);
15847 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015848
Kiet Lam3b17fc82013-09-27 05:24:08 +053015849 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
15850 sinfo->filled |= STATION_INFO_SIGNAL;
15851
c_hpothu09f19542014-05-30 21:53:31 +053015852 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053015853 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
15854 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053015855 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053015856 {
15857 rate_flags = pAdapter->maxRateFlags;
15858 }
c_hpothu44ff4e02014-05-08 00:13:57 +053015859
Jeff Johnson295189b2012-06-20 16:38:30 -070015860 //convert to the UI units of 100kbps
15861 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
15862
15863#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070015864 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 -070015865 sinfo->signal,
15866 pCfg->reportMaxLinkSpeed,
15867 myRate,
15868 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015869 (int) pCfg->linkSpeedRssiMid,
15870 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070015871 (int) rate_flags,
15872 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070015873#endif //LINKSPEED_DEBUG_ENABLED
15874
15875 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
15876 {
15877 // we do not want to necessarily report the current speed
15878 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
15879 {
15880 // report the max possible speed
15881 rssidx = 0;
15882 }
15883 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
15884 {
15885 // report the max possible speed with RSSI scaling
15886 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
15887 {
15888 // report the max possible speed
15889 rssidx = 0;
15890 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015891 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070015892 {
15893 // report middle speed
15894 rssidx = 1;
15895 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015896 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
15897 {
15898 // report middle speed
15899 rssidx = 2;
15900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 else
15902 {
15903 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015904 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070015905 }
15906 }
15907 else
15908 {
15909 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
15910 hddLog(VOS_TRACE_LEVEL_ERROR,
15911 "%s: Invalid value for reportMaxLinkSpeed: %u",
15912 __func__, pCfg->reportMaxLinkSpeed);
15913 rssidx = 0;
15914 }
15915
15916 maxRate = 0;
15917
15918 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015919 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
15920 OperationalRates, &ORLeng))
15921 {
15922 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15923 /*To keep GUI happy*/
15924 return 0;
15925 }
15926
Jeff Johnson295189b2012-06-20 16:38:30 -070015927 for (i = 0; i < ORLeng; i++)
15928 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015929 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 {
15931 /* Validate Rate Set */
15932 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
15933 {
15934 currentRate = supported_data_rate[j].supported_rate[rssidx];
15935 break;
15936 }
15937 }
15938 /* Update MAX rate */
15939 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15940 }
15941
15942 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015943 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
15944 ExtendedRates, &ERLeng))
15945 {
15946 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15947 /*To keep GUI happy*/
15948 return 0;
15949 }
15950
Jeff Johnson295189b2012-06-20 16:38:30 -070015951 for (i = 0; i < ERLeng; i++)
15952 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015953 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 {
15955 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
15956 {
15957 currentRate = supported_data_rate[j].supported_rate[rssidx];
15958 break;
15959 }
15960 }
15961 /* Update MAX rate */
15962 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15963 }
c_hpothu79aab322014-07-14 21:11:01 +053015964
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015965 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053015966 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015967 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053015968 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 {
c_hpothu79aab322014-07-14 21:11:01 +053015970 if (rate_flags & eHAL_TX_RATE_VHT80)
15971 mode = 2;
15972 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
15973 mode = 1;
15974 else
15975 mode = 0;
15976
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015977 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
15978 MCSRates, &MCSLeng))
15979 {
15980 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15981 /*To keep GUI happy*/
15982 return 0;
15983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015984 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070015985#ifdef WLAN_FEATURE_11AC
15986 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015987 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015989 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015990 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070015991 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070015992 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015993 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015994 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015995 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070015996 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015997 maxMCSIdx = 7;
15998 }
15999 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
16000 {
16001 maxMCSIdx = 8;
16002 }
16003 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
16004 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016005 //VHT20 is supporting 0~8
16006 if (rate_flags & eHAL_TX_RATE_VHT20)
16007 maxMCSIdx = 8;
16008 else
16009 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070016010 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016011
c_hpothu79aab322014-07-14 21:11:01 +053016012 if (0 != rssidx)/*check for scaled */
16013 {
16014 //get middle rate MCS index if rssi=1/2
16015 for (i=0; i <= maxMCSIdx; i++)
16016 {
16017 if (sinfo->signal <= rssiMcsTbl[mode][i])
16018 {
16019 maxMCSIdx = i;
16020 break;
16021 }
16022 }
16023 }
16024
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016025 if (rate_flags & eHAL_TX_RATE_VHT80)
16026 {
16027 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
16028 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
16029 }
16030 else if (rate_flags & eHAL_TX_RATE_VHT40)
16031 {
16032 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
16033 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
16034 }
16035 else if (rate_flags & eHAL_TX_RATE_VHT20)
16036 {
16037 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
16038 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
16039 }
16040
Leo Chang6f8870f2013-03-26 18:11:36 -070016041 maxSpeedMCS = 1;
16042 if (currentRate > maxRate)
16043 {
16044 maxRate = currentRate;
16045 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016046
Leo Chang6f8870f2013-03-26 18:11:36 -070016047 }
16048 else
16049#endif /* WLAN_FEATURE_11AC */
16050 {
16051 if (rate_flags & eHAL_TX_RATE_HT40)
16052 {
16053 rateFlag |= 1;
16054 }
16055 if (rate_flags & eHAL_TX_RATE_SGI)
16056 {
16057 rateFlag |= 2;
16058 }
16059
Girish Gowli01abcee2014-07-31 20:18:55 +053016060 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053016061 if (rssidx == 1 || rssidx == 2)
16062 {
16063 //get middle rate MCS index if rssi=1/2
16064 for (i=0; i <= 7; i++)
16065 {
16066 if (sinfo->signal <= rssiMcsTbl[mode][i])
16067 {
16068 temp = i+1;
16069 break;
16070 }
16071 }
16072 }
c_hpothu79aab322014-07-14 21:11:01 +053016073
16074 for (i = 0; i < MCSLeng; i++)
16075 {
Leo Chang6f8870f2013-03-26 18:11:36 -070016076 for (j = 0; j < temp; j++)
16077 {
16078 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
16079 {
16080 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016081 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016082 break;
16083 }
16084 }
16085 if ((j < temp) && (currentRate > maxRate))
16086 {
16087 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070016088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016089 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053016090 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 }
16092 }
16093
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016094 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
16095 {
16096 maxRate = myRate;
16097 maxSpeedMCS = 1;
16098 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16099 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016100 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053016101 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070016102 {
16103 maxRate = myRate;
16104 if (rate_flags & eHAL_TX_RATE_LEGACY)
16105 {
16106 maxSpeedMCS = 0;
16107 }
16108 else
16109 {
16110 maxSpeedMCS = 1;
16111 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
16112 }
16113 }
16114
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016115 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070016116 {
16117 sinfo->txrate.legacy = maxRate;
16118#ifdef LINKSPEED_DEBUG_ENABLED
16119 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
16120#endif //LINKSPEED_DEBUG_ENABLED
16121 }
16122 else
16123 {
16124 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070016125#ifdef WLAN_FEATURE_11AC
16126 sinfo->txrate.nss = 1;
16127 if (rate_flags & eHAL_TX_RATE_VHT80)
16128 {
16129 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016130 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070016131 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016132 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070016133 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016134 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16135 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16136 }
16137 else if (rate_flags & eHAL_TX_RATE_VHT20)
16138 {
16139 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16140 }
16141#endif /* WLAN_FEATURE_11AC */
16142 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
16143 {
16144 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16145 if (rate_flags & eHAL_TX_RATE_HT40)
16146 {
16147 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16148 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016150 if (rate_flags & eHAL_TX_RATE_SGI)
16151 {
16152 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16153 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016154
Jeff Johnson295189b2012-06-20 16:38:30 -070016155#ifdef LINKSPEED_DEBUG_ENABLED
16156 pr_info("Reporting MCS rate %d flags %x\n",
16157 sinfo->txrate.mcs,
16158 sinfo->txrate.flags );
16159#endif //LINKSPEED_DEBUG_ENABLED
16160 }
16161 }
16162 else
16163 {
16164 // report current rate instead of max rate
16165
16166 if (rate_flags & eHAL_TX_RATE_LEGACY)
16167 {
16168 //provide to the UI in units of 100kbps
16169 sinfo->txrate.legacy = myRate;
16170#ifdef LINKSPEED_DEBUG_ENABLED
16171 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
16172#endif //LINKSPEED_DEBUG_ENABLED
16173 }
16174 else
16175 {
16176 //must be MCS
16177 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016178#ifdef WLAN_FEATURE_11AC
16179 sinfo->txrate.nss = 1;
16180 if (rate_flags & eHAL_TX_RATE_VHT80)
16181 {
16182 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16183 }
16184 else
16185#endif /* WLAN_FEATURE_11AC */
16186 {
16187 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016189 if (rate_flags & eHAL_TX_RATE_SGI)
16190 {
16191 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16192 }
16193 if (rate_flags & eHAL_TX_RATE_HT40)
16194 {
16195 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16196 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016197#ifdef WLAN_FEATURE_11AC
16198 else if (rate_flags & eHAL_TX_RATE_VHT80)
16199 {
16200 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
16201 }
16202#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070016203#ifdef LINKSPEED_DEBUG_ENABLED
16204 pr_info("Reporting actual MCS rate %d flags %x\n",
16205 sinfo->txrate.mcs,
16206 sinfo->txrate.flags );
16207#endif //LINKSPEED_DEBUG_ENABLED
16208 }
16209 }
16210 sinfo->filled |= STATION_INFO_TX_BITRATE;
16211
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016212 sinfo->tx_packets =
16213 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
16214 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
16215 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
16216 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
16217
16218 sinfo->tx_retries =
16219 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
16220 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
16221 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
16222 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
16223
16224 sinfo->tx_failed =
16225 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
16226 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
16227 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
16228 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
16229
16230 sinfo->filled |=
16231 STATION_INFO_TX_PACKETS |
16232 STATION_INFO_TX_RETRIES |
16233 STATION_INFO_TX_FAILED;
16234
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053016235 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
16236 sinfo->filled |= STATION_INFO_RX_PACKETS;
16237
16238 if (rate_flags & eHAL_TX_RATE_LEGACY)
16239 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
16240 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
16241 sinfo->rx_packets);
16242 else
16243 hddLog(LOG1,
16244 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
16245 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
16246 sinfo->tx_packets, sinfo->rx_packets);
16247
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016248 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16249 TRACE_CODE_HDD_CFG80211_GET_STA,
16250 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016251 EXIT();
16252 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016253}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016254#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16255static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16256 const u8* mac, struct station_info *sinfo)
16257#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016258static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16259 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016260#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016261{
16262 int ret;
16263
16264 vos_ssr_protect(__func__);
16265 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
16266 vos_ssr_unprotect(__func__);
16267
16268 return ret;
16269}
16270
16271static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070016272 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070016273{
16274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016275 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016276 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016277 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016278
Jeff Johnsone7245742012-09-05 17:12:55 -070016279 ENTER();
16280
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 if (NULL == pAdapter)
16282 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 return -ENODEV;
16285 }
16286
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016287 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16288 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
16289 pAdapter->sessionId, timeout));
16290
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016291 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016292 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016293 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016294 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016295 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016296 }
16297
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016298 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
16299 (TRUE == pHddCtx->hdd_wlan_suspended) &&
16300 (pHddCtx->cfg_ini->fhostArpOffload) &&
16301 (eConnectionState_Associated ==
16302 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
16303 {
Amar Singhald53568e2013-09-26 11:03:45 -070016304
16305 hddLog(VOS_TRACE_LEVEL_INFO,
16306 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053016307 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016308 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16309 {
16310 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016311 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016312 __func__, vos_status);
16313 }
16314 }
16315
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 /**The get power cmd from the supplicant gets updated by the nl only
16317 *on successful execution of the function call
16318 *we are oppositely mapped w.r.t mode in the driver
16319 **/
16320 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
16321
16322 if (VOS_STATUS_E_FAILURE == vos_status)
16323 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016324 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16325 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 return -EINVAL;
16327 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016328 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016329 return 0;
16330}
16331
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016332static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16333 struct net_device *dev, bool mode, int timeout)
16334{
16335 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016336
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016337 vos_ssr_protect(__func__);
16338 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
16339 vos_ssr_unprotect(__func__);
16340
16341 return ret;
16342}
Sushant Kaushik084f6592015-09-10 13:11:56 +053016343
Jeff Johnson295189b2012-06-20 16:38:30 -070016344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016345static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
16346 struct net_device *netdev,
16347 u8 key_index)
16348{
16349 ENTER();
16350 return 0;
16351}
16352
Jeff Johnson295189b2012-06-20 16:38:30 -070016353static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016354 struct net_device *netdev,
16355 u8 key_index)
16356{
16357 int ret;
16358 vos_ssr_protect(__func__);
16359 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16360 vos_ssr_unprotect(__func__);
16361 return ret;
16362}
16363#endif //LINUX_VERSION_CODE
16364
16365#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16366static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16367 struct net_device *dev,
16368 struct ieee80211_txq_params *params)
16369{
16370 ENTER();
16371 return 0;
16372}
16373#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16374static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16375 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016376{
Jeff Johnsone7245742012-09-05 17:12:55 -070016377 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016378 return 0;
16379}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016380#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016381
16382#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16383static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016384 struct net_device *dev,
16385 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016386{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016387 int ret;
16388
16389 vos_ssr_protect(__func__);
16390 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16391 vos_ssr_unprotect(__func__);
16392 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016393}
16394#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16395static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16396 struct ieee80211_txq_params *params)
16397{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016398 int ret;
16399
16400 vos_ssr_protect(__func__);
16401 ret = __wlan_hdd_set_txq_params(wiphy, params);
16402 vos_ssr_unprotect(__func__);
16403 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016404}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016405#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016406
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016407static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016408 struct net_device *dev,
16409 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016410{
16411 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016412 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016413 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016414 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016415 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016416 v_CONTEXT_t pVosContext = NULL;
16417 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016418
Jeff Johnsone7245742012-09-05 17:12:55 -070016419 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016420
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016421 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016422 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016423 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016424 return -EINVAL;
16425 }
16426
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016427 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16428 TRACE_CODE_HDD_CFG80211_DEL_STA,
16429 pAdapter->sessionId, pAdapter->device_mode));
16430
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016431 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16432 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016433 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016434 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016435 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016436 }
16437
Jeff Johnson295189b2012-06-20 16:38:30 -070016438 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 )
16441 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016442 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16443 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16444 if(pSapCtx == NULL){
16445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16446 FL("psapCtx is NULL"));
16447 return -ENOENT;
16448 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016449 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 {
16451 v_U16_t i;
16452 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16453 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016454 if ((pSapCtx->aStaInfo[i].isUsed) &&
16455 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016457 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016458 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016459 ETHER_ADDR_LEN);
16460
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016462 "%s: Delete STA with MAC::"
16463 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016464 __func__,
16465 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16466 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016467 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016468 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 }
16470 }
16471 }
16472 else
16473 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016474
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016475 vos_status = hdd_softap_GetStaId(pAdapter,
16476 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016477 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16478 {
16479 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016480 "%s: Skip this DEL STA as this is not used::"
16481 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016482 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016483 return -ENOENT;
16484 }
16485
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016486 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016487 {
16488 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016489 "%s: Skip this DEL STA as deauth is in progress::"
16490 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016491 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016492 return -ENOENT;
16493 }
16494
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016495 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016496
Jeff Johnson295189b2012-06-20 16:38:30 -070016497 hddLog(VOS_TRACE_LEVEL_INFO,
16498 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016499 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016500 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016501 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016502
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016503 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016504 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16505 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016506 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016507 hddLog(VOS_TRACE_LEVEL_INFO,
16508 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016509 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016510 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016511 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016512 return -ENOENT;
16513 }
16514
Jeff Johnson295189b2012-06-20 16:38:30 -070016515 }
16516 }
16517
16518 EXIT();
16519
16520 return 0;
16521}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016522
16523#ifdef CFG80211_DEL_STA_V2
16524static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16525 struct net_device *dev,
16526 struct station_del_parameters *param)
16527#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16529static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16530 struct net_device *dev, const u8 *mac)
16531#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016532static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16533 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016534#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016535#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016536{
16537 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016538 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016539
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016540 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016541
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016542#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016543 if (NULL == param) {
16544 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016545 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016546 return -EINVAL;
16547 }
16548
16549 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16550 param->subtype, &delStaParams);
16551
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016552#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016553 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016554 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016555#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016556 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16557
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016558 vos_ssr_unprotect(__func__);
16559
16560 return ret;
16561}
16562
16563static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016564 struct net_device *dev,
16565#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16566 const u8 *mac,
16567#else
16568 u8 *mac,
16569#endif
16570 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016571{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016572 hdd_adapter_t *pAdapter;
16573 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016574 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016575#ifdef FEATURE_WLAN_TDLS
16576 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016577
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016578 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016579
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016580 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16581 if (NULL == pAdapter)
16582 {
16583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16584 "%s: Adapter is NULL",__func__);
16585 return -EINVAL;
16586 }
16587 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16588 status = wlan_hdd_validate_context(pHddCtx);
16589 if (0 != status)
16590 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016591 return status;
16592 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016593
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016594 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16595 TRACE_CODE_HDD_CFG80211_ADD_STA,
16596 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016597 mask = params->sta_flags_mask;
16598
16599 set = params->sta_flags_set;
16600
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016601 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016602 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16603 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016604
16605 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16606 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016607 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016608 }
16609 }
16610#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016611 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016612 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016613}
16614
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016615#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16616static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16617 struct net_device *dev, const u8 *mac,
16618 struct station_parameters *params)
16619#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016620static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16621 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016622#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016623{
16624 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016625
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016626 vos_ssr_protect(__func__);
16627 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16628 vos_ssr_unprotect(__func__);
16629
16630 return ret;
16631}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016632#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016633
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016634static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016635 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016636{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016637 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16638 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016639 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016640 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016641 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016642 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016644 ENTER();
16645
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016646 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016647 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016648 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016649 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016650 return -EINVAL;
16651 }
16652
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016653 if (!pmksa) {
16654 hddLog(LOGE, FL("pmksa is NULL"));
16655 return -EINVAL;
16656 }
16657
16658 if (!pmksa->bssid || !pmksa->pmkid) {
16659 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
16660 pmksa->bssid, pmksa->pmkid);
16661 return -EINVAL;
16662 }
16663
16664 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
16665 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16666
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016667 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16668 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016669 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016670 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016671 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016672 }
16673
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016674 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016675 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16676
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016677 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
16678 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016679
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016680 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016681 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016682 &pmk_id, 1, FALSE);
16683
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016684 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16685 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
16686 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016688 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016689 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016690}
16691
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016692static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
16693 struct cfg80211_pmksa *pmksa)
16694{
16695 int ret;
16696
16697 vos_ssr_protect(__func__);
16698 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
16699 vos_ssr_unprotect(__func__);
16700
16701 return ret;
16702}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016703
Wilson Yang6507c4e2013-10-01 20:11:19 -070016704
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016705static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070016706 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016707{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16709 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016710 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016711 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016712
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016713 ENTER();
16714
Wilson Yang6507c4e2013-10-01 20:11:19 -070016715 /* Validate pAdapter */
16716 if (NULL == pAdapter)
16717 {
16718 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
16719 return -EINVAL;
16720 }
16721
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016722 if (!pmksa) {
16723 hddLog(LOGE, FL("pmksa is NULL"));
16724 return -EINVAL;
16725 }
16726
16727 if (!pmksa->bssid) {
16728 hddLog(LOGE, FL("pmksa->bssid is NULL"));
16729 return -EINVAL;
16730 }
16731
Kiet Lam98c46a12014-10-31 15:34:57 -070016732 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
16733 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16734
Wilson Yang6507c4e2013-10-01 20:11:19 -070016735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16736 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016737 if (0 != status)
16738 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016739 return status;
16740 }
16741
16742 /*Retrieve halHandle*/
16743 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16744
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016745 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16746 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
16747 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016748 /* Delete the PMKID CSR cache */
16749 if (eHAL_STATUS_SUCCESS !=
16750 sme_RoamDelPMKIDfromCache(halHandle,
16751 pAdapter->sessionId, pmksa->bssid, FALSE)) {
16752 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
16753 MAC_ADDR_ARRAY(pmksa->bssid));
16754 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016755 }
16756
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016757 EXIT();
16758 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016759}
16760
Wilson Yang6507c4e2013-10-01 20:11:19 -070016761
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016762static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
16763 struct cfg80211_pmksa *pmksa)
16764{
16765 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016766
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016767 vos_ssr_protect(__func__);
16768 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
16769 vos_ssr_unprotect(__func__);
16770
16771 return ret;
16772
16773}
16774
16775static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016776{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016777 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16778 tHalHandle halHandle;
16779 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016780 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016781
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016782 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070016783
16784 /* Validate pAdapter */
16785 if (NULL == pAdapter)
16786 {
16787 hddLog(VOS_TRACE_LEVEL_ERROR,
16788 "%s: Invalid Adapter" ,__func__);
16789 return -EINVAL;
16790 }
16791
16792 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16793 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016794 if (0 != status)
16795 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016796 return status;
16797 }
16798
16799 /*Retrieve halHandle*/
16800 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16801
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016802 /* Flush the PMKID cache in CSR */
16803 if (eHAL_STATUS_SUCCESS !=
16804 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
16805 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
16806 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016807 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016808 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080016809 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016810}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016811
16812static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
16813{
16814 int ret;
16815
16816 vos_ssr_protect(__func__);
16817 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
16818 vos_ssr_unprotect(__func__);
16819
16820 return ret;
16821}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016822#endif
16823
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016824#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016825static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16826 struct net_device *dev,
16827 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016828{
16829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16830 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016831 hdd_context_t *pHddCtx;
16832 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016833
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016834 ENTER();
16835
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016836 if (NULL == pAdapter)
16837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016838 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016839 return -ENODEV;
16840 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16842 ret = wlan_hdd_validate_context(pHddCtx);
16843 if (0 != ret)
16844 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016845 return ret;
16846 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016847 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016848 if (NULL == pHddStaCtx)
16849 {
16850 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
16851 return -EINVAL;
16852 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016853
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016854 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16855 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
16856 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016857 // Added for debug on reception of Re-assoc Req.
16858 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
16859 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016860 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016861 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080016862 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016863 }
16864
16865#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080016866 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016867 ftie->ie_len);
16868#endif
16869
16870 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016871 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
16872 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016873 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016874
16875 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016876 return 0;
16877}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016878
16879static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16880 struct net_device *dev,
16881 struct cfg80211_update_ft_ies_params *ftie)
16882{
16883 int ret;
16884
16885 vos_ssr_protect(__func__);
16886 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
16887 vos_ssr_unprotect(__func__);
16888
16889 return ret;
16890}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016891#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016892
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016893#ifdef FEATURE_WLAN_SCAN_PNO
16894
16895void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
16896 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
16897{
16898 int ret;
16899 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
16900 hdd_context_t *pHddCtx;
16901
Nirav Shah80830bf2013-12-31 16:35:12 +053016902 ENTER();
16903
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016904 if (NULL == pAdapter)
16905 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016907 "%s: HDD adapter is Null", __func__);
16908 return ;
16909 }
16910
16911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16912 if (NULL == pHddCtx)
16913 {
16914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16915 "%s: HDD context is Null!!!", __func__);
16916 return ;
16917 }
16918
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016919 spin_lock(&pHddCtx->schedScan_lock);
16920 if (TRUE == pHddCtx->isWiphySuspended)
16921 {
16922 pHddCtx->isSchedScanUpdatePending = TRUE;
16923 spin_unlock(&pHddCtx->schedScan_lock);
16924 hddLog(VOS_TRACE_LEVEL_INFO,
16925 "%s: Update cfg80211 scan database after it resume", __func__);
16926 return ;
16927 }
16928 spin_unlock(&pHddCtx->schedScan_lock);
16929
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016930 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
16931
16932 if (0 > ret)
16933 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053016934 else
16935 {
16936 /* Acquire wakelock to handle the case where APP's tries to suspend
16937 * immediatly after the driver gets connect request(i.e after pno)
16938 * from supplicant, this result in app's is suspending and not able
16939 * to process the connect request to AP */
16940 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
16941 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016942 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16944 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016945}
16946
16947/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016948 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016949 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016950 */
16951static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
16952{
16953 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
16954 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016955 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016956 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16957 int status = 0;
16958 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
16959
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016960 /* The current firmware design does not allow PNO during any
16961 * active sessions. Hence, determine the active sessions
16962 * and return a failure.
16963 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016964 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
16965 {
16966 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016967 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016968
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016969 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
16970 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
16971 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
16972 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
16973 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053016974 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016975 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016976 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016977 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016978 }
16979 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16980 pAdapterNode = pNext;
16981 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016982 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016983}
16984
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016985void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
16986{
16987 hdd_adapter_t *pAdapter = callbackContext;
16988 hdd_context_t *pHddCtx;
16989
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016990 ENTER();
16991
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016992 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
16993 {
16994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16995 FL("Invalid adapter or adapter has invalid magic"));
16996 return;
16997 }
16998
16999 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
17000 if (0 != wlan_hdd_validate_context(pHddCtx))
17001 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017002 return;
17003 }
17004
c_hpothub53c45d2014-08-18 16:53:14 +053017005 if (VOS_STATUS_SUCCESS != status)
17006 {
17007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017008 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053017009 pHddCtx->isPnoEnable = FALSE;
17010 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017011
17012 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
17013 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017014 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017015}
17016
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017017/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017018 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
17019 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017020 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017021static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017022 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17023{
17024 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017025 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017026 hdd_context_t *pHddCtx;
17027 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017028 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053017029 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
17030 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017031 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
17032 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017033 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017034 hdd_config_t *pConfig = NULL;
17035 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017036
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017037 ENTER();
17038
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017039 if (NULL == pAdapter)
17040 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017042 "%s: HDD adapter is Null", __func__);
17043 return -ENODEV;
17044 }
17045
17046 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017047 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017048
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017049 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017050 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017051 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017052 }
17053
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017054 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017055 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17056 if (NULL == hHal)
17057 {
17058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17059 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017060 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017061 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017062 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17063 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
17064 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053017065 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017066 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053017067 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053017068 {
17069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17070 "%s: aborting the existing scan is unsuccessfull", __func__);
17071 return -EBUSY;
17072 }
17073
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017074 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017075 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053017076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053017077 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053017078 return -EBUSY;
17079 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017080
c_hpothu37f21312014-04-09 21:49:54 +053017081 if (TRUE == pHddCtx->isPnoEnable)
17082 {
17083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
17084 FL("already PNO is enabled"));
17085 return -EBUSY;
17086 }
c_hpothu225aa7c2014-10-22 17:45:13 +053017087
17088 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
17089 {
17090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17091 "%s: abort ROC failed ", __func__);
17092 return -EBUSY;
17093 }
17094
c_hpothu37f21312014-04-09 21:49:54 +053017095 pHddCtx->isPnoEnable = TRUE;
17096
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017097 pnoRequest.enable = 1; /*Enable PNO */
17098 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017099
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017100 if (( !pnoRequest.ucNetworksCount ) ||
17101 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017102 {
17103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017104 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017105 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017106 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017107 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017108 goto error;
17109 }
17110
17111 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
17112 {
17113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017114 "%s: Incorrect number of channels %d",
17115 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017116 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017117 goto error;
17118 }
17119
17120 /* Framework provides one set of channels(all)
17121 * common for all saved profile */
17122 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
17123 channels_allowed, &num_channels_allowed))
17124 {
17125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17126 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017127 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017128 goto error;
17129 }
17130 /* Checking each channel against allowed channel list */
17131 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053017132 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017133 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017134 char chList [(request->n_channels*5)+1];
17135 int len;
17136 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017137 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017138 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017139 {
Nirav Shah80830bf2013-12-31 16:35:12 +053017140 if (request->channels[i]->hw_value == channels_allowed[indx])
17141 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017142 if ((!pConfig->enableDFSPnoChnlScan) &&
17143 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
17144 {
17145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17146 "%s : Dropping DFS channel : %d",
17147 __func__,channels_allowed[indx]);
17148 num_ignore_dfs_ch++;
17149 break;
17150 }
17151
Nirav Shah80830bf2013-12-31 16:35:12 +053017152 valid_ch[num_ch++] = request->channels[i]->hw_value;
17153 len += snprintf(chList+len, 5, "%d ",
17154 request->channels[i]->hw_value);
17155 break ;
17156 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017157 }
17158 }
Nirav Shah80830bf2013-12-31 16:35:12 +053017159 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017160
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017161 /*If all channels are DFS and dropped, then ignore the PNO request*/
17162 if (num_ignore_dfs_ch == request->n_channels)
17163 {
17164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17165 "%s : All requested channels are DFS channels", __func__);
17166 ret = -EINVAL;
17167 goto error;
17168 }
17169 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017170
17171 pnoRequest.aNetworks =
17172 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17173 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017174 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017175 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17176 FL("failed to allocate memory aNetworks %u"),
17177 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17178 goto error;
17179 }
17180 vos_mem_zero(pnoRequest.aNetworks,
17181 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17182
17183 /* Filling per profile params */
17184 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
17185 {
17186 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017187 request->match_sets[i].ssid.ssid_len;
17188
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017189 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
17190 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017191 {
17192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017193 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017194 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017195 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017196 goto error;
17197 }
17198
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017199 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017200 request->match_sets[i].ssid.ssid,
17201 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17203 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017204 i, pnoRequest.aNetworks[i].ssId.ssId);
17205 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
17206 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
17207 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017208
17209 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017210 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
17211 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017212
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017213 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017214 }
17215
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017216 for (i = 0; i < request->n_ssids; i++)
17217 {
17218 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017219 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017220 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017221 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017222 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017223 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017224 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017225 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017226 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017227 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017228 break;
17229 }
17230 j++;
17231 }
17232 }
17233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17234 "Number of hidden networks being Configured = %d",
17235 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080017237 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017238
17239 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17240 if (pnoRequest.p24GProbeTemplate == NULL)
17241 {
17242 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17243 FL("failed to allocate memory p24GProbeTemplate %u"),
17244 SIR_PNO_MAX_PB_REQ_SIZE);
17245 goto error;
17246 }
17247
17248 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17249 if (pnoRequest.p5GProbeTemplate == NULL)
17250 {
17251 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17252 FL("failed to allocate memory p5GProbeTemplate %u"),
17253 SIR_PNO_MAX_PB_REQ_SIZE);
17254 goto error;
17255 }
17256
17257 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17258 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17259
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053017260 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
17261 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017262 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017263 pnoRequest.us24GProbeTemplateLen = request->ie_len;
17264 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
17265 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017266
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017267 pnoRequest.us5GProbeTemplateLen = request->ie_len;
17268 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
17269 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017270 }
17271
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017272 /* Driver gets only one time interval which is hardcoded in
17273 * supplicant for 10000ms. Taking power consumption into account 6 timers
17274 * will be used, Timervalue is increased exponentially i.e 10,20,40,
17275 * 80,160,320 secs. And number of scan cycle for each timer
17276 * is configurable through INI param gPNOScanTimerRepeatValue.
17277 * If it is set to 0 only one timer will be used and PNO scan cycle
17278 * will be repeated after each interval specified by supplicant
17279 * till PNO is disabled.
17280 */
17281 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017282 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017283 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017284 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017285 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17286
17287 tempInterval = (request->interval)/1000;
17288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17289 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17290 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017291 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017292 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017293 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017294 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017295 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017296 tempInterval *= 2;
17297 }
17298 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017299 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017300
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017301 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017302
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017303 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017304 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17305 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017306 pAdapter->pno_req_status = 0;
17307
Nirav Shah80830bf2013-12-31 16:35:12 +053017308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17309 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017310 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
17311 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053017312
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017313 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017314 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017315 hdd_cfg80211_sched_scan_done_callback, pAdapter);
17316 if (eHAL_STATUS_SUCCESS != status)
17317 {
17318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017319 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017320 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017321 goto error;
17322 }
17323
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017324 ret = wait_for_completion_timeout(
17325 &pAdapter->pno_comp_var,
17326 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17327 if (0 >= ret)
17328 {
17329 // Did not receive the response for PNO enable in time.
17330 // Assuming the PNO enable was success.
17331 // Returning error from here, because we timeout, results
17332 // in side effect of Wifi (Wifi Setting) not to work.
17333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17334 FL("Timed out waiting for PNO to be Enabled"));
17335 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017336 }
17337
17338 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053017339 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017340
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017341error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17343 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053017344 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017345 if (pnoRequest.aNetworks)
17346 vos_mem_free(pnoRequest.aNetworks);
17347 if (pnoRequest.p24GProbeTemplate)
17348 vos_mem_free(pnoRequest.p24GProbeTemplate);
17349 if (pnoRequest.p5GProbeTemplate)
17350 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017351
17352 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017353 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017354}
17355
17356/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017357 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17358 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017359 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017360static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17361 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17362{
17363 int ret;
17364
17365 vos_ssr_protect(__func__);
17366 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17367 vos_ssr_unprotect(__func__);
17368
17369 return ret;
17370}
17371
17372/*
17373 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17374 * Function to disable PNO
17375 */
17376static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017377 struct net_device *dev)
17378{
17379 eHalStatus status = eHAL_STATUS_FAILURE;
17380 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17381 hdd_context_t *pHddCtx;
17382 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017383 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017384 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017385
17386 ENTER();
17387
17388 if (NULL == pAdapter)
17389 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017391 "%s: HDD adapter is Null", __func__);
17392 return -ENODEV;
17393 }
17394
17395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017396
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017397 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017398 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017399 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017400 "%s: HDD context is Null", __func__);
17401 return -ENODEV;
17402 }
17403
17404 /* The return 0 is intentional when isLogpInProgress and
17405 * isLoadUnloadInProgress. We did observe a crash due to a return of
17406 * failure in sched_scan_stop , especially for a case where the unload
17407 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17408 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17409 * success. If it returns a failure , then its next invocation due to the
17410 * clean up of the second interface will have the dev pointer corresponding
17411 * to the first one leading to a crash.
17412 */
17413 if (pHddCtx->isLogpInProgress)
17414 {
17415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17416 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017417 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017418 return ret;
17419 }
17420
Mihir Shete18156292014-03-11 15:38:30 +053017421 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017422 {
17423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17424 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17425 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017426 }
17427
17428 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17429 if (NULL == hHal)
17430 {
17431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17432 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017433 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017434 }
17435
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017436 pnoRequest.enable = 0; /* Disable PNO */
17437 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017438
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017439 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17440 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17441 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017442
17443 INIT_COMPLETION(pAdapter->pno_comp_var);
17444 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17445 pnoRequest.callbackContext = pAdapter;
17446 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017447 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017448 pAdapter->sessionId,
17449 NULL, pAdapter);
17450 if (eHAL_STATUS_SUCCESS != status)
17451 {
17452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17453 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017454 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017455 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017456 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017457 ret = wait_for_completion_timeout(
17458 &pAdapter->pno_comp_var,
17459 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17460 if (0 >= ret)
17461 {
17462 // Did not receive the response for PNO disable in time.
17463 // Assuming the PNO disable was success.
17464 // Returning error from here, because we timeout, results
17465 // in side effect of Wifi (Wifi Setting) not to work.
Anurag Chouhan96b41cb2016-09-28 18:54:47 +053017466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017467 FL("Timed out waiting for PNO to be disabled"));
17468 ret = 0;
17469 }
17470
17471 ret = pAdapter->pno_req_status;
17472 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017473
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017474error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017475 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017476 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017477
17478 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017479 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017480}
17481
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017482/*
17483 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17484 * NL interface to disable PNO
17485 */
17486static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17487 struct net_device *dev)
17488{
17489 int ret;
17490
17491 vos_ssr_protect(__func__);
17492 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17493 vos_ssr_unprotect(__func__);
17494
17495 return ret;
17496}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017497#endif /*FEATURE_WLAN_SCAN_PNO*/
17498
17499
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017500#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017501#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017502static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17503 struct net_device *dev,
17504 u8 *peer, u8 action_code,
17505 u8 dialog_token,
17506 u16 status_code, u32 peer_capability,
17507 const u8 *buf, size_t len)
17508#else /* TDLS_MGMT_VERSION2 */
17509#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17510static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17511 struct net_device *dev,
17512 const u8 *peer, u8 action_code,
17513 u8 dialog_token, u16 status_code,
17514 u32 peer_capability, bool initiator,
17515 const u8 *buf, size_t len)
17516#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17517static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17518 struct net_device *dev,
17519 const u8 *peer, u8 action_code,
17520 u8 dialog_token, u16 status_code,
17521 u32 peer_capability, const u8 *buf,
17522 size_t len)
17523#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17524static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17525 struct net_device *dev,
17526 u8 *peer, u8 action_code,
17527 u8 dialog_token,
17528 u16 status_code, u32 peer_capability,
17529 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017530#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017531static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17532 struct net_device *dev,
17533 u8 *peer, u8 action_code,
17534 u8 dialog_token,
17535 u16 status_code, const u8 *buf,
17536 size_t len)
17537#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017538#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017539{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017540 hdd_adapter_t *pAdapter;
17541 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017542 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017543 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017544 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017545 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017546 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017547 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017548#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017549 u32 peer_capability = 0;
17550#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017551 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017552 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017553
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017554 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17555 if (NULL == pAdapter)
17556 {
17557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17558 "%s: Adapter is NULL",__func__);
17559 return -EINVAL;
17560 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017561 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17562 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17563 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017564
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017565 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017566 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017567 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017568 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017569 "Invalid arguments");
17570 return -EINVAL;
17571 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017572
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017573 if (pHddCtx->isLogpInProgress)
17574 {
17575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17576 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017577 wlan_hdd_tdls_set_link_status(pAdapter,
17578 peer,
17579 eTDLS_LINK_IDLE,
17580 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017581 return -EBUSY;
17582 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017583
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017584 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17585 {
17586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17587 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17588 return -EAGAIN;
17589 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017590
Hoonki Lee27511902013-03-14 18:19:06 -070017591 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017592 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017594 "%s: TDLS mode is disabled OR not enabled in FW."
17595 MAC_ADDRESS_STR " action %d declined.",
17596 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017597 return -ENOTSUPP;
17598 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017599
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017600 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17601
17602 if( NULL == pHddStaCtx )
17603 {
17604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17605 "%s: HDD station context NULL ",__func__);
17606 return -EINVAL;
17607 }
17608
17609 /* STA should be connected and authenticated
17610 * before sending any TDLS frames
17611 */
17612 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
17613 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
17614 {
17615 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17616 "STA is not connected or unauthenticated. "
17617 "connState %u, uIsAuthenticated %u",
17618 pHddStaCtx->conn_info.connState,
17619 pHddStaCtx->conn_info.uIsAuthenticated);
17620 return -EAGAIN;
17621 }
17622
Hoonki Lee27511902013-03-14 18:19:06 -070017623 /* other than teardown frame, other mgmt frames are not sent if disabled */
17624 if (SIR_MAC_TDLS_TEARDOWN != action_code)
17625 {
17626 /* if tdls_mode is disabled to respond to peer's request */
17627 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
17628 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017629 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017630 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017631 " TDLS mode is disabled. action %d declined.",
17632 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070017633
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017634 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070017635 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053017636
17637 if (vos_max_concurrent_connections_reached())
17638 {
17639 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17640 return -EINVAL;
17641 }
Hoonki Lee27511902013-03-14 18:19:06 -070017642 }
17643
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017644 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
17645 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053017646 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017647 {
17648 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017649 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017650 " TDLS setup is ongoing. action %d declined.",
17651 __func__, MAC_ADDR_ARRAY(peer), action_code);
17652 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017653 }
17654 }
17655
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017656 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
17657 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080017658 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017659 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17660 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017661 {
17662 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
17663 we return error code at 'add_station()'. Hence we have this
17664 check again in addtion to add_station().
17665 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017666 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017667 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017668 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17669 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017670 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
17671 __func__, MAC_ADDR_ARRAY(peer), action_code,
17672 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053017673 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080017674 }
17675 else
17676 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017677 /* maximum reached. tweak to send error code to peer and return
17678 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017679 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17681 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017682 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
17683 __func__, MAC_ADDR_ARRAY(peer), status_code,
17684 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070017685 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017686 /* fall through to send setup resp with failure status
17687 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017688 }
17689 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017690 else
17691 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017692 mutex_lock(&pHddCtx->tdls_lock);
17693 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017694 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017695 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017696 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017698 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
17699 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017700 return -EPERM;
17701 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017702 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017703 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017704 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017705
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017706 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017707 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017708 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
17709 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017710
Hoonki Leea34dd892013-02-05 22:56:02 -080017711 /*Except teardown responder will not be used so just make 0*/
17712 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017713 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080017714 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017715
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017716 mutex_lock(&pHddCtx->tdls_lock);
17717 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017718
17719 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
17720 responder = pTdlsPeer->is_responder;
17721 else
Hoonki Leea34dd892013-02-05 22:56:02 -080017722 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017724 "%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 -070017725 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
17726 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017727 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017728 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080017729 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017730 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017731 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017732
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017733 /* Discard TDLS setup if peer is removed by user app */
17734 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
17735 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17736 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
17737 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
17738
17739 mutex_lock(&pHddCtx->tdls_lock);
17740 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17741 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
17742 mutex_unlock(&pHddCtx->tdls_lock);
17743 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
17744 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
17745 MAC_ADDR_ARRAY(peer), action_code);
17746 return -EINVAL;
17747 }
17748 mutex_unlock(&pHddCtx->tdls_lock);
17749 }
17750
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017751 /* For explicit trigger of DIS_REQ come out of BMPS for
17752 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070017753 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053017754 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017755 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
17756 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070017757 {
17758 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
17759 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017761 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017762 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
17763 if (status != VOS_STATUS_SUCCESS) {
17764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
17765 }
Hoonki Lee14621352013-04-16 17:51:19 -070017766 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017767 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017768 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
17770 }
17771 }
Hoonki Lee14621352013-04-16 17:51:19 -070017772 }
17773
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017774 /* make sure doesn't call send_mgmt() while it is pending */
17775 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
17776 {
17777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017778 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017779 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017780 ret = -EBUSY;
17781 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017782 }
17783
17784 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017785 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
17786
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017787 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
17788 pAdapter->sessionId, peer, action_code, dialog_token,
17789 status_code, peer_capability, (tANI_U8 *)buf, len,
17790 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017791
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017792 if (VOS_STATUS_SUCCESS != status)
17793 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17795 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017796 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017797 ret = -EINVAL;
17798 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017799 }
17800
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17802 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
17803 WAIT_TIME_TDLS_MGMT);
17804
Hoonki Leed37cbb32013-04-20 00:31:14 -070017805 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
17806 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
17807
17808 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017809 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070017810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070017811 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070017812 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017813 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080017814
17815 if (pHddCtx->isLogpInProgress)
17816 {
17817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17818 "%s: LOGP in Progress. Ignore!!!", __func__);
17819 return -EAGAIN;
17820 }
Abhishek Singh837adf22015-10-01 17:37:37 +053017821 if (rc <= 0)
17822 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
17823 WLAN_LOG_INDICATOR_HOST_DRIVER,
17824 WLAN_LOG_REASON_HDD_TIME_OUT,
17825 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080017826
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017827 ret = -EINVAL;
17828 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017829 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017830 else
17831 {
17832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17833 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
17834 __func__, rc, pAdapter->mgmtTxCompletionStatus);
17835 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017836
Gopichand Nakkala05922802013-03-14 12:23:19 -070017837 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070017838 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017839 ret = max_sta_failed;
17840 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070017841 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017842
Hoonki Leea34dd892013-02-05 22:56:02 -080017843 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
17844 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017845 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017846 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17847 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017848 }
17849 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
17850 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017851 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017852 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17853 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017854 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017855
17856 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017857
17858tx_failed:
17859 /* add_station will be called before sending TDLS_SETUP_REQ and
17860 * TDLS_SETUP_RSP and as part of add_station driver will enable
17861 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
17862 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
17863 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
17864 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
17865 */
17866
17867 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17868 (SIR_MAC_TDLS_SETUP_RSP == action_code))
17869 wlan_hdd_tdls_check_bmps(pAdapter);
17870 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017871}
17872
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017873#if TDLS_MGMT_VERSION2
17874static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17875 u8 *peer, u8 action_code, u8 dialog_token,
17876 u16 status_code, u32 peer_capability,
17877 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017878#else /* TDLS_MGMT_VERSION2 */
17879#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17880static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17881 struct net_device *dev,
17882 const u8 *peer, u8 action_code,
17883 u8 dialog_token, u16 status_code,
17884 u32 peer_capability, bool initiator,
17885 const u8 *buf, size_t len)
17886#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17887static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17888 struct net_device *dev,
17889 const u8 *peer, u8 action_code,
17890 u8 dialog_token, u16 status_code,
17891 u32 peer_capability, const u8 *buf,
17892 size_t len)
17893#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17894static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17895 struct net_device *dev,
17896 u8 *peer, u8 action_code,
17897 u8 dialog_token,
17898 u16 status_code, u32 peer_capability,
17899 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017900#else
17901static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17902 u8 *peer, u8 action_code, u8 dialog_token,
17903 u16 status_code, const u8 *buf, size_t len)
17904#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017905#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017906{
17907 int ret;
17908
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017909 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017910#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017911 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17912 dialog_token, status_code,
17913 peer_capability, buf, len);
17914#else /* TDLS_MGMT_VERSION2 */
17915#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17916 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17917 dialog_token, status_code,
17918 peer_capability, initiator,
17919 buf, len);
17920#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17921 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17922 dialog_token, status_code,
17923 peer_capability, buf, len);
17924#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17925 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17926 dialog_token, status_code,
17927 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017928#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017929 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17930 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017931#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017932#endif
17933 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017934
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017935 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017936}
Atul Mittal115287b2014-07-08 13:26:33 +053017937
17938int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017939#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17940 const u8 *peer,
17941#else
Atul Mittal115287b2014-07-08 13:26:33 +053017942 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017943#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017944 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053017945 cfg80211_exttdls_callback callback)
17946{
17947
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017948 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053017949 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017950 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053017951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17952 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
17953 __func__, MAC_ADDR_ARRAY(peer));
17954
17955 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17956 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17957
17958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017959 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17960 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17961 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017962 return -ENOTSUPP;
17963 }
17964
17965 /* To cater the requirement of establishing the TDLS link
17966 * irrespective of the data traffic , get an entry of TDLS peer.
17967 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017968 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017969 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
17970 if (pTdlsPeer == NULL) {
17971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17972 "%s: peer " MAC_ADDRESS_STR " not existing",
17973 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017974 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017975 return -EINVAL;
17976 }
17977
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017978 /* check FW TDLS Off Channel capability */
17979 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017980 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017981 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017982 {
17983 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
17984 pTdlsPeer->peerParams.global_operating_class =
17985 tdls_peer_params->global_operating_class;
17986 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
17987 pTdlsPeer->peerParams.min_bandwidth_kbps =
17988 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017989 /* check configured channel is valid, non dfs and
17990 * not current operating channel */
17991 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
17992 tdls_peer_params->channel)) &&
17993 (pHddStaCtx) &&
17994 (tdls_peer_params->channel !=
17995 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017996 {
17997 pTdlsPeer->isOffChannelConfigured = TRUE;
17998 }
17999 else
18000 {
18001 pTdlsPeer->isOffChannelConfigured = FALSE;
18002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18003 "%s: Configured Tdls Off Channel is not valid", __func__);
18004
18005 }
18006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018007 "%s: tdls_off_channel %d isOffChannelConfigured %d "
18008 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018009 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053018010 pTdlsPeer->isOffChannelConfigured,
18011 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018012 }
18013 else
18014 {
18015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053018016 "%s: TDLS off channel FW capability %d, "
18017 "host capab %d or Invalid TDLS Peer Params", __func__,
18018 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
18019 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018020 }
18021
Atul Mittal115287b2014-07-08 13:26:33 +053018022 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
18023
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018024 mutex_unlock(&pHddCtx->tdls_lock);
18025
Atul Mittal115287b2014-07-08 13:26:33 +053018026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18027 " %s TDLS Add Force Peer Failed",
18028 __func__);
18029 return -EINVAL;
18030 }
18031 /*EXT TDLS*/
18032
18033 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018034 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18036 " %s TDLS set callback Failed",
18037 __func__);
18038 return -EINVAL;
18039 }
18040
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018041 mutex_unlock(&pHddCtx->tdls_lock);
18042
Atul Mittal115287b2014-07-08 13:26:33 +053018043 return(0);
18044
18045}
18046
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018047int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
18048#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18049 const u8 *peer
18050#else
18051 u8 *peer
18052#endif
18053)
Atul Mittal115287b2014-07-08 13:26:33 +053018054{
18055
18056 hddTdlsPeer_t *pTdlsPeer;
18057 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018058
Atul Mittal115287b2014-07-08 13:26:33 +053018059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18060 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
18061 __func__, MAC_ADDR_ARRAY(peer));
18062
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018063 if (0 != wlan_hdd_validate_context(pHddCtx)) {
18064 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
18065 return -EINVAL;
18066 }
18067
Atul Mittal115287b2014-07-08 13:26:33 +053018068 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
18069 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
18070
18071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018072 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
18073 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
18074 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053018075 return -ENOTSUPP;
18076 }
18077
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018078 mutex_lock(&pHddCtx->tdls_lock);
18079 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053018080
18081 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018082 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018083 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018084 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053018085 __func__, MAC_ADDR_ARRAY(peer));
18086 return -EINVAL;
18087 }
18088 else {
18089 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
18090 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053018091 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
18092 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018093 /* if channel switch is configured, reset
18094 the channel for this peer */
18095 if (TRUE == pTdlsPeer->isOffChannelConfigured)
18096 {
18097 pTdlsPeer->peerParams.channel = 0;
18098 pTdlsPeer->isOffChannelConfigured = FALSE;
18099 }
Atul Mittal115287b2014-07-08 13:26:33 +053018100 }
18101
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018102 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018103 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053018105 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018106 }
Atul Mittal115287b2014-07-08 13:26:33 +053018107
18108 /*EXT TDLS*/
18109
18110 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018111 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053018112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18113 " %s TDLS set callback Failed",
18114 __func__);
18115 return -EINVAL;
18116 }
Atul Mittal115287b2014-07-08 13:26:33 +053018117
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018118 mutex_unlock(&pHddCtx->tdls_lock);
18119
18120 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053018121}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018122static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018123#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18124 const u8 *peer,
18125#else
18126 u8 *peer,
18127#endif
18128 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018129{
18130 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18131 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018132 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018133 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018134
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018135 ENTER();
18136
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053018137 if (!pAdapter) {
18138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
18139 return -EINVAL;
18140 }
18141
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018142 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18143 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
18144 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018145 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018146 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070018148 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018149 return -EINVAL;
18150 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018151
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018152 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018153 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018154 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018155 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018156 }
18157
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018158
18159 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018160 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018161 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018163 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
18164 "Cannot process TDLS commands",
18165 pHddCtx->cfg_ini->fEnableTDLSSupport,
18166 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018167 return -ENOTSUPP;
18168 }
18169
18170 switch (oper) {
18171 case NL80211_TDLS_ENABLE_LINK:
18172 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018173 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018174 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053018175 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
18176 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053018177 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018178 tANI_U16 numCurrTdlsPeers = 0;
18179 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018180 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018181 tSirMacAddr peerMac;
18182 int channel;
18183 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018184
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18186 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
18187 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018188
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018189 mutex_lock(&pHddCtx->tdls_lock);
18190 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018191 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053018192 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018193 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018194 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18195 " (oper %d) not exsting. ignored",
18196 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18197 return -EINVAL;
18198 }
18199
18200 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18201 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18202 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18203 "NL80211_TDLS_ENABLE_LINK");
18204
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018205 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
18206 {
18207 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
18208 MAC_ADDRESS_STR " failed",
18209 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018210 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018211 return -EINVAL;
18212 }
18213
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018214 /* before starting tdls connection, set tdls
18215 * off channel established status to default value */
18216 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018217
18218 mutex_unlock(&pHddCtx->tdls_lock);
18219
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053018220 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018221 /* TDLS Off Channel, Disable tdls channel switch,
18222 when there are more than one tdls link */
18223 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053018224 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018225 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018226 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018227 /* get connected peer and send disable tdls off chan */
18228 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018229 if ((connPeer) &&
18230 (connPeer->isOffChannelSupported == TRUE) &&
18231 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018232 {
18233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18234 "%s: More then one peer connected, Disable "
18235 "TDLS channel switch", __func__);
18236
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018237 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018238 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
18239 channel = connPeer->peerParams.channel;
18240
18241 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018242
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018243 ret = sme_SendTdlsChanSwitchReq(
18244 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018245 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018246 peerMac,
18247 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018248 TDLS_OFF_CHANNEL_BW_OFFSET,
18249 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018250 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018251 hddLog(VOS_TRACE_LEVEL_ERROR,
18252 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018253 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018254 }
18255 else
18256 {
18257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18258 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018259 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018260 "isOffChannelConfigured %d",
18261 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018262 (connPeer ? (connPeer->isOffChannelSupported)
18263 : -1),
18264 (connPeer ? (connPeer->isOffChannelConfigured)
18265 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018266 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018267 }
18268 }
18269
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018270 mutex_lock(&pHddCtx->tdls_lock);
18271 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18272 if ( NULL == pTdlsPeer ) {
18273 mutex_unlock(&pHddCtx->tdls_lock);
18274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18275 "%s: " MAC_ADDRESS_STR
18276 " (oper %d) peer got freed in other context. ignored",
18277 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18278 return -EINVAL;
18279 }
18280 peer_status = pTdlsPeer->link_status;
18281 mutex_unlock(&pHddCtx->tdls_lock);
18282
18283 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018284 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018285 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053018286
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018287 if (0 != wlan_hdd_tdls_get_link_establish_params(
18288 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018290 return -EINVAL;
18291 }
18292 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018293
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018294 ret = sme_SendTdlsLinkEstablishParams(
18295 WLAN_HDD_GET_HAL_CTX(pAdapter),
18296 pAdapter->sessionId, peer,
18297 &tdlsLinkEstablishParams);
18298 if (ret != VOS_STATUS_SUCCESS) {
18299 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
18300 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018301 /* Send TDLS peer UAPSD capabilities to the firmware and
18302 * register with the TL on after the response for this operation
18303 * is received .
18304 */
18305 ret = wait_for_completion_interruptible_timeout(
18306 &pAdapter->tdls_link_establish_req_comp,
18307 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053018308
18309 mutex_lock(&pHddCtx->tdls_lock);
18310 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18311 if ( NULL == pTdlsPeer ) {
18312 mutex_unlock(&pHddCtx->tdls_lock);
18313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18314 "%s %d: " MAC_ADDRESS_STR
18315 " (oper %d) peer got freed in other context. ignored",
18316 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
18317 (int)oper);
18318 return -EINVAL;
18319 }
18320 peer_status = pTdlsPeer->link_status;
18321 mutex_unlock(&pHddCtx->tdls_lock);
18322
18323 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018324 {
18325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018326 FL("Link Establish Request Failed Status %ld"),
18327 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018328 return -EINVAL;
18329 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018330 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018331
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018332 mutex_lock(&pHddCtx->tdls_lock);
18333 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18334 if ( NULL == pTdlsPeer ) {
18335 mutex_unlock(&pHddCtx->tdls_lock);
18336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18337 "%s: " MAC_ADDRESS_STR
18338 " (oper %d) peer got freed in other context. ignored",
18339 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18340 return -EINVAL;
18341 }
18342
Atul Mittal115287b2014-07-08 13:26:33 +053018343 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18344 eTDLS_LINK_CONNECTED,
18345 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018346 staDesc.ucSTAId = pTdlsPeer->staId;
18347 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018348
18349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18350 "%s: tdlsLinkEstablishParams of peer "
18351 MAC_ADDRESS_STR "uapsdQueues: %d"
18352 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18353 "isResponder: %d peerstaId: %d",
18354 __func__,
18355 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18356 tdlsLinkEstablishParams.uapsdQueues,
18357 tdlsLinkEstablishParams.qos,
18358 tdlsLinkEstablishParams.maxSp,
18359 tdlsLinkEstablishParams.isBufSta,
18360 tdlsLinkEstablishParams.isOffChannelSupported,
18361 tdlsLinkEstablishParams.isResponder,
18362 pTdlsPeer->staId);
18363
18364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18365 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18366 __func__,
18367 staDesc.ucSTAId,
18368 staDesc.ucQosEnabled);
18369
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018370 ret = WLANTL_UpdateTdlsSTAClient(
18371 pHddCtx->pvosContext,
18372 &staDesc);
18373 if (ret != VOS_STATUS_SUCCESS) {
18374 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18375 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018376
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018377 /* Mark TDLS client Authenticated .*/
18378 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18379 pTdlsPeer->staId,
18380 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018381 if (VOS_STATUS_SUCCESS == status)
18382 {
Hoonki Lee14621352013-04-16 17:51:19 -070018383 if (pTdlsPeer->is_responder == 0)
18384 {
18385 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018386 tdlsConnInfo_t *tdlsInfo;
18387
18388 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18389
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018390 if (!vos_timer_is_initialized(
18391 &pTdlsPeer->initiatorWaitTimeoutTimer))
18392 {
18393 /* Initialize initiator wait callback */
18394 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018395 &pTdlsPeer->initiatorWaitTimeoutTimer,
18396 VOS_TIMER_TYPE_SW,
18397 wlan_hdd_tdls_initiator_wait_cb,
18398 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018399 }
Hoonki Lee14621352013-04-16 17:51:19 -070018400 wlan_hdd_tdls_timer_restart(pAdapter,
18401 &pTdlsPeer->initiatorWaitTimeoutTimer,
18402 WAIT_TIME_TDLS_INITIATOR);
18403 /* suspend initiator TX until it receives direct packet from the
18404 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018405 ret = WLANTL_SuspendDataTx(
18406 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18407 &staId, NULL);
18408 if (ret != VOS_STATUS_SUCCESS) {
18409 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18410 }
Hoonki Lee14621352013-04-16 17:51:19 -070018411 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018412
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018413 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018414 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018415 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018416 suppChannelLen =
18417 tdlsLinkEstablishParams.supportedChannelsLen;
18418
18419 if ((suppChannelLen > 0) &&
18420 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18421 {
18422 tANI_U8 suppPeerChannel = 0;
18423 int i = 0;
18424 for (i = 0U; i < suppChannelLen; i++)
18425 {
18426 suppPeerChannel =
18427 tdlsLinkEstablishParams.supportedChannels[i];
18428
18429 pTdlsPeer->isOffChannelSupported = FALSE;
18430 if (suppPeerChannel ==
18431 pTdlsPeer->peerParams.channel)
18432 {
18433 pTdlsPeer->isOffChannelSupported = TRUE;
18434 break;
18435 }
18436 }
18437 }
18438 else
18439 {
18440 pTdlsPeer->isOffChannelSupported = FALSE;
18441 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018442 }
18443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18444 "%s: TDLS channel switch request for channel "
18445 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018446 "%d isOffChannelSupported %d", __func__,
18447 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018448 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018449 suppChannelLen,
18450 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018451
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018452 /* TDLS Off Channel, Enable tdls channel switch,
18453 when their is only one tdls link and it supports */
18454 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18455 if ((numCurrTdlsPeers == 1) &&
18456 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18457 (TRUE == pTdlsPeer->isOffChannelConfigured))
18458 {
18459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18460 "%s: Send TDLS channel switch request for channel %d",
18461 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018462
18463 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018464 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18465 channel = pTdlsPeer->peerParams.channel;
18466
18467 mutex_unlock(&pHddCtx->tdls_lock);
18468
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018469 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18470 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018471 peerMac,
18472 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018473 TDLS_OFF_CHANNEL_BW_OFFSET,
18474 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018475 if (ret != VOS_STATUS_SUCCESS) {
18476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18477 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018478 }
18479 else
18480 {
18481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18482 "%s: TDLS channel switch request not sent"
18483 " numCurrTdlsPeers %d "
18484 "isOffChannelSupported %d "
18485 "isOffChannelConfigured %d",
18486 __func__, numCurrTdlsPeers,
18487 pTdlsPeer->isOffChannelSupported,
18488 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018489 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018490 }
18491
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018492 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018493 else
18494 mutex_unlock(&pHddCtx->tdls_lock);
18495
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018496 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018497
18498 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018499 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18500 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018501 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018502 int ac;
18503 uint8 ucAc[4] = { WLANTL_AC_VO,
18504 WLANTL_AC_VI,
18505 WLANTL_AC_BK,
18506 WLANTL_AC_BE };
18507 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18508 for(ac=0; ac < 4; ac++)
18509 {
18510 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18511 pTdlsPeer->staId, ucAc[ac],
18512 tlTid[ac], tlTid[ac], 0, 0,
18513 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018514 if (status != VOS_STATUS_SUCCESS) {
18515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18516 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018517 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018518 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018519 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018520
Bhargav Shah66896792015-10-01 18:17:37 +053018521 /* stop TCP delack timer if TDLS is enable */
18522 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18523 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053018524 hdd_wlan_tdls_enable_link_event(peer,
18525 pTdlsPeer->isOffChannelSupported,
18526 pTdlsPeer->isOffChannelConfigured,
18527 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018528 }
18529 break;
18530 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018531 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018532 tANI_U16 numCurrTdlsPeers = 0;
18533 hddTdlsPeer_t *connPeer = NULL;
18534
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18536 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18537 __func__, MAC_ADDR_ARRAY(peer));
18538
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018539 mutex_lock(&pHddCtx->tdls_lock);
18540 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018541
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018542
Sunil Dutt41de4e22013-11-14 18:09:02 +053018543 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018544 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018545 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18546 " (oper %d) not exsting. ignored",
18547 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18548 return -EINVAL;
18549 }
18550
18551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18552 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18553 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18554 "NL80211_TDLS_DISABLE_LINK");
18555
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018556 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018557 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018558 long status;
18559
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018560 /* set tdls off channel status to false for this peer */
18561 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018562 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18563 eTDLS_LINK_TEARING,
18564 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18565 eTDLS_LINK_UNSPECIFIED:
18566 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018567 mutex_unlock(&pHddCtx->tdls_lock);
18568
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018569 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18570
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018571 status = sme_DeleteTdlsPeerSta(
18572 WLAN_HDD_GET_HAL_CTX(pAdapter),
18573 pAdapter->sessionId, peer );
18574 if (status != VOS_STATUS_SUCCESS) {
18575 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18576 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018577
18578 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18579 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018580
18581 mutex_lock(&pHddCtx->tdls_lock);
18582 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18583 if ( NULL == pTdlsPeer ) {
18584 mutex_unlock(&pHddCtx->tdls_lock);
18585 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18586 " peer was freed in other context",
18587 __func__, MAC_ADDR_ARRAY(peer));
18588 return -EINVAL;
18589 }
18590
Atul Mittal271a7652014-09-12 13:18:22 +053018591 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018592 eTDLS_LINK_IDLE,
18593 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018594 mutex_unlock(&pHddCtx->tdls_lock);
18595
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018596 if (status <= 0)
18597 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18599 "%s: Del station failed status %ld",
18600 __func__, status);
18601 return -EPERM;
18602 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018603
18604 /* TDLS Off Channel, Enable tdls channel switch,
18605 when their is only one tdls link and it supports */
18606 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18607 if (numCurrTdlsPeers == 1)
18608 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018609 tSirMacAddr peerMac;
18610 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018611
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018612 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018613 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018614
18615 if (connPeer == NULL) {
18616 mutex_unlock(&pHddCtx->tdls_lock);
18617 hddLog(VOS_TRACE_LEVEL_ERROR,
18618 "%s connPeer is NULL", __func__);
18619 return -EINVAL;
18620 }
18621
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018622 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
18623 channel = connPeer->peerParams.channel;
18624
18625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18626 "%s: TDLS channel switch "
18627 "isOffChannelSupported %d "
18628 "isOffChannelConfigured %d "
18629 "isOffChannelEstablished %d",
18630 __func__,
18631 (connPeer ? connPeer->isOffChannelSupported : -1),
18632 (connPeer ? connPeer->isOffChannelConfigured : -1),
18633 (connPeer ? connPeer->isOffChannelEstablished : -1));
18634
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018635 if ((connPeer) &&
18636 (connPeer->isOffChannelSupported == TRUE) &&
18637 (connPeer->isOffChannelConfigured == TRUE))
18638 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018639 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018640 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018641 status = sme_SendTdlsChanSwitchReq(
18642 WLAN_HDD_GET_HAL_CTX(pAdapter),
18643 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018644 peerMac,
18645 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018646 TDLS_OFF_CHANNEL_BW_OFFSET,
18647 TDLS_CHANNEL_SWITCH_ENABLE);
18648 if (status != VOS_STATUS_SUCCESS) {
18649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
18650 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018651 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018652 else
18653 mutex_unlock(&pHddCtx->tdls_lock);
18654 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018655 else
18656 {
18657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18658 "%s: TDLS channel switch request not sent "
18659 "numCurrTdlsPeers %d ",
18660 __func__, numCurrTdlsPeers);
18661 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018662 }
18663 else
18664 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018665 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18667 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080018668 }
Bhargav Shah66896792015-10-01 18:17:37 +053018669 if (numCurrTdlsPeers == 0) {
18670 /* start TCP delack timer if TDLS is disable */
18671 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18672 hdd_manage_delack_timer(pHddCtx);
18673 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018674 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018675 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018676 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018677 {
Atul Mittal115287b2014-07-08 13:26:33 +053018678 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018679
Atul Mittal115287b2014-07-08 13:26:33 +053018680 if (0 != status)
18681 {
18682 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018683 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053018684 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018685 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053018686 break;
18687 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018688 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018689 {
Atul Mittal115287b2014-07-08 13:26:33 +053018690 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
18691 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018692 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053018693 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018694
Atul Mittal115287b2014-07-08 13:26:33 +053018695 if (0 != status)
18696 {
18697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018698 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053018699 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053018700 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053018701 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018702 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018703 case NL80211_TDLS_DISCOVERY_REQ:
18704 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018706 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018707 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018708 return -ENOTSUPP;
18709 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18711 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018712 return -ENOTSUPP;
18713 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018714
18715 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018716 return 0;
18717}
Chilam NG571c65a2013-01-19 12:27:36 +053018718
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018719static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18721 const u8 *peer,
18722#else
18723 u8 *peer,
18724#endif
18725 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018726{
18727 int ret;
18728
18729 vos_ssr_protect(__func__);
18730 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
18731 vos_ssr_unprotect(__func__);
18732
18733 return ret;
18734}
18735
Chilam NG571c65a2013-01-19 12:27:36 +053018736int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
18737 struct net_device *dev, u8 *peer)
18738{
Arif Hussaina7c8e412013-11-20 11:06:42 -080018739 hddLog(VOS_TRACE_LEVEL_INFO,
18740 "tdls send discover req: "MAC_ADDRESS_STR,
18741 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018742#if TDLS_MGMT_VERSION2
18743 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18744 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18745#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018746#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18747 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18748 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
18749#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18750 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18751 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18752#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18753 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18754 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18755#else
Chilam NG571c65a2013-01-19 12:27:36 +053018756 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18757 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018758#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018759#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053018760}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018761#endif
18762
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018763#ifdef WLAN_FEATURE_GTK_OFFLOAD
18764/*
18765 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
18766 * Callback rountine called upon receiving response for
18767 * get offload info
18768 */
18769void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
18770 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
18771{
18772
18773 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018774 tANI_U8 tempReplayCounter[8];
18775 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018776
18777 ENTER();
18778
18779 if (NULL == pAdapter)
18780 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053018781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018782 "%s: HDD adapter is Null", __func__);
18783 return ;
18784 }
18785
18786 if (NULL == pGtkOffloadGetInfoRsp)
18787 {
18788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18789 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
18790 return ;
18791 }
18792
18793 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
18794 {
18795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18796 "%s: wlan Failed to get replay counter value",
18797 __func__);
18798 return ;
18799 }
18800
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018801 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18802 /* Update replay counter */
18803 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
18804 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18805
18806 {
18807 /* changing from little to big endian since supplicant
18808 * works on big endian format
18809 */
18810 int i;
18811 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18812
18813 for (i = 0; i < 8; i++)
18814 {
18815 tempReplayCounter[7-i] = (tANI_U8)p[i];
18816 }
18817 }
18818
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018819 /* Update replay counter to NL */
18820 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018821 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018822}
18823
18824/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018825 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018826 * This function is used to offload GTK rekeying job to the firmware.
18827 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018828int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018829 struct cfg80211_gtk_rekey_data *data)
18830{
18831 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18832 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18833 hdd_station_ctx_t *pHddStaCtx;
18834 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018835 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018836 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018837 eHalStatus status = eHAL_STATUS_FAILURE;
18838
18839 ENTER();
18840
18841 if (NULL == pAdapter)
18842 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018844 "%s: HDD adapter is Null", __func__);
18845 return -ENODEV;
18846 }
18847
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018848 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18849 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
18850 pAdapter->sessionId, pAdapter->device_mode));
18851
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018852 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018853 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018854 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018855 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018856 }
18857
18858 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18859 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18860 if (NULL == hHal)
18861 {
18862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18863 "%s: HAL context is Null!!!", __func__);
18864 return -EAGAIN;
18865 }
18866
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018867 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
18868 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
18869 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
18870 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018871 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018872 {
18873 /* changing from big to little endian since driver
18874 * works on little endian format
18875 */
18876 tANI_U8 *p =
18877 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
18878 int i;
18879
18880 for (i = 0; i < 8; i++)
18881 {
18882 p[7-i] = data->replay_ctr[i];
18883 }
18884 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018885
18886 if (TRUE == pHddCtx->hdd_wlan_suspended)
18887 {
18888 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018889 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
18890 sizeof (tSirGtkOffloadParams));
18891 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018892 pAdapter->sessionId);
18893
18894 if (eHAL_STATUS_SUCCESS != status)
18895 {
18896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18897 "%s: sme_SetGTKOffload failed, returned %d",
18898 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018899
18900 /* Need to clear any trace of key value in the memory.
18901 * Thus zero out the memory even though it is local
18902 * variable.
18903 */
18904 vos_mem_zero(&hddGtkOffloadReqParams,
18905 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018906 return status;
18907 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18909 "%s: sme_SetGTKOffload successfull", __func__);
18910 }
18911 else
18912 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18914 "%s: wlan not suspended GTKOffload request is stored",
18915 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018916 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018917
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018918 /* Need to clear any trace of key value in the memory.
18919 * Thus zero out the memory even though it is local
18920 * variable.
18921 */
18922 vos_mem_zero(&hddGtkOffloadReqParams,
18923 sizeof(hddGtkOffloadReqParams));
18924
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018925 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018926 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018927}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018928
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018929int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
18930 struct cfg80211_gtk_rekey_data *data)
18931{
18932 int ret;
18933
18934 vos_ssr_protect(__func__);
18935 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
18936 vos_ssr_unprotect(__func__);
18937
18938 return ret;
18939}
18940#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018941/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018942 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018943 * This function is used to set access control policy
18944 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018945static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18946 struct net_device *dev,
18947 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018948{
18949 int i;
18950 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18951 hdd_hostapd_state_t *pHostapdState;
18952 tsap_Config_t *pConfig;
18953 v_CONTEXT_t pVosContext = NULL;
18954 hdd_context_t *pHddCtx;
18955 int status;
18956
18957 ENTER();
18958
18959 if (NULL == pAdapter)
18960 {
18961 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18962 "%s: HDD adapter is Null", __func__);
18963 return -ENODEV;
18964 }
18965
18966 if (NULL == params)
18967 {
18968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18969 "%s: params is Null", __func__);
18970 return -EINVAL;
18971 }
18972
18973 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18974 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018975 if (0 != status)
18976 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018977 return status;
18978 }
18979
18980 pVosContext = pHddCtx->pvosContext;
18981 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
18982
18983 if (NULL == pHostapdState)
18984 {
18985 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18986 "%s: pHostapdState is Null", __func__);
18987 return -EINVAL;
18988 }
18989
18990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
18991 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018992 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18993 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
18994 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018995
18996 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
18997 {
18998 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
18999
19000 /* default value */
19001 pConfig->num_accept_mac = 0;
19002 pConfig->num_deny_mac = 0;
19003
19004 /**
19005 * access control policy
19006 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
19007 * listed in hostapd.deny file.
19008 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
19009 * listed in hostapd.accept file.
19010 */
19011 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
19012 {
19013 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
19014 }
19015 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
19016 {
19017 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
19018 }
19019 else
19020 {
19021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19022 "%s:Acl Policy : %d is not supported",
19023 __func__, params->acl_policy);
19024 return -ENOTSUPP;
19025 }
19026
19027 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
19028 {
19029 pConfig->num_accept_mac = params->n_acl_entries;
19030 for (i = 0; i < params->n_acl_entries; i++)
19031 {
19032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19033 "** Add ACL MAC entry %i in WhiletList :"
19034 MAC_ADDRESS_STR, i,
19035 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19036
19037 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
19038 sizeof(qcmacaddr));
19039 }
19040 }
19041 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
19042 {
19043 pConfig->num_deny_mac = params->n_acl_entries;
19044 for (i = 0; i < params->n_acl_entries; i++)
19045 {
19046 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19047 "** Add ACL MAC entry %i in BlackList :"
19048 MAC_ADDRESS_STR, i,
19049 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
19050
19051 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
19052 sizeof(qcmacaddr));
19053 }
19054 }
19055
19056 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
19057 {
19058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19059 "%s: SAP Set Mac Acl fail", __func__);
19060 return -EINVAL;
19061 }
19062 }
19063 else
19064 {
19065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053019066 "%s: Invalid device_mode = %s (%d)",
19067 __func__, hdd_device_modetoString(pAdapter->device_mode),
19068 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019069 return -EINVAL;
19070 }
19071
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019072 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019073 return 0;
19074}
19075
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053019076static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
19077 struct net_device *dev,
19078 const struct cfg80211_acl_data *params)
19079{
19080 int ret;
19081 vos_ssr_protect(__func__);
19082 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
19083 vos_ssr_unprotect(__func__);
19084
19085 return ret;
19086}
19087
Leo Chang9056f462013-08-01 19:21:11 -070019088#ifdef WLAN_NL80211_TESTMODE
19089#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070019090void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070019091(
19092 void *pAdapter,
19093 void *indCont
19094)
19095{
Leo Changd9df8aa2013-09-26 13:32:26 -070019096 tSirLPHBInd *lphbInd;
19097 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053019098 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070019099
19100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019101 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070019102
c_hpothu73f35e62014-04-18 13:40:08 +053019103 if (pAdapter == NULL)
19104 {
19105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19106 "%s: pAdapter is NULL\n",__func__);
19107 return;
19108 }
19109
Leo Chang9056f462013-08-01 19:21:11 -070019110 if (NULL == indCont)
19111 {
19112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070019113 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070019114 return;
19115 }
19116
c_hpothu73f35e62014-04-18 13:40:08 +053019117 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070019118 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070019119 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053019120 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070019121 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070019122 GFP_ATOMIC);
19123 if (!skb)
19124 {
19125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19126 "LPHB timeout, NL buffer alloc fail");
19127 return;
19128 }
19129
Leo Changac3ba772013-10-07 09:47:04 -070019130 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070019131 {
19132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19133 "WLAN_HDD_TM_ATTR_CMD put fail");
19134 goto nla_put_failure;
19135 }
Leo Changac3ba772013-10-07 09:47:04 -070019136 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070019137 {
19138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19139 "WLAN_HDD_TM_ATTR_TYPE put fail");
19140 goto nla_put_failure;
19141 }
Leo Changac3ba772013-10-07 09:47:04 -070019142 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070019143 sizeof(tSirLPHBInd), lphbInd))
19144 {
19145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19146 "WLAN_HDD_TM_ATTR_DATA put fail");
19147 goto nla_put_failure;
19148 }
Leo Chang9056f462013-08-01 19:21:11 -070019149 cfg80211_testmode_event(skb, GFP_ATOMIC);
19150 return;
19151
19152nla_put_failure:
19153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19154 "NLA Put fail");
19155 kfree_skb(skb);
19156
19157 return;
19158}
19159#endif /* FEATURE_WLAN_LPHB */
19160
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019161static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070019162{
19163 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
19164 int err = 0;
19165#ifdef FEATURE_WLAN_LPHB
19166 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070019167 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019168
19169 ENTER();
19170
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019171 err = wlan_hdd_validate_context(pHddCtx);
19172 if (0 != err)
19173 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019174 return err;
19175 }
Leo Chang9056f462013-08-01 19:21:11 -070019176#endif /* FEATURE_WLAN_LPHB */
19177
19178 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
19179 if (err)
19180 {
19181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19182 "%s Testmode INV ATTR", __func__);
19183 return err;
19184 }
19185
19186 if (!tb[WLAN_HDD_TM_ATTR_CMD])
19187 {
19188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19189 "%s Testmode INV CMD", __func__);
19190 return -EINVAL;
19191 }
19192
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019193 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19194 TRACE_CODE_HDD_CFG80211_TESTMODE,
19195 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070019196 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
19197 {
19198#ifdef FEATURE_WLAN_LPHB
19199 /* Low Power Heartbeat configuration request */
19200 case WLAN_HDD_TM_CMD_WLAN_HB:
19201 {
19202 int buf_len;
19203 void *buf;
19204 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080019205 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070019206
19207 if (!tb[WLAN_HDD_TM_ATTR_DATA])
19208 {
19209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19210 "%s Testmode INV DATA", __func__);
19211 return -EINVAL;
19212 }
19213
19214 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
19215 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080019216
19217 hb_params_temp =(tSirLPHBReq *)buf;
19218 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
19219 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
19220 return -EINVAL;
19221
Leo Chang9056f462013-08-01 19:21:11 -070019222 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
19223 if (NULL == hb_params)
19224 {
19225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19226 "%s Request Buffer Alloc Fail", __func__);
19227 return -EINVAL;
19228 }
19229
19230 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070019231 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
19232 hb_params,
19233 wlan_hdd_cfg80211_lphb_ind_handler);
19234 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070019235 {
Leo Changd9df8aa2013-09-26 13:32:26 -070019236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19237 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070019238 vos_mem_free(hb_params);
19239 }
Leo Chang9056f462013-08-01 19:21:11 -070019240 return 0;
19241 }
19242#endif /* FEATURE_WLAN_LPHB */
19243 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19245 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070019246 return -EOPNOTSUPP;
19247 }
19248
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019249 EXIT();
19250 return err;
Leo Chang9056f462013-08-01 19:21:11 -070019251}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019252
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053019253static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
19254#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
19255 struct wireless_dev *wdev,
19256#endif
19257 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019258{
19259 int ret;
19260
19261 vos_ssr_protect(__func__);
19262 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
19263 vos_ssr_unprotect(__func__);
19264
19265 return ret;
19266}
Leo Chang9056f462013-08-01 19:21:11 -070019267#endif /* CONFIG_NL80211_TESTMODE */
19268
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019269static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019270 struct net_device *dev,
19271 int idx, struct survey_info *survey)
19272{
19273 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19274 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053019275 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019276 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053019277 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019278 v_S7_t snr,rssi;
19279 int status, i, j, filled = 0;
19280
19281 ENTER();
19282
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019283 if (NULL == pAdapter)
19284 {
19285 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19286 "%s: HDD adapter is Null", __func__);
19287 return -ENODEV;
19288 }
19289
19290 if (NULL == wiphy)
19291 {
19292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19293 "%s: wiphy is Null", __func__);
19294 return -ENODEV;
19295 }
19296
19297 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19298 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019299 if (0 != status)
19300 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019301 return status;
19302 }
19303
Mihir Sheted9072e02013-08-21 17:02:29 +053019304 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19305
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019306 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053019307 0 != pAdapter->survey_idx ||
19308 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019309 {
19310 /* The survey dump ops when implemented completely is expected to
19311 * return a survey of all channels and the ops is called by the
19312 * kernel with incremental values of the argument 'idx' till it
19313 * returns -ENONET. But we can only support the survey for the
19314 * operating channel for now. survey_idx is used to track
19315 * that the ops is called only once and then return -ENONET for
19316 * the next iteration
19317 */
19318 pAdapter->survey_idx = 0;
19319 return -ENONET;
19320 }
19321
Mukul Sharma9d5233b2015-06-11 20:28:20 +053019322 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
19323 {
19324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19325 "%s: Roaming in progress, hence return ", __func__);
19326 return -ENONET;
19327 }
19328
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019329 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19330
19331 wlan_hdd_get_snr(pAdapter, &snr);
19332 wlan_hdd_get_rssi(pAdapter, &rssi);
19333
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019334 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19335 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
19336 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019337 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
19338 hdd_wlan_get_freq(channel, &freq);
19339
19340
19341 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
19342 {
19343 if (NULL == wiphy->bands[i])
19344 {
19345 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19346 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19347 continue;
19348 }
19349
19350 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19351 {
19352 struct ieee80211_supported_band *band = wiphy->bands[i];
19353
19354 if (band->channels[j].center_freq == (v_U16_t)freq)
19355 {
19356 survey->channel = &band->channels[j];
19357 /* The Rx BDs contain SNR values in dB for the received frames
19358 * while the supplicant expects noise. So we calculate and
19359 * return the value of noise (dBm)
19360 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19361 */
19362 survey->noise = rssi - snr;
19363 survey->filled = SURVEY_INFO_NOISE_DBM;
19364 filled = 1;
19365 }
19366 }
19367 }
19368
19369 if (filled)
19370 pAdapter->survey_idx = 1;
19371 else
19372 {
19373 pAdapter->survey_idx = 0;
19374 return -ENONET;
19375 }
19376
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019377 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019378 return 0;
19379}
19380
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019381static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19382 struct net_device *dev,
19383 int idx, struct survey_info *survey)
19384{
19385 int ret;
19386
19387 vos_ssr_protect(__func__);
19388 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19389 vos_ssr_unprotect(__func__);
19390
19391 return ret;
19392}
19393
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019394/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019395 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019396 * this is called when cfg80211 driver resume
19397 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19398 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019399int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019400{
19401 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19402 hdd_adapter_t *pAdapter;
19403 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19404 VOS_STATUS status = VOS_STATUS_SUCCESS;
19405
19406 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019407
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019408 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019409 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019410 return 0;
19411 }
19412
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019413 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19414 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019415 spin_lock(&pHddCtx->schedScan_lock);
19416 pHddCtx->isWiphySuspended = FALSE;
19417 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19418 {
19419 spin_unlock(&pHddCtx->schedScan_lock);
19420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19421 "%s: Return resume is not due to PNO indication", __func__);
19422 return 0;
19423 }
19424 // Reset flag to avoid updatating cfg80211 data old results again
19425 pHddCtx->isSchedScanUpdatePending = FALSE;
19426 spin_unlock(&pHddCtx->schedScan_lock);
19427
19428 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19429
19430 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19431 {
19432 pAdapter = pAdapterNode->pAdapter;
19433 if ( (NULL != pAdapter) &&
19434 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19435 {
19436 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019437 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19439 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019440 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019441 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019442 {
19443 /* Acquire wakelock to handle the case where APP's tries to
19444 * suspend immediately after updating the scan results. Whis
19445 * results in app's is in suspended state and not able to
19446 * process the connect request to AP
19447 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019448 hdd_prevent_suspend_timeout(2000,
19449 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019450 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019451 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019452
19453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19454 "%s : cfg80211 scan result database updated", __func__);
19455
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019456 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019457 return 0;
19458
19459 }
19460 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19461 pAdapterNode = pNext;
19462 }
19463
19464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19465 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019466 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019467 return 0;
19468}
19469
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019470int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19471{
19472 int ret;
19473
19474 vos_ssr_protect(__func__);
19475 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19476 vos_ssr_unprotect(__func__);
19477
19478 return ret;
19479}
19480
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019481/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019482 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019483 * this is called when cfg80211 driver suspends
19484 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019485int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019486 struct cfg80211_wowlan *wow)
19487{
19488 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019489 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019490
19491 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019492
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019493 ret = wlan_hdd_validate_context(pHddCtx);
19494 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019495 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019496 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019497 }
19498
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019499
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019500 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19501 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19502 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019503 pHddCtx->isWiphySuspended = TRUE;
19504
19505 EXIT();
19506
19507 return 0;
19508}
19509
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019510int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19511 struct cfg80211_wowlan *wow)
19512{
19513 int ret;
19514
19515 vos_ssr_protect(__func__);
19516 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19517 vos_ssr_unprotect(__func__);
19518
19519 return ret;
19520}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019521
19522#ifdef FEATURE_OEM_DATA_SUPPORT
19523static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019524 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019525{
19526 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19527
19528 ENTER();
19529
19530 if (wlan_hdd_validate_context(pHddCtx)) {
19531 return;
19532 }
19533 if (!pMsg)
19534 {
19535 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19536 return;
19537 }
19538
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019539 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019540
19541 EXIT();
19542 return;
19543
19544}
19545
19546void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019547 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019548{
19549 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19550
19551 ENTER();
19552
19553 if (wlan_hdd_validate_context(pHddCtx)) {
19554 return;
19555 }
19556
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019557 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019558
19559 switch(evType) {
19560 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019561 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019562 break;
19563 default:
19564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19565 break;
19566 }
19567 EXIT();
19568}
19569#endif
19570
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019571#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19572 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019573/**
19574 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
19575 * @wiphy: Pointer to wiphy
19576 * @wdev: Pointer to wireless device structure
19577 *
19578 * This function is used to abort an ongoing scan
19579 *
19580 * Return: None
19581 */
19582static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19583 struct wireless_dev *wdev)
19584{
19585 struct net_device *dev = wdev->netdev;
19586 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19587 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19588 int ret;
19589
19590 ENTER();
19591
19592 if (NULL == adapter) {
19593 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
19594 return;
19595 }
19596
19597 ret = wlan_hdd_validate_context(hdd_ctx);
19598 if (0 != ret)
19599 return;
19600
19601 wlan_hdd_scan_abort(adapter);
19602
19603 return;
19604}
19605
19606/**
19607 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
19608 * @wiphy: Pointer to wiphy
19609 * @wdev: Pointer to wireless device structure
19610 *
19611 * Return: None
19612 */
19613void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19614 struct wireless_dev *wdev)
19615{
19616 vos_ssr_protect(__func__);
19617 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
19618 vos_ssr_unprotect(__func__);
19619
19620 return;
19621}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019622#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019623
Jeff Johnson295189b2012-06-20 16:38:30 -070019624/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019625static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070019626{
19627 .add_virtual_intf = wlan_hdd_add_virtual_intf,
19628 .del_virtual_intf = wlan_hdd_del_virtual_intf,
19629 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
19630 .change_station = wlan_hdd_change_station,
19631#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
19632 .add_beacon = wlan_hdd_cfg80211_add_beacon,
19633 .del_beacon = wlan_hdd_cfg80211_del_beacon,
19634 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019635#else
19636 .start_ap = wlan_hdd_cfg80211_start_ap,
19637 .change_beacon = wlan_hdd_cfg80211_change_beacon,
19638 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070019639#endif
19640 .change_bss = wlan_hdd_cfg80211_change_bss,
19641 .add_key = wlan_hdd_cfg80211_add_key,
19642 .get_key = wlan_hdd_cfg80211_get_key,
19643 .del_key = wlan_hdd_cfg80211_del_key,
19644 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019645#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070019646 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019647#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019648 .scan = wlan_hdd_cfg80211_scan,
19649 .connect = wlan_hdd_cfg80211_connect,
19650 .disconnect = wlan_hdd_cfg80211_disconnect,
19651 .join_ibss = wlan_hdd_cfg80211_join_ibss,
19652 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
19653 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
19654 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
19655 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070019656 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
19657 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053019658 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070019659#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19660 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
19661 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
19662 .set_txq_params = wlan_hdd_set_txq_params,
19663#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019664 .get_station = wlan_hdd_cfg80211_get_station,
19665 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
19666 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019667 .add_station = wlan_hdd_cfg80211_add_station,
19668#ifdef FEATURE_WLAN_LFR
19669 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
19670 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
19671 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
19672#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019673#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
19674 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
19675#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019676#ifdef FEATURE_WLAN_TDLS
19677 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
19678 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
19679#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019680#ifdef WLAN_FEATURE_GTK_OFFLOAD
19681 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
19682#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019683#ifdef FEATURE_WLAN_SCAN_PNO
19684 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
19685 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
19686#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019687 .resume = wlan_hdd_cfg80211_resume_wlan,
19688 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019689 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070019690#ifdef WLAN_NL80211_TESTMODE
19691 .testmode_cmd = wlan_hdd_cfg80211_testmode,
19692#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019693 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019694#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19695 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019696 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019697#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019698};
19699