blob: 84dd57a6705132eb49a55ecb5d0c3b64136e3903 [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"
Sushant Kaushik084f6592015-09-10 13:11:56 +0530100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101
102#define g_mode_rates_size (12)
103#define a_mode_rates_size (8)
104#define FREQ_BASE_80211G (2407)
105#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700106#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530107#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800109 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700110
111#define HDD2GHZCHAN(freq, chan, flag) { \
112 .band = IEEE80211_BAND_2GHZ, \
113 .center_freq = (freq), \
114 .hw_value = (chan),\
115 .flags = (flag), \
116 .max_antenna_gain = 0 ,\
117 .max_power = 30, \
118}
119
120#define HDD5GHZCHAN(freq, chan, flag) { \
121 .band = IEEE80211_BAND_5GHZ, \
122 .center_freq = (freq), \
123 .hw_value = (chan),\
124 .flags = (flag), \
125 .max_antenna_gain = 0 ,\
126 .max_power = 30, \
127}
128
129#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
130{\
131 .bitrate = rate, \
132 .hw_value = rate_id, \
133 .flags = flag, \
134}
135
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530136#ifdef WLAN_FEATURE_VOWIFI_11R
137#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
138#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
139#endif
140
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530141#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530142#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530143
Sunil Duttc69bccb2014-05-26 21:30:20 +0530144#ifdef WLAN_FEATURE_LINK_LAYER_STATS
145/*
146 * Used to allocate the size of 4096 for the link layer stats.
147 * The size of 4096 is considered assuming that all data per
148 * respective event fit with in the limit.Please take a call
149 * on the limit based on the data requirements on link layer
150 * statistics.
151 */
152#define LL_STATS_EVENT_BUF_SIZE 4096
153#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530154#ifdef WLAN_FEATURE_EXTSCAN
155/*
156 * Used to allocate the size of 4096 for the EXTScan NL data.
157 * The size of 4096 is considered assuming that all data per
158 * respective event fit with in the limit.Please take a call
159 * on the limit based on the data requirements.
160 */
161
162#define EXTSCAN_EVENT_BUF_SIZE 4096
163#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
164#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530165
Atul Mittal115287b2014-07-08 13:26:33 +0530166/*EXT TDLS*/
167/*
168 * Used to allocate the size of 4096 for the TDLS.
169 * The size of 4096 is considered assuming that all data per
170 * respective event fit with in the limit.Please take a call
171 * on the limit based on the data requirements on link layer
172 * statistics.
173 */
174#define EXTTDLS_EVENT_BUF_SIZE 4096
175
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530176/*
177 * Values for Mac spoofing feature
178 *
179 */
180#define MAC_ADDR_SPOOFING_FW_HOST_DISABLE 0
181#define MAC_ADDR_SPOOFING_FW_HOST_ENABLE 1
182#define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE 2
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +0530183#define MAC_ADDR_SPOOFING_DEFER_INTERVAL 10 //in ms
184
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +0530185
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530186static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700187{
188 WLAN_CIPHER_SUITE_WEP40,
189 WLAN_CIPHER_SUITE_WEP104,
190 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800191#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700192#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
193 WLAN_CIPHER_SUITE_KRK,
194 WLAN_CIPHER_SUITE_CCMP,
195#else
196 WLAN_CIPHER_SUITE_CCMP,
197#endif
198#ifdef FEATURE_WLAN_WAPI
199 WLAN_CIPHER_SUITE_SMS4,
200#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700201#ifdef WLAN_FEATURE_11W
202 WLAN_CIPHER_SUITE_AES_CMAC,
203#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700204};
205
206static inline int is_broadcast_ether_addr(const u8 *addr)
207{
208 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
209 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
210}
211
Agrawal Ashish97dec502015-11-26 20:20:58 +0530212const static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530213{
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 HDD2GHZCHAN(2412, 1, 0) ,
215 HDD2GHZCHAN(2417, 2, 0) ,
216 HDD2GHZCHAN(2422, 3, 0) ,
217 HDD2GHZCHAN(2427, 4, 0) ,
218 HDD2GHZCHAN(2432, 5, 0) ,
219 HDD2GHZCHAN(2437, 6, 0) ,
220 HDD2GHZCHAN(2442, 7, 0) ,
221 HDD2GHZCHAN(2447, 8, 0) ,
222 HDD2GHZCHAN(2452, 9, 0) ,
223 HDD2GHZCHAN(2457, 10, 0) ,
224 HDD2GHZCHAN(2462, 11, 0) ,
225 HDD2GHZCHAN(2467, 12, 0) ,
226 HDD2GHZCHAN(2472, 13, 0) ,
227 HDD2GHZCHAN(2484, 14, 0) ,
228};
229
Agrawal Ashish97dec502015-11-26 20:20:58 +0530230const static struct ieee80211_channel hdd_channels_5_GHZ[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700231{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700232 HDD5GHZCHAN(4920, 240, 0) ,
233 HDD5GHZCHAN(4940, 244, 0) ,
234 HDD5GHZCHAN(4960, 248, 0) ,
235 HDD5GHZCHAN(4980, 252, 0) ,
236 HDD5GHZCHAN(5040, 208, 0) ,
237 HDD5GHZCHAN(5060, 212, 0) ,
238 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 HDD5GHZCHAN(5180, 36, 0) ,
240 HDD5GHZCHAN(5200, 40, 0) ,
241 HDD5GHZCHAN(5220, 44, 0) ,
242 HDD5GHZCHAN(5240, 48, 0) ,
243 HDD5GHZCHAN(5260, 52, 0) ,
244 HDD5GHZCHAN(5280, 56, 0) ,
245 HDD5GHZCHAN(5300, 60, 0) ,
246 HDD5GHZCHAN(5320, 64, 0) ,
247 HDD5GHZCHAN(5500,100, 0) ,
248 HDD5GHZCHAN(5520,104, 0) ,
249 HDD5GHZCHAN(5540,108, 0) ,
250 HDD5GHZCHAN(5560,112, 0) ,
251 HDD5GHZCHAN(5580,116, 0) ,
252 HDD5GHZCHAN(5600,120, 0) ,
253 HDD5GHZCHAN(5620,124, 0) ,
254 HDD5GHZCHAN(5640,128, 0) ,
255 HDD5GHZCHAN(5660,132, 0) ,
256 HDD5GHZCHAN(5680,136, 0) ,
257 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800258#ifdef FEATURE_WLAN_CH144
259 HDD5GHZCHAN(5720,144, 0) ,
260#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 HDD5GHZCHAN(5745,149, 0) ,
262 HDD5GHZCHAN(5765,153, 0) ,
263 HDD5GHZCHAN(5785,157, 0) ,
264 HDD5GHZCHAN(5805,161, 0) ,
265 HDD5GHZCHAN(5825,165, 0) ,
266};
267
268static struct ieee80211_rate g_mode_rates[] =
269{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530270 HDD_G_MODE_RATETAB(10, 0x1, 0),
271 HDD_G_MODE_RATETAB(20, 0x2, 0),
272 HDD_G_MODE_RATETAB(55, 0x4, 0),
273 HDD_G_MODE_RATETAB(110, 0x8, 0),
274 HDD_G_MODE_RATETAB(60, 0x10, 0),
275 HDD_G_MODE_RATETAB(90, 0x20, 0),
276 HDD_G_MODE_RATETAB(120, 0x40, 0),
277 HDD_G_MODE_RATETAB(180, 0x80, 0),
278 HDD_G_MODE_RATETAB(240, 0x100, 0),
279 HDD_G_MODE_RATETAB(360, 0x200, 0),
280 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530282};
Jeff Johnson295189b2012-06-20 16:38:30 -0700283
284static struct ieee80211_rate a_mode_rates[] =
285{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530286 HDD_G_MODE_RATETAB(60, 0x10, 0),
287 HDD_G_MODE_RATETAB(90, 0x20, 0),
288 HDD_G_MODE_RATETAB(120, 0x40, 0),
289 HDD_G_MODE_RATETAB(180, 0x80, 0),
290 HDD_G_MODE_RATETAB(240, 0x100, 0),
291 HDD_G_MODE_RATETAB(360, 0x200, 0),
292 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 HDD_G_MODE_RATETAB(540, 0x800, 0),
294};
295
296static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
297{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530298 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
300 .band = IEEE80211_BAND_2GHZ,
301 .bitrates = g_mode_rates,
302 .n_bitrates = g_mode_rates_size,
303 .ht_cap.ht_supported = 1,
304 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
305 | IEEE80211_HT_CAP_GRN_FLD
306 | IEEE80211_HT_CAP_DSSSCCK40
307 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
308 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
309 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
310 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
311 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
312 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
313};
314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
316{
Agrawal Ashish97dec502015-11-26 20:20:58 +0530317 .channels = NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
319 .band = IEEE80211_BAND_5GHZ,
320 .bitrates = a_mode_rates,
321 .n_bitrates = a_mode_rates_size,
322 .ht_cap.ht_supported = 1,
323 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
324 | IEEE80211_HT_CAP_GRN_FLD
325 | IEEE80211_HT_CAP_DSSSCCK40
326 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
327 | IEEE80211_HT_CAP_SGI_40
328 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
329 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
330 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
331 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
332 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
333 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
334};
335
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530336/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 TX/RX direction for each kind of interface */
338static const struct ieee80211_txrx_stypes
339wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
340 [NL80211_IFTYPE_STATION] = {
341 .tx = 0xffff,
342 .rx = BIT(SIR_MAC_MGMT_ACTION) |
343 BIT(SIR_MAC_MGMT_PROBE_REQ),
344 },
345 [NL80211_IFTYPE_AP] = {
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_PROBE_REQ) |
350 BIT(SIR_MAC_MGMT_DISASSOC) |
351 BIT(SIR_MAC_MGMT_AUTH) |
352 BIT(SIR_MAC_MGMT_DEAUTH) |
353 BIT(SIR_MAC_MGMT_ACTION),
354 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700355 [NL80211_IFTYPE_ADHOC] = {
356 .tx = 0xffff,
357 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
358 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
359 BIT(SIR_MAC_MGMT_PROBE_REQ) |
360 BIT(SIR_MAC_MGMT_DISASSOC) |
361 BIT(SIR_MAC_MGMT_AUTH) |
362 BIT(SIR_MAC_MGMT_DEAUTH) |
363 BIT(SIR_MAC_MGMT_ACTION),
364 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 [NL80211_IFTYPE_P2P_CLIENT] = {
366 .tx = 0xffff,
367 .rx = BIT(SIR_MAC_MGMT_ACTION) |
368 BIT(SIR_MAC_MGMT_PROBE_REQ),
369 },
370 [NL80211_IFTYPE_P2P_GO] = {
371 /* This is also same as for SoftAP */
372 .tx = 0xffff,
373 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
374 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
375 BIT(SIR_MAC_MGMT_PROBE_REQ) |
376 BIT(SIR_MAC_MGMT_DISASSOC) |
377 BIT(SIR_MAC_MGMT_AUTH) |
378 BIT(SIR_MAC_MGMT_DEAUTH) |
379 BIT(SIR_MAC_MGMT_ACTION),
380 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700381};
382
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800383#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800384static const struct ieee80211_iface_limit
385wlan_hdd_iface_limit[] = {
386 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800387 /* max = 3 ; Our driver create two interfaces during driver init
388 * wlan0 and p2p0 interfaces. p2p0 is considered as station
389 * interface until a group is formed. In JB architecture, once the
390 * group is formed, interface type of p2p0 is changed to P2P GO or
391 * Client.
392 * When supplicant remove the group, it first issue a set interface
393 * cmd to change the mode back to Station. In JB this works fine as
394 * we advertize two station type interface during driver init.
395 * Some vendors create separate interface for P2P GO/Client,
396 * after group formation(Third one). But while group remove
397 * supplicant first tries to change the mode(3rd interface) to STATION
398 * But as we advertized only two sta type interfaces nl80211 was
399 * returning error for the third one which was leading to failure in
400 * delete interface. Ideally while removing the group, supplicant
401 * should not try to change the 3rd interface mode to Station type.
402 * Till we get a fix in wpa_supplicant, we advertize max STA
403 * interface type to 3
404 */
405 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800406 .types = BIT(NL80211_IFTYPE_STATION),
407 },
408 {
409 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700410 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800411 },
412 {
413 .max = 1,
414 .types = BIT(NL80211_IFTYPE_P2P_GO) |
415 BIT(NL80211_IFTYPE_P2P_CLIENT),
416 },
417};
418
419/* By default, only single channel concurrency is allowed */
420static struct ieee80211_iface_combination
421wlan_hdd_iface_combination = {
422 .limits = wlan_hdd_iface_limit,
423 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800424 /*
425 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
426 * and p2p0 interfaces during driver init
427 * Some vendors create separate interface for P2P operations.
428 * wlan0: STA interface
429 * p2p0: P2P Device interface, action frames goes
430 * through this interface.
431 * p2p-xx: P2P interface, After GO negotiation this interface is
432 * created for p2p operations(GO/CLIENT interface).
433 */
434 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800435 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
436 .beacon_int_infra_match = false,
437};
438#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440static struct cfg80211_ops wlan_hdd_cfg80211_ops;
441
442/* Data rate 100KBPS based on IE Index */
443struct index_data_rate_type
444{
445 v_U8_t beacon_rate_index;
446 v_U16_t supported_rate[4];
447};
448
449/* 11B, 11G Rate table include Basic rate and Extended rate
450 The IDX field is the rate index
451 The HI field is the rate when RSSI is strong or being ignored
452 (in this case we report actual rate)
453 The MID field is the rate when RSSI is moderate
454 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
455 The LO field is the rate when RSSI is low
456 (in this case we don't report rates, actual current rate used)
457 */
458static const struct
459{
460 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700461 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700462} supported_data_rate[] =
463{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700464/* IDX HI HM LM LO (RSSI-based index */
465 {2, { 10, 10, 10, 0}},
466 {4, { 20, 20, 10, 0}},
467 {11, { 55, 20, 10, 0}},
468 {12, { 60, 55, 20, 0}},
469 {18, { 90, 55, 20, 0}},
470 {22, {110, 55, 20, 0}},
471 {24, {120, 90, 60, 0}},
472 {36, {180, 120, 60, 0}},
473 {44, {220, 180, 60, 0}},
474 {48, {240, 180, 90, 0}},
475 {66, {330, 180, 90, 0}},
476 {72, {360, 240, 90, 0}},
477 {96, {480, 240, 120, 0}},
478 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700479};
480
481/* MCS Based rate table */
482static struct index_data_rate_type supported_mcs_rate[] =
483{
484/* MCS L20 L40 S20 S40 */
485 {0, {65, 135, 72, 150}},
486 {1, {130, 270, 144, 300}},
487 {2, {195, 405, 217, 450}},
488 {3, {260, 540, 289, 600}},
489 {4, {390, 810, 433, 900}},
490 {5, {520, 1080, 578, 1200}},
491 {6, {585, 1215, 650, 1350}},
492 {7, {650, 1350, 722, 1500}}
493};
494
Leo Chang6f8870f2013-03-26 18:11:36 -0700495#ifdef WLAN_FEATURE_11AC
496
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530497#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700498
499struct index_vht_data_rate_type
500{
501 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530502 v_U16_t supported_VHT80_rate[2];
503 v_U16_t supported_VHT40_rate[2];
504 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700505};
506
507typedef enum
508{
509 DATA_RATE_11AC_MAX_MCS_7,
510 DATA_RATE_11AC_MAX_MCS_8,
511 DATA_RATE_11AC_MAX_MCS_9,
512 DATA_RATE_11AC_MAX_MCS_NA
513} eDataRate11ACMaxMcs;
514
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530515/* SSID broadcast type */
516typedef enum eSSIDBcastType
517{
518 eBCAST_UNKNOWN = 0,
519 eBCAST_NORMAL = 1,
520 eBCAST_HIDDEN = 2,
521} tSSIDBcastType;
522
Leo Chang6f8870f2013-03-26 18:11:36 -0700523/* MCS Based VHT rate table */
524static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
525{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530526/* MCS L80 S80 L40 S40 L20 S40*/
527 {0, {293, 325}, {135, 150}, {65, 72}},
528 {1, {585, 650}, {270, 300}, {130, 144}},
529 {2, {878, 975}, {405, 450}, {195, 217}},
530 {3, {1170, 1300}, {540, 600}, {260, 289}},
531 {4, {1755, 1950}, {810, 900}, {390, 433}},
532 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
533 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
534 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
535 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
536 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700537};
538#endif /* WLAN_FEATURE_11AC */
539
c_hpothu79aab322014-07-14 21:11:01 +0530540/*array index points to MCS and array value points respective rssi*/
541static int rssiMcsTbl[][10] =
542{
543/*MCS 0 1 2 3 4 5 6 7 8 9*/
544 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
545 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
546 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
547};
548
Jeff Johnson295189b2012-06-20 16:38:30 -0700549extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530550#ifdef FEATURE_WLAN_SCAN_PNO
551static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
Leo Chang9056f462013-08-01 19:21:11 -0700554#ifdef WLAN_NL80211_TESTMODE
555enum wlan_hdd_tm_attr
556{
557 WLAN_HDD_TM_ATTR_INVALID = 0,
558 WLAN_HDD_TM_ATTR_CMD = 1,
559 WLAN_HDD_TM_ATTR_DATA = 2,
560 WLAN_HDD_TM_ATTR_TYPE = 3,
561 /* keep last */
562 WLAN_HDD_TM_ATTR_AFTER_LAST,
563 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
564};
565
566enum wlan_hdd_tm_cmd
567{
568 WLAN_HDD_TM_CMD_WLAN_HB = 1,
569};
570
571#define WLAN_HDD_TM_DATA_MAX_LEN 5000
572
573static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
574{
575 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
576 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
577 .len = WLAN_HDD_TM_DATA_MAX_LEN },
578};
579#endif /* WLAN_NL80211_TESTMODE */
580
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800581#ifdef FEATURE_WLAN_CH_AVOID
582/*
583 * FUNCTION: wlan_hdd_send_avoid_freq_event
584 * This is called when wlan driver needs to send vendor specific
585 * avoid frequency range event to userspace
586 */
587int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
588 tHddAvoidFreqList *pAvoidFreqList)
589{
590 struct sk_buff *vendor_event;
591
592 ENTER();
593
594 if (!pHddCtx)
595 {
596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
597 "%s: HDD context is null", __func__);
598 return -1;
599 }
600
601 if (!pAvoidFreqList)
602 {
603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
604 "%s: pAvoidFreqList is null", __func__);
605 return -1;
606 }
607
608 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530609#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
610 NULL,
611#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800612 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530613 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800614 GFP_KERNEL);
615 if (!vendor_event)
616 {
617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
618 "%s: cfg80211_vendor_event_alloc failed", __func__);
619 return -1;
620 }
621
622 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
623 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
624
625 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
626
627 EXIT();
628 return 0;
629}
630#endif /* FEATURE_WLAN_CH_AVOID */
631
Srinivas Dasari030bad32015-02-18 23:23:54 +0530632/*
633 * FUNCTION: __wlan_hdd_cfg80211_nan_request
634 * This is called when wlan driver needs to send vendor specific
635 * nan request event.
636 */
637static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
638 struct wireless_dev *wdev,
639 const void *data, int data_len)
640{
641 tNanRequestReq nan_req;
642 VOS_STATUS status;
643 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530644 struct net_device *dev = wdev->netdev;
645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
646 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530647 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
648
649 if (0 == data_len)
650 {
651 hddLog(VOS_TRACE_LEVEL_ERROR,
652 FL("NAN - Invalid Request, length = 0"));
653 return ret_val;
654 }
655
656 if (NULL == data)
657 {
658 hddLog(VOS_TRACE_LEVEL_ERROR,
659 FL("NAN - Invalid Request, data is NULL"));
660 return ret_val;
661 }
662
663 status = wlan_hdd_validate_context(pHddCtx);
664 if (0 != status)
665 {
666 hddLog(VOS_TRACE_LEVEL_ERROR,
667 FL("HDD context is not valid"));
668 return -EINVAL;
669 }
670
671 hddLog(LOG1, FL("Received NAN command"));
672 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
673 (tANI_U8 *)data, data_len);
674
675 /* check the NAN Capability */
676 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
677 {
678 hddLog(VOS_TRACE_LEVEL_ERROR,
679 FL("NAN is not supported by Firmware"));
680 return -EINVAL;
681 }
682
683 nan_req.request_data_len = data_len;
684 nan_req.request_data = data;
685
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530686 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530687 if (VOS_STATUS_SUCCESS == status)
688 {
689 ret_val = 0;
690 }
691 return ret_val;
692}
693
694/*
695 * FUNCTION: wlan_hdd_cfg80211_nan_request
696 * Wrapper to protect the nan vendor command from ssr
697 */
698static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
699 struct wireless_dev *wdev,
700 const void *data, int data_len)
701{
702 int ret;
703
704 vos_ssr_protect(__func__);
705 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
706 vos_ssr_unprotect(__func__);
707
708 return ret;
709}
710
711/*
712 * FUNCTION: wlan_hdd_cfg80211_nan_callback
713 * This is a callback function and it gets called
714 * when we need to report nan response event to
715 * upper layers.
716 */
717static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
718{
719 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
720 struct sk_buff *vendor_event;
721 int status;
722 tSirNanEvent *data;
723
724 ENTER();
725 if (NULL == msg)
726 {
727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
728 FL(" msg received here is null"));
729 return;
730 }
731 data = msg;
732
733 status = wlan_hdd_validate_context(pHddCtx);
734
735 if (0 != status)
736 {
737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 FL("HDD context is not valid"));
739 return;
740 }
741
742 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530743#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
744 NULL,
745#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530746 data->event_data_len +
747 NLMSG_HDRLEN,
748 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
749 GFP_KERNEL);
750
751 if (!vendor_event)
752 {
753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
754 FL("cfg80211_vendor_event_alloc failed"));
755 return;
756 }
757 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
758 data->event_data_len, data->event_data))
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
762 kfree_skb(vendor_event);
763 return;
764 }
765 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
766 EXIT();
767}
768
769/*
770 * FUNCTION: wlan_hdd_cfg80211_nan_init
771 * This function is called to register the callback to sme layer
772 */
773inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
774{
775 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
776}
777
778
Sunil Duttc69bccb2014-05-26 21:30:20 +0530779#ifdef WLAN_FEATURE_LINK_LAYER_STATS
780
781static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
782 struct sk_buff *vendor_event)
783{
784 if (nla_put_u8(vendor_event,
785 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
786 stats->rate.preamble) ||
787 nla_put_u8(vendor_event,
788 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
789 stats->rate.nss) ||
790 nla_put_u8(vendor_event,
791 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
792 stats->rate.bw) ||
793 nla_put_u8(vendor_event,
794 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
795 stats->rate.rateMcsIdx) ||
796 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
797 stats->rate.bitrate ) ||
798 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
799 stats->txMpdu ) ||
800 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
801 stats->rxMpdu ) ||
802 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
803 stats->mpduLost ) ||
804 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
805 stats->retries) ||
806 nla_put_u32(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
808 stats->retriesShort ) ||
809 nla_put_u32(vendor_event,
810 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
811 stats->retriesLong))
812 {
813 hddLog(VOS_TRACE_LEVEL_ERROR,
814 FL("QCA_WLAN_VENDOR_ATTR put fail"));
815 return FALSE;
816 }
817 return TRUE;
818}
819
820static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
821 struct sk_buff *vendor_event)
822{
823 u32 i = 0;
824 struct nlattr *rateInfo;
825 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
826 stats->type) ||
827 nla_put(vendor_event,
828 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
829 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
830 nla_put_u32(vendor_event,
831 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
832 stats->capabilities) ||
833 nla_put_u32(vendor_event,
834 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
835 stats->numRate))
836 {
837 hddLog(VOS_TRACE_LEVEL_ERROR,
838 FL("QCA_WLAN_VENDOR_ATTR put fail"));
839 goto error;
840 }
841
842 rateInfo = nla_nest_start(vendor_event,
843 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530844 if(!rateInfo)
845 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530846 for (i = 0; i < stats->numRate; i++)
847 {
848 struct nlattr *rates;
849 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
850 stats->rateStats +
851 (i * sizeof(tSirWifiRateStat)));
852 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530853 if(!rates)
854 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530855
856 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
857 {
858 hddLog(VOS_TRACE_LEVEL_ERROR,
859 FL("QCA_WLAN_VENDOR_ATTR put fail"));
860 return FALSE;
861 }
862 nla_nest_end(vendor_event, rates);
863 }
864 nla_nest_end(vendor_event, rateInfo);
865
866 return TRUE;
867error:
868 return FALSE;
869}
870
871static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
872 struct sk_buff *vendor_event)
873{
874 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
875 stats->ac ) ||
876 nla_put_u32(vendor_event,
877 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
878 stats->txMpdu ) ||
879 nla_put_u32(vendor_event,
880 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
881 stats->rxMpdu ) ||
882 nla_put_u32(vendor_event,
883 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
884 stats->txMcast ) ||
885 nla_put_u32(vendor_event,
886 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
887 stats->rxMcast ) ||
888 nla_put_u32(vendor_event,
889 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
890 stats->rxAmpdu ) ||
891 nla_put_u32(vendor_event,
892 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
893 stats->txAmpdu ) ||
894 nla_put_u32(vendor_event,
895 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
896 stats->mpduLost )||
897 nla_put_u32(vendor_event,
898 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
899 stats->retries ) ||
900 nla_put_u32(vendor_event,
901 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
902 stats->retriesShort ) ||
903 nla_put_u32(vendor_event,
904 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
905 stats->retriesLong ) ||
906 nla_put_u32(vendor_event,
907 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
908 stats->contentionTimeMin ) ||
909 nla_put_u32(vendor_event,
910 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
911 stats->contentionTimeMax ) ||
912 nla_put_u32(vendor_event,
913 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
914 stats->contentionTimeAvg ) ||
915 nla_put_u32(vendor_event,
916 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
917 stats->contentionNumSamples ))
918 {
919 hddLog(VOS_TRACE_LEVEL_ERROR,
920 FL("QCA_WLAN_VENDOR_ATTR put fail") );
921 return FALSE;
922 }
923 return TRUE;
924}
925
926static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
927 struct sk_buff *vendor_event)
928{
Dino Myclec8f3f332014-07-21 16:48:27 +0530929 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530930 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
931 nla_put(vendor_event,
932 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
933 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
934 nla_put_u32(vendor_event,
935 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
936 stats->state ) ||
937 nla_put_u32(vendor_event,
938 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
939 stats->roaming ) ||
940 nla_put_u32(vendor_event,
941 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
942 stats->capabilities ) ||
943 nla_put(vendor_event,
944 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
945 strlen(stats->ssid), stats->ssid) ||
946 nla_put(vendor_event,
947 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
948 WNI_CFG_BSSID_LEN, stats->bssid) ||
949 nla_put(vendor_event,
950 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
951 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
952 nla_put(vendor_event,
953 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
954 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
955 )
956 {
957 hddLog(VOS_TRACE_LEVEL_ERROR,
958 FL("QCA_WLAN_VENDOR_ATTR put fail") );
959 return FALSE;
960 }
961 return TRUE;
962}
963
Dino Mycle3b9536d2014-07-09 22:05:24 +0530964static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
965 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530966 struct sk_buff *vendor_event)
967{
968 int i = 0;
969 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530970 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
971 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530972 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530973
Sunil Duttc69bccb2014-05-26 21:30:20 +0530974 if (FALSE == put_wifi_interface_info(
975 &pWifiIfaceStat->info,
976 vendor_event))
977 {
978 hddLog(VOS_TRACE_LEVEL_ERROR,
979 FL("QCA_WLAN_VENDOR_ATTR put fail") );
980 return FALSE;
981
982 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
984 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
985 if (NULL == pWifiIfaceStatTL)
986 {
987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
988 return FALSE;
989 }
990
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530991 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
992 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
993 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
994 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
995
996 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
997 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
998 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301000
1001 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1002 {
1003 if (VOS_STATUS_SUCCESS ==
1004 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1005 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1006 {
1007 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1008 * obtained from TL structure
1009 */
1010
1011 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1012 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1014
Srinivas Dasari98947432014-11-07 19:41:24 +05301015 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1016 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1017 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1018 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1019 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1020 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1021 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1022 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301023
Srinivas Dasari98947432014-11-07 19:41:24 +05301024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301032
Srinivas Dasari98947432014-11-07 19:41:24 +05301033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301041 }
1042 else
1043 {
1044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1045 }
1046
Dino Mycle3b9536d2014-07-09 22:05:24 +05301047 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1048 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1049 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1050 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1051 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1052 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1053 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1054 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1055 }
1056 else
1057 {
1058 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1059 }
1060
1061
Sunil Duttc69bccb2014-05-26 21:30:20 +05301062
1063 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301064 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1065 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1066 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301067 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1068 pWifiIfaceStat->beaconRx) ||
1069 nla_put_u32(vendor_event,
1070 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1071 pWifiIfaceStat->mgmtRx) ||
1072 nla_put_u32(vendor_event,
1073 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1074 pWifiIfaceStat->mgmtActionRx) ||
1075 nla_put_u32(vendor_event,
1076 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1077 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301078 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301079 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1080 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301081 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301082 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1083 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301084 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301085 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1086 pWifiIfaceStat->rssiAck))
1087 {
1088 hddLog(VOS_TRACE_LEVEL_ERROR,
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301089 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1090 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301091 return FALSE;
1092 }
1093
Mukul Sharmaf1bd9322015-10-20 16:03:42 +05301094#ifdef FEATURE_EXT_LL_STAT
1095 /*
1096 * Ensure when EXT_LL_STAT is supported by both host and fwr,
1097 * then host should send Leaky AP stats to upper layer,
1098 * otherwise no need to send these stats.
1099 */
1100 if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) &&
1101 sme_IsFeatureSupportedByDriver(EXT_LL_STAT)
1102 )
1103 {
1104 hddLog(VOS_TRACE_LEVEL_INFO,
1105 FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"),
1106 pWifiIfaceStat->leakyApStat.is_leaky_ap,
1107 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked,
1108 pWifiIfaceStat->leakyApStat.rx_leak_window,
1109 pWifiIfaceStat->leakyApStat.avg_bcn_spread);
1110 if (nla_put_u32(vendor_event,
1111 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED,
1112 pWifiIfaceStat->leakyApStat.is_leaky_ap) ||
1113 nla_put_u32(vendor_event,
1114 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED,
1115 pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) ||
1116 nla_put_u32(vendor_event,
1117 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME,
1118 pWifiIfaceStat->leakyApStat.rx_leak_window) ||
1119 nla_put_u64(vendor_event,
1120 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET,
1121 pWifiIfaceStat->leakyApStat.avg_bcn_spread))
1122 {
1123 hddLog(VOS_TRACE_LEVEL_ERROR,
1124 FL("EXT_LL_STAT put fail"));
1125 vos_mem_free(pWifiIfaceStatTL);
1126 return FALSE;
1127 }
1128 }
1129#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 wmmInfo = nla_nest_start(vendor_event,
1131 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301132 if(!wmmInfo)
1133 {
1134 vos_mem_free(pWifiIfaceStatTL);
1135 return FALSE;
1136 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 for (i = 0; i < WIFI_AC_MAX; i++)
1138 {
1139 struct nlattr *wmmStats;
1140 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301141 if(!wmmStats)
1142 {
1143 vos_mem_free(pWifiIfaceStatTL);
1144 return FALSE;
1145 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301146 if (FALSE == put_wifi_wmm_ac_stat(
1147 &pWifiIfaceStat->AccessclassStats[i],
1148 vendor_event))
1149 {
1150 hddLog(VOS_TRACE_LEVEL_ERROR,
1151 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301152 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301153 return FALSE;
1154 }
1155
1156 nla_nest_end(vendor_event, wmmStats);
1157 }
1158 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301159 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301160 return TRUE;
1161}
1162
1163static tSirWifiInterfaceMode
1164 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1165{
1166 switch (deviceMode)
1167 {
1168 case WLAN_HDD_INFRA_STATION:
1169 return WIFI_INTERFACE_STA;
1170 case WLAN_HDD_SOFTAP:
1171 return WIFI_INTERFACE_SOFTAP;
1172 case WLAN_HDD_P2P_CLIENT:
1173 return WIFI_INTERFACE_P2P_CLIENT;
1174 case WLAN_HDD_P2P_GO:
1175 return WIFI_INTERFACE_P2P_GO;
1176 case WLAN_HDD_IBSS:
1177 return WIFI_INTERFACE_IBSS;
1178 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301179 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301180 }
1181}
1182
1183static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1184 tpSirWifiInterfaceInfo pInfo)
1185{
1186 v_U8_t *staMac = NULL;
1187 hdd_station_ctx_t *pHddStaCtx;
1188 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1189 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1190
1191 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1192
1193 vos_mem_copy(pInfo->macAddr,
1194 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1195
1196 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1197 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1198 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1199 {
1200 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1201 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1202 {
1203 pInfo->state = WIFI_DISCONNECTED;
1204 }
1205 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1206 {
1207 hddLog(VOS_TRACE_LEVEL_ERROR,
1208 "%s: Session ID %d, Connection is in progress", __func__,
1209 pAdapter->sessionId);
1210 pInfo->state = WIFI_ASSOCIATING;
1211 }
1212 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1213 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1214 {
1215 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1216 hddLog(VOS_TRACE_LEVEL_ERROR,
1217 "%s: client " MAC_ADDRESS_STR
1218 " is in the middle of WPS/EAPOL exchange.", __func__,
1219 MAC_ADDR_ARRAY(staMac));
1220 pInfo->state = WIFI_AUTHENTICATING;
1221 }
1222 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1223 {
1224 pInfo->state = WIFI_ASSOCIATED;
1225 vos_mem_copy(pInfo->bssid,
1226 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1227 vos_mem_copy(pInfo->ssid,
1228 pHddStaCtx->conn_info.SSID.SSID.ssId,
1229 pHddStaCtx->conn_info.SSID.SSID.length);
1230 //NULL Terminate the string.
1231 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1232 }
1233 }
1234 vos_mem_copy(pInfo->countryStr,
1235 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1236
1237 vos_mem_copy(pInfo->apCountryStr,
1238 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1239
1240 return TRUE;
1241}
1242
1243/*
1244 * hdd_link_layer_process_peer_stats () - This function is called after
1245 * receiving Link Layer Peer statistics from FW.This function converts
1246 * the firmware data to the NL data and sends the same to the kernel/upper
1247 * layers.
1248 */
1249static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1250 v_VOID_t *pData)
1251{
1252 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301253 tpSirWifiPeerStat pWifiPeerStat;
1254 tpSirWifiPeerInfo pWifiPeerInfo;
1255 struct nlattr *peerInfo;
1256 struct sk_buff *vendor_event;
1257 int status, i;
1258
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301259 ENTER();
1260
Sunil Duttc69bccb2014-05-26 21:30:20 +05301261 status = wlan_hdd_validate_context(pHddCtx);
1262 if (0 != status)
1263 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 return;
1265 }
1266
1267 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1268
1269 hddLog(VOS_TRACE_LEVEL_INFO,
1270 "LL_STATS_PEER_ALL : numPeers %u",
1271 pWifiPeerStat->numPeers);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301272 /*
1273 * Allocate a size of 4096 for the peer stats comprising
1274 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1275 * sizeof (tSirWifiRateStat).Each field is put with an
1276 * NL attribute.The size of 4096 is considered assuming
1277 * that number of rates shall not exceed beyond 50 with
1278 * the sizeof (tSirWifiRateStat) being 32.
1279 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301280 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1281 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301282 if (!vendor_event)
1283 {
1284 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301285 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301286 __func__);
1287 return;
1288 }
1289 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301290 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1291 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1292 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301293 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1294 pWifiPeerStat->numPeers))
1295 {
1296 hddLog(VOS_TRACE_LEVEL_ERROR,
1297 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1298 kfree_skb(vendor_event);
1299 return;
1300 }
1301
1302 peerInfo = nla_nest_start(vendor_event,
1303 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301304 if(!peerInfo)
1305 {
1306 hddLog(VOS_TRACE_LEVEL_ERROR,
1307 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1308 __func__);
1309 kfree_skb(vendor_event);
1310 return;
1311 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301312
1313 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1314 pWifiPeerStat->peerInfo);
1315
1316 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1317 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301318 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301319 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301320
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301321 if(!peers)
1322 {
1323 hddLog(VOS_TRACE_LEVEL_ERROR,
1324 "%s: peer stats put fail",
1325 __func__);
1326 kfree_skb(vendor_event);
1327 return;
1328 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301329 if (FALSE == put_wifi_peer_info(
1330 pWifiPeerInfo, vendor_event))
1331 {
1332 hddLog(VOS_TRACE_LEVEL_ERROR,
1333 "%s: put_wifi_peer_info put fail", __func__);
1334 kfree_skb(vendor_event);
1335 return;
1336 }
1337
1338 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1339 pWifiPeerStat->peerInfo +
1340 (i * sizeof(tSirWifiPeerInfo)) +
1341 (numRate * sizeof (tSirWifiRateStat)));
1342 nla_nest_end(vendor_event, peers);
1343 }
1344 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301345 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301346 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301347}
1348
1349/*
1350 * hdd_link_layer_process_iface_stats () - This function is called after
1351 * receiving Link Layer Interface statistics from FW.This function converts
1352 * the firmware data to the NL data and sends the same to the kernel/upper
1353 * layers.
1354 */
1355static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1356 v_VOID_t *pData)
1357{
1358 tpSirWifiIfaceStat pWifiIfaceStat;
1359 struct sk_buff *vendor_event;
1360 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1361 int status;
1362
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301363 ENTER();
1364
Sunil Duttc69bccb2014-05-26 21:30:20 +05301365 status = wlan_hdd_validate_context(pHddCtx);
1366 if (0 != status)
1367 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301368 return;
1369 }
1370 /*
1371 * Allocate a size of 4096 for the interface stats comprising
1372 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1373 * assuming that all these fit with in the limit.Please take
1374 * a call on the limit based on the data requirements on
1375 * interface statistics.
1376 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301377 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1378 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301379 if (!vendor_event)
1380 {
1381 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301382 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301383 return;
1384 }
1385
1386 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1387
Dino Mycle3b9536d2014-07-09 22:05:24 +05301388
1389 if (FALSE == hdd_get_interface_info( pAdapter,
1390 &pWifiIfaceStat->info))
1391 {
1392 hddLog(VOS_TRACE_LEVEL_ERROR,
1393 FL("hdd_get_interface_info get fail") );
1394 kfree_skb(vendor_event);
1395 return;
1396 }
1397
1398 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1399 vendor_event))
1400 {
1401 hddLog(VOS_TRACE_LEVEL_ERROR,
1402 FL("put_wifi_iface_stats fail") );
1403 kfree_skb(vendor_event);
1404 return;
1405 }
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 hddLog(VOS_TRACE_LEVEL_INFO,
1408 "WMI_LINK_STATS_IFACE Data");
1409
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301410 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301411
1412 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301413}
1414
1415/*
1416 * hdd_link_layer_process_radio_stats () - This function is called after
1417 * receiving Link Layer Radio statistics from FW.This function converts
1418 * the firmware data to the NL data and sends the same to the kernel/upper
1419 * layers.
1420 */
1421static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1422 v_VOID_t *pData)
1423{
1424 int status, i;
1425 tpSirWifiRadioStat pWifiRadioStat;
1426 tpSirWifiChannelStats pWifiChannelStats;
1427 struct sk_buff *vendor_event;
1428 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1429 struct nlattr *chList;
1430
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301431 ENTER();
1432
Sunil Duttc69bccb2014-05-26 21:30:20 +05301433 status = wlan_hdd_validate_context(pHddCtx);
1434 if (0 != status)
1435 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301436 return;
1437 }
1438 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1439
1440 hddLog(VOS_TRACE_LEVEL_INFO,
1441 "LL_STATS_RADIO"
1442 " radio is %d onTime is %u "
1443 " txTime is %u rxTime is %u "
1444 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301445 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301446 " onTimePnoScan is %u onTimeHs20 is %u "
1447 " numChannels is %u",
1448 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1449 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1450 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301451 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301452 pWifiRadioStat->onTimeRoamScan,
1453 pWifiRadioStat->onTimePnoScan,
1454 pWifiRadioStat->onTimeHs20,
1455 pWifiRadioStat->numChannels);
1456 /*
1457 * Allocate a size of 4096 for the Radio stats comprising
1458 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1459 * (tSirWifiChannelStats).Each channel data is put with an
1460 * NL attribute.The size of 4096 is considered assuming that
1461 * number of channels shall not exceed beyond 60 with the
1462 * sizeof (tSirWifiChannelStats) being 24 bytes.
1463 */
1464
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301465 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1466 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301467 if (!vendor_event)
1468 {
1469 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301470 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301471 return;
1472 }
1473
1474 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301475 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1476 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1477 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301478 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1479 pWifiRadioStat->radio) ||
1480 nla_put_u32(vendor_event,
1481 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1482 pWifiRadioStat->onTime) ||
1483 nla_put_u32(vendor_event,
1484 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1485 pWifiRadioStat->txTime) ||
1486 nla_put_u32(vendor_event,
1487 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1488 pWifiRadioStat->rxTime) ||
1489 nla_put_u32(vendor_event,
1490 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1491 pWifiRadioStat->onTimeScan) ||
1492 nla_put_u32(vendor_event,
1493 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1494 pWifiRadioStat->onTimeNbd) ||
1495 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301496 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1497 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301498 nla_put_u32(vendor_event,
1499 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1500 pWifiRadioStat->onTimeRoamScan) ||
1501 nla_put_u32(vendor_event,
1502 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1503 pWifiRadioStat->onTimePnoScan) ||
1504 nla_put_u32(vendor_event,
1505 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1506 pWifiRadioStat->onTimeHs20) ||
1507 nla_put_u32(vendor_event,
1508 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1509 pWifiRadioStat->numChannels))
1510 {
1511 hddLog(VOS_TRACE_LEVEL_ERROR,
1512 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1513 kfree_skb(vendor_event);
1514 return ;
1515 }
1516
1517 chList = nla_nest_start(vendor_event,
1518 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301519 if(!chList)
1520 {
1521 hddLog(VOS_TRACE_LEVEL_ERROR,
1522 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1523 __func__);
1524 kfree_skb(vendor_event);
1525 return;
1526 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301527 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1528 {
1529 struct nlattr *chInfo;
1530
1531 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1532 pWifiRadioStat->channels +
1533 (i * sizeof(tSirWifiChannelStats)));
1534
Sunil Duttc69bccb2014-05-26 21:30:20 +05301535 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301536 if(!chInfo)
1537 {
1538 hddLog(VOS_TRACE_LEVEL_ERROR,
1539 "%s: failed to put chInfo",
1540 __func__);
1541 kfree_skb(vendor_event);
1542 return;
1543 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301544
1545 if (nla_put_u32(vendor_event,
1546 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1547 pWifiChannelStats->channel.width) ||
1548 nla_put_u32(vendor_event,
1549 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1550 pWifiChannelStats->channel.centerFreq) ||
1551 nla_put_u32(vendor_event,
1552 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1553 pWifiChannelStats->channel.centerFreq0) ||
1554 nla_put_u32(vendor_event,
1555 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1556 pWifiChannelStats->channel.centerFreq1) ||
1557 nla_put_u32(vendor_event,
1558 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1559 pWifiChannelStats->onTime) ||
1560 nla_put_u32(vendor_event,
1561 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1562 pWifiChannelStats->ccaBusyTime))
1563 {
1564 hddLog(VOS_TRACE_LEVEL_ERROR,
1565 FL("cfg80211_vendor_event_alloc failed") );
1566 kfree_skb(vendor_event);
1567 return ;
1568 }
1569 nla_nest_end(vendor_event, chInfo);
1570 }
1571 nla_nest_end(vendor_event, chList);
1572
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301573 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301574
1575 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301576 return;
1577}
1578
1579/*
1580 * hdd_link_layer_stats_ind_callback () - This function is called after
1581 * receiving Link Layer indications from FW.This callback converts the firmware
1582 * data to the NL data and send the same to the kernel/upper layers.
1583 */
1584static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1585 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301586 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301587{
Dino Mycled3d50022014-07-07 12:58:25 +05301588 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1589 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301590 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301591 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301592 int status;
1593
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301594 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301595
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301596 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301597 if (0 != status)
1598 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301599 return;
1600 }
1601
Dino Mycled3d50022014-07-07 12:58:25 +05301602 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1603 if (NULL == pAdapter)
1604 {
1605 hddLog(VOS_TRACE_LEVEL_ERROR,
1606 FL(" MAC address %pM does not exist with host"),
1607 macAddr);
1608 return;
1609 }
1610
Sunil Duttc69bccb2014-05-26 21:30:20 +05301611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301612 "%s: Interface: %s LLStats indType: %d", __func__,
1613 pAdapter->dev->name, indType);
1614
Sunil Duttc69bccb2014-05-26 21:30:20 +05301615 switch (indType)
1616 {
1617 case SIR_HAL_LL_STATS_RESULTS_RSP:
1618 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301619 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301620 "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM "
1621 "respId = %u, moreResultToFollow = %u",
1622 linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId,
1623 macAddr, linkLayerStatsResults->respId,
1624 linkLayerStatsResults->moreResultToFollow);
1625
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301626 spin_lock(&hdd_context_lock);
1627 context = &pHddCtx->ll_stats_context;
1628 /* validate response received from target */
1629 if ((context->request_id != linkLayerStatsResults->respId) ||
1630 !(context->request_bitmap & linkLayerStatsResults->paramId))
1631 {
1632 spin_unlock(&hdd_context_lock);
1633 hddLog(LOGE,
1634 FL("Error : Request id %d response id %d request bitmap 0x%x"
1635 "response bitmap 0x%x"),
1636 context->request_id, linkLayerStatsResults->respId,
1637 context->request_bitmap, linkLayerStatsResults->paramId);
1638 return;
1639 }
1640 spin_unlock(&hdd_context_lock);
1641
Sunil Duttc69bccb2014-05-26 21:30:20 +05301642 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1643 {
1644 hdd_link_layer_process_radio_stats(pAdapter,
1645 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301646 spin_lock(&hdd_context_lock);
1647 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1648 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649 }
1650 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1651 {
1652 hdd_link_layer_process_iface_stats(pAdapter,
1653 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301654 spin_lock(&hdd_context_lock);
1655 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1656 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301657 }
1658 else if ( linkLayerStatsResults->paramId &
1659 WMI_LINK_STATS_ALL_PEER )
1660 {
1661 hdd_link_layer_process_peer_stats(pAdapter,
1662 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301663 spin_lock(&hdd_context_lock);
1664 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1665 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301666 } /* WMI_LINK_STATS_ALL_PEER */
1667 else
1668 {
1669 hddLog(VOS_TRACE_LEVEL_ERROR,
1670 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1671 }
1672
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301673 spin_lock(&hdd_context_lock);
1674 /* complete response event if all requests are completed */
1675 if (0 == context->request_bitmap)
1676 complete(&context->response_event);
1677 spin_unlock(&hdd_context_lock);
1678
Sunil Duttc69bccb2014-05-26 21:30:20 +05301679 break;
1680 }
1681 default:
1682 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1683 break;
1684 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301685
1686 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301687 return;
1688}
1689
1690const struct
1691nla_policy
1692qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1693{
1694 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1695 { .type = NLA_U32 },
1696 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1697 { .type = NLA_U32 },
1698};
1699
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301700static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1701 struct wireless_dev *wdev,
1702 const void *data,
1703 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301704{
1705 int status;
1706 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301707 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301708 struct net_device *dev = wdev->netdev;
1709 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1710 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1711
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301712 ENTER();
1713
Sunil Duttc69bccb2014-05-26 21:30:20 +05301714 status = wlan_hdd_validate_context(pHddCtx);
1715 if (0 != status)
1716 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301717 return -EINVAL;
1718 }
1719
1720 if (NULL == pAdapter)
1721 {
1722 hddLog(VOS_TRACE_LEVEL_ERROR,
1723 FL("HDD adapter is Null"));
1724 return -ENODEV;
1725 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301726 /* check the LLStats Capability */
1727 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1728 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1729 {
1730 hddLog(VOS_TRACE_LEVEL_ERROR,
1731 FL("Link Layer Statistics not supported by Firmware"));
1732 return -EINVAL;
1733 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301734
1735 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1736 (struct nlattr *)data,
1737 data_len, qca_wlan_vendor_ll_set_policy))
1738 {
1739 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1740 return -EINVAL;
1741 }
1742 if (!tb_vendor
1743 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1744 {
1745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1746 return -EINVAL;
1747 }
1748 if (!tb_vendor[
1749 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1752 return -EINVAL;
1753 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301754 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301755 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301756
Dino Mycledf0a5d92014-07-04 09:41:55 +05301757 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301758 nla_get_u32(
1759 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1760
Dino Mycledf0a5d92014-07-04 09:41:55 +05301761 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301762 nla_get_u32(
1763 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1764
Dino Mycled3d50022014-07-07 12:58:25 +05301765 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1766 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301767
1768
1769 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301770 "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d "
1771 "Statistics Gathering = %d ",
1772 linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr,
1773 linkLayerStatsSetReq.mpduSizeThreshold,
1774 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301775
1776 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1777 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301778 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301779 {
1780 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1781 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301782 return -EINVAL;
1783
1784 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301785
Sunil Duttc69bccb2014-05-26 21:30:20 +05301786 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301787 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301788 {
1789 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1790 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301791 return -EINVAL;
1792 }
1793
1794 pAdapter->isLinkLayerStatsSet = 1;
1795
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301796 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301797 return 0;
1798}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301799static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1800 struct wireless_dev *wdev,
1801 const void *data,
1802 int data_len)
1803{
1804 int ret = 0;
1805
1806 vos_ssr_protect(__func__);
1807 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1808 vos_ssr_unprotect(__func__);
1809
1810 return ret;
1811}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301812
1813const struct
1814nla_policy
1815qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1816{
1817 /* Unsigned 32bit value provided by the caller issuing the GET stats
1818 * command. When reporting
1819 * the stats results, the driver uses the same value to indicate
1820 * which GET request the results
1821 * correspond to.
1822 */
1823 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1824
1825 /* Unsigned 32bit value . bit mask to identify what statistics are
1826 requested for retrieval */
1827 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1828};
1829
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301830static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1831 struct wireless_dev *wdev,
1832 const void *data,
1833 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301834{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301835 unsigned long rc;
1836 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301837 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1838 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301839 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301840 struct net_device *dev = wdev->netdev;
1841 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05301842 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 int status;
1844
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301845 ENTER();
1846
Sunil Duttc69bccb2014-05-26 21:30:20 +05301847 status = wlan_hdd_validate_context(pHddCtx);
1848 if (0 != status)
1849 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301850 return -EINVAL ;
1851 }
1852
1853 if (NULL == pAdapter)
1854 {
1855 hddLog(VOS_TRACE_LEVEL_FATAL,
1856 "%s: HDD adapter is Null", __func__);
1857 return -ENODEV;
1858 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05301859
1860 if (pHddStaCtx == NULL)
1861 {
1862 hddLog(VOS_TRACE_LEVEL_FATAL,
1863 "%s: HddStaCtx is Null", __func__);
1864 return -ENODEV;
1865 }
1866
Dino Mycledf0a5d92014-07-04 09:41:55 +05301867 /* check the LLStats Capability */
1868 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1869 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1870 {
1871 hddLog(VOS_TRACE_LEVEL_ERROR,
1872 FL("Link Layer Statistics not supported by Firmware"));
1873 return -EINVAL;
1874 }
1875
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876
1877 if (!pAdapter->isLinkLayerStatsSet)
1878 {
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05301879 hddLog(VOS_TRACE_LEVEL_ERROR,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301880 "%s: isLinkLayerStatsSet : %d",
1881 __func__, pAdapter->isLinkLayerStatsSet);
1882 return -EINVAL;
1883 }
1884
Mukul Sharma10313ba2015-07-29 19:14:39 +05301885 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1886 {
1887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1888 "%s: Roaming in progress, so unable to proceed this request", __func__);
1889 return -EBUSY;
1890 }
1891
Sunil Duttc69bccb2014-05-26 21:30:20 +05301892 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1893 (struct nlattr *)data,
1894 data_len, qca_wlan_vendor_ll_get_policy))
1895 {
1896 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1897 return -EINVAL;
1898 }
1899
1900 if (!tb_vendor
1901 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1902 {
1903 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1904 return -EINVAL;
1905 }
1906
1907 if (!tb_vendor
1908 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1909 {
1910 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1911 return -EINVAL;
1912 }
1913
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914
Dino Mycledf0a5d92014-07-04 09:41:55 +05301915 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301916 nla_get_u32( tb_vendor[
1917 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301918 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301919 nla_get_u32( tb_vendor[
1920 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1921
Dino Mycled3d50022014-07-07 12:58:25 +05301922 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1923 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05301926 "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d",
1927 linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301928 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301930 spin_lock(&hdd_context_lock);
1931 context = &pHddCtx->ll_stats_context;
1932 context->request_id = linkLayerStatsGetReq.reqId;
1933 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
1934 INIT_COMPLETION(context->response_event);
1935 spin_unlock(&hdd_context_lock);
1936
Sunil Duttc69bccb2014-05-26 21:30:20 +05301937 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301938 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301944
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301945 rc = wait_for_completion_timeout(&context->response_event,
1946 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
1947 if (!rc)
1948 {
1949 hddLog(LOGE,
1950 FL("Target response timed out request id %d request bitmap 0x%x"),
1951 context->request_id, context->request_bitmap);
1952 return -ETIMEDOUT;
1953 }
1954
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301955 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301956 return 0;
1957}
1958
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
1972
Sunil Duttc69bccb2014-05-26 21:30:20 +05301973const struct
1974nla_policy
1975qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1976{
1977 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1978 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1979 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1980 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1981};
1982
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301983static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1984 struct wireless_dev *wdev,
1985 const void *data,
1986 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301987{
1988 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1989 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301990 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301991 struct net_device *dev = wdev->netdev;
1992 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1993 u32 statsClearReqMask;
1994 u8 stopReq;
1995 int status;
1996
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301997 ENTER();
1998
Sunil Duttc69bccb2014-05-26 21:30:20 +05301999 status = wlan_hdd_validate_context(pHddCtx);
2000 if (0 != status)
2001 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302002 return -EINVAL;
2003 }
2004
2005 if (NULL == pAdapter)
2006 {
2007 hddLog(VOS_TRACE_LEVEL_FATAL,
2008 "%s: HDD adapter is Null", __func__);
2009 return -ENODEV;
2010 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302011 /* check the LLStats Capability */
2012 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2013 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2014 {
2015 hddLog(VOS_TRACE_LEVEL_ERROR,
2016 FL("Enable LLStats Capability"));
2017 return -EINVAL;
2018 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302019
2020 if (!pAdapter->isLinkLayerStatsSet)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: isLinkLayerStatsSet : %d",
2024 __func__, pAdapter->isLinkLayerStatsSet);
2025 return -EINVAL;
2026 }
2027
2028 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2029 (struct nlattr *)data,
2030 data_len, qca_wlan_vendor_ll_clr_policy))
2031 {
2032 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2033 return -EINVAL;
2034 }
2035
2036 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2037
2038 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2039 {
2040 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2041 return -EINVAL;
2042
2043 }
2044
Sunil Duttc69bccb2014-05-26 21:30:20 +05302045
Dino Mycledf0a5d92014-07-04 09:41:55 +05302046 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302047 nla_get_u32(
2048 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2049
Dino Mycledf0a5d92014-07-04 09:41:55 +05302050 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302051 nla_get_u8(
2052 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2053
2054 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302055 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302056
Dino Mycled3d50022014-07-07 12:58:25 +05302057 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2058 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302059
2060 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik81a730c2015-09-14 14:49:52 +05302061 "LL_STATS_CLEAR reqId = %d, MAC = %pM,"
2062 "statsClearReqMask = 0x%X, stopReq = %d",
2063 linkLayerStatsClearReq.reqId,
2064 linkLayerStatsClearReq.macAddr,
2065 linkLayerStatsClearReq.statsClearReqMask,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302066 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302067
2068 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302069 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302070 {
2071 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302072 hdd_station_ctx_t *pHddStaCtx;
2073
2074 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2075 if (VOS_STATUS_SUCCESS !=
2076 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2077 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2078 {
2079 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2080 "WLANTL_ClearInterfaceStats Failed", __func__);
2081 return -EINVAL;
2082 }
2083 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2084 (statsClearReqMask & WIFI_STATS_IFACE)) {
2085 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2086 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2087 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2088 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2089 }
2090
Sunil Duttc69bccb2014-05-26 21:30:20 +05302091 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2092 2 * sizeof(u32) +
2093 NLMSG_HDRLEN);
2094
2095 if (temp_skbuff != NULL)
2096 {
2097
2098 if (nla_put_u32(temp_skbuff,
2099 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2100 statsClearReqMask) ||
2101 nla_put_u32(temp_skbuff,
2102 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2103 stopReq))
2104 {
2105 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2106 kfree_skb(temp_skbuff);
2107 return -EINVAL;
2108 }
2109 /* If the ask is to stop the stats collection as part of clear
2110 * (stopReq = 1) , ensure that no further requests of get
2111 * go to the firmware by having isLinkLayerStatsSet set to 0.
2112 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302113 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302114 * case the firmware is just asked to clear the statistics.
2115 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302116 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302117 pAdapter->isLinkLayerStatsSet = 0;
2118 return cfg80211_vendor_cmd_reply(temp_skbuff);
2119 }
2120 return -ENOMEM;
2121 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302122
2123 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302124 return -EINVAL;
2125}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302126static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2127 struct wireless_dev *wdev,
2128 const void *data,
2129 int data_len)
2130{
2131 int ret = 0;
2132
2133 vos_ssr_protect(__func__);
2134 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2135 vos_ssr_unprotect(__func__);
2136
2137 return ret;
2138
2139
2140}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302141#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2142
Dino Mycle6fb96c12014-06-10 11:52:40 +05302143#ifdef WLAN_FEATURE_EXTSCAN
2144static const struct nla_policy
2145wlan_hdd_extscan_config_policy
2146 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2147{
2148 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2149 { .type = NLA_U32 },
2150 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2151 { .type = NLA_U32 },
2152 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2153 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2154 { .type = NLA_U32 },
2155 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2156 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2157
2158 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2159 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2160 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2161 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2162 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302163 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2164 { .type = NLA_U32 },
2165 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2166 { .type = NLA_U32 },
2167 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2168 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302169 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2170 { .type = NLA_U32 },
2171 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2172 { .type = NLA_U32 },
2173 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2174 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302175 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2176 { .type = NLA_U8 },
2177 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302178 { .type = NLA_U8 },
2179 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2180 { .type = NLA_U8 },
2181 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2182 { .type = NLA_U8 },
2183
2184 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2185 { .type = NLA_U32 },
2186 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2187 { .type = NLA_UNSPEC },
2188 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2189 { .type = NLA_S32 },
2190 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2191 { .type = NLA_S32 },
2192 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2193 { .type = NLA_U32 },
2194 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2195 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302196 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2197 { .type = NLA_U32 },
2198 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2199 { .type = NLA_BINARY,
2200 .len = IEEE80211_MAX_SSID_LEN + 1 },
2201 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302202 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302203 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2204 { .type = NLA_U32 },
2205 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2206 { .type = NLA_U8 },
2207 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2208 { .type = NLA_S32 },
2209 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2210 { .type = NLA_S32 },
2211 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2212 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302213};
2214
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302215/**
2216 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2217 * @ctx: hdd global context
2218 * @data: capabilities data
2219 *
2220 * Return: none
2221 */
2222static void
2223wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302224{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302225 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302226 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302227 tSirEXTScanCapabilitiesEvent *data =
2228 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302229
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302230 ENTER();
2231
2232 if (wlan_hdd_validate_context(pHddCtx))
2233 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302234 return;
2235 }
2236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302237 if (!pMsg)
2238 {
2239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2240 return;
2241 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302242
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302243 vos_spin_lock_acquire(&hdd_context_lock);
2244
2245 context = &pHddCtx->ext_scan_context;
2246 /* validate response received from target*/
2247 if (context->request_id != data->requestId)
2248 {
2249 vos_spin_lock_release(&hdd_context_lock);
2250 hddLog(LOGE,
2251 FL("Target response id did not match: request_id %d resposne_id %d"),
2252 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302253 return;
2254 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302255 else
2256 {
2257 context->capability_response = *data;
2258 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302259 }
2260
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302261 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302262
Dino Mycle6fb96c12014-06-10 11:52:40 +05302263 return;
2264}
2265
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302266/*
2267 * define short names for the global vendor params
2268 * used by wlan_hdd_send_ext_scan_capability()
2269 */
2270#define PARAM_REQUEST_ID \
2271 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2272#define PARAM_STATUS \
2273 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2274#define MAX_SCAN_CACHE_SIZE \
2275 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2276#define MAX_SCAN_BUCKETS \
2277 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2278#define MAX_AP_CACHE_PER_SCAN \
2279 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2280#define MAX_RSSI_SAMPLE_SIZE \
2281 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2282#define MAX_SCAN_RPT_THRHOLD \
2283 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2284#define MAX_HOTLIST_BSSIDS \
2285 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2286#define MAX_BSSID_HISTORY_ENTRIES \
2287 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2288#define MAX_HOTLIST_SSIDS \
2289 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302290#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2291 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302292
2293static int wlan_hdd_send_ext_scan_capability(void *ctx)
2294{
2295 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2296 struct sk_buff *skb = NULL;
2297 int ret;
2298 tSirEXTScanCapabilitiesEvent *data;
2299 tANI_U32 nl_buf_len;
2300
2301 ret = wlan_hdd_validate_context(pHddCtx);
2302 if (0 != ret)
2303 {
2304 return ret;
2305 }
2306
2307 data = &(pHddCtx->ext_scan_context.capability_response);
2308
2309 nl_buf_len = NLMSG_HDRLEN;
2310 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2311 (sizeof(data->status) + NLA_HDRLEN) +
2312 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2313 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2314 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2315 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2316 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2317 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2318 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2319 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2320
2321 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2322
2323 if (!skb)
2324 {
2325 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2326 return -ENOMEM;
2327 }
2328
2329 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2330 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2331 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2332 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2333 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2334 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2335 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2336 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2337
2338 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2339 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2340 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2341 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2342 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2343 data->maxApPerScan) ||
2344 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2345 data->maxRssiSampleSize) ||
2346 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2347 data->maxScanReportingThreshold) ||
2348 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2349 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2350 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302351 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2352 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302353 {
2354 hddLog(LOGE, FL("nla put fail"));
2355 goto nla_put_failure;
2356 }
2357
2358 cfg80211_vendor_cmd_reply(skb);
2359 return 0;
2360
2361nla_put_failure:
2362 kfree_skb(skb);
2363 return -EINVAL;;
2364}
2365
2366/*
2367 * done with short names for the global vendor params
2368 * used by wlan_hdd_send_ext_scan_capability()
2369 */
2370#undef PARAM_REQUEST_ID
2371#undef PARAM_STATUS
2372#undef MAX_SCAN_CACHE_SIZE
2373#undef MAX_SCAN_BUCKETS
2374#undef MAX_AP_CACHE_PER_SCAN
2375#undef MAX_RSSI_SAMPLE_SIZE
2376#undef MAX_SCAN_RPT_THRHOLD
2377#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302378#undef MAX_BSSID_HISTORY_ENTRIES
2379#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302380
2381static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2382{
2383 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2384 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302385 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302386 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302387
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302388 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302389
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302390 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302391 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302392
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302393 if (!pMsg)
2394 {
2395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302396 return;
2397 }
2398
Dino Mycle6fb96c12014-06-10 11:52:40 +05302399 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2400 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2401
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302402 context = &pHddCtx->ext_scan_context;
2403 spin_lock(&hdd_context_lock);
2404 if (context->request_id == pData->requestId) {
2405 context->response_status = pData->status ? -EINVAL : 0;
2406 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302407 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302408 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302409
2410 /*
2411 * Store the Request ID for comparing with the requestID obtained
2412 * in other requests.HDD shall return a failure is the extscan_stop
2413 * request is issued with a different requestId as that of the
2414 * extscan_start request. Also, This requestId shall be used while
2415 * indicating the full scan results to the upper layers.
2416 * The requestId is stored with the assumption that the firmware
2417 * shall return the ext scan start request's requestId in ext scan
2418 * start response.
2419 */
2420 if (pData->status == 0)
2421 pMac->sme.extScanStartReqId = pData->requestId;
2422
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302423 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302424 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302425}
2426
2427
2428static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2429{
2430 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2431 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302432 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302433
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302434 ENTER();
2435
2436 if (wlan_hdd_validate_context(pHddCtx)){
2437 return;
2438 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302439
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302440 if (!pMsg)
2441 {
2442 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302443 return;
2444 }
2445
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302446 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2447 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302448
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302449 context = &pHddCtx->ext_scan_context;
2450 spin_lock(&hdd_context_lock);
2451 if (context->request_id == pData->requestId) {
2452 context->response_status = pData->status ? -EINVAL : 0;
2453 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302454 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302455 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302456
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302457 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302458 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302459}
2460
Dino Mycle6fb96c12014-06-10 11:52:40 +05302461static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2462 void *pMsg)
2463{
2464 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302465 tpSirEXTScanSetBssidHotListRspParams pData =
2466 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302467 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302468
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302469 ENTER();
2470
2471 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302472 return;
2473 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302474
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302475 if (!pMsg)
2476 {
2477 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2478 return;
2479 }
2480
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302481 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2482 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302483
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302484 context = &pHddCtx->ext_scan_context;
2485 spin_lock(&hdd_context_lock);
2486 if (context->request_id == pData->requestId) {
2487 context->response_status = pData->status ? -EINVAL : 0;
2488 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302489 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302490 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302491
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302492 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302493 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302494}
2495
2496static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2497 void *pMsg)
2498{
2499 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302500 tpSirEXTScanResetBssidHotlistRspParams pData =
2501 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302502 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302504 ENTER();
2505
2506 if (wlan_hdd_validate_context(pHddCtx)) {
2507 return;
2508 }
2509 if (!pMsg)
2510 {
2511 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302512 return;
2513 }
2514
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302515 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2516 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302517
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302518 context = &pHddCtx->ext_scan_context;
2519 spin_lock(&hdd_context_lock);
2520 if (context->request_id == pData->requestId) {
2521 context->response_status = pData->status ? -EINVAL : 0;
2522 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302523 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302524 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302526 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302527 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302528}
2529
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05302530static void wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(void *ctx,
2531 void *pMsg)
2532{
2533 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2534 tpSirEXTScanSetSsidHotListRspParams pData =
2535 (tpSirEXTScanSetSsidHotListRspParams) pMsg;
2536 struct hdd_ext_scan_context *context;
2537
2538 if (wlan_hdd_validate_context(pHddCtx)){
2539 return;
2540 }
2541
2542 if (!pMsg)
2543 {
2544 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2545 return;
2546 }
2547
2548 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2549 pData->status);
2550
2551 context = &pHddCtx->ext_scan_context;
2552 spin_lock(&hdd_context_lock);
2553 if (context->request_id == pData->requestId) {
2554 context->response_status = pData->status ? -EINVAL : 0;
2555 complete(&context->response_event);
2556 }
2557 spin_unlock(&hdd_context_lock);
2558
2559 return;
2560}
2561
2562static void wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(void *ctx,
2563 void *pMsg)
2564{
2565 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2566 tpSirEXTScanResetSsidHotlistRspParams pData =
2567 (tpSirEXTScanResetSsidHotlistRspParams) pMsg;
2568 struct hdd_ext_scan_context *context;
2569
2570 if (wlan_hdd_validate_context(pHddCtx)) {
2571 return;
2572 }
2573 if (!pMsg)
2574 {
2575 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2576 return;
2577 }
2578
2579 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2580 pData->status);
2581
2582 context = &pHddCtx->ext_scan_context;
2583 spin_lock(&hdd_context_lock);
2584 if (context->request_id == pData->requestId) {
2585 context->response_status = pData->status ? -EINVAL : 0;
2586 complete(&context->response_event);
2587 }
2588 spin_unlock(&hdd_context_lock);
2589
2590 return;
2591}
2592
2593
Dino Mycle6fb96c12014-06-10 11:52:40 +05302594static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2595 void *pMsg)
2596{
2597 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2598 struct sk_buff *skb = NULL;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302599 tANI_U32 i = 0, j, resultsPerEvent, scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302600 tANI_S32 totalResults;
2601 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302602 tpSirWifiScanResult pSirWifiScanResult, head_ptr;
2603 struct hdd_ext_scan_context *context;
2604 bool ignore_cached_results = false;
2605 tExtscanCachedScanResult *result;
2606 struct nlattr *nla_results;
2607 tANI_U16 ieLength= 0;
2608 tANI_U8 *ie = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302609
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302610 ENTER();
2611
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302612 if (wlan_hdd_validate_context(pHddCtx))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302613 return;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302614
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302615 if (!pMsg)
2616 {
2617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2618 return;
2619 }
2620
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302621 spin_lock(&hdd_context_lock);
2622 context = &pHddCtx->ext_scan_context;
2623 ignore_cached_results = context->ignore_cached_results;
2624 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302625
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302626 if (ignore_cached_results) {
2627 hddLog(LOGE,
2628 FL("Ignore the cached results received after timeout"));
2629 return;
2630 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302631
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302632 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u",
2633 pData->requestId, pData->moreData, pData->scanResultSize);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302634
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302635 result = (tExtscanCachedScanResult *)&(pData->result);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302637 for (scan_id_index = 0; scan_id_index < pData->scanResultSize;
2638 scan_id_index++) {
2639 result+= scan_id_index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302640
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302641 totalResults = result->num_results;
2642 hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u",
2643 result->scan_id, result->flags, totalResults);
2644 i = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302645
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302646 do{
2647 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2648 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2649 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302650
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302651 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
2652 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN);
2653
2654 if (!skb) {
2655 hddLog(VOS_TRACE_LEVEL_ERROR,
2656 FL("cfg80211_vendor_event_alloc failed"));
2657 return;
2658 }
2659
2660 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2661
2662 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2663 pData->requestId) ||
2664 nla_put_u32(skb,
2665 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2666 resultsPerEvent)) {
2667 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2668 goto fail;
2669 }
2670 if (nla_put_u8(skb,
2671 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2672 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302673 {
2674 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2675 goto fail;
2676 }
2677
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302678 if (nla_put_u32(skb,
2679 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2680 result->scan_id)) {
2681 hddLog(LOGE, FL("put fail"));
2682 goto fail;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302683 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302684
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302685 nla_results = nla_nest_start(skb,
2686 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST);
2687 if (!nla_results)
2688 goto fail;
2689
2690 if (resultsPerEvent) {
2691 struct nlattr *aps;
2692 struct nlattr *nla_result;
2693
2694 nla_result = nla_nest_start(skb, scan_id_index);
2695 if(!nla_result)
2696 goto fail;
2697
2698 if (nla_put_u32(skb,
2699 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
2700 result->scan_id) ||
2701 nla_put_u32(skb,
2702 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
2703 result->flags) ||
2704 nla_put_u32(skb,
2705 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2706 totalResults)) {
2707 hddLog(LOGE, FL("put fail"));
2708 goto fail;
2709 }
2710
2711 aps = nla_nest_start(skb,
2712 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2713 if (!aps)
2714 {
2715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2716 goto fail;
2717 }
2718
2719 head_ptr = (tpSirWifiScanResult) &(result->ap);
2720
2721 for (j = 0; j < resultsPerEvent; j++, i++) {
2722 struct nlattr *ap;
2723 pSirWifiScanResult = head_ptr + i;
2724
2725 /*
Srinivas Dasari91727c12016-03-23 17:59:06 +05302726 * Firmware returns timestamp from extscan_start till
2727 * BSSID was cached (in micro seconds). Add this with
2728 * time gap between system boot up to extscan_start
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302729 * to derive the time since boot when the
2730 * BSSID was cached.
2731 */
Srinivas Dasari91727c12016-03-23 17:59:06 +05302732 pSirWifiScanResult->ts +=
2733 pHddCtx->extscan_start_time_since_boot;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05302734 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2735 "Ssid (%s)"
2736 "Bssid: %pM "
2737 "Channel (%u)"
2738 "Rssi (%d)"
2739 "RTT (%u)"
2740 "RTT_SD (%u)"
2741 "Beacon Period %u"
2742 "Capability 0x%x "
2743 "Ie length %d",
2744 i,
2745 pSirWifiScanResult->ts,
2746 pSirWifiScanResult->ssid,
2747 pSirWifiScanResult->bssid,
2748 pSirWifiScanResult->channel,
2749 pSirWifiScanResult->rssi,
2750 pSirWifiScanResult->rtt,
2751 pSirWifiScanResult->rtt_sd,
2752 pSirWifiScanResult->beaconPeriod,
2753 pSirWifiScanResult->capability,
2754 ieLength);
2755
2756 ap = nla_nest_start(skb, j + 1);
2757 if (!ap)
2758 {
2759 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2760 goto fail;
2761 }
2762
2763 if (nla_put_u64(skb,
2764 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2765 pSirWifiScanResult->ts) )
2766 {
2767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2768 goto fail;
2769 }
2770 if (nla_put(skb,
2771 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2772 sizeof(pSirWifiScanResult->ssid),
2773 pSirWifiScanResult->ssid) )
2774 {
2775 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2776 goto fail;
2777 }
2778 if (nla_put(skb,
2779 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2780 sizeof(pSirWifiScanResult->bssid),
2781 pSirWifiScanResult->bssid) )
2782 {
2783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2784 goto fail;
2785 }
2786 if (nla_put_u32(skb,
2787 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2788 pSirWifiScanResult->channel) )
2789 {
2790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2791 goto fail;
2792 }
2793 if (nla_put_s32(skb,
2794 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2795 pSirWifiScanResult->rssi) )
2796 {
2797 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2798 goto fail;
2799 }
2800 if (nla_put_u32(skb,
2801 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2802 pSirWifiScanResult->rtt) )
2803 {
2804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2805 goto fail;
2806 }
2807 if (nla_put_u32(skb,
2808 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2809 pSirWifiScanResult->rtt_sd))
2810 {
2811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2812 goto fail;
2813 }
2814 if (nla_put_u32(skb,
2815 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2816 pSirWifiScanResult->beaconPeriod))
2817 {
2818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2819 goto fail;
2820 }
2821 if (nla_put_u32(skb,
2822 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2823 pSirWifiScanResult->capability))
2824 {
2825 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2826 goto fail;
2827 }
2828 if (nla_put_u32(skb,
2829 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2830 ieLength))
2831 {
2832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2833 goto fail;
2834 }
2835
2836 if (ieLength)
2837 if (nla_put(skb,
2838 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2839 ieLength, ie)) {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843
2844 nla_nest_end(skb, ap);
2845 }
2846 nla_nest_end(skb, aps);
2847 nla_nest_end(skb, nla_result);
2848 }
2849
2850 nla_nest_end(skb, nla_results);
2851
2852 cfg80211_vendor_cmd_reply(skb);
2853
2854 } while (totalResults > 0);
2855 }
2856
2857 if (!pData->moreData) {
2858 spin_lock(&hdd_context_lock);
2859 context->response_status = 0;
2860 complete(&context->response_event);
2861 spin_unlock(&hdd_context_lock);
2862 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302863
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302864 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302865 return;
2866fail:
2867 kfree_skb(skb);
2868 return;
2869}
2870
2871static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2872 void *pMsg)
2873{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302874 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302875 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2876 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302877 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302878
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302879 ENTER();
2880
2881 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302882 hddLog(LOGE,
2883 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302884 return;
2885 }
2886 if (!pMsg)
2887 {
2888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302889 return;
2890 }
2891
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302892 if (pData->bss_found)
2893 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2894 else
2895 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2896
Dino Mycle6fb96c12014-06-10 11:52:40 +05302897 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302898#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2899 NULL,
2900#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302901 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302902 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302903
2904 if (!skb) {
2905 hddLog(VOS_TRACE_LEVEL_ERROR,
2906 FL("cfg80211_vendor_event_alloc failed"));
2907 return;
2908 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302909
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302910 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2911 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2912 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2913 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2914
2915 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302916 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2917 "Ssid (%s) "
2918 "Bssid (" MAC_ADDRESS_STR ") "
2919 "Channel (%u) "
2920 "Rssi (%d) "
2921 "RTT (%u) "
2922 "RTT_SD (%u) ",
2923 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302924 pData->bssHotlist[i].ts,
2925 pData->bssHotlist[i].ssid,
2926 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2927 pData->bssHotlist[i].channel,
2928 pData->bssHotlist[i].rssi,
2929 pData->bssHotlist[i].rtt,
2930 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302931 }
2932
2933 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2934 pData->requestId) ||
2935 nla_put_u32(skb,
2936 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302937 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2939 goto fail;
2940 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302941 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302942 struct nlattr *aps;
2943
2944 aps = nla_nest_start(skb,
2945 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2946 if (!aps)
2947 goto fail;
2948
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302949 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302950 struct nlattr *ap;
2951
2952 ap = nla_nest_start(skb, i + 1);
2953 if (!ap)
2954 goto fail;
2955
2956 if (nla_put_u64(skb,
2957 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302958 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302959 nla_put(skb,
2960 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302961 sizeof(pData->bssHotlist[i].ssid),
2962 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302963 nla_put(skb,
2964 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302965 sizeof(pData->bssHotlist[i].bssid),
2966 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302967 nla_put_u32(skb,
2968 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302969 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302970 nla_put_s32(skb,
2971 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302972 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302973 nla_put_u32(skb,
2974 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302975 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302976 nla_put_u32(skb,
2977 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302978 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302979 goto fail;
2980
2981 nla_nest_end(skb, ap);
2982 }
2983 nla_nest_end(skb, aps);
2984
2985 if (nla_put_u8(skb,
2986 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2987 pData->moreData))
2988 goto fail;
2989 }
2990
2991 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302993 return;
2994
2995fail:
2996 kfree_skb(skb);
2997 return;
2998
2999}
Dino Mycle6fb96c12014-06-10 11:52:40 +05303000
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303001/**
3002 * wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind() -
3003 * Handle an SSID hotlist match event
3004 * @ctx: HDD context registered with SME
3005 * @event: The SSID hotlist match event
3006 *
3007 * This function will take an SSID match event that was generated by
3008 * firmware and will convert it into a cfg80211 vendor event which is
3009 * sent to userspace.
3010 *
3011 * Return: none
3012 */
3013static void
3014wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(void *ctx,
3015 void *pMsg)
3016{
3017 hdd_context_t *hdd_ctx = ctx;
3018 struct sk_buff *skb;
3019 tANI_U32 i, index;
3020 tpSirEXTScanSsidHotlistMatch pData = (tpSirEXTScanSsidHotlistMatch) pMsg;
3021
3022 ENTER();
3023
3024 if (wlan_hdd_validate_context(hdd_ctx)) {
3025 hddLog(LOGE,
3026 FL("HDD context is not valid or response"));
3027 return;
3028 }
3029 if (!pMsg)
3030 {
3031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3032 return;
3033 }
3034
3035 if (pData->ssid_found) {
3036 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX;
3037 hddLog(LOG1, "SSID hotlist found");
3038 } else {
3039 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX;
3040 hddLog(LOG1, "SSID hotlist lost");
3041 }
3042
3043 skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
3044#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3045 NULL,
3046#endif
3047 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3048 index, GFP_KERNEL);
3049
3050 if (!skb) {
3051 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
3052 return;
3053 }
3054 hddLog(LOG1, "Req Id %u, Num of SSIDs %u, More Data (%u)",
3055 pData->requestId, pData->numHotlistSsid, pData->moreData);
3056
3057 for (i = 0; i < pData->numHotlistSsid; i++) {
3058 hddLog(LOG1, "[i=%d] Timestamp %llu "
3059 "Ssid: %s "
3060 "Bssid (" MAC_ADDRESS_STR ") "
3061 "Channel %u "
3062 "Rssi %d "
3063 "RTT %u "
3064 "RTT_SD %u",
3065 i,
3066 pData->ssidHotlist[i].ts,
3067 pData->ssidHotlist[i].ssid,
3068 MAC_ADDR_ARRAY(pData->ssidHotlist[i].bssid),
3069 pData->ssidHotlist[i].channel,
3070 pData->ssidHotlist[i].rssi,
3071 pData->ssidHotlist[i].rtt,
3072 pData->ssidHotlist[i].rtt_sd);
3073 }
3074
3075 if (nla_put_u32(skb,
3076 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3077 pData->requestId) ||
3078 nla_put_u32(skb,
3079 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3080 pData->numHotlistSsid)) {
3081 hddLog(LOGE, FL("put fail"));
3082 goto fail;
3083 }
3084
3085 if (pData->numHotlistSsid) {
3086 struct nlattr *aps;
3087 aps = nla_nest_start(skb,
3088 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3089 if (!aps) {
3090 hddLog(LOGE, FL("nest fail"));
3091 goto fail;
3092 }
3093
3094 for (i = 0; i < pData->numHotlistSsid; i++) {
3095 struct nlattr *ap;
3096
3097 ap = nla_nest_start(skb, i);
3098 if (!ap) {
3099 hddLog(LOGE, FL("nest fail"));
3100 goto fail;
3101 }
3102
3103 if (nla_put_u64(skb,
3104 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3105 pData->ssidHotlist[i].ts) ||
3106 nla_put(skb,
3107 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3108 sizeof(pData->ssidHotlist[i].ssid),
3109 pData->ssidHotlist[i].ssid) ||
3110 nla_put(skb,
3111 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3112 sizeof(pData->ssidHotlist[i].bssid),
3113 pData->ssidHotlist[i].bssid) ||
3114 nla_put_u32(skb,
3115 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3116 pData->ssidHotlist[i].channel) ||
3117 nla_put_s32(skb,
3118 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3119 pData->ssidHotlist[i].rssi) ||
3120 nla_put_u32(skb,
3121 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3122 pData->ssidHotlist[i].rtt) ||
3123 nla_put_u32(skb,
3124 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3125 pData->ssidHotlist[i].rtt_sd)) {
3126 hddLog(LOGE, FL("put fail"));
3127 goto fail;
3128 }
3129 nla_nest_end(skb, ap);
3130 }
3131 nla_nest_end(skb, aps);
3132
3133 if (nla_put_u8(skb,
3134 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3135 pData->moreData)) {
3136 hddLog(LOGE, FL("put fail"));
3137 goto fail;
3138 }
3139 }
3140
3141 cfg80211_vendor_event(skb, GFP_KERNEL);
3142 return;
3143
3144fail:
3145 kfree_skb(skb);
3146 return;
3147
3148}
3149
3150
Dino Mycle6fb96c12014-06-10 11:52:40 +05303151static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3152 void *pMsg)
3153{
3154 struct sk_buff *skb;
3155 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3156 tpSirWifiFullScanResultEvent pData =
3157 (tpSirWifiFullScanResultEvent) (pMsg);
3158
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303159 ENTER();
3160
3161 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303162 hddLog(LOGE,
3163 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303164 return;
3165 }
3166 if (!pMsg)
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303169 return;
3170 }
3171
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303172 /*
3173 * If the full scan result including IE data exceeds NL 4K size
3174 * limitation, drop that beacon/probe rsp frame.
3175 */
3176 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
3177 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
3178 return;
3179 }
3180
Dino Mycle6fb96c12014-06-10 11:52:40 +05303181 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303182#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3183 NULL,
3184#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303185 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3186 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3187 GFP_KERNEL);
3188
3189 if (!skb) {
3190 hddLog(VOS_TRACE_LEVEL_ERROR,
3191 FL("cfg80211_vendor_event_alloc failed"));
3192 return;
3193 }
3194
Dino Mycle6fb96c12014-06-10 11:52:40 +05303195 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3196 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3197 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3198 "Ssid (%s)"
3199 "Bssid (" MAC_ADDRESS_STR ")"
3200 "Channel (%u)"
3201 "Rssi (%d)"
3202 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303203 "RTT_SD (%u)"
3204 "Bcn Period %d"
3205 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303206 pData->ap.ts,
3207 pData->ap.ssid,
3208 MAC_ADDR_ARRAY(pData->ap.bssid),
3209 pData->ap.channel,
3210 pData->ap.rssi,
3211 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303212 pData->ap.rtt_sd,
3213 pData->ap.beaconPeriod,
3214 pData->ap.capability);
3215
Dino Mycle6fb96c12014-06-10 11:52:40 +05303216 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3217 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3218 pData->requestId) ||
3219 nla_put_u64(skb,
3220 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3221 pData->ap.ts) ||
3222 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3223 sizeof(pData->ap.ssid),
3224 pData->ap.ssid) ||
3225 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3226 WNI_CFG_BSSID_LEN,
3227 pData->ap.bssid) ||
3228 nla_put_u32(skb,
3229 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3230 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303231 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303232 pData->ap.rssi) ||
3233 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3234 pData->ap.rtt) ||
3235 nla_put_u32(skb,
3236 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3237 pData->ap.rtt_sd) ||
3238 nla_put_u16(skb,
3239 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3240 pData->ap.beaconPeriod) ||
3241 nla_put_u16(skb,
3242 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3243 pData->ap.capability) ||
3244 nla_put_u32(skb,
3245 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303246 pData->ieLength) ||
3247 nla_put_u8(skb,
3248 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3249 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303250 {
3251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3252 goto nla_put_failure;
3253 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303254
3255 if (pData->ieLength) {
3256 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3257 pData->ieLength,
3258 pData->ie))
3259 {
3260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3261 goto nla_put_failure;
3262 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303263 }
3264
3265 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303266 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303267 return;
3268
3269nla_put_failure:
3270 kfree_skb(skb);
3271 return;
3272}
3273
3274static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3275 void *pMsg)
3276{
3277 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3278 struct sk_buff *skb = NULL;
3279 tpSirEXTScanResultsAvailableIndParams pData =
3280 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303282 ENTER();
3283
3284 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303285 hddLog(LOGE,
3286 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303287 return;
3288 }
3289 if (!pMsg)
3290 {
3291 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303292 return;
3293 }
3294
3295 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303296#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3297 NULL,
3298#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303299 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3300 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3301 GFP_KERNEL);
3302
3303 if (!skb) {
3304 hddLog(VOS_TRACE_LEVEL_ERROR,
3305 FL("cfg80211_vendor_event_alloc failed"));
3306 return;
3307 }
3308
Dino Mycle6fb96c12014-06-10 11:52:40 +05303309 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3310 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3311 pData->numResultsAvailable);
3312 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3313 pData->requestId) ||
3314 nla_put_u32(skb,
3315 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3316 pData->numResultsAvailable)) {
3317 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3318 goto nla_put_failure;
3319 }
3320
3321 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303322 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303323 return;
3324
3325nla_put_failure:
3326 kfree_skb(skb);
3327 return;
3328}
3329
3330static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3331{
3332 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3333 struct sk_buff *skb = NULL;
3334 tpSirEXTScanProgressIndParams pData =
3335 (tpSirEXTScanProgressIndParams) pMsg;
3336
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303337 ENTER();
3338
3339 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303340 hddLog(LOGE,
3341 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303342 return;
3343 }
3344 if (!pMsg)
3345 {
3346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 return;
3348 }
3349
3350 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3352 NULL,
3353#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3355 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3356 GFP_KERNEL);
3357
3358 if (!skb) {
3359 hddLog(VOS_TRACE_LEVEL_ERROR,
3360 FL("cfg80211_vendor_event_alloc failed"));
3361 return;
3362 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303363 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3365 pData->extScanEventType);
3366 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3367 pData->status);
3368
3369 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3370 pData->extScanEventType) ||
3371 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3373 pData->requestId) ||
3374 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3376 pData->status)) {
3377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3378 goto nla_put_failure;
3379 }
3380
3381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return;
3384
3385nla_put_failure:
3386 kfree_skb(skb);
3387 return;
3388}
3389
3390void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3391 void *pMsg)
3392{
3393 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303395 ENTER();
3396
Dino Mycle6fb96c12014-06-10 11:52:40 +05303397 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303398 return;
3399 }
3400
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3402
3403
3404 switch(evType) {
3405 case SIR_HAL_EXTSCAN_START_RSP:
3406 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3407 break;
3408
3409 case SIR_HAL_EXTSCAN_STOP_RSP:
3410 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3411 break;
3412 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3413 /* There is no need to send this response to upper layer
3414 Just log the message */
3415 hddLog(VOS_TRACE_LEVEL_INFO,
3416 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3417 break;
3418 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3419 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3420 break;
3421
3422 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3423 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3424 break;
3425
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303426 case SIR_HAL_EXTSCAN_SET_SSID_HOTLIST_RSP:
3427 wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(ctx, pMsg);
3428 break;
3429
3430 case SIR_HAL_EXTSCAN_RESET_SSID_HOTLIST_RSP:
3431 wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(ctx, pMsg);
3432 break;
3433
Dino Mycle6fb96c12014-06-10 11:52:40 +05303434 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303435 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303436 break;
3437 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3438 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3439 break;
3440 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3441 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3442 break;
3443 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3444 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3445 break;
3446 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3447 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3448 break;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303449 case SIR_HAL_EXTSCAN_SSID_HOTLIST_MATCH_IND:
3450 wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(ctx, pMsg);
3451 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303452 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3453 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3454 break;
3455 default:
3456 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3457 break;
3458 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303459 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303460}
3461
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303462static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3463 struct wireless_dev *wdev,
3464 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303465{
Dino Myclee8843b32014-07-04 14:21:45 +05303466 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303467 struct net_device *dev = wdev->netdev;
3468 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3469 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3470 struct nlattr
3471 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3472 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303473 struct hdd_ext_scan_context *context;
3474 unsigned long rc;
3475 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303476
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303477 ENTER();
3478
Dino Mycle6fb96c12014-06-10 11:52:40 +05303479 status = wlan_hdd_validate_context(pHddCtx);
3480 if (0 != status)
3481 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303482 return -EINVAL;
3483 }
Dino Myclee8843b32014-07-04 14:21:45 +05303484 /* check the EXTScan Capability */
3485 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303486 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3487 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303488 {
3489 hddLog(VOS_TRACE_LEVEL_ERROR,
3490 FL("EXTScan not enabled/supported by Firmware"));
3491 return -EINVAL;
3492 }
3493
Dino Mycle6fb96c12014-06-10 11:52:40 +05303494 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3495 data, dataLen,
3496 wlan_hdd_extscan_config_policy)) {
3497 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3498 return -EINVAL;
3499 }
3500
3501 /* Parse and fetch request Id */
3502 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3503 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3504 return -EINVAL;
3505 }
3506
Dino Myclee8843b32014-07-04 14:21:45 +05303507 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303508 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303509 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303510
Dino Myclee8843b32014-07-04 14:21:45 +05303511 reqMsg.sessionId = pAdapter->sessionId;
3512 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303513
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303514 vos_spin_lock_acquire(&hdd_context_lock);
3515 context = &pHddCtx->ext_scan_context;
3516 context->request_id = reqMsg.requestId;
3517 INIT_COMPLETION(context->response_event);
3518 vos_spin_lock_release(&hdd_context_lock);
3519
Dino Myclee8843b32014-07-04 14:21:45 +05303520 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303521 if (!HAL_STATUS_SUCCESS(status)) {
3522 hddLog(VOS_TRACE_LEVEL_ERROR,
3523 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524 return -EINVAL;
3525 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303526
3527 rc = wait_for_completion_timeout(&context->response_event,
3528 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3529 if (!rc) {
3530 hddLog(LOGE, FL("Target response timed out"));
3531 return -ETIMEDOUT;
3532 }
3533
3534 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3535 if (ret)
3536 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3537
3538 return ret;
3539
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303540 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303541 return 0;
3542}
3543
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303544static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3545 struct wireless_dev *wdev,
3546 const void *data, int dataLen)
3547{
3548 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303549
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303550 vos_ssr_protect(__func__);
3551 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3552 vos_ssr_unprotect(__func__);
3553
3554 return ret;
3555}
3556
3557static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3558 struct wireless_dev *wdev,
3559 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303560{
Dino Myclee8843b32014-07-04 14:21:45 +05303561 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303562 struct net_device *dev = wdev->netdev;
3563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3564 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3565 struct nlattr
3566 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3567 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303568 struct hdd_ext_scan_context *context;
3569 unsigned long rc;
3570 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303571
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303572 ENTER();
3573
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303574 if (VOS_FTM_MODE == hdd_get_conparam()) {
3575 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3576 return -EINVAL;
3577 }
3578
Dino Mycle6fb96c12014-06-10 11:52:40 +05303579 status = wlan_hdd_validate_context(pHddCtx);
3580 if (0 != status)
3581 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303582 return -EINVAL;
3583 }
Dino Myclee8843b32014-07-04 14:21:45 +05303584 /* check the EXTScan Capability */
3585 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303586 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3587 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303588 {
3589 hddLog(VOS_TRACE_LEVEL_ERROR,
3590 FL("EXTScan not enabled/supported by Firmware"));
3591 return -EINVAL;
3592 }
3593
Dino Mycle6fb96c12014-06-10 11:52:40 +05303594 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3595 data, dataLen,
3596 wlan_hdd_extscan_config_policy)) {
3597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3598 return -EINVAL;
3599 }
3600 /* Parse and fetch request Id */
3601 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3602 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3603 return -EINVAL;
3604 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303605
Dino Myclee8843b32014-07-04 14:21:45 +05303606 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303607 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3608
Dino Myclee8843b32014-07-04 14:21:45 +05303609 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610
Dino Myclee8843b32014-07-04 14:21:45 +05303611 reqMsg.sessionId = pAdapter->sessionId;
3612 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303613
3614 /* Parse and fetch flush parameter */
3615 if (!tb
3616 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3617 {
3618 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3619 goto failed;
3620 }
Dino Myclee8843b32014-07-04 14:21:45 +05303621 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303622 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3623
Dino Myclee8843b32014-07-04 14:21:45 +05303624 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303625
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303626 spin_lock(&hdd_context_lock);
3627 context = &pHddCtx->ext_scan_context;
3628 context->request_id = reqMsg.requestId;
3629 context->ignore_cached_results = false;
3630 INIT_COMPLETION(context->response_event);
3631 spin_unlock(&hdd_context_lock);
3632
Dino Myclee8843b32014-07-04 14:21:45 +05303633 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303634 if (!HAL_STATUS_SUCCESS(status)) {
3635 hddLog(VOS_TRACE_LEVEL_ERROR,
3636 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 return -EINVAL;
3638 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303639
3640 rc = wait_for_completion_timeout(&context->response_event,
3641 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3642 if (!rc) {
3643 hddLog(LOGE, FL("Target response timed out"));
3644 retval = -ETIMEDOUT;
3645 spin_lock(&hdd_context_lock);
3646 context->ignore_cached_results = true;
3647 spin_unlock(&hdd_context_lock);
3648 } else {
3649 spin_lock(&hdd_context_lock);
3650 retval = context->response_status;
3651 spin_unlock(&hdd_context_lock);
3652 }
3653
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303654 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303655 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303656
3657failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303658 return -EINVAL;
3659}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303660static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3661 struct wireless_dev *wdev,
3662 const void *data, int dataLen)
3663{
3664 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303665
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303666 vos_ssr_protect(__func__);
3667 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3668 vos_ssr_unprotect(__func__);
3669
3670 return ret;
3671}
3672
3673static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303675 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303676{
3677 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3678 struct net_device *dev = wdev->netdev;
3679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3680 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3681 struct nlattr
3682 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr
3684 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3685 struct nlattr *apTh;
3686 eHalStatus status;
3687 tANI_U8 i = 0;
3688 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303689 struct hdd_ext_scan_context *context;
3690 tANI_U32 request_id;
3691 unsigned long rc;
3692 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303694 ENTER();
3695
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303696 if (VOS_FTM_MODE == hdd_get_conparam()) {
3697 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3698 return -EINVAL;
3699 }
3700
Dino Mycle6fb96c12014-06-10 11:52:40 +05303701 status = wlan_hdd_validate_context(pHddCtx);
3702 if (0 != status)
3703 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 return -EINVAL;
3705 }
Dino Myclee8843b32014-07-04 14:21:45 +05303706 /* check the EXTScan Capability */
3707 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303708 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3709 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303710 {
3711 hddLog(VOS_TRACE_LEVEL_ERROR,
3712 FL("EXTScan not enabled/supported by Firmware"));
3713 return -EINVAL;
3714 }
3715
Dino Mycle6fb96c12014-06-10 11:52:40 +05303716 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3717 data, dataLen,
3718 wlan_hdd_extscan_config_policy)) {
3719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3720 return -EINVAL;
3721 }
3722
3723 /* Parse and fetch request Id */
3724 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3726 return -EINVAL;
3727 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303728 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3729 vos_mem_malloc(sizeof(*pReqMsg));
3730 if (!pReqMsg) {
3731 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3732 return -ENOMEM;
3733 }
3734
Dino Myclee8843b32014-07-04 14:21:45 +05303735
Dino Mycle6fb96c12014-06-10 11:52:40 +05303736 pReqMsg->requestId = nla_get_u32(
3737 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3738 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3739
3740 /* Parse and fetch number of APs */
3741 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3742 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3743 goto fail;
3744 }
3745
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303746 /* Parse and fetch lost ap sample size */
3747 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3748 hddLog(LOGE, FL("attr lost ap sample size failed"));
3749 goto fail;
3750 }
3751
3752 pReqMsg->lostBssidSampleSize = nla_get_u32(
3753 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3754 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3755
Dino Mycle6fb96c12014-06-10 11:52:40 +05303756 pReqMsg->sessionId = pAdapter->sessionId;
3757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3758
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303759 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303760 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303761 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303762
3763 nla_for_each_nested(apTh,
3764 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3765 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3766 nla_data(apTh), nla_len(apTh),
3767 NULL)) {
3768 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3769 goto fail;
3770 }
3771
3772 /* Parse and fetch MAC address */
3773 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3775 goto fail;
3776 }
3777 memcpy(pReqMsg->ap[i].bssid, nla_data(
3778 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3779 sizeof(tSirMacAddr));
3780 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3781
3782 /* Parse and fetch low RSSI */
3783 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3785 goto fail;
3786 }
3787 pReqMsg->ap[i].low = nla_get_s32(
3788 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3789 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3790
3791 /* Parse and fetch high RSSI */
3792 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3794 goto fail;
3795 }
3796 pReqMsg->ap[i].high = nla_get_s32(
3797 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3798 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3799 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303800 i++;
3801 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303802
3803 context = &pHddCtx->ext_scan_context;
3804 spin_lock(&hdd_context_lock);
3805 INIT_COMPLETION(context->response_event);
3806 context->request_id = request_id = pReqMsg->requestId;
3807 spin_unlock(&hdd_context_lock);
3808
Dino Mycle6fb96c12014-06-10 11:52:40 +05303809 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3810 if (!HAL_STATUS_SUCCESS(status)) {
3811 hddLog(VOS_TRACE_LEVEL_ERROR,
3812 FL("sme_SetBssHotlist failed(err=%d)"), status);
3813 vos_mem_free(pReqMsg);
3814 return -EINVAL;
3815 }
3816
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303817 /* request was sent -- wait for the response */
3818 rc = wait_for_completion_timeout(&context->response_event,
3819 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3820
3821 if (!rc) {
3822 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3823 retval = -ETIMEDOUT;
3824 } else {
3825 spin_lock(&hdd_context_lock);
3826 if (context->request_id == request_id)
3827 retval = context->response_status;
3828 else
3829 retval = -EINVAL;
3830 spin_unlock(&hdd_context_lock);
3831 }
3832
Dino Myclee8843b32014-07-04 14:21:45 +05303833 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303834 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303835 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303836
3837fail:
3838 vos_mem_free(pReqMsg);
3839 return -EINVAL;
3840}
3841
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303842static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3843 struct wireless_dev *wdev,
3844 const void *data, int dataLen)
3845{
3846 int ret = 0;
3847
3848 vos_ssr_protect(__func__);
3849 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3850 dataLen);
3851 vos_ssr_unprotect(__func__);
3852
3853 return ret;
3854}
3855
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303856/*
3857 * define short names for the global vendor params
3858 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3859 */
3860#define PARAM_MAX \
3861QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3862#define PARAM_REQUEST_ID \
3863QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3864#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3865QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3866#define PARAMS_NUM_SSID \
3867QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3868#define THRESHOLD_PARAM \
3869QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3870#define PARAM_SSID \
3871QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3872#define PARAM_BAND \
3873QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3874#define PARAM_RSSI_LOW \
3875QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3876#define PARAM_RSSI_HIGH \
3877QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3878
3879/**
3880 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3881 * @wiphy: Pointer to wireless phy
3882 * @wdev: Pointer to wireless device
3883 * @data: Pointer to data
3884 * @data_len: Data length
3885 *
3886 * Return: 0 on success, negative errno on failure
3887 */
3888static int
3889__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3890 struct wireless_dev *wdev,
3891 const void *data,
3892 int data_len)
3893{
3894 tSirEXTScanSetSsidHotListReqParams *request;
3895 struct net_device *dev = wdev->netdev;
3896 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3897 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3898 struct nlattr *tb[PARAM_MAX + 1];
3899 struct nlattr *tb2[PARAM_MAX + 1];
3900 struct nlattr *ssids;
3901 struct hdd_ext_scan_context *context;
3902 uint32_t request_id;
3903 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3904 int ssid_len;
3905 eHalStatus status;
3906 int i, rem, retval;
3907 unsigned long rc;
3908
3909 ENTER();
3910
3911 if (VOS_FTM_MODE == hdd_get_conparam()) {
3912 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3913 return -EINVAL;
3914 }
3915
3916 retval = wlan_hdd_validate_context(hdd_ctx);
3917 if (0 != retval) {
3918 hddLog(LOGE, FL("HDD context is not valid"));
3919 return -EINVAL;
3920 }
3921
3922 /* check the EXTScan Capability */
3923 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303924 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3925 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303926 {
3927 hddLog(VOS_TRACE_LEVEL_ERROR,
3928 FL("EXTScan not enabled/supported by Firmware"));
3929 return -EINVAL;
3930 }
3931
3932 if (nla_parse(tb, PARAM_MAX,
3933 data, data_len,
3934 wlan_hdd_extscan_config_policy)) {
3935 hddLog(LOGE, FL("Invalid ATTR"));
3936 return -EINVAL;
3937 }
3938
3939 request = vos_mem_malloc(sizeof(*request));
3940 if (!request) {
3941 hddLog(LOGE, FL("vos_mem_malloc failed"));
3942 return -ENOMEM;
3943 }
3944
3945 /* Parse and fetch request Id */
3946 if (!tb[PARAM_REQUEST_ID]) {
3947 hddLog(LOGE, FL("attr request id failed"));
3948 goto fail;
3949 }
3950
3951 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3952 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3953
3954 /* Parse and fetch lost SSID sample size */
3955 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3956 hddLog(LOGE, FL("attr number of Ssid failed"));
3957 goto fail;
3958 }
3959 request->lost_ssid_sample_size =
3960 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3961 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3962 request->lost_ssid_sample_size);
3963
3964 /* Parse and fetch number of hotlist SSID */
3965 if (!tb[PARAMS_NUM_SSID]) {
3966 hddLog(LOGE, FL("attr number of Ssid failed"));
3967 goto fail;
3968 }
3969 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3970 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3971
3972 request->session_id = adapter->sessionId;
3973 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
3974
3975 i = 0;
3976 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
3977 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
3978 hddLog(LOGE,
3979 FL("Too Many SSIDs, %d exceeds %d"),
3980 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
3981 break;
3982 }
3983 if (nla_parse(tb2, PARAM_MAX,
3984 nla_data(ssids), nla_len(ssids),
3985 wlan_hdd_extscan_config_policy)) {
3986 hddLog(LOGE, FL("nla_parse failed"));
3987 goto fail;
3988 }
3989
3990 /* Parse and fetch SSID */
3991 if (!tb2[PARAM_SSID]) {
3992 hddLog(LOGE, FL("attr ssid failed"));
3993 goto fail;
3994 }
3995 nla_memcpy(ssid_string,
3996 tb2[PARAM_SSID],
3997 sizeof(ssid_string));
3998 hddLog(LOG1, FL("SSID %s"),
3999 ssid_string);
4000 ssid_len = strlen(ssid_string);
4001 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
4002 request->ssid[i].ssid.length = ssid_len;
4003 request->ssid[i].ssid.ssId[ssid_len] = '\0';
4004 hddLog(LOG1, FL("After copying SSID %s"),
4005 request->ssid[i].ssid.ssId);
4006 hddLog(LOG1, FL("After copying length: %d"),
4007 ssid_len);
4008
4009 /* Parse and fetch low RSSI */
4010 if (!tb2[PARAM_BAND]) {
4011 hddLog(LOGE, FL("attr band failed"));
4012 goto fail;
4013 }
4014 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
4015 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
4016
4017 /* Parse and fetch low RSSI */
4018 if (!tb2[PARAM_RSSI_LOW]) {
4019 hddLog(LOGE, FL("attr low RSSI failed"));
4020 goto fail;
4021 }
4022 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
4023 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
4024
4025 /* Parse and fetch high RSSI */
4026 if (!tb2[PARAM_RSSI_HIGH]) {
4027 hddLog(LOGE, FL("attr high RSSI failed"));
4028 goto fail;
4029 }
4030 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4031 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4032 i++;
4033 }
4034
4035 context = &hdd_ctx->ext_scan_context;
4036 spin_lock(&hdd_context_lock);
4037 INIT_COMPLETION(context->response_event);
4038 context->request_id = request_id = request->request_id;
4039 spin_unlock(&hdd_context_lock);
4040
4041 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4042 if (!HAL_STATUS_SUCCESS(status)) {
4043 hddLog(LOGE,
4044 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4045 goto fail;
4046 }
4047
4048 vos_mem_free(request);
4049
4050 /* request was sent -- wait for the response */
4051 rc = wait_for_completion_timeout(&context->response_event,
4052 msecs_to_jiffies
4053 (WLAN_WAIT_TIME_EXTSCAN));
4054 if (!rc) {
4055 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4056 retval = -ETIMEDOUT;
4057 } else {
4058 spin_lock(&hdd_context_lock);
4059 if (context->request_id == request_id)
4060 retval = context->response_status;
4061 else
4062 retval = -EINVAL;
4063 spin_unlock(&hdd_context_lock);
4064 }
4065
4066 return retval;
4067
4068fail:
4069 vos_mem_free(request);
4070 return -EINVAL;
4071}
4072
4073/*
4074 * done with short names for the global vendor params
4075 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4076 */
4077#undef PARAM_MAX
4078#undef PARAM_REQUEST_ID
4079#undef PARAMS_NUM_SSID
4080#undef THRESHOLD_PARAM
4081#undef PARAM_SSID
4082#undef PARAM_BAND
4083#undef PARAM_RSSI_LOW
4084#undef PARAM_RSSI_HIGH
4085
4086static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4087 struct wireless_dev *wdev,
4088 const void *data, int dataLen)
4089{
4090 int ret = 0;
4091
4092 vos_ssr_protect(__func__);
4093 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4094 dataLen);
4095 vos_ssr_unprotect(__func__);
4096
4097 return ret;
4098}
4099
4100static int
4101__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4102 struct wireless_dev *wdev,
4103 const void *data,
4104 int data_len)
4105{
4106 tSirEXTScanResetSsidHotlistReqParams request;
4107 struct net_device *dev = wdev->netdev;
4108 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4109 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4110 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4111 struct hdd_ext_scan_context *context;
4112 uint32_t request_id;
4113 eHalStatus status;
4114 int retval;
4115 unsigned long rc;
4116
4117 ENTER();
4118
4119 if (VOS_FTM_MODE == hdd_get_conparam()) {
4120 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4121 return -EINVAL;
4122 }
4123
4124 retval = wlan_hdd_validate_context(hdd_ctx);
4125 if (0 != retval) {
4126 hddLog(LOGE, FL("HDD context is not valid"));
4127 return -EINVAL;
4128 }
4129
4130 /* check the EXTScan Capability */
4131 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304132 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4133 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304134 {
4135 hddLog(LOGE,
4136 FL("EXTScan not enabled/supported by Firmware"));
4137 return -EINVAL;
4138 }
4139
4140 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4141 data, data_len,
4142 wlan_hdd_extscan_config_policy)) {
4143 hddLog(LOGE, FL("Invalid ATTR"));
4144 return -EINVAL;
4145 }
4146
4147 /* Parse and fetch request Id */
4148 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4149 hddLog(LOGE, FL("attr request id failed"));
4150 return -EINVAL;
4151 }
4152
4153 request.requestId = nla_get_u32(
4154 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4155 request.sessionId = adapter->sessionId;
4156 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4157 request.sessionId);
4158
4159 context = &hdd_ctx->ext_scan_context;
4160 spin_lock(&hdd_context_lock);
4161 INIT_COMPLETION(context->response_event);
4162 context->request_id = request_id = request.requestId;
4163 spin_unlock(&hdd_context_lock);
4164
4165 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4166 if (!HAL_STATUS_SUCCESS(status)) {
4167 hddLog(LOGE,
4168 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4169 return -EINVAL;
4170 }
4171
4172 /* request was sent -- wait for the response */
4173 rc = wait_for_completion_timeout(&context->response_event,
4174 msecs_to_jiffies
4175 (WLAN_WAIT_TIME_EXTSCAN));
4176 if (!rc) {
4177 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4178 retval = -ETIMEDOUT;
4179 } else {
4180 spin_lock(&hdd_context_lock);
4181 if (context->request_id == request_id)
4182 retval = context->response_status;
4183 else
4184 retval = -EINVAL;
4185 spin_unlock(&hdd_context_lock);
4186 }
4187
4188 return retval;
4189}
4190
4191static int
4192wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4193 struct wireless_dev *wdev,
4194 const void *data,
4195 int data_len)
4196{
4197 int ret;
4198
4199 vos_ssr_protect(__func__);
4200 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4201 data, data_len);
4202 vos_ssr_unprotect(__func__);
4203
4204 return ret;
4205}
4206
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304207static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304208 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304209 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304210{
4211 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4212 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4213 tANI_U8 numChannels = 0;
4214 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304215 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216 tWifiBand wifiBand;
4217 eHalStatus status;
4218 struct sk_buff *replySkb;
4219 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304220 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304221
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304222 ENTER();
4223
Dino Mycle6fb96c12014-06-10 11:52:40 +05304224 status = wlan_hdd_validate_context(pHddCtx);
4225 if (0 != status)
4226 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304227 return -EINVAL;
4228 }
Dino Myclee8843b32014-07-04 14:21:45 +05304229
Dino Mycle6fb96c12014-06-10 11:52:40 +05304230 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4231 data, dataLen,
4232 wlan_hdd_extscan_config_policy)) {
4233 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4234 return -EINVAL;
4235 }
4236
4237 /* Parse and fetch request Id */
4238 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4240 return -EINVAL;
4241 }
4242 requestId = nla_get_u32(
4243 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4244 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4245
4246 /* Parse and fetch wifi band */
4247 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4248 {
4249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4250 return -EINVAL;
4251 }
4252 wifiBand = nla_get_u32(
4253 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4254 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4255
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304256 /* Parse and fetch max channels */
4257 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4258 {
4259 hddLog(LOGE, FL("attr max channels failed"));
4260 return -EINVAL;
4261 }
4262 maxChannels = nla_get_u32(
4263 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4264 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4265
Dino Mycle6fb96c12014-06-10 11:52:40 +05304266 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
4267 wifiBand, ChannelList,
4268 &numChannels);
4269 if (eHAL_STATUS_SUCCESS != status) {
4270 hddLog(VOS_TRACE_LEVEL_ERROR,
4271 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4272 return -EINVAL;
4273 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304274
4275 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304276 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304277
Dino Mycle6fb96c12014-06-10 11:52:40 +05304278 for (i = 0; i < numChannels; i++)
4279 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4280
4281 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4282 sizeof(u32) * numChannels +
4283 NLMSG_HDRLEN);
4284
4285 if (!replySkb) {
4286 hddLog(VOS_TRACE_LEVEL_ERROR,
4287 FL("valid channels: buffer alloc fail"));
4288 return -EINVAL;
4289 }
4290 if (nla_put_u32(replySkb,
4291 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4292 numChannels) ||
4293 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4294 sizeof(u32) * numChannels, ChannelList)) {
4295
4296 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4297 kfree_skb(replySkb);
4298 return -EINVAL;
4299 }
4300
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304301 ret = cfg80211_vendor_cmd_reply(replySkb);
4302
4303 EXIT();
4304 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304305}
4306
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304307static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4308 struct wireless_dev *wdev,
4309 const void *data, int dataLen)
4310{
4311 int ret = 0;
4312
4313 vos_ssr_protect(__func__);
4314 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4315 dataLen);
4316 vos_ssr_unprotect(__func__);
4317
4318 return ret;
4319}
4320
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304321static int hdd_extscan_start_fill_bucket_channel_spec(
4322 hdd_context_t *pHddCtx,
4323 tpSirEXTScanStartReqParams pReqMsg,
4324 struct nlattr **tb)
4325{
4326 struct nlattr *bucket[
4327 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4328 struct nlattr *channel[
4329 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4330 struct nlattr *buckets;
4331 struct nlattr *channels;
4332 int rem1, rem2;
4333 eHalStatus status;
4334 tANI_U8 bktIndex, j, numChannels;
4335 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4336 tANI_U32 passive_max_chn_time, active_max_chn_time;
4337
4338 bktIndex = 0;
4339
4340 nla_for_each_nested(buckets,
4341 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4342 if (nla_parse(bucket,
4343 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4344 nla_data(buckets), nla_len(buckets), NULL)) {
4345 hddLog(LOGE, FL("nla_parse failed"));
4346 return -EINVAL;
4347 }
4348
4349 /* Parse and fetch bucket spec */
4350 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4351 hddLog(LOGE, FL("attr bucket index failed"));
4352 return -EINVAL;
4353 }
4354 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4355 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4356 hddLog(LOG1, FL("Bucket spec Index %d"),
4357 pReqMsg->buckets[bktIndex].bucket);
4358
4359 /* Parse and fetch wifi band */
4360 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4361 hddLog(LOGE, FL("attr wifi band failed"));
4362 return -EINVAL;
4363 }
4364 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4365 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4366 hddLog(LOG1, FL("Wifi band %d"),
4367 pReqMsg->buckets[bktIndex].band);
4368
4369 /* Parse and fetch period */
4370 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4371 hddLog(LOGE, FL("attr period failed"));
4372 return -EINVAL;
4373 }
4374 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4375 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4376 hddLog(LOG1, FL("period %d"),
4377 pReqMsg->buckets[bktIndex].period);
4378
4379 /* Parse and fetch report events */
4380 if (!bucket[
4381 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4382 hddLog(LOGE, FL("attr report events failed"));
4383 return -EINVAL;
4384 }
4385 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4386 bucket[
4387 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4388 hddLog(LOG1, FL("report events %d"),
4389 pReqMsg->buckets[bktIndex].reportEvents);
4390
4391 /* Parse and fetch max period */
4392 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4393 hddLog(LOGE, FL("attr max period failed"));
4394 return -EINVAL;
4395 }
4396 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4397 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4398 hddLog(LOG1, FL("max period %u"),
4399 pReqMsg->buckets[bktIndex].max_period);
4400
4401 /* Parse and fetch exponent */
4402 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4403 hddLog(LOGE, FL("attr exponent failed"));
4404 return -EINVAL;
4405 }
4406 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4407 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4408 hddLog(LOG1, FL("exponent %u"),
4409 pReqMsg->buckets[bktIndex].exponent);
4410
4411 /* Parse and fetch step count */
4412 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4413 hddLog(LOGE, FL("attr step count failed"));
4414 return -EINVAL;
4415 }
4416 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4417 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4418 hddLog(LOG1, FL("Step count %u"),
4419 pReqMsg->buckets[bktIndex].step_count);
4420
4421 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4422 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4423
4424 /* Framework shall pass the channel list if the input WiFi band is
4425 * WIFI_BAND_UNSPECIFIED.
4426 * If the input WiFi band is specified (any value other than
4427 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4428 */
4429 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4430 numChannels = 0;
4431 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4432 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4433 pReqMsg->buckets[bktIndex].band,
4434 chanList, &numChannels);
4435 if (!HAL_STATUS_SUCCESS(status)) {
4436 hddLog(LOGE,
4437 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4438 status);
4439 return -EINVAL;
4440 }
4441
4442 pReqMsg->buckets[bktIndex].numChannels =
4443 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4444 hddLog(LOG1, FL("Num channels %d"),
4445 pReqMsg->buckets[bktIndex].numChannels);
4446
4447 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4448 j++) {
4449 pReqMsg->buckets[bktIndex].channels[j].channel =
4450 chanList[j];
4451 pReqMsg->buckets[bktIndex].channels[j].
4452 chnlClass = 0;
4453 if (CSR_IS_CHANNEL_DFS(
4454 vos_freq_to_chan(chanList[j]))) {
4455 pReqMsg->buckets[bktIndex].channels[j].
4456 passive = 1;
4457 pReqMsg->buckets[bktIndex].channels[j].
4458 dwellTimeMs = passive_max_chn_time;
4459 } else {
4460 pReqMsg->buckets[bktIndex].channels[j].
4461 passive = 0;
4462 pReqMsg->buckets[bktIndex].channels[j].
4463 dwellTimeMs = active_max_chn_time;
4464 }
4465
4466 hddLog(LOG1,
4467 "Channel %u Passive %u Dwell time %u ms",
4468 pReqMsg->buckets[bktIndex].channels[j].channel,
4469 pReqMsg->buckets[bktIndex].channels[j].passive,
4470 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4471 }
4472
4473 bktIndex++;
4474 continue;
4475 }
4476
4477 /* Parse and fetch number of channels */
4478 if (!bucket[
4479 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4480 hddLog(LOGE, FL("attr num channels failed"));
4481 return -EINVAL;
4482 }
4483
4484 pReqMsg->buckets[bktIndex].numChannels =
4485 nla_get_u32(bucket[
4486 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4487 hddLog(LOG1, FL("num channels %d"),
4488 pReqMsg->buckets[bktIndex].numChannels);
4489
4490 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4491 hddLog(LOGE, FL("attr channel spec failed"));
4492 return -EINVAL;
4493 }
4494
4495 j = 0;
4496 nla_for_each_nested(channels,
4497 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4498 if (nla_parse(channel,
4499 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4500 nla_data(channels), nla_len(channels),
4501 wlan_hdd_extscan_config_policy)) {
4502 hddLog(LOGE, FL("nla_parse failed"));
4503 return -EINVAL;
4504 }
4505
4506 /* Parse and fetch channel */
4507 if (!channel[
4508 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4509 hddLog(LOGE, FL("attr channel failed"));
4510 return -EINVAL;
4511 }
4512 pReqMsg->buckets[bktIndex].channels[j].channel =
4513 nla_get_u32(channel[
4514 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4515 hddLog(LOG1, FL("channel %u"),
4516 pReqMsg->buckets[bktIndex].channels[j].channel);
4517
4518 /* Parse and fetch dwell time */
4519 if (!channel[
4520 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4521 hddLog(LOGE, FL("attr dwelltime failed"));
4522 return -EINVAL;
4523 }
4524 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4525 nla_get_u32(channel[
4526 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4527
4528 hddLog(LOG1, FL("Dwell time (%u ms)"),
4529 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4530
4531
4532 /* Parse and fetch channel spec passive */
4533 if (!channel[
4534 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4535 hddLog(LOGE,
4536 FL("attr channel spec passive failed"));
4537 return -EINVAL;
4538 }
4539 pReqMsg->buckets[bktIndex].channels[j].passive =
4540 nla_get_u8(channel[
4541 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4542 hddLog(LOG1, FL("Chnl spec passive %u"),
4543 pReqMsg->buckets[bktIndex].channels[j].passive);
4544
4545 j++;
4546 }
4547
4548 bktIndex++;
4549 }
4550
4551 return 0;
4552}
4553
4554
4555/*
4556 * define short names for the global vendor params
4557 * used by wlan_hdd_cfg80211_extscan_start()
4558 */
4559#define PARAM_MAX \
4560QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4561#define PARAM_REQUEST_ID \
4562QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4563#define PARAM_BASE_PERIOD \
4564QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4565#define PARAM_MAX_AP_PER_SCAN \
4566QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4567#define PARAM_RPT_THRHLD_PERCENT \
4568QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4569#define PARAM_RPT_THRHLD_NUM_SCANS \
4570QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4571#define PARAM_NUM_BUCKETS \
4572QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4573
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304574static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304575 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304576 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304577{
Dino Myclee8843b32014-07-04 14:21:45 +05304578 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304579 struct net_device *dev = wdev->netdev;
4580 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4581 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4582 struct nlattr *tb[PARAM_MAX + 1];
4583 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304584 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304585 tANI_U32 request_id;
4586 struct hdd_ext_scan_context *context;
4587 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304588
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304589 ENTER();
4590
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304591 if (VOS_FTM_MODE == hdd_get_conparam()) {
4592 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4593 return -EINVAL;
4594 }
4595
Dino Mycle6fb96c12014-06-10 11:52:40 +05304596 status = wlan_hdd_validate_context(pHddCtx);
4597 if (0 != status)
4598 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304599 return -EINVAL;
4600 }
Dino Myclee8843b32014-07-04 14:21:45 +05304601 /* check the EXTScan Capability */
4602 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304603 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4604 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304605 {
4606 hddLog(VOS_TRACE_LEVEL_ERROR,
4607 FL("EXTScan not enabled/supported by Firmware"));
4608 return -EINVAL;
4609 }
4610
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304611 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304612 data, dataLen,
4613 wlan_hdd_extscan_config_policy)) {
4614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4615 return -EINVAL;
4616 }
4617
4618 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304619 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304620 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4621 return -EINVAL;
4622 }
4623
Dino Myclee8843b32014-07-04 14:21:45 +05304624 pReqMsg = (tpSirEXTScanStartReqParams)
4625 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304626 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304627 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4628 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304629 }
4630
4631 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304632 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304633 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4634
4635 pReqMsg->sessionId = pAdapter->sessionId;
4636 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4637
4638 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304639 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304640 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4641 goto fail;
4642 }
4643 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304644 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304645 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4646 pReqMsg->basePeriod);
4647
4648 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304649 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304650 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4651 goto fail;
4652 }
4653 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304654 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304655 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4656 pReqMsg->maxAPperScan);
4657
4658 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304659 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4661 goto fail;
4662 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304663 pReqMsg->reportThresholdPercent = nla_get_u8(
4664 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304665 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304666 pReqMsg->reportThresholdPercent);
4667
4668 /* Parse and fetch report threshold num scans */
4669 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4670 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4671 goto fail;
4672 }
4673 pReqMsg->reportThresholdNumScans = nla_get_u8(
4674 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4675 hddLog(LOG1, FL("Report Threshold num scans %d"),
4676 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304677
4678 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304679 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4681 goto fail;
4682 }
4683 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304684 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304685 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4686 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4687 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4688 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4689 }
4690 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4691 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304692
Dino Mycle6fb96c12014-06-10 11:52:40 +05304693 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4694 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4695 goto fail;
4696 }
4697
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304698 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304699
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304700 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4701 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304702
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304703 context = &pHddCtx->ext_scan_context;
4704 spin_lock(&hdd_context_lock);
4705 INIT_COMPLETION(context->response_event);
4706 context->request_id = request_id = pReqMsg->requestId;
4707 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304708
Dino Mycle6fb96c12014-06-10 11:52:40 +05304709 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4710 if (!HAL_STATUS_SUCCESS(status)) {
4711 hddLog(VOS_TRACE_LEVEL_ERROR,
4712 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304713 goto fail;
4714 }
4715
Srinivas Dasari91727c12016-03-23 17:59:06 +05304716 pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime();
4717
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304718 /* request was sent -- wait for the response */
4719 rc = wait_for_completion_timeout(&context->response_event,
4720 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4721
4722 if (!rc) {
4723 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4724 retval = -ETIMEDOUT;
4725 } else {
4726 spin_lock(&hdd_context_lock);
4727 if (context->request_id == request_id)
4728 retval = context->response_status;
4729 else
4730 retval = -EINVAL;
4731 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304732 }
4733
Dino Myclee8843b32014-07-04 14:21:45 +05304734 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304735 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304736 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304737
4738fail:
4739 vos_mem_free(pReqMsg);
4740 return -EINVAL;
4741}
4742
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304743/*
4744 * done with short names for the global vendor params
4745 * used by wlan_hdd_cfg80211_extscan_start()
4746 */
4747#undef PARAM_MAX
4748#undef PARAM_REQUEST_ID
4749#undef PARAM_BASE_PERIOD
4750#undef PARAMS_MAX_AP_PER_SCAN
4751#undef PARAMS_RPT_THRHLD_PERCENT
4752#undef PARAMS_RPT_THRHLD_NUM_SCANS
4753#undef PARAMS_NUM_BUCKETS
4754
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304755static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4756 struct wireless_dev *wdev,
4757 const void *data, int dataLen)
4758{
4759 int ret = 0;
4760
4761 vos_ssr_protect(__func__);
4762 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4763 vos_ssr_unprotect(__func__);
4764
4765 return ret;
4766}
4767
4768static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304769 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304770 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304771{
Dino Myclee8843b32014-07-04 14:21:45 +05304772 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304773 struct net_device *dev = wdev->netdev;
4774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4775 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4776 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4777 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304778 int retval;
4779 unsigned long rc;
4780 struct hdd_ext_scan_context *context;
4781 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304782
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304783 ENTER();
4784
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304785 if (VOS_FTM_MODE == hdd_get_conparam()) {
4786 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4787 return -EINVAL;
4788 }
4789
Dino Mycle6fb96c12014-06-10 11:52:40 +05304790 status = wlan_hdd_validate_context(pHddCtx);
4791 if (0 != status)
4792 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304793 return -EINVAL;
4794 }
Dino Myclee8843b32014-07-04 14:21:45 +05304795 /* check the EXTScan Capability */
4796 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304797 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4798 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304799 {
4800 hddLog(VOS_TRACE_LEVEL_ERROR,
4801 FL("EXTScan not enabled/supported by Firmware"));
4802 return -EINVAL;
4803 }
4804
Dino Mycle6fb96c12014-06-10 11:52:40 +05304805 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4806 data, dataLen,
4807 wlan_hdd_extscan_config_policy)) {
4808 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4809 return -EINVAL;
4810 }
4811
4812 /* Parse and fetch request Id */
4813 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4815 return -EINVAL;
4816 }
4817
Dino Myclee8843b32014-07-04 14:21:45 +05304818 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304819 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304820 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304821
Dino Myclee8843b32014-07-04 14:21:45 +05304822 reqMsg.sessionId = pAdapter->sessionId;
4823 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304824
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304825 context = &pHddCtx->ext_scan_context;
4826 spin_lock(&hdd_context_lock);
4827 INIT_COMPLETION(context->response_event);
Sravanti Palakonda7539fb92016-02-26 17:49:21 +05304828 context->request_id = request_id = reqMsg.requestId;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304829 spin_unlock(&hdd_context_lock);
4830
Dino Myclee8843b32014-07-04 14:21:45 +05304831 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304832 if (!HAL_STATUS_SUCCESS(status)) {
4833 hddLog(VOS_TRACE_LEVEL_ERROR,
4834 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304835 return -EINVAL;
4836 }
4837
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304838 /* request was sent -- wait for the response */
4839 rc = wait_for_completion_timeout(&context->response_event,
4840 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4841
4842 if (!rc) {
4843 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4844 retval = -ETIMEDOUT;
4845 } else {
4846 spin_lock(&hdd_context_lock);
4847 if (context->request_id == request_id)
4848 retval = context->response_status;
4849 else
4850 retval = -EINVAL;
4851 spin_unlock(&hdd_context_lock);
4852 }
4853
4854 return retval;
4855
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304856 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304857 return 0;
4858}
4859
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304860static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4861 struct wireless_dev *wdev,
4862 const void *data, int dataLen)
4863{
4864 int ret = 0;
4865
4866 vos_ssr_protect(__func__);
4867 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4868 vos_ssr_unprotect(__func__);
4869
4870 return ret;
4871}
4872
4873static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304874 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304875 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304876{
Dino Myclee8843b32014-07-04 14:21:45 +05304877 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304878 struct net_device *dev = wdev->netdev;
4879 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4880 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4881 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4882 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304883 struct hdd_ext_scan_context *context;
4884 tANI_U32 request_id;
4885 unsigned long rc;
4886 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304887
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304888 ENTER();
4889
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304890 if (VOS_FTM_MODE == hdd_get_conparam()) {
4891 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4892 return -EINVAL;
4893 }
4894
Dino Mycle6fb96c12014-06-10 11:52:40 +05304895 status = wlan_hdd_validate_context(pHddCtx);
4896 if (0 != status)
4897 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304898 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304899 return -EINVAL;
4900 }
Dino Myclee8843b32014-07-04 14:21:45 +05304901 /* check the EXTScan Capability */
4902 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304903 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4904 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304905 {
4906 hddLog(VOS_TRACE_LEVEL_ERROR,
4907 FL("EXTScan not enabled/supported by Firmware"));
4908 return -EINVAL;
4909 }
4910
Dino Mycle6fb96c12014-06-10 11:52:40 +05304911 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4912 data, dataLen,
4913 wlan_hdd_extscan_config_policy)) {
4914 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4915 return -EINVAL;
4916 }
4917
4918 /* Parse and fetch request Id */
4919 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4921 return -EINVAL;
4922 }
4923
Dino Myclee8843b32014-07-04 14:21:45 +05304924 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304925 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304926 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304927
Dino Myclee8843b32014-07-04 14:21:45 +05304928 reqMsg.sessionId = pAdapter->sessionId;
4929 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304930
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304931 context = &pHddCtx->ext_scan_context;
4932 spin_lock(&hdd_context_lock);
4933 INIT_COMPLETION(context->response_event);
4934 context->request_id = request_id = reqMsg.requestId;
4935 spin_unlock(&hdd_context_lock);
4936
Dino Myclee8843b32014-07-04 14:21:45 +05304937 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304938 if (!HAL_STATUS_SUCCESS(status)) {
4939 hddLog(VOS_TRACE_LEVEL_ERROR,
4940 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304941 return -EINVAL;
4942 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304943
4944 /* request was sent -- wait for the response */
4945 rc = wait_for_completion_timeout(&context->response_event,
4946 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4947 if (!rc) {
4948 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4949 retval = -ETIMEDOUT;
4950 } else {
4951 spin_lock(&hdd_context_lock);
4952 if (context->request_id == request_id)
4953 retval = context->response_status;
4954 else
4955 retval = -EINVAL;
4956 spin_unlock(&hdd_context_lock);
4957 }
4958
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304959 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304960 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304961}
4962
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304963static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4964 struct wireless_dev *wdev,
4965 const void *data, int dataLen)
4966{
4967 int ret = 0;
4968
4969 vos_ssr_protect(__func__);
4970 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4971 vos_ssr_unprotect(__func__);
4972
4973 return ret;
4974}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304975#endif /* WLAN_FEATURE_EXTSCAN */
4976
Atul Mittal115287b2014-07-08 13:26:33 +05304977/*EXT TDLS*/
4978static const struct nla_policy
4979wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4980{
4981 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4982 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4983 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4984 {.type = NLA_S32 },
4985 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4986 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4987
4988};
4989
4990static const struct nla_policy
4991wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4992{
4993 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4994
4995};
4996
4997static const struct nla_policy
4998wlan_hdd_tdls_config_state_change_policy[
4999 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
5000{
5001 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
5002 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5003 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305004 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5005 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5006 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305007
5008};
5009
5010static const struct nla_policy
5011wlan_hdd_tdls_config_get_status_policy[
5012 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5013{
5014 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
5015 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5016 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305017 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5018 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5019 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305020
5021};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305022
5023static const struct nla_policy
5024wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5025{
5026 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
5027};
5028
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305029static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305030 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305031 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305032 int data_len)
5033{
5034
5035 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5036 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5037
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305038 ENTER();
5039
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305040 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305041 return -EINVAL;
5042 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305043 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305044 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305045 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305046 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305047 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305048 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305049 return -ENOTSUPP;
5050 }
5051
5052 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5053 data, data_len, wlan_hdd_mac_config)) {
5054 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5055 return -EINVAL;
5056 }
5057
5058 /* Parse and fetch mac address */
5059 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5060 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5061 return -EINVAL;
5062 }
5063
5064 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5065 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5066 VOS_MAC_ADDR_LAST_3_BYTES);
5067
Siddharth Bhal76972212014-10-15 16:22:51 +05305068 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5069
5070 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305071 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5072 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305073 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5074 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5075 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5076 {
5077 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5078 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5079 VOS_MAC_ADDRESS_LEN);
5080 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305081 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305082
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305083 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5084 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305085
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305086 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305087 return 0;
5088}
5089
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305090static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5091 struct wireless_dev *wdev,
5092 const void *data,
5093 int data_len)
5094{
5095 int ret = 0;
5096
5097 vos_ssr_protect(__func__);
5098 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5099 vos_ssr_unprotect(__func__);
5100
5101 return ret;
5102}
5103
5104static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305105 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305106 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305107 int data_len)
5108{
5109 u8 peer[6] = {0};
5110 struct net_device *dev = wdev->netdev;
5111 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5112 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5113 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5114 eHalStatus ret;
5115 tANI_S32 state;
5116 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305117 tANI_S32 global_operating_class = 0;
5118 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305119 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305120 int retVal;
5121
5122 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305123
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305124 if (!pAdapter) {
5125 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5126 return -EINVAL;
5127 }
5128
Atul Mittal115287b2014-07-08 13:26:33 +05305129 ret = wlan_hdd_validate_context(pHddCtx);
5130 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305131 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305132 return -EINVAL;
5133 }
5134 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305135 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305136 return -ENOTSUPP;
5137 }
5138 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5139 data, data_len,
5140 wlan_hdd_tdls_config_get_status_policy)) {
5141 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5142 return -EINVAL;
5143 }
5144
5145 /* Parse and fetch mac address */
5146 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5148 return -EINVAL;
5149 }
5150
5151 memcpy(peer, nla_data(
5152 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5153 sizeof(peer));
5154 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5155
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305156 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305157
Atul Mittal115287b2014-07-08 13:26:33 +05305158 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305159 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305160 NLMSG_HDRLEN);
5161
5162 if (!skb) {
5163 hddLog(VOS_TRACE_LEVEL_ERROR,
5164 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5165 return -EINVAL;
5166 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305167 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 +05305168 reason,
5169 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305170 global_operating_class,
5171 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305172 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305173 if (nla_put_s32(skb,
5174 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5175 state) ||
5176 nla_put_s32(skb,
5177 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5178 reason) ||
5179 nla_put_s32(skb,
5180 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5181 global_operating_class) ||
5182 nla_put_s32(skb,
5183 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5184 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305185
5186 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5187 goto nla_put_failure;
5188 }
5189
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305190 retVal = cfg80211_vendor_cmd_reply(skb);
5191 EXIT();
5192 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305193
5194nla_put_failure:
5195 kfree_skb(skb);
5196 return -EINVAL;
5197}
5198
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305199static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5200 struct wireless_dev *wdev,
5201 const void *data,
5202 int data_len)
5203{
5204 int ret = 0;
5205
5206 vos_ssr_protect(__func__);
5207 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5208 vos_ssr_unprotect(__func__);
5209
5210 return ret;
5211}
5212
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305213static int wlan_hdd_cfg80211_exttdls_callback(
5214#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5215 const tANI_U8* mac,
5216#else
5217 tANI_U8* mac,
5218#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305219 tANI_S32 state,
5220 tANI_S32 reason,
5221 void *ctx)
5222{
5223 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305224 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305225 tANI_S32 global_operating_class = 0;
5226 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305227 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305228
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305229 ENTER();
5230
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305231 if (!pAdapter) {
5232 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5233 return -EINVAL;
5234 }
5235
5236 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305237 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305239 return -EINVAL;
5240 }
5241
5242 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305244 return -ENOTSUPP;
5245 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305246 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5247#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5248 NULL,
5249#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305250 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5251 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5252 GFP_KERNEL);
5253
5254 if (!skb) {
5255 hddLog(VOS_TRACE_LEVEL_ERROR,
5256 FL("cfg80211_vendor_event_alloc failed"));
5257 return -EINVAL;
5258 }
5259 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305260 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5261 reason,
5262 state,
5263 global_operating_class,
5264 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305265 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5266 MAC_ADDR_ARRAY(mac));
5267
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305268 if (nla_put(skb,
5269 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5270 VOS_MAC_ADDR_SIZE, mac) ||
5271 nla_put_s32(skb,
5272 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5273 state) ||
5274 nla_put_s32(skb,
5275 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5276 reason) ||
5277 nla_put_s32(skb,
5278 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5279 channel) ||
5280 nla_put_s32(skb,
5281 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5282 global_operating_class)
5283 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305284 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5285 goto nla_put_failure;
5286 }
5287
5288 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305289 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305290 return (0);
5291
5292nla_put_failure:
5293 kfree_skb(skb);
5294 return -EINVAL;
5295}
5296
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305297static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305298 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305299 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305300 int data_len)
5301{
5302 u8 peer[6] = {0};
5303 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305304 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5305 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5306 eHalStatus status;
5307 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305308 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305309 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305310
5311 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305312
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305313 if (!dev) {
5314 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5315 return -EINVAL;
5316 }
5317
5318 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5319 if (!pAdapter) {
5320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5321 return -EINVAL;
5322 }
5323
Atul Mittal115287b2014-07-08 13:26:33 +05305324 status = wlan_hdd_validate_context(pHddCtx);
5325 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305326 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305327 return -EINVAL;
5328 }
5329 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305330 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305331 return -ENOTSUPP;
5332 }
5333 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5334 data, data_len,
5335 wlan_hdd_tdls_config_enable_policy)) {
5336 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5337 return -EINVAL;
5338 }
5339
5340 /* Parse and fetch mac address */
5341 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5342 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5343 return -EINVAL;
5344 }
5345
5346 memcpy(peer, nla_data(
5347 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5348 sizeof(peer));
5349 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5350
5351 /* Parse and fetch channel */
5352 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5354 return -EINVAL;
5355 }
5356 pReqMsg.channel = nla_get_s32(
5357 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5358 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5359
5360 /* Parse and fetch global operating class */
5361 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5362 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5363 return -EINVAL;
5364 }
5365 pReqMsg.global_operating_class = nla_get_s32(
5366 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5367 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5368 pReqMsg.global_operating_class);
5369
5370 /* Parse and fetch latency ms */
5371 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5373 return -EINVAL;
5374 }
5375 pReqMsg.max_latency_ms = nla_get_s32(
5376 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5377 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5378 pReqMsg.max_latency_ms);
5379
5380 /* Parse and fetch required bandwidth kbps */
5381 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5382 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5383 return -EINVAL;
5384 }
5385
5386 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5387 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5388 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5389 pReqMsg.min_bandwidth_kbps);
5390
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305391 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305392 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305393 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305394 wlan_hdd_cfg80211_exttdls_callback);
5395
5396 EXIT();
5397 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305398}
5399
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305400static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5401 struct wireless_dev *wdev,
5402 const void *data,
5403 int data_len)
5404{
5405 int ret = 0;
5406
5407 vos_ssr_protect(__func__);
5408 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5409 vos_ssr_unprotect(__func__);
5410
5411 return ret;
5412}
5413
5414static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305415 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305416 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305417 int data_len)
5418{
5419 u8 peer[6] = {0};
5420 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305421 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5422 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5423 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305424 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305425 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305426
5427 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305428
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305429 if (!dev) {
5430 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5431 return -EINVAL;
5432 }
5433
5434 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5435 if (!pAdapter) {
5436 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5437 return -EINVAL;
5438 }
5439
Atul Mittal115287b2014-07-08 13:26:33 +05305440 status = wlan_hdd_validate_context(pHddCtx);
5441 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305442 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305443 return -EINVAL;
5444 }
5445 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305446 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305447 return -ENOTSUPP;
5448 }
5449 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5450 data, data_len,
5451 wlan_hdd_tdls_config_disable_policy)) {
5452 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5453 return -EINVAL;
5454 }
5455 /* Parse and fetch mac address */
5456 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5457 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5458 return -EINVAL;
5459 }
5460
5461 memcpy(peer, nla_data(
5462 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5463 sizeof(peer));
5464 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5465
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305466 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5467
5468 EXIT();
5469 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305470}
5471
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305472static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5473 struct wireless_dev *wdev,
5474 const void *data,
5475 int data_len)
5476{
5477 int ret = 0;
5478
5479 vos_ssr_protect(__func__);
5480 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5481 vos_ssr_unprotect(__func__);
5482
5483 return ret;
5484}
5485
Dasari Srinivas7875a302014-09-26 17:50:57 +05305486static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305487__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305488 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305489 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305490{
5491 struct net_device *dev = wdev->netdev;
5492 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5493 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5494 struct sk_buff *skb = NULL;
5495 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305496 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305497
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305498 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305499
5500 ret = wlan_hdd_validate_context(pHddCtx);
5501 if (0 != ret)
5502 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305503 return ret;
5504 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305505 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5506 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5507 fset |= WIFI_FEATURE_INFRA;
5508 }
5509
5510 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5511 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5512 fset |= WIFI_FEATURE_INFRA_5G;
5513 }
5514
5515#ifdef WLAN_FEATURE_P2P
5516 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5517 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5518 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5519 fset |= WIFI_FEATURE_P2P;
5520 }
5521#endif
5522
5523 /* Soft-AP is supported currently by default */
5524 fset |= WIFI_FEATURE_SOFT_AP;
5525
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305526 /* HOTSPOT is a supplicant feature, enable it by default */
5527 fset |= WIFI_FEATURE_HOTSPOT;
5528
Dasari Srinivas7875a302014-09-26 17:50:57 +05305529#ifdef WLAN_FEATURE_EXTSCAN
5530 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305531 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5532 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5533 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305534 fset |= WIFI_FEATURE_EXTSCAN;
5535 }
5536#endif
5537
Dasari Srinivas7875a302014-09-26 17:50:57 +05305538 if (sme_IsFeatureSupportedByFW(NAN)) {
5539 hddLog(LOG1, FL("NAN is supported by firmware"));
5540 fset |= WIFI_FEATURE_NAN;
5541 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305542
5543 /* D2D RTT is not supported currently by default */
5544 if (sme_IsFeatureSupportedByFW(RTT)) {
5545 hddLog(LOG1, FL("RTT is supported by firmware"));
5546 fset |= WIFI_FEATURE_D2AP_RTT;
5547 }
5548
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305549 if (sme_IsFeatureSupportedByFW(RTT3)) {
5550 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5551 fset |= WIFI_FEATURE_RTT3;
5552 }
5553
Dasari Srinivas7875a302014-09-26 17:50:57 +05305554#ifdef FEATURE_WLAN_BATCH_SCAN
5555 if (fset & WIFI_FEATURE_EXTSCAN) {
5556 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5557 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5558 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5559 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5560 fset |= WIFI_FEATURE_BATCH_SCAN;
5561 }
5562#endif
5563
5564#ifdef FEATURE_WLAN_SCAN_PNO
5565 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5566 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5567 hddLog(LOG1, FL("PNO is supported by firmware"));
5568 fset |= WIFI_FEATURE_PNO;
5569 }
5570#endif
5571
5572 /* STA+STA is supported currently by default */
5573 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5574
5575#ifdef FEATURE_WLAN_TDLS
5576 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5577 sme_IsFeatureSupportedByFW(TDLS)) {
5578 hddLog(LOG1, FL("TDLS is supported by firmware"));
5579 fset |= WIFI_FEATURE_TDLS;
5580 }
5581
5582 /* TDLS_OFFCHANNEL is not supported currently by default */
5583#endif
5584
5585#ifdef WLAN_AP_STA_CONCURRENCY
5586 /* AP+STA concurrency is supported currently by default */
5587 fset |= WIFI_FEATURE_AP_STA;
5588#endif
5589
Mukul Sharma5add0532015-08-17 15:57:47 +05305590#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5591 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5592 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5593#endif
5594
Dasari Srinivas7875a302014-09-26 17:50:57 +05305595 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5596 NLMSG_HDRLEN);
5597
5598 if (!skb) {
5599 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5600 return -EINVAL;
5601 }
5602 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5603
5604 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5605 hddLog(LOGE, FL("nla put fail"));
5606 goto nla_put_failure;
5607 }
5608
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305609 ret = cfg80211_vendor_cmd_reply(skb);
5610 EXIT();
5611 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305612
5613nla_put_failure:
5614 kfree_skb(skb);
5615 return -EINVAL;
5616}
5617
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305618static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305619wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5620 struct wireless_dev *wdev,
5621 const void *data, int data_len)
5622{
5623 int ret = 0;
5624
5625 vos_ssr_protect(__func__);
5626 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5627 vos_ssr_unprotect(__func__);
5628
5629 return ret;
5630}
5631
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305632
5633static const struct
5634nla_policy
5635qca_wlan_vendor_wifi_logger_get_ring_data_policy
5636[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5637 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5638 = {.type = NLA_U32 },
5639};
5640
5641static int
5642 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5643 struct wireless_dev *wdev,
5644 const void *data,
5645 int data_len)
5646{
5647 int ret;
5648 VOS_STATUS status;
5649 uint32_t ring_id;
5650 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5651 struct nlattr *tb
5652 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5653
5654 ENTER();
5655
5656 ret = wlan_hdd_validate_context(hdd_ctx);
5657 if (0 != ret) {
5658 return ret;
5659 }
5660
5661 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5662 data, data_len,
5663 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5664 hddLog(LOGE, FL("Invalid attribute"));
5665 return -EINVAL;
5666 }
5667
5668 /* Parse and fetch ring id */
5669 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5670 hddLog(LOGE, FL("attr ATTR failed"));
5671 return -EINVAL;
5672 }
5673
5674 ring_id = nla_get_u32(
5675 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5676
5677 hddLog(LOG1, FL("Bug report triggered by framework"));
5678
5679 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5680 WLAN_LOG_INDICATOR_FRAMEWORK,
5681 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305682 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305683 );
5684 if (VOS_STATUS_SUCCESS != status) {
5685 hddLog(LOGE, FL("Failed to trigger bug report"));
5686
5687 return -EINVAL;
5688 }
5689
5690 return 0;
5691
5692
5693}
5694
5695
5696static int
5697 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5698 struct wireless_dev *wdev,
5699 const void *data,
5700 int data_len)
5701{
5702 int ret = 0;
5703
5704 vos_ssr_protect(__func__);
5705 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5706 wdev, data, data_len);
5707 vos_ssr_unprotect(__func__);
5708
5709 return ret;
5710
5711}
5712
5713
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305714static int
5715__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305716 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305717 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305718{
5719 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5720 uint8_t i, feature_sets, max_feature_sets;
5721 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5722 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305723 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5724 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305725
5726 ENTER();
5727
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305728 ret = wlan_hdd_validate_context(pHddCtx);
5729 if (0 != ret)
5730 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305731 return ret;
5732 }
5733
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305734 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5735 data, data_len, NULL)) {
5736 hddLog(LOGE, FL("Invalid ATTR"));
5737 return -EINVAL;
5738 }
5739
5740 /* Parse and fetch max feature set */
5741 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5742 hddLog(LOGE, FL("Attr max feature set size failed"));
5743 return -EINVAL;
5744 }
5745 max_feature_sets = nla_get_u32(
5746 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5747 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5748
5749 /* Fill feature combination matrix */
5750 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305751 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5752 WIFI_FEATURE_P2P;
5753
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305754 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5755 WIFI_FEATURE_SOFT_AP;
5756
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305757 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5758 WIFI_FEATURE_SOFT_AP;
5759
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305760 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5761 WIFI_FEATURE_SOFT_AP |
5762 WIFI_FEATURE_P2P;
5763
5764 /* Add more feature combinations here */
5765
5766 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5767 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5768 hddLog(LOG1, "Feature set matrix");
5769 for (i = 0; i < feature_sets; i++)
5770 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5771
5772 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5773 sizeof(u32) * feature_sets +
5774 NLMSG_HDRLEN);
5775
5776 if (reply_skb) {
5777 if (nla_put_u32(reply_skb,
5778 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5779 feature_sets) ||
5780 nla_put(reply_skb,
5781 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5782 sizeof(u32) * feature_sets, feature_set_matrix)) {
5783 hddLog(LOGE, FL("nla put fail"));
5784 kfree_skb(reply_skb);
5785 return -EINVAL;
5786 }
5787
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305788 ret = cfg80211_vendor_cmd_reply(reply_skb);
5789 EXIT();
5790 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305791 }
5792 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5793 return -ENOMEM;
5794
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305795}
5796
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305797static int
5798wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5799 struct wireless_dev *wdev,
5800 const void *data, int data_len)
5801{
5802 int ret = 0;
5803
5804 vos_ssr_protect(__func__);
5805 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5806 data_len);
5807 vos_ssr_unprotect(__func__);
5808
5809 return ret;
5810}
5811
c_manjeecfd1efb2015-09-25 19:32:34 +05305812
5813static int
5814__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5815 struct wireless_dev *wdev,
5816 const void *data, int data_len)
5817{
5818 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5819 int ret;
5820 ENTER();
5821
5822 ret = wlan_hdd_validate_context(pHddCtx);
5823 if (0 != ret)
5824 {
5825 return ret;
5826 }
5827
5828 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5829 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5830 {
5831 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5832 return -EINVAL;
5833 }
5834 /*call common API for FW mem dump req*/
5835 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5836
Abhishek Singhc783fa72015-12-09 18:07:34 +05305837 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305838 {
5839 /*indicate to userspace the status of fw mem dump */
5840 wlan_indicate_mem_dump_complete(true);
5841 }
5842 else
5843 {
5844 /*else send failure to userspace */
5845 wlan_indicate_mem_dump_complete(false);
5846 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305847 EXIT();
5848 return ret;
5849}
5850
5851/**
5852 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5853 * @wiphy: pointer to wireless wiphy structure.
5854 * @wdev: pointer to wireless_dev structure.
5855 * @data: Pointer to the NL data.
5856 * @data_len:Length of @data
5857 *
5858 * This is called when wlan driver needs to get the firmware memory dump
5859 * via vendor specific command.
5860 *
5861 * Return: 0 on success, error number otherwise.
5862 */
5863
5864static int
5865wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5866 struct wireless_dev *wdev,
5867 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305868{
5869 int ret = 0;
5870 vos_ssr_protect(__func__);
5871 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5872 data_len);
5873 vos_ssr_unprotect(__func__);
5874 return ret;
5875}
c_manjeecfd1efb2015-09-25 19:32:34 +05305876
Sushant Kaushik8e644982015-09-23 12:18:54 +05305877static const struct
5878nla_policy
5879qca_wlan_vendor_wifi_logger_start_policy
5880[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5881 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5882 = {.type = NLA_U32 },
5883 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5884 = {.type = NLA_U32 },
5885 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5886 = {.type = NLA_U32 },
5887};
5888
5889/**
5890 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5891 * or disable the collection of packet statistics from the firmware
5892 * @wiphy: WIPHY structure pointer
5893 * @wdev: Wireless device structure pointer
5894 * @data: Pointer to the data received
5895 * @data_len: Length of the data received
5896 *
5897 * This function is used to enable or disable the collection of packet
5898 * statistics from the firmware
5899 *
5900 * Return: 0 on success and errno on failure
5901 */
5902static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5903 struct wireless_dev *wdev,
5904 const void *data,
5905 int data_len)
5906{
5907 eHalStatus status;
5908 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5909 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5910 tAniWifiStartLog start_log;
5911
5912 status = wlan_hdd_validate_context(hdd_ctx);
5913 if (0 != status) {
5914 return -EINVAL;
5915 }
5916
5917 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5918 data, data_len,
5919 qca_wlan_vendor_wifi_logger_start_policy)) {
5920 hddLog(LOGE, FL("Invalid attribute"));
5921 return -EINVAL;
5922 }
5923
5924 /* Parse and fetch ring id */
5925 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5926 hddLog(LOGE, FL("attr ATTR failed"));
5927 return -EINVAL;
5928 }
5929 start_log.ringId = nla_get_u32(
5930 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5931 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5932
5933 /* Parse and fetch verbose level */
5934 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5935 hddLog(LOGE, FL("attr verbose_level failed"));
5936 return -EINVAL;
5937 }
5938 start_log.verboseLevel = nla_get_u32(
5939 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5940 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5941
5942 /* Parse and fetch flag */
5943 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5944 hddLog(LOGE, FL("attr flag failed"));
5945 return -EINVAL;
5946 }
5947 start_log.flag = nla_get_u32(
5948 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5949 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5950
5951 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305952 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5953 !vos_isPktStatsEnabled()))
5954
Sushant Kaushik8e644982015-09-23 12:18:54 +05305955 {
5956 hddLog(LOGE, FL("per pkt stats not enabled"));
5957 return -EINVAL;
5958 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305959
Sushant Kaushik33200572015-08-05 16:46:20 +05305960 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305961 return 0;
5962}
5963
5964/**
5965 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
5966 * or disable the collection of packet statistics from the firmware
5967 * @wiphy: WIPHY structure pointer
5968 * @wdev: Wireless device structure pointer
5969 * @data: Pointer to the data received
5970 * @data_len: Length of the data received
5971 *
5972 * This function is used to enable or disable the collection of packet
5973 * statistics from the firmware
5974 *
5975 * Return: 0 on success and errno on failure
5976 */
5977static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5978 struct wireless_dev *wdev,
5979 const void *data,
5980 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05305981{
5982 int ret = 0;
5983
5984 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305985
5986 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
5987 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05305988 vos_ssr_unprotect(__func__);
5989
5990 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05305991}
5992
5993
Agarwal Ashish738843c2014-09-25 12:27:56 +05305994static const struct nla_policy
5995wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5996 +1] =
5997{
5998 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5999};
6000
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306001static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306002 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306003 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306004 int data_len)
6005{
6006 struct net_device *dev = wdev->netdev;
6007 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6008 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6009 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6010 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6011 eHalStatus status;
6012 u32 dfsFlag = 0;
6013
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306014 ENTER();
6015
Agarwal Ashish738843c2014-09-25 12:27:56 +05306016 status = wlan_hdd_validate_context(pHddCtx);
6017 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306018 return -EINVAL;
6019 }
6020 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6021 data, data_len,
6022 wlan_hdd_set_no_dfs_flag_config_policy)) {
6023 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6024 return -EINVAL;
6025 }
6026
6027 /* Parse and fetch required bandwidth kbps */
6028 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6030 return -EINVAL;
6031 }
6032
6033 dfsFlag = nla_get_u32(
6034 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6035 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6036 dfsFlag);
6037
6038 pHddCtx->disable_dfs_flag = dfsFlag;
6039
6040 sme_disable_dfs_channel(hHal, dfsFlag);
6041 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306042
6043 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306044 return 0;
6045}
Atul Mittal115287b2014-07-08 13:26:33 +05306046
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306047static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6048 struct wireless_dev *wdev,
6049 const void *data,
6050 int data_len)
6051{
6052 int ret = 0;
6053
6054 vos_ssr_protect(__func__);
6055 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6056 vos_ssr_unprotect(__func__);
6057
6058 return ret;
6059
6060}
6061
Mukul Sharma2a271632014-10-13 14:59:01 +05306062const struct
6063nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6064{
6065 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6066 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6067};
6068
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306069static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306070 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306071{
6072
6073 u8 bssid[6] = {0};
6074 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6075 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6076 eHalStatus status = eHAL_STATUS_SUCCESS;
6077 v_U32_t isFwrRoamEnabled = FALSE;
6078 int ret;
6079
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306080 ENTER();
6081
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306082 ret = wlan_hdd_validate_context(pHddCtx);
6083 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306084 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306085 }
6086
6087 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6088 data, data_len,
6089 qca_wlan_vendor_attr);
6090 if (ret){
6091 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6092 return -EINVAL;
6093 }
6094
6095 /* Parse and fetch Enable flag */
6096 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6097 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6098 return -EINVAL;
6099 }
6100
6101 isFwrRoamEnabled = nla_get_u32(
6102 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6103
6104 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6105
6106 /* Parse and fetch bssid */
6107 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6108 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6109 return -EINVAL;
6110 }
6111
6112 memcpy(bssid, nla_data(
6113 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6114 sizeof(bssid));
6115 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6116
6117 //Update roaming
6118 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306119 if (!HAL_STATUS_SUCCESS(status)) {
6120 hddLog(LOGE,
6121 FL("sme_ConfigFwrRoaming failed (err=%d)"), status);
6122 return -EINVAL;
6123 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306124 EXIT();
Abhishek Singhc6ab38f2016-06-28 17:48:16 +05306125 return 0;
Mukul Sharma2a271632014-10-13 14:59:01 +05306126}
6127
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306128static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6129 struct wireless_dev *wdev, const void *data, int data_len)
6130{
6131 int ret = 0;
6132
6133 vos_ssr_protect(__func__);
6134 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6135 vos_ssr_unprotect(__func__);
6136
6137 return ret;
6138}
6139
Sushant Kaushik847890c2015-09-28 16:05:17 +05306140static const struct
6141nla_policy
6142qca_wlan_vendor_get_wifi_info_policy[
6143 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6144 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6145 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6146};
6147
6148
6149/**
6150 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6151 * @wiphy: pointer to wireless wiphy structure.
6152 * @wdev: pointer to wireless_dev structure.
6153 * @data: Pointer to the data to be passed via vendor interface
6154 * @data_len:Length of the data to be passed
6155 *
6156 * This is called when wlan driver needs to send wifi driver related info
6157 * (driver/fw version) to the user space application upon request.
6158 *
6159 * Return: Return the Success or Failure code.
6160 */
6161static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6162 struct wireless_dev *wdev,
6163 const void *data, int data_len)
6164{
6165 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6166 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6167 tSirVersionString version;
6168 uint32 version_len;
6169 uint8 attr;
6170 int status;
6171 struct sk_buff *reply_skb = NULL;
6172
6173 if (VOS_FTM_MODE == hdd_get_conparam()) {
6174 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6175 return -EINVAL;
6176 }
6177
6178 status = wlan_hdd_validate_context(hdd_ctx);
6179 if (0 != status) {
6180 hddLog(LOGE, FL("HDD context is not valid"));
6181 return -EINVAL;
6182 }
6183
6184 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6185 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6186 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6187 return -EINVAL;
6188 }
6189
6190 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6191 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6192 QWLAN_VERSIONSTR);
6193 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6194 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6195 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6196 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6197 hdd_ctx->fw_Version);
6198 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6199 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6200 } else {
6201 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6202 return -EINVAL;
6203 }
6204
6205 version_len = strlen(version);
6206 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6207 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6208 if (!reply_skb) {
6209 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6210 return -ENOMEM;
6211 }
6212
6213 if (nla_put(reply_skb, attr, version_len, version)) {
6214 hddLog(LOGE, FL("nla put fail"));
6215 kfree_skb(reply_skb);
6216 return -EINVAL;
6217 }
6218
6219 return cfg80211_vendor_cmd_reply(reply_skb);
6220}
6221
6222/**
6223 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6224 * @wiphy: pointer to wireless wiphy structure.
6225 * @wdev: pointer to wireless_dev structure.
6226 * @data: Pointer to the data to be passed via vendor interface
6227 * @data_len:Length of the data to be passed
6228 * @data_len: Length of the data received
6229 *
6230 * This function is used to enable or disable the collection of packet
6231 * statistics from the firmware
6232 *
6233 * Return: 0 on success and errno on failure
6234 */
6235
6236static int
6237wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6238 struct wireless_dev *wdev,
6239 const void *data, int data_len)
6240
6241
6242{
6243 int ret = 0;
6244
6245 vos_ssr_protect(__func__);
6246 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6247 wdev, data, data_len);
6248 vos_ssr_unprotect(__func__);
6249
6250 return ret;
6251}
6252
6253
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306254/*
6255 * define short names for the global vendor params
6256 * used by __wlan_hdd_cfg80211_monitor_rssi()
6257 */
6258#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6259#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6260#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6261#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6262#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6263
6264/**---------------------------------------------------------------------------
6265
6266 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6267 monitor start is completed successfully.
6268
6269 \return - None
6270
6271 --------------------------------------------------------------------------*/
6272void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6273{
6274 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6275
6276 if (NULL == pHddCtx)
6277 {
6278 hddLog(VOS_TRACE_LEVEL_ERROR,
6279 "%s: HDD context is NULL",__func__);
6280 return;
6281 }
6282
6283 if (VOS_STATUS_SUCCESS == status)
6284 {
6285 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6286 }
6287 else
6288 {
6289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6290 }
6291
6292 return;
6293}
6294
6295/**---------------------------------------------------------------------------
6296
6297 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6298 stop is completed successfully.
6299
6300 \return - None
6301
6302 --------------------------------------------------------------------------*/
6303void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6304{
6305 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6306
6307 if (NULL == pHddCtx)
6308 {
6309 hddLog(VOS_TRACE_LEVEL_ERROR,
6310 "%s: HDD context is NULL",__func__);
6311 return;
6312 }
6313
6314 if (VOS_STATUS_SUCCESS == status)
6315 {
6316 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6317 }
6318 else
6319 {
6320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6321 }
6322
6323 return;
6324}
6325
6326/**
6327 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6328 * @wiphy: Pointer to wireless phy
6329 * @wdev: Pointer to wireless device
6330 * @data: Pointer to data
6331 * @data_len: Data length
6332 *
6333 * Return: 0 on success, negative errno on failure
6334 */
6335
6336static int
6337__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6338 struct wireless_dev *wdev,
6339 const void *data,
6340 int data_len)
6341{
6342 struct net_device *dev = wdev->netdev;
6343 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6344 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6345 hdd_station_ctx_t *pHddStaCtx;
6346 struct nlattr *tb[PARAM_MAX + 1];
6347 tpSirRssiMonitorReq pReq;
6348 eHalStatus status;
6349 int ret;
6350 uint32_t control;
6351 static const struct nla_policy policy[PARAM_MAX + 1] = {
6352 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6353 [PARAM_CONTROL] = { .type = NLA_U32 },
6354 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6355 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6356 };
6357
6358 ENTER();
6359
6360 ret = wlan_hdd_validate_context(hdd_ctx);
6361 if (0 != ret) {
6362 return -EINVAL;
6363 }
6364
6365 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6366 hddLog(LOGE, FL("Not in Connected state!"));
6367 return -ENOTSUPP;
6368 }
6369
6370 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6371 hddLog(LOGE, FL("Invalid ATTR"));
6372 return -EINVAL;
6373 }
6374
6375 if (!tb[PARAM_REQUEST_ID]) {
6376 hddLog(LOGE, FL("attr request id failed"));
6377 return -EINVAL;
6378 }
6379
6380 if (!tb[PARAM_CONTROL]) {
6381 hddLog(LOGE, FL("attr control failed"));
6382 return -EINVAL;
6383 }
6384
6385 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6386
6387 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6388 if(NULL == pReq)
6389 {
6390 hddLog(LOGE,
6391 FL("vos_mem_alloc failed "));
6392 return eHAL_STATUS_FAILED_ALLOC;
6393 }
6394 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6395
6396 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6397 pReq->sessionId = pAdapter->sessionId;
6398 pReq->rssiMonitorCbContext = hdd_ctx;
6399 control = nla_get_u32(tb[PARAM_CONTROL]);
6400 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6401
6402 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6403 pReq->requestId, pReq->sessionId, control);
6404
6405 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6406 if (!tb[PARAM_MIN_RSSI]) {
6407 hddLog(LOGE, FL("attr min rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306408 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306409 }
6410
6411 if (!tb[PARAM_MAX_RSSI]) {
6412 hddLog(LOGE, FL("attr max rssi failed"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306413 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306414 }
6415
6416 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6417 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6418 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6419
6420 if (!(pReq->minRssi < pReq->maxRssi)) {
6421 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6422 pReq->minRssi, pReq->maxRssi);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306423 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306424 }
6425 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6426 pReq->minRssi, pReq->maxRssi);
6427 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6428
6429 }
6430 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6431 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6432 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6433 }
6434 else {
6435 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306436 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306437 }
6438
6439 if (!HAL_STATUS_SUCCESS(status)) {
6440 hddLog(LOGE,
6441 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306442 goto fail;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306443 }
6444
6445 return 0;
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306446fail:
6447 vos_mem_free(pReq);
6448 return -EINVAL;
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306449}
6450
6451/*
6452 * done with short names for the global vendor params
6453 * used by __wlan_hdd_cfg80211_monitor_rssi()
6454 */
6455#undef PARAM_MAX
6456#undef PARAM_CONTROL
6457#undef PARAM_REQUEST_ID
6458#undef PARAM_MAX_RSSI
6459#undef PARAM_MIN_RSSI
6460
6461/**
6462 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6463 * @wiphy: wiphy structure pointer
6464 * @wdev: Wireless device structure pointer
6465 * @data: Pointer to the data received
6466 * @data_len: Length of @data
6467 *
6468 * Return: 0 on success; errno on failure
6469 */
6470static int
6471wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6472 const void *data, int data_len)
6473{
6474 int ret;
6475
6476 vos_ssr_protect(__func__);
6477 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6478 vos_ssr_unprotect(__func__);
6479
6480 return ret;
6481}
6482
6483/**
6484 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6485 * @hddctx: HDD context
6486 * @data: rssi breached event data
6487 *
6488 * This function reads the rssi breached event %data and fill in the skb with
6489 * NL attributes and send up the NL event.
6490 * This callback execute in atomic context and must not invoke any
6491 * blocking calls.
6492 *
6493 * Return: none
6494 */
6495void hdd_rssi_threshold_breached_cb(void *hddctx,
6496 struct rssi_breach_event *data)
6497{
6498 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6499 int status;
6500 struct sk_buff *skb;
6501
6502 ENTER();
6503 status = wlan_hdd_validate_context(pHddCtx);
6504
6505 if (0 != status) {
6506 return;
6507 }
6508
6509 if (!data) {
6510 hddLog(LOGE, FL("data is null"));
6511 return;
6512 }
6513
6514 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6515#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6516 NULL,
6517#endif
6518 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6519 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6520 GFP_KERNEL);
6521
6522 if (!skb) {
6523 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6524 return;
6525 }
6526
6527 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6528 data->request_id, data->curr_rssi);
6529 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6530 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6531
6532 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6533 data->request_id) ||
6534 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6535 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6536 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6537 data->curr_rssi)) {
6538 hddLog(LOGE, FL("nla put fail"));
6539 goto fail;
6540 }
6541
6542 cfg80211_vendor_event(skb, GFP_KERNEL);
6543 return;
6544
6545fail:
6546 kfree_skb(skb);
6547 return;
6548}
6549
6550
6551
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306552/**
6553 * __wlan_hdd_cfg80211_setband() - set band
6554 * @wiphy: Pointer to wireless phy
6555 * @wdev: Pointer to wireless device
6556 * @data: Pointer to data
6557 * @data_len: Data length
6558 *
6559 * Return: 0 on success, negative errno on failure
6560 */
6561static int
6562__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6563 struct wireless_dev *wdev,
6564 const void *data,
6565 int data_len)
6566{
6567 struct net_device *dev = wdev->netdev;
6568 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6569 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6570 int ret;
6571 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6572 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6573
6574 ENTER();
6575
6576 ret = wlan_hdd_validate_context(hdd_ctx);
6577 if (0 != ret) {
6578 hddLog(LOGE, FL("HDD context is not valid"));
6579 return ret;
6580 }
6581
6582 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6583 policy)) {
6584 hddLog(LOGE, FL("Invalid ATTR"));
6585 return -EINVAL;
6586 }
6587
6588 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6589 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6590 return -EINVAL;
6591 }
6592
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306593 hdd_ctx->isSetBandByNL = TRUE;
6594 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306595 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306596 hdd_ctx->isSetBandByNL = FALSE;
6597
6598 EXIT();
6599 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306600}
6601
6602/**
6603 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6604 * @wiphy: wiphy structure pointer
6605 * @wdev: Wireless device structure pointer
6606 * @data: Pointer to the data received
6607 * @data_len: Length of @data
6608 *
6609 * Return: 0 on success; errno on failure
6610 */
6611static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6612 struct wireless_dev *wdev,
6613 const void *data,
6614 int data_len)
6615{
6616 int ret = 0;
6617
6618 vos_ssr_protect(__func__);
6619 ret = __wlan_hdd_cfg80211_setband(wiphy,
6620 wdev, data, data_len);
6621 vos_ssr_unprotect(__func__);
6622
6623 return ret;
6624}
6625
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306626#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6627/**
6628 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6629 * @hdd_ctx: HDD context
6630 * @request_id: [input] request id
6631 * @pattern_id: [output] pattern id
6632 *
6633 * This function loops through request id to pattern id array
6634 * if the slot is available, store the request id and return pattern id
6635 * if entry exists, return the pattern id
6636 *
6637 * Return: 0 on success and errno on failure
6638 */
6639static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6640 uint32_t request_id,
6641 uint8_t *pattern_id)
6642{
6643 uint32_t i;
6644
6645 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6646 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6647 {
6648 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6649 {
6650 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6651 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6652 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6653 return 0;
6654 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6655 request_id) {
6656 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6657 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6658 return 0;
6659 }
6660 }
6661 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6662 return -EINVAL;
6663}
6664
6665/**
6666 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6667 * @hdd_ctx: HDD context
6668 * @request_id: [input] request id
6669 * @pattern_id: [output] pattern id
6670 *
6671 * This function loops through request id to pattern id array
6672 * reset request id to 0 (slot available again) and
6673 * return pattern id
6674 *
6675 * Return: 0 on success and errno on failure
6676 */
6677static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6678 uint32_t request_id,
6679 uint8_t *pattern_id)
6680{
6681 uint32_t i;
6682
6683 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6684 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6685 {
6686 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6687 {
6688 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6689 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6690 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6691 return 0;
6692 }
6693 }
6694 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6695 return -EINVAL;
6696}
6697
6698
6699/*
6700 * define short names for the global vendor params
6701 * used by __wlan_hdd_cfg80211_offloaded_packets()
6702 */
6703#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6704#define PARAM_REQUEST_ID \
6705 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6706#define PARAM_CONTROL \
6707 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6708#define PARAM_IP_PACKET \
6709 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6710#define PARAM_SRC_MAC_ADDR \
6711 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6712#define PARAM_DST_MAC_ADDR \
6713 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6714#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6715
6716/**
6717 * wlan_hdd_add_tx_ptrn() - add tx pattern
6718 * @adapter: adapter pointer
6719 * @hdd_ctx: hdd context
6720 * @tb: nl attributes
6721 *
6722 * This function reads the NL attributes and forms a AddTxPtrn message
6723 * posts it to SME.
6724 *
6725 */
6726static int
6727wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6728 struct nlattr **tb)
6729{
6730 struct sSirAddPeriodicTxPtrn *add_req;
6731 eHalStatus status;
6732 uint32_t request_id, ret, len;
6733 uint8_t pattern_id = 0;
6734 v_MACADDR_t dst_addr;
6735 uint16_t eth_type = htons(ETH_P_IP);
6736
6737 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6738 {
6739 hddLog(LOGE, FL("Not in Connected state!"));
6740 return -ENOTSUPP;
6741 }
6742
6743 add_req = vos_mem_malloc(sizeof(*add_req));
6744 if (!add_req)
6745 {
6746 hddLog(LOGE, FL("memory allocation failed"));
6747 return -ENOMEM;
6748 }
6749
6750 /* Parse and fetch request Id */
6751 if (!tb[PARAM_REQUEST_ID])
6752 {
6753 hddLog(LOGE, FL("attr request id failed"));
6754 goto fail;
6755 }
6756
6757 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6758 hddLog(LOG1, FL("Request Id: %u"), request_id);
6759 if (request_id == 0)
6760 {
6761 hddLog(LOGE, FL("request_id cannot be zero"));
Sreelakshmi Konamkideb22532016-04-14 14:59:13 +05306762 goto fail;
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306763 }
6764
6765 if (!tb[PARAM_PERIOD])
6766 {
6767 hddLog(LOGE, FL("attr period failed"));
6768 goto fail;
6769 }
6770 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6771 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6772 if (add_req->usPtrnIntervalMs == 0)
6773 {
6774 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6775 goto fail;
6776 }
6777
6778 if (!tb[PARAM_SRC_MAC_ADDR])
6779 {
6780 hddLog(LOGE, FL("attr source mac address failed"));
6781 goto fail;
6782 }
6783 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6784 VOS_MAC_ADDR_SIZE);
6785 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6786 MAC_ADDR_ARRAY(add_req->macAddress));
6787
6788 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6789 VOS_MAC_ADDR_SIZE))
6790 {
6791 hddLog(LOGE,
6792 FL("input src mac address and connected ap bssid are different"));
6793 goto fail;
6794 }
6795
6796 if (!tb[PARAM_DST_MAC_ADDR])
6797 {
6798 hddLog(LOGE, FL("attr dst mac address failed"));
6799 goto fail;
6800 }
6801 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6802 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6803 MAC_ADDR_ARRAY(dst_addr.bytes));
6804
6805 if (!tb[PARAM_IP_PACKET])
6806 {
6807 hddLog(LOGE, FL("attr ip packet failed"));
6808 goto fail;
6809 }
6810 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6811 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6812
6813 if (add_req->ucPtrnSize < 0 ||
6814 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6815 HDD_ETH_HEADER_LEN))
6816 {
6817 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6818 add_req->ucPtrnSize);
6819 goto fail;
6820 }
6821
6822 len = 0;
6823 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6824 len += VOS_MAC_ADDR_SIZE;
6825 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6826 VOS_MAC_ADDR_SIZE);
6827 len += VOS_MAC_ADDR_SIZE;
6828 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6829 len += 2;
6830
6831 /*
6832 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6833 * ------------------------------------------------------------
6834 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6835 * ------------------------------------------------------------
6836 */
6837 vos_mem_copy(&add_req->ucPattern[len],
6838 nla_data(tb[PARAM_IP_PACKET]),
6839 add_req->ucPtrnSize);
6840 add_req->ucPtrnSize += len;
6841
6842 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6843 add_req->ucPattern, add_req->ucPtrnSize);
6844
6845 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6846 if (ret)
6847 {
6848 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6849 goto fail;
6850 }
6851 add_req->ucPtrnId = pattern_id;
6852 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6853
6854 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6855 if (!HAL_STATUS_SUCCESS(status))
6856 {
6857 hddLog(LOGE,
6858 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6859 goto fail;
6860 }
6861
6862 EXIT();
6863 vos_mem_free(add_req);
6864 return 0;
6865
6866fail:
6867 vos_mem_free(add_req);
6868 return -EINVAL;
6869}
6870
6871/**
6872 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6873 * @adapter: adapter pointer
6874 * @hdd_ctx: hdd context
6875 * @tb: nl attributes
6876 *
6877 * This function reads the NL attributes and forms a DelTxPtrn message
6878 * posts it to SME.
6879 *
6880 */
6881static int
6882wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6883 struct nlattr **tb)
6884{
6885 struct sSirDelPeriodicTxPtrn *del_req;
6886 eHalStatus status;
6887 uint32_t request_id, ret;
6888 uint8_t pattern_id = 0;
6889
6890 /* Parse and fetch request Id */
6891 if (!tb[PARAM_REQUEST_ID])
6892 {
6893 hddLog(LOGE, FL("attr request id failed"));
6894 return -EINVAL;
6895 }
6896 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6897 if (request_id == 0)
6898 {
6899 hddLog(LOGE, FL("request_id cannot be zero"));
6900 return -EINVAL;
6901 }
6902
6903 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6904 if (ret)
6905 {
6906 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6907 return -EINVAL;
6908 }
6909
6910 del_req = vos_mem_malloc(sizeof(*del_req));
6911 if (!del_req)
6912 {
6913 hddLog(LOGE, FL("memory allocation failed"));
6914 return -ENOMEM;
6915 }
6916
6917 vos_mem_set(del_req, sizeof(*del_req), 0);
6918 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6919 VOS_MAC_ADDR_SIZE);
6920 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6921 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6922 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6923 request_id, pattern_id, del_req->ucPatternIdBitmap);
6924
6925 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6926 if (!HAL_STATUS_SUCCESS(status))
6927 {
6928 hddLog(LOGE,
6929 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6930 goto fail;
6931 }
6932
6933 EXIT();
6934 vos_mem_free(del_req);
6935 return 0;
6936
6937fail:
6938 vos_mem_free(del_req);
6939 return -EINVAL;
6940}
6941
6942
6943/**
6944 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6945 * @wiphy: Pointer to wireless phy
6946 * @wdev: Pointer to wireless device
6947 * @data: Pointer to data
6948 * @data_len: Data length
6949 *
6950 * Return: 0 on success, negative errno on failure
6951 */
6952static int
6953__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6954 struct wireless_dev *wdev,
6955 const void *data,
6956 int data_len)
6957{
6958 struct net_device *dev = wdev->netdev;
6959 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6960 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6961 struct nlattr *tb[PARAM_MAX + 1];
6962 uint8_t control;
6963 int ret;
6964 static const struct nla_policy policy[PARAM_MAX + 1] =
6965 {
6966 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6967 [PARAM_CONTROL] = { .type = NLA_U32 },
6968 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
6969 .len = VOS_MAC_ADDR_SIZE },
6970 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
6971 .len = VOS_MAC_ADDR_SIZE },
6972 [PARAM_PERIOD] = { .type = NLA_U32 },
6973 };
6974
6975 ENTER();
6976
6977 ret = wlan_hdd_validate_context(hdd_ctx);
6978 if (0 != ret)
6979 {
6980 hddLog(LOGE, FL("HDD context is not valid"));
6981 return ret;
6982 }
6983
6984 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
6985 {
6986 hddLog(LOGE,
6987 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
6988 return -ENOTSUPP;
6989 }
6990
6991 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
6992 {
6993 hddLog(LOGE, FL("Invalid ATTR"));
6994 return -EINVAL;
6995 }
6996
6997 if (!tb[PARAM_CONTROL])
6998 {
6999 hddLog(LOGE, FL("attr control failed"));
7000 return -EINVAL;
7001 }
7002 control = nla_get_u32(tb[PARAM_CONTROL]);
7003 hddLog(LOG1, FL("Control: %d"), control);
7004
7005 if (control == WLAN_START_OFFLOADED_PACKETS)
7006 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
7007 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
7008 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
7009 else
7010 {
7011 hddLog(LOGE, FL("Invalid control: %d"), control);
7012 return -EINVAL;
7013 }
7014}
7015
7016/*
7017 * done with short names for the global vendor params
7018 * used by __wlan_hdd_cfg80211_offloaded_packets()
7019 */
7020#undef PARAM_MAX
7021#undef PARAM_REQUEST_ID
7022#undef PARAM_CONTROL
7023#undef PARAM_IP_PACKET
7024#undef PARAM_SRC_MAC_ADDR
7025#undef PARAM_DST_MAC_ADDR
7026#undef PARAM_PERIOD
7027
7028/**
7029 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7030 * @wiphy: wiphy structure pointer
7031 * @wdev: Wireless device structure pointer
7032 * @data: Pointer to the data received
7033 * @data_len: Length of @data
7034 *
7035 * Return: 0 on success; errno on failure
7036 */
7037static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7038 struct wireless_dev *wdev,
7039 const void *data,
7040 int data_len)
7041{
7042 int ret = 0;
7043
7044 vos_ssr_protect(__func__);
7045 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7046 wdev, data, data_len);
7047 vos_ssr_unprotect(__func__);
7048
7049 return ret;
7050}
7051#endif
7052
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307053static const struct
7054nla_policy
7055qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
7056 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
7057};
7058
7059/**
7060 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7061 * get link properties like nss, rate flags and operating frequency for
7062 * the connection with the given peer.
7063 * @wiphy: WIPHY structure pointer
7064 * @wdev: Wireless device structure pointer
7065 * @data: Pointer to the data received
7066 * @data_len: Length of the data received
7067 *
7068 * This function return the above link properties on success.
7069 *
7070 * Return: 0 on success and errno on failure
7071 */
7072static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7073 struct wireless_dev *wdev,
7074 const void *data,
7075 int data_len)
7076{
7077 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7078 struct net_device *dev = wdev->netdev;
7079 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7080 hdd_station_ctx_t *hdd_sta_ctx;
7081 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7082 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7083 uint32_t sta_id;
7084 struct sk_buff *reply_skb;
7085 uint32_t rate_flags = 0;
7086 uint8_t nss;
7087 uint8_t final_rate_flags = 0;
7088 uint32_t freq;
7089 v_CONTEXT_t pVosContext = NULL;
7090 ptSapContext pSapCtx = NULL;
7091
7092 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7094 return -EINVAL;
7095 }
7096
7097 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7098 qca_wlan_vendor_attr_policy)) {
7099 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7100 return -EINVAL;
7101 }
7102
7103 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7104 hddLog(VOS_TRACE_LEVEL_ERROR,
7105 FL("Attribute peerMac not provided for mode=%d"),
7106 adapter->device_mode);
7107 return -EINVAL;
7108 }
7109
7110 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7111 sizeof(peer_mac));
7112 hddLog(VOS_TRACE_LEVEL_INFO,
7113 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7114 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7115
7116 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7117 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7118 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7119 if ((hdd_sta_ctx->conn_info.connState !=
7120 eConnectionState_Associated) ||
7121 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7122 VOS_MAC_ADDRESS_LEN)) {
7123 hddLog(VOS_TRACE_LEVEL_ERROR,
7124 FL("Not Associated to mac "MAC_ADDRESS_STR),
7125 MAC_ADDR_ARRAY(peer_mac));
7126 return -EINVAL;
7127 }
7128
7129 nss = 1; //pronto supports only one spatial stream
7130 freq = vos_chan_to_freq(
7131 hdd_sta_ctx->conn_info.operationChannel);
7132 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7133
7134 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7135 adapter->device_mode == WLAN_HDD_SOFTAP) {
7136
7137 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7138 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7139 if(pSapCtx == NULL){
7140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7141 FL("psapCtx is NULL"));
7142 return -ENOENT;
7143 }
7144
7145
7146 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7147 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7148 !vos_is_macaddr_broadcast(
7149 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7150 vos_mem_compare(
7151 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7152 peer_mac, VOS_MAC_ADDRESS_LEN))
7153 break;
7154 }
7155
7156 if (WLAN_MAX_STA_COUNT == sta_id) {
7157 hddLog(VOS_TRACE_LEVEL_ERROR,
7158 FL("No active peer with mac="MAC_ADDRESS_STR),
7159 MAC_ADDR_ARRAY(peer_mac));
7160 return -EINVAL;
7161 }
7162
7163 nss = 1; //pronto supports only one spatial stream
7164 freq = vos_chan_to_freq(
7165 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7166 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7167 } else {
7168 hddLog(VOS_TRACE_LEVEL_ERROR,
7169 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7170 MAC_ADDR_ARRAY(peer_mac));
7171 return -EINVAL;
7172 }
7173
7174 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7175 if (rate_flags & eHAL_TX_RATE_VHT80) {
7176 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7177 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7178 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7179 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7180 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7181 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7182 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7183 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7184 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7185 if (rate_flags & eHAL_TX_RATE_HT40)
7186 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7187 }
7188
7189 if (rate_flags & eHAL_TX_RATE_SGI) {
7190 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7191 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7192 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7193 }
7194 }
7195
7196 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7197 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7198
7199 if (NULL == reply_skb) {
7200 hddLog(VOS_TRACE_LEVEL_ERROR,
7201 FL("getLinkProperties: skb alloc failed"));
7202 return -EINVAL;
7203 }
7204
7205 if (nla_put_u8(reply_skb,
7206 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7207 nss) ||
7208 nla_put_u8(reply_skb,
7209 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7210 final_rate_flags) ||
7211 nla_put_u32(reply_skb,
7212 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7213 freq)) {
7214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7215 kfree_skb(reply_skb);
7216 return -EINVAL;
7217 }
7218
7219 return cfg80211_vendor_cmd_reply(reply_skb);
7220}
7221
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307222#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7223#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7224#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7225#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307226#define PARAM_BCNMISS_PENALTY_PARAM_COUNT \
7227 QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307228
7229/**
7230 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7231 * vendor command
7232 *
7233 * @wiphy: wiphy device pointer
7234 * @wdev: wireless device pointer
7235 * @data: Vendor command data buffer
7236 * @data_len: Buffer length
7237 *
7238 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7239 *
7240 * Return: EOK or other error codes.
7241 */
7242
7243static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7244 struct wireless_dev *wdev,
7245 const void *data,
7246 int data_len)
7247{
7248 struct net_device *dev = wdev->netdev;
7249 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7250 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7251 hdd_station_ctx_t *pHddStaCtx;
7252 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7253 tpSetWifiConfigParams pReq;
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307254 tModifyRoamParamsReqParams modifyRoamParamsReq;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307255 eHalStatus status;
7256 int ret_val;
7257 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7258 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7259 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307260 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7261 [PARAM_BCNMISS_PENALTY_PARAM_COUNT] =
7262 { .type = NLA_U32},
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307263 };
7264
7265 ENTER();
7266
7267 if (VOS_FTM_MODE == hdd_get_conparam()) {
7268 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7269 return -EINVAL;
7270 }
7271
7272 ret_val = wlan_hdd_validate_context(pHddCtx);
7273 if (ret_val) {
7274 return ret_val;
7275 }
7276
7277 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7278
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307279 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7280 hddLog(LOGE, FL("Invalid ATTR"));
7281 return -EINVAL;
7282 }
7283
7284 /* check the Wifi Capability */
7285 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7286 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7287 {
7288 hddLog(VOS_TRACE_LEVEL_ERROR,
7289 FL("WIFICONFIG not supported by Firmware"));
7290 return -EINVAL;
7291 }
7292
Mahesh A Saptasagar41f9ddd2016-02-09 14:01:03 +05307293 if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) {
7294 modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT;
7295 modifyRoamParamsReq.value =
7296 nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]);
7297
7298 if (eHAL_STATUS_SUCCESS !=
7299 sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq))
7300 {
7301 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__);
7302 ret_val = -EINVAL;
7303 }
7304 return ret_val;
7305 }
7306
7307 /* Moved this down in order to provide provision to set beacon
7308 * miss penalty count irrespective of connection state.
7309 */
7310 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7311 hddLog(LOGE, FL("Not in Connected state!"));
7312 return -ENOTSUPP;
7313 }
7314
7315 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307316
7317 if (!pReq) {
7318 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7319 "%s: Not able to allocate memory for tSetWifiConfigParams",
7320 __func__);
7321 return eHAL_STATUS_E_MALLOC_FAILED;
7322 }
7323
7324 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7325
7326 pReq->sessionId = pAdapter->sessionId;
7327 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7328
7329 if (tb[PARAM_MODULATED_DTIM]) {
7330 pReq->paramValue = nla_get_u32(
7331 tb[PARAM_MODULATED_DTIM]);
7332 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7333 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307334 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307335 hdd_set_pwrparams(pHddCtx);
7336 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7337 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7338
7339 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7340 iw_full_power_cbfn, pAdapter,
7341 eSME_FULL_PWR_NEEDED_BY_HDD);
7342 }
7343 else
7344 {
7345 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7346 }
7347 }
7348
7349 if (tb[PARAM_STATS_AVG_FACTOR]) {
7350 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7351 pReq->paramValue = nla_get_u16(
7352 tb[PARAM_STATS_AVG_FACTOR]);
7353 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7354 pReq->paramType, pReq->paramValue);
7355 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7356
7357 if (eHAL_STATUS_SUCCESS != status)
7358 {
7359 vos_mem_free(pReq);
7360 pReq = NULL;
7361 ret_val = -EPERM;
7362 return ret_val;
7363 }
7364 }
7365
7366
7367 if (tb[PARAM_GUARD_TIME]) {
7368 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7369 pReq->paramValue = nla_get_u32(
7370 tb[PARAM_GUARD_TIME]);
7371 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7372 pReq->paramType, pReq->paramValue);
7373 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7374
7375 if (eHAL_STATUS_SUCCESS != status)
7376 {
7377 vos_mem_free(pReq);
7378 pReq = NULL;
7379 ret_val = -EPERM;
7380 return ret_val;
7381 }
7382
7383 }
7384
7385 EXIT();
7386 return ret_val;
7387}
7388
7389/**
7390 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7391 * vendor command
7392 *
7393 * @wiphy: wiphy device pointer
7394 * @wdev: wireless device pointer
7395 * @data: Vendor command data buffer
7396 * @data_len: Buffer length
7397 *
7398 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7399 *
7400 * Return: EOK or other error codes.
7401 */
7402static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7403 struct wireless_dev *wdev,
7404 const void *data,
7405 int data_len)
7406{
7407 int ret;
7408
7409 vos_ssr_protect(__func__);
7410 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
7411 data, data_len);
7412 vos_ssr_unprotect(__func__);
7413
7414 return ret;
7415}
Sunil Duttc69bccb2014-05-26 21:30:20 +05307416const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7417{
Mukul Sharma2a271632014-10-13 14:59:01 +05307418 {
7419 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7420 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7421 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7422 WIPHY_VENDOR_CMD_NEED_NETDEV |
7423 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307424 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307425 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307426
7427 {
7428 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7429 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7430 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7431 WIPHY_VENDOR_CMD_NEED_NETDEV |
7432 WIPHY_VENDOR_CMD_NEED_RUNNING,
7433 .doit = wlan_hdd_cfg80211_nan_request
7434 },
7435
Sunil Duttc69bccb2014-05-26 21:30:20 +05307436#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7437 {
7438 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7439 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7440 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7441 WIPHY_VENDOR_CMD_NEED_NETDEV |
7442 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307443 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307444 },
7445
7446 {
7447 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7448 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7449 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7450 WIPHY_VENDOR_CMD_NEED_NETDEV |
7451 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307452 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307453 },
7454
7455 {
7456 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7457 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7458 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7459 WIPHY_VENDOR_CMD_NEED_NETDEV |
7460 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307461 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307462 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307463#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307464#ifdef WLAN_FEATURE_EXTSCAN
7465 {
7466 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7467 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7468 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7469 WIPHY_VENDOR_CMD_NEED_NETDEV |
7470 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307471 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307472 },
7473 {
7474 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7475 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7476 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7477 WIPHY_VENDOR_CMD_NEED_NETDEV |
7478 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307479 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307480 },
7481 {
7482 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7483 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7484 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7485 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307486 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307487 },
7488 {
7489 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7490 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
7491 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7492 WIPHY_VENDOR_CMD_NEED_NETDEV |
7493 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307494 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307495 },
7496 {
7497 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7498 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7499 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7500 WIPHY_VENDOR_CMD_NEED_NETDEV |
7501 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307502 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307503 },
7504 {
7505 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7506 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7507 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7508 WIPHY_VENDOR_CMD_NEED_NETDEV |
7509 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307510 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307511 },
7512 {
7513 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7514 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7515 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7516 WIPHY_VENDOR_CMD_NEED_NETDEV |
7517 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307518 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307519 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307520 {
7521 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7522 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
7523 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7524 WIPHY_VENDOR_CMD_NEED_NETDEV |
7525 WIPHY_VENDOR_CMD_NEED_RUNNING,
7526 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
7527 },
7528 {
7529 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7530 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
7531 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7532 WIPHY_VENDOR_CMD_NEED_NETDEV |
7533 WIPHY_VENDOR_CMD_NEED_RUNNING,
7534 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
7535 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307536#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307537/*EXT TDLS*/
7538 {
7539 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7540 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7541 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7542 WIPHY_VENDOR_CMD_NEED_NETDEV |
7543 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307544 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307545 },
7546 {
7547 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7548 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7549 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7550 WIPHY_VENDOR_CMD_NEED_NETDEV |
7551 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307552 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307553 },
7554 {
7555 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7556 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7557 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7558 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307559 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307560 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307561 {
7562 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7563 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7564 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7565 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307566 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307567 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307568 {
7569 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7570 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7571 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7572 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307573 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307574 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307575 {
7576 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7577 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7578 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7579 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307580 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307581 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307582 {
7583 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7584 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7585 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7586 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307587 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307588 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307589 {
7590 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307591 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7592 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7593 WIPHY_VENDOR_CMD_NEED_NETDEV |
7594 WIPHY_VENDOR_CMD_NEED_RUNNING,
7595 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7596 },
7597 {
7598 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307599 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7600 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7601 WIPHY_VENDOR_CMD_NEED_NETDEV |
7602 WIPHY_VENDOR_CMD_NEED_RUNNING,
7603 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307604 },
7605 {
7606 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7607 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7608 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7609 WIPHY_VENDOR_CMD_NEED_NETDEV,
7610 .doit = wlan_hdd_cfg80211_wifi_logger_start
7611 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307612 {
7613 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7614 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7615 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7616 WIPHY_VENDOR_CMD_NEED_NETDEV|
7617 WIPHY_VENDOR_CMD_NEED_RUNNING,
7618 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307619 },
7620 {
7621 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7622 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7623 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7624 WIPHY_VENDOR_CMD_NEED_NETDEV |
7625 WIPHY_VENDOR_CMD_NEED_RUNNING,
7626 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307627 },
7628 {
7629 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7630 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7631 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7632 WIPHY_VENDOR_CMD_NEED_NETDEV |
7633 WIPHY_VENDOR_CMD_NEED_RUNNING,
7634 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307635 },
7636#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7637 {
7638 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7639 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7640 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7641 WIPHY_VENDOR_CMD_NEED_NETDEV |
7642 WIPHY_VENDOR_CMD_NEED_RUNNING,
7643 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307644 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307645#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307646 {
7647 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7648 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7649 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7650 WIPHY_VENDOR_CMD_NEED_NETDEV |
7651 WIPHY_VENDOR_CMD_NEED_RUNNING,
7652 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307653 },
7654 {
7655 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7656 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
7657 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7658 WIPHY_VENDOR_CMD_NEED_NETDEV |
7659 WIPHY_VENDOR_CMD_NEED_RUNNING,
7660 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307661 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05307662};
7663
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007664/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307665static const
7666struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007667{
7668#ifdef FEATURE_WLAN_CH_AVOID
7669 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307670 .vendor_id = QCA_NL80211_VENDOR_ID,
7671 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007672 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307673#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7674#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7675 {
7676 /* Index = 1*/
7677 .vendor_id = QCA_NL80211_VENDOR_ID,
7678 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7679 },
7680 {
7681 /* Index = 2*/
7682 .vendor_id = QCA_NL80211_VENDOR_ID,
7683 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7684 },
7685 {
7686 /* Index = 3*/
7687 .vendor_id = QCA_NL80211_VENDOR_ID,
7688 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7689 },
7690 {
7691 /* Index = 4*/
7692 .vendor_id = QCA_NL80211_VENDOR_ID,
7693 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7694 },
7695 {
7696 /* Index = 5*/
7697 .vendor_id = QCA_NL80211_VENDOR_ID,
7698 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7699 },
7700 {
7701 /* Index = 6*/
7702 .vendor_id = QCA_NL80211_VENDOR_ID,
7703 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7704 },
7705#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307706#ifdef WLAN_FEATURE_EXTSCAN
7707 {
7708 .vendor_id = QCA_NL80211_VENDOR_ID,
7709 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7710 },
7711 {
7712 .vendor_id = QCA_NL80211_VENDOR_ID,
7713 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7714 },
7715 {
7716 .vendor_id = QCA_NL80211_VENDOR_ID,
7717 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7718 },
7719 {
7720 .vendor_id = QCA_NL80211_VENDOR_ID,
7721 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7722 },
7723 {
7724 .vendor_id = QCA_NL80211_VENDOR_ID,
7725 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7726 },
7727 {
7728 .vendor_id = QCA_NL80211_VENDOR_ID,
7729 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7730 },
7731 {
7732 .vendor_id = QCA_NL80211_VENDOR_ID,
7733 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7734 },
7735 {
7736 .vendor_id = QCA_NL80211_VENDOR_ID,
7737 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7738 },
7739 {
7740 .vendor_id = QCA_NL80211_VENDOR_ID,
7741 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7742 },
7743 {
7744 .vendor_id = QCA_NL80211_VENDOR_ID,
7745 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7746 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307747 {
7748 .vendor_id = QCA_NL80211_VENDOR_ID,
7749 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
7750 },
7751 {
7752 .vendor_id = QCA_NL80211_VENDOR_ID,
7753 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
7754 },
7755 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
7756 .vendor_id = QCA_NL80211_VENDOR_ID,
7757 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
7758 },
7759 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
7760 .vendor_id = QCA_NL80211_VENDOR_ID,
7761 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
7762 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307763#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307764/*EXT TDLS*/
7765 {
7766 .vendor_id = QCA_NL80211_VENDOR_ID,
7767 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7768 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307769 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7770 .vendor_id = QCA_NL80211_VENDOR_ID,
7771 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7772 },
7773
Srinivas Dasari030bad32015-02-18 23:23:54 +05307774
7775 {
7776 .vendor_id = QCA_NL80211_VENDOR_ID,
7777 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7778 },
7779
Sushant Kaushik084f6592015-09-10 13:11:56 +05307780 {
7781 .vendor_id = QCA_NL80211_VENDOR_ID,
7782 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307783 },
7784 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7785 .vendor_id = QCA_NL80211_VENDOR_ID,
7786 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7787 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05307788 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
7789 .vendor_id = QCA_NL80211_VENDOR_ID,
7790 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
7791 },
Sushant Kaushik084f6592015-09-10 13:11:56 +05307792
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007793};
7794
Jeff Johnson295189b2012-06-20 16:38:30 -07007795/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307796 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307797 * This function is called by hdd_wlan_startup()
7798 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307799 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307801struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007802{
7803 struct wiphy *wiphy;
7804 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307805 /*
7806 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 */
7808 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7809
7810 if (!wiphy)
7811 {
7812 /* Print error and jump into err label and free the memory */
7813 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7814 return NULL;
7815 }
7816
Sunil Duttc69bccb2014-05-26 21:30:20 +05307817
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 return wiphy;
7819}
7820
7821/*
7822 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307823 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 * private ioctl to change the band value
7825 */
7826int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7827{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307828 int i, j;
7829 eNVChannelEnabledType channelEnabledState;
7830
Jeff Johnsone7245742012-09-05 17:12:55 -07007831 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307832
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307833 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307835
7836 if (NULL == wiphy->bands[i])
7837 {
7838 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7839 __func__, i);
7840 continue;
7841 }
7842
7843 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7844 {
7845 struct ieee80211_supported_band *band = wiphy->bands[i];
7846
7847 channelEnabledState = vos_nv_getChannelEnabledState(
7848 band->channels[j].hw_value);
7849
7850 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7851 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307852 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307853 continue;
7854 }
7855 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7856 {
7857 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7858 continue;
7859 }
7860
7861 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7862 NV_CHANNEL_INVALID == channelEnabledState)
7863 {
7864 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7865 }
7866 else if (NV_CHANNEL_DFS == channelEnabledState)
7867 {
7868 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7869 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7870 }
7871 else
7872 {
7873 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7874 |IEEE80211_CHAN_RADAR);
7875 }
7876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 }
7878 return 0;
7879}
7880/*
7881 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307882 * This function is called by hdd_wlan_startup()
7883 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 * This function is used to initialize and register wiphy structure.
7885 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307886int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 struct wiphy *wiphy,
7888 hdd_config_t *pCfg
7889 )
7890{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307891 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307892 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7893
Jeff Johnsone7245742012-09-05 17:12:55 -07007894 ENTER();
7895
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 /* Now bind the underlying wlan device with wiphy */
7897 set_wiphy_dev(wiphy, dev);
7898
7899 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007900
Kiet Lam6c583332013-10-14 05:37:09 +05307901#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007902 /* the flag for the other case would be initialzed in
7903 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07007904 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307905#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007906
Amar Singhalfddc28c2013-09-05 13:03:40 -07007907 /* This will disable updating of NL channels from passive to
7908 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307909#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7910 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7911#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007912 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307913#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007914
Amar Singhala49cbc52013-10-08 18:37:44 -07007915
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007916#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007917 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7918 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7919 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007920 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307921#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7922 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
7923#else
7924 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7925#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007926#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007927
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007928#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007929 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007930#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007931 || pCfg->isFastRoamIniFeatureEnabled
7932#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007933#ifdef FEATURE_WLAN_ESE
7934 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007935#endif
7936 )
7937 {
7938 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7939 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007940#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007941#ifdef FEATURE_WLAN_TDLS
7942 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7943 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7944#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307945#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307946 if (pCfg->configPNOScanSupport)
7947 {
7948 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7949 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7950 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7951 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7952 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307953#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007954
Abhishek Singh10d85972015-04-17 10:27:23 +05307955#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7956 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7957#endif
7958
Amar Singhalfddc28c2013-09-05 13:03:40 -07007959#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007960 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
7961 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07007962 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007963 driver need to determine what to do with both
7964 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07007965
7966 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07007967#else
7968 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007969#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007970
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307971 wiphy->max_scan_ssids = MAX_SCAN_SSID;
7972
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05307973 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07007974
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307975 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
7976
Jeff Johnson295189b2012-06-20 16:38:30 -07007977 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05307978 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7979 | BIT(NL80211_IFTYPE_ADHOC)
7980 | BIT(NL80211_IFTYPE_P2P_CLIENT)
7981 | BIT(NL80211_IFTYPE_P2P_GO)
7982 | BIT(NL80211_IFTYPE_AP);
7983
7984 if (VOS_MONITOR_MODE == hdd_get_conparam())
7985 {
7986 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
7987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007988
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307989 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007990 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307991#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7992 if( pCfg->enableMCC )
7993 {
7994 /* Currently, supports up to two channels */
7995 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007996
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307997 if( !pCfg->allowMCCGODiffBI )
7998 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007999
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308000 }
8001 wiphy->iface_combinations = &wlan_hdd_iface_combination;
8002 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008003#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05308004 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08008005
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 /* Before registering we need to update the ht capabilitied based
8007 * on ini values*/
8008 if( !pCfg->ShortGI20MhzEnable )
8009 {
8010 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
8011 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 }
8013
8014 if( !pCfg->ShortGI40MhzEnable )
8015 {
8016 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
8017 }
8018
8019 if( !pCfg->nChannelBondingMode5GHz )
8020 {
8021 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8022 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05308023 /*
8024 * In case of static linked driver at the time of driver unload,
8025 * module exit doesn't happens. Module cleanup helps in cleaning
8026 * of static memory.
8027 * If driver load happens statically, at the time of driver unload,
8028 * wiphy flags don't get reset because of static memory.
8029 * It's better not to store channel in static memory.
8030 */
8031 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
8032 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8033 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8034 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8035 {
8036 hddLog(VOS_TRACE_LEVEL_ERROR,
8037 FL("Not enough memory to allocate channels"));
8038 return -ENOMEM;
8039 }
8040 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8041 &hdd_channels_2_4_GHZ[0],
8042 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008043
Agrawal Ashish97dec502015-11-26 20:20:58 +05308044 if (true == hdd_is_5g_supported(pHddCtx))
8045 {
8046 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8047 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8048 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8049 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8050 {
8051 hddLog(VOS_TRACE_LEVEL_ERROR,
8052 FL("Not enough memory to allocate channels"));
8053 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8054 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8055 return -ENOMEM;
8056 }
8057 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8058 &hdd_channels_5_GHZ[0],
8059 sizeof(hdd_channels_5_GHZ));
8060 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308061
8062 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8063 {
8064
8065 if (NULL == wiphy->bands[i])
8066 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308067 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308068 __func__, i);
8069 continue;
8070 }
8071
8072 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8073 {
8074 struct ieee80211_supported_band *band = wiphy->bands[i];
8075
8076 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8077 {
8078 // Enable social channels for P2P
8079 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8080 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8081 else
8082 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8083 continue;
8084 }
8085 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8086 {
8087 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8088 continue;
8089 }
8090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 }
8092 /*Initialise the supported cipher suite details*/
8093 wiphy->cipher_suites = hdd_cipher_suites;
8094 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8095
8096 /*signal strength in mBm (100*dBm) */
8097 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8098
8099#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308100 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008102
Sunil Duttc69bccb2014-05-26 21:30:20 +05308103 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8104 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008105 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8106 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8107
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308108 EXIT();
8109 return 0;
8110}
8111
8112/* In this function we are registering wiphy. */
8113int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8114{
8115 ENTER();
8116 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 if (0 > wiphy_register(wiphy))
8118 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308119 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8121 return -EIO;
8122 }
8123
8124 EXIT();
8125 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308126}
Jeff Johnson295189b2012-06-20 16:38:30 -07008127
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308128/* In this function we are updating channel list when,
8129 regulatory domain is FCC and country code is US.
8130 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8131 As per FCC smart phone is not a indoor device.
8132 GO should not opeate on indoor channels */
8133void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8134{
8135 int j;
8136 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8137 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8138 //Default counrtycode from NV at the time of wiphy initialization.
8139 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8140 &defaultCountryCode[0]))
8141 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008142 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308143 }
8144 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8145 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308146 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8147 {
8148 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8149 return;
8150 }
8151 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8152 {
8153 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8154 // Mark UNII -1 band channel as passive
8155 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8156 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8157 }
8158 }
8159}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308160/* This function registers for all frame which supplicant is interested in */
8161void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008162{
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8164 /* Register for all P2P action, public action etc frames */
8165 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008166 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308167 /* Register frame indication call back */
8168 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 /* Right now we are registering these frame when driver is getting
8170 initialized. Once we will move to 2.6.37 kernel, in which we have
8171 frame register ops, we will move this code as a part of that */
8172 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308173 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8175
8176 /* GAS Initial Response */
8177 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8178 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308179
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 /* GAS Comeback Request */
8181 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8182 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8183
8184 /* GAS Comeback Response */
8185 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8186 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8187
8188 /* P2P Public Action */
8189 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308190 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 P2P_PUBLIC_ACTION_FRAME_SIZE );
8192
8193 /* P2P Action */
8194 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8195 (v_U8_t*)P2P_ACTION_FRAME,
8196 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008197
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308198 /* WNM BSS Transition Request frame */
8199 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8200 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8201 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008202
8203 /* WNM-Notification */
8204 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8205 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8206 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008207}
8208
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308209void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008210{
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8212 /* Register for all P2P action, public action etc frames */
8213 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8214
Jeff Johnsone7245742012-09-05 17:12:55 -07008215 ENTER();
8216
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 /* Right now we are registering these frame when driver is getting
8218 initialized. Once we will move to 2.6.37 kernel, in which we have
8219 frame register ops, we will move this code as a part of that */
8220 /* GAS Initial Request */
8221
8222 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8223 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8224
8225 /* GAS Initial Response */
8226 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8227 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308228
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 /* GAS Comeback Request */
8230 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8231 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8232
8233 /* GAS Comeback Response */
8234 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8235 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8236
8237 /* P2P Public Action */
8238 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308239 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 P2P_PUBLIC_ACTION_FRAME_SIZE );
8241
8242 /* P2P Action */
8243 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8244 (v_U8_t*)P2P_ACTION_FRAME,
8245 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008246 /* WNM-Notification */
8247 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8248 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8249 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008250}
8251
8252#ifdef FEATURE_WLAN_WAPI
8253void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308254 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008255{
8256 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8257 tCsrRoamSetKey setKey;
8258 v_BOOL_t isConnected = TRUE;
8259 int status = 0;
8260 v_U32_t roamId= 0xFF;
8261 tANI_U8 *pKeyPtr = NULL;
8262 int n = 0;
8263
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8265 __func__, hdd_device_modetoString(pAdapter->device_mode),
8266 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008267
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308268 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 setKey.keyId = key_index; // Store Key ID
8270 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8271 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8272 setKey.paeRole = 0 ; // the PAE role
8273 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8274 {
8275 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8276 }
8277 else
8278 {
8279 isConnected = hdd_connIsConnected(pHddStaCtx);
8280 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8281 }
8282 setKey.keyLength = key_Len;
8283 pKeyPtr = setKey.Key;
8284 memcpy( pKeyPtr, key, key_Len);
8285
Arif Hussain6d2a3322013-11-17 19:50:10 -08008286 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 __func__, key_Len);
8288 for (n = 0 ; n < key_Len; n++)
8289 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8290 __func__,n,setKey.Key[n]);
8291
8292 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8293 if ( isConnected )
8294 {
8295 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8296 pAdapter->sessionId, &setKey, &roamId );
8297 }
8298 if ( status != 0 )
8299 {
8300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8301 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8302 __LINE__, status );
8303 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8304 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308305 /* Need to clear any trace of key value in the memory.
8306 * Thus zero out the memory even though it is local
8307 * variable.
8308 */
8309 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008310}
8311#endif /* FEATURE_WLAN_WAPI*/
8312
8313#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308314int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008315 beacon_data_t **ppBeacon,
8316 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008317#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308318int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008319 beacon_data_t **ppBeacon,
8320 struct cfg80211_beacon_data *params,
8321 int dtim_period)
8322#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308323{
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 int size;
8325 beacon_data_t *beacon = NULL;
8326 beacon_data_t *old = NULL;
8327 int head_len,tail_len;
8328
Jeff Johnsone7245742012-09-05 17:12:55 -07008329 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308331 {
8332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8333 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008336
8337 old = pAdapter->sessionCtx.ap.beacon;
8338
8339 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308340 {
8341 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8342 FL("session(%d) old and new heads points to NULL"),
8343 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308345 }
8346
8347 if (params->tail && !params->tail_len)
8348 {
8349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8350 FL("tail_len is zero but tail is not NULL"));
8351 return -EINVAL;
8352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008353
Jeff Johnson295189b2012-06-20 16:38:30 -07008354#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8355 /* Kernel 3.0 is not updating dtim_period for set beacon */
8356 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308357 {
8358 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8359 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008362#endif
8363
8364 if(params->head)
8365 head_len = params->head_len;
8366 else
8367 head_len = old->head_len;
8368
8369 if(params->tail || !old)
8370 tail_len = params->tail_len;
8371 else
8372 tail_len = old->tail_len;
8373
8374 size = sizeof(beacon_data_t) + head_len + tail_len;
8375
8376 beacon = kzalloc(size, GFP_KERNEL);
8377
8378 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308379 {
8380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8381 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008384
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008385#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 if(params->dtim_period || !old )
8387 beacon->dtim_period = params->dtim_period;
8388 else
8389 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008390#else
8391 if(dtim_period || !old )
8392 beacon->dtim_period = dtim_period;
8393 else
8394 beacon->dtim_period = old->dtim_period;
8395#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308396
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8398 beacon->tail = beacon->head + head_len;
8399 beacon->head_len = head_len;
8400 beacon->tail_len = tail_len;
8401
8402 if(params->head) {
8403 memcpy (beacon->head,params->head,beacon->head_len);
8404 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308405 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 if(old)
8407 memcpy (beacon->head,old->head,beacon->head_len);
8408 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308409
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 if(params->tail) {
8411 memcpy (beacon->tail,params->tail,beacon->tail_len);
8412 }
8413 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308414 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 memcpy (beacon->tail,old->tail,beacon->tail_len);
8416 }
8417
8418 *ppBeacon = beacon;
8419
8420 kfree(old);
8421
8422 return 0;
8423
8424}
Jeff Johnson295189b2012-06-20 16:38:30 -07008425
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308426v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8427#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8428 const v_U8_t *pIes,
8429#else
8430 v_U8_t *pIes,
8431#endif
8432 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008433{
8434 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308435 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308437
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308439 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 elem_id = ptr[0];
8441 elem_len = ptr[1];
8442 left -= 2;
8443 if(elem_len > left)
8444 {
8445 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008446 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 eid,elem_len,left);
8448 return NULL;
8449 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308450 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 {
8452 return ptr;
8453 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308454
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 left -= elem_len;
8456 ptr += (elem_len + 2);
8457 }
8458 return NULL;
8459}
8460
Jeff Johnson295189b2012-06-20 16:38:30 -07008461/* Check if rate is 11g rate or not */
8462static int wlan_hdd_rate_is_11g(u8 rate)
8463{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008464 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 u8 i;
8466 for (i = 0; i < 8; i++)
8467 {
8468 if(rate == gRateArray[i])
8469 return TRUE;
8470 }
8471 return FALSE;
8472}
8473
8474/* Check for 11g rate and set proper 11g only mode */
8475static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8476 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8477{
8478 u8 i, num_rates = pIe[0];
8479
8480 pIe += 1;
8481 for ( i = 0; i < num_rates; i++)
8482 {
8483 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8484 {
8485 /* If rate set have 11g rate than change the mode to 11G */
8486 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8487 if (pIe[i] & BASIC_RATE_MASK)
8488 {
8489 /* If we have 11g rate as basic rate, it means mode
8490 is 11g only mode.
8491 */
8492 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8493 *pCheckRatesfor11g = FALSE;
8494 }
8495 }
8496 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8497 {
8498 *require_ht = TRUE;
8499 }
8500 }
8501 return;
8502}
8503
8504static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8505{
8506 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8507 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8508 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8509 u8 checkRatesfor11g = TRUE;
8510 u8 require_ht = FALSE;
8511 u8 *pIe=NULL;
8512
8513 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8514
8515 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8516 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8517 if (pIe != NULL)
8518 {
8519 pIe += 1;
8520 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8521 &pConfig->SapHw_mode);
8522 }
8523
8524 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8525 WLAN_EID_EXT_SUPP_RATES);
8526 if (pIe != NULL)
8527 {
8528
8529 pIe += 1;
8530 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8531 &pConfig->SapHw_mode);
8532 }
8533
8534 if( pConfig->channel > 14 )
8535 {
8536 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8537 }
8538
8539 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8540 WLAN_EID_HT_CAPABILITY);
8541
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308542 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 {
8544 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8545 if(require_ht)
8546 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8547 }
8548}
8549
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308550static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8551 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8552{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008553 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308554 v_U8_t *pIe = NULL;
8555 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8556
8557 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8558 pBeacon->tail, pBeacon->tail_len);
8559
8560 if (pIe)
8561 {
8562 ielen = pIe[1] + 2;
8563 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8564 {
8565 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8566 }
8567 else
8568 {
8569 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8570 return -EINVAL;
8571 }
8572 *total_ielen += ielen;
8573 }
8574 return 0;
8575}
8576
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008577static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8578 v_U8_t *genie, v_U8_t *total_ielen)
8579{
8580 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8581 int left = pBeacon->tail_len;
8582 v_U8_t *ptr = pBeacon->tail;
8583 v_U8_t elem_id, elem_len;
8584 v_U16_t ielen = 0;
8585
8586 if ( NULL == ptr || 0 == left )
8587 return;
8588
8589 while (left >= 2)
8590 {
8591 elem_id = ptr[0];
8592 elem_len = ptr[1];
8593 left -= 2;
8594 if (elem_len > left)
8595 {
8596 hddLog( VOS_TRACE_LEVEL_ERROR,
8597 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8598 elem_id, elem_len, left);
8599 return;
8600 }
8601 if (IE_EID_VENDOR == elem_id)
8602 {
8603 /* skipping the VSIE's which we don't want to include or
8604 * it will be included by existing code
8605 */
8606 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8607#ifdef WLAN_FEATURE_WFD
8608 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8609#endif
8610 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8611 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8612 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8613 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8614 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8615 {
8616 ielen = ptr[1] + 2;
8617 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8618 {
8619 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8620 *total_ielen += ielen;
8621 }
8622 else
8623 {
8624 hddLog( VOS_TRACE_LEVEL_ERROR,
8625 "IE Length is too big "
8626 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8627 elem_id, elem_len, *total_ielen);
8628 }
8629 }
8630 }
8631
8632 left -= elem_len;
8633 ptr += (elem_len + 2);
8634 }
8635 return;
8636}
8637
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008638#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008639static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8640 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008641#else
8642static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8643 struct cfg80211_beacon_data *params)
8644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008645{
8646 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308647 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008648 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008649 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008650
8651 genie = vos_mem_malloc(MAX_GENIE_LEN);
8652
8653 if(genie == NULL) {
8654
8655 return -ENOMEM;
8656 }
8657
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308658 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8659 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308661 hddLog(LOGE,
8662 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308663 ret = -EINVAL;
8664 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 }
8666
8667#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308668 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8669 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8670 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308671 hddLog(LOGE,
8672 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308673 ret = -EINVAL;
8674 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008675 }
8676#endif
8677
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308678 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8679 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308681 hddLog(LOGE,
8682 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308683 ret = -EINVAL;
8684 goto done;
8685 }
8686
8687 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8688 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008689 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008691
8692 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8693 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8694 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8695 {
8696 hddLog(LOGE,
8697 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008698 ret = -EINVAL;
8699 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 }
8701
8702 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8703 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8704 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8705 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8706 ==eHAL_STATUS_FAILURE)
8707 {
8708 hddLog(LOGE,
8709 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008710 ret = -EINVAL;
8711 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 }
8713
8714 // Added for ProResp IE
8715 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
8716 {
8717 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
8718 u8 probe_rsp_ie_len[3] = {0};
8719 u8 counter = 0;
8720 /* Check Probe Resp Length if it is greater then 255 then Store
8721 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8722 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8723 Store More then 255 bytes into One Variable.
8724 */
8725 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8726 {
8727 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8728 {
8729 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8730 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8731 }
8732 else
8733 {
8734 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8735 rem_probe_resp_ie_len = 0;
8736 }
8737 }
8738
8739 rem_probe_resp_ie_len = 0;
8740
8741 if (probe_rsp_ie_len[0] > 0)
8742 {
8743 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8744 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
8745 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8746 probe_rsp_ie_len[0], NULL,
8747 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8748 {
8749 hddLog(LOGE,
8750 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008751 ret = -EINVAL;
8752 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 }
8754 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8755 }
8756
8757 if (probe_rsp_ie_len[1] > 0)
8758 {
8759 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8760 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
8761 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8762 probe_rsp_ie_len[1], NULL,
8763 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8764 {
8765 hddLog(LOGE,
8766 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008767 ret = -EINVAL;
8768 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 }
8770 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8771 }
8772
8773 if (probe_rsp_ie_len[2] > 0)
8774 {
8775 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8776 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
8777 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8778 probe_rsp_ie_len[2], NULL,
8779 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8780 {
8781 hddLog(LOGE,
8782 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008783 ret = -EINVAL;
8784 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 }
8786 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8787 }
8788
8789 if (probe_rsp_ie_len[1] == 0 )
8790 {
8791 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8792 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8793 eANI_BOOLEAN_FALSE) )
8794 {
8795 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008796 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 }
8798 }
8799
8800 if (probe_rsp_ie_len[2] == 0 )
8801 {
8802 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8803 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8804 eANI_BOOLEAN_FALSE) )
8805 {
8806 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008807 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 }
8809 }
8810
8811 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8812 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8813 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8814 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8815 == eHAL_STATUS_FAILURE)
8816 {
8817 hddLog(LOGE,
8818 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008819 ret = -EINVAL;
8820 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008821 }
8822 }
8823 else
8824 {
8825 // Reset WNI_CFG_PROBE_RSP Flags
8826 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8827
8828 hddLog(VOS_TRACE_LEVEL_INFO,
8829 "%s: No Probe Response IE received in set beacon",
8830 __func__);
8831 }
8832
8833 // Added for AssocResp IE
8834 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
8835 {
8836 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8837 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
8838 params->assocresp_ies_len, NULL,
8839 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8840 {
8841 hddLog(LOGE,
8842 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008843 ret = -EINVAL;
8844 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008845 }
8846
8847 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8848 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8849 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8850 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8851 == eHAL_STATUS_FAILURE)
8852 {
8853 hddLog(LOGE,
8854 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008855 ret = -EINVAL;
8856 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 }
8858 }
8859 else
8860 {
8861 hddLog(VOS_TRACE_LEVEL_INFO,
8862 "%s: No Assoc Response IE received in set beacon",
8863 __func__);
8864
8865 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8866 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8867 eANI_BOOLEAN_FALSE) )
8868 {
8869 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008870 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 }
8872 }
8873
Jeff Johnsone7245742012-09-05 17:12:55 -07008874done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308876 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008877}
Jeff Johnson295189b2012-06-20 16:38:30 -07008878
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308879/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 * FUNCTION: wlan_hdd_validate_operation_channel
8881 * called by wlan_hdd_cfg80211_start_bss() and
8882 * wlan_hdd_cfg80211_set_channel()
8883 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308884 * channel list.
8885 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008886VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008887{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308888
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 v_U32_t num_ch = 0;
8890 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8891 u32 indx = 0;
8892 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308893 v_U8_t fValidChannel = FALSE, count = 0;
8894 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308895
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8897
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308898 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308900 /* Validate the channel */
8901 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308903 if ( channel == rfChannels[count].channelNum )
8904 {
8905 fValidChannel = TRUE;
8906 break;
8907 }
8908 }
8909 if (fValidChannel != TRUE)
8910 {
8911 hddLog(VOS_TRACE_LEVEL_ERROR,
8912 "%s: Invalid Channel [%d]", __func__, channel);
8913 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 }
8915 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308916 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308918 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8919 valid_ch, &num_ch))
8920 {
8921 hddLog(VOS_TRACE_LEVEL_ERROR,
8922 "%s: failed to get valid channel list", __func__);
8923 return VOS_STATUS_E_FAILURE;
8924 }
8925 for (indx = 0; indx < num_ch; indx++)
8926 {
8927 if (channel == valid_ch[indx])
8928 {
8929 break;
8930 }
8931 }
8932
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308933 if (indx >= num_ch)
8934 {
8935 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8936 {
8937 eCsrBand band;
8938 unsigned int freq;
8939
8940 sme_GetFreqBand(hHal, &band);
8941
8942 if (eCSR_BAND_5G == band)
8943 {
8944#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8945 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8946 {
8947 freq = ieee80211_channel_to_frequency(channel,
8948 IEEE80211_BAND_2GHZ);
8949 }
8950 else
8951 {
8952 freq = ieee80211_channel_to_frequency(channel,
8953 IEEE80211_BAND_5GHZ);
8954 }
8955#else
8956 freq = ieee80211_channel_to_frequency(channel);
8957#endif
8958 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8959 return VOS_STATUS_SUCCESS;
8960 }
8961 }
8962
8963 hddLog(VOS_TRACE_LEVEL_ERROR,
8964 "%s: Invalid Channel [%d]", __func__, channel);
8965 return VOS_STATUS_E_FAILURE;
8966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308968
Jeff Johnson295189b2012-06-20 16:38:30 -07008969 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308970
Jeff Johnson295189b2012-06-20 16:38:30 -07008971}
8972
Viral Modi3a32cc52013-02-08 11:14:52 -08008973/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308974 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08008975 * This function is used to set the channel number
8976 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308977static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08008978 struct ieee80211_channel *chan,
8979 enum nl80211_channel_type channel_type
8980 )
8981{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308982 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08008983 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07008984 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08008985 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308986 hdd_context_t *pHddCtx;
8987 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008988
8989 ENTER();
8990
8991 if( NULL == dev )
8992 {
8993 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008994 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08008995 return -ENODEV;
8996 }
8997 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308998
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308999 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9000 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
9001 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08009002 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309003 "%s: device_mode = %s (%d) freq = %d", __func__,
9004 hdd_device_modetoString(pAdapter->device_mode),
9005 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309006
9007 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9008 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309009 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08009010 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309011 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009012 }
9013
9014 /*
9015 * Do freq to chan conversion
9016 * TODO: for 11a
9017 */
9018
9019 channel = ieee80211_frequency_to_channel(freq);
9020
9021 /* Check freq range */
9022 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
9023 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
9024 {
9025 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009026 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08009027 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
9028 WNI_CFG_CURRENT_CHANNEL_STAMAX);
9029 return -EINVAL;
9030 }
9031
9032 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9033
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309034 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9035 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009036 {
9037 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9038 {
9039 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009040 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009041 return -EINVAL;
9042 }
9043 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9044 "%s: set channel to [%d] for device mode =%d",
9045 __func__, channel,pAdapter->device_mode);
9046 }
9047 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009048 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009049 )
9050 {
9051 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9052 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9053 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9054
9055 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9056 {
9057 /* Link is up then return cant set channel*/
9058 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009059 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009060 return -EINVAL;
9061 }
9062
9063 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9064 pHddStaCtx->conn_info.operationChannel = channel;
9065 pRoamProfile->ChannelInfo.ChannelList =
9066 &pHddStaCtx->conn_info.operationChannel;
9067 }
9068 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009069 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009070 )
9071 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309072 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9073 {
9074 if(VOS_STATUS_SUCCESS !=
9075 wlan_hdd_validate_operation_channel(pAdapter,channel))
9076 {
9077 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009078 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309079 return -EINVAL;
9080 }
9081 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9082 }
9083 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009084 {
9085 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9086
9087 /* If auto channel selection is configured as enable/ 1 then ignore
9088 channel set by supplicant
9089 */
9090 if ( cfg_param->apAutoChannelSelection )
9091 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309092 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9093 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009094 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309095 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9096 __func__, hdd_device_modetoString(pAdapter->device_mode),
9097 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009098 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309099 else
9100 {
9101 if(VOS_STATUS_SUCCESS !=
9102 wlan_hdd_validate_operation_channel(pAdapter,channel))
9103 {
9104 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009105 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309106 return -EINVAL;
9107 }
9108 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9109 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009110 }
9111 }
9112 else
9113 {
9114 hddLog(VOS_TRACE_LEVEL_FATAL,
9115 "%s: Invalid device mode failed to set valid channel", __func__);
9116 return -EINVAL;
9117 }
9118 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309119 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009120}
9121
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309122static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9123 struct net_device *dev,
9124 struct ieee80211_channel *chan,
9125 enum nl80211_channel_type channel_type
9126 )
9127{
9128 int ret;
9129
9130 vos_ssr_protect(__func__);
9131 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9132 vos_ssr_unprotect(__func__);
9133
9134 return ret;
9135}
9136
Jeff Johnson295189b2012-06-20 16:38:30 -07009137#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9138static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9139 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009140#else
9141static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9142 struct cfg80211_beacon_data *params,
9143 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309144 enum nl80211_hidden_ssid hidden_ssid,
9145 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009147{
9148 tsap_Config_t *pConfig;
9149 beacon_data_t *pBeacon = NULL;
9150 struct ieee80211_mgmt *pMgmt_frame;
9151 v_U8_t *pIe=NULL;
9152 v_U16_t capab_info;
9153 eCsrAuthType RSNAuthType;
9154 eCsrEncryptionType RSNEncryptType;
9155 eCsrEncryptionType mcRSNEncryptType;
9156 int status = VOS_STATUS_SUCCESS;
9157 tpWLAN_SAPEventCB pSapEventCallback;
9158 hdd_hostapd_state_t *pHostapdState;
9159 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
9160 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309161 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309163 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009165 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309166 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009167 v_BOOL_t MFPCapable = VOS_FALSE;
9168 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309169 v_BOOL_t sapEnable11AC =
9170 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 ENTER();
9172
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309173 iniConfig = pHddCtx->cfg_ini;
9174
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9176
9177 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9178
9179 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9180
9181 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9182
9183 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9184
9185 //channel is already set in the set_channel Call back
9186 //pConfig->channel = pCommitConfig->channel;
9187
9188 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309189 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9191
9192 pConfig->dtim_period = pBeacon->dtim_period;
9193
Arif Hussain6d2a3322013-11-17 19:50:10 -08009194 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 pConfig->dtim_period);
9196
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009197 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009198 {
9199 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309201 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9202 {
9203 tANI_BOOLEAN restartNeeded;
9204 pConfig->ieee80211d = 1;
9205 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9206 sme_setRegInfo(hHal, pConfig->countryCode);
9207 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9208 }
9209 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009211 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009212 pConfig->ieee80211d = 1;
9213 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9214 sme_setRegInfo(hHal, pConfig->countryCode);
9215 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009216 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009217 else
9218 {
9219 pConfig->ieee80211d = 0;
9220 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309221 /*
9222 * If auto channel is configured i.e. channel is 0,
9223 * so skip channel validation.
9224 */
9225 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9226 {
9227 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9228 {
9229 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009230 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309231 return -EINVAL;
9232 }
9233 }
9234 else
9235 {
9236 if(1 != pHddCtx->is_dynamic_channel_range_set)
9237 {
9238 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9239 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9240 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9241 }
9242 pHddCtx->is_dynamic_channel_range_set = 0;
9243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009245 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 {
9247 pConfig->ieee80211d = 0;
9248 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309249
9250#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9251 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9252 pConfig->authType = eSAP_OPEN_SYSTEM;
9253 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9254 pConfig->authType = eSAP_SHARED_KEY;
9255 else
9256 pConfig->authType = eSAP_AUTO_SWITCH;
9257#else
9258 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9259 pConfig->authType = eSAP_OPEN_SYSTEM;
9260 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9261 pConfig->authType = eSAP_SHARED_KEY;
9262 else
9263 pConfig->authType = eSAP_AUTO_SWITCH;
9264#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009265
9266 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309267
9268 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
9270
9271 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9272
9273 /*Set wps station to configured*/
9274 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9275
9276 if(pIe)
9277 {
9278 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9279 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009280 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 return -EINVAL;
9282 }
9283 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9284 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009285 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 /* Check 15 bit of WPS IE as it contain information for wps state
9287 * WPS state
9288 */
9289 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9290 {
9291 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9292 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9293 {
9294 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9295 }
9296 }
9297 }
9298 else
9299 {
9300 pConfig->wps_state = SAP_WPS_DISABLED;
9301 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309302 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009303
c_hpothufe599e92014-06-16 11:38:55 +05309304 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9305 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9306 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9307 eCSR_ENCRYPT_TYPE_NONE;
9308
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 pConfig->RSNWPAReqIELength = 0;
9310 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309311 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 WLAN_EID_RSN);
9313 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309314 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9316 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9317 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309318 /* The actual processing may eventually be more extensive than
9319 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 * by the app.
9321 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309322 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9324 &RSNEncryptType,
9325 &mcRSNEncryptType,
9326 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009327 &MFPCapable,
9328 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 pConfig->pRSNWPAReqIE[1]+2,
9330 pConfig->pRSNWPAReqIE );
9331
9332 if( VOS_STATUS_SUCCESS == status )
9333 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309334 /* Now copy over all the security attributes you have
9335 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 * */
9337 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9338 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9339 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9340 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309341 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009342 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9344 }
9345 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309346
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9348 pBeacon->tail, pBeacon->tail_len);
9349
9350 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9351 {
9352 if (pConfig->pRSNWPAReqIE)
9353 {
9354 /*Mixed mode WPA/WPA2*/
9355 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
9356 pConfig->RSNWPAReqIELength += pIe[1] + 2;
9357 }
9358 else
9359 {
9360 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9361 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9362 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309363 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9365 &RSNEncryptType,
9366 &mcRSNEncryptType,
9367 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009368 &MFPCapable,
9369 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 pConfig->pRSNWPAReqIE[1]+2,
9371 pConfig->pRSNWPAReqIE );
9372
9373 if( VOS_STATUS_SUCCESS == status )
9374 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309375 /* Now copy over all the security attributes you have
9376 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 * */
9378 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9379 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9380 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9381 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309382 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009383 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9385 }
9386 }
9387 }
9388
Jeff Johnson4416a782013-03-25 14:17:50 -07009389 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
9390 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9391 return -EINVAL;
9392 }
9393
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9395
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009396#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009397 if (params->ssid != NULL)
9398 {
9399 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9400 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9401 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9402 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9403 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009404#else
9405 if (ssid != NULL)
9406 {
9407 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9408 pConfig->SSIDinfo.ssid.length = ssid_len;
9409 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9410 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9411 }
9412#endif
9413
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309414 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309416
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 /* default value */
9418 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9419 pConfig->num_accept_mac = 0;
9420 pConfig->num_deny_mac = 0;
9421
9422 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9423 pBeacon->tail, pBeacon->tail_len);
9424
9425 /* pIe for black list is following form:
9426 type : 1 byte
9427 length : 1 byte
9428 OUI : 4 bytes
9429 acl type : 1 byte
9430 no of mac addr in black list: 1 byte
9431 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309432 */
9433 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 {
9435 pConfig->SapMacaddr_acl = pIe[6];
9436 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009437 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309439 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9440 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9442 for (i = 0; i < pConfig->num_deny_mac; i++)
9443 {
9444 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9445 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 }
9448 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9449 pBeacon->tail, pBeacon->tail_len);
9450
9451 /* pIe for white list is following form:
9452 type : 1 byte
9453 length : 1 byte
9454 OUI : 4 bytes
9455 acl type : 1 byte
9456 no of mac addr in white list: 1 byte
9457 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309458 */
9459 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 {
9461 pConfig->SapMacaddr_acl = pIe[6];
9462 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009463 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309465 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9466 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9468 for (i = 0; i < pConfig->num_accept_mac; i++)
9469 {
9470 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9471 acl_entry++;
9472 }
9473 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309474
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9476
Jeff Johnsone7245742012-09-05 17:12:55 -07009477#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009478 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309479 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9480 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309481 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9482 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009483 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9484 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309485 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9486 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009487 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309488 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009489 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309490 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009491
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309492 /* If ACS disable and selected channel <= 14
9493 * OR
9494 * ACS enabled and ACS operating band is choosen as 2.4
9495 * AND
9496 * VHT in 2.4G Disabled
9497 * THEN
9498 * Fallback to 11N mode
9499 */
9500 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9501 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309502 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309503 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009504 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309505 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9506 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009507 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9508 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009509 }
9510#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309511
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 // ht_capab is not what the name conveys,this is used for protection bitmap
9513 pConfig->ht_capab =
9514 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9515
9516 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9517 {
9518 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9519 return -EINVAL;
9520 }
9521
9522 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309523 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9525 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309526 pConfig->obssProtEnabled =
9527 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
Chet Lanctot8cecea22014-02-11 19:09:36 -08009529#ifdef WLAN_FEATURE_11W
9530 pConfig->mfpCapable = MFPCapable;
9531 pConfig->mfpRequired = MFPRequired;
9532 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9533 pConfig->mfpCapable, pConfig->mfpRequired);
9534#endif
9535
Arif Hussain6d2a3322013-11-17 19:50:10 -08009536 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009538 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9539 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9540 (int)pConfig->channel);
9541 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9542 pConfig->SapHw_mode, pConfig->privacy,
9543 pConfig->authType);
9544 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9545 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9546 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9547 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009548
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309549 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 {
9551 //Bss already started. just return.
9552 //TODO Probably it should update some beacon params.
9553 hddLog( LOGE, "Bss Already started...Ignore the request");
9554 EXIT();
9555 return 0;
9556 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309557
Agarwal Ashish51325b52014-06-16 16:50:49 +05309558 if (vos_max_concurrent_connections_reached()) {
9559 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9560 return -EINVAL;
9561 }
9562
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 pConfig->persona = pHostapdAdapter->device_mode;
9564
Peng Xu2446a892014-09-05 17:21:18 +05309565 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9566 if ( NULL != psmeConfig)
9567 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309568 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309569 sme_GetConfigParam(hHal, psmeConfig);
9570 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309571#ifdef WLAN_FEATURE_AP_HT40_24G
9572 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9573 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9574 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9575 {
9576 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9577 sme_UpdateConfig (hHal, psmeConfig);
9578 }
9579#endif
Peng Xu2446a892014-09-05 17:21:18 +05309580 vos_mem_free(psmeConfig);
9581 }
Peng Xuafc34e32014-09-25 13:23:55 +05309582 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309583
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 pSapEventCallback = hdd_hostapd_SAPEventCB;
9585 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9586 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9587 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009588 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 return -EINVAL;
9590 }
9591
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309592 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9594
9595 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309596
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309598 {
9599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009600 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009601 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 VOS_ASSERT(0);
9603 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309604
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309606 /* Initialize WMM configuation */
9607 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309608 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009609
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009610#ifdef WLAN_FEATURE_P2P_DEBUG
9611 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9612 {
9613 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9614 {
9615 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9616 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009617 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009618 }
9619 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9620 {
9621 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9622 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009623 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009624 }
9625 }
9626#endif
9627
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 pHostapdState->bCommit = TRUE;
9629 EXIT();
9630
9631 return 0;
9632}
9633
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009634#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309635static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309636 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 struct beacon_parameters *params)
9638{
9639 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309640 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309641 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009642
9643 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309644
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309645 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9646 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9647 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309648 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9649 hdd_device_modetoString(pAdapter->device_mode),
9650 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009651
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309652 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9653 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309654 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009655 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309656 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009657 }
9658
Agarwal Ashish51325b52014-06-16 16:50:49 +05309659 if (vos_max_concurrent_connections_reached()) {
9660 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9661 return -EINVAL;
9662 }
9663
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309664 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 )
9667 {
9668 beacon_data_t *old,*new;
9669
9670 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309671
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309673 {
9674 hddLog(VOS_TRACE_LEVEL_WARN,
9675 FL("already beacon info added to session(%d)"),
9676 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009677 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009679
9680 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9681
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309682 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 {
9684 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009685 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 return -EINVAL;
9687 }
9688
9689 pAdapter->sessionCtx.ap.beacon = new;
9690
9691 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9692 }
9693
9694 EXIT();
9695 return status;
9696}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309697
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309698static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9699 struct net_device *dev,
9700 struct beacon_parameters *params)
9701{
9702 int ret;
9703
9704 vos_ssr_protect(__func__);
9705 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9706 vos_ssr_unprotect(__func__);
9707
9708 return ret;
9709}
9710
9711static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 struct net_device *dev,
9713 struct beacon_parameters *params)
9714{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309715 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309716 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9717 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309718 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009719
9720 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309721
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309722 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9723 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9724 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9725 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9726 __func__, hdd_device_modetoString(pAdapter->device_mode),
9727 pAdapter->device_mode);
9728
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309729 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9730 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309731 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009732 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309733 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009734 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309735
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309736 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309738 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 {
9740 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309741
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309743
Jeff Johnson295189b2012-06-20 16:38:30 -07009744 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309745 {
9746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9747 FL("session(%d) old and new heads points to NULL"),
9748 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009751
9752 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9753
9754 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309755 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009756 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 return -EINVAL;
9758 }
9759
9760 pAdapter->sessionCtx.ap.beacon = new;
9761
9762 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9763 }
9764
9765 EXIT();
9766 return status;
9767}
9768
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309769static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
9770 struct net_device *dev,
9771 struct beacon_parameters *params)
9772{
9773 int ret;
9774
9775 vos_ssr_protect(__func__);
9776 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
9777 vos_ssr_unprotect(__func__);
9778
9779 return ret;
9780}
9781
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009782#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9783
9784#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309785static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009787#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309788static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009789 struct net_device *dev)
9790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009791{
9792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07009793 hdd_context_t *pHddCtx = NULL;
9794 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309795 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309796 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009797
9798 ENTER();
9799
9800 if (NULL == pAdapter)
9801 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309802 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009803 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 return -ENODEV;
9805 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009806
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309807 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9808 TRACE_CODE_HDD_CFG80211_STOP_AP,
9809 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309810 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9811 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309812 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009813 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309814 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07009815 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009816
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009817 pScanInfo = &pHddCtx->scan_info;
9818
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309819 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9820 __func__, hdd_device_modetoString(pAdapter->device_mode),
9821 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009822
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309823 ret = wlan_hdd_scan_abort(pAdapter);
9824
Girish Gowli4bf7a632014-06-12 13:42:11 +05309825 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07009826 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309827 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9828 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309829
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309830 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07009831 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9833 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08009834
Jeff Johnsone7245742012-09-05 17:12:55 -07009835 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309836 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07009837 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309838 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009839 }
9840
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309841 /* Delete all associated STAs before stopping AP/P2P GO */
9842 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05309843 hdd_hostapd_stop(dev);
9844
Jeff Johnson295189b2012-06-20 16:38:30 -07009845 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 )
9848 {
9849 beacon_data_t *old;
9850
9851 old = pAdapter->sessionCtx.ap.beacon;
9852
9853 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309854 {
9855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9856 FL("session(%d) beacon data points to NULL"),
9857 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009860
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009862
9863 mutex_lock(&pHddCtx->sap_lock);
9864 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9865 {
Jeff Johnson4416a782013-03-25 14:17:50 -07009866 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 {
9868 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9869
9870 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
9871
9872 if (!VOS_IS_STATUS_SUCCESS(status))
9873 {
9874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009875 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309877 }
9878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009879 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309880 /* BSS stopped, clear the active sessions for this device mode */
9881 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 }
9883 mutex_unlock(&pHddCtx->sap_lock);
9884
9885 if(status != VOS_STATUS_SUCCESS)
9886 {
9887 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009888 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 return -EINVAL;
9890 }
9891
Jeff Johnson4416a782013-03-25 14:17:50 -07009892 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
9894 ==eHAL_STATUS_FAILURE)
9895 {
9896 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009897 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 }
9899
Jeff Johnson4416a782013-03-25 14:17:50 -07009900 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009901 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9902 eANI_BOOLEAN_FALSE) )
9903 {
9904 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009905 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 }
9907
9908 // Reset WNI_CFG_PROBE_RSP Flags
9909 wlan_hdd_reset_prob_rspies(pAdapter);
9910
9911 pAdapter->sessionCtx.ap.beacon = NULL;
9912 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009913#ifdef WLAN_FEATURE_P2P_DEBUG
9914 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
9915 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
9916 {
9917 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
9918 "GO got removed");
9919 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
9920 }
9921#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009922 }
9923 EXIT();
9924 return status;
9925}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009926
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309927#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9928static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
9929 struct net_device *dev)
9930{
9931 int ret;
9932
9933 vos_ssr_protect(__func__);
9934 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
9935 vos_ssr_unprotect(__func__);
9936
9937 return ret;
9938}
9939#else
9940static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
9941 struct net_device *dev)
9942{
9943 int ret;
9944
9945 vos_ssr_protect(__func__);
9946 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
9947 vos_ssr_unprotect(__func__);
9948
9949 return ret;
9950}
9951#endif
9952
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009953#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
9954
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309955static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309956 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009957 struct cfg80211_ap_settings *params)
9958{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309959 hdd_adapter_t *pAdapter;
9960 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309961 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009962
9963 ENTER();
9964
Girish Gowlib143d7a2015-02-18 19:39:55 +05309965 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009966 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05309968 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309969 return -ENODEV;
9970 }
9971
9972 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9973 if (NULL == pAdapter)
9974 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309975 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309976 "%s: HDD adapter is Null", __func__);
9977 return -ENODEV;
9978 }
9979
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309980 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9981 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
9982 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309983 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
9984 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309985 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309986 "%s: HDD adapter magic is invalid", __func__);
9987 return -ENODEV;
9988 }
9989
9990 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309991 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309992 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309993 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309994 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309995 }
9996
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309997 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
9998 __func__, hdd_device_modetoString(pAdapter->device_mode),
9999 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010000
10001 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010002 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010003 )
10004 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010005 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010006
10007 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010008
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010009 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010010 {
10011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10012 FL("already beacon info added to session(%d)"),
10013 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010014 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010015 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010016
Girish Gowlib143d7a2015-02-18 19:39:55 +053010017#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
10018 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10019 &new,
10020 &params->beacon);
10021#else
10022 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
10023 &new,
10024 &params->beacon,
10025 params->dtim_period);
10026#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010027
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010028 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010029 {
10030 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +053010031 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010032 return -EINVAL;
10033 }
10034 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010035#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010036 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10037#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10038 params->channel, params->channel_type);
10039#else
10040 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10041#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010042#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010043 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010044 params->ssid_len, params->hidden_ssid,
10045 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010046 }
10047
10048 EXIT();
10049 return status;
10050}
10051
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010052static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10053 struct net_device *dev,
10054 struct cfg80211_ap_settings *params)
10055{
10056 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010057
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010058 vos_ssr_protect(__func__);
10059 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10060 vos_ssr_unprotect(__func__);
10061
10062 return ret;
10063}
10064
10065static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010066 struct net_device *dev,
10067 struct cfg80211_beacon_data *params)
10068{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010070 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010071 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010072
10073 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010074
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010075 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10076 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10077 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010078 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010079 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010080
10081 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10082 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010083 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010084 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010085 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010086 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010087
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010088 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010089 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010090 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010091 {
10092 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010093
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010094 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010095
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010096 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010097 {
10098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10099 FL("session(%d) beacon data points to NULL"),
10100 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010101 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010102 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010103
10104 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10105
10106 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010107 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010108 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010109 return -EINVAL;
10110 }
10111
10112 pAdapter->sessionCtx.ap.beacon = new;
10113
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010114 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10115 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010116 }
10117
10118 EXIT();
10119 return status;
10120}
10121
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010122static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10123 struct net_device *dev,
10124 struct cfg80211_beacon_data *params)
10125{
10126 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010127
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010128 vos_ssr_protect(__func__);
10129 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10130 vos_ssr_unprotect(__func__);
10131
10132 return ret;
10133}
10134
10135#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010136
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010137static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 struct net_device *dev,
10139 struct bss_parameters *params)
10140{
10141 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010142 hdd_context_t *pHddCtx;
10143 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010144
10145 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010146
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010147 if (NULL == pAdapter)
10148 {
10149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10150 "%s: HDD adapter is Null", __func__);
10151 return -ENODEV;
10152 }
10153 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010154 ret = wlan_hdd_validate_context(pHddCtx);
10155 if (0 != ret)
10156 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010157 return ret;
10158 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010159 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10160 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10161 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010162 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10163 __func__, hdd_device_modetoString(pAdapter->device_mode),
10164 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010165
10166 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010168 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 {
10170 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10171 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010172 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 {
10174 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 }
10177
10178 EXIT();
10179 return 0;
10180}
10181
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010182static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10183 struct net_device *dev,
10184 struct bss_parameters *params)
10185{
10186 int ret;
10187
10188 vos_ssr_protect(__func__);
10189 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10190 vos_ssr_unprotect(__func__);
10191
10192 return ret;
10193}
Kiet Lam10841362013-11-01 11:36:50 +053010194/* FUNCTION: wlan_hdd_change_country_code_cd
10195* to wait for contry code completion
10196*/
10197void* wlan_hdd_change_country_code_cb(void *pAdapter)
10198{
10199 hdd_adapter_t *call_back_pAdapter = pAdapter;
10200 complete(&call_back_pAdapter->change_country_code);
10201 return NULL;
10202}
10203
Jeff Johnson295189b2012-06-20 16:38:30 -070010204/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010205 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10207 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010208int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 struct net_device *ndev,
10210 enum nl80211_iftype type,
10211 u32 *flags,
10212 struct vif_params *params
10213 )
10214{
10215 struct wireless_dev *wdev;
10216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010217 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010218 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 tCsrRoamProfile *pRoamProfile = NULL;
10220 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010221 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 eMib_dot11DesiredBssType connectedBssType;
10223 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010224 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010225
10226 ENTER();
10227
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010228 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010229 {
10230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10231 "%s: Adapter context is null", __func__);
10232 return VOS_STATUS_E_FAILURE;
10233 }
10234
10235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10236 if (!pHddCtx)
10237 {
10238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10239 "%s: HDD context is null", __func__);
10240 return VOS_STATUS_E_FAILURE;
10241 }
10242
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010243 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10244 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10245 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010246 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010247 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010249 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 }
10251
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010252 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10253 __func__, hdd_device_modetoString(pAdapter->device_mode),
10254 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010255
Agarwal Ashish51325b52014-06-16 16:50:49 +053010256 if (vos_max_concurrent_connections_reached()) {
10257 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10258 return -EINVAL;
10259 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010260 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 wdev = ndev->ieee80211_ptr;
10262
10263#ifdef WLAN_BTAMP_FEATURE
10264 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10265 (NL80211_IFTYPE_ADHOC == type)||
10266 (NL80211_IFTYPE_AP == type)||
10267 (NL80211_IFTYPE_P2P_GO == type))
10268 {
10269 pHddCtx->isAmpAllowed = VOS_FALSE;
10270 // stop AMP traffic
10271 status = WLANBAP_StopAmp();
10272 if(VOS_STATUS_SUCCESS != status )
10273 {
10274 pHddCtx->isAmpAllowed = VOS_TRUE;
10275 hddLog(VOS_TRACE_LEVEL_FATAL,
10276 "%s: Failed to stop AMP", __func__);
10277 return -EINVAL;
10278 }
10279 }
10280#endif //WLAN_BTAMP_FEATURE
10281 /* Reset the current device mode bit mask*/
10282 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10283
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010284 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10285 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10286 (type == NL80211_IFTYPE_P2P_GO)))
10287 {
10288 /* Notify Mode change in case of concurrency.
10289 * Below function invokes TDLS teardown Functionality Since TDLS is
10290 * not Supported in case of concurrency i.e Once P2P session
10291 * is detected disable offchannel and teardown TDLS links
10292 */
10293 hddLog(LOG1,
10294 FL("Device mode = %d Interface type = %d"),
10295 pAdapter->device_mode, type);
10296 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10297 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010298
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010301 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 )
10303 {
10304 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010305 if (!pWextState)
10306 {
10307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10308 "%s: pWextState is null", __func__);
10309 return VOS_STATUS_E_FAILURE;
10310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 pRoamProfile = &pWextState->roamProfile;
10312 LastBSSType = pRoamProfile->BSSType;
10313
10314 switch (type)
10315 {
10316 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 hddLog(VOS_TRACE_LEVEL_INFO,
10319 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10320 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010321#ifdef WLAN_FEATURE_11AC
10322 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10323 {
10324 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10325 }
10326#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010327 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010328 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010329 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010330 //Check for sub-string p2p to confirm its a p2p interface
10331 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010332 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010333#ifdef FEATURE_WLAN_TDLS
10334 mutex_lock(&pHddCtx->tdls_lock);
10335 wlan_hdd_tdls_exit(pAdapter, TRUE);
10336 mutex_unlock(&pHddCtx->tdls_lock);
10337#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010338 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10339 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10340 }
10341 else
10342 {
10343 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010347
Jeff Johnson295189b2012-06-20 16:38:30 -070010348 case NL80211_IFTYPE_ADHOC:
10349 hddLog(VOS_TRACE_LEVEL_INFO,
10350 "%s: setting interface Type to ADHOC", __func__);
10351 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10352 pRoamProfile->phyMode =
10353 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010354 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010356 hdd_set_ibss_ops( pAdapter );
10357 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010358
10359 status = hdd_sta_id_hash_attach(pAdapter);
10360 if (VOS_STATUS_SUCCESS != status) {
10361 hddLog(VOS_TRACE_LEVEL_ERROR,
10362 FL("Failed to initialize hash for IBSS"));
10363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 break;
10365
10366 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 {
10369 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10370 "%s: setting interface Type to %s", __func__,
10371 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10372
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010373 //Cancel any remain on channel for GO mode
10374 if (NL80211_IFTYPE_P2P_GO == type)
10375 {
10376 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10377 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010378 if (NL80211_IFTYPE_AP == type)
10379 {
10380 /* As Loading WLAN Driver one interface being created for p2p device
10381 * address. This will take one HW STA and the max number of clients
10382 * that can connect to softAP will be reduced by one. so while changing
10383 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10384 * interface as it is not required in SoftAP mode.
10385 */
10386
10387 // Get P2P Adapter
10388 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10389
10390 if (pP2pAdapter)
10391 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010392 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010393 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010394 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10395 }
10396 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010397 //Disable IMPS & BMPS for SAP/GO
10398 if(VOS_STATUS_E_FAILURE ==
10399 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10400 {
10401 //Fail to Exit BMPS
10402 VOS_ASSERT(0);
10403 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010404
10405 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10406
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010407#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010408
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010409 /* A Mutex Lock is introduced while changing the mode to
10410 * protect the concurrent access for the Adapters by TDLS
10411 * module.
10412 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010413 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010414#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010416 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10419 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010420#ifdef FEATURE_WLAN_TDLS
10421 mutex_unlock(&pHddCtx->tdls_lock);
10422#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010423 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10424 (pConfig->apRandomBssidEnabled))
10425 {
10426 /* To meet Android requirements create a randomized
10427 MAC address of the form 02:1A:11:Fx:xx:xx */
10428 get_random_bytes(&ndev->dev_addr[3], 3);
10429 ndev->dev_addr[0] = 0x02;
10430 ndev->dev_addr[1] = 0x1A;
10431 ndev->dev_addr[2] = 0x11;
10432 ndev->dev_addr[3] |= 0xF0;
10433 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10434 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010435 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10436 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010437 }
10438
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 hdd_set_ap_ops( pAdapter->dev );
10440
Kiet Lam10841362013-11-01 11:36:50 +053010441 /* This is for only SAP mode where users can
10442 * control country through ini.
10443 * P2P GO follows station country code
10444 * acquired during the STA scanning. */
10445 if((NL80211_IFTYPE_AP == type) &&
10446 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10447 {
10448 int status = 0;
10449 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10450 "%s: setting country code from INI ", __func__);
10451 init_completion(&pAdapter->change_country_code);
10452 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10453 (void *)(tSmeChangeCountryCallback)
10454 wlan_hdd_change_country_code_cb,
10455 pConfig->apCntryCode, pAdapter,
10456 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010457 eSIR_FALSE,
10458 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010459 if (eHAL_STATUS_SUCCESS == status)
10460 {
10461 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010462 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010463 &pAdapter->change_country_code,
10464 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010465 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010466 {
10467 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010468 FL("SME Timed out while setting country code %ld"),
10469 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010470
10471 if (pHddCtx->isLogpInProgress)
10472 {
10473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10474 "%s: LOGP in Progress. Ignore!!!", __func__);
10475 return -EAGAIN;
10476 }
Kiet Lam10841362013-11-01 11:36:50 +053010477 }
10478 }
10479 else
10480 {
10481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010482 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010483 return -EINVAL;
10484 }
10485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 status = hdd_init_ap_mode(pAdapter);
10487 if(status != VOS_STATUS_SUCCESS)
10488 {
10489 hddLog(VOS_TRACE_LEVEL_FATAL,
10490 "%s: Error initializing the ap mode", __func__);
10491 return -EINVAL;
10492 }
10493 hdd_set_conparam(1);
10494
Nirav Shah7e3c8132015-06-22 23:51:42 +053010495 status = hdd_sta_id_hash_attach(pAdapter);
10496 if (VOS_STATUS_SUCCESS != status)
10497 {
10498 hddLog(VOS_TRACE_LEVEL_ERROR,
10499 FL("Failed to initialize hash for AP"));
10500 return -EINVAL;
10501 }
10502
Jeff Johnson295189b2012-06-20 16:38:30 -070010503 /*interface type changed update in wiphy structure*/
10504 if(wdev)
10505 {
10506 wdev->iftype = type;
10507 pHddCtx->change_iface = type;
10508 }
10509 else
10510 {
10511 hddLog(VOS_TRACE_LEVEL_ERROR,
10512 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10513 return -EINVAL;
10514 }
10515 goto done;
10516 }
10517
10518 default:
10519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10520 __func__);
10521 return -EOPNOTSUPP;
10522 }
10523 }
10524 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 )
10527 {
10528 switch(type)
10529 {
10530 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010533
10534 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010535#ifdef FEATURE_WLAN_TDLS
10536
10537 /* A Mutex Lock is introduced while changing the mode to
10538 * protect the concurrent access for the Adapters by TDLS
10539 * module.
10540 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010541 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010542#endif
c_hpothu002231a2015-02-05 14:58:51 +053010543 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010545 //Check for sub-string p2p to confirm its a p2p interface
10546 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010547 {
10548 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10549 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10550 }
10551 else
10552 {
10553 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 hdd_set_conparam(0);
10557 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10559 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010560#ifdef FEATURE_WLAN_TDLS
10561 mutex_unlock(&pHddCtx->tdls_lock);
10562#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010563 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 if( VOS_STATUS_SUCCESS != status )
10565 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010566 /* In case of JB, for P2P-GO, only change interface will be called,
10567 * This is the right place to enable back bmps_imps()
10568 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010569 if (pHddCtx->hdd_wlan_suspended)
10570 {
10571 hdd_set_pwrparams(pHddCtx);
10572 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010573 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 goto done;
10575 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10579 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 goto done;
10581 default:
10582 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10583 __func__);
10584 return -EOPNOTSUPP;
10585
10586 }
10587
10588 }
10589 else
10590 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010591 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10592 __func__, hdd_device_modetoString(pAdapter->device_mode),
10593 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 return -EOPNOTSUPP;
10595 }
10596
10597
10598 if(pRoamProfile)
10599 {
10600 if ( LastBSSType != pRoamProfile->BSSType )
10601 {
10602 /*interface type changed update in wiphy structure*/
10603 wdev->iftype = type;
10604
10605 /*the BSS mode changed, We need to issue disconnect
10606 if connected or in IBSS disconnect state*/
10607 if ( hdd_connGetConnectedBssType(
10608 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10609 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10610 {
10611 /*need to issue a disconnect to CSR.*/
10612 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10613 if( eHAL_STATUS_SUCCESS ==
10614 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10615 pAdapter->sessionId,
10616 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10617 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010618 ret = wait_for_completion_interruptible_timeout(
10619 &pAdapter->disconnect_comp_var,
10620 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10621 if (ret <= 0)
10622 {
10623 hddLog(VOS_TRACE_LEVEL_ERROR,
10624 FL("wait on disconnect_comp_var failed %ld"), ret);
10625 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 }
10627 }
10628 }
10629 }
10630
10631done:
10632 /*set bitmask based on updated value*/
10633 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010634
10635 /* Only STA mode support TM now
10636 * all other mode, TM feature should be disabled */
10637 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10638 (~VOS_STA & pHddCtx->concurrency_mode) )
10639 {
10640 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10641 }
10642
Jeff Johnson295189b2012-06-20 16:38:30 -070010643#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010644 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010645 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010646 {
10647 //we are ok to do AMP
10648 pHddCtx->isAmpAllowed = VOS_TRUE;
10649 }
10650#endif //WLAN_BTAMP_FEATURE
10651 EXIT();
10652 return 0;
10653}
10654
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010655/*
10656 * FUNCTION: wlan_hdd_cfg80211_change_iface
10657 * wrapper function to protect the actual implementation from SSR.
10658 */
10659int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10660 struct net_device *ndev,
10661 enum nl80211_iftype type,
10662 u32 *flags,
10663 struct vif_params *params
10664 )
10665{
10666 int ret;
10667
10668 vos_ssr_protect(__func__);
10669 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10670 vos_ssr_unprotect(__func__);
10671
10672 return ret;
10673}
10674
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010675#ifdef FEATURE_WLAN_TDLS
10676static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010677 struct net_device *dev,
10678#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10679 const u8 *mac,
10680#else
10681 u8 *mac,
10682#endif
10683 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010684{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010685 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010686 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010687 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010688 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010689 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010690 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010691
10692 ENTER();
10693
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010694 if (!dev) {
10695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10696 return -EINVAL;
10697 }
10698
10699 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10700 if (!pAdapter) {
10701 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10702 return -EINVAL;
10703 }
10704
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010705 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010706 {
10707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10708 "Invalid arguments");
10709 return -EINVAL;
10710 }
Hoonki Lee27511902013-03-14 18:19:06 -070010711
10712 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10713 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10714 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010716 "%s: TDLS mode is disabled OR not enabled in FW."
10717 MAC_ADDRESS_STR " Request declined.",
10718 __func__, MAC_ADDR_ARRAY(mac));
10719 return -ENOTSUPP;
10720 }
10721
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010722 if (pHddCtx->isLogpInProgress)
10723 {
10724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10725 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010726 wlan_hdd_tdls_set_link_status(pAdapter,
10727 mac,
10728 eTDLS_LINK_IDLE,
10729 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010730 return -EBUSY;
10731 }
10732
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010733 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010734 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010735
10736 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010738 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10739 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010740 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010741 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010742 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010743
10744 /* in add station, we accept existing valid staId if there is */
10745 if ((0 == update) &&
10746 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10747 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010748 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010750 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010751 " link_status %d. staId %d. add station ignored.",
10752 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010753 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010754 return 0;
10755 }
10756 /* in change station, we accept only when staId is valid */
10757 if ((1 == update) &&
10758 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
10759 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
10760 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010761 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010763 "%s: " MAC_ADDRESS_STR
10764 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010765 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
10766 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
10767 mutex_unlock(&pHddCtx->tdls_lock);
10768 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010769 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010770 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010771
10772 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053010773 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010774 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10776 "%s: " MAC_ADDRESS_STR
10777 " TDLS setup is ongoing. Request declined.",
10778 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070010779 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010780 }
10781
10782 /* first to check if we reached to maximum supported TDLS peer.
10783 TODO: for now, return -EPERM looks working fine,
10784 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010785 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10786 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010787 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10789 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010790 " TDLS Max peer already connected. Request declined."
10791 " Num of peers (%d), Max allowed (%d).",
10792 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
10793 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010794 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010795 }
10796 else
10797 {
10798 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010799 mutex_lock(&pHddCtx->tdls_lock);
10800 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010801 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010802 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010803 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10805 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
10806 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010807 return -EPERM;
10808 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010809 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010810 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010811 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053010812 wlan_hdd_tdls_set_link_status(pAdapter,
10813 mac,
10814 eTDLS_LINK_CONNECTING,
10815 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010816
Jeff Johnsond75fe012013-04-06 10:53:06 -070010817 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010818 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010819 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010821 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010822 if(StaParams->htcap_present)
10823 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010825 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010827 "ht_capa->extended_capabilities: %0x",
10828 StaParams->HTCap.extendedHtCapInfo);
10829 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010831 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010833 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010834 if(StaParams->vhtcap_present)
10835 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010837 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
10838 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
10839 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
10840 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010841 {
10842 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010844 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010846 "[%d]: %x ", i, StaParams->supported_rates[i]);
10847 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070010848 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010849 else if ((1 == update) && (NULL == StaParams))
10850 {
10851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10852 "%s : update is true, but staParams is NULL. Error!", __func__);
10853 return -EPERM;
10854 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010855
10856 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
10857
10858 if (!update)
10859 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010860 /*Before adding sta make sure that device exited from BMPS*/
10861 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10862 {
10863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10864 "%s: Adding tdls peer sta. Disable BMPS", __func__);
10865 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10866 if (status != VOS_STATUS_SUCCESS) {
10867 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
10868 }
10869 }
10870
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010871 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010872 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010873 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010874 hddLog(VOS_TRACE_LEVEL_ERROR,
10875 FL("Failed to add TDLS peer STA. Enable Bmps"));
10876 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010877 return -EPERM;
10878 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010879 }
10880 else
10881 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010882 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010883 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010884 if (ret != eHAL_STATUS_SUCCESS) {
10885 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
10886 return -EPERM;
10887 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010888 }
10889
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010890 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010891 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
10892
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053010893 mutex_lock(&pHddCtx->tdls_lock);
10894 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
10895
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010896 if ((pTdlsPeer != NULL) &&
10897 (pTdlsPeer->link_status == eTDLS_LINK_TEARING))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010898 {
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010899 hddLog(VOS_TRACE_LEVEL_ERROR,
10900 FL("peer link status %u"), pTdlsPeer->link_status);
10901 mutex_unlock(&pHddCtx->tdls_lock);
10902 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010903 }
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +053010904 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010905
Masti, Narayanraddi07262462016-01-19 12:40:06 +053010906 if (ret <= 0)
10907 {
10908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10909 "%s: timeout waiting for tdls add station indication %ld",
10910 __func__, ret);
10911 goto error;
10912 }
10913
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010914 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
10915 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010917 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010918 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010919 }
10920
10921 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010922
10923error:
Atul Mittal115287b2014-07-08 13:26:33 +053010924 wlan_hdd_tdls_set_link_status(pAdapter,
10925 mac,
10926 eTDLS_LINK_IDLE,
10927 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010928 return -EPERM;
10929
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010930}
10931#endif
10932
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010933static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010935#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10936 const u8 *mac,
10937#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010939#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 struct station_parameters *params)
10941{
10942 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010943 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010944 hdd_context_t *pHddCtx;
10945 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010947 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010948#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010949 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010950 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010951 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053010952 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010953#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010954
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010955 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010956
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010957 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010958 if ((NULL == pAdapter))
10959 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053010961 "invalid adapter ");
10962 return -EINVAL;
10963 }
10964
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010965 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10966 TRACE_CODE_HDD_CHANGE_STATION,
10967 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053010968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010969
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010970 ret = wlan_hdd_validate_context(pHddCtx);
10971 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053010972 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010973 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010974 }
10975
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010976 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10977
10978 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010979 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10981 "invalid HDD station context");
10982 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
10985
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010986 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10987 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010989 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070010990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010991 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 WLANTL_STA_AUTHENTICATED);
10993
Gopichand Nakkala29149562013-05-10 21:43:41 +053010994 if (status != VOS_STATUS_SUCCESS)
10995 {
10996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10997 "%s: Not able to change TL state to AUTHENTICATED", __func__);
10998 return -EINVAL;
10999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 }
11001 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070011002 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
11003 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011004#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011005 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11006 StaParams.capability = params->capability;
11007 StaParams.uapsd_queues = params->uapsd_queues;
11008 StaParams.max_sp = params->max_sp;
11009
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011010 /* Convert (first channel , number of channels) tuple to
11011 * the total list of channels. This goes with the assumption
11012 * that if the first channel is < 14, then the next channels
11013 * are an incremental of 1 else an incremental of 4 till the number
11014 * of channels.
11015 */
11016 if (0 != params->supported_channels_len) {
11017 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
11018 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
11019 {
11020 int wifi_chan_index;
11021 StaParams.supported_channels[j] = params->supported_channels[i];
11022 wifi_chan_index =
11023 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
11024 no_of_channels = params->supported_channels[i+1];
11025 for(k=1; k <= no_of_channels; k++)
11026 {
11027 StaParams.supported_channels[j+1] =
11028 StaParams.supported_channels[j] + wifi_chan_index;
11029 j+=1;
11030 }
11031 }
11032 StaParams.supported_channels_len = j;
11033 }
11034 vos_mem_copy(StaParams.supported_oper_classes,
11035 params->supported_oper_classes,
11036 params->supported_oper_classes_len);
11037 StaParams.supported_oper_classes_len =
11038 params->supported_oper_classes_len;
11039
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011040 if (0 != params->ext_capab_len)
11041 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
11042 sizeof(StaParams.extn_capability));
11043
11044 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011045 {
11046 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011047 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011048 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011049
11050 StaParams.supported_rates_len = params->supported_rates_len;
11051
11052 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11053 * The supported_rates array , for all the structures propogating till Add Sta
11054 * to the firmware has to be modified , if the supplicant (ieee80211) is
11055 * modified to send more rates.
11056 */
11057
11058 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11059 */
11060 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11061 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11062
11063 if (0 != StaParams.supported_rates_len) {
11064 int i = 0;
11065 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11066 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011068 "Supported Rates with Length %d", StaParams.supported_rates_len);
11069 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011071 "[%d]: %0x", i, StaParams.supported_rates[i]);
11072 }
11073
11074 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011075 {
11076 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011077 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011078 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011079
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011080 if (0 != params->ext_capab_len ) {
11081 /*Define A Macro : TODO Sunil*/
11082 if ((1<<4) & StaParams.extn_capability[3]) {
11083 isBufSta = 1;
11084 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011085 /* TDLS Channel Switching Support */
11086 if ((1<<6) & StaParams.extn_capability[3]) {
11087 isOffChannelSupported = 1;
11088 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011089 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011090
11091 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
11092 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))) {
11093
11094 /* TDLS Peer is WME/QoS capable */
11095 isQosWmmSta = TRUE;
11096 }
11097
11098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11099 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11100 __func__, isQosWmmSta, StaParams.htcap_present);
11101
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011102 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11103 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011104 isOffChannelSupported,
11105 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011106
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011107 if (VOS_STATUS_SUCCESS != status) {
11108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11109 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11110 return -EINVAL;
11111 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011112 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11113
11114 if (VOS_STATUS_SUCCESS != status) {
11115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11116 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11117 return -EINVAL;
11118 }
11119 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011120#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011121 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011122 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 return status;
11124}
11125
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011126#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11127static int wlan_hdd_change_station(struct wiphy *wiphy,
11128 struct net_device *dev,
11129 const u8 *mac,
11130 struct station_parameters *params)
11131#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011132static int wlan_hdd_change_station(struct wiphy *wiphy,
11133 struct net_device *dev,
11134 u8 *mac,
11135 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011136#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011137{
11138 int ret;
11139
11140 vos_ssr_protect(__func__);
11141 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11142 vos_ssr_unprotect(__func__);
11143
11144 return ret;
11145}
11146
Jeff Johnson295189b2012-06-20 16:38:30 -070011147/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011148 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 * This function is used to initialize the key information
11150 */
11151#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011152static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 struct net_device *ndev,
11154 u8 key_index, bool pairwise,
11155 const u8 *mac_addr,
11156 struct key_params *params
11157 )
11158#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011159static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011160 struct net_device *ndev,
11161 u8 key_index, const u8 *mac_addr,
11162 struct key_params *params
11163 )
11164#endif
11165{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011166 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011167 tCsrRoamSetKey setKey;
11168 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011169 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011170 v_U32_t roamId= 0xFF;
11171 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 hdd_hostapd_state_t *pHostapdState;
11173 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011174 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011175 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011176
11177 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011178
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011179 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11180 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11181 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11183 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011184 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011185 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011186 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011187 }
11188
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011189 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11190 __func__, hdd_device_modetoString(pAdapter->device_mode),
11191 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011192
11193 if (CSR_MAX_NUM_KEY <= key_index)
11194 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 key_index);
11197
11198 return -EINVAL;
11199 }
11200
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011201 if (CSR_MAX_KEY_LEN < params->key_len)
11202 {
11203 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11204 params->key_len);
11205
11206 return -EINVAL;
11207 }
11208
11209 hddLog(VOS_TRACE_LEVEL_INFO,
11210 "%s: called with key index = %d & key length %d",
11211 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011212
11213 /*extract key idx, key len and key*/
11214 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11215 setKey.keyId = key_index;
11216 setKey.keyLength = params->key_len;
11217 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11218
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011219 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011220 {
11221 case WLAN_CIPHER_SUITE_WEP40:
11222 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11223 break;
11224
11225 case WLAN_CIPHER_SUITE_WEP104:
11226 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11227 break;
11228
11229 case WLAN_CIPHER_SUITE_TKIP:
11230 {
11231 u8 *pKey = &setKey.Key[0];
11232 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11233
11234 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11235
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011236 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011237
11238 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011239 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 |--------------|----------|----------|
11241 <---16bytes---><--8bytes--><--8bytes-->
11242
11243 */
11244 /*Sme expects the 32 bytes key to be in the below order
11245
11246 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011247 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011248 |--------------|----------|----------|
11249 <---16bytes---><--8bytes--><--8bytes-->
11250 */
11251 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011252 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011253
11254 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011255 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011256
11257 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011258 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011259
11260
11261 break;
11262 }
11263
11264 case WLAN_CIPHER_SUITE_CCMP:
11265 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11266 break;
11267
11268#ifdef FEATURE_WLAN_WAPI
11269 case WLAN_CIPHER_SUITE_SMS4:
11270 {
11271 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11272 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11273 params->key, params->key_len);
11274 return 0;
11275 }
11276#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011277
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011278#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 case WLAN_CIPHER_SUITE_KRK:
11280 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11281 break;
11282#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011283
11284#ifdef WLAN_FEATURE_11W
11285 case WLAN_CIPHER_SUITE_AES_CMAC:
11286 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011287 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011288#endif
11289
Jeff Johnson295189b2012-06-20 16:38:30 -070011290 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011291 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011293 status = -EOPNOTSUPP;
11294 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 }
11296
11297 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11298 __func__, setKey.encType);
11299
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011300 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11302 (!pairwise)
11303#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011304 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011305#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011306 )
11307 {
11308 /* set group key*/
11309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11310 "%s- %d: setting Broadcast key",
11311 __func__, __LINE__);
11312 setKey.keyDirection = eSIR_RX_ONLY;
11313 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11314 }
11315 else
11316 {
11317 /* set pairwise key*/
11318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11319 "%s- %d: setting pairwise key",
11320 __func__, __LINE__);
11321 setKey.keyDirection = eSIR_TX_RX;
11322 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11323 }
11324 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11325 {
11326 setKey.keyDirection = eSIR_TX_RX;
11327 /*Set the group key*/
11328 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11329 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011330
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011331 if ( 0 != status )
11332 {
11333 hddLog(VOS_TRACE_LEVEL_ERROR,
11334 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011335 status = -EINVAL;
11336 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011337 }
11338 /*Save the keys here and call sme_RoamSetKey for setting
11339 the PTK after peer joins the IBSS network*/
11340 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11341 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011342 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011343 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011344 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11345 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11346 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011348 if( pHostapdState->bssState == BSS_START )
11349 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011350 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11351 vos_status = wlan_hdd_check_ula_done(pAdapter);
11352
11353 if ( vos_status != VOS_STATUS_SUCCESS )
11354 {
11355 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11356 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11357 __LINE__, vos_status );
11358
11359 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11360
11361 status = -EINVAL;
11362 goto end;
11363 }
11364
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11366
11367 if ( status != eHAL_STATUS_SUCCESS )
11368 {
11369 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11370 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11371 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011372 status = -EINVAL;
11373 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 }
11375 }
11376
11377 /* Saving WEP keys */
11378 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11379 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11380 {
11381 //Save the wep key in ap context. Issue setkey after the BSS is started.
11382 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11383 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11384 }
11385 else
11386 {
11387 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011388 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11390 }
11391 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011392 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11393 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 {
11395 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11396 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11397
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011398#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11399 if (!pairwise)
11400#else
11401 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11402#endif
11403 {
11404 /* set group key*/
11405 if (pHddStaCtx->roam_info.deferKeyComplete)
11406 {
11407 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11408 "%s- %d: Perform Set key Complete",
11409 __func__, __LINE__);
11410 hdd_PerformRoamSetKeyComplete(pAdapter);
11411 }
11412 }
11413
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11415
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011416 pWextState->roamProfile.Keys.defaultIndex = key_index;
11417
11418
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011419 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 params->key, params->key_len);
11421
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011422
Jeff Johnson295189b2012-06-20 16:38:30 -070011423 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11424
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011425 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011427 __func__, setKey.peerMac[0], setKey.peerMac[1],
11428 setKey.peerMac[2], setKey.peerMac[3],
11429 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 setKey.keyDirection);
11431
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011432 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011433
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011434 if ( vos_status != VOS_STATUS_SUCCESS )
11435 {
11436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11438 __LINE__, vos_status );
11439
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011440 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011441
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011442 status = -EINVAL;
11443 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011444
11445 }
11446
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011447#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011448 /* The supplicant may attempt to set the PTK once pre-authentication
11449 is done. Save the key in the UMAC and include it in the ADD BSS
11450 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011451 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011452 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011453 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011454 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11455 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011456 status = 0;
11457 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011458 }
11459 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11460 {
11461 hddLog(VOS_TRACE_LEVEL_ERROR,
11462 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011463 status = -EINVAL;
11464 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011465 }
11466#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011467
11468 /* issue set key request to SME*/
11469 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11470 pAdapter->sessionId, &setKey, &roamId );
11471
11472 if ( 0 != status )
11473 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011474 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11476 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011477 status = -EINVAL;
11478 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 }
11480
11481
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011482 /* in case of IBSS as there was no information available about WEP keys during
11483 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011485 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11486 !( ( IW_AUTH_KEY_MGMT_802_1X
11487 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11489 )
11490 &&
11491 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11492 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11493 )
11494 )
11495 {
11496 setKey.keyDirection = eSIR_RX_ONLY;
11497 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11498
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011499 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011500 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011501 __func__, setKey.peerMac[0], setKey.peerMac[1],
11502 setKey.peerMac[2], setKey.peerMac[3],
11503 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 setKey.keyDirection);
11505
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011506 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 pAdapter->sessionId, &setKey, &roamId );
11508
11509 if ( 0 != status )
11510 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011511 hddLog(VOS_TRACE_LEVEL_ERROR,
11512 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011513 __func__, status);
11514 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011515 status = -EINVAL;
11516 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 }
11518 }
11519 }
11520
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011521end:
11522 /* Need to clear any trace of key value in the memory.
11523 * Thus zero out the memory even though it is local
11524 * variable.
11525 */
11526 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011527 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011528 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011529}
11530
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011531#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11532static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11533 struct net_device *ndev,
11534 u8 key_index, bool pairwise,
11535 const u8 *mac_addr,
11536 struct key_params *params
11537 )
11538#else
11539static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11540 struct net_device *ndev,
11541 u8 key_index, const u8 *mac_addr,
11542 struct key_params *params
11543 )
11544#endif
11545{
11546 int ret;
11547 vos_ssr_protect(__func__);
11548#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11549 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11550 mac_addr, params);
11551#else
11552 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11553 params);
11554#endif
11555 vos_ssr_unprotect(__func__);
11556
11557 return ret;
11558}
11559
Jeff Johnson295189b2012-06-20 16:38:30 -070011560/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011561 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 * This function is used to get the key information
11563 */
11564#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011565static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011566 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011568 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 const u8 *mac_addr, void *cookie,
11570 void (*callback)(void *cookie, struct key_params*)
11571 )
11572#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011573static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011574 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 struct net_device *ndev,
11576 u8 key_index, const u8 *mac_addr, void *cookie,
11577 void (*callback)(void *cookie, struct key_params*)
11578 )
11579#endif
11580{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011582 hdd_wext_state_t *pWextState = NULL;
11583 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011585 hdd_context_t *pHddCtx;
11586 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011587
11588 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011589
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011590 if (NULL == pAdapter)
11591 {
11592 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11593 "%s: HDD adapter is Null", __func__);
11594 return -ENODEV;
11595 }
11596
11597 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11598 ret = wlan_hdd_validate_context(pHddCtx);
11599 if (0 != ret)
11600 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011601 return ret;
11602 }
11603
11604 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11605 pRoamProfile = &(pWextState->roamProfile);
11606
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011607 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11608 __func__, hdd_device_modetoString(pAdapter->device_mode),
11609 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011610
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 memset(&params, 0, sizeof(params));
11612
11613 if (CSR_MAX_NUM_KEY <= key_index)
11614 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011615 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011618
11619 switch(pRoamProfile->EncryptionType.encryptionType[0])
11620 {
11621 case eCSR_ENCRYPT_TYPE_NONE:
11622 params.cipher = IW_AUTH_CIPHER_NONE;
11623 break;
11624
11625 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11626 case eCSR_ENCRYPT_TYPE_WEP40:
11627 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11628 break;
11629
11630 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11631 case eCSR_ENCRYPT_TYPE_WEP104:
11632 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11633 break;
11634
11635 case eCSR_ENCRYPT_TYPE_TKIP:
11636 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11637 break;
11638
11639 case eCSR_ENCRYPT_TYPE_AES:
11640 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11641 break;
11642
11643 default:
11644 params.cipher = IW_AUTH_CIPHER_NONE;
11645 break;
11646 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011647
c_hpothuaaf19692014-05-17 17:01:48 +053011648 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11649 TRACE_CODE_HDD_CFG80211_GET_KEY,
11650 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011651
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11653 params.seq_len = 0;
11654 params.seq = NULL;
11655 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11656 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011657 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 return 0;
11659}
11660
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011661#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11662static int wlan_hdd_cfg80211_get_key(
11663 struct wiphy *wiphy,
11664 struct net_device *ndev,
11665 u8 key_index, bool pairwise,
11666 const u8 *mac_addr, void *cookie,
11667 void (*callback)(void *cookie, struct key_params*)
11668 )
11669#else
11670static int wlan_hdd_cfg80211_get_key(
11671 struct wiphy *wiphy,
11672 struct net_device *ndev,
11673 u8 key_index, const u8 *mac_addr, void *cookie,
11674 void (*callback)(void *cookie, struct key_params*)
11675 )
11676#endif
11677{
11678 int ret;
11679
11680 vos_ssr_protect(__func__);
11681#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11682 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11683 mac_addr, cookie, callback);
11684#else
11685 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11686 callback);
11687#endif
11688 vos_ssr_unprotect(__func__);
11689
11690 return ret;
11691}
11692
Jeff Johnson295189b2012-06-20 16:38:30 -070011693/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011694 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 * This function is used to delete the key information
11696 */
11697#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011698static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011700 u8 key_index,
11701 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 const u8 *mac_addr
11703 )
11704#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011705static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 struct net_device *ndev,
11707 u8 key_index,
11708 const u8 *mac_addr
11709 )
11710#endif
11711{
11712 int status = 0;
11713
11714 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011715 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 //it is observed that this is invalidating peer
11717 //key index whenever re-key is done. This is affecting data link.
11718 //It should be ok to ignore del_key.
11719#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11721 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11723 tCsrRoamSetKey setKey;
11724 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011725
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 ENTER();
11727
11728 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11729 __func__,pAdapter->device_mode);
11730
11731 if (CSR_MAX_NUM_KEY <= key_index)
11732 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011733 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 key_index);
11735
11736 return -EINVAL;
11737 }
11738
11739 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11740 setKey.keyId = key_index;
11741
11742 if (mac_addr)
11743 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11744 else
11745 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11746
11747 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11748
11749 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011751 )
11752 {
11753
11754 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070011755 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11756 if( pHostapdState->bssState == BSS_START)
11757 {
11758 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011759
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 if ( status != eHAL_STATUS_SUCCESS )
11761 {
11762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11763 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11764 __LINE__, status );
11765 }
11766 }
11767 }
11768 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011769 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 )
11771 {
11772 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11773
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011774 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11775
11776 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011778 __func__, setKey.peerMac[0], setKey.peerMac[1],
11779 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011781 if(pAdapter->sessionCtx.station.conn_info.connState ==
11782 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011784 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011785 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011786
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 if ( 0 != status )
11788 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011789 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 "%s: sme_RoamSetKey failure, returned %d",
11791 __func__, status);
11792 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11793 return -EINVAL;
11794 }
11795 }
11796 }
11797#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011798 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 return status;
11800}
11801
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011802#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11803static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11804 struct net_device *ndev,
11805 u8 key_index,
11806 bool pairwise,
11807 const u8 *mac_addr
11808 )
11809#else
11810static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11811 struct net_device *ndev,
11812 u8 key_index,
11813 const u8 *mac_addr
11814 )
11815#endif
11816{
11817 int ret;
11818
11819 vos_ssr_protect(__func__);
11820#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11821 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
11822 mac_addr);
11823#else
11824 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
11825#endif
11826 vos_ssr_unprotect(__func__);
11827
11828 return ret;
11829}
11830
Jeff Johnson295189b2012-06-20 16:38:30 -070011831/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011832 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 * This function is used to set the default tx key index
11834 */
11835#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011836static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 struct net_device *ndev,
11838 u8 key_index,
11839 bool unicast, bool multicast)
11840#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011841static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 struct net_device *ndev,
11843 u8 key_index)
11844#endif
11845{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011846 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011847 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011848 hdd_wext_state_t *pWextState;
11849 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011850 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011851
11852 ENTER();
11853
Gopichand Nakkala29149562013-05-10 21:43:41 +053011854 if ((NULL == pAdapter))
11855 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011857 "invalid adapter");
11858 return -EINVAL;
11859 }
11860
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011861 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11862 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
11863 pAdapter->sessionId, key_index));
11864
Gopichand Nakkala29149562013-05-10 21:43:41 +053011865 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11866 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11867
11868 if ((NULL == pWextState) || (NULL == pHddStaCtx))
11869 {
11870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11871 "invalid Wext state or HDD context");
11872 return -EINVAL;
11873 }
11874
Arif Hussain6d2a3322013-11-17 19:50:10 -080011875 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011876 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011877
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 if (CSR_MAX_NUM_KEY <= key_index)
11879 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011880 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011881 key_index);
11882
11883 return -EINVAL;
11884 }
11885
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011886 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11887 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011888 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011889 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011890 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011891 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011892
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011894 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011895 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011896 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011897 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080011898 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011899 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080011900 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070011901 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011902 {
11903 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011905
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 tCsrRoamSetKey setKey;
11907 v_U32_t roamId= 0xFF;
11908 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011909
11910 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011912
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 Keys->defaultIndex = (u8)key_index;
11914 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11915 setKey.keyId = key_index;
11916 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011917
11918 vos_mem_copy(&setKey.Key[0],
11919 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011921
Gopichand Nakkala29149562013-05-10 21:43:41 +053011922 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011923
11924 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 &pHddStaCtx->conn_info.bssId[0],
11926 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011927
Gopichand Nakkala29149562013-05-10 21:43:41 +053011928 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
11929 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
11930 eCSR_ENCRYPT_TYPE_WEP104)
11931 {
11932 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
11933 even though ap is configured for WEP-40 encryption. In this canse the key length
11934 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
11935 type(104) and switching encryption type to 40*/
11936 pWextState->roamProfile.EncryptionType.encryptionType[0] =
11937 eCSR_ENCRYPT_TYPE_WEP40;
11938 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
11939 eCSR_ENCRYPT_TYPE_WEP40;
11940 }
11941
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011942 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011944
Jeff Johnson295189b2012-06-20 16:38:30 -070011945 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011946 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011948
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 if ( 0 != status )
11950 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011951 hddLog(VOS_TRACE_LEVEL_ERROR,
11952 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 status);
11954 return -EINVAL;
11955 }
11956 }
11957 }
11958
11959 /* In SoftAp mode setting key direction for default mode */
11960 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
11961 {
11962 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
11963 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
11964 (eCSR_ENCRYPT_TYPE_AES !=
11965 pWextState->roamProfile.EncryptionType.encryptionType[0])
11966 )
11967 {
11968 /* Saving key direction for default key index to TX default */
11969 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11970 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
11971 }
11972 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011973 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 return status;
11975}
11976
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011977#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11978static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11979 struct net_device *ndev,
11980 u8 key_index,
11981 bool unicast, bool multicast)
11982#else
11983static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11984 struct net_device *ndev,
11985 u8 key_index)
11986#endif
11987{
11988 int ret;
11989 vos_ssr_protect(__func__);
11990#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11991 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
11992 multicast);
11993#else
11994 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
11995#endif
11996 vos_ssr_unprotect(__func__);
11997
11998 return ret;
11999}
12000
Jeff Johnson295189b2012-06-20 16:38:30 -070012001/*
12002 * FUNCTION: wlan_hdd_cfg80211_inform_bss
12003 * This function is used to inform the BSS details to nl80211 interface.
12004 */
12005static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
12006 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
12007{
12008 struct net_device *dev = pAdapter->dev;
12009 struct wireless_dev *wdev = dev->ieee80211_ptr;
12010 struct wiphy *wiphy = wdev->wiphy;
12011 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
12012 int chan_no;
12013 int ie_length;
12014 const char *ie;
12015 unsigned int freq;
12016 struct ieee80211_channel *chan;
12017 int rssi = 0;
12018 struct cfg80211_bss *bss = NULL;
12019
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 if( NULL == pBssDesc )
12021 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012022 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012023 return bss;
12024 }
12025
12026 chan_no = pBssDesc->channelId;
12027 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
12028 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
12029
12030 if( NULL == ie )
12031 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012032 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 return bss;
12034 }
12035
12036#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
12037 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
12038 {
12039 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12040 }
12041 else
12042 {
12043 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12044 }
12045#else
12046 freq = ieee80211_channel_to_frequency(chan_no);
12047#endif
12048
12049 chan = __ieee80211_get_channel(wiphy, freq);
12050
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012051 if (!chan) {
12052 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12053 return NULL;
12054 }
12055
Abhishek Singhaee43942014-06-16 18:55:47 +053012056 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012057
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012058 return cfg80211_inform_bss(wiphy, chan,
12059#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12060 CFG80211_BSS_FTYPE_UNKNOWN,
12061#endif
12062 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012063 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 pBssDesc->capabilityInfo,
12065 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012066 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012067}
12068
Abhishek Singh72c2f4e2016-07-22 11:25:43 +053012069/*
12070 * wlan_hdd_cfg80211_update_bss_list :to inform nl80211
12071 * interface that BSS might have been lost.
12072 * @pAdapter: adaptor
12073 * @bssid: bssid which might have been lost
12074 *
12075 * Return: bss which is unlinked from kernel cache
12076 */
12077struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list(
12078 hdd_adapter_t *pAdapter, tSirMacAddr bssid)
12079{
12080 struct net_device *dev = pAdapter->dev;
12081 struct wireless_dev *wdev = dev->ieee80211_ptr;
12082 struct wiphy *wiphy = wdev->wiphy;
12083 struct cfg80211_bss *bss = NULL;
12084
12085 bss = cfg80211_get_bss(wiphy, NULL, bssid,
12086 NULL,
12087 0,
12088#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS) \
12089 && !defined(IEEE80211_PRIVACY)
12090 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
12091#else
12092 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
12093#endif
12094 if (bss == NULL) {
12095 hddLog(LOGE, FL("BSS not present"));
12096 } else {
12097 hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID "
12098 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid));
12099 cfg80211_unlink_bss(wiphy, bss);
12100 }
12101 return bss;
12102}
Jeff Johnson295189b2012-06-20 16:38:30 -070012103
12104
12105/*
12106 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12107 * This function is used to inform the BSS details to nl80211 interface.
12108 */
12109struct cfg80211_bss*
12110wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12111 tSirBssDescription *bss_desc
12112 )
12113{
12114 /*
12115 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12116 already exists in bss data base of cfg80211 for that particular BSS ID.
12117 Using cfg80211_inform_bss_frame to update the bss entry instead of
12118 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12119 now there is no possibility to get the mgmt(probe response) frame from PE,
12120 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12121 cfg80211_inform_bss_frame.
12122 */
12123 struct net_device *dev = pAdapter->dev;
12124 struct wireless_dev *wdev = dev->ieee80211_ptr;
12125 struct wiphy *wiphy = wdev->wiphy;
12126 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012127#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12128 qcom_ie_age *qie_age = NULL;
12129 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12130#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012132#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 const char *ie =
12134 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12135 unsigned int freq;
12136 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012137 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 struct cfg80211_bss *bss_status = NULL;
12139 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12140 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012141 hdd_context_t *pHddCtx;
12142 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012143#ifdef WLAN_OPEN_SOURCE
12144 struct timespec ts;
12145#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012147
Wilson Yangf80a0542013-10-07 13:02:37 -070012148 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12149 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012150 if (0 != status)
12151 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012152 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012153 }
12154
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012155 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012156 if (!mgmt)
12157 {
12158 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12159 "%s: memory allocation failed ", __func__);
12160 return NULL;
12161 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012162
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012164
12165#ifdef WLAN_OPEN_SOURCE
12166 /* Android does not want the timestamp from the frame.
12167 Instead it wants a monotonic increasing value */
12168 get_monotonic_boottime(&ts);
12169 mgmt->u.probe_resp.timestamp =
12170 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12171#else
12172 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12174 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012175
12176#endif
12177
Jeff Johnson295189b2012-06-20 16:38:30 -070012178 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12179 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012180
12181#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12182 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12183 /* Assuming this is the last IE, copy at the end */
12184 ie_length -=sizeof(qcom_ie_age);
12185 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12186 qie_age->element_id = QCOM_VENDOR_IE_ID;
12187 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12188 qie_age->oui_1 = QCOM_OUI1;
12189 qie_age->oui_2 = QCOM_OUI2;
12190 qie_age->oui_3 = QCOM_OUI3;
12191 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
Deepthi Gowri4480a3f2016-05-18 19:30:17 +053012192 qie_age->age = vos_timer_get_system_time() - bss_desc->nReceivedTime;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012193#endif
12194
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012196 if (bss_desc->fProbeRsp)
12197 {
12198 mgmt->frame_control |=
12199 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12200 }
12201 else
12202 {
12203 mgmt->frame_control |=
12204 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012206
12207#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012208 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12210 {
12211 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12212 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012213 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12215
12216 {
12217 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12218 }
12219 else
12220 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012221 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12222 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 kfree(mgmt);
12224 return NULL;
12225 }
12226#else
12227 freq = ieee80211_channel_to_frequency(chan_no);
12228#endif
12229 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012230 /*when the band is changed on the fly using the GUI, three things are done
12231 * 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)
12232 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12233 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12234 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12235 * and discards the channels correponding to previous band and calls back with zero bss results.
12236 * 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
12237 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12238 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12239 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12240 * So drop the bss and continue to next bss.
12241 */
12242 if(chan == NULL)
12243 {
Deepthi Gowri306657b2016-04-28 17:10:41 +053012244 hddLog(VOS_TRACE_LEVEL_ERROR,
12245 FL("chan pointer is NULL, chan_no: %d freq: %d"),
12246 chan_no, freq);
Chilam Ngc4244af2013-04-01 15:37:32 -070012247 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012248 return NULL;
12249 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012250 /*To keep the rssi icon of the connected AP in the scan window
12251 *and the rssi icon of the wireless networks in sync
12252 * */
12253 if (( eConnectionState_Associated ==
12254 pAdapter->sessionCtx.station.conn_info.connState ) &&
12255 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12256 pAdapter->sessionCtx.station.conn_info.bssId,
12257 WNI_CFG_BSSID_LEN)) &&
12258 (pHddCtx->hdd_wlan_suspended == FALSE))
12259 {
12260 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12261 rssi = (pAdapter->rssi * 100);
12262 }
12263 else
12264 {
12265 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012267
Nirav Shah20ac06f2013-12-12 18:14:06 +053012268 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012269 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12270 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012271
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12273 frame_len, rssi, GFP_KERNEL);
12274 kfree(mgmt);
12275 return bss_status;
12276}
12277
12278/*
12279 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12280 * This function is used to update the BSS data base of CFG8011
12281 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012282struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 tCsrRoamInfo *pRoamInfo
12284 )
12285{
12286 tCsrRoamConnectedProfile roamProfile;
12287 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12288 struct cfg80211_bss *bss = NULL;
12289
12290 ENTER();
12291
12292 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12293 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12294
12295 if (NULL != roamProfile.pBssDesc)
12296 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012297 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12298 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012299
12300 if (NULL == bss)
12301 {
12302 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12303 __func__);
12304 }
12305
12306 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12307 }
12308 else
12309 {
12310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12311 __func__);
12312 }
12313 return bss;
12314}
12315
12316/*
12317 * FUNCTION: wlan_hdd_cfg80211_update_bss
12318 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012319static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12320 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012321 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012322{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012323 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 tCsrScanResultInfo *pScanResult;
12325 eHalStatus status = 0;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012326 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 tScanResultHandle pResult;
12328 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012329 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012330 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012332
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012333 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12334 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12335 NO_SESSION, pAdapter->sessionId));
12336
Wilson Yangf80a0542013-10-07 13:02:37 -070012337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012338 ret = wlan_hdd_validate_context(pHddCtx);
12339 if (0 != ret)
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 {
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012341 return ret;
Wilson Yangf80a0542013-10-07 13:02:37 -070012342 }
12343
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012344 if (pAdapter->request != NULL)
12345 {
12346 if ((pAdapter->request->n_ssids == 1)
12347 && (pAdapter->request->ssids != NULL)
12348 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12349 is_p2p_scan = true;
12350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012351 /*
12352 * start getting scan results and populate cgf80211 BSS database
12353 */
12354 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12355
12356 /* no scan results */
12357 if (NULL == pResult)
12358 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012359 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12360 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012361 wlan_hdd_get_frame_logs(pAdapter,
12362 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 return status;
12364 }
12365
12366 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12367
12368 while (pScanResult)
12369 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012370 /*
12371 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12372 * entry already exists in bss data base of cfg80211 for that
12373 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12374 * bss entry instead of cfg80211_inform_bss, But this call expects
12375 * mgmt packet as input. As of now there is no possibility to get
12376 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 * ieee80211_mgmt(probe response) and passing to c
12378 * fg80211_inform_bss_frame.
12379 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012380 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12381 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12382 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012383 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12384 continue; //Skip the non p2p bss entries
12385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12387 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012388
Jeff Johnson295189b2012-06-20 16:38:30 -070012389
12390 if (NULL == bss_status)
12391 {
12392 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012393 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 }
12395 else
12396 {
Yue Maf49ba872013-08-19 12:04:25 -070012397 cfg80211_put_bss(
12398#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12399 wiphy,
12400#endif
12401 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 }
12403
12404 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12405 }
12406
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012407 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012408 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012409 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012410}
12411
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012412void
12413hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12414{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012415 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012416 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012417} /****** end hddPrintMacAddr() ******/
12418
12419void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012420hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012421{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012422 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012423 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012424 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12425 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12426 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012427} /****** end hddPrintPmkId() ******/
12428
12429//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12430//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12431
12432//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12433//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12434
12435#define dump_bssid(bssid) \
12436 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012437 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12438 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012439 }
12440
12441#define dump_pmkid(pMac, pmkid) \
12442 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012443 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12444 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012445 }
12446
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012447#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012448/*
12449 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12450 * This function is used to notify the supplicant of a new PMKSA candidate.
12451 */
12452int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012453 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012454 int index, bool preauth )
12455{
Jeff Johnsone7245742012-09-05 17:12:55 -070012456#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012457 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012458 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012459
12460 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012461 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012462
12463 if( NULL == pRoamInfo )
12464 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012465 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012466 return -EINVAL;
12467 }
12468
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012469 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12470 {
12471 dump_bssid(pRoamInfo->bssid);
12472 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012473 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012474 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012475#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012476 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012477}
12478#endif //FEATURE_WLAN_LFR
12479
Yue Maef608272013-04-08 23:09:17 -070012480#ifdef FEATURE_WLAN_LFR_METRICS
12481/*
12482 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12483 * 802.11r/LFR metrics reporting function to report preauth initiation
12484 *
12485 */
12486#define MAX_LFR_METRICS_EVENT_LENGTH 100
12487VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12488 tCsrRoamInfo *pRoamInfo)
12489{
12490 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12491 union iwreq_data wrqu;
12492
12493 ENTER();
12494
12495 if (NULL == pAdapter)
12496 {
12497 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12498 return VOS_STATUS_E_FAILURE;
12499 }
12500
12501 /* create the event */
12502 memset(&wrqu, 0, sizeof(wrqu));
12503 memset(metrics_notification, 0, sizeof(metrics_notification));
12504
12505 wrqu.data.pointer = metrics_notification;
12506 wrqu.data.length = scnprintf(metrics_notification,
12507 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12508 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12509
12510 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12511
12512 EXIT();
12513
12514 return VOS_STATUS_SUCCESS;
12515}
12516
12517/*
12518 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12519 * 802.11r/LFR metrics reporting function to report preauth completion
12520 * or failure
12521 */
12522VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12523 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12524{
12525 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12526 union iwreq_data wrqu;
12527
12528 ENTER();
12529
12530 if (NULL == pAdapter)
12531 {
12532 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12533 return VOS_STATUS_E_FAILURE;
12534 }
12535
12536 /* create the event */
12537 memset(&wrqu, 0, sizeof(wrqu));
12538 memset(metrics_notification, 0, sizeof(metrics_notification));
12539
12540 scnprintf(metrics_notification, sizeof(metrics_notification),
12541 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12542 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12543
12544 if (1 == preauth_status)
12545 strncat(metrics_notification, " TRUE", 5);
12546 else
12547 strncat(metrics_notification, " FALSE", 6);
12548
12549 wrqu.data.pointer = metrics_notification;
12550 wrqu.data.length = strlen(metrics_notification);
12551
12552 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12553
12554 EXIT();
12555
12556 return VOS_STATUS_SUCCESS;
12557}
12558
12559/*
12560 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12561 * 802.11r/LFR metrics reporting function to report handover initiation
12562 *
12563 */
12564VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12565 tCsrRoamInfo *pRoamInfo)
12566{
12567 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12568 union iwreq_data wrqu;
12569
12570 ENTER();
12571
12572 if (NULL == pAdapter)
12573 {
12574 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12575 return VOS_STATUS_E_FAILURE;
12576 }
12577
12578 /* create the event */
12579 memset(&wrqu, 0, sizeof(wrqu));
12580 memset(metrics_notification, 0, sizeof(metrics_notification));
12581
12582 wrqu.data.pointer = metrics_notification;
12583 wrqu.data.length = scnprintf(metrics_notification,
12584 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12585 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12586
12587 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12588
12589 EXIT();
12590
12591 return VOS_STATUS_SUCCESS;
12592}
12593#endif
12594
Jeff Johnson295189b2012-06-20 16:38:30 -070012595/*
12596 * FUNCTION: hdd_cfg80211_scan_done_callback
12597 * scanning callback function, called after finishing scan
12598 *
12599 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012600static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12602{
12603 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012604 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012606 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 struct cfg80211_scan_request *req = NULL;
12608 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012609 bool aborted = false;
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012610#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12611 bool iface_down = false;
12612#endif
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012613 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012614 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012615 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012616
12617 ENTER();
12618
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012619 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012620 if (NULL == pHddCtx) {
12621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012622 return 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012623 }
12624
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12626 if (!(pAdapter->dev->flags & IFF_UP))
12627 {
12628 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012629 iface_down = true;
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012630 }
12631#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012632 pScanInfo = &pHddCtx->scan_info;
12633
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 hddLog(VOS_TRACE_LEVEL_INFO,
12635 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012636 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 __func__, halHandle, pContext, (int) scanId, (int) status);
12638
Kiet Lamac06e2c2013-10-23 16:25:07 +053012639 pScanInfo->mScanPendingCounter = 0;
12640
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012642 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 &pScanInfo->scan_req_completion_event,
12644 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012645 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012647 hddLog(VOS_TRACE_LEVEL_ERROR,
12648 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012650 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 }
12652
Yue Maef608272013-04-08 23:09:17 -070012653 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 {
12655 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012656 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 }
12658
12659 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012660 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 {
12662 hddLog(VOS_TRACE_LEVEL_INFO,
12663 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012664 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 (int) scanId);
12666 }
12667
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012668#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012669 if (!iface_down)
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012670#endif
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012671 {
12672 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
12673 pAdapter);
12674 if (0 > ret)
12675 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagar9dd72842016-04-15 19:45:14 +053012676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012677
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 /* If any client wait scan result through WEXT
12679 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012680 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 {
12682 /* The other scan request waiting for current scan finish
12683 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012684 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012686 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012687 }
12688 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012689 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 {
12691 struct net_device *dev = pAdapter->dev;
12692 union iwreq_data wrqu;
12693 int we_event;
12694 char *msg;
12695
12696 memset(&wrqu, '\0', sizeof(wrqu));
12697 we_event = SIOCGIWSCAN;
12698 msg = NULL;
12699 wireless_send_event(dev, we_event, &wrqu, msg);
12700 }
12701 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012702 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012703
12704 /* Get the Scan Req */
12705 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053012706 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012707
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012708 /* Scan is no longer pending */
12709 pScanInfo->mScanPending = VOS_FALSE;
12710
mukul sharmae7041822015-12-03 15:09:21 +053012711 if (!req || req->wiphy == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012713 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
mukul sharmae7041822015-12-03 15:09:21 +053012714 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070012715 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 }
12717
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012718 /* last_scan_timestamp is used to decide if new scan
12719 * is needed or not on station interface. If last station
12720 * scan time and new station scan time is less then
12721 * last_scan_timestamp ; driver will return cached scan.
12722 */
12723 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
12724 {
12725 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
12726
12727 if ( req->n_channels )
12728 {
12729 for (i = 0; i < req->n_channels ; i++ )
12730 {
12731 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
12732 }
12733 /* store no of channel scanned */
12734 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
12735 }
12736
12737 }
12738
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070012739 /*
12740 * cfg80211_scan_done informing NL80211 about completion
12741 * of scanning
12742 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012743 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
12744 {
12745 aborted = true;
12746 }
mukul sharmae7041822015-12-03 15:09:21 +053012747
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012748#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12749 if (!iface_down)
12750#endif
12751 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053012752
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080012753 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070012754
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012755allow_suspend:
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053012756 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
12757 ) && (pHddCtx->spoofMacAddr.isEnabled
12758 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053012759 /* Generate new random mac addr for next scan */
12760 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053012761
12762 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
12763 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053012764 }
12765
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012766 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012767 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012768
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012769 /* Acquire wakelock to handle the case where APP's tries to suspend
12770 * immediatly after the driver gets connect request(i.e after scan)
12771 * from supplicant, this result in app's is suspending and not able
12772 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012773 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012774
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012775#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12776 if (!iface_down)
12777#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012778#ifdef FEATURE_WLAN_TDLS
Mahesh A Saptasagar08af5a32016-06-30 12:29:49 +053012779 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012780#endif
12781
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 EXIT();
12783 return 0;
12784}
12785
12786/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053012787 * FUNCTION: hdd_isConnectionInProgress
12788 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012789 *
12790 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012791v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012792{
12793 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12794 hdd_station_ctx_t *pHddStaCtx = NULL;
12795 hdd_adapter_t *pAdapter = NULL;
12796 VOS_STATUS status = 0;
12797 v_U8_t staId = 0;
12798 v_U8_t *staMac = NULL;
12799
c_hpothu9b781ba2013-12-30 20:57:45 +053012800 if (TRUE == pHddCtx->btCoexModeSet)
12801 {
12802 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053012803 FL("BTCoex Mode operation in progress"));
12804 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053012805 }
12806
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012807 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
12808
12809 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
12810 {
12811 pAdapter = pAdapterNode->pAdapter;
12812
12813 if( pAdapter )
12814 {
12815 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012816 "%s: Adapter with device mode %s (%d) exists",
12817 __func__, hdd_device_modetoString(pAdapter->device_mode),
12818 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012819 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053012820 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12821 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
12822 (eConnectionState_Connecting ==
12823 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12824 {
12825 hddLog(VOS_TRACE_LEVEL_ERROR,
12826 "%s: %p(%d) Connection is in progress", __func__,
12827 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12828 return VOS_TRUE;
12829 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012830 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053012831 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012832 {
12833 hddLog(VOS_TRACE_LEVEL_ERROR,
12834 "%s: %p(%d) Reassociation is in progress", __func__,
12835 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12836 return VOS_TRUE;
12837 }
12838 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012839 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12840 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012841 {
12842 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12843 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012844 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012845 {
12846 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
12847 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012848 "%s: client " MAC_ADDRESS_STR
12849 " is in the middle of WPS/EAPOL exchange.", __func__,
12850 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012851 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012852 }
12853 }
12854 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
12855 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
12856 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012857 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12858 ptSapContext pSapCtx = NULL;
12859 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12860 if(pSapCtx == NULL){
12861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12862 FL("psapCtx is NULL"));
12863 return VOS_FALSE;
12864 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012865 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
12866 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012867 if ((pSapCtx->aStaInfo[staId].isUsed) &&
12868 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012869 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012870 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012871
12872 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012873 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
12874 "middle of WPS/EAPOL exchange.", __func__,
12875 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012876 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012877 }
12878 }
12879 }
12880 }
12881 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12882 pAdapterNode = pNext;
12883 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012884 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012885}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012886
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053012887/**
12888 * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant
12889 * to the Scan request
12890 * @scanRequest: Pointer to the csr scan request
12891 * @request: Pointer to the scan request from supplicant
12892 *
12893 * Return: None
12894 */
12895#ifdef CFG80211_SCAN_BSSID
12896static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
12897 struct cfg80211_scan_request *request)
12898{
12899 vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE);
12900}
12901#else
12902static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest,
12903 struct cfg80211_scan_request *request)
12904{
12905}
12906#endif
12907
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012908/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012909 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 * this scan respond to scan trigger and update cfg80211 scan database
12911 * later, scan dump command can be used to recieve scan results
12912 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012913int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080012914#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12915 struct net_device *dev,
12916#endif
12917 struct cfg80211_scan_request *request)
12918{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012919 hdd_adapter_t *pAdapter = NULL;
12920 hdd_context_t *pHddCtx = NULL;
12921 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012922 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 tCsrScanRequest scanRequest;
12924 tANI_U8 *channelList = NULL, i;
12925 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012926 int status;
12927 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012929 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053012930 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012931 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012932 v_S7_t rssi=0;
12933 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012934
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012935#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
12936 struct net_device *dev = NULL;
12937 if (NULL == request)
12938 {
12939 hddLog(VOS_TRACE_LEVEL_ERROR,
12940 "%s: scan req param null", __func__);
12941 return -EINVAL;
12942 }
12943 dev = request->wdev->netdev;
12944#endif
12945
12946 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
12947 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
12948 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12949
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 ENTER();
12951
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012952 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12953 __func__, hdd_device_modetoString(pAdapter->device_mode),
12954 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012955
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012956 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012957 if (0 != status)
12958 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012959 return status;
12960 }
12961
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012962 if (NULL == pwextBuf)
12963 {
12964 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
12965 __func__);
12966 return -EIO;
12967 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012968 cfg_param = pHddCtx->cfg_ini;
12969 pScanInfo = &pHddCtx->scan_info;
12970
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012971 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12972 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
12973 {
12974 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
12975 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
12976 }
12977
Jeff Johnson295189b2012-06-20 16:38:30 -070012978#ifdef WLAN_BTAMP_FEATURE
12979 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012980 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080012982 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 "%s: No scanning when AMP is on", __func__);
12984 return -EOPNOTSUPP;
12985 }
12986#endif
12987 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012988 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012990 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012991 "%s: Not scanning on device_mode = %s (%d)",
12992 __func__, hdd_device_modetoString(pAdapter->device_mode),
12993 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 return -EOPNOTSUPP;
12995 }
12996
12997 if (TRUE == pScanInfo->mScanPending)
12998 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012999 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
13000 {
13001 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
13002 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013003 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 }
13005
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053013006 // Don't allow scan if PNO scan is going on.
13007 if (pHddCtx->isPnoEnable)
13008 {
13009 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13010 FL("pno scan in progress"));
13011 return -EBUSY;
13012 }
13013
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013014 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070013015 //Channel and action frame is pending
13016 //Otherwise Cancel Remain On Channel and allow Scan
13017 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013018 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070013019 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053013020 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070013021 return -EBUSY;
13022 }
13023
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
13025 {
13026 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080013027 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013029 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
13031 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013032 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 "%s: MAX TM Level Scan not allowed", __func__);
13034 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013035 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 }
13037 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
13038
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013039 /* Check if scan is allowed at this point of time.
13040 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053013041 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080013042 {
13043 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
13044 return -EBUSY;
13045 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013046
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 vos_mem_zero( &scanRequest, sizeof(scanRequest));
13048
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013049 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
13050 * Becasue of this, driver is assuming that this is not wildcard scan and so
13051 * is not aging out the scan results.
13052 */
13053 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013055 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013057
13058 if ((request->ssids) && (0 < request->n_ssids))
13059 {
13060 tCsrSSIDInfo *SsidInfo;
13061 int j;
13062 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
13063 /* Allocate num_ssid tCsrSSIDInfo structure */
13064 SsidInfo = scanRequest.SSIDs.SSIDList =
13065 ( tCsrSSIDInfo *)vos_mem_malloc(
13066 request->n_ssids*sizeof(tCsrSSIDInfo));
13067
13068 if(NULL == scanRequest.SSIDs.SSIDList)
13069 {
13070 hddLog(VOS_TRACE_LEVEL_ERROR,
13071 "%s: memory alloc failed SSIDInfo buffer", __func__);
13072 return -ENOMEM;
13073 }
13074
13075 /* copy all the ssid's and their length */
13076 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
13077 {
13078 /* get the ssid length */
13079 SsidInfo->SSID.length = request->ssids[j].ssid_len;
13080 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
13081 SsidInfo->SSID.length);
13082 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
13083 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
13084 j, SsidInfo->SSID.ssId);
13085 }
13086 /* set the scan type to active */
13087 scanRequest.scanType = eSIR_ACTIVE_SCAN;
13088 }
13089 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053013091 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13092 TRACE_CODE_HDD_CFG80211_SCAN,
13093 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 /* set the scan type to active */
13095 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013097 else
13098 {
13099 /*Set the scan type to default type, in this case it is ACTIVE*/
13100 scanRequest.scanType = pScanInfo->scan_mode;
13101 }
13102 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13103 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013104
Selvaraj, Sridhard2b078a2016-06-18 10:44:37 +053013105 csr_scan_request_assign_bssid(&scanRequest, request);
13106
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 /* set BSSType to default type */
13108 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13109
13110 /*TODO: scan the requested channels only*/
13111
13112 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013113 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013115 hddLog(VOS_TRACE_LEVEL_WARN,
13116 "No of Scan Channels exceeded limit: %d", request->n_channels);
13117 request->n_channels = MAX_CHANNEL;
13118 }
13119
13120 hddLog(VOS_TRACE_LEVEL_INFO,
13121 "No of Scan Channels: %d", request->n_channels);
13122
13123
13124 if( request->n_channels )
13125 {
13126 char chList [(request->n_channels*5)+1];
13127 int len;
13128 channelList = vos_mem_malloc( request->n_channels );
13129 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013130 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013131 hddLog(VOS_TRACE_LEVEL_ERROR,
13132 "%s: memory alloc failed channelList", __func__);
13133 status = -ENOMEM;
13134 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013135 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013136
13137 for( i = 0, len = 0; i < request->n_channels ; i++ )
13138 {
13139 channelList[i] = request->channels[i]->hw_value;
13140 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13141 }
13142
Nirav Shah20ac06f2013-12-12 18:14:06 +053013143 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013144 "Channel-List: %s ", chList);
13145 }
c_hpothu53512302014-04-15 18:49:53 +053013146
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013147 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13148 scanRequest.ChannelInfo.ChannelList = channelList;
13149
13150 /* set requestType to full scan */
13151 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13152
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013153 /* if there is back to back scan happening in driver with in
13154 * nDeferScanTimeInterval interval driver should defer new scan request
13155 * and should provide last cached scan results instead of new channel list.
13156 * This rule is not applicable if scan is p2p scan.
13157 * This condition will work only in case when last request no of channels
13158 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013159 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013160 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013161 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013162
Sushant Kaushik86592172015-04-27 16:35:03 +053013163 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13164 /* if wps ie is NULL , then only defer scan */
13165 if ( pWpsIe == NULL &&
13166 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013167 {
13168 if ( pScanInfo->last_scan_timestamp !=0 &&
13169 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13170 {
13171 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13172 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13173 vos_mem_compare(pScanInfo->last_scan_channelList,
13174 channelList, pScanInfo->last_scan_numChannels))
13175 {
13176 hddLog(VOS_TRACE_LEVEL_WARN,
13177 " New and old station scan time differ is less then %u",
13178 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13179
13180 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013181 pAdapter);
13182
Agarwal Ashish57e84372014-12-05 18:26:53 +053013183 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013184 "Return old cached scan as all channels and no of channels are same");
13185
Agarwal Ashish57e84372014-12-05 18:26:53 +053013186 if (0 > ret)
13187 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013188
Agarwal Ashish57e84372014-12-05 18:26:53 +053013189 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013190
13191 status = eHAL_STATUS_SUCCESS;
13192 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013193 }
13194 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013195 }
13196
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013197 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13198 * search (Flush on both full scan and social scan but not on single
13199 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13200 */
13201
13202 /* Supplicant does single channel scan after 8-way handshake
13203 * and in that case driver shoudnt flush scan results. If
13204 * driver flushes the scan results here and unfortunately if
13205 * the AP doesnt respond to our probe req then association
13206 * fails which is not desired
13207 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013208 if ((request->n_ssids == 1)
13209 && (request->ssids != NULL)
13210 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13211 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013212
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013213 if( is_p2p_scan ||
13214 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013215 {
13216 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13217 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13218 pAdapter->sessionId );
13219 }
13220
13221 if( request->ie_len )
13222 {
13223 /* save this for future association (join requires this) */
13224 /*TODO: Array needs to be converted to dynamic allocation,
13225 * as multiple ie.s can be sent in cfg80211_scan_request structure
13226 * CR 597966
13227 */
13228 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13229 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13230 pScanInfo->scanAddIE.length = request->ie_len;
13231
13232 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13233 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13234 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013236 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013238 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13239 memcpy( pwextBuf->roamProfile.addIEScan,
13240 request->ie, request->ie_len);
13241 }
13242 else
13243 {
13244 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13245 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 }
13247
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013248 }
13249 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13250 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13251
13252 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13253 request->ie_len);
13254 if (pP2pIe != NULL)
13255 {
13256#ifdef WLAN_FEATURE_P2P_DEBUG
13257 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13258 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13259 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013260 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013261 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13262 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13263 "Go nego completed to Connection is started");
13264 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13265 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013266 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013267 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13268 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013270 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13271 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13272 "Disconnected state to Connection is started");
13273 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13274 "for 4way Handshake");
13275 }
13276#endif
13277
13278 /* no_cck will be set during p2p find to disable 11b rates */
13279 if(TRUE == request->no_cck)
13280 {
13281 hddLog(VOS_TRACE_LEVEL_INFO,
13282 "%s: This is a P2P Search", __func__);
13283 scanRequest.p2pSearch = 1;
13284
13285 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013286 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013287 /* set requestType to P2P Discovery */
13288 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13289 }
13290
13291 /*
13292 Skip Dfs Channel in case of P2P Search
13293 if it is set in ini file
13294 */
13295 if(cfg_param->skipDfsChnlInP2pSearch)
13296 {
13297 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013298 }
13299 else
13300 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013301 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013303
Agarwal Ashish4f616132013-12-30 23:32:50 +053013304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 }
13306 }
13307
13308 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13309
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013310#ifdef FEATURE_WLAN_TDLS
13311 /* if tdls disagree scan right now, return immediately.
13312 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13313 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13314 */
13315 status = wlan_hdd_tdls_scan_callback (pAdapter,
13316 wiphy,
13317#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13318 dev,
13319#endif
13320 request);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013321 if (status <= 0)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013322 {
Abhishek Singhe2b63952016-01-05 18:27:29 +053013323 if (!status)
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013324 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13325 "scan rejected %d", __func__, status);
13326 else
13327 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13328 __func__, status);
Abhishek Singhe2b63952016-01-05 18:27:29 +053013329 hdd_wlan_block_scan_by_tdls();
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053013330 goto free_mem;
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013331 }
13332#endif
13333
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013334 /* acquire the wakelock to avoid the apps suspend during the scan. To
13335 * address the following issues.
13336 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13337 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13338 * for long time, this result in apps running at full power for long time.
13339 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13340 * be stuck in full power because of resume BMPS
13341 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013342 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013343
Nirav Shah20ac06f2013-12-12 18:14:06 +053013344 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13345 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013346 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13347 scanRequest.requestType, scanRequest.scanType,
13348 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013349 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13350
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013351 if (pHddCtx->spoofMacAddr.isEnabled &&
13352 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013353 {
13354 hddLog(VOS_TRACE_LEVEL_INFO,
13355 "%s: MAC Spoofing enabled for current scan", __func__);
13356 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13357 * to fill TxBds for probe request during current scan
13358 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013359 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013360 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013361
13362 if(status != VOS_STATUS_SUCCESS)
13363 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013364 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013365 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013366#ifdef FEATURE_WLAN_TDLS
13367 wlan_hdd_tdls_scan_done_callback(pAdapter);
13368#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013369 goto free_mem;
13370 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013371 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013372 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013373 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 pAdapter->sessionId, &scanRequest, &scanId,
13375 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013376
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 if (eHAL_STATUS_SUCCESS != status)
13378 {
13379 hddLog(VOS_TRACE_LEVEL_ERROR,
13380 "%s: sme_ScanRequest returned error %d", __func__, status);
13381 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013382 if(eHAL_STATUS_RESOURCES == status)
13383 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013384 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13385 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013386 status = -EBUSY;
13387 } else {
13388 status = -EIO;
13389 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013390 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013391
13392#ifdef FEATURE_WLAN_TDLS
13393 wlan_hdd_tdls_scan_done_callback(pAdapter);
13394#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 goto free_mem;
13396 }
13397
13398 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013399 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 pAdapter->request = request;
13401 pScanInfo->scanId = scanId;
13402
13403 complete(&pScanInfo->scan_req_completion_event);
13404
13405free_mem:
13406 if( scanRequest.SSIDs.SSIDList )
13407 {
13408 vos_mem_free(scanRequest.SSIDs.SSIDList);
13409 }
13410
13411 if( channelList )
13412 vos_mem_free( channelList );
13413
13414 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 return status;
13416}
13417
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013418int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13419#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13420 struct net_device *dev,
13421#endif
13422 struct cfg80211_scan_request *request)
13423{
13424 int ret;
13425
13426 vos_ssr_protect(__func__);
13427 ret = __wlan_hdd_cfg80211_scan(wiphy,
13428#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13429 dev,
13430#endif
13431 request);
13432 vos_ssr_unprotect(__func__);
13433
13434 return ret;
13435}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013436
13437void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13438{
13439 v_U8_t iniDot11Mode =
13440 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13441 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13442
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013443 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13444 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013445 switch ( iniDot11Mode )
13446 {
13447 case eHDD_DOT11_MODE_AUTO:
13448 case eHDD_DOT11_MODE_11ac:
13449 case eHDD_DOT11_MODE_11ac_ONLY:
13450#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013451 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13452 sme_IsFeatureSupportedByFW(DOT11AC) )
13453 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13454 else
13455 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013456#else
13457 hddDot11Mode = eHDD_DOT11_MODE_11n;
13458#endif
13459 break;
13460 case eHDD_DOT11_MODE_11n:
13461 case eHDD_DOT11_MODE_11n_ONLY:
13462 hddDot11Mode = eHDD_DOT11_MODE_11n;
13463 break;
13464 default:
13465 hddDot11Mode = iniDot11Mode;
13466 break;
13467 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013468#ifdef WLAN_FEATURE_AP_HT40_24G
13469 if (operationChannel > SIR_11B_CHANNEL_END)
13470#endif
13471 {
13472 /* This call decides required channel bonding mode */
13473 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013474 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13475 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013476 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013477}
13478
Jeff Johnson295189b2012-06-20 16:38:30 -070013479/*
13480 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013481 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013483int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013484 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13485 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013486{
13487 int status = 0;
13488 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013489 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 v_U32_t roamId;
13491 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013493 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013494
13495 ENTER();
13496
13497 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013498 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13499
13500 status = wlan_hdd_validate_context(pHddCtx);
13501 if (status)
13502 {
Yue Mae36e3552014-03-05 17:06:20 -080013503 return status;
13504 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013505
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13507 {
13508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13509 return -EINVAL;
13510 }
13511
13512 pRoamProfile = &pWextState->roamProfile;
13513
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013514 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013516 hdd_station_ctx_t *pHddStaCtx;
13517 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013518
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013519 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13520
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013521 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13523 {
13524 /*QoS not enabled in cfg file*/
13525 pRoamProfile->uapsd_mask = 0;
13526 }
13527 else
13528 {
13529 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013530 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13532 }
13533
13534 pRoamProfile->SSIDs.numOfSSIDs = 1;
13535 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13536 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013537 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13539 ssid, ssid_len);
13540
13541 if (bssid)
13542 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013543 pValidBssid = bssid;
13544 }
13545 else if (bssid_hint)
13546 {
13547 pValidBssid = bssid_hint;
13548 }
13549 if (pValidBssid)
13550 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013552 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013554 /* Save BSSID in seperate variable as well, as RoamProfile
13555 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 case of join failure we should send valid BSSID to supplicant
13557 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013558 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 WNI_CFG_BSSID_LEN);
13560 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070013561 else
13562 {
13563 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
13564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013565
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013566 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13567 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13569 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013570 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 /*set gen ie*/
13572 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13573 /*set auth*/
13574 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013576#ifdef FEATURE_WLAN_WAPI
13577 if (pAdapter->wapi_info.nWapiMode)
13578 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013579 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 switch (pAdapter->wapi_info.wapiAuthMode)
13581 {
13582 case WAPI_AUTH_MODE_PSK:
13583 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013584 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 pAdapter->wapi_info.wapiAuthMode);
13586 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13587 break;
13588 }
13589 case WAPI_AUTH_MODE_CERT:
13590 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013591 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 pAdapter->wapi_info.wapiAuthMode);
13593 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13594 break;
13595 }
13596 } // End of switch
13597 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13598 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13599 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013600 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 pRoamProfile->AuthType.numEntries = 1;
13602 pRoamProfile->EncryptionType.numEntries = 1;
13603 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13604 pRoamProfile->mcEncryptionType.numEntries = 1;
13605 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13606 }
13607 }
13608#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013609#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013610 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013611 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13612 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13613 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013614 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13615 sizeof (tSirGtkOffloadParams));
13616 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013617 }
13618#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 pRoamProfile->csrPersona = pAdapter->device_mode;
13620
Jeff Johnson32d95a32012-09-10 13:15:23 -070013621 if( operatingChannel )
13622 {
13623 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13624 pRoamProfile->ChannelInfo.numOfChannels = 1;
13625 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013626 else
13627 {
13628 pRoamProfile->ChannelInfo.ChannelList = NULL;
13629 pRoamProfile->ChannelInfo.numOfChannels = 0;
13630 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013631 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13632 {
13633 hdd_select_cbmode(pAdapter,operatingChannel);
13634 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013635
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013636 /*
13637 * Change conn_state to connecting before sme_RoamConnect(),
13638 * because sme_RoamConnect() has a direct path to call
13639 * hdd_smeRoamCallback(), which will change the conn_state
13640 * If direct path, conn_state will be accordingly changed
13641 * to NotConnected or Associated by either
13642 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13643 * in sme_RoamCallback()
13644 * if sme_RomConnect is to be queued,
13645 * Connecting state will remain until it is completed.
13646 * If connection state is not changed,
13647 * connection state will remain in eConnectionState_NotConnected state.
13648 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13649 * if conn state is eConnectionState_NotConnected.
13650 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13651 * informed of connect result indication which is an issue.
13652 */
13653
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013654 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13655 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013656 {
13657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013658 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013659 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
13660 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053013661 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013662 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 pAdapter->sessionId, pRoamProfile, &roamId);
13664
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013665 if ((eHAL_STATUS_SUCCESS != status) &&
13666 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13667 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013668
13669 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013670 hddLog(VOS_TRACE_LEVEL_ERROR,
13671 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
13672 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013673 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013674 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013675 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013676 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013677
13678 pRoamProfile->ChannelInfo.ChannelList = NULL;
13679 pRoamProfile->ChannelInfo.numOfChannels = 0;
13680
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 }
13682 else
13683 {
13684 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
13685 return -EINVAL;
13686 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013687 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 return status;
13689}
13690
13691/*
13692 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
13693 * This function is used to set the authentication type (OPEN/SHARED).
13694 *
13695 */
13696static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
13697 enum nl80211_auth_type auth_type)
13698{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013699 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13701
13702 ENTER();
13703
13704 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013705 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013708 hddLog(VOS_TRACE_LEVEL_INFO,
13709 "%s: set authentication type to AUTOSWITCH", __func__);
13710 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
13711 break;
13712
13713 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013714#ifdef WLAN_FEATURE_VOWIFI_11R
13715 case NL80211_AUTHTYPE_FT:
13716#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013717 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 "%s: set authentication type to OPEN", __func__);
13719 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13720 break;
13721
13722 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013723 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 "%s: set authentication type to SHARED", __func__);
13725 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
13726 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013727#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013728 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013729 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 "%s: set authentication type to CCKM WPA", __func__);
13731 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
13732 break;
13733#endif
13734
13735
13736 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013737 hddLog(VOS_TRACE_LEVEL_ERROR,
13738 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 auth_type);
13740 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
13741 return -EINVAL;
13742 }
13743
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013744 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 pHddStaCtx->conn_info.authType;
13746 return 0;
13747}
13748
13749/*
13750 * FUNCTION: wlan_hdd_set_akm_suite
13751 * This function is used to set the key mgmt type(PSK/8021x).
13752 *
13753 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013754static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 u32 key_mgmt
13756 )
13757{
13758 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13759 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053013760 /* Should be in ieee802_11_defs.h */
13761#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
13762#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 /*set key mgmt type*/
13764 switch(key_mgmt)
13765 {
13766 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053013767 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013768#ifdef WLAN_FEATURE_VOWIFI_11R
13769 case WLAN_AKM_SUITE_FT_PSK:
13770#endif
13771 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 __func__);
13773 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
13774 break;
13775
13776 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053013777 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013778#ifdef WLAN_FEATURE_VOWIFI_11R
13779 case WLAN_AKM_SUITE_FT_8021X:
13780#endif
13781 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 __func__);
13783 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13784 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013785#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013786#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
13787#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
13788 case WLAN_AKM_SUITE_CCKM:
13789 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
13790 __func__);
13791 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
13792 break;
13793#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070013794#ifndef WLAN_AKM_SUITE_OSEN
13795#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
13796 case WLAN_AKM_SUITE_OSEN:
13797 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
13798 __func__);
13799 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13800 break;
13801#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013802
13803 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 __func__, key_mgmt);
13806 return -EINVAL;
13807
13808 }
13809 return 0;
13810}
13811
13812/*
13813 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013814 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 * (NONE/WEP40/WEP104/TKIP/CCMP).
13816 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013817static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
13818 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 bool ucast
13820 )
13821{
13822 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013823 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13825
13826 ENTER();
13827
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013828 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013830 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 __func__, cipher);
13832 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13833 }
13834 else
13835 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013836
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013838 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 {
13840 case IW_AUTH_CIPHER_NONE:
13841 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13842 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013843
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013845 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013847
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013849 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070013850 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013851
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 case WLAN_CIPHER_SUITE_TKIP:
13853 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
13854 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013855
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 case WLAN_CIPHER_SUITE_CCMP:
13857 encryptionType = eCSR_ENCRYPT_TYPE_AES;
13858 break;
13859#ifdef FEATURE_WLAN_WAPI
13860 case WLAN_CIPHER_SUITE_SMS4:
13861 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
13862 break;
13863#endif
13864
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013865#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 case WLAN_CIPHER_SUITE_KRK:
13867 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
13868 break;
13869#endif
13870 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013871 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 __func__, cipher);
13873 return -EOPNOTSUPP;
13874 }
13875 }
13876
13877 if (ucast)
13878 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013879 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 __func__, encryptionType);
13881 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
13882 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013883 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 encryptionType;
13885 }
13886 else
13887 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013888 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 __func__, encryptionType);
13890 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
13891 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
13892 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
13893 }
13894
13895 return 0;
13896}
13897
13898
13899/*
13900 * FUNCTION: wlan_hdd_cfg80211_set_ie
13901 * This function is used to parse WPA/RSN IE's.
13902 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013903int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013904#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13905 const u8 *ie,
13906#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013907 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 size_t ie_len
13910 )
13911{
13912 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013913#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13914 const u8 *genie = ie;
13915#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 v_U16_t remLen = ie_len;
13919#ifdef FEATURE_WLAN_WAPI
13920 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
13921 u16 *tmp;
13922 v_U16_t akmsuiteCount;
13923 int *akmlist;
13924#endif
13925 ENTER();
13926
13927 /* clear previous assocAddIE */
13928 pWextState->assocAddIE.length = 0;
13929 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013930 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013931
13932 while (remLen >= 2)
13933 {
13934 v_U16_t eLen = 0;
13935 v_U8_t elementId;
13936 elementId = *genie++;
13937 eLen = *genie++;
13938 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013939
Arif Hussain6d2a3322013-11-17 19:50:10 -080013940 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013942
13943 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013945 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013946 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 -070013947 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013948 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 "%s: Invalid WPA IE", __func__);
13950 return -EINVAL;
13951 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013952 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 {
13954 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013955 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013957
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013958 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013960 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
13961 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 VOS_ASSERT(0);
13963 return -ENOMEM;
13964 }
13965 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13966 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13967 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013968
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
13970 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13971 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13972 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013973 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
13974 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
13976 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
13977 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
13978 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
13979 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
13980 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013981 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053013982 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 {
13984 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013985 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013987
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013988 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013990 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13991 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 VOS_ASSERT(0);
13993 return -ENOMEM;
13994 }
13995 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13996 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13997 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013998
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14000 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14001 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014002#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014003 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
14004 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 /*Consider WFD IE, only for P2P Client */
14006 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
14007 {
14008 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014009 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014011
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014012 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014014 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14015 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 VOS_ASSERT(0);
14017 return -ENOMEM;
14018 }
14019 // WFD IE is saved to Additional IE ; it should be accumulated to handle
14020 // WPS IE + P2P IE + WFD IE
14021 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14022 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014023
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14025 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14026 }
14027#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014028 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014029 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014030 HS20_OUI_TYPE_SIZE)) )
14031 {
14032 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014033 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014034 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014035
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014036 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014037 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014038 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14039 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014040 VOS_ASSERT(0);
14041 return -ENOMEM;
14042 }
14043 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14044 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014045
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070014046 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14047 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14048 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014049 /* Appending OSEN Information Element in Assiciation Request */
14050 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
14051 OSEN_OUI_TYPE_SIZE)) )
14052 {
14053 v_U16_t curAddIELen = pWextState->assocAddIE.length;
14054 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
14055 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014056
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014057 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070014058 {
14059 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14060 "Need bigger buffer space");
14061 VOS_ASSERT(0);
14062 return -ENOMEM;
14063 }
14064 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14065 pWextState->assocAddIE.length += eLen + 2;
14066
14067 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
14068 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14069 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14070 }
14071
Abhishek Singh4322e622015-06-10 15:42:54 +053014072 /* Update only for WPA IE */
14073 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
14074 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014075
14076 /* populating as ADDIE in beacon frames */
14077 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014078 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014079 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
14080 {
14081 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14082 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
14083 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14084 {
14085 hddLog(LOGE,
14086 "Coldn't pass "
14087 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
14088 }
14089 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
14090 else
14091 hddLog(LOGE,
14092 "Could not pass on "
14093 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
14094
14095 /* IBSS mode doesn't contain params->proberesp_ies still
14096 beaconIE's need to be populated in probe response frames */
14097 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
14098 {
14099 u16 rem_probe_resp_ie_len = eLen + 2;
14100 u8 probe_rsp_ie_len[3] = {0};
14101 u8 counter = 0;
14102
14103 /* Check Probe Resp Length if it is greater then 255 then
14104 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14105 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14106 not able Store More then 255 bytes into One Variable */
14107
14108 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14109 {
14110 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14111 {
14112 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14113 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14114 }
14115 else
14116 {
14117 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14118 rem_probe_resp_ie_len = 0;
14119 }
14120 }
14121
14122 rem_probe_resp_ie_len = 0;
14123
14124 if (probe_rsp_ie_len[0] > 0)
14125 {
14126 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14127 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14128 (tANI_U8*)(genie - 2),
14129 probe_rsp_ie_len[0], NULL,
14130 eANI_BOOLEAN_FALSE)
14131 == eHAL_STATUS_FAILURE)
14132 {
14133 hddLog(LOGE,
14134 "Could not pass"
14135 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14136 }
14137 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14138 }
14139
14140 if (probe_rsp_ie_len[1] > 0)
14141 {
14142 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14143 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14144 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14145 probe_rsp_ie_len[1], NULL,
14146 eANI_BOOLEAN_FALSE)
14147 == eHAL_STATUS_FAILURE)
14148 {
14149 hddLog(LOGE,
14150 "Could not pass"
14151 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14152 }
14153 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14154 }
14155
14156 if (probe_rsp_ie_len[2] > 0)
14157 {
14158 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14159 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14160 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14161 probe_rsp_ie_len[2], NULL,
14162 eANI_BOOLEAN_FALSE)
14163 == eHAL_STATUS_FAILURE)
14164 {
14165 hddLog(LOGE,
14166 "Could not pass"
14167 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14168 }
14169 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14170 }
14171
14172 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14173 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14174 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14175 {
14176 hddLog(LOGE,
14177 "Could not pass"
14178 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14179 }
14180 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014181 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014182 break;
14183 case DOT11F_EID_RSN:
14184 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14185 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14186 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14187 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14188 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14189 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014190
Abhishek Singhb16f3562016-01-20 11:08:32 +053014191 /* Appending extended capabilities with Interworking or
14192 * bsstransition bit set in Assoc Req.
Abhishek Singh15d95602015-03-24 15:52:57 +053014193 *
14194 * In assoc req this EXT Cap will only be taken into account if
Abhishek Singhb16f3562016-01-20 11:08:32 +053014195 * interworkingService or bsstransition bit is set to 1.
14196 * Driver is only interested in interworkingService and
14197 * bsstransition capability from supplicant.
14198 * If in future any other EXT Cap info is
Abhishek Singh15d95602015-03-24 15:52:57 +053014199 * required from supplicat, it needs to be handled while
14200 * sending Assoc Req in LIM.
14201 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014202 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014203 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014204 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014205 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014206 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014207
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014208 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014209 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014210 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14211 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014212 VOS_ASSERT(0);
14213 return -ENOMEM;
14214 }
14215 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14216 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014217
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014218 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14219 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14220 break;
14221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014222#ifdef FEATURE_WLAN_WAPI
14223 case WLAN_EID_WAPI:
14224 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014225 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 pAdapter->wapi_info.nWapiMode);
14227 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014228 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 akmsuiteCount = WPA_GET_LE16(tmp);
14230 tmp = tmp + 1;
14231 akmlist = (int *)(tmp);
14232 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14233 {
14234 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14235 }
14236 else
14237 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014238 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 VOS_ASSERT(0);
14240 return -EINVAL;
14241 }
14242
14243 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14244 {
14245 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014246 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014250 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014252 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14254 }
14255 break;
14256#endif
14257 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014258 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014260 /* when Unknown IE is received we should break and continue
14261 * to the next IE in the buffer instead we were returning
14262 * so changing this to break */
14263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 }
14265 genie += eLen;
14266 remLen -= eLen;
14267 }
14268 EXIT();
14269 return 0;
14270}
14271
14272/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014273 * FUNCTION: hdd_isWPAIEPresent
14274 * Parse the received IE to find the WPA IE
14275 *
14276 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014277static bool hdd_isWPAIEPresent(
14278#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14279 const u8 *ie,
14280#else
14281 u8 *ie,
14282#endif
14283 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014284{
14285 v_U8_t eLen = 0;
14286 v_U16_t remLen = ie_len;
14287 v_U8_t elementId = 0;
14288
14289 while (remLen >= 2)
14290 {
14291 elementId = *ie++;
14292 eLen = *ie++;
14293 remLen -= 2;
14294 if (eLen > remLen)
14295 {
14296 hddLog(VOS_TRACE_LEVEL_ERROR,
14297 "%s: IE length is wrong %d", __func__, eLen);
14298 return FALSE;
14299 }
14300 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14301 {
14302 /* OUI - 0x00 0X50 0XF2
14303 WPA Information Element - 0x01
14304 WPA version - 0x01*/
14305 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14306 return TRUE;
14307 }
14308 ie += eLen;
14309 remLen -= eLen;
14310 }
14311 return FALSE;
14312}
14313
14314/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014316 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 * parameters during connect operation.
14318 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014319int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014321 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014322{
14323 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014324 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 ENTER();
14326
14327 /*set wpa version*/
14328 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14329
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014330 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014332 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 {
14334 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14335 }
14336 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14337 {
14338 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14339 }
14340 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014341
14342 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 pWextState->wpaVersion);
14344
14345 /*set authentication type*/
14346 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14347
14348 if (0 > status)
14349 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014350 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 "%s: failed to set authentication type ", __func__);
14352 return status;
14353 }
14354
14355 /*set key mgmt type*/
14356 if (req->crypto.n_akm_suites)
14357 {
14358 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14359 if (0 > status)
14360 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014361 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 __func__);
14363 return status;
14364 }
14365 }
14366
14367 /*set pairwise cipher type*/
14368 if (req->crypto.n_ciphers_pairwise)
14369 {
14370 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14371 req->crypto.ciphers_pairwise[0], true);
14372 if (0 > status)
14373 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014374 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 "%s: failed to set unicast cipher type", __func__);
14376 return status;
14377 }
14378 }
14379 else
14380 {
14381 /*Reset previous cipher suite to none*/
14382 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14383 if (0 > status)
14384 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014385 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 "%s: failed to set unicast cipher type", __func__);
14387 return status;
14388 }
14389 }
14390
14391 /*set group cipher type*/
14392 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14393 false);
14394
14395 if (0 > status)
14396 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 __func__);
14399 return status;
14400 }
14401
Chet Lanctot186b5732013-03-18 10:26:30 -070014402#ifdef WLAN_FEATURE_11W
14403 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14404#endif
14405
Jeff Johnson295189b2012-06-20 16:38:30 -070014406 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14407 if (req->ie_len)
14408 {
14409 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14410 if ( 0 > status)
14411 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014412 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 __func__);
14414 return status;
14415 }
14416 }
14417
14418 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014419 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014420 {
14421 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14422 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14423 )
14424 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014425 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14427 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014428 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014429 __func__);
14430 return -EOPNOTSUPP;
14431 }
14432 else
14433 {
14434 u8 key_len = req->key_len;
14435 u8 key_idx = req->key_idx;
14436
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014437 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014438 && (CSR_MAX_NUM_KEY > key_idx)
14439 )
14440 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014441 hddLog(VOS_TRACE_LEVEL_INFO,
14442 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 __func__, key_idx, key_len);
14444 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014445 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014447 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 (u8)key_len;
14449 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14450 }
14451 }
14452 }
14453 }
14454
14455 return status;
14456}
14457
14458/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014459 * FUNCTION: wlan_hdd_try_disconnect
14460 * This function is used to disconnect from previous
14461 * connection
14462 */
14463static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
14464{
14465 long ret = 0;
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014466 int status, result = 0;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014467 hdd_station_ctx_t *pHddStaCtx;
14468 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014469 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014470
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014471 ret = wlan_hdd_validate_context(pHddCtx);
14472 if (0 != ret)
14473 {
14474 return ret;
14475 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014476 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14477
14478 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14479
14480 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14481 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014482 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014483 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14484 {
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014485 spin_lock_bh(&pAdapter->lock_for_active_session);
14486 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14487 {
14488 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14489 }
14490 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014491 hdd_connSetConnectionState(pHddStaCtx,
14492 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014493 /* Issue disconnect to CSR */
14494 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014495 status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014496 pAdapter->sessionId,
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014497 eCSR_DISCONNECT_REASON_UNSPECIFIED);
14498 if(eHAL_STATUS_CMD_NOT_QUEUED == status) {
14499 hddLog(LOG1,
14500 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
14501 } else if ( 0 != status ) {
14502 hddLog(LOGE,
14503 FL("csrRoamDisconnect failure, returned %d"),
14504 (int)status );
14505 result = -EINVAL;
14506 goto disconnected;
14507 }
14508 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014509 &pAdapter->disconnect_comp_var,
14510 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014511 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) {
14512 hddLog(LOGE,
14513 "%s: Failed to disconnect, timed out", __func__);
14514 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014515 }
14516 }
14517 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14518 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014519 ret = wait_for_completion_timeout(
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014520 &pAdapter->disconnect_comp_var,
14521 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014522 if (!ret)
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014523 {
14524 hddLog(LOGE, FL("Failed to receive disconnect event"));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014525 result = -ETIMEDOUT;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014526 }
14527 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014528disconnected:
14529 hddLog(LOG1,
14530 FL("Set HDD connState to eConnectionState_NotConnected"));
14531 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14532 return result;
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014533}
14534
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014535/**
14536 * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present
14537 * @adapter: Pointer to the HDD adapter
14538 * @req: Pointer to the structure cfg_connect_params receieved from user space
14539 *
14540 * This function will start reassociation if bssid hint, channel hint and
14541 * previous bssid parameters are present in the connect request
14542 *
14543 * Return: success if reassociation is happening
14544 * Error code if reassociation is not permitted or not happening
14545 */
14546#ifdef CFG80211_CONNECT_PREV_BSSID
14547static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14548 struct cfg80211_connect_params *req)
14549{
14550 int status = -EPERM;
14551 if (req->bssid_hint && req->channel_hint && req->prev_bssid) {
14552 hddLog(VOS_TRACE_LEVEL_INFO,
14553 FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR),
14554 req->channel_hint->hw_value,
14555 MAC_ADDR_ARRAY(req->bssid_hint));
14556 status = hdd_reassoc(adapter, req->bssid_hint,
14557 req->channel_hint->hw_value,
14558 CONNECT_CMD_USERSPACE);
14559 }
14560 return status;
14561}
14562#else
14563static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter,
14564 struct cfg80211_connect_params *req)
14565{
14566 return -EPERM;
14567}
14568#endif
14569
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014570/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053014571 * FUNCTION: __wlan_hdd_cfg80211_connect
14572 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014574static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 struct net_device *ndev,
14576 struct cfg80211_connect_params *req
14577 )
14578{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014579 int status;
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014580 u16 channel;
Edhar, Mahesh Kumar496c7f72016-03-18 12:47:44 +053014581#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
14582 defined(CFG80211_BSSID_HINT_BACKPORT)
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014583 const u8 *bssid_hint = req->bssid_hint;
14584#else
14585 const u8 *bssid_hint = NULL;
14586#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014587 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014588 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053014589 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014590
14591 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014592
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014593 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14594 TRACE_CODE_HDD_CFG80211_CONNECT,
14595 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014596 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014597 "%s: device_mode = %s (%d)", __func__,
14598 hdd_device_modetoString(pAdapter->device_mode),
14599 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014600
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014601 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014602 if (!pHddCtx)
14603 {
14604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14605 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053014606 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014607 }
14608
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014609 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014610 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014611 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014612 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 }
14614
Selvaraj, Sridhar95e226f2016-06-18 12:27:25 +053014615 status = wlan_hdd_reassoc_bssid_hint(pAdapter, req);
14616 if (0 == status)
14617 return status;
14618
Agarwal Ashish51325b52014-06-16 16:50:49 +053014619
Jeff Johnson295189b2012-06-20 16:38:30 -070014620#ifdef WLAN_BTAMP_FEATURE
14621 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014622 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070014623 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014624 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080014626 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 }
14628#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014629
14630 //If Device Mode is Station Concurrent Sessions Exit BMps
14631 //P2P Mode will be taken care in Open/close adapter
14632 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053014633 (vos_concurrent_open_sessions_running())) {
14634 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14635 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014636 }
14637
14638 /*Try disconnecting if already in connected state*/
14639 status = wlan_hdd_try_disconnect(pAdapter);
14640 if ( 0 > status)
14641 {
14642 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14643 " connection"));
14644 return -EALREADY;
14645 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053014646 /* Check for max concurrent connections after doing disconnect if any*/
14647 if (vos_max_concurrent_connections_reached()) {
14648 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14649 return -ECONNREFUSED;
14650 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014651
Jeff Johnson295189b2012-06-20 16:38:30 -070014652 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014653 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014654
14655 if ( 0 > status)
14656 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 __func__);
14659 return status;
14660 }
Sravan Kumar Kairam589c5722016-01-27 20:28:53 +053014661
14662 if (pHddCtx->spoofMacAddr.isEnabled)
14663 {
14664 hddLog(VOS_TRACE_LEVEL_INFO,
14665 "%s: MAC Spoofing enabled ", __func__);
14666 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
14667 * to fill TxBds for probe request during SSID scan which may happen
14668 * as part of connect command
14669 */
14670 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
14671 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
14672 if (status != VOS_STATUS_SUCCESS)
14673 return -ECONNREFUSED;
14674 }
14675
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014676 if (req->channel)
14677 channel = req->channel->hw_value;
Mohit Khanna765234a2012-09-11 15:08:35 -070014678 else
Sreelakshmi Konamkie6521742016-03-18 12:44:27 +053014679 channel = 0;
14680 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
14681 req->ssid_len, req->bssid,
14682 bssid_hint, channel);
Jeff Johnson295189b2012-06-20 16:38:30 -070014683
Sushant Kaushikd7083982015-03-18 14:33:24 +053014684 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 {
14686 //ReEnable BMPS if disabled
14687 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
14688 (NULL != pHddCtx))
14689 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053014690 if (pHddCtx->hdd_wlan_suspended)
14691 {
14692 hdd_set_pwrparams(pHddCtx);
14693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 //ReEnable Bmps and Imps back
14695 hdd_enable_bmps_imps(pHddCtx);
14696 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053014697 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 return status;
14699 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014700 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014701 EXIT();
14702 return status;
14703}
14704
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014705static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
14706 struct net_device *ndev,
14707 struct cfg80211_connect_params *req)
14708{
14709 int ret;
14710 vos_ssr_protect(__func__);
14711 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
14712 vos_ssr_unprotect(__func__);
14713
14714 return ret;
14715}
Jeff Johnson295189b2012-06-20 16:38:30 -070014716
14717/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014718 * FUNCTION: wlan_hdd_disconnect
14719 * This function is used to issue a disconnect request to SME
14720 */
14721int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
14722{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014723 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014724 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014725 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014726 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014727
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014728 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014729
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014730 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014731 if (0 != status)
14732 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014733 return status;
14734 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053014735 /* Indicate sme of disconnect so that in progress connection or preauth
14736 * can be aborted
14737 */
14738 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053014739 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014740 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014741
Agarwal Ashish47d18112014-08-04 19:55:07 +053014742 /* Need to apply spin lock before decreasing active sessions
14743 * as there can be chance for double decrement if context switch
14744 * Calls hdd_DisConnectHandler.
14745 */
14746
14747 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014748 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14749 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014750 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14751 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053014752 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
14753 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014754
Abhishek Singhf4669da2014-05-26 15:07:49 +053014755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053014756 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
14757
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014758 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014759
Mihir Shete182a0b22014-08-18 16:08:48 +053014760 /*
14761 * stop tx queues before deleting STA/BSS context from the firmware.
14762 * tx has to be disabled because the firmware can get busy dropping
14763 * the tx frames after BSS/STA has been deleted and will not send
14764 * back a response resulting in WDI timeout
14765 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053014766 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053014767 netif_tx_disable(pAdapter->dev);
14768 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014769
Mihir Shete182a0b22014-08-18 16:08:48 +053014770 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014771 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14772 pAdapter->sessionId, reason);
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014773 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
14774 {
14775 hddLog(LOG1,
14776 FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect"));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014777 }
14778 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014779 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014780 hddLog(LOGE,
14781 FL("csrRoamDisconnect failure, returned %d"),
14782 (int)status);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014783 result = -EINVAL;
14784 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014785 }
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014786 ret = wait_for_completion_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014787 &pAdapter->disconnect_comp_var,
14788 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014789 if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014790 {
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014791 hddLog(LOGE,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014792 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014793 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014794 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014795disconnected:
Abhishek Singhf1b048a2016-01-13 13:57:27 +053014796 hddLog(LOG1,
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014797 FL("Set HDD connState to eConnectionState_NotConnected"));
14798 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053014799#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
14800 /* Sending disconnect event to userspace for kernel version < 3.11
14801 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
14802 */
14803 hddLog(LOG1, FL("Send disconnected event to userspace"));
14804
Mahesh A Saptasagarf5859b12016-06-01 17:17:50 +053014805 wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
Mahesh A Saptasagar936ffc32016-05-25 11:27:43 +053014806 WLAN_REASON_UNSPECIFIED);
14807#endif
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014808
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014809 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014810 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014811}
14812
14813
14814/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014815 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 * This function is used to issue a disconnect request to SME
14817 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014818static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 struct net_device *dev,
14820 u16 reason
14821 )
14822{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014824 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014825 tCsrRoamProfile *pRoamProfile;
14826 hdd_station_ctx_t *pHddStaCtx;
14827 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014828#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014829 tANI_U8 staIdx;
14830#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014831
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014833
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014834 if (!pAdapter) {
14835 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
14836 return -EINVAL;
14837 }
14838
14839 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14840 if (!pHddStaCtx) {
14841 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
14842 return -EINVAL;
14843 }
14844
14845 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14846 status = wlan_hdd_validate_context(pHddCtx);
14847 if (0 != status)
14848 {
14849 return status;
14850 }
14851
14852 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
14853
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014854 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14855 TRACE_CODE_HDD_CFG80211_DISCONNECT,
14856 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014857 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
14858 __func__, hdd_device_modetoString(pAdapter->device_mode),
14859 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014860
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014861 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
14862 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070014863
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 if (NULL != pRoamProfile)
14865 {
14866 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014867 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
14868 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014870 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014872 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 switch(reason)
14874 {
14875 case WLAN_REASON_MIC_FAILURE:
14876 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
14877 break;
14878
14879 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
14880 case WLAN_REASON_DISASSOC_AP_BUSY:
14881 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
14882 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
14883 break;
14884
14885 case WLAN_REASON_PREV_AUTH_NOT_VALID:
14886 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053014887 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
14889 break;
14890
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 default:
14892 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
14893 break;
14894 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014895 pScanInfo = &pHddCtx->scan_info;
14896 if (pScanInfo->mScanPending)
14897 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014898 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014899 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053014900 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014901 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014902 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053014903 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014904#ifdef FEATURE_WLAN_TDLS
14905 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014906 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014907 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014908 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
14909 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014910 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014911 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014912 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014914 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014915 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014916 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014917 status = sme_DeleteTdlsPeerSta(
14918 WLAN_HDD_GET_HAL_CTX(pAdapter),
14919 pAdapter->sessionId,
14920 mac);
14921 if (status != eHAL_STATUS_SUCCESS) {
14922 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
14923 return -EPERM;
14924 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014925 }
14926 }
14927#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014928 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014929 status = wlan_hdd_disconnect(pAdapter, reasonCode);
14930 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 {
14932 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014933 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 __func__, (int)status );
14935 return -EINVAL;
14936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014938 else
14939 {
14940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
14941 "called while in %d state", __func__,
14942 pHddStaCtx->conn_info.connState);
14943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 }
14945 else
14946 {
14947 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
14948 }
14949
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014950 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 return status;
14952}
14953
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014954static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
14955 struct net_device *dev,
14956 u16 reason
14957 )
14958{
14959 int ret;
14960 vos_ssr_protect(__func__);
14961 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
14962 vos_ssr_unprotect(__func__);
14963
14964 return ret;
14965}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014966
Jeff Johnson295189b2012-06-20 16:38:30 -070014967/*
14968 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014969 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 * settings in IBSS mode.
14971 */
14972static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014973 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 struct cfg80211_ibss_params *params
14975 )
14976{
14977 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014978 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14980 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014981
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 ENTER();
14983
14984 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070014985 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070014986
14987 if (params->ie_len && ( NULL != params->ie) )
14988 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014989 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14990 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 {
14992 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14993 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14994 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014995 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014997 tDot11fIEWPA dot11WPAIE;
14998 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014999 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015000
Wilson Yang00256342013-10-10 23:13:38 -070015001 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015002 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
15003 params->ie_len, DOT11F_EID_WPA);
15004 if ( NULL != ie )
15005 {
15006 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
15007 // Unpack the WPA IE
15008 //Skip past the EID byte and length byte - and four byte WiFi OUI
15009 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
15010 &ie[2+4],
15011 ie[1] - 4,
15012 &dot11WPAIE);
15013 /*Extract the multicast cipher, the encType for unicast
15014 cipher for wpa-none is none*/
15015 encryptionType =
15016 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
15017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070015019
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
15021
15022 if (0 > status)
15023 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015024 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 __func__);
15026 return status;
15027 }
15028 }
15029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015030 pWextState->roamProfile.AuthType.authType[0] =
15031 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 eCSR_AUTH_TYPE_OPEN_SYSTEM;
15033
15034 if (params->privacy)
15035 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015036 /* Security enabled IBSS, At this time there is no information available
15037 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070015038 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015039 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070015040 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015041 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070015042 *enable privacy bit in beacons */
15043
15044 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
15045 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070015046 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
15047 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
15049 pWextState->roamProfile.EncryptionType.numEntries = 1;
15050 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 return status;
15052}
15053
15054/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015055 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015056 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015058static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 struct net_device *dev,
15060 struct cfg80211_ibss_params *params
15061 )
15062{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15065 tCsrRoamProfile *pRoamProfile;
15066 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015067 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15068 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015069 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070015070
15071 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015072
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015073 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15074 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
15075 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015076 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015077 "%s: device_mode = %s (%d)", __func__,
15078 hdd_device_modetoString(pAdapter->device_mode),
15079 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015080
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015081 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015082 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015084 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015085 }
15086
15087 if (NULL == pWextState)
15088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015089 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015090 __func__);
15091 return -EIO;
15092 }
15093
Agarwal Ashish51325b52014-06-16 16:50:49 +053015094 if (vos_max_concurrent_connections_reached()) {
15095 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15096 return -ECONNREFUSED;
15097 }
15098
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053015099 /*Try disconnecting if already in connected state*/
15100 status = wlan_hdd_try_disconnect(pAdapter);
15101 if ( 0 > status)
15102 {
15103 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
15104 " IBSS connection"));
15105 return -EALREADY;
15106 }
15107
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 pRoamProfile = &pWextState->roamProfile;
15109
15110 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
15111 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015112 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015113 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 return -EINVAL;
15115 }
15116
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015117 /* BSSID is provided by upper layers hence no need to AUTO generate */
15118 if (NULL != params->bssid) {
15119 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15120 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
15121 hddLog (VOS_TRACE_LEVEL_ERROR,
15122 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15123 return -EIO;
15124 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015125 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015126 }
krunal sonie9002db2013-11-25 14:24:17 -080015127 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
15128 {
15129 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
15130 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
15131 {
15132 hddLog (VOS_TRACE_LEVEL_ERROR,
15133 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
15134 return -EIO;
15135 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015136
15137 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080015138 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015139 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080015140 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070015141
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070015143 if (NULL !=
15144#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15145 params->chandef.chan)
15146#else
15147 params->channel)
15148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 {
15150 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015151 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
15152 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
15153 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15154 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015155
15156 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015157 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070015158 ieee80211_frequency_to_channel(
15159#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
15160 params->chandef.chan->center_freq);
15161#else
15162 params->channel->center_freq);
15163#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015164
15165 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15166 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015168 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15169 __func__);
15170 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015171 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015172
15173 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015175 if (channelNum == validChan[indx])
15176 {
15177 break;
15178 }
15179 }
15180 if (indx >= numChans)
15181 {
15182 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 __func__, channelNum);
15184 return -EINVAL;
15185 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015186 /* Set the Operational Channel */
15187 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15188 channelNum);
15189 pRoamProfile->ChannelInfo.numOfChannels = 1;
15190 pHddStaCtx->conn_info.operationChannel = channelNum;
15191 pRoamProfile->ChannelInfo.ChannelList =
15192 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 }
15194
15195 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015196 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 if (status < 0)
15198 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015199 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015200 __func__);
15201 return status;
15202 }
15203
15204 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015205 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015206 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015207 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015208
15209 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015210 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015211
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015212 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015213 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015214}
15215
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015216static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15217 struct net_device *dev,
15218 struct cfg80211_ibss_params *params
15219 )
15220{
15221 int ret = 0;
15222
15223 vos_ssr_protect(__func__);
15224 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15225 vos_ssr_unprotect(__func__);
15226
15227 return ret;
15228}
15229
Jeff Johnson295189b2012-06-20 16:38:30 -070015230/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015231 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015232 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015234static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 struct net_device *dev
15236 )
15237{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015238 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015239 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15240 tCsrRoamProfile *pRoamProfile;
15241 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015242 int status;
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015243#ifdef WLAN_FEATURE_RMC
15244 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0};
15245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015246
15247 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015248
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015249 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15250 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15251 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015252 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015253 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015254 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015255 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015256 }
15257
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015258 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15259 hdd_device_modetoString(pAdapter->device_mode),
15260 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015261 if (NULL == pWextState)
15262 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015263 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015264 __func__);
15265 return -EIO;
15266 }
15267
15268 pRoamProfile = &pWextState->roamProfile;
15269
15270 /* Issue disconnect only if interface type is set to IBSS */
15271 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15272 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015273 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 __func__);
15275 return -EINVAL;
15276 }
15277
Abhishek Singh7cd040e2016-01-07 10:51:04 +053015278#ifdef WLAN_FEATURE_RMC
15279 /* Clearing add IE of beacon */
15280 if (ccmCfgSetStr(pHddCtx->hHal,
15281 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0],
15282 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN,
15283 NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15284 {
15285 hddLog (VOS_TRACE_LEVEL_ERROR,
15286 "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__);
15287 return -EINVAL;
15288 }
15289 if (ccmCfgSetInt(pHddCtx->hHal,
15290 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL,
15291 eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
15292 {
15293 hddLog (VOS_TRACE_LEVEL_ERROR,
15294 "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
15295 __func__);
15296 return -EINVAL;
15297 }
15298
15299 // Reset WNI_CFG_PROBE_RSP Flags
15300 wlan_hdd_reset_prob_rspies(pAdapter);
15301
15302 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
15303 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL,
15304 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
15305 {
15306 hddLog (VOS_TRACE_LEVEL_ERROR,
15307 "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG",
15308 __func__);
15309 return -EINVAL;
15310 }
15311#endif
15312
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 /* Issue Disconnect request */
15314 INIT_COMPLETION(pAdapter->disconnect_comp_var);
15315 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
15316 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15317
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015318 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 return 0;
15320}
15321
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015322static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15323 struct net_device *dev
15324 )
15325{
15326 int ret = 0;
15327
15328 vos_ssr_protect(__func__);
15329 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15330 vos_ssr_unprotect(__func__);
15331
15332 return ret;
15333}
15334
Jeff Johnson295189b2012-06-20 16:38:30 -070015335/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015336 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 * This function is used to set the phy parameters
15338 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15339 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015340static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 u32 changed)
15342{
15343 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15344 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015345 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015346
15347 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015348
15349 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015350 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15351 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015353 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015354 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015355 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015356 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015357 }
15358
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15360 {
15361 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15362 WNI_CFG_RTS_THRESHOLD_STAMAX :
15363 wiphy->rts_threshold;
15364
15365 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015366 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015368 hddLog(VOS_TRACE_LEVEL_ERROR,
15369 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 __func__, rts_threshold);
15371 return -EINVAL;
15372 }
15373
15374 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15375 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015376 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015378 hddLog(VOS_TRACE_LEVEL_ERROR,
15379 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 __func__, rts_threshold);
15381 return -EIO;
15382 }
15383
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015384 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 rts_threshold);
15386 }
15387
15388 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15389 {
15390 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15391 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15392 wiphy->frag_threshold;
15393
15394 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015395 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015397 hddLog(VOS_TRACE_LEVEL_ERROR,
15398 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 frag_threshold);
15400 return -EINVAL;
15401 }
15402
15403 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15404 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015405 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015407 hddLog(VOS_TRACE_LEVEL_ERROR,
15408 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 __func__, frag_threshold);
15410 return -EIO;
15411 }
15412
15413 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15414 frag_threshold);
15415 }
15416
15417 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15418 || (changed & WIPHY_PARAM_RETRY_LONG))
15419 {
15420 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15421 wiphy->retry_short :
15422 wiphy->retry_long;
15423
15424 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15425 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15426 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015427 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 __func__, retry_value);
15429 return -EINVAL;
15430 }
15431
15432 if (changed & WIPHY_PARAM_RETRY_SHORT)
15433 {
15434 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15435 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015436 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015438 hddLog(VOS_TRACE_LEVEL_ERROR,
15439 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 __func__, retry_value);
15441 return -EIO;
15442 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015443 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 __func__, retry_value);
15445 }
15446 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15447 {
15448 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15449 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015450 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015452 hddLog(VOS_TRACE_LEVEL_ERROR,
15453 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 __func__, retry_value);
15455 return -EIO;
15456 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015457 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015458 __func__, retry_value);
15459 }
15460 }
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 Saptasagar179d2252014-06-02 21:32:21 +053015466static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15467 u32 changed)
15468{
15469 int ret;
15470
15471 vos_ssr_protect(__func__);
15472 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15473 vos_ssr_unprotect(__func__);
15474
15475 return ret;
15476}
15477
Jeff Johnson295189b2012-06-20 16:38:30 -070015478/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015479 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015480 * This function is used to set the txpower
15481 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015482static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015483#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15484 struct wireless_dev *wdev,
15485#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015486#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015487 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015488#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015489 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015490#endif
15491 int dbm)
15492{
15493 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015494 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15496 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015497 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015498
15499 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015500
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015501 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15502 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15503 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015504 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015505 if (0 != status)
15506 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015507 return status;
15508 }
15509
15510 hHal = pHddCtx->hHal;
15511
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015512 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15513 dbm, ccmCfgSetCallback,
15514 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015516 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015517 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15518 return -EIO;
15519 }
15520
15521 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15522 dbm);
15523
15524 switch(type)
15525 {
15526 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
15527 /* Fall through */
15528 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
15529 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
15530 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015531 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
15532 __func__);
15533 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070015534 }
15535 break;
15536 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015537 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015538 __func__);
15539 return -EOPNOTSUPP;
15540 break;
15541 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015542 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
15543 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 return -EIO;
15545 }
15546
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015547 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 return 0;
15549}
15550
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015551static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
15552#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15553 struct wireless_dev *wdev,
15554#endif
15555#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15556 enum tx_power_setting type,
15557#else
15558 enum nl80211_tx_power_setting type,
15559#endif
15560 int dbm)
15561{
15562 int ret;
15563 vos_ssr_protect(__func__);
15564 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
15565#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15566 wdev,
15567#endif
15568#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15569 type,
15570#else
15571 type,
15572#endif
15573 dbm);
15574 vos_ssr_unprotect(__func__);
15575
15576 return ret;
15577}
15578
Jeff Johnson295189b2012-06-20 16:38:30 -070015579/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015580 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 * This function is used to read the txpower
15582 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015583static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015584#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15585 struct wireless_dev *wdev,
15586#endif
15587 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070015588{
15589
15590 hdd_adapter_t *pAdapter;
15591 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015592 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015593
Jeff Johnsone7245742012-09-05 17:12:55 -070015594 ENTER();
15595
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015596 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015597 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015598 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015599 *dbm = 0;
15600 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015601 }
15602
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
15604 if (NULL == pAdapter)
15605 {
15606 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
15607 return -ENOENT;
15608 }
15609
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015610 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15611 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
15612 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070015613 wlan_hdd_get_classAstats(pAdapter);
15614 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
15615
Jeff Johnsone7245742012-09-05 17:12:55 -070015616 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 return 0;
15618}
15619
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015620static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
15621#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15622 struct wireless_dev *wdev,
15623#endif
15624 int *dbm)
15625{
15626 int ret;
15627
15628 vos_ssr_protect(__func__);
15629 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
15630#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15631 wdev,
15632#endif
15633 dbm);
15634 vos_ssr_unprotect(__func__);
15635
15636 return ret;
15637}
15638
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015639static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015640#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15641 const u8* mac,
15642#else
15643 u8* mac,
15644#endif
15645 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070015646{
15647 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15648 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15649 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053015650 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015651
15652 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
15653 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070015654
15655 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
15656 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
15657 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
15658 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
15659 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
15660 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
15661 tANI_U16 maxRate = 0;
15662 tANI_U16 myRate;
15663 tANI_U16 currentRate = 0;
15664 tANI_U8 maxSpeedMCS = 0;
15665 tANI_U8 maxMCSIdx = 0;
15666 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053015667 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070015668 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015669 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015670
Leo Chang6f8870f2013-03-26 18:11:36 -070015671#ifdef WLAN_FEATURE_11AC
15672 tANI_U32 vht_mcs_map;
15673 eDataRate11ACMaxMcs vhtMaxMcs;
15674#endif /* WLAN_FEATURE_11AC */
15675
Jeff Johnsone7245742012-09-05 17:12:55 -070015676 ENTER();
15677
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15679 (0 == ssidlen))
15680 {
15681 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
15682 " Invalid ssidlen, %d", __func__, ssidlen);
15683 /*To keep GUI happy*/
15684 return 0;
15685 }
15686
Mukul Sharma811205f2014-07-09 21:07:30 +053015687 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
15688 {
15689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15690 "%s: Roaming in progress, so unable to proceed this request", __func__);
15691 return 0;
15692 }
15693
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015694 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015695 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015696 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015697 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015698 }
15699
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053015700 wlan_hdd_get_station_stats(pAdapter);
15701 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015702
Kiet Lam3b17fc82013-09-27 05:24:08 +053015703 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
15704 sinfo->filled |= STATION_INFO_SIGNAL;
15705
c_hpothu09f19542014-05-30 21:53:31 +053015706 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053015707 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
15708 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053015709 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053015710 {
15711 rate_flags = pAdapter->maxRateFlags;
15712 }
c_hpothu44ff4e02014-05-08 00:13:57 +053015713
Jeff Johnson295189b2012-06-20 16:38:30 -070015714 //convert to the UI units of 100kbps
15715 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
15716
15717#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070015718 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 -070015719 sinfo->signal,
15720 pCfg->reportMaxLinkSpeed,
15721 myRate,
15722 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015723 (int) pCfg->linkSpeedRssiMid,
15724 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070015725 (int) rate_flags,
15726 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070015727#endif //LINKSPEED_DEBUG_ENABLED
15728
15729 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
15730 {
15731 // we do not want to necessarily report the current speed
15732 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
15733 {
15734 // report the max possible speed
15735 rssidx = 0;
15736 }
15737 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
15738 {
15739 // report the max possible speed with RSSI scaling
15740 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
15741 {
15742 // report the max possible speed
15743 rssidx = 0;
15744 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015745 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070015746 {
15747 // report middle speed
15748 rssidx = 1;
15749 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015750 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
15751 {
15752 // report middle speed
15753 rssidx = 2;
15754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015755 else
15756 {
15757 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015758 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070015759 }
15760 }
15761 else
15762 {
15763 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
15764 hddLog(VOS_TRACE_LEVEL_ERROR,
15765 "%s: Invalid value for reportMaxLinkSpeed: %u",
15766 __func__, pCfg->reportMaxLinkSpeed);
15767 rssidx = 0;
15768 }
15769
15770 maxRate = 0;
15771
15772 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015773 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
15774 OperationalRates, &ORLeng))
15775 {
15776 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15777 /*To keep GUI happy*/
15778 return 0;
15779 }
15780
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 for (i = 0; i < ORLeng; i++)
15782 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015783 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 {
15785 /* Validate Rate Set */
15786 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
15787 {
15788 currentRate = supported_data_rate[j].supported_rate[rssidx];
15789 break;
15790 }
15791 }
15792 /* Update MAX rate */
15793 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15794 }
15795
15796 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015797 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
15798 ExtendedRates, &ERLeng))
15799 {
15800 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15801 /*To keep GUI happy*/
15802 return 0;
15803 }
15804
Jeff Johnson295189b2012-06-20 16:38:30 -070015805 for (i = 0; i < ERLeng; i++)
15806 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015807 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 {
15809 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
15810 {
15811 currentRate = supported_data_rate[j].supported_rate[rssidx];
15812 break;
15813 }
15814 }
15815 /* Update MAX rate */
15816 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15817 }
c_hpothu79aab322014-07-14 21:11:01 +053015818
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015819 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053015820 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015821 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053015822 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070015823 {
c_hpothu79aab322014-07-14 21:11:01 +053015824 if (rate_flags & eHAL_TX_RATE_VHT80)
15825 mode = 2;
15826 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
15827 mode = 1;
15828 else
15829 mode = 0;
15830
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015831 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
15832 MCSRates, &MCSLeng))
15833 {
15834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15835 /*To keep GUI happy*/
15836 return 0;
15837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015838 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070015839#ifdef WLAN_FEATURE_11AC
15840 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015841 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015843 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015844 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070015845 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070015846 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015847 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015848 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015849 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070015850 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015851 maxMCSIdx = 7;
15852 }
15853 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
15854 {
15855 maxMCSIdx = 8;
15856 }
15857 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
15858 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015859 //VHT20 is supporting 0~8
15860 if (rate_flags & eHAL_TX_RATE_VHT20)
15861 maxMCSIdx = 8;
15862 else
15863 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070015864 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015865
c_hpothu79aab322014-07-14 21:11:01 +053015866 if (0 != rssidx)/*check for scaled */
15867 {
15868 //get middle rate MCS index if rssi=1/2
15869 for (i=0; i <= maxMCSIdx; i++)
15870 {
15871 if (sinfo->signal <= rssiMcsTbl[mode][i])
15872 {
15873 maxMCSIdx = i;
15874 break;
15875 }
15876 }
15877 }
15878
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015879 if (rate_flags & eHAL_TX_RATE_VHT80)
15880 {
15881 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
15882 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
15883 }
15884 else if (rate_flags & eHAL_TX_RATE_VHT40)
15885 {
15886 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
15887 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
15888 }
15889 else if (rate_flags & eHAL_TX_RATE_VHT20)
15890 {
15891 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
15892 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
15893 }
15894
Leo Chang6f8870f2013-03-26 18:11:36 -070015895 maxSpeedMCS = 1;
15896 if (currentRate > maxRate)
15897 {
15898 maxRate = currentRate;
15899 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015900
Leo Chang6f8870f2013-03-26 18:11:36 -070015901 }
15902 else
15903#endif /* WLAN_FEATURE_11AC */
15904 {
15905 if (rate_flags & eHAL_TX_RATE_HT40)
15906 {
15907 rateFlag |= 1;
15908 }
15909 if (rate_flags & eHAL_TX_RATE_SGI)
15910 {
15911 rateFlag |= 2;
15912 }
15913
Girish Gowli01abcee2014-07-31 20:18:55 +053015914 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053015915 if (rssidx == 1 || rssidx == 2)
15916 {
15917 //get middle rate MCS index if rssi=1/2
15918 for (i=0; i <= 7; i++)
15919 {
15920 if (sinfo->signal <= rssiMcsTbl[mode][i])
15921 {
15922 temp = i+1;
15923 break;
15924 }
15925 }
15926 }
c_hpothu79aab322014-07-14 21:11:01 +053015927
15928 for (i = 0; i < MCSLeng; i++)
15929 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015930 for (j = 0; j < temp; j++)
15931 {
15932 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
15933 {
15934 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015935 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015936 break;
15937 }
15938 }
15939 if ((j < temp) && (currentRate > maxRate))
15940 {
15941 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070015942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015944 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015945 }
15946 }
15947
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015948 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
15949 {
15950 maxRate = myRate;
15951 maxSpeedMCS = 1;
15952 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053015955 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070015956 {
15957 maxRate = myRate;
15958 if (rate_flags & eHAL_TX_RATE_LEGACY)
15959 {
15960 maxSpeedMCS = 0;
15961 }
15962 else
15963 {
15964 maxSpeedMCS = 1;
15965 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15966 }
15967 }
15968
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015969 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070015970 {
15971 sinfo->txrate.legacy = maxRate;
15972#ifdef LINKSPEED_DEBUG_ENABLED
15973 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
15974#endif //LINKSPEED_DEBUG_ENABLED
15975 }
15976 else
15977 {
15978 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070015979#ifdef WLAN_FEATURE_11AC
15980 sinfo->txrate.nss = 1;
15981 if (rate_flags & eHAL_TX_RATE_VHT80)
15982 {
15983 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015984 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070015985 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015986 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070015987 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015988 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15989 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15990 }
15991 else if (rate_flags & eHAL_TX_RATE_VHT20)
15992 {
15993 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15994 }
15995#endif /* WLAN_FEATURE_11AC */
15996 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
15997 {
15998 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15999 if (rate_flags & eHAL_TX_RATE_HT40)
16000 {
16001 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16002 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 if (rate_flags & eHAL_TX_RATE_SGI)
16005 {
16006 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16007 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053016008
Jeff Johnson295189b2012-06-20 16:38:30 -070016009#ifdef LINKSPEED_DEBUG_ENABLED
16010 pr_info("Reporting MCS rate %d flags %x\n",
16011 sinfo->txrate.mcs,
16012 sinfo->txrate.flags );
16013#endif //LINKSPEED_DEBUG_ENABLED
16014 }
16015 }
16016 else
16017 {
16018 // report current rate instead of max rate
16019
16020 if (rate_flags & eHAL_TX_RATE_LEGACY)
16021 {
16022 //provide to the UI in units of 100kbps
16023 sinfo->txrate.legacy = myRate;
16024#ifdef LINKSPEED_DEBUG_ENABLED
16025 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
16026#endif //LINKSPEED_DEBUG_ENABLED
16027 }
16028 else
16029 {
16030 //must be MCS
16031 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070016032#ifdef WLAN_FEATURE_11AC
16033 sinfo->txrate.nss = 1;
16034 if (rate_flags & eHAL_TX_RATE_VHT80)
16035 {
16036 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
16037 }
16038 else
16039#endif /* WLAN_FEATURE_11AC */
16040 {
16041 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
16042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 if (rate_flags & eHAL_TX_RATE_SGI)
16044 {
16045 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
16046 }
16047 if (rate_flags & eHAL_TX_RATE_HT40)
16048 {
16049 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
16050 }
Leo Chang6f8870f2013-03-26 18:11:36 -070016051#ifdef WLAN_FEATURE_11AC
16052 else if (rate_flags & eHAL_TX_RATE_VHT80)
16053 {
16054 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
16055 }
16056#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070016057#ifdef LINKSPEED_DEBUG_ENABLED
16058 pr_info("Reporting actual MCS rate %d flags %x\n",
16059 sinfo->txrate.mcs,
16060 sinfo->txrate.flags );
16061#endif //LINKSPEED_DEBUG_ENABLED
16062 }
16063 }
16064 sinfo->filled |= STATION_INFO_TX_BITRATE;
16065
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016066 sinfo->tx_packets =
16067 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
16068 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
16069 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
16070 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
16071
16072 sinfo->tx_retries =
16073 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
16074 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
16075 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
16076 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
16077
16078 sinfo->tx_failed =
16079 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
16080 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
16081 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
16082 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
16083
16084 sinfo->filled |=
16085 STATION_INFO_TX_PACKETS |
16086 STATION_INFO_TX_RETRIES |
16087 STATION_INFO_TX_FAILED;
16088
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053016089 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
16090 sinfo->filled |= STATION_INFO_RX_PACKETS;
16091
16092 if (rate_flags & eHAL_TX_RATE_LEGACY)
16093 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
16094 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
16095 sinfo->rx_packets);
16096 else
16097 hddLog(LOG1,
16098 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
16099 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
16100 sinfo->tx_packets, sinfo->rx_packets);
16101
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016102 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16103 TRACE_CODE_HDD_CFG80211_GET_STA,
16104 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070016105 EXIT();
16106 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016107}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016108#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16109static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16110 const u8* mac, struct station_info *sinfo)
16111#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016112static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
16113 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016114#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016115{
16116 int ret;
16117
16118 vos_ssr_protect(__func__);
16119 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
16120 vos_ssr_unprotect(__func__);
16121
16122 return ret;
16123}
16124
16125static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070016126 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070016127{
16128 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016129 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070016130 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016131 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016132
Jeff Johnsone7245742012-09-05 17:12:55 -070016133 ENTER();
16134
Jeff Johnson295189b2012-06-20 16:38:30 -070016135 if (NULL == pAdapter)
16136 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016137 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016138 return -ENODEV;
16139 }
16140
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016141 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16142 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
16143 pAdapter->sessionId, timeout));
16144
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016145 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016146 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016147 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016148 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016149 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016150 }
16151
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016152 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
16153 (TRUE == pHddCtx->hdd_wlan_suspended) &&
16154 (pHddCtx->cfg_ini->fhostArpOffload) &&
16155 (eConnectionState_Associated ==
16156 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
16157 {
Amar Singhald53568e2013-09-26 11:03:45 -070016158
16159 hddLog(VOS_TRACE_LEVEL_INFO,
16160 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053016161 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016162 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16163 {
16164 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080016165 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053016166 __func__, vos_status);
16167 }
16168 }
16169
Jeff Johnson295189b2012-06-20 16:38:30 -070016170 /**The get power cmd from the supplicant gets updated by the nl only
16171 *on successful execution of the function call
16172 *we are oppositely mapped w.r.t mode in the driver
16173 **/
16174 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
16175
16176 if (VOS_STATUS_E_FAILURE == vos_status)
16177 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16179 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016180 return -EINVAL;
16181 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016182 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070016183 return 0;
16184}
16185
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016186static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16187 struct net_device *dev, bool mode, int timeout)
16188{
16189 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016190
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016191 vos_ssr_protect(__func__);
16192 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
16193 vos_ssr_unprotect(__func__);
16194
16195 return ret;
16196}
Sushant Kaushik084f6592015-09-10 13:11:56 +053016197
Jeff Johnson295189b2012-06-20 16:38:30 -070016198#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016199static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
16200 struct net_device *netdev,
16201 u8 key_index)
16202{
16203 ENTER();
16204 return 0;
16205}
16206
Jeff Johnson295189b2012-06-20 16:38:30 -070016207static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016208 struct net_device *netdev,
16209 u8 key_index)
16210{
16211 int ret;
16212 vos_ssr_protect(__func__);
16213 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16214 vos_ssr_unprotect(__func__);
16215 return ret;
16216}
16217#endif //LINUX_VERSION_CODE
16218
16219#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16220static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16221 struct net_device *dev,
16222 struct ieee80211_txq_params *params)
16223{
16224 ENTER();
16225 return 0;
16226}
16227#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16228static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16229 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016230{
Jeff Johnsone7245742012-09-05 17:12:55 -070016231 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016232 return 0;
16233}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016234#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016235
16236#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16237static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016238 struct net_device *dev,
16239 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016240{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016241 int ret;
16242
16243 vos_ssr_protect(__func__);
16244 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16245 vos_ssr_unprotect(__func__);
16246 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016247}
16248#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16249static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16250 struct ieee80211_txq_params *params)
16251{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016252 int ret;
16253
16254 vos_ssr_protect(__func__);
16255 ret = __wlan_hdd_set_txq_params(wiphy, params);
16256 vos_ssr_unprotect(__func__);
16257 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016258}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016260
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016261static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016262 struct net_device *dev,
16263 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016264{
16265 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016266 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016267 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016268 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016269 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016270 v_CONTEXT_t pVosContext = NULL;
16271 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016272
Jeff Johnsone7245742012-09-05 17:12:55 -070016273 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016274
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016275 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016276 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016277 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016278 return -EINVAL;
16279 }
16280
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016281 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16282 TRACE_CODE_HDD_CFG80211_DEL_STA,
16283 pAdapter->sessionId, pAdapter->device_mode));
16284
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016285 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16286 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016287 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016288 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016289 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016290 }
16291
Jeff Johnson295189b2012-06-20 16:38:30 -070016292 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016293 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 )
16295 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016296 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16297 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16298 if(pSapCtx == NULL){
16299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16300 FL("psapCtx is NULL"));
16301 return -ENOENT;
16302 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016303 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016304 {
16305 v_U16_t i;
16306 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16307 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016308 if ((pSapCtx->aStaInfo[i].isUsed) &&
16309 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016311 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016312 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016313 ETHER_ADDR_LEN);
16314
Jeff Johnson295189b2012-06-20 16:38:30 -070016315 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016316 "%s: Delete STA with MAC::"
16317 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016318 __func__,
16319 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16320 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016321 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016322 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016323 }
16324 }
16325 }
16326 else
16327 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016328
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016329 vos_status = hdd_softap_GetStaId(pAdapter,
16330 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016331 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16332 {
16333 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016334 "%s: Skip this DEL STA as this is not used::"
16335 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016336 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016337 return -ENOENT;
16338 }
16339
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016340 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016341 {
16342 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016343 "%s: Skip this DEL STA as deauth is in progress::"
16344 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016345 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016346 return -ENOENT;
16347 }
16348
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016349 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016350
Jeff Johnson295189b2012-06-20 16:38:30 -070016351 hddLog(VOS_TRACE_LEVEL_INFO,
16352 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016353 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016355 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016356
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016357 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016358 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16359 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016360 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016361 hddLog(VOS_TRACE_LEVEL_INFO,
16362 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016363 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016364 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016365 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016366 return -ENOENT;
16367 }
16368
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 }
16370 }
16371
16372 EXIT();
16373
16374 return 0;
16375}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016376
16377#ifdef CFG80211_DEL_STA_V2
16378static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16379 struct net_device *dev,
16380 struct station_del_parameters *param)
16381#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016382#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16383static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16384 struct net_device *dev, const u8 *mac)
16385#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016386static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16387 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016388#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016389#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016390{
16391 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016392 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016393
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016394 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016395
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016396#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016397 if (NULL == param) {
16398 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016399 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016400 return -EINVAL;
16401 }
16402
16403 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16404 param->subtype, &delStaParams);
16405
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016406#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016407 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016408 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016409#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016410 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16411
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016412 vos_ssr_unprotect(__func__);
16413
16414 return ret;
16415}
16416
16417static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016418 struct net_device *dev,
16419#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16420 const u8 *mac,
16421#else
16422 u8 *mac,
16423#endif
16424 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016425{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016426 hdd_adapter_t *pAdapter;
16427 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016428 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016429#ifdef FEATURE_WLAN_TDLS
16430 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016431
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016432 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016433
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016434 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16435 if (NULL == pAdapter)
16436 {
16437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16438 "%s: Adapter is NULL",__func__);
16439 return -EINVAL;
16440 }
16441 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16442 status = wlan_hdd_validate_context(pHddCtx);
16443 if (0 != status)
16444 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016445 return status;
16446 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016447
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016448 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16449 TRACE_CODE_HDD_CFG80211_ADD_STA,
16450 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016451 mask = params->sta_flags_mask;
16452
16453 set = params->sta_flags_set;
16454
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016456 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16457 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016458
16459 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16460 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016461 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016462 }
16463 }
16464#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016465 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016466 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016467}
16468
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016469#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16470static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16471 struct net_device *dev, const u8 *mac,
16472 struct station_parameters *params)
16473#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016474static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16475 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016476#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016477{
16478 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016479
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016480 vos_ssr_protect(__func__);
16481 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16482 vos_ssr_unprotect(__func__);
16483
16484 return ret;
16485}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016486#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016487
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016488static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016489 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016490{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016491 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16492 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016493 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016494 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016495 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016496 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016497
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016498 ENTER();
16499
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016500 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016501 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016502 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016503 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016504 return -EINVAL;
16505 }
16506
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016507 if (!pmksa) {
16508 hddLog(LOGE, FL("pmksa is NULL"));
16509 return -EINVAL;
16510 }
16511
16512 if (!pmksa->bssid || !pmksa->pmkid) {
16513 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
16514 pmksa->bssid, pmksa->pmkid);
16515 return -EINVAL;
16516 }
16517
16518 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
16519 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16520
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16522 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016523 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016524 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016525 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016526 }
16527
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016528 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016529 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16530
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016531 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
16532 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016533
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016534 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016535 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016536 &pmk_id, 1, FALSE);
16537
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016538 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16539 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
16540 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016541
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016542 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016543 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016544}
16545
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016546static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
16547 struct cfg80211_pmksa *pmksa)
16548{
16549 int ret;
16550
16551 vos_ssr_protect(__func__);
16552 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
16553 vos_ssr_unprotect(__func__);
16554
16555 return ret;
16556}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016557
Wilson Yang6507c4e2013-10-01 20:11:19 -070016558
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016559static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070016560 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016561{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016562 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16563 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016564 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016565 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016566
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016567 ENTER();
16568
Wilson Yang6507c4e2013-10-01 20:11:19 -070016569 /* Validate pAdapter */
16570 if (NULL == pAdapter)
16571 {
16572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
16573 return -EINVAL;
16574 }
16575
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016576 if (!pmksa) {
16577 hddLog(LOGE, FL("pmksa is NULL"));
16578 return -EINVAL;
16579 }
16580
16581 if (!pmksa->bssid) {
16582 hddLog(LOGE, FL("pmksa->bssid is NULL"));
16583 return -EINVAL;
16584 }
16585
Kiet Lam98c46a12014-10-31 15:34:57 -070016586 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
16587 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16588
Wilson Yang6507c4e2013-10-01 20:11:19 -070016589 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16590 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016591 if (0 != status)
16592 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016593 return status;
16594 }
16595
16596 /*Retrieve halHandle*/
16597 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16598
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016599 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16600 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
16601 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016602 /* Delete the PMKID CSR cache */
16603 if (eHAL_STATUS_SUCCESS !=
16604 sme_RoamDelPMKIDfromCache(halHandle,
16605 pAdapter->sessionId, pmksa->bssid, FALSE)) {
16606 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
16607 MAC_ADDR_ARRAY(pmksa->bssid));
16608 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016609 }
16610
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016611 EXIT();
16612 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016613}
16614
Wilson Yang6507c4e2013-10-01 20:11:19 -070016615
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016616static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
16617 struct cfg80211_pmksa *pmksa)
16618{
16619 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016620
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016621 vos_ssr_protect(__func__);
16622 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
16623 vos_ssr_unprotect(__func__);
16624
16625 return ret;
16626
16627}
16628
16629static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016630{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16632 tHalHandle halHandle;
16633 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016634 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016635
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016636 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070016637
16638 /* Validate pAdapter */
16639 if (NULL == pAdapter)
16640 {
16641 hddLog(VOS_TRACE_LEVEL_ERROR,
16642 "%s: Invalid Adapter" ,__func__);
16643 return -EINVAL;
16644 }
16645
16646 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16647 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016648 if (0 != status)
16649 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016650 return status;
16651 }
16652
16653 /*Retrieve halHandle*/
16654 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16655
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016656 /* Flush the PMKID cache in CSR */
16657 if (eHAL_STATUS_SUCCESS !=
16658 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
16659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
16660 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016661 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016662 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080016663 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016664}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016665
16666static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
16667{
16668 int ret;
16669
16670 vos_ssr_protect(__func__);
16671 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
16672 vos_ssr_unprotect(__func__);
16673
16674 return ret;
16675}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016676#endif
16677
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016678#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016679static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16680 struct net_device *dev,
16681 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016682{
16683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16684 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016685 hdd_context_t *pHddCtx;
16686 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016688 ENTER();
16689
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016690 if (NULL == pAdapter)
16691 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016692 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016693 return -ENODEV;
16694 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016695 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16696 ret = wlan_hdd_validate_context(pHddCtx);
16697 if (0 != ret)
16698 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016699 return ret;
16700 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016701 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016702 if (NULL == pHddStaCtx)
16703 {
16704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
16705 return -EINVAL;
16706 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016707
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016708 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16709 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
16710 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016711 // Added for debug on reception of Re-assoc Req.
16712 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
16713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016714 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016715 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080016716 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016717 }
16718
16719#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080016720 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016721 ftie->ie_len);
16722#endif
16723
16724 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016725 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
16726 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016727 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016728
16729 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016730 return 0;
16731}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016732
16733static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16734 struct net_device *dev,
16735 struct cfg80211_update_ft_ies_params *ftie)
16736{
16737 int ret;
16738
16739 vos_ssr_protect(__func__);
16740 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
16741 vos_ssr_unprotect(__func__);
16742
16743 return ret;
16744}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016745#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016746
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016747#ifdef FEATURE_WLAN_SCAN_PNO
16748
16749void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
16750 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
16751{
16752 int ret;
16753 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
16754 hdd_context_t *pHddCtx;
16755
Nirav Shah80830bf2013-12-31 16:35:12 +053016756 ENTER();
16757
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016758 if (NULL == pAdapter)
16759 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016761 "%s: HDD adapter is Null", __func__);
16762 return ;
16763 }
16764
16765 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16766 if (NULL == pHddCtx)
16767 {
16768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16769 "%s: HDD context is Null!!!", __func__);
16770 return ;
16771 }
16772
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016773 spin_lock(&pHddCtx->schedScan_lock);
16774 if (TRUE == pHddCtx->isWiphySuspended)
16775 {
16776 pHddCtx->isSchedScanUpdatePending = TRUE;
16777 spin_unlock(&pHddCtx->schedScan_lock);
16778 hddLog(VOS_TRACE_LEVEL_INFO,
16779 "%s: Update cfg80211 scan database after it resume", __func__);
16780 return ;
16781 }
16782 spin_unlock(&pHddCtx->schedScan_lock);
16783
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016784 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
16785
16786 if (0 > ret)
16787 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053016788 else
16789 {
16790 /* Acquire wakelock to handle the case where APP's tries to suspend
16791 * immediatly after the driver gets connect request(i.e after pno)
16792 * from supplicant, this result in app's is suspending and not able
16793 * to process the connect request to AP */
16794 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
16795 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016796 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16798 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016799}
16800
16801/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016802 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016803 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016804 */
16805static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
16806{
16807 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
16808 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016809 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016810 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16811 int status = 0;
16812 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
16813
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016814 /* The current firmware design does not allow PNO during any
16815 * active sessions. Hence, determine the active sessions
16816 * and return a failure.
16817 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016818 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
16819 {
16820 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016821 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016822
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016823 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
16824 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
16825 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
16826 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
16827 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053016828 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016829 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016830 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016831 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016832 }
16833 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16834 pAdapterNode = pNext;
16835 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016836 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016837}
16838
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016839void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
16840{
16841 hdd_adapter_t *pAdapter = callbackContext;
16842 hdd_context_t *pHddCtx;
16843
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016844 ENTER();
16845
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016846 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
16847 {
16848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16849 FL("Invalid adapter or adapter has invalid magic"));
16850 return;
16851 }
16852
16853 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16854 if (0 != wlan_hdd_validate_context(pHddCtx))
16855 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016856 return;
16857 }
16858
c_hpothub53c45d2014-08-18 16:53:14 +053016859 if (VOS_STATUS_SUCCESS != status)
16860 {
16861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016862 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053016863 pHddCtx->isPnoEnable = FALSE;
16864 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016865
16866 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
16867 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016868 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016869}
16870
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016871/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016872 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
16873 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016874 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016875static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016876 struct net_device *dev, struct cfg80211_sched_scan_request *request)
16877{
16878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016879 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016880 hdd_context_t *pHddCtx;
16881 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016882 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053016883 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
16884 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016885 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
16886 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016887 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016888 hdd_config_t *pConfig = NULL;
16889 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016890
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016891 ENTER();
16892
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016893 if (NULL == pAdapter)
16894 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016896 "%s: HDD adapter is Null", __func__);
16897 return -ENODEV;
16898 }
16899
16900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016901 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016902
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016903 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016904 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016905 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016906 }
16907
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016908 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016909 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16910 if (NULL == hHal)
16911 {
16912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16913 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016914 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016915 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016916 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16917 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
16918 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053016919 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016920 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053016921 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016922 {
16923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16924 "%s: aborting the existing scan is unsuccessfull", __func__);
16925 return -EBUSY;
16926 }
16927
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016928 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016929 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016931 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016932 return -EBUSY;
16933 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016934
c_hpothu37f21312014-04-09 21:49:54 +053016935 if (TRUE == pHddCtx->isPnoEnable)
16936 {
16937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16938 FL("already PNO is enabled"));
16939 return -EBUSY;
16940 }
c_hpothu225aa7c2014-10-22 17:45:13 +053016941
16942 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
16943 {
16944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16945 "%s: abort ROC failed ", __func__);
16946 return -EBUSY;
16947 }
16948
c_hpothu37f21312014-04-09 21:49:54 +053016949 pHddCtx->isPnoEnable = TRUE;
16950
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016951 pnoRequest.enable = 1; /*Enable PNO */
16952 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016953
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016954 if (( !pnoRequest.ucNetworksCount ) ||
16955 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016956 {
16957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016958 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016959 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016960 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016961 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016962 goto error;
16963 }
16964
16965 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
16966 {
16967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016968 "%s: Incorrect number of channels %d",
16969 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016970 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016971 goto error;
16972 }
16973
16974 /* Framework provides one set of channels(all)
16975 * common for all saved profile */
16976 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
16977 channels_allowed, &num_channels_allowed))
16978 {
16979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16980 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016981 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016982 goto error;
16983 }
16984 /* Checking each channel against allowed channel list */
16985 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053016986 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016987 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016988 char chList [(request->n_channels*5)+1];
16989 int len;
16990 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016991 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016992 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016993 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016994 if (request->channels[i]->hw_value == channels_allowed[indx])
16995 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016996 if ((!pConfig->enableDFSPnoChnlScan) &&
16997 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
16998 {
16999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17000 "%s : Dropping DFS channel : %d",
17001 __func__,channels_allowed[indx]);
17002 num_ignore_dfs_ch++;
17003 break;
17004 }
17005
Nirav Shah80830bf2013-12-31 16:35:12 +053017006 valid_ch[num_ch++] = request->channels[i]->hw_value;
17007 len += snprintf(chList+len, 5, "%d ",
17008 request->channels[i]->hw_value);
17009 break ;
17010 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017011 }
17012 }
Nirav Shah80830bf2013-12-31 16:35:12 +053017013 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017014
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053017015 /*If all channels are DFS and dropped, then ignore the PNO request*/
17016 if (num_ignore_dfs_ch == request->n_channels)
17017 {
17018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17019 "%s : All requested channels are DFS channels", __func__);
17020 ret = -EINVAL;
17021 goto error;
17022 }
17023 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017024
17025 pnoRequest.aNetworks =
17026 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17027 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017028 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017029 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17030 FL("failed to allocate memory aNetworks %u"),
17031 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17032 goto error;
17033 }
17034 vos_mem_zero(pnoRequest.aNetworks,
17035 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
17036
17037 /* Filling per profile params */
17038 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
17039 {
17040 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017041 request->match_sets[i].ssid.ssid_len;
17042
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017043 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
17044 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017045 {
17046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017047 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017048 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017049 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017050 goto error;
17051 }
17052
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017053 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017054 request->match_sets[i].ssid.ssid,
17055 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053017056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17057 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017058 i, pnoRequest.aNetworks[i].ssId.ssId);
17059 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
17060 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
17061 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017062
17063 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017064 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
17065 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017066
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017067 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017068 }
17069
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017070 for (i = 0; i < request->n_ssids; i++)
17071 {
17072 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017073 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017074 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017075 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017076 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017077 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017078 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017079 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017080 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017081 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053017082 break;
17083 }
17084 j++;
17085 }
17086 }
17087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17088 "Number of hidden networks being Configured = %d",
17089 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080017091 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017092
17093 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17094 if (pnoRequest.p24GProbeTemplate == NULL)
17095 {
17096 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17097 FL("failed to allocate memory p24GProbeTemplate %u"),
17098 SIR_PNO_MAX_PB_REQ_SIZE);
17099 goto error;
17100 }
17101
17102 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
17103 if (pnoRequest.p5GProbeTemplate == NULL)
17104 {
17105 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17106 FL("failed to allocate memory p5GProbeTemplate %u"),
17107 SIR_PNO_MAX_PB_REQ_SIZE);
17108 goto error;
17109 }
17110
17111 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17112 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
17113
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053017114 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
17115 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017116 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017117 pnoRequest.us24GProbeTemplateLen = request->ie_len;
17118 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
17119 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017120
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017121 pnoRequest.us5GProbeTemplateLen = request->ie_len;
17122 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
17123 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053017124 }
17125
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017126 /* Driver gets only one time interval which is hardcoded in
17127 * supplicant for 10000ms. Taking power consumption into account 6 timers
17128 * will be used, Timervalue is increased exponentially i.e 10,20,40,
17129 * 80,160,320 secs. And number of scan cycle for each timer
17130 * is configurable through INI param gPNOScanTimerRepeatValue.
17131 * If it is set to 0 only one timer will be used and PNO scan cycle
17132 * will be repeated after each interval specified by supplicant
17133 * till PNO is disabled.
17134 */
17135 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017136 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017137 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017138 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017139 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
17140
17141 tempInterval = (request->interval)/1000;
17142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17143 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
17144 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017145 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017146 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017147 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017148 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017149 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017150 tempInterval *= 2;
17151 }
17152 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017153 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053017154
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017155 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017156
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017157 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017158 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17159 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017160 pAdapter->pno_req_status = 0;
17161
Nirav Shah80830bf2013-12-31 16:35:12 +053017162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17163 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017164 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
17165 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053017166
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017167 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017168 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017169 hdd_cfg80211_sched_scan_done_callback, pAdapter);
17170 if (eHAL_STATUS_SUCCESS != status)
17171 {
17172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053017173 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017174 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017175 goto error;
17176 }
17177
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017178 ret = wait_for_completion_timeout(
17179 &pAdapter->pno_comp_var,
17180 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17181 if (0 >= ret)
17182 {
17183 // Did not receive the response for PNO enable in time.
17184 // Assuming the PNO enable was success.
17185 // Returning error from here, because we timeout, results
17186 // in side effect of Wifi (Wifi Setting) not to work.
17187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17188 FL("Timed out waiting for PNO to be Enabled"));
17189 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017190 }
17191
17192 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053017193 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017194
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017195error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17197 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053017198 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017199 if (pnoRequest.aNetworks)
17200 vos_mem_free(pnoRequest.aNetworks);
17201 if (pnoRequest.p24GProbeTemplate)
17202 vos_mem_free(pnoRequest.p24GProbeTemplate);
17203 if (pnoRequest.p5GProbeTemplate)
17204 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017205
17206 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017207 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017208}
17209
17210/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017211 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17212 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017213 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017214static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17215 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17216{
17217 int ret;
17218
17219 vos_ssr_protect(__func__);
17220 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17221 vos_ssr_unprotect(__func__);
17222
17223 return ret;
17224}
17225
17226/*
17227 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17228 * Function to disable PNO
17229 */
17230static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017231 struct net_device *dev)
17232{
17233 eHalStatus status = eHAL_STATUS_FAILURE;
17234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17235 hdd_context_t *pHddCtx;
17236 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017237 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017238 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017239
17240 ENTER();
17241
17242 if (NULL == pAdapter)
17243 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017245 "%s: HDD adapter is Null", __func__);
17246 return -ENODEV;
17247 }
17248
17249 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017250
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017251 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017252 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017254 "%s: HDD context is Null", __func__);
17255 return -ENODEV;
17256 }
17257
17258 /* The return 0 is intentional when isLogpInProgress and
17259 * isLoadUnloadInProgress. We did observe a crash due to a return of
17260 * failure in sched_scan_stop , especially for a case where the unload
17261 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17262 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17263 * success. If it returns a failure , then its next invocation due to the
17264 * clean up of the second interface will have the dev pointer corresponding
17265 * to the first one leading to a crash.
17266 */
17267 if (pHddCtx->isLogpInProgress)
17268 {
17269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17270 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017271 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017272 return ret;
17273 }
17274
Mihir Shete18156292014-03-11 15:38:30 +053017275 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017276 {
17277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17278 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17279 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017280 }
17281
17282 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17283 if (NULL == hHal)
17284 {
17285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17286 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017287 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017288 }
17289
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017290 pnoRequest.enable = 0; /* Disable PNO */
17291 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017292
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017293 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17294 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17295 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017296
17297 INIT_COMPLETION(pAdapter->pno_comp_var);
17298 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17299 pnoRequest.callbackContext = pAdapter;
17300 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017301 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017302 pAdapter->sessionId,
17303 NULL, pAdapter);
17304 if (eHAL_STATUS_SUCCESS != status)
17305 {
17306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17307 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017308 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017309 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017310 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017311 ret = wait_for_completion_timeout(
17312 &pAdapter->pno_comp_var,
17313 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17314 if (0 >= ret)
17315 {
17316 // Did not receive the response for PNO disable in time.
17317 // Assuming the PNO disable was success.
17318 // Returning error from here, because we timeout, results
17319 // in side effect of Wifi (Wifi Setting) not to work.
17320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17321 FL("Timed out waiting for PNO to be disabled"));
17322 ret = 0;
17323 }
17324
17325 ret = pAdapter->pno_req_status;
17326 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017327
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017328error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017329 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017330 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017331
17332 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017333 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017334}
17335
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017336/*
17337 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17338 * NL interface to disable PNO
17339 */
17340static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17341 struct net_device *dev)
17342{
17343 int ret;
17344
17345 vos_ssr_protect(__func__);
17346 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17347 vos_ssr_unprotect(__func__);
17348
17349 return ret;
17350}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017351#endif /*FEATURE_WLAN_SCAN_PNO*/
17352
17353
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017354#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017355#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017356static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17357 struct net_device *dev,
17358 u8 *peer, u8 action_code,
17359 u8 dialog_token,
17360 u16 status_code, u32 peer_capability,
17361 const u8 *buf, size_t len)
17362#else /* TDLS_MGMT_VERSION2 */
17363#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17364static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17365 struct net_device *dev,
17366 const u8 *peer, u8 action_code,
17367 u8 dialog_token, u16 status_code,
17368 u32 peer_capability, bool initiator,
17369 const u8 *buf, size_t len)
17370#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17371static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17372 struct net_device *dev,
17373 const u8 *peer, u8 action_code,
17374 u8 dialog_token, u16 status_code,
17375 u32 peer_capability, const u8 *buf,
17376 size_t len)
17377#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17378static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17379 struct net_device *dev,
17380 u8 *peer, u8 action_code,
17381 u8 dialog_token,
17382 u16 status_code, u32 peer_capability,
17383 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017384#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017385static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17386 struct net_device *dev,
17387 u8 *peer, u8 action_code,
17388 u8 dialog_token,
17389 u16 status_code, const u8 *buf,
17390 size_t len)
17391#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017392#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017393{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017394 hdd_adapter_t *pAdapter;
17395 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017396 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017397 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017398 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017399 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017400 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017401 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017402#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017403 u32 peer_capability = 0;
17404#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017405 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017406 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017407
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017408 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17409 if (NULL == pAdapter)
17410 {
17411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17412 "%s: Adapter is NULL",__func__);
17413 return -EINVAL;
17414 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017415 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17416 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17417 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017418
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017419 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017420 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017421 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017423 "Invalid arguments");
17424 return -EINVAL;
17425 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017426
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017427 if (pHddCtx->isLogpInProgress)
17428 {
17429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17430 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017431 wlan_hdd_tdls_set_link_status(pAdapter,
17432 peer,
17433 eTDLS_LINK_IDLE,
17434 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017435 return -EBUSY;
17436 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017437
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017438 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17439 {
17440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17441 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17442 return -EAGAIN;
17443 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017444
Hoonki Lee27511902013-03-14 18:19:06 -070017445 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017446 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017448 "%s: TDLS mode is disabled OR not enabled in FW."
17449 MAC_ADDRESS_STR " action %d declined.",
17450 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017451 return -ENOTSUPP;
17452 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017453
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017454 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17455
17456 if( NULL == pHddStaCtx )
17457 {
17458 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17459 "%s: HDD station context NULL ",__func__);
17460 return -EINVAL;
17461 }
17462
17463 /* STA should be connected and authenticated
17464 * before sending any TDLS frames
17465 */
17466 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
17467 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
17468 {
17469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17470 "STA is not connected or unauthenticated. "
17471 "connState %u, uIsAuthenticated %u",
17472 pHddStaCtx->conn_info.connState,
17473 pHddStaCtx->conn_info.uIsAuthenticated);
17474 return -EAGAIN;
17475 }
17476
Hoonki Lee27511902013-03-14 18:19:06 -070017477 /* other than teardown frame, other mgmt frames are not sent if disabled */
17478 if (SIR_MAC_TDLS_TEARDOWN != action_code)
17479 {
17480 /* if tdls_mode is disabled to respond to peer's request */
17481 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
17482 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017483 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017484 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017485 " TDLS mode is disabled. action %d declined.",
17486 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070017487
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017488 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070017489 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053017490
17491 if (vos_max_concurrent_connections_reached())
17492 {
17493 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17494 return -EINVAL;
17495 }
Hoonki Lee27511902013-03-14 18:19:06 -070017496 }
17497
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017498 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
17499 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053017500 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017501 {
17502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017503 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017504 " TDLS setup is ongoing. action %d declined.",
17505 __func__, MAC_ADDR_ARRAY(peer), action_code);
17506 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017507 }
17508 }
17509
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017510 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
17511 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080017512 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017513 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17514 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017515 {
17516 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
17517 we return error code at 'add_station()'. Hence we have this
17518 check again in addtion to add_station().
17519 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017520 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017521 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17523 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017524 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
17525 __func__, MAC_ADDR_ARRAY(peer), action_code,
17526 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053017527 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080017528 }
17529 else
17530 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017531 /* maximum reached. tweak to send error code to peer and return
17532 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017533 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17535 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017536 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
17537 __func__, MAC_ADDR_ARRAY(peer), status_code,
17538 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070017539 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017540 /* fall through to send setup resp with failure status
17541 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017542 }
17543 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017544 else
17545 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017546 mutex_lock(&pHddCtx->tdls_lock);
17547 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017548 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017549 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017550 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017552 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
17553 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017554 return -EPERM;
17555 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017556 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017557 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017558 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017559
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017561 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017562 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
17563 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017564
Hoonki Leea34dd892013-02-05 22:56:02 -080017565 /*Except teardown responder will not be used so just make 0*/
17566 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017567 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080017568 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017569
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017570 mutex_lock(&pHddCtx->tdls_lock);
17571 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017572
17573 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
17574 responder = pTdlsPeer->is_responder;
17575 else
Hoonki Leea34dd892013-02-05 22:56:02 -080017576 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017578 "%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 -070017579 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
17580 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017581 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017582 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080017583 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017584 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017585 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017586
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017587 /* Discard TDLS setup if peer is removed by user app */
17588 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
17589 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17590 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
17591 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
17592
17593 mutex_lock(&pHddCtx->tdls_lock);
17594 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17595 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
17596 mutex_unlock(&pHddCtx->tdls_lock);
17597 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
17598 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
17599 MAC_ADDR_ARRAY(peer), action_code);
17600 return -EINVAL;
17601 }
17602 mutex_unlock(&pHddCtx->tdls_lock);
17603 }
17604
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017605 /* For explicit trigger of DIS_REQ come out of BMPS for
17606 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070017607 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Deepthi Gowrif78f1f72016-03-21 13:13:28 +053017608 (SIR_MAC_TDLS_SETUP_CNF== action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017609 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
17610 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070017611 {
17612 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
17613 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017614 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017615 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017616 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
17617 if (status != VOS_STATUS_SUCCESS) {
17618 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
17619 }
Hoonki Lee14621352013-04-16 17:51:19 -070017620 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017621 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017622 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
17624 }
17625 }
Hoonki Lee14621352013-04-16 17:51:19 -070017626 }
17627
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017628 /* make sure doesn't call send_mgmt() while it is pending */
17629 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
17630 {
17631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017632 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017633 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017634 ret = -EBUSY;
17635 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017636 }
17637
17638 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017639 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
17640
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017641 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
17642 pAdapter->sessionId, peer, action_code, dialog_token,
17643 status_code, peer_capability, (tANI_U8 *)buf, len,
17644 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017645
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017646 if (VOS_STATUS_SUCCESS != status)
17647 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17649 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017650 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017651 ret = -EINVAL;
17652 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017653 }
17654
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17656 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
17657 WAIT_TIME_TDLS_MGMT);
17658
Hoonki Leed37cbb32013-04-20 00:31:14 -070017659 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
17660 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
17661
17662 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017663 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070017664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070017665 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070017666 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017667 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080017668
17669 if (pHddCtx->isLogpInProgress)
17670 {
17671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17672 "%s: LOGP in Progress. Ignore!!!", __func__);
17673 return -EAGAIN;
17674 }
Abhishek Singh837adf22015-10-01 17:37:37 +053017675 if (rc <= 0)
17676 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
17677 WLAN_LOG_INDICATOR_HOST_DRIVER,
17678 WLAN_LOG_REASON_HDD_TIME_OUT,
17679 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080017680
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017681 ret = -EINVAL;
17682 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017683 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017684 else
17685 {
17686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17687 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
17688 __func__, rc, pAdapter->mgmtTxCompletionStatus);
17689 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017690
Gopichand Nakkala05922802013-03-14 12:23:19 -070017691 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070017692 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017693 ret = max_sta_failed;
17694 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070017695 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017696
Hoonki Leea34dd892013-02-05 22:56:02 -080017697 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
17698 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017699 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017700 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17701 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017702 }
17703 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
17704 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017705 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017706 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17707 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017708 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017709
17710 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017711
17712tx_failed:
17713 /* add_station will be called before sending TDLS_SETUP_REQ and
17714 * TDLS_SETUP_RSP and as part of add_station driver will enable
17715 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
17716 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
17717 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
17718 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
17719 */
17720
17721 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17722 (SIR_MAC_TDLS_SETUP_RSP == action_code))
17723 wlan_hdd_tdls_check_bmps(pAdapter);
17724 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017725}
17726
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017727#if TDLS_MGMT_VERSION2
17728static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17729 u8 *peer, u8 action_code, u8 dialog_token,
17730 u16 status_code, u32 peer_capability,
17731 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017732#else /* TDLS_MGMT_VERSION2 */
17733#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17734static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17735 struct net_device *dev,
17736 const u8 *peer, u8 action_code,
17737 u8 dialog_token, u16 status_code,
17738 u32 peer_capability, bool initiator,
17739 const u8 *buf, size_t len)
17740#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17741static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17742 struct net_device *dev,
17743 const u8 *peer, u8 action_code,
17744 u8 dialog_token, u16 status_code,
17745 u32 peer_capability, const u8 *buf,
17746 size_t len)
17747#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17748static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17749 struct net_device *dev,
17750 u8 *peer, u8 action_code,
17751 u8 dialog_token,
17752 u16 status_code, u32 peer_capability,
17753 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017754#else
17755static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17756 u8 *peer, u8 action_code, u8 dialog_token,
17757 u16 status_code, const u8 *buf, size_t len)
17758#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017759#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017760{
17761 int ret;
17762
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017763 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017764#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017765 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17766 dialog_token, status_code,
17767 peer_capability, buf, len);
17768#else /* TDLS_MGMT_VERSION2 */
17769#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17770 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17771 dialog_token, status_code,
17772 peer_capability, initiator,
17773 buf, len);
17774#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17775 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17776 dialog_token, status_code,
17777 peer_capability, buf, len);
17778#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17779 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17780 dialog_token, status_code,
17781 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017782#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017783 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17784 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017785#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017786#endif
17787 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017788
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017789 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017790}
Atul Mittal115287b2014-07-08 13:26:33 +053017791
17792int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017793#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17794 const u8 *peer,
17795#else
Atul Mittal115287b2014-07-08 13:26:33 +053017796 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017797#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017798 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053017799 cfg80211_exttdls_callback callback)
17800{
17801
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017802 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053017803 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017804 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053017805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17806 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
17807 __func__, MAC_ADDR_ARRAY(peer));
17808
17809 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17810 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17811
17812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017813 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17814 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17815 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017816 return -ENOTSUPP;
17817 }
17818
17819 /* To cater the requirement of establishing the TDLS link
17820 * irrespective of the data traffic , get an entry of TDLS peer.
17821 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017822 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017823 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
17824 if (pTdlsPeer == NULL) {
17825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17826 "%s: peer " MAC_ADDRESS_STR " not existing",
17827 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017828 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017829 return -EINVAL;
17830 }
17831
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017832 /* check FW TDLS Off Channel capability */
17833 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017834 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017835 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017836 {
17837 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
17838 pTdlsPeer->peerParams.global_operating_class =
17839 tdls_peer_params->global_operating_class;
17840 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
17841 pTdlsPeer->peerParams.min_bandwidth_kbps =
17842 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017843 /* check configured channel is valid, non dfs and
17844 * not current operating channel */
17845 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
17846 tdls_peer_params->channel)) &&
17847 (pHddStaCtx) &&
17848 (tdls_peer_params->channel !=
17849 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017850 {
17851 pTdlsPeer->isOffChannelConfigured = TRUE;
17852 }
17853 else
17854 {
17855 pTdlsPeer->isOffChannelConfigured = FALSE;
17856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17857 "%s: Configured Tdls Off Channel is not valid", __func__);
17858
17859 }
17860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017861 "%s: tdls_off_channel %d isOffChannelConfigured %d "
17862 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017863 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017864 pTdlsPeer->isOffChannelConfigured,
17865 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017866 }
17867 else
17868 {
17869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017870 "%s: TDLS off channel FW capability %d, "
17871 "host capab %d or Invalid TDLS Peer Params", __func__,
17872 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
17873 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017874 }
17875
Atul Mittal115287b2014-07-08 13:26:33 +053017876 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
17877
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017878 mutex_unlock(&pHddCtx->tdls_lock);
17879
Atul Mittal115287b2014-07-08 13:26:33 +053017880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17881 " %s TDLS Add Force Peer Failed",
17882 __func__);
17883 return -EINVAL;
17884 }
17885 /*EXT TDLS*/
17886
17887 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017888 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17890 " %s TDLS set callback Failed",
17891 __func__);
17892 return -EINVAL;
17893 }
17894
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017895 mutex_unlock(&pHddCtx->tdls_lock);
17896
Atul Mittal115287b2014-07-08 13:26:33 +053017897 return(0);
17898
17899}
17900
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017901int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
17902#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17903 const u8 *peer
17904#else
17905 u8 *peer
17906#endif
17907)
Atul Mittal115287b2014-07-08 13:26:33 +053017908{
17909
17910 hddTdlsPeer_t *pTdlsPeer;
17911 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053017912
Atul Mittal115287b2014-07-08 13:26:33 +053017913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17914 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
17915 __func__, MAC_ADDR_ARRAY(peer));
17916
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017917 if (0 != wlan_hdd_validate_context(pHddCtx)) {
17918 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
17919 return -EINVAL;
17920 }
17921
Atul Mittal115287b2014-07-08 13:26:33 +053017922 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17923 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17924
17925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017926 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17927 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17928 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017929 return -ENOTSUPP;
17930 }
17931
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017932 mutex_lock(&pHddCtx->tdls_lock);
17933 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053017934
17935 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017936 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017937 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017938 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053017939 __func__, MAC_ADDR_ARRAY(peer));
17940 return -EINVAL;
17941 }
17942 else {
17943 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
17944 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053017945 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
17946 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017947 /* if channel switch is configured, reset
17948 the channel for this peer */
17949 if (TRUE == pTdlsPeer->isOffChannelConfigured)
17950 {
17951 pTdlsPeer->peerParams.channel = 0;
17952 pTdlsPeer->isOffChannelConfigured = FALSE;
17953 }
Atul Mittal115287b2014-07-08 13:26:33 +053017954 }
17955
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017956 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017957 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017958 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053017959 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017960 }
Atul Mittal115287b2014-07-08 13:26:33 +053017961
17962 /*EXT TDLS*/
17963
17964 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017965 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17967 " %s TDLS set callback Failed",
17968 __func__);
17969 return -EINVAL;
17970 }
Atul Mittal115287b2014-07-08 13:26:33 +053017971
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017972 mutex_unlock(&pHddCtx->tdls_lock);
17973
17974 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053017975}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017976static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017977#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17978 const u8 *peer,
17979#else
17980 u8 *peer,
17981#endif
17982 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017983{
17984 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17985 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017986 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017987 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017988
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017989 ENTER();
17990
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017991 if (!pAdapter) {
17992 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17993 return -EINVAL;
17994 }
17995
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017996 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17997 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
17998 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017999 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018000 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080018001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070018002 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018003 return -EINVAL;
18004 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018005
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018006 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018007 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018008 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018009 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080018010 }
18011
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018012
18013 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018014 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018015 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080018016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018017 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
18018 "Cannot process TDLS commands",
18019 pHddCtx->cfg_ini->fEnableTDLSSupport,
18020 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018021 return -ENOTSUPP;
18022 }
18023
18024 switch (oper) {
18025 case NL80211_TDLS_ENABLE_LINK:
18026 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018027 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018028 long ret;
Hanumantha Reddy Pothulada389492016-02-11 17:29:27 +053018029 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0,
18030 0, 0, 0, 0, 0, 0, {0}, 0, {0} };
Agarwal Ashish16020c42014-12-29 22:01:11 +053018031 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018032 tANI_U16 numCurrTdlsPeers = 0;
18033 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018034 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018035 tSirMacAddr peerMac;
18036 int channel;
18037 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018038
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18040 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
18041 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018042
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018043 mutex_lock(&pHddCtx->tdls_lock);
18044 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018045 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053018046 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018047 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018048 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18049 " (oper %d) not exsting. ignored",
18050 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18051 return -EINVAL;
18052 }
18053
18054 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18055 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18056 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18057 "NL80211_TDLS_ENABLE_LINK");
18058
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018059 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
18060 {
18061 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
18062 MAC_ADDRESS_STR " failed",
18063 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018064 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070018065 return -EINVAL;
18066 }
18067
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018068 /* before starting tdls connection, set tdls
18069 * off channel established status to default value */
18070 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018071
18072 mutex_unlock(&pHddCtx->tdls_lock);
18073
Deepthi Gowri2d85bbf2016-07-25 15:43:31 +053018074 wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018075 /* TDLS Off Channel, Disable tdls channel switch,
18076 when there are more than one tdls link */
18077 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053018078 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018079 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018080 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018081 /* get connected peer and send disable tdls off chan */
18082 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018083 if ((connPeer) &&
18084 (connPeer->isOffChannelSupported == TRUE) &&
18085 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018086 {
18087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18088 "%s: More then one peer connected, Disable "
18089 "TDLS channel switch", __func__);
18090
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018091 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018092 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
18093 channel = connPeer->peerParams.channel;
18094
18095 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018096
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018097 ret = sme_SendTdlsChanSwitchReq(
18098 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018099 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018100 peerMac,
18101 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018102 TDLS_OFF_CHANNEL_BW_OFFSET,
18103 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018104 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018105 hddLog(VOS_TRACE_LEVEL_ERROR,
18106 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018107 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018108 }
18109 else
18110 {
18111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18112 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018113 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018114 "isOffChannelConfigured %d",
18115 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018116 (connPeer ? (connPeer->isOffChannelSupported)
18117 : -1),
18118 (connPeer ? (connPeer->isOffChannelConfigured)
18119 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018120 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018121 }
18122 }
18123
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018124 mutex_lock(&pHddCtx->tdls_lock);
18125 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18126 if ( NULL == pTdlsPeer ) {
18127 mutex_unlock(&pHddCtx->tdls_lock);
18128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18129 "%s: " MAC_ADDRESS_STR
18130 " (oper %d) peer got freed in other context. ignored",
18131 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18132 return -EINVAL;
18133 }
18134 peer_status = pTdlsPeer->link_status;
18135 mutex_unlock(&pHddCtx->tdls_lock);
18136
18137 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018138 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018139 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053018140
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018141 if (0 != wlan_hdd_tdls_get_link_establish_params(
18142 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018144 return -EINVAL;
18145 }
18146 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018147
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018148 ret = sme_SendTdlsLinkEstablishParams(
18149 WLAN_HDD_GET_HAL_CTX(pAdapter),
18150 pAdapter->sessionId, peer,
18151 &tdlsLinkEstablishParams);
18152 if (ret != VOS_STATUS_SUCCESS) {
18153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
18154 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018155 /* Send TDLS peer UAPSD capabilities to the firmware and
18156 * register with the TL on after the response for this operation
18157 * is received .
18158 */
18159 ret = wait_for_completion_interruptible_timeout(
18160 &pAdapter->tdls_link_establish_req_comp,
18161 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053018162
18163 mutex_lock(&pHddCtx->tdls_lock);
18164 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18165 if ( NULL == pTdlsPeer ) {
18166 mutex_unlock(&pHddCtx->tdls_lock);
18167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18168 "%s %d: " MAC_ADDRESS_STR
18169 " (oper %d) peer got freed in other context. ignored",
18170 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
18171 (int)oper);
18172 return -EINVAL;
18173 }
18174 peer_status = pTdlsPeer->link_status;
18175 mutex_unlock(&pHddCtx->tdls_lock);
18176
18177 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018178 {
18179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018180 FL("Link Establish Request Failed Status %ld"),
18181 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053018182 return -EINVAL;
18183 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018184 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053018185
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018186 mutex_lock(&pHddCtx->tdls_lock);
18187 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18188 if ( NULL == pTdlsPeer ) {
18189 mutex_unlock(&pHddCtx->tdls_lock);
18190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18191 "%s: " MAC_ADDRESS_STR
18192 " (oper %d) peer got freed in other context. ignored",
18193 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18194 return -EINVAL;
18195 }
18196
Atul Mittal115287b2014-07-08 13:26:33 +053018197 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18198 eTDLS_LINK_CONNECTED,
18199 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018200 staDesc.ucSTAId = pTdlsPeer->staId;
18201 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018202
18203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18204 "%s: tdlsLinkEstablishParams of peer "
18205 MAC_ADDRESS_STR "uapsdQueues: %d"
18206 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18207 "isResponder: %d peerstaId: %d",
18208 __func__,
18209 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18210 tdlsLinkEstablishParams.uapsdQueues,
18211 tdlsLinkEstablishParams.qos,
18212 tdlsLinkEstablishParams.maxSp,
18213 tdlsLinkEstablishParams.isBufSta,
18214 tdlsLinkEstablishParams.isOffChannelSupported,
18215 tdlsLinkEstablishParams.isResponder,
18216 pTdlsPeer->staId);
18217
18218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18219 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18220 __func__,
18221 staDesc.ucSTAId,
18222 staDesc.ucQosEnabled);
18223
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018224 ret = WLANTL_UpdateTdlsSTAClient(
18225 pHddCtx->pvosContext,
18226 &staDesc);
18227 if (ret != VOS_STATUS_SUCCESS) {
18228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18229 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018230
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018231 /* Mark TDLS client Authenticated .*/
18232 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18233 pTdlsPeer->staId,
18234 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018235 if (VOS_STATUS_SUCCESS == status)
18236 {
Hoonki Lee14621352013-04-16 17:51:19 -070018237 if (pTdlsPeer->is_responder == 0)
18238 {
18239 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018240 tdlsConnInfo_t *tdlsInfo;
18241
18242 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18243
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018244 if (!vos_timer_is_initialized(
18245 &pTdlsPeer->initiatorWaitTimeoutTimer))
18246 {
18247 /* Initialize initiator wait callback */
18248 vos_timer_init(
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018249 &pTdlsPeer->initiatorWaitTimeoutTimer,
18250 VOS_TIMER_TYPE_SW,
18251 wlan_hdd_tdls_initiator_wait_cb,
18252 tdlsInfo);
Hanumantha Reddy Pothulac8238402016-03-24 18:02:23 +053018253 }
Hoonki Lee14621352013-04-16 17:51:19 -070018254 wlan_hdd_tdls_timer_restart(pAdapter,
18255 &pTdlsPeer->initiatorWaitTimeoutTimer,
18256 WAIT_TIME_TDLS_INITIATOR);
18257 /* suspend initiator TX until it receives direct packet from the
18258 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018259 ret = WLANTL_SuspendDataTx(
18260 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18261 &staId, NULL);
18262 if (ret != VOS_STATUS_SUCCESS) {
18263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18264 }
Hoonki Lee14621352013-04-16 17:51:19 -070018265 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018266
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018267 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018268 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018269 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018270 suppChannelLen =
18271 tdlsLinkEstablishParams.supportedChannelsLen;
18272
18273 if ((suppChannelLen > 0) &&
18274 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18275 {
18276 tANI_U8 suppPeerChannel = 0;
18277 int i = 0;
18278 for (i = 0U; i < suppChannelLen; i++)
18279 {
18280 suppPeerChannel =
18281 tdlsLinkEstablishParams.supportedChannels[i];
18282
18283 pTdlsPeer->isOffChannelSupported = FALSE;
18284 if (suppPeerChannel ==
18285 pTdlsPeer->peerParams.channel)
18286 {
18287 pTdlsPeer->isOffChannelSupported = TRUE;
18288 break;
18289 }
18290 }
18291 }
18292 else
18293 {
18294 pTdlsPeer->isOffChannelSupported = FALSE;
18295 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018296 }
18297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18298 "%s: TDLS channel switch request for channel "
18299 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018300 "%d isOffChannelSupported %d", __func__,
18301 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018302 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018303 suppChannelLen,
18304 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018305
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018306 /* TDLS Off Channel, Enable tdls channel switch,
18307 when their is only one tdls link and it supports */
18308 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18309 if ((numCurrTdlsPeers == 1) &&
18310 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18311 (TRUE == pTdlsPeer->isOffChannelConfigured))
18312 {
18313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18314 "%s: Send TDLS channel switch request for channel %d",
18315 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018316
18317 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018318 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18319 channel = pTdlsPeer->peerParams.channel;
18320
18321 mutex_unlock(&pHddCtx->tdls_lock);
18322
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018323 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18324 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018325 peerMac,
18326 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018327 TDLS_OFF_CHANNEL_BW_OFFSET,
18328 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018329 if (ret != VOS_STATUS_SUCCESS) {
18330 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18331 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018332 }
18333 else
18334 {
18335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18336 "%s: TDLS channel switch request not sent"
18337 " numCurrTdlsPeers %d "
18338 "isOffChannelSupported %d "
18339 "isOffChannelConfigured %d",
18340 __func__, numCurrTdlsPeers,
18341 pTdlsPeer->isOffChannelSupported,
18342 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018343 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018344 }
18345
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018346 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018347 else
18348 mutex_unlock(&pHddCtx->tdls_lock);
18349
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018350 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018351
18352 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018353 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18354 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018355 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018356 int ac;
18357 uint8 ucAc[4] = { WLANTL_AC_VO,
18358 WLANTL_AC_VI,
18359 WLANTL_AC_BK,
18360 WLANTL_AC_BE };
18361 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18362 for(ac=0; ac < 4; ac++)
18363 {
18364 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18365 pTdlsPeer->staId, ucAc[ac],
18366 tlTid[ac], tlTid[ac], 0, 0,
18367 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018368 if (status != VOS_STATUS_SUCCESS) {
18369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18370 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018371 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018372 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018373 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018374
Bhargav Shah66896792015-10-01 18:17:37 +053018375 /* stop TCP delack timer if TDLS is enable */
18376 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18377 hdd_manage_delack_timer(pHddCtx);
Abhishek Singh67fa6bc2016-01-05 15:57:19 +053018378 hdd_wlan_tdls_enable_link_event(peer,
18379 pTdlsPeer->isOffChannelSupported,
18380 pTdlsPeer->isOffChannelConfigured,
18381 pTdlsPeer->isOffChannelEstablished);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018382 }
18383 break;
18384 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018385 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018386 tANI_U16 numCurrTdlsPeers = 0;
18387 hddTdlsPeer_t *connPeer = NULL;
18388
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18390 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18391 __func__, MAC_ADDR_ARRAY(peer));
18392
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018393 mutex_lock(&pHddCtx->tdls_lock);
18394 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018395
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018396
Sunil Dutt41de4e22013-11-14 18:09:02 +053018397 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018398 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018399 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18400 " (oper %d) not exsting. ignored",
18401 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18402 return -EINVAL;
18403 }
18404
18405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18406 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18407 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18408 "NL80211_TDLS_DISABLE_LINK");
18409
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018410 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018411 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018412 long status;
18413
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018414 /* set tdls off channel status to false for this peer */
18415 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018416 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18417 eTDLS_LINK_TEARING,
18418 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18419 eTDLS_LINK_UNSPECIFIED:
18420 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018421 mutex_unlock(&pHddCtx->tdls_lock);
18422
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018423 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18424
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018425 status = sme_DeleteTdlsPeerSta(
18426 WLAN_HDD_GET_HAL_CTX(pAdapter),
18427 pAdapter->sessionId, peer );
18428 if (status != VOS_STATUS_SUCCESS) {
18429 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18430 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018431
18432 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18433 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018434
18435 mutex_lock(&pHddCtx->tdls_lock);
18436 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18437 if ( NULL == pTdlsPeer ) {
18438 mutex_unlock(&pHddCtx->tdls_lock);
18439 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18440 " peer was freed in other context",
18441 __func__, MAC_ADDR_ARRAY(peer));
18442 return -EINVAL;
18443 }
18444
Atul Mittal271a7652014-09-12 13:18:22 +053018445 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018446 eTDLS_LINK_IDLE,
18447 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018448 mutex_unlock(&pHddCtx->tdls_lock);
18449
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018450 if (status <= 0)
18451 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18453 "%s: Del station failed status %ld",
18454 __func__, status);
18455 return -EPERM;
18456 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018457
18458 /* TDLS Off Channel, Enable tdls channel switch,
18459 when their is only one tdls link and it supports */
18460 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18461 if (numCurrTdlsPeers == 1)
18462 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018463 tSirMacAddr peerMac;
18464 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018465
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018466 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018467 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018468
18469 if (connPeer == NULL) {
18470 mutex_unlock(&pHddCtx->tdls_lock);
18471 hddLog(VOS_TRACE_LEVEL_ERROR,
18472 "%s connPeer is NULL", __func__);
18473 return -EINVAL;
18474 }
18475
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018476 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
18477 channel = connPeer->peerParams.channel;
18478
18479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18480 "%s: TDLS channel switch "
18481 "isOffChannelSupported %d "
18482 "isOffChannelConfigured %d "
18483 "isOffChannelEstablished %d",
18484 __func__,
18485 (connPeer ? connPeer->isOffChannelSupported : -1),
18486 (connPeer ? connPeer->isOffChannelConfigured : -1),
18487 (connPeer ? connPeer->isOffChannelEstablished : -1));
18488
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018489 if ((connPeer) &&
18490 (connPeer->isOffChannelSupported == TRUE) &&
18491 (connPeer->isOffChannelConfigured == TRUE))
18492 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018493 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018494 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018495 status = sme_SendTdlsChanSwitchReq(
18496 WLAN_HDD_GET_HAL_CTX(pAdapter),
18497 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018498 peerMac,
18499 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018500 TDLS_OFF_CHANNEL_BW_OFFSET,
18501 TDLS_CHANNEL_SWITCH_ENABLE);
18502 if (status != VOS_STATUS_SUCCESS) {
18503 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
18504 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018505 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018506 else
18507 mutex_unlock(&pHddCtx->tdls_lock);
18508 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018509 else
18510 {
18511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18512 "%s: TDLS channel switch request not sent "
18513 "numCurrTdlsPeers %d ",
18514 __func__, numCurrTdlsPeers);
18515 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018516 }
18517 else
18518 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018519 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18521 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080018522 }
Bhargav Shah66896792015-10-01 18:17:37 +053018523 if (numCurrTdlsPeers == 0) {
18524 /* start TCP delack timer if TDLS is disable */
18525 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18526 hdd_manage_delack_timer(pHddCtx);
18527 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018528 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018529 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018530 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018531 {
Atul Mittal115287b2014-07-08 13:26:33 +053018532 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018533
Atul Mittal115287b2014-07-08 13:26:33 +053018534 if (0 != status)
18535 {
18536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018537 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053018538 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018539 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053018540 break;
18541 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018542 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018543 {
Atul Mittal115287b2014-07-08 13:26:33 +053018544 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
18545 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018546 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053018547 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018548
Atul Mittal115287b2014-07-08 13:26:33 +053018549 if (0 != status)
18550 {
18551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018552 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053018553 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053018554 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053018555 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018556 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018557 case NL80211_TDLS_DISCOVERY_REQ:
18558 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018560 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018561 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018562 return -ENOTSUPP;
18563 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18565 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018566 return -ENOTSUPP;
18567 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018568
18569 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018570 return 0;
18571}
Chilam NG571c65a2013-01-19 12:27:36 +053018572
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018573static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018574#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18575 const u8 *peer,
18576#else
18577 u8 *peer,
18578#endif
18579 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018580{
18581 int ret;
18582
18583 vos_ssr_protect(__func__);
18584 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
18585 vos_ssr_unprotect(__func__);
18586
18587 return ret;
18588}
18589
Chilam NG571c65a2013-01-19 12:27:36 +053018590int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
18591 struct net_device *dev, u8 *peer)
18592{
Arif Hussaina7c8e412013-11-20 11:06:42 -080018593 hddLog(VOS_TRACE_LEVEL_INFO,
18594 "tdls send discover req: "MAC_ADDRESS_STR,
18595 MAC_ADDR_ARRAY(peer));
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018596#if TDLS_MGMT_VERSION2
18597 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18598 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18599#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018600#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18601 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18602 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
18603#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18604 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18605 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18606#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18607 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18608 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18609#else
Chilam NG571c65a2013-01-19 12:27:36 +053018610 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18611 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018612#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018613#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053018614}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018615#endif
18616
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018617#ifdef WLAN_FEATURE_GTK_OFFLOAD
18618/*
18619 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
18620 * Callback rountine called upon receiving response for
18621 * get offload info
18622 */
18623void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
18624 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
18625{
18626
18627 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018628 tANI_U8 tempReplayCounter[8];
18629 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018630
18631 ENTER();
18632
18633 if (NULL == pAdapter)
18634 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053018635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018636 "%s: HDD adapter is Null", __func__);
18637 return ;
18638 }
18639
18640 if (NULL == pGtkOffloadGetInfoRsp)
18641 {
18642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18643 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
18644 return ;
18645 }
18646
18647 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
18648 {
18649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18650 "%s: wlan Failed to get replay counter value",
18651 __func__);
18652 return ;
18653 }
18654
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018655 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18656 /* Update replay counter */
18657 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
18658 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18659
18660 {
18661 /* changing from little to big endian since supplicant
18662 * works on big endian format
18663 */
18664 int i;
18665 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18666
18667 for (i = 0; i < 8; i++)
18668 {
18669 tempReplayCounter[7-i] = (tANI_U8)p[i];
18670 }
18671 }
18672
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018673 /* Update replay counter to NL */
18674 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018675 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018676}
18677
18678/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018679 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018680 * This function is used to offload GTK rekeying job to the firmware.
18681 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018682int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018683 struct cfg80211_gtk_rekey_data *data)
18684{
18685 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18686 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18687 hdd_station_ctx_t *pHddStaCtx;
18688 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018689 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018690 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018691 eHalStatus status = eHAL_STATUS_FAILURE;
18692
18693 ENTER();
18694
18695 if (NULL == pAdapter)
18696 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018698 "%s: HDD adapter is Null", __func__);
18699 return -ENODEV;
18700 }
18701
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018702 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18703 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
18704 pAdapter->sessionId, pAdapter->device_mode));
18705
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018706 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018707 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018708 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018709 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018710 }
18711
18712 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18713 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18714 if (NULL == hHal)
18715 {
18716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18717 "%s: HAL context is Null!!!", __func__);
18718 return -EAGAIN;
18719 }
18720
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018721 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
18722 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
18723 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
18724 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018725 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018726 {
18727 /* changing from big to little endian since driver
18728 * works on little endian format
18729 */
18730 tANI_U8 *p =
18731 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
18732 int i;
18733
18734 for (i = 0; i < 8; i++)
18735 {
18736 p[7-i] = data->replay_ctr[i];
18737 }
18738 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018739
18740 if (TRUE == pHddCtx->hdd_wlan_suspended)
18741 {
18742 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018743 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
18744 sizeof (tSirGtkOffloadParams));
18745 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018746 pAdapter->sessionId);
18747
18748 if (eHAL_STATUS_SUCCESS != status)
18749 {
18750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18751 "%s: sme_SetGTKOffload failed, returned %d",
18752 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018753
18754 /* Need to clear any trace of key value in the memory.
18755 * Thus zero out the memory even though it is local
18756 * variable.
18757 */
18758 vos_mem_zero(&hddGtkOffloadReqParams,
18759 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018760 return status;
18761 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18763 "%s: sme_SetGTKOffload successfull", __func__);
18764 }
18765 else
18766 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18768 "%s: wlan not suspended GTKOffload request is stored",
18769 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018770 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018771
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018772 /* Need to clear any trace of key value in the memory.
18773 * Thus zero out the memory even though it is local
18774 * variable.
18775 */
18776 vos_mem_zero(&hddGtkOffloadReqParams,
18777 sizeof(hddGtkOffloadReqParams));
18778
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018779 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018780 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018781}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018782
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018783int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
18784 struct cfg80211_gtk_rekey_data *data)
18785{
18786 int ret;
18787
18788 vos_ssr_protect(__func__);
18789 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
18790 vos_ssr_unprotect(__func__);
18791
18792 return ret;
18793}
18794#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018795/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018796 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018797 * This function is used to set access control policy
18798 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018799static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18800 struct net_device *dev,
18801 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018802{
18803 int i;
18804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18805 hdd_hostapd_state_t *pHostapdState;
18806 tsap_Config_t *pConfig;
18807 v_CONTEXT_t pVosContext = NULL;
18808 hdd_context_t *pHddCtx;
18809 int status;
18810
18811 ENTER();
18812
18813 if (NULL == pAdapter)
18814 {
18815 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18816 "%s: HDD adapter is Null", __func__);
18817 return -ENODEV;
18818 }
18819
18820 if (NULL == params)
18821 {
18822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18823 "%s: params is Null", __func__);
18824 return -EINVAL;
18825 }
18826
18827 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18828 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018829 if (0 != status)
18830 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018831 return status;
18832 }
18833
18834 pVosContext = pHddCtx->pvosContext;
18835 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
18836
18837 if (NULL == pHostapdState)
18838 {
18839 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18840 "%s: pHostapdState is Null", __func__);
18841 return -EINVAL;
18842 }
18843
18844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
18845 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018846 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18847 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
18848 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018849
18850 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
18851 {
18852 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
18853
18854 /* default value */
18855 pConfig->num_accept_mac = 0;
18856 pConfig->num_deny_mac = 0;
18857
18858 /**
18859 * access control policy
18860 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
18861 * listed in hostapd.deny file.
18862 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
18863 * listed in hostapd.accept file.
18864 */
18865 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
18866 {
18867 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
18868 }
18869 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
18870 {
18871 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
18872 }
18873 else
18874 {
18875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18876 "%s:Acl Policy : %d is not supported",
18877 __func__, params->acl_policy);
18878 return -ENOTSUPP;
18879 }
18880
18881 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
18882 {
18883 pConfig->num_accept_mac = params->n_acl_entries;
18884 for (i = 0; i < params->n_acl_entries; i++)
18885 {
18886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18887 "** Add ACL MAC entry %i in WhiletList :"
18888 MAC_ADDRESS_STR, i,
18889 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18890
18891 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
18892 sizeof(qcmacaddr));
18893 }
18894 }
18895 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
18896 {
18897 pConfig->num_deny_mac = params->n_acl_entries;
18898 for (i = 0; i < params->n_acl_entries; i++)
18899 {
18900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18901 "** Add ACL MAC entry %i in BlackList :"
18902 MAC_ADDRESS_STR, i,
18903 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18904
18905 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
18906 sizeof(qcmacaddr));
18907 }
18908 }
18909
18910 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
18911 {
18912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18913 "%s: SAP Set Mac Acl fail", __func__);
18914 return -EINVAL;
18915 }
18916 }
18917 else
18918 {
18919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053018920 "%s: Invalid device_mode = %s (%d)",
18921 __func__, hdd_device_modetoString(pAdapter->device_mode),
18922 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018923 return -EINVAL;
18924 }
18925
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018926 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018927 return 0;
18928}
18929
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018930static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18931 struct net_device *dev,
18932 const struct cfg80211_acl_data *params)
18933{
18934 int ret;
18935 vos_ssr_protect(__func__);
18936 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
18937 vos_ssr_unprotect(__func__);
18938
18939 return ret;
18940}
18941
Leo Chang9056f462013-08-01 19:21:11 -070018942#ifdef WLAN_NL80211_TESTMODE
18943#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070018944void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070018945(
18946 void *pAdapter,
18947 void *indCont
18948)
18949{
Leo Changd9df8aa2013-09-26 13:32:26 -070018950 tSirLPHBInd *lphbInd;
18951 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053018952 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070018953
18954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018955 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070018956
c_hpothu73f35e62014-04-18 13:40:08 +053018957 if (pAdapter == NULL)
18958 {
18959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18960 "%s: pAdapter is NULL\n",__func__);
18961 return;
18962 }
18963
Leo Chang9056f462013-08-01 19:21:11 -070018964 if (NULL == indCont)
18965 {
18966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018967 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070018968 return;
18969 }
18970
c_hpothu73f35e62014-04-18 13:40:08 +053018971 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070018972 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070018973 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053018974 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070018975 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070018976 GFP_ATOMIC);
18977 if (!skb)
18978 {
18979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18980 "LPHB timeout, NL buffer alloc fail");
18981 return;
18982 }
18983
Leo Changac3ba772013-10-07 09:47:04 -070018984 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070018985 {
18986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18987 "WLAN_HDD_TM_ATTR_CMD put fail");
18988 goto nla_put_failure;
18989 }
Leo Changac3ba772013-10-07 09:47:04 -070018990 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070018991 {
18992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18993 "WLAN_HDD_TM_ATTR_TYPE put fail");
18994 goto nla_put_failure;
18995 }
Leo Changac3ba772013-10-07 09:47:04 -070018996 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070018997 sizeof(tSirLPHBInd), lphbInd))
18998 {
18999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19000 "WLAN_HDD_TM_ATTR_DATA put fail");
19001 goto nla_put_failure;
19002 }
Leo Chang9056f462013-08-01 19:21:11 -070019003 cfg80211_testmode_event(skb, GFP_ATOMIC);
19004 return;
19005
19006nla_put_failure:
19007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19008 "NLA Put fail");
19009 kfree_skb(skb);
19010
19011 return;
19012}
19013#endif /* FEATURE_WLAN_LPHB */
19014
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019015static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070019016{
19017 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
19018 int err = 0;
19019#ifdef FEATURE_WLAN_LPHB
19020 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070019021 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019022
19023 ENTER();
19024
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019025 err = wlan_hdd_validate_context(pHddCtx);
19026 if (0 != err)
19027 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019028 return err;
19029 }
Leo Chang9056f462013-08-01 19:21:11 -070019030#endif /* FEATURE_WLAN_LPHB */
19031
19032 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
19033 if (err)
19034 {
19035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19036 "%s Testmode INV ATTR", __func__);
19037 return err;
19038 }
19039
19040 if (!tb[WLAN_HDD_TM_ATTR_CMD])
19041 {
19042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19043 "%s Testmode INV CMD", __func__);
19044 return -EINVAL;
19045 }
19046
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019047 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19048 TRACE_CODE_HDD_CFG80211_TESTMODE,
19049 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070019050 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
19051 {
19052#ifdef FEATURE_WLAN_LPHB
19053 /* Low Power Heartbeat configuration request */
19054 case WLAN_HDD_TM_CMD_WLAN_HB:
19055 {
19056 int buf_len;
19057 void *buf;
19058 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080019059 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070019060
19061 if (!tb[WLAN_HDD_TM_ATTR_DATA])
19062 {
19063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19064 "%s Testmode INV DATA", __func__);
19065 return -EINVAL;
19066 }
19067
19068 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
19069 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080019070
19071 hb_params_temp =(tSirLPHBReq *)buf;
19072 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
19073 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
19074 return -EINVAL;
19075
Leo Chang9056f462013-08-01 19:21:11 -070019076 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
19077 if (NULL == hb_params)
19078 {
19079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19080 "%s Request Buffer Alloc Fail", __func__);
19081 return -EINVAL;
19082 }
19083
19084 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070019085 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
19086 hb_params,
19087 wlan_hdd_cfg80211_lphb_ind_handler);
19088 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070019089 {
Leo Changd9df8aa2013-09-26 13:32:26 -070019090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19091 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070019092 vos_mem_free(hb_params);
19093 }
Leo Chang9056f462013-08-01 19:21:11 -070019094 return 0;
19095 }
19096#endif /* FEATURE_WLAN_LPHB */
19097 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053019098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
19099 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070019100 return -EOPNOTSUPP;
19101 }
19102
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019103 EXIT();
19104 return err;
Leo Chang9056f462013-08-01 19:21:11 -070019105}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019106
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053019107static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
19108#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
19109 struct wireless_dev *wdev,
19110#endif
19111 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019112{
19113 int ret;
19114
19115 vos_ssr_protect(__func__);
19116 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
19117 vos_ssr_unprotect(__func__);
19118
19119 return ret;
19120}
Leo Chang9056f462013-08-01 19:21:11 -070019121#endif /* CONFIG_NL80211_TESTMODE */
19122
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019123static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019124 struct net_device *dev,
19125 int idx, struct survey_info *survey)
19126{
19127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
19128 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053019129 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019130 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053019131 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019132 v_S7_t snr,rssi;
19133 int status, i, j, filled = 0;
19134
19135 ENTER();
19136
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019137 if (NULL == pAdapter)
19138 {
19139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19140 "%s: HDD adapter is Null", __func__);
19141 return -ENODEV;
19142 }
19143
19144 if (NULL == wiphy)
19145 {
19146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
19147 "%s: wiphy is Null", __func__);
19148 return -ENODEV;
19149 }
19150
19151 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
19152 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019153 if (0 != status)
19154 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019155 return status;
19156 }
19157
Mihir Sheted9072e02013-08-21 17:02:29 +053019158 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
19159
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019160 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053019161 0 != pAdapter->survey_idx ||
19162 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019163 {
19164 /* The survey dump ops when implemented completely is expected to
19165 * return a survey of all channels and the ops is called by the
19166 * kernel with incremental values of the argument 'idx' till it
19167 * returns -ENONET. But we can only support the survey for the
19168 * operating channel for now. survey_idx is used to track
19169 * that the ops is called only once and then return -ENONET for
19170 * the next iteration
19171 */
19172 pAdapter->survey_idx = 0;
19173 return -ENONET;
19174 }
19175
Mukul Sharma9d5233b2015-06-11 20:28:20 +053019176 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
19177 {
19178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19179 "%s: Roaming in progress, hence return ", __func__);
19180 return -ENONET;
19181 }
19182
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019183 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
19184
19185 wlan_hdd_get_snr(pAdapter, &snr);
19186 wlan_hdd_get_rssi(pAdapter, &rssi);
19187
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019188 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19189 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
19190 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019191 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
19192 hdd_wlan_get_freq(channel, &freq);
19193
19194
19195 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
19196 {
19197 if (NULL == wiphy->bands[i])
19198 {
19199 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19200 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19201 continue;
19202 }
19203
19204 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19205 {
19206 struct ieee80211_supported_band *band = wiphy->bands[i];
19207
19208 if (band->channels[j].center_freq == (v_U16_t)freq)
19209 {
19210 survey->channel = &band->channels[j];
19211 /* The Rx BDs contain SNR values in dB for the received frames
19212 * while the supplicant expects noise. So we calculate and
19213 * return the value of noise (dBm)
19214 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19215 */
19216 survey->noise = rssi - snr;
19217 survey->filled = SURVEY_INFO_NOISE_DBM;
19218 filled = 1;
19219 }
19220 }
19221 }
19222
19223 if (filled)
19224 pAdapter->survey_idx = 1;
19225 else
19226 {
19227 pAdapter->survey_idx = 0;
19228 return -ENONET;
19229 }
19230
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019231 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019232 return 0;
19233}
19234
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019235static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19236 struct net_device *dev,
19237 int idx, struct survey_info *survey)
19238{
19239 int ret;
19240
19241 vos_ssr_protect(__func__);
19242 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19243 vos_ssr_unprotect(__func__);
19244
19245 return ret;
19246}
19247
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019248/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019249 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019250 * this is called when cfg80211 driver resume
19251 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19252 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019253int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019254{
19255 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19256 hdd_adapter_t *pAdapter;
19257 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19258 VOS_STATUS status = VOS_STATUS_SUCCESS;
19259
19260 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019261
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019262 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019263 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019264 return 0;
19265 }
19266
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019267 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19268 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019269 spin_lock(&pHddCtx->schedScan_lock);
19270 pHddCtx->isWiphySuspended = FALSE;
19271 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19272 {
19273 spin_unlock(&pHddCtx->schedScan_lock);
19274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19275 "%s: Return resume is not due to PNO indication", __func__);
19276 return 0;
19277 }
19278 // Reset flag to avoid updatating cfg80211 data old results again
19279 pHddCtx->isSchedScanUpdatePending = FALSE;
19280 spin_unlock(&pHddCtx->schedScan_lock);
19281
19282 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19283
19284 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19285 {
19286 pAdapter = pAdapterNode->pAdapter;
19287 if ( (NULL != pAdapter) &&
19288 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19289 {
19290 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019291 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19293 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019294 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019295 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019296 {
19297 /* Acquire wakelock to handle the case where APP's tries to
19298 * suspend immediately after updating the scan results. Whis
19299 * results in app's is in suspended state and not able to
19300 * process the connect request to AP
19301 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019302 hdd_prevent_suspend_timeout(2000,
19303 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019304 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019305 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019306
19307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19308 "%s : cfg80211 scan result database updated", __func__);
19309
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019310 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019311 return 0;
19312
19313 }
19314 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19315 pAdapterNode = pNext;
19316 }
19317
19318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19319 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019320 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019321 return 0;
19322}
19323
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019324int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19325{
19326 int ret;
19327
19328 vos_ssr_protect(__func__);
19329 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19330 vos_ssr_unprotect(__func__);
19331
19332 return ret;
19333}
19334
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019335/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019336 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019337 * this is called when cfg80211 driver suspends
19338 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019339int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019340 struct cfg80211_wowlan *wow)
19341{
19342 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019343 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019344
19345 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019346
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019347 ret = wlan_hdd_validate_context(pHddCtx);
19348 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019349 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019350 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019351 }
19352
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019353
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019354 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19355 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19356 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019357 pHddCtx->isWiphySuspended = TRUE;
19358
19359 EXIT();
19360
19361 return 0;
19362}
19363
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019364int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19365 struct cfg80211_wowlan *wow)
19366{
19367 int ret;
19368
19369 vos_ssr_protect(__func__);
19370 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19371 vos_ssr_unprotect(__func__);
19372
19373 return ret;
19374}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019375
19376#ifdef FEATURE_OEM_DATA_SUPPORT
19377static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019378 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019379{
19380 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19381
19382 ENTER();
19383
19384 if (wlan_hdd_validate_context(pHddCtx)) {
19385 return;
19386 }
19387 if (!pMsg)
19388 {
19389 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19390 return;
19391 }
19392
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019393 send_oem_data_rsp_msg(evLen, pMsg);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019394
19395 EXIT();
19396 return;
19397
19398}
19399
19400void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019401 void *pMsg, tANI_U32 evLen)
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019402{
19403 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19404
19405 ENTER();
19406
19407 if (wlan_hdd_validate_context(pHddCtx)) {
19408 return;
19409 }
19410
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019412
19413 switch(evType) {
19414 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
Padma, Santhosh Kumarf75c37b2016-01-25 10:36:08 +053019415 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen);
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019416 break;
19417 default:
19418 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19419 break;
19420 }
19421 EXIT();
19422}
19423#endif
19424
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019425#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19426 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019427/**
19428 * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api
19429 * @wiphy: Pointer to wiphy
19430 * @wdev: Pointer to wireless device structure
19431 *
19432 * This function is used to abort an ongoing scan
19433 *
19434 * Return: None
19435 */
19436static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19437 struct wireless_dev *wdev)
19438{
19439 struct net_device *dev = wdev->netdev;
19440 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
19441 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
19442 int ret;
19443
19444 ENTER();
19445
19446 if (NULL == adapter) {
19447 hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL"));
19448 return;
19449 }
19450
19451 ret = wlan_hdd_validate_context(hdd_ctx);
19452 if (0 != ret)
19453 return;
19454
19455 wlan_hdd_scan_abort(adapter);
19456
19457 return;
19458}
19459
19460/**
19461 * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api
19462 * @wiphy: Pointer to wiphy
19463 * @wdev: Pointer to wireless device structure
19464 *
19465 * Return: None
19466 */
19467void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
19468 struct wireless_dev *wdev)
19469{
19470 vos_ssr_protect(__func__);
19471 __wlan_hdd_cfg80211_abort_scan(wiphy, wdev);
19472 vos_ssr_unprotect(__func__);
19473
19474 return;
19475}
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019476#endif
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019477
Jeff Johnson295189b2012-06-20 16:38:30 -070019478/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019479static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070019480{
19481 .add_virtual_intf = wlan_hdd_add_virtual_intf,
19482 .del_virtual_intf = wlan_hdd_del_virtual_intf,
19483 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
19484 .change_station = wlan_hdd_change_station,
19485#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
19486 .add_beacon = wlan_hdd_cfg80211_add_beacon,
19487 .del_beacon = wlan_hdd_cfg80211_del_beacon,
19488 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019489#else
19490 .start_ap = wlan_hdd_cfg80211_start_ap,
19491 .change_beacon = wlan_hdd_cfg80211_change_beacon,
19492 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070019493#endif
19494 .change_bss = wlan_hdd_cfg80211_change_bss,
19495 .add_key = wlan_hdd_cfg80211_add_key,
19496 .get_key = wlan_hdd_cfg80211_get_key,
19497 .del_key = wlan_hdd_cfg80211_del_key,
19498 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019499#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070019500 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019501#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019502 .scan = wlan_hdd_cfg80211_scan,
19503 .connect = wlan_hdd_cfg80211_connect,
19504 .disconnect = wlan_hdd_cfg80211_disconnect,
19505 .join_ibss = wlan_hdd_cfg80211_join_ibss,
19506 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
19507 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
19508 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
19509 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070019510 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
19511 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053019512 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070019513#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19514 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
19515 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
19516 .set_txq_params = wlan_hdd_set_txq_params,
19517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019518 .get_station = wlan_hdd_cfg80211_get_station,
19519 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
19520 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019521 .add_station = wlan_hdd_cfg80211_add_station,
19522#ifdef FEATURE_WLAN_LFR
19523 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
19524 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
19525 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
19526#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019527#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
19528 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
19529#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019530#ifdef FEATURE_WLAN_TDLS
19531 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
19532 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
19533#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019534#ifdef WLAN_FEATURE_GTK_OFFLOAD
19535 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
19536#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019537#ifdef FEATURE_WLAN_SCAN_PNO
19538 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
19539 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
19540#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019541 .resume = wlan_hdd_cfg80211_resume_wlan,
19542 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019543 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070019544#ifdef WLAN_NL80211_TESTMODE
19545 .testmode_cmd = wlan_hdd_cfg80211_testmode,
19546#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019547 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019548#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \
19549 defined(CFG80211_ABORT_SCAN)
Kanchanapally, Vidyullathac4735162016-02-09 17:49:39 +053019550 .abort_scan = wlan_hdd_cfg80211_abort_scan,
Kanchanapally, Vidyullatha740d64e2016-05-03 15:25:54 +053019551#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019552};
19553