blob: 99c77747122584cc3ee6adef3d6c6192f2f605f9 [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 /*
2726 * Firmware returns timestamp from WiFi turn ON till
2727 * BSSID was cached (in seconds). Add this with
2728 * time gap between system boot up to WiFi turn ON
2729 * to derive the time since boot when the
2730 * BSSID was cached.
2731 */
2732 pSirWifiScanResult->ts += pHddCtx->wifi_turn_on_time_since_boot;
2733 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2734 "Ssid (%s)"
2735 "Bssid: %pM "
2736 "Channel (%u)"
2737 "Rssi (%d)"
2738 "RTT (%u)"
2739 "RTT_SD (%u)"
2740 "Beacon Period %u"
2741 "Capability 0x%x "
2742 "Ie length %d",
2743 i,
2744 pSirWifiScanResult->ts,
2745 pSirWifiScanResult->ssid,
2746 pSirWifiScanResult->bssid,
2747 pSirWifiScanResult->channel,
2748 pSirWifiScanResult->rssi,
2749 pSirWifiScanResult->rtt,
2750 pSirWifiScanResult->rtt_sd,
2751 pSirWifiScanResult->beaconPeriod,
2752 pSirWifiScanResult->capability,
2753 ieLength);
2754
2755 ap = nla_nest_start(skb, j + 1);
2756 if (!ap)
2757 {
2758 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2759 goto fail;
2760 }
2761
2762 if (nla_put_u64(skb,
2763 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2764 pSirWifiScanResult->ts) )
2765 {
2766 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2767 goto fail;
2768 }
2769 if (nla_put(skb,
2770 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2771 sizeof(pSirWifiScanResult->ssid),
2772 pSirWifiScanResult->ssid) )
2773 {
2774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2775 goto fail;
2776 }
2777 if (nla_put(skb,
2778 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2779 sizeof(pSirWifiScanResult->bssid),
2780 pSirWifiScanResult->bssid) )
2781 {
2782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2783 goto fail;
2784 }
2785 if (nla_put_u32(skb,
2786 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2787 pSirWifiScanResult->channel) )
2788 {
2789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2790 goto fail;
2791 }
2792 if (nla_put_s32(skb,
2793 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2794 pSirWifiScanResult->rssi) )
2795 {
2796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2797 goto fail;
2798 }
2799 if (nla_put_u32(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2801 pSirWifiScanResult->rtt) )
2802 {
2803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2804 goto fail;
2805 }
2806 if (nla_put_u32(skb,
2807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2808 pSirWifiScanResult->rtt_sd))
2809 {
2810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2811 goto fail;
2812 }
2813 if (nla_put_u32(skb,
2814 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2815 pSirWifiScanResult->beaconPeriod))
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2818 goto fail;
2819 }
2820 if (nla_put_u32(skb,
2821 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2822 pSirWifiScanResult->capability))
2823 {
2824 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2825 goto fail;
2826 }
2827 if (nla_put_u32(skb,
2828 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2829 ieLength))
2830 {
2831 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2832 goto fail;
2833 }
2834
2835 if (ieLength)
2836 if (nla_put(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2838 ieLength, ie)) {
2839 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2840 goto fail;
2841 }
2842
2843 nla_nest_end(skb, ap);
2844 }
2845 nla_nest_end(skb, aps);
2846 nla_nest_end(skb, nla_result);
2847 }
2848
2849 nla_nest_end(skb, nla_results);
2850
2851 cfg80211_vendor_cmd_reply(skb);
2852
2853 } while (totalResults > 0);
2854 }
2855
2856 if (!pData->moreData) {
2857 spin_lock(&hdd_context_lock);
2858 context->response_status = 0;
2859 complete(&context->response_event);
2860 spin_unlock(&hdd_context_lock);
2861 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302862
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302863 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302864 return;
2865fail:
2866 kfree_skb(skb);
2867 return;
2868}
2869
2870static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2871 void *pMsg)
2872{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302873 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302874 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2875 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302876 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302877
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302878 ENTER();
2879
2880 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302881 hddLog(LOGE,
2882 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302883 return;
2884 }
2885 if (!pMsg)
2886 {
2887 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302888 return;
2889 }
2890
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302891 if (pData->bss_found)
2892 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2893 else
2894 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2895
Dino Mycle6fb96c12014-06-10 11:52:40 +05302896 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2898 NULL,
2899#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302900 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302901 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302902
2903 if (!skb) {
2904 hddLog(VOS_TRACE_LEVEL_ERROR,
2905 FL("cfg80211_vendor_event_alloc failed"));
2906 return;
2907 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302908
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302909 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2910 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2911 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2912 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2913
2914 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302915 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2916 "Ssid (%s) "
2917 "Bssid (" MAC_ADDRESS_STR ") "
2918 "Channel (%u) "
2919 "Rssi (%d) "
2920 "RTT (%u) "
2921 "RTT_SD (%u) ",
2922 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302923 pData->bssHotlist[i].ts,
2924 pData->bssHotlist[i].ssid,
2925 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2926 pData->bssHotlist[i].channel,
2927 pData->bssHotlist[i].rssi,
2928 pData->bssHotlist[i].rtt,
2929 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302930 }
2931
2932 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2933 pData->requestId) ||
2934 nla_put_u32(skb,
2935 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302936 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302937 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2938 goto fail;
2939 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302940 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302941 struct nlattr *aps;
2942
2943 aps = nla_nest_start(skb,
2944 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2945 if (!aps)
2946 goto fail;
2947
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302948 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302949 struct nlattr *ap;
2950
2951 ap = nla_nest_start(skb, i + 1);
2952 if (!ap)
2953 goto fail;
2954
2955 if (nla_put_u64(skb,
2956 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302957 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302958 nla_put(skb,
2959 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302960 sizeof(pData->bssHotlist[i].ssid),
2961 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302962 nla_put(skb,
2963 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302964 sizeof(pData->bssHotlist[i].bssid),
2965 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302966 nla_put_u32(skb,
2967 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302968 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 nla_put_s32(skb,
2970 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302971 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302972 nla_put_u32(skb,
2973 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302974 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302975 nla_put_u32(skb,
2976 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302977 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302978 goto fail;
2979
2980 nla_nest_end(skb, ap);
2981 }
2982 nla_nest_end(skb, aps);
2983
2984 if (nla_put_u8(skb,
2985 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2986 pData->moreData))
2987 goto fail;
2988 }
2989
2990 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302991 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302992 return;
2993
2994fail:
2995 kfree_skb(skb);
2996 return;
2997
2998}
Dino Mycle6fb96c12014-06-10 11:52:40 +05302999
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303000/**
3001 * wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind() -
3002 * Handle an SSID hotlist match event
3003 * @ctx: HDD context registered with SME
3004 * @event: The SSID hotlist match event
3005 *
3006 * This function will take an SSID match event that was generated by
3007 * firmware and will convert it into a cfg80211 vendor event which is
3008 * sent to userspace.
3009 *
3010 * Return: none
3011 */
3012static void
3013wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(void *ctx,
3014 void *pMsg)
3015{
3016 hdd_context_t *hdd_ctx = ctx;
3017 struct sk_buff *skb;
3018 tANI_U32 i, index;
3019 tpSirEXTScanSsidHotlistMatch pData = (tpSirEXTScanSsidHotlistMatch) pMsg;
3020
3021 ENTER();
3022
3023 if (wlan_hdd_validate_context(hdd_ctx)) {
3024 hddLog(LOGE,
3025 FL("HDD context is not valid or response"));
3026 return;
3027 }
3028 if (!pMsg)
3029 {
3030 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3031 return;
3032 }
3033
3034 if (pData->ssid_found) {
3035 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX;
3036 hddLog(LOG1, "SSID hotlist found");
3037 } else {
3038 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX;
3039 hddLog(LOG1, "SSID hotlist lost");
3040 }
3041
3042 skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
3043#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3044 NULL,
3045#endif
3046 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3047 index, GFP_KERNEL);
3048
3049 if (!skb) {
3050 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
3051 return;
3052 }
3053 hddLog(LOG1, "Req Id %u, Num of SSIDs %u, More Data (%u)",
3054 pData->requestId, pData->numHotlistSsid, pData->moreData);
3055
3056 for (i = 0; i < pData->numHotlistSsid; i++) {
3057 hddLog(LOG1, "[i=%d] Timestamp %llu "
3058 "Ssid: %s "
3059 "Bssid (" MAC_ADDRESS_STR ") "
3060 "Channel %u "
3061 "Rssi %d "
3062 "RTT %u "
3063 "RTT_SD %u",
3064 i,
3065 pData->ssidHotlist[i].ts,
3066 pData->ssidHotlist[i].ssid,
3067 MAC_ADDR_ARRAY(pData->ssidHotlist[i].bssid),
3068 pData->ssidHotlist[i].channel,
3069 pData->ssidHotlist[i].rssi,
3070 pData->ssidHotlist[i].rtt,
3071 pData->ssidHotlist[i].rtt_sd);
3072 }
3073
3074 if (nla_put_u32(skb,
3075 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3076 pData->requestId) ||
3077 nla_put_u32(skb,
3078 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3079 pData->numHotlistSsid)) {
3080 hddLog(LOGE, FL("put fail"));
3081 goto fail;
3082 }
3083
3084 if (pData->numHotlistSsid) {
3085 struct nlattr *aps;
3086 aps = nla_nest_start(skb,
3087 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3088 if (!aps) {
3089 hddLog(LOGE, FL("nest fail"));
3090 goto fail;
3091 }
3092
3093 for (i = 0; i < pData->numHotlistSsid; i++) {
3094 struct nlattr *ap;
3095
3096 ap = nla_nest_start(skb, i);
3097 if (!ap) {
3098 hddLog(LOGE, FL("nest fail"));
3099 goto fail;
3100 }
3101
3102 if (nla_put_u64(skb,
3103 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3104 pData->ssidHotlist[i].ts) ||
3105 nla_put(skb,
3106 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3107 sizeof(pData->ssidHotlist[i].ssid),
3108 pData->ssidHotlist[i].ssid) ||
3109 nla_put(skb,
3110 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3111 sizeof(pData->ssidHotlist[i].bssid),
3112 pData->ssidHotlist[i].bssid) ||
3113 nla_put_u32(skb,
3114 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3115 pData->ssidHotlist[i].channel) ||
3116 nla_put_s32(skb,
3117 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3118 pData->ssidHotlist[i].rssi) ||
3119 nla_put_u32(skb,
3120 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3121 pData->ssidHotlist[i].rtt) ||
3122 nla_put_u32(skb,
3123 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3124 pData->ssidHotlist[i].rtt_sd)) {
3125 hddLog(LOGE, FL("put fail"));
3126 goto fail;
3127 }
3128 nla_nest_end(skb, ap);
3129 }
3130 nla_nest_end(skb, aps);
3131
3132 if (nla_put_u8(skb,
3133 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3134 pData->moreData)) {
3135 hddLog(LOGE, FL("put fail"));
3136 goto fail;
3137 }
3138 }
3139
3140 cfg80211_vendor_event(skb, GFP_KERNEL);
3141 return;
3142
3143fail:
3144 kfree_skb(skb);
3145 return;
3146
3147}
3148
3149
Dino Mycle6fb96c12014-06-10 11:52:40 +05303150static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3151 void *pMsg)
3152{
3153 struct sk_buff *skb;
3154 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3155 tpSirWifiFullScanResultEvent pData =
3156 (tpSirWifiFullScanResultEvent) (pMsg);
3157
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303158 ENTER();
3159
3160 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303161 hddLog(LOGE,
3162 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303163 return;
3164 }
3165 if (!pMsg)
3166 {
3167 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303168 return;
3169 }
3170
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303171 /*
3172 * If the full scan result including IE data exceeds NL 4K size
3173 * limitation, drop that beacon/probe rsp frame.
3174 */
3175 if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) {
3176 hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!"));
3177 return;
3178 }
3179
Dino Mycle6fb96c12014-06-10 11:52:40 +05303180 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303181#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3182 NULL,
3183#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303184 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3185 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3186 GFP_KERNEL);
3187
3188 if (!skb) {
3189 hddLog(VOS_TRACE_LEVEL_ERROR,
3190 FL("cfg80211_vendor_event_alloc failed"));
3191 return;
3192 }
3193
Dino Mycle6fb96c12014-06-10 11:52:40 +05303194 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3195 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3196 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3197 "Ssid (%s)"
3198 "Bssid (" MAC_ADDRESS_STR ")"
3199 "Channel (%u)"
3200 "Rssi (%d)"
3201 "RTT (%u)"
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303202 "RTT_SD (%u)"
3203 "Bcn Period %d"
3204 "Capability 0x%X "),
Dino Mycle6fb96c12014-06-10 11:52:40 +05303205 pData->ap.ts,
3206 pData->ap.ssid,
3207 MAC_ADDR_ARRAY(pData->ap.bssid),
3208 pData->ap.channel,
3209 pData->ap.rssi,
3210 pData->ap.rtt,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303211 pData->ap.rtt_sd,
3212 pData->ap.beaconPeriod,
3213 pData->ap.capability);
3214
Dino Mycle6fb96c12014-06-10 11:52:40 +05303215 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3216 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3217 pData->requestId) ||
3218 nla_put_u64(skb,
3219 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3220 pData->ap.ts) ||
3221 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3222 sizeof(pData->ap.ssid),
3223 pData->ap.ssid) ||
3224 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3225 WNI_CFG_BSSID_LEN,
3226 pData->ap.bssid) ||
3227 nla_put_u32(skb,
3228 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3229 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303230 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303231 pData->ap.rssi) ||
3232 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3233 pData->ap.rtt) ||
3234 nla_put_u32(skb,
3235 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3236 pData->ap.rtt_sd) ||
3237 nla_put_u16(skb,
3238 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3239 pData->ap.beaconPeriod) ||
3240 nla_put_u16(skb,
3241 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3242 pData->ap.capability) ||
3243 nla_put_u32(skb,
3244 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303245 pData->ieLength) ||
3246 nla_put_u8(skb,
3247 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3248 pData->moreData))
Dino Mycle6fb96c12014-06-10 11:52:40 +05303249 {
3250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3251 goto nla_put_failure;
3252 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303253
3254 if (pData->ieLength) {
3255 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3256 pData->ieLength,
3257 pData->ie))
3258 {
3259 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3260 goto nla_put_failure;
3261 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303262 }
3263
3264 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303265 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303266 return;
3267
3268nla_put_failure:
3269 kfree_skb(skb);
3270 return;
3271}
3272
3273static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3274 void *pMsg)
3275{
3276 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3277 struct sk_buff *skb = NULL;
3278 tpSirEXTScanResultsAvailableIndParams pData =
3279 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3280
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303281 ENTER();
3282
3283 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303284 hddLog(LOGE,
3285 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303286 return;
3287 }
3288 if (!pMsg)
3289 {
3290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303291 return;
3292 }
3293
3294 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303295#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3296 NULL,
3297#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303298 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3299 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3300 GFP_KERNEL);
3301
3302 if (!skb) {
3303 hddLog(VOS_TRACE_LEVEL_ERROR,
3304 FL("cfg80211_vendor_event_alloc failed"));
3305 return;
3306 }
3307
Dino Mycle6fb96c12014-06-10 11:52:40 +05303308 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3309 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3310 pData->numResultsAvailable);
3311 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3312 pData->requestId) ||
3313 nla_put_u32(skb,
3314 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3315 pData->numResultsAvailable)) {
3316 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3317 goto nla_put_failure;
3318 }
3319
3320 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303321 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303322 return;
3323
3324nla_put_failure:
3325 kfree_skb(skb);
3326 return;
3327}
3328
3329static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3330{
3331 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3332 struct sk_buff *skb = NULL;
3333 tpSirEXTScanProgressIndParams pData =
3334 (tpSirEXTScanProgressIndParams) pMsg;
3335
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303336 ENTER();
3337
3338 if (wlan_hdd_validate_context(pHddCtx)){
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303339 hddLog(LOGE,
3340 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303341 return;
3342 }
3343 if (!pMsg)
3344 {
3345 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303346 return;
3347 }
3348
3349 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303350#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3351 NULL,
3352#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303353 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3354 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3355 GFP_KERNEL);
3356
3357 if (!skb) {
3358 hddLog(VOS_TRACE_LEVEL_ERROR,
3359 FL("cfg80211_vendor_event_alloc failed"));
3360 return;
3361 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303362 hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303363 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3364 pData->extScanEventType);
3365 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3366 pData->status);
3367
3368 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3369 pData->extScanEventType) ||
3370 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303371 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3372 pData->requestId) ||
3373 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303374 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3375 pData->status)) {
3376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3377 goto nla_put_failure;
3378 }
3379
3380 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303381 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303382 return;
3383
3384nla_put_failure:
3385 kfree_skb(skb);
3386 return;
3387}
3388
3389void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3390 void *pMsg)
3391{
3392 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3393
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303394 ENTER();
3395
Dino Mycle6fb96c12014-06-10 11:52:40 +05303396 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303397 return;
3398 }
3399
3400 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3401
3402
3403 switch(evType) {
3404 case SIR_HAL_EXTSCAN_START_RSP:
3405 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3406 break;
3407
3408 case SIR_HAL_EXTSCAN_STOP_RSP:
3409 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3410 break;
3411 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3412 /* There is no need to send this response to upper layer
3413 Just log the message */
3414 hddLog(VOS_TRACE_LEVEL_INFO,
3415 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3416 break;
3417 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3418 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3419 break;
3420
3421 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3422 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3423 break;
3424
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303425 case SIR_HAL_EXTSCAN_SET_SSID_HOTLIST_RSP:
3426 wlan_hdd_cfg80211_extscan_set_ssid_hotlist_rsp(ctx, pMsg);
3427 break;
3428
3429 case SIR_HAL_EXTSCAN_RESET_SSID_HOTLIST_RSP:
3430 wlan_hdd_cfg80211_extscan_reset_ssid_hotlist_rsp(ctx, pMsg);
3431 break;
3432
Dino Mycle6fb96c12014-06-10 11:52:40 +05303433 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303434 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303435 break;
3436 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3437 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3438 break;
3439 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3440 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3441 break;
3442 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3443 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3444 break;
3445 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3446 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3447 break;
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303448 case SIR_HAL_EXTSCAN_SSID_HOTLIST_MATCH_IND:
3449 wlan_hdd_cfg80211_extscan_hotlist_ssid_match_ind(ctx, pMsg);
3450 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303451 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3452 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3453 break;
3454 default:
3455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3456 break;
3457 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303458 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459}
3460
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303461static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3462 struct wireless_dev *wdev,
3463 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464{
Dino Myclee8843b32014-07-04 14:21:45 +05303465 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 struct net_device *dev = wdev->netdev;
3467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3468 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3469 struct nlattr
3470 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3471 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303472 struct hdd_ext_scan_context *context;
3473 unsigned long rc;
3474 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303476 ENTER();
3477
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 status = wlan_hdd_validate_context(pHddCtx);
3479 if (0 != status)
3480 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303481 return -EINVAL;
3482 }
Dino Myclee8843b32014-07-04 14:21:45 +05303483 /* check the EXTScan Capability */
3484 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303485 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3486 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303487 {
3488 hddLog(VOS_TRACE_LEVEL_ERROR,
3489 FL("EXTScan not enabled/supported by Firmware"));
3490 return -EINVAL;
3491 }
3492
Dino Mycle6fb96c12014-06-10 11:52:40 +05303493 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3494 data, dataLen,
3495 wlan_hdd_extscan_config_policy)) {
3496 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3497 return -EINVAL;
3498 }
3499
3500 /* Parse and fetch request Id */
3501 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3503 return -EINVAL;
3504 }
3505
Dino Myclee8843b32014-07-04 14:21:45 +05303506 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303507 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303508 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303509
Dino Myclee8843b32014-07-04 14:21:45 +05303510 reqMsg.sessionId = pAdapter->sessionId;
3511 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303512
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303513 vos_spin_lock_acquire(&hdd_context_lock);
3514 context = &pHddCtx->ext_scan_context;
3515 context->request_id = reqMsg.requestId;
3516 INIT_COMPLETION(context->response_event);
3517 vos_spin_lock_release(&hdd_context_lock);
3518
Dino Myclee8843b32014-07-04 14:21:45 +05303519 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303520 if (!HAL_STATUS_SUCCESS(status)) {
3521 hddLog(VOS_TRACE_LEVEL_ERROR,
3522 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303523 return -EINVAL;
3524 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303525
3526 rc = wait_for_completion_timeout(&context->response_event,
3527 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3528 if (!rc) {
3529 hddLog(LOGE, FL("Target response timed out"));
3530 return -ETIMEDOUT;
3531 }
3532
3533 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3534 if (ret)
3535 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3536
3537 return ret;
3538
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303539 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303540 return 0;
3541}
3542
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303543static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3544 struct wireless_dev *wdev,
3545 const void *data, int dataLen)
3546{
3547 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303548
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303549 vos_ssr_protect(__func__);
3550 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3551 vos_ssr_unprotect(__func__);
3552
3553 return ret;
3554}
3555
3556static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3557 struct wireless_dev *wdev,
3558 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303559{
Dino Myclee8843b32014-07-04 14:21:45 +05303560 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 struct net_device *dev = wdev->netdev;
3562 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3563 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3564 struct nlattr
3565 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3566 eHalStatus status;
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303567 struct hdd_ext_scan_context *context;
3568 unsigned long rc;
3569 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303570
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303571 ENTER();
3572
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303573 if (VOS_FTM_MODE == hdd_get_conparam()) {
3574 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3575 return -EINVAL;
3576 }
3577
Dino Mycle6fb96c12014-06-10 11:52:40 +05303578 status = wlan_hdd_validate_context(pHddCtx);
3579 if (0 != status)
3580 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303581 return -EINVAL;
3582 }
Dino Myclee8843b32014-07-04 14:21:45 +05303583 /* check the EXTScan Capability */
3584 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303585 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3586 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303587 {
3588 hddLog(VOS_TRACE_LEVEL_ERROR,
3589 FL("EXTScan not enabled/supported by Firmware"));
3590 return -EINVAL;
3591 }
3592
Dino Mycle6fb96c12014-06-10 11:52:40 +05303593 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3594 data, dataLen,
3595 wlan_hdd_extscan_config_policy)) {
3596 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3597 return -EINVAL;
3598 }
3599 /* Parse and fetch request Id */
3600 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3601 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3602 return -EINVAL;
3603 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303604
Dino Myclee8843b32014-07-04 14:21:45 +05303605 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303606 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3607
Dino Myclee8843b32014-07-04 14:21:45 +05303608 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303609
Dino Myclee8843b32014-07-04 14:21:45 +05303610 reqMsg.sessionId = pAdapter->sessionId;
3611 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303612
3613 /* Parse and fetch flush parameter */
3614 if (!tb
3615 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3616 {
3617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3618 goto failed;
3619 }
Dino Myclee8843b32014-07-04 14:21:45 +05303620 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303621 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3622
Dino Myclee8843b32014-07-04 14:21:45 +05303623 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303624
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303625 spin_lock(&hdd_context_lock);
3626 context = &pHddCtx->ext_scan_context;
3627 context->request_id = reqMsg.requestId;
3628 context->ignore_cached_results = false;
3629 INIT_COMPLETION(context->response_event);
3630 spin_unlock(&hdd_context_lock);
3631
Dino Myclee8843b32014-07-04 14:21:45 +05303632 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303633 if (!HAL_STATUS_SUCCESS(status)) {
3634 hddLog(VOS_TRACE_LEVEL_ERROR,
3635 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303636 return -EINVAL;
3637 }
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303638
3639 rc = wait_for_completion_timeout(&context->response_event,
3640 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3641 if (!rc) {
3642 hddLog(LOGE, FL("Target response timed out"));
3643 retval = -ETIMEDOUT;
3644 spin_lock(&hdd_context_lock);
3645 context->ignore_cached_results = true;
3646 spin_unlock(&hdd_context_lock);
3647 } else {
3648 spin_lock(&hdd_context_lock);
3649 retval = context->response_status;
3650 spin_unlock(&hdd_context_lock);
3651 }
3652
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303653 EXIT();
Padma, Santhosh Kumare1b8a942015-08-25 12:44:24 +05303654 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303655
3656failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303657 return -EINVAL;
3658}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303659static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3660 struct wireless_dev *wdev,
3661 const void *data, int dataLen)
3662{
3663 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303664
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303665 vos_ssr_protect(__func__);
3666 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3667 vos_ssr_unprotect(__func__);
3668
3669 return ret;
3670}
3671
3672static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303673 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303674 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303675{
3676 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3677 struct net_device *dev = wdev->netdev;
3678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3679 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3680 struct nlattr
3681 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3682 struct nlattr
3683 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3684 struct nlattr *apTh;
3685 eHalStatus status;
3686 tANI_U8 i = 0;
3687 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303688 struct hdd_ext_scan_context *context;
3689 tANI_U32 request_id;
3690 unsigned long rc;
3691 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303692
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303693 ENTER();
3694
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303695 if (VOS_FTM_MODE == hdd_get_conparam()) {
3696 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3697 return -EINVAL;
3698 }
3699
Dino Mycle6fb96c12014-06-10 11:52:40 +05303700 status = wlan_hdd_validate_context(pHddCtx);
3701 if (0 != status)
3702 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303703 return -EINVAL;
3704 }
Dino Myclee8843b32014-07-04 14:21:45 +05303705 /* check the EXTScan Capability */
3706 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303707 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3708 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05303709 {
3710 hddLog(VOS_TRACE_LEVEL_ERROR,
3711 FL("EXTScan not enabled/supported by Firmware"));
3712 return -EINVAL;
3713 }
3714
Dino Mycle6fb96c12014-06-10 11:52:40 +05303715 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3716 data, dataLen,
3717 wlan_hdd_extscan_config_policy)) {
3718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3719 return -EINVAL;
3720 }
3721
3722 /* Parse and fetch request Id */
3723 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3724 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3725 return -EINVAL;
3726 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303727 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3728 vos_mem_malloc(sizeof(*pReqMsg));
3729 if (!pReqMsg) {
3730 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3731 return -ENOMEM;
3732 }
3733
Dino Myclee8843b32014-07-04 14:21:45 +05303734
Dino Mycle6fb96c12014-06-10 11:52:40 +05303735 pReqMsg->requestId = nla_get_u32(
3736 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3737 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3738
3739 /* Parse and fetch number of APs */
3740 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3741 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3742 goto fail;
3743 }
3744
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303745 /* Parse and fetch lost ap sample size */
3746 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3747 hddLog(LOGE, FL("attr lost ap sample size failed"));
3748 goto fail;
3749 }
3750
3751 pReqMsg->lostBssidSampleSize = nla_get_u32(
3752 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3753 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3754
Dino Mycle6fb96c12014-06-10 11:52:40 +05303755 pReqMsg->sessionId = pAdapter->sessionId;
3756 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3757
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303758 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303759 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303760 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303761
3762 nla_for_each_nested(apTh,
3763 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3764 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3765 nla_data(apTh), nla_len(apTh),
3766 NULL)) {
3767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3768 goto fail;
3769 }
3770
3771 /* Parse and fetch MAC address */
3772 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3774 goto fail;
3775 }
3776 memcpy(pReqMsg->ap[i].bssid, nla_data(
3777 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3778 sizeof(tSirMacAddr));
3779 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3780
3781 /* Parse and fetch low RSSI */
3782 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3784 goto fail;
3785 }
3786 pReqMsg->ap[i].low = nla_get_s32(
3787 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3788 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3789
3790 /* Parse and fetch high RSSI */
3791 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3793 goto fail;
3794 }
3795 pReqMsg->ap[i].high = nla_get_s32(
3796 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3797 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3798 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303799 i++;
3800 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303801
3802 context = &pHddCtx->ext_scan_context;
3803 spin_lock(&hdd_context_lock);
3804 INIT_COMPLETION(context->response_event);
3805 context->request_id = request_id = pReqMsg->requestId;
3806 spin_unlock(&hdd_context_lock);
3807
Dino Mycle6fb96c12014-06-10 11:52:40 +05303808 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3809 if (!HAL_STATUS_SUCCESS(status)) {
3810 hddLog(VOS_TRACE_LEVEL_ERROR,
3811 FL("sme_SetBssHotlist failed(err=%d)"), status);
3812 vos_mem_free(pReqMsg);
3813 return -EINVAL;
3814 }
3815
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303816 /* request was sent -- wait for the response */
3817 rc = wait_for_completion_timeout(&context->response_event,
3818 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3819
3820 if (!rc) {
3821 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3822 retval = -ETIMEDOUT;
3823 } else {
3824 spin_lock(&hdd_context_lock);
3825 if (context->request_id == request_id)
3826 retval = context->response_status;
3827 else
3828 retval = -EINVAL;
3829 spin_unlock(&hdd_context_lock);
3830 }
3831
Dino Myclee8843b32014-07-04 14:21:45 +05303832 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303833 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303834 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303835
3836fail:
3837 vos_mem_free(pReqMsg);
3838 return -EINVAL;
3839}
3840
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303841static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3842 struct wireless_dev *wdev,
3843 const void *data, int dataLen)
3844{
3845 int ret = 0;
3846
3847 vos_ssr_protect(__func__);
3848 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3849 dataLen);
3850 vos_ssr_unprotect(__func__);
3851
3852 return ret;
3853}
3854
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303855/*
3856 * define short names for the global vendor params
3857 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
3858 */
3859#define PARAM_MAX \
3860QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3861#define PARAM_REQUEST_ID \
3862QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3863#define PARAMS_LOST_SSID_SAMPLE_SIZE \
3864QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
3865#define PARAMS_NUM_SSID \
3866QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
3867#define THRESHOLD_PARAM \
3868QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
3869#define PARAM_SSID \
3870QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
3871#define PARAM_BAND \
3872QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
3873#define PARAM_RSSI_LOW \
3874QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
3875#define PARAM_RSSI_HIGH \
3876QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
3877
3878/**
3879 * __wlan_hdd_cfg80211_extscan_set_ssid_hotlist() - set ssid hot list
3880 * @wiphy: Pointer to wireless phy
3881 * @wdev: Pointer to wireless device
3882 * @data: Pointer to data
3883 * @data_len: Data length
3884 *
3885 * Return: 0 on success, negative errno on failure
3886 */
3887static int
3888__wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
3889 struct wireless_dev *wdev,
3890 const void *data,
3891 int data_len)
3892{
3893 tSirEXTScanSetSsidHotListReqParams *request;
3894 struct net_device *dev = wdev->netdev;
3895 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3896 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
3897 struct nlattr *tb[PARAM_MAX + 1];
3898 struct nlattr *tb2[PARAM_MAX + 1];
3899 struct nlattr *ssids;
3900 struct hdd_ext_scan_context *context;
3901 uint32_t request_id;
3902 char ssid_string[SIR_MAC_MAX_SSID_LENGTH + 1] = {'\0'};
3903 int ssid_len;
3904 eHalStatus status;
3905 int i, rem, retval;
3906 unsigned long rc;
3907
3908 ENTER();
3909
3910 if (VOS_FTM_MODE == hdd_get_conparam()) {
3911 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3912 return -EINVAL;
3913 }
3914
3915 retval = wlan_hdd_validate_context(hdd_ctx);
3916 if (0 != retval) {
3917 hddLog(LOGE, FL("HDD context is not valid"));
3918 return -EINVAL;
3919 }
3920
3921 /* check the EXTScan Capability */
3922 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05303923 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
3924 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05303925 {
3926 hddLog(VOS_TRACE_LEVEL_ERROR,
3927 FL("EXTScan not enabled/supported by Firmware"));
3928 return -EINVAL;
3929 }
3930
3931 if (nla_parse(tb, PARAM_MAX,
3932 data, data_len,
3933 wlan_hdd_extscan_config_policy)) {
3934 hddLog(LOGE, FL("Invalid ATTR"));
3935 return -EINVAL;
3936 }
3937
3938 request = vos_mem_malloc(sizeof(*request));
3939 if (!request) {
3940 hddLog(LOGE, FL("vos_mem_malloc failed"));
3941 return -ENOMEM;
3942 }
3943
3944 /* Parse and fetch request Id */
3945 if (!tb[PARAM_REQUEST_ID]) {
3946 hddLog(LOGE, FL("attr request id failed"));
3947 goto fail;
3948 }
3949
3950 request->request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
3951 hddLog(LOG1, FL("Request Id %d"), request->request_id);
3952
3953 /* Parse and fetch lost SSID sample size */
3954 if (!tb[PARAMS_LOST_SSID_SAMPLE_SIZE]) {
3955 hddLog(LOGE, FL("attr number of Ssid failed"));
3956 goto fail;
3957 }
3958 request->lost_ssid_sample_size =
3959 nla_get_u32(tb[PARAMS_LOST_SSID_SAMPLE_SIZE]);
3960 hddLog(LOG1, FL("Lost SSID Sample Size %d"),
3961 request->lost_ssid_sample_size);
3962
3963 /* Parse and fetch number of hotlist SSID */
3964 if (!tb[PARAMS_NUM_SSID]) {
3965 hddLog(LOGE, FL("attr number of Ssid failed"));
3966 goto fail;
3967 }
3968 request->ssid_count = nla_get_u32(tb[PARAMS_NUM_SSID]);
3969 hddLog(LOG1, FL("Number of SSID %d"), request->ssid_count);
3970
3971 request->session_id = adapter->sessionId;
3972 hddLog(LOG1, FL("Session Id (%d)"), request->session_id);
3973
3974 i = 0;
3975 nla_for_each_nested(ssids, tb[THRESHOLD_PARAM], rem) {
3976 if (i >= WLAN_EXTSCAN_MAX_HOTLIST_SSIDS) {
3977 hddLog(LOGE,
3978 FL("Too Many SSIDs, %d exceeds %d"),
3979 i, WLAN_EXTSCAN_MAX_HOTLIST_SSIDS);
3980 break;
3981 }
3982 if (nla_parse(tb2, PARAM_MAX,
3983 nla_data(ssids), nla_len(ssids),
3984 wlan_hdd_extscan_config_policy)) {
3985 hddLog(LOGE, FL("nla_parse failed"));
3986 goto fail;
3987 }
3988
3989 /* Parse and fetch SSID */
3990 if (!tb2[PARAM_SSID]) {
3991 hddLog(LOGE, FL("attr ssid failed"));
3992 goto fail;
3993 }
3994 nla_memcpy(ssid_string,
3995 tb2[PARAM_SSID],
3996 sizeof(ssid_string));
3997 hddLog(LOG1, FL("SSID %s"),
3998 ssid_string);
3999 ssid_len = strlen(ssid_string);
4000 memcpy(request->ssid[i].ssid.ssId, ssid_string, ssid_len);
4001 request->ssid[i].ssid.length = ssid_len;
4002 request->ssid[i].ssid.ssId[ssid_len] = '\0';
4003 hddLog(LOG1, FL("After copying SSID %s"),
4004 request->ssid[i].ssid.ssId);
4005 hddLog(LOG1, FL("After copying length: %d"),
4006 ssid_len);
4007
4008 /* Parse and fetch low RSSI */
4009 if (!tb2[PARAM_BAND]) {
4010 hddLog(LOGE, FL("attr band failed"));
4011 goto fail;
4012 }
4013 request->ssid[i].band = nla_get_u8(tb2[PARAM_BAND]);
4014 hddLog(LOG1, FL("band %d"), request->ssid[i].band);
4015
4016 /* Parse and fetch low RSSI */
4017 if (!tb2[PARAM_RSSI_LOW]) {
4018 hddLog(LOGE, FL("attr low RSSI failed"));
4019 goto fail;
4020 }
4021 request->ssid[i].rssi_low = nla_get_s32(tb2[PARAM_RSSI_LOW]);
4022 hddLog(LOG1, FL("RSSI low %d"), request->ssid[i].rssi_low);
4023
4024 /* Parse and fetch high RSSI */
4025 if (!tb2[PARAM_RSSI_HIGH]) {
4026 hddLog(LOGE, FL("attr high RSSI failed"));
4027 goto fail;
4028 }
4029 request->ssid[i].rssi_high = nla_get_u32(tb2[PARAM_RSSI_HIGH]);
4030 hddLog(LOG1, FL("RSSI high %d"), request->ssid[i].rssi_high);
4031 i++;
4032 }
4033
4034 context = &hdd_ctx->ext_scan_context;
4035 spin_lock(&hdd_context_lock);
4036 INIT_COMPLETION(context->response_event);
4037 context->request_id = request_id = request->request_id;
4038 spin_unlock(&hdd_context_lock);
4039
4040 status = sme_set_ssid_hotlist(hdd_ctx->hHal, request);
4041 if (!HAL_STATUS_SUCCESS(status)) {
4042 hddLog(LOGE,
4043 FL("sme_set_ssid_hotlist failed(err=%d)"), status);
4044 goto fail;
4045 }
4046
4047 vos_mem_free(request);
4048
4049 /* request was sent -- wait for the response */
4050 rc = wait_for_completion_timeout(&context->response_event,
4051 msecs_to_jiffies
4052 (WLAN_WAIT_TIME_EXTSCAN));
4053 if (!rc) {
4054 hddLog(LOGE, FL("sme_set_ssid_hotlist timed out"));
4055 retval = -ETIMEDOUT;
4056 } else {
4057 spin_lock(&hdd_context_lock);
4058 if (context->request_id == request_id)
4059 retval = context->response_status;
4060 else
4061 retval = -EINVAL;
4062 spin_unlock(&hdd_context_lock);
4063 }
4064
4065 return retval;
4066
4067fail:
4068 vos_mem_free(request);
4069 return -EINVAL;
4070}
4071
4072/*
4073 * done with short names for the global vendor params
4074 * used by wlan_hdd_cfg80211_extscan_set_ssid_hotlist()
4075 */
4076#undef PARAM_MAX
4077#undef PARAM_REQUEST_ID
4078#undef PARAMS_NUM_SSID
4079#undef THRESHOLD_PARAM
4080#undef PARAM_SSID
4081#undef PARAM_BAND
4082#undef PARAM_RSSI_LOW
4083#undef PARAM_RSSI_HIGH
4084
4085static int wlan_hdd_cfg80211_extscan_set_ssid_hotlist(struct wiphy *wiphy,
4086 struct wireless_dev *wdev,
4087 const void *data, int dataLen)
4088{
4089 int ret = 0;
4090
4091 vos_ssr_protect(__func__);
4092 ret = __wlan_hdd_cfg80211_extscan_set_ssid_hotlist(wiphy, wdev, data,
4093 dataLen);
4094 vos_ssr_unprotect(__func__);
4095
4096 return ret;
4097}
4098
4099static int
4100__wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4101 struct wireless_dev *wdev,
4102 const void *data,
4103 int data_len)
4104{
4105 tSirEXTScanResetSsidHotlistReqParams request;
4106 struct net_device *dev = wdev->netdev;
4107 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4108 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
4109 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4110 struct hdd_ext_scan_context *context;
4111 uint32_t request_id;
4112 eHalStatus status;
4113 int retval;
4114 unsigned long rc;
4115
4116 ENTER();
4117
4118 if (VOS_FTM_MODE == hdd_get_conparam()) {
4119 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4120 return -EINVAL;
4121 }
4122
4123 retval = wlan_hdd_validate_context(hdd_ctx);
4124 if (0 != retval) {
4125 hddLog(LOGE, FL("HDD context is not valid"));
4126 return -EINVAL;
4127 }
4128
4129 /* check the EXTScan Capability */
4130 if ( (TRUE != hdd_ctx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304131 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4132 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05304133 {
4134 hddLog(LOGE,
4135 FL("EXTScan not enabled/supported by Firmware"));
4136 return -EINVAL;
4137 }
4138
4139 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4140 data, data_len,
4141 wlan_hdd_extscan_config_policy)) {
4142 hddLog(LOGE, FL("Invalid ATTR"));
4143 return -EINVAL;
4144 }
4145
4146 /* Parse and fetch request Id */
4147 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4148 hddLog(LOGE, FL("attr request id failed"));
4149 return -EINVAL;
4150 }
4151
4152 request.requestId = nla_get_u32(
4153 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4154 request.sessionId = adapter->sessionId;
4155 hddLog(LOG1, FL("Request Id %d Session Id %d"), request.requestId,
4156 request.sessionId);
4157
4158 context = &hdd_ctx->ext_scan_context;
4159 spin_lock(&hdd_context_lock);
4160 INIT_COMPLETION(context->response_event);
4161 context->request_id = request_id = request.requestId;
4162 spin_unlock(&hdd_context_lock);
4163
4164 status = sme_reset_ssid_hotlist(hdd_ctx->hHal, &request);
4165 if (!HAL_STATUS_SUCCESS(status)) {
4166 hddLog(LOGE,
4167 FL("sme_reset_ssid_hotlist failed(err=%d)"), status);
4168 return -EINVAL;
4169 }
4170
4171 /* request was sent -- wait for the response */
4172 rc = wait_for_completion_timeout(&context->response_event,
4173 msecs_to_jiffies
4174 (WLAN_WAIT_TIME_EXTSCAN));
4175 if (!rc) {
4176 hddLog(LOGE, FL("sme_reset_ssid_hotlist timed out"));
4177 retval = -ETIMEDOUT;
4178 } else {
4179 spin_lock(&hdd_context_lock);
4180 if (context->request_id == request_id)
4181 retval = context->response_status;
4182 else
4183 retval = -EINVAL;
4184 spin_unlock(&hdd_context_lock);
4185 }
4186
4187 return retval;
4188}
4189
4190static int
4191wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(struct wiphy *wiphy,
4192 struct wireless_dev *wdev,
4193 const void *data,
4194 int data_len)
4195{
4196 int ret;
4197
4198 vos_ssr_protect(__func__);
4199 ret = __wlan_hdd_cfg80211_extscan_reset_ssid_hotlist(wiphy, wdev,
4200 data, data_len);
4201 vos_ssr_unprotect(__func__);
4202
4203 return ret;
4204}
4205
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304206static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304207 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304208 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304209{
4210 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4211 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4212 tANI_U8 numChannels = 0;
4213 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304214 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304215 tWifiBand wifiBand;
4216 eHalStatus status;
4217 struct sk_buff *replySkb;
4218 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304219 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304220
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304221 ENTER();
4222
Dino Mycle6fb96c12014-06-10 11:52:40 +05304223 status = wlan_hdd_validate_context(pHddCtx);
4224 if (0 != status)
4225 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304226 return -EINVAL;
4227 }
Dino Myclee8843b32014-07-04 14:21:45 +05304228
Dino Mycle6fb96c12014-06-10 11:52:40 +05304229 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4230 data, dataLen,
4231 wlan_hdd_extscan_config_policy)) {
4232 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4233 return -EINVAL;
4234 }
4235
4236 /* Parse and fetch request Id */
4237 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4239 return -EINVAL;
4240 }
4241 requestId = nla_get_u32(
4242 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4243 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4244
4245 /* Parse and fetch wifi band */
4246 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4247 {
4248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4249 return -EINVAL;
4250 }
4251 wifiBand = nla_get_u32(
4252 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4253 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4254
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304255 /* Parse and fetch max channels */
4256 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4257 {
4258 hddLog(LOGE, FL("attr max channels failed"));
4259 return -EINVAL;
4260 }
4261 maxChannels = nla_get_u32(
4262 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4263 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4264
Dino Mycle6fb96c12014-06-10 11:52:40 +05304265 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
4266 wifiBand, ChannelList,
4267 &numChannels);
4268 if (eHAL_STATUS_SUCCESS != status) {
4269 hddLog(VOS_TRACE_LEVEL_ERROR,
4270 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4271 return -EINVAL;
4272 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304273
4274 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304275 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304276
Dino Mycle6fb96c12014-06-10 11:52:40 +05304277 for (i = 0; i < numChannels; i++)
4278 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4279
4280 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4281 sizeof(u32) * numChannels +
4282 NLMSG_HDRLEN);
4283
4284 if (!replySkb) {
4285 hddLog(VOS_TRACE_LEVEL_ERROR,
4286 FL("valid channels: buffer alloc fail"));
4287 return -EINVAL;
4288 }
4289 if (nla_put_u32(replySkb,
4290 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4291 numChannels) ||
4292 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4293 sizeof(u32) * numChannels, ChannelList)) {
4294
4295 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4296 kfree_skb(replySkb);
4297 return -EINVAL;
4298 }
4299
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304300 ret = cfg80211_vendor_cmd_reply(replySkb);
4301
4302 EXIT();
4303 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304304}
4305
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304306static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4307 struct wireless_dev *wdev,
4308 const void *data, int dataLen)
4309{
4310 int ret = 0;
4311
4312 vos_ssr_protect(__func__);
4313 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4314 dataLen);
4315 vos_ssr_unprotect(__func__);
4316
4317 return ret;
4318}
4319
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304320static int hdd_extscan_start_fill_bucket_channel_spec(
4321 hdd_context_t *pHddCtx,
4322 tpSirEXTScanStartReqParams pReqMsg,
4323 struct nlattr **tb)
4324{
4325 struct nlattr *bucket[
4326 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4327 struct nlattr *channel[
4328 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4329 struct nlattr *buckets;
4330 struct nlattr *channels;
4331 int rem1, rem2;
4332 eHalStatus status;
4333 tANI_U8 bktIndex, j, numChannels;
4334 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4335 tANI_U32 passive_max_chn_time, active_max_chn_time;
4336
4337 bktIndex = 0;
4338
4339 nla_for_each_nested(buckets,
4340 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4341 if (nla_parse(bucket,
4342 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4343 nla_data(buckets), nla_len(buckets), NULL)) {
4344 hddLog(LOGE, FL("nla_parse failed"));
4345 return -EINVAL;
4346 }
4347
4348 /* Parse and fetch bucket spec */
4349 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4350 hddLog(LOGE, FL("attr bucket index failed"));
4351 return -EINVAL;
4352 }
4353 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4354 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4355 hddLog(LOG1, FL("Bucket spec Index %d"),
4356 pReqMsg->buckets[bktIndex].bucket);
4357
4358 /* Parse and fetch wifi band */
4359 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4360 hddLog(LOGE, FL("attr wifi band failed"));
4361 return -EINVAL;
4362 }
4363 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4364 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4365 hddLog(LOG1, FL("Wifi band %d"),
4366 pReqMsg->buckets[bktIndex].band);
4367
4368 /* Parse and fetch period */
4369 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4370 hddLog(LOGE, FL("attr period failed"));
4371 return -EINVAL;
4372 }
4373 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4374 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4375 hddLog(LOG1, FL("period %d"),
4376 pReqMsg->buckets[bktIndex].period);
4377
4378 /* Parse and fetch report events */
4379 if (!bucket[
4380 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4381 hddLog(LOGE, FL("attr report events failed"));
4382 return -EINVAL;
4383 }
4384 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4385 bucket[
4386 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4387 hddLog(LOG1, FL("report events %d"),
4388 pReqMsg->buckets[bktIndex].reportEvents);
4389
4390 /* Parse and fetch max period */
4391 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4392 hddLog(LOGE, FL("attr max period failed"));
4393 return -EINVAL;
4394 }
4395 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4396 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4397 hddLog(LOG1, FL("max period %u"),
4398 pReqMsg->buckets[bktIndex].max_period);
4399
4400 /* Parse and fetch exponent */
4401 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4402 hddLog(LOGE, FL("attr exponent failed"));
4403 return -EINVAL;
4404 }
4405 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4406 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4407 hddLog(LOG1, FL("exponent %u"),
4408 pReqMsg->buckets[bktIndex].exponent);
4409
4410 /* Parse and fetch step count */
4411 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4412 hddLog(LOGE, FL("attr step count failed"));
4413 return -EINVAL;
4414 }
4415 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4416 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4417 hddLog(LOG1, FL("Step count %u"),
4418 pReqMsg->buckets[bktIndex].step_count);
4419
4420 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4421 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4422
4423 /* Framework shall pass the channel list if the input WiFi band is
4424 * WIFI_BAND_UNSPECIFIED.
4425 * If the input WiFi band is specified (any value other than
4426 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4427 */
4428 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4429 numChannels = 0;
4430 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4431 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4432 pReqMsg->buckets[bktIndex].band,
4433 chanList, &numChannels);
4434 if (!HAL_STATUS_SUCCESS(status)) {
4435 hddLog(LOGE,
4436 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4437 status);
4438 return -EINVAL;
4439 }
4440
4441 pReqMsg->buckets[bktIndex].numChannels =
4442 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4443 hddLog(LOG1, FL("Num channels %d"),
4444 pReqMsg->buckets[bktIndex].numChannels);
4445
4446 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4447 j++) {
4448 pReqMsg->buckets[bktIndex].channels[j].channel =
4449 chanList[j];
4450 pReqMsg->buckets[bktIndex].channels[j].
4451 chnlClass = 0;
4452 if (CSR_IS_CHANNEL_DFS(
4453 vos_freq_to_chan(chanList[j]))) {
4454 pReqMsg->buckets[bktIndex].channels[j].
4455 passive = 1;
4456 pReqMsg->buckets[bktIndex].channels[j].
4457 dwellTimeMs = passive_max_chn_time;
4458 } else {
4459 pReqMsg->buckets[bktIndex].channels[j].
4460 passive = 0;
4461 pReqMsg->buckets[bktIndex].channels[j].
4462 dwellTimeMs = active_max_chn_time;
4463 }
4464
4465 hddLog(LOG1,
4466 "Channel %u Passive %u Dwell time %u ms",
4467 pReqMsg->buckets[bktIndex].channels[j].channel,
4468 pReqMsg->buckets[bktIndex].channels[j].passive,
4469 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4470 }
4471
4472 bktIndex++;
4473 continue;
4474 }
4475
4476 /* Parse and fetch number of channels */
4477 if (!bucket[
4478 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4479 hddLog(LOGE, FL("attr num channels failed"));
4480 return -EINVAL;
4481 }
4482
4483 pReqMsg->buckets[bktIndex].numChannels =
4484 nla_get_u32(bucket[
4485 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4486 hddLog(LOG1, FL("num channels %d"),
4487 pReqMsg->buckets[bktIndex].numChannels);
4488
4489 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4490 hddLog(LOGE, FL("attr channel spec failed"));
4491 return -EINVAL;
4492 }
4493
4494 j = 0;
4495 nla_for_each_nested(channels,
4496 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4497 if (nla_parse(channel,
4498 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4499 nla_data(channels), nla_len(channels),
4500 wlan_hdd_extscan_config_policy)) {
4501 hddLog(LOGE, FL("nla_parse failed"));
4502 return -EINVAL;
4503 }
4504
4505 /* Parse and fetch channel */
4506 if (!channel[
4507 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4508 hddLog(LOGE, FL("attr channel failed"));
4509 return -EINVAL;
4510 }
4511 pReqMsg->buckets[bktIndex].channels[j].channel =
4512 nla_get_u32(channel[
4513 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4514 hddLog(LOG1, FL("channel %u"),
4515 pReqMsg->buckets[bktIndex].channels[j].channel);
4516
4517 /* Parse and fetch dwell time */
4518 if (!channel[
4519 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4520 hddLog(LOGE, FL("attr dwelltime failed"));
4521 return -EINVAL;
4522 }
4523 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4524 nla_get_u32(channel[
4525 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4526
4527 hddLog(LOG1, FL("Dwell time (%u ms)"),
4528 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4529
4530
4531 /* Parse and fetch channel spec passive */
4532 if (!channel[
4533 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4534 hddLog(LOGE,
4535 FL("attr channel spec passive failed"));
4536 return -EINVAL;
4537 }
4538 pReqMsg->buckets[bktIndex].channels[j].passive =
4539 nla_get_u8(channel[
4540 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4541 hddLog(LOG1, FL("Chnl spec passive %u"),
4542 pReqMsg->buckets[bktIndex].channels[j].passive);
4543
4544 j++;
4545 }
4546
4547 bktIndex++;
4548 }
4549
4550 return 0;
4551}
4552
4553
4554/*
4555 * define short names for the global vendor params
4556 * used by wlan_hdd_cfg80211_extscan_start()
4557 */
4558#define PARAM_MAX \
4559QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4560#define PARAM_REQUEST_ID \
4561QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4562#define PARAM_BASE_PERIOD \
4563QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4564#define PARAM_MAX_AP_PER_SCAN \
4565QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4566#define PARAM_RPT_THRHLD_PERCENT \
4567QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4568#define PARAM_RPT_THRHLD_NUM_SCANS \
4569QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4570#define PARAM_NUM_BUCKETS \
4571QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4572
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304573static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304574 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304575 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304576{
Dino Myclee8843b32014-07-04 14:21:45 +05304577 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304578 struct net_device *dev = wdev->netdev;
4579 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4580 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4581 struct nlattr *tb[PARAM_MAX + 1];
4582 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304583 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304584 tANI_U32 request_id;
4585 struct hdd_ext_scan_context *context;
4586 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304587
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304588 ENTER();
4589
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304590 if (VOS_FTM_MODE == hdd_get_conparam()) {
4591 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4592 return -EINVAL;
4593 }
4594
Dino Mycle6fb96c12014-06-10 11:52:40 +05304595 status = wlan_hdd_validate_context(pHddCtx);
4596 if (0 != status)
4597 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304598 return -EINVAL;
4599 }
Dino Myclee8843b32014-07-04 14:21:45 +05304600 /* check the EXTScan Capability */
4601 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304602 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4603 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304604 {
4605 hddLog(VOS_TRACE_LEVEL_ERROR,
4606 FL("EXTScan not enabled/supported by Firmware"));
4607 return -EINVAL;
4608 }
4609
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304610 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304611 data, dataLen,
4612 wlan_hdd_extscan_config_policy)) {
4613 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4614 return -EINVAL;
4615 }
4616
4617 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304618 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304619 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4620 return -EINVAL;
4621 }
4622
Dino Myclee8843b32014-07-04 14:21:45 +05304623 pReqMsg = (tpSirEXTScanStartReqParams)
4624 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304625 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304626 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4627 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304628 }
4629
4630 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304631 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304632 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4633
4634 pReqMsg->sessionId = pAdapter->sessionId;
4635 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4636
4637 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304638 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304639 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4640 goto fail;
4641 }
4642 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304643 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304644 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4645 pReqMsg->basePeriod);
4646
4647 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304648 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4650 goto fail;
4651 }
4652 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304653 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304654 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4655 pReqMsg->maxAPperScan);
4656
4657 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304658 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4660 goto fail;
4661 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304662 pReqMsg->reportThresholdPercent = nla_get_u8(
4663 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304664 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304665 pReqMsg->reportThresholdPercent);
4666
4667 /* Parse and fetch report threshold num scans */
4668 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4669 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4670 goto fail;
4671 }
4672 pReqMsg->reportThresholdNumScans = nla_get_u8(
4673 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4674 hddLog(LOG1, FL("Report Threshold num scans %d"),
4675 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304676
4677 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304678 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304679 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4680 goto fail;
4681 }
4682 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304683 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304684 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4685 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4686 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4687 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4688 }
4689 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4690 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304691
Dino Mycle6fb96c12014-06-10 11:52:40 +05304692 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4694 goto fail;
4695 }
4696
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304697 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304698
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304699 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4700 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304701
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304702 context = &pHddCtx->ext_scan_context;
4703 spin_lock(&hdd_context_lock);
4704 INIT_COMPLETION(context->response_event);
4705 context->request_id = request_id = pReqMsg->requestId;
4706 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304707
Dino Mycle6fb96c12014-06-10 11:52:40 +05304708 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4709 if (!HAL_STATUS_SUCCESS(status)) {
4710 hddLog(VOS_TRACE_LEVEL_ERROR,
4711 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304712 goto fail;
4713 }
4714
4715 /* request was sent -- wait for the response */
4716 rc = wait_for_completion_timeout(&context->response_event,
4717 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4718
4719 if (!rc) {
4720 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4721 retval = -ETIMEDOUT;
4722 } else {
4723 spin_lock(&hdd_context_lock);
4724 if (context->request_id == request_id)
4725 retval = context->response_status;
4726 else
4727 retval = -EINVAL;
4728 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304729 }
4730
Dino Myclee8843b32014-07-04 14:21:45 +05304731 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304732 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304733 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304734
4735fail:
4736 vos_mem_free(pReqMsg);
4737 return -EINVAL;
4738}
4739
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304740/*
4741 * done with short names for the global vendor params
4742 * used by wlan_hdd_cfg80211_extscan_start()
4743 */
4744#undef PARAM_MAX
4745#undef PARAM_REQUEST_ID
4746#undef PARAM_BASE_PERIOD
4747#undef PARAMS_MAX_AP_PER_SCAN
4748#undef PARAMS_RPT_THRHLD_PERCENT
4749#undef PARAMS_RPT_THRHLD_NUM_SCANS
4750#undef PARAMS_NUM_BUCKETS
4751
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304752static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4753 struct wireless_dev *wdev,
4754 const void *data, int dataLen)
4755{
4756 int ret = 0;
4757
4758 vos_ssr_protect(__func__);
4759 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4760 vos_ssr_unprotect(__func__);
4761
4762 return ret;
4763}
4764
4765static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304766 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304767 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304768{
Dino Myclee8843b32014-07-04 14:21:45 +05304769 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304770 struct net_device *dev = wdev->netdev;
4771 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4772 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4773 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4774 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304775 int retval;
4776 unsigned long rc;
4777 struct hdd_ext_scan_context *context;
4778 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304779
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304780 ENTER();
4781
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304782 if (VOS_FTM_MODE == hdd_get_conparam()) {
4783 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4784 return -EINVAL;
4785 }
4786
Dino Mycle6fb96c12014-06-10 11:52:40 +05304787 status = wlan_hdd_validate_context(pHddCtx);
4788 if (0 != status)
4789 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304790 return -EINVAL;
4791 }
Dino Myclee8843b32014-07-04 14:21:45 +05304792 /* check the EXTScan Capability */
4793 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304794 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4795 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304796 {
4797 hddLog(VOS_TRACE_LEVEL_ERROR,
4798 FL("EXTScan not enabled/supported by Firmware"));
4799 return -EINVAL;
4800 }
4801
Dino Mycle6fb96c12014-06-10 11:52:40 +05304802 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4803 data, dataLen,
4804 wlan_hdd_extscan_config_policy)) {
4805 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4806 return -EINVAL;
4807 }
4808
4809 /* Parse and fetch request Id */
4810 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4812 return -EINVAL;
4813 }
4814
Dino Myclee8843b32014-07-04 14:21:45 +05304815 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304816 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304817 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304818
Dino Myclee8843b32014-07-04 14:21:45 +05304819 reqMsg.sessionId = pAdapter->sessionId;
4820 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304821
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304822 context = &pHddCtx->ext_scan_context;
4823 spin_lock(&hdd_context_lock);
4824 INIT_COMPLETION(context->response_event);
4825 context->request_id = request_id = reqMsg.sessionId;
4826 spin_unlock(&hdd_context_lock);
4827
Dino Myclee8843b32014-07-04 14:21:45 +05304828 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304829 if (!HAL_STATUS_SUCCESS(status)) {
4830 hddLog(VOS_TRACE_LEVEL_ERROR,
4831 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304832 return -EINVAL;
4833 }
4834
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304835 /* request was sent -- wait for the response */
4836 rc = wait_for_completion_timeout(&context->response_event,
4837 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4838
4839 if (!rc) {
4840 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4841 retval = -ETIMEDOUT;
4842 } else {
4843 spin_lock(&hdd_context_lock);
4844 if (context->request_id == request_id)
4845 retval = context->response_status;
4846 else
4847 retval = -EINVAL;
4848 spin_unlock(&hdd_context_lock);
4849 }
4850
4851 return retval;
4852
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304853 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304854 return 0;
4855}
4856
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304857static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4858 struct wireless_dev *wdev,
4859 const void *data, int dataLen)
4860{
4861 int ret = 0;
4862
4863 vos_ssr_protect(__func__);
4864 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4865 vos_ssr_unprotect(__func__);
4866
4867 return ret;
4868}
4869
4870static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304871 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304872 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304873{
Dino Myclee8843b32014-07-04 14:21:45 +05304874 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304875 struct net_device *dev = wdev->netdev;
4876 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4877 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4878 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4879 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304880 struct hdd_ext_scan_context *context;
4881 tANI_U32 request_id;
4882 unsigned long rc;
4883 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304884
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304885 ENTER();
4886
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304887 if (VOS_FTM_MODE == hdd_get_conparam()) {
4888 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4889 return -EINVAL;
4890 }
4891
Dino Mycle6fb96c12014-06-10 11:52:40 +05304892 status = wlan_hdd_validate_context(pHddCtx);
4893 if (0 != status)
4894 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304895 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304896 return -EINVAL;
4897 }
Dino Myclee8843b32014-07-04 14:21:45 +05304898 /* check the EXTScan Capability */
4899 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05304900 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) ||
4901 (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)))
Dino Myclee8843b32014-07-04 14:21:45 +05304902 {
4903 hddLog(VOS_TRACE_LEVEL_ERROR,
4904 FL("EXTScan not enabled/supported by Firmware"));
4905 return -EINVAL;
4906 }
4907
Dino Mycle6fb96c12014-06-10 11:52:40 +05304908 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4909 data, dataLen,
4910 wlan_hdd_extscan_config_policy)) {
4911 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4912 return -EINVAL;
4913 }
4914
4915 /* Parse and fetch request Id */
4916 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4917 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4918 return -EINVAL;
4919 }
4920
Dino Myclee8843b32014-07-04 14:21:45 +05304921 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304922 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304923 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304924
Dino Myclee8843b32014-07-04 14:21:45 +05304925 reqMsg.sessionId = pAdapter->sessionId;
4926 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304927
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304928 context = &pHddCtx->ext_scan_context;
4929 spin_lock(&hdd_context_lock);
4930 INIT_COMPLETION(context->response_event);
4931 context->request_id = request_id = reqMsg.requestId;
4932 spin_unlock(&hdd_context_lock);
4933
Dino Myclee8843b32014-07-04 14:21:45 +05304934 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304935 if (!HAL_STATUS_SUCCESS(status)) {
4936 hddLog(VOS_TRACE_LEVEL_ERROR,
4937 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304938 return -EINVAL;
4939 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304940
4941 /* request was sent -- wait for the response */
4942 rc = wait_for_completion_timeout(&context->response_event,
4943 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4944 if (!rc) {
4945 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4946 retval = -ETIMEDOUT;
4947 } else {
4948 spin_lock(&hdd_context_lock);
4949 if (context->request_id == request_id)
4950 retval = context->response_status;
4951 else
4952 retval = -EINVAL;
4953 spin_unlock(&hdd_context_lock);
4954 }
4955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304956 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304957 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304958}
4959
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304960static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4961 struct wireless_dev *wdev,
4962 const void *data, int dataLen)
4963{
4964 int ret = 0;
4965
4966 vos_ssr_protect(__func__);
4967 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4968 vos_ssr_unprotect(__func__);
4969
4970 return ret;
4971}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304972#endif /* WLAN_FEATURE_EXTSCAN */
4973
Atul Mittal115287b2014-07-08 13:26:33 +05304974/*EXT TDLS*/
4975static const struct nla_policy
4976wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4977{
4978 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4979 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4980 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4981 {.type = NLA_S32 },
4982 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4983 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4984
4985};
4986
4987static const struct nla_policy
4988wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4989{
4990 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4991
4992};
4993
4994static const struct nla_policy
4995wlan_hdd_tdls_config_state_change_policy[
4996 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4997{
4998 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4999 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
5000 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305001 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
5002 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
5003 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305004
5005};
5006
5007static const struct nla_policy
5008wlan_hdd_tdls_config_get_status_policy[
5009 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
5010{
5011 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
5012 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
5013 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305014 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
5015 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
5016 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05305017
5018};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305019
5020static const struct nla_policy
5021wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
5022{
5023 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
5024};
5025
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305026static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305027 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305028 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305029 int data_len)
5030{
5031
5032 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5033 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
5034
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305035 ENTER();
5036
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305037 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305038 return -EINVAL;
5039 }
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +05305040 if (0 == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305041 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305042 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05305043 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305044 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05305045 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305046 return -ENOTSUPP;
5047 }
5048
5049 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
5050 data, data_len, wlan_hdd_mac_config)) {
5051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5052 return -EINVAL;
5053 }
5054
5055 /* Parse and fetch mac address */
5056 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
5057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5058 return -EINVAL;
5059 }
5060
5061 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
5062 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5063 VOS_MAC_ADDR_LAST_3_BYTES);
5064
Siddharth Bhal76972212014-10-15 16:22:51 +05305065 pHddCtx->spoofMacAddr.isEnabled = TRUE;
5066
5067 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305068 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
5069 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05305070 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
5071 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
5072 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
5073 {
5074 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
5075 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
5076 VOS_MAC_ADDRESS_LEN);
5077 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305078 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305079
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +05305080 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
5081 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305082
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305083 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305084 return 0;
5085}
5086
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305087static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
5088 struct wireless_dev *wdev,
5089 const void *data,
5090 int data_len)
5091{
5092 int ret = 0;
5093
5094 vos_ssr_protect(__func__);
5095 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
5096 vos_ssr_unprotect(__func__);
5097
5098 return ret;
5099}
5100
5101static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305102 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305103 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305104 int data_len)
5105{
5106 u8 peer[6] = {0};
5107 struct net_device *dev = wdev->netdev;
5108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5109 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5110 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
5111 eHalStatus ret;
5112 tANI_S32 state;
5113 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305114 tANI_S32 global_operating_class = 0;
5115 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05305116 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305117 int retVal;
5118
5119 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305120
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305121 if (!pAdapter) {
5122 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5123 return -EINVAL;
5124 }
5125
Atul Mittal115287b2014-07-08 13:26:33 +05305126 ret = wlan_hdd_validate_context(pHddCtx);
5127 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305128 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305129 return -EINVAL;
5130 }
5131 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305133 return -ENOTSUPP;
5134 }
5135 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
5136 data, data_len,
5137 wlan_hdd_tdls_config_get_status_policy)) {
5138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5139 return -EINVAL;
5140 }
5141
5142 /* Parse and fetch mac address */
5143 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
5144 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5145 return -EINVAL;
5146 }
5147
5148 memcpy(peer, nla_data(
5149 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5150 sizeof(peer));
5151 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5152
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305153 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305154
Atul Mittal115287b2014-07-08 13:26:33 +05305155 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305156 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305157 NLMSG_HDRLEN);
5158
5159 if (!skb) {
5160 hddLog(VOS_TRACE_LEVEL_ERROR,
5161 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5162 return -EINVAL;
5163 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305164 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 +05305165 reason,
5166 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305167 global_operating_class,
5168 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305169 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305170 if (nla_put_s32(skb,
5171 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5172 state) ||
5173 nla_put_s32(skb,
5174 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5175 reason) ||
5176 nla_put_s32(skb,
5177 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5178 global_operating_class) ||
5179 nla_put_s32(skb,
5180 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5181 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305182
5183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5184 goto nla_put_failure;
5185 }
5186
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305187 retVal = cfg80211_vendor_cmd_reply(skb);
5188 EXIT();
5189 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305190
5191nla_put_failure:
5192 kfree_skb(skb);
5193 return -EINVAL;
5194}
5195
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305196static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5197 struct wireless_dev *wdev,
5198 const void *data,
5199 int data_len)
5200{
5201 int ret = 0;
5202
5203 vos_ssr_protect(__func__);
5204 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5205 vos_ssr_unprotect(__func__);
5206
5207 return ret;
5208}
5209
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305210static int wlan_hdd_cfg80211_exttdls_callback(
5211#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5212 const tANI_U8* mac,
5213#else
5214 tANI_U8* mac,
5215#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305216 tANI_S32 state,
5217 tANI_S32 reason,
5218 void *ctx)
5219{
5220 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305221 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305222 tANI_S32 global_operating_class = 0;
5223 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305224 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305225
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305226 ENTER();
5227
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305228 if (!pAdapter) {
5229 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5230 return -EINVAL;
5231 }
5232
5233 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305234 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305236 return -EINVAL;
5237 }
5238
5239 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305241 return -ENOTSUPP;
5242 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305243 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5244#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5245 NULL,
5246#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305247 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5248 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5249 GFP_KERNEL);
5250
5251 if (!skb) {
5252 hddLog(VOS_TRACE_LEVEL_ERROR,
5253 FL("cfg80211_vendor_event_alloc failed"));
5254 return -EINVAL;
5255 }
5256 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305257 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5258 reason,
5259 state,
5260 global_operating_class,
5261 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305262 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5263 MAC_ADDR_ARRAY(mac));
5264
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305265 if (nla_put(skb,
5266 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5267 VOS_MAC_ADDR_SIZE, mac) ||
5268 nla_put_s32(skb,
5269 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5270 state) ||
5271 nla_put_s32(skb,
5272 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5273 reason) ||
5274 nla_put_s32(skb,
5275 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5276 channel) ||
5277 nla_put_s32(skb,
5278 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5279 global_operating_class)
5280 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305281 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5282 goto nla_put_failure;
5283 }
5284
5285 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305286 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305287 return (0);
5288
5289nla_put_failure:
5290 kfree_skb(skb);
5291 return -EINVAL;
5292}
5293
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305294static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305295 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305296 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305297 int data_len)
5298{
5299 u8 peer[6] = {0};
5300 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305301 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5302 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5303 eHalStatus status;
5304 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305305 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305306 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305307
5308 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305309
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305310 if (!dev) {
5311 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5312 return -EINVAL;
5313 }
5314
5315 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5316 if (!pAdapter) {
5317 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5318 return -EINVAL;
5319 }
5320
Atul Mittal115287b2014-07-08 13:26:33 +05305321 status = wlan_hdd_validate_context(pHddCtx);
5322 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305323 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305324 return -EINVAL;
5325 }
5326 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305327 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305328 return -ENOTSUPP;
5329 }
5330 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5331 data, data_len,
5332 wlan_hdd_tdls_config_enable_policy)) {
5333 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5334 return -EINVAL;
5335 }
5336
5337 /* Parse and fetch mac address */
5338 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5339 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5340 return -EINVAL;
5341 }
5342
5343 memcpy(peer, nla_data(
5344 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5345 sizeof(peer));
5346 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5347
5348 /* Parse and fetch channel */
5349 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5350 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5351 return -EINVAL;
5352 }
5353 pReqMsg.channel = nla_get_s32(
5354 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5355 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5356
5357 /* Parse and fetch global operating class */
5358 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5359 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5360 return -EINVAL;
5361 }
5362 pReqMsg.global_operating_class = nla_get_s32(
5363 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5364 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5365 pReqMsg.global_operating_class);
5366
5367 /* Parse and fetch latency ms */
5368 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5370 return -EINVAL;
5371 }
5372 pReqMsg.max_latency_ms = nla_get_s32(
5373 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5374 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5375 pReqMsg.max_latency_ms);
5376
5377 /* Parse and fetch required bandwidth kbps */
5378 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5380 return -EINVAL;
5381 }
5382
5383 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5384 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5385 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5386 pReqMsg.min_bandwidth_kbps);
5387
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305388 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305389 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305390 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305391 wlan_hdd_cfg80211_exttdls_callback);
5392
5393 EXIT();
5394 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305395}
5396
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305397static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5398 struct wireless_dev *wdev,
5399 const void *data,
5400 int data_len)
5401{
5402 int ret = 0;
5403
5404 vos_ssr_protect(__func__);
5405 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5406 vos_ssr_unprotect(__func__);
5407
5408 return ret;
5409}
5410
5411static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305412 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305413 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305414 int data_len)
5415{
5416 u8 peer[6] = {0};
5417 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305418 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5419 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5420 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305421 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305422 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305423
5424 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305425
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305426 if (!dev) {
5427 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5428 return -EINVAL;
5429 }
5430
5431 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5432 if (!pAdapter) {
5433 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5434 return -EINVAL;
5435 }
5436
Atul Mittal115287b2014-07-08 13:26:33 +05305437 status = wlan_hdd_validate_context(pHddCtx);
5438 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305439 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305440 return -EINVAL;
5441 }
5442 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305443 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305444 return -ENOTSUPP;
5445 }
5446 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5447 data, data_len,
5448 wlan_hdd_tdls_config_disable_policy)) {
5449 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5450 return -EINVAL;
5451 }
5452 /* Parse and fetch mac address */
5453 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5455 return -EINVAL;
5456 }
5457
5458 memcpy(peer, nla_data(
5459 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5460 sizeof(peer));
5461 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5462
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305463 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5464
5465 EXIT();
5466 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305467}
5468
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305469static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5470 struct wireless_dev *wdev,
5471 const void *data,
5472 int data_len)
5473{
5474 int ret = 0;
5475
5476 vos_ssr_protect(__func__);
5477 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5478 vos_ssr_unprotect(__func__);
5479
5480 return ret;
5481}
5482
Dasari Srinivas7875a302014-09-26 17:50:57 +05305483static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305484__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305485 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305486 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305487{
5488 struct net_device *dev = wdev->netdev;
5489 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5490 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5491 struct sk_buff *skb = NULL;
5492 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305493 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305494
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305495 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305496
5497 ret = wlan_hdd_validate_context(pHddCtx);
5498 if (0 != ret)
5499 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305500 return ret;
5501 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305502 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5503 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5504 fset |= WIFI_FEATURE_INFRA;
5505 }
5506
5507 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5508 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5509 fset |= WIFI_FEATURE_INFRA_5G;
5510 }
5511
5512#ifdef WLAN_FEATURE_P2P
5513 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5514 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5515 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5516 fset |= WIFI_FEATURE_P2P;
5517 }
5518#endif
5519
5520 /* Soft-AP is supported currently by default */
5521 fset |= WIFI_FEATURE_SOFT_AP;
5522
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305523 /* HOTSPOT is a supplicant feature, enable it by default */
5524 fset |= WIFI_FEATURE_HOTSPOT;
5525
Dasari Srinivas7875a302014-09-26 17:50:57 +05305526#ifdef WLAN_FEATURE_EXTSCAN
5527 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
Padma, Santhosh Kumar2ac54992015-10-12 18:20:58 +05305528 sme_IsFeatureSupportedByFW(EXTENDED_SCAN) &&
5529 sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) {
5530 hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware"));
Dasari Srinivas7875a302014-09-26 17:50:57 +05305531 fset |= WIFI_FEATURE_EXTSCAN;
5532 }
5533#endif
5534
Dasari Srinivas7875a302014-09-26 17:50:57 +05305535 if (sme_IsFeatureSupportedByFW(NAN)) {
5536 hddLog(LOG1, FL("NAN is supported by firmware"));
5537 fset |= WIFI_FEATURE_NAN;
5538 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305539
5540 /* D2D RTT is not supported currently by default */
5541 if (sme_IsFeatureSupportedByFW(RTT)) {
5542 hddLog(LOG1, FL("RTT is supported by firmware"));
5543 fset |= WIFI_FEATURE_D2AP_RTT;
5544 }
5545
Padma, Santhosh Kumaraac4c4d2015-12-08 16:07:47 +05305546 if (sme_IsFeatureSupportedByFW(RTT3)) {
5547 hddLog(LOG1, FL("RTT3 is supported by firmware"));
5548 fset |= WIFI_FEATURE_RTT3;
5549 }
5550
Dasari Srinivas7875a302014-09-26 17:50:57 +05305551#ifdef FEATURE_WLAN_BATCH_SCAN
5552 if (fset & WIFI_FEATURE_EXTSCAN) {
5553 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5554 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5555 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5556 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5557 fset |= WIFI_FEATURE_BATCH_SCAN;
5558 }
5559#endif
5560
5561#ifdef FEATURE_WLAN_SCAN_PNO
5562 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5563 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5564 hddLog(LOG1, FL("PNO is supported by firmware"));
5565 fset |= WIFI_FEATURE_PNO;
5566 }
5567#endif
5568
5569 /* STA+STA is supported currently by default */
5570 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5571
5572#ifdef FEATURE_WLAN_TDLS
5573 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5574 sme_IsFeatureSupportedByFW(TDLS)) {
5575 hddLog(LOG1, FL("TDLS is supported by firmware"));
5576 fset |= WIFI_FEATURE_TDLS;
5577 }
5578
5579 /* TDLS_OFFCHANNEL is not supported currently by default */
5580#endif
5581
5582#ifdef WLAN_AP_STA_CONCURRENCY
5583 /* AP+STA concurrency is supported currently by default */
5584 fset |= WIFI_FEATURE_AP_STA;
5585#endif
5586
Mukul Sharma5add0532015-08-17 15:57:47 +05305587#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5588 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5589 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5590#endif
5591
Dasari Srinivas7875a302014-09-26 17:50:57 +05305592 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5593 NLMSG_HDRLEN);
5594
5595 if (!skb) {
5596 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5597 return -EINVAL;
5598 }
5599 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5600
5601 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5602 hddLog(LOGE, FL("nla put fail"));
5603 goto nla_put_failure;
5604 }
5605
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305606 ret = cfg80211_vendor_cmd_reply(skb);
5607 EXIT();
5608 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305609
5610nla_put_failure:
5611 kfree_skb(skb);
5612 return -EINVAL;
5613}
5614
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305615static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305616wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5617 struct wireless_dev *wdev,
5618 const void *data, int data_len)
5619{
5620 int ret = 0;
5621
5622 vos_ssr_protect(__func__);
5623 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5624 vos_ssr_unprotect(__func__);
5625
5626 return ret;
5627}
5628
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305629
5630static const struct
5631nla_policy
5632qca_wlan_vendor_wifi_logger_get_ring_data_policy
5633[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = {
5634 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]
5635 = {.type = NLA_U32 },
5636};
5637
5638static int
5639 __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5640 struct wireless_dev *wdev,
5641 const void *data,
5642 int data_len)
5643{
5644 int ret;
5645 VOS_STATUS status;
5646 uint32_t ring_id;
5647 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5648 struct nlattr *tb
5649 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1];
5650
5651 ENTER();
5652
5653 ret = wlan_hdd_validate_context(hdd_ctx);
5654 if (0 != ret) {
5655 return ret;
5656 }
5657
5658 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX,
5659 data, data_len,
5660 qca_wlan_vendor_wifi_logger_get_ring_data_policy)) {
5661 hddLog(LOGE, FL("Invalid attribute"));
5662 return -EINVAL;
5663 }
5664
5665 /* Parse and fetch ring id */
5666 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) {
5667 hddLog(LOGE, FL("attr ATTR failed"));
5668 return -EINVAL;
5669 }
5670
5671 ring_id = nla_get_u32(
5672 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]);
5673
5674 hddLog(LOG1, FL("Bug report triggered by framework"));
5675
5676 status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
5677 WLAN_LOG_INDICATOR_FRAMEWORK,
5678 WLAN_LOG_REASON_CODE_FRAMEWORK,
Abhishek Singh837adf22015-10-01 17:37:37 +05305679 TRUE, TRUE
Sachin Ahujac08f72a2015-09-22 15:25:47 +05305680 );
5681 if (VOS_STATUS_SUCCESS != status) {
5682 hddLog(LOGE, FL("Failed to trigger bug report"));
5683
5684 return -EINVAL;
5685 }
5686
5687 return 0;
5688
5689
5690}
5691
5692
5693static int
5694 wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy,
5695 struct wireless_dev *wdev,
5696 const void *data,
5697 int data_len)
5698{
5699 int ret = 0;
5700
5701 vos_ssr_protect(__func__);
5702 ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy,
5703 wdev, data, data_len);
5704 vos_ssr_unprotect(__func__);
5705
5706 return ret;
5707
5708}
5709
5710
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305711static int
5712__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305713 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305714 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305715{
5716 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5717 uint8_t i, feature_sets, max_feature_sets;
5718 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5719 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305720 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5721 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305722
5723 ENTER();
5724
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305725 ret = wlan_hdd_validate_context(pHddCtx);
5726 if (0 != ret)
5727 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305728 return ret;
5729 }
5730
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305731 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5732 data, data_len, NULL)) {
5733 hddLog(LOGE, FL("Invalid ATTR"));
5734 return -EINVAL;
5735 }
5736
5737 /* Parse and fetch max feature set */
5738 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5739 hddLog(LOGE, FL("Attr max feature set size failed"));
5740 return -EINVAL;
5741 }
5742 max_feature_sets = nla_get_u32(
5743 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5744 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5745
5746 /* Fill feature combination matrix */
5747 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305748 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5749 WIFI_FEATURE_P2P;
5750
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305751 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5752 WIFI_FEATURE_SOFT_AP;
5753
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305754 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5755 WIFI_FEATURE_SOFT_AP;
5756
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305757 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5758 WIFI_FEATURE_SOFT_AP |
5759 WIFI_FEATURE_P2P;
5760
5761 /* Add more feature combinations here */
5762
5763 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5764 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5765 hddLog(LOG1, "Feature set matrix");
5766 for (i = 0; i < feature_sets; i++)
5767 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5768
5769 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5770 sizeof(u32) * feature_sets +
5771 NLMSG_HDRLEN);
5772
5773 if (reply_skb) {
5774 if (nla_put_u32(reply_skb,
5775 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5776 feature_sets) ||
5777 nla_put(reply_skb,
5778 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5779 sizeof(u32) * feature_sets, feature_set_matrix)) {
5780 hddLog(LOGE, FL("nla put fail"));
5781 kfree_skb(reply_skb);
5782 return -EINVAL;
5783 }
5784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305785 ret = cfg80211_vendor_cmd_reply(reply_skb);
5786 EXIT();
5787 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305788 }
5789 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5790 return -ENOMEM;
5791
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305792}
5793
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305794static int
5795wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5796 struct wireless_dev *wdev,
5797 const void *data, int data_len)
5798{
5799 int ret = 0;
5800
5801 vos_ssr_protect(__func__);
5802 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5803 data_len);
5804 vos_ssr_unprotect(__func__);
5805
5806 return ret;
5807}
5808
c_manjeecfd1efb2015-09-25 19:32:34 +05305809
5810static int
5811__wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5812 struct wireless_dev *wdev,
5813 const void *data, int data_len)
5814{
5815 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5816 int ret;
5817 ENTER();
5818
5819 ret = wlan_hdd_validate_context(pHddCtx);
5820 if (0 != ret)
5821 {
5822 return ret;
5823 }
5824
5825 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
5826 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
5827 {
5828 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
5829 return -EINVAL;
5830 }
5831 /*call common API for FW mem dump req*/
5832 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
5833
Abhishek Singhc783fa72015-12-09 18:07:34 +05305834 if (!ret)
c_manjee04b4c5c2015-10-13 18:35:01 +05305835 {
5836 /*indicate to userspace the status of fw mem dump */
5837 wlan_indicate_mem_dump_complete(true);
5838 }
5839 else
5840 {
5841 /*else send failure to userspace */
5842 wlan_indicate_mem_dump_complete(false);
5843 }
c_manjeecfd1efb2015-09-25 19:32:34 +05305844 EXIT();
5845 return ret;
5846}
5847
5848/**
5849 * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump
5850 * @wiphy: pointer to wireless wiphy structure.
5851 * @wdev: pointer to wireless_dev structure.
5852 * @data: Pointer to the NL data.
5853 * @data_len:Length of @data
5854 *
5855 * This is called when wlan driver needs to get the firmware memory dump
5856 * via vendor specific command.
5857 *
5858 * Return: 0 on success, error number otherwise.
5859 */
5860
5861static int
5862wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy,
5863 struct wireless_dev *wdev,
5864 const void *data, int data_len)
Sushant Kaushik8e644982015-09-23 12:18:54 +05305865{
5866 int ret = 0;
5867 vos_ssr_protect(__func__);
5868 ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data,
5869 data_len);
5870 vos_ssr_unprotect(__func__);
5871 return ret;
5872}
c_manjeecfd1efb2015-09-25 19:32:34 +05305873
Sushant Kaushik8e644982015-09-23 12:18:54 +05305874static const struct
5875nla_policy
5876qca_wlan_vendor_wifi_logger_start_policy
5877[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = {
5878 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]
5879 = {.type = NLA_U32 },
5880 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]
5881 = {.type = NLA_U32 },
5882 [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]
5883 = {.type = NLA_U32 },
5884};
5885
5886/**
5887 * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable
5888 * or disable the collection of packet statistics from the firmware
5889 * @wiphy: WIPHY structure pointer
5890 * @wdev: Wireless device structure pointer
5891 * @data: Pointer to the data received
5892 * @data_len: Length of the data received
5893 *
5894 * This function is used to enable or disable the collection of packet
5895 * statistics from the firmware
5896 *
5897 * Return: 0 on success and errno on failure
5898 */
5899static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5900 struct wireless_dev *wdev,
5901 const void *data,
5902 int data_len)
5903{
5904 eHalStatus status;
5905 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5906 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1];
5907 tAniWifiStartLog start_log;
5908
5909 status = wlan_hdd_validate_context(hdd_ctx);
5910 if (0 != status) {
5911 return -EINVAL;
5912 }
5913
5914 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX,
5915 data, data_len,
5916 qca_wlan_vendor_wifi_logger_start_policy)) {
5917 hddLog(LOGE, FL("Invalid attribute"));
5918 return -EINVAL;
5919 }
5920
5921 /* Parse and fetch ring id */
5922 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) {
5923 hddLog(LOGE, FL("attr ATTR failed"));
5924 return -EINVAL;
5925 }
5926 start_log.ringId = nla_get_u32(
5927 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]);
5928 hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId);
5929
5930 /* Parse and fetch verbose level */
5931 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) {
5932 hddLog(LOGE, FL("attr verbose_level failed"));
5933 return -EINVAL;
5934 }
5935 start_log.verboseLevel = nla_get_u32(
5936 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]);
5937 hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel);
5938
5939 /* Parse and fetch flag */
5940 if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) {
5941 hddLog(LOGE, FL("attr flag failed"));
5942 return -EINVAL;
5943 }
5944 start_log.flag = nla_get_u32(
5945 tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]);
5946 hddLog(LOG1, FL("flag=%d"), start_log.flag);
5947
5948 if ((RING_ID_PER_PACKET_STATS == start_log.ringId) &&
Sushant Kaushik33200572015-08-05 16:46:20 +05305949 (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable ||
5950 !vos_isPktStatsEnabled()))
5951
Sushant Kaushik8e644982015-09-23 12:18:54 +05305952 {
5953 hddLog(LOGE, FL("per pkt stats not enabled"));
5954 return -EINVAL;
5955 }
Sushant Kaushik8e644982015-09-23 12:18:54 +05305956
Sushant Kaushik33200572015-08-05 16:46:20 +05305957 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305958 return 0;
5959}
5960
5961/**
5962 * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable
5963 * or disable the collection of packet statistics from the firmware
5964 * @wiphy: WIPHY structure pointer
5965 * @wdev: Wireless device structure pointer
5966 * @data: Pointer to the data received
5967 * @data_len: Length of the data received
5968 *
5969 * This function is used to enable or disable the collection of packet
5970 * statistics from the firmware
5971 *
5972 * Return: 0 on success and errno on failure
5973 */
5974static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy,
5975 struct wireless_dev *wdev,
5976 const void *data,
5977 int data_len)
c_manjeecfd1efb2015-09-25 19:32:34 +05305978{
5979 int ret = 0;
5980
5981 vos_ssr_protect(__func__);
Sushant Kaushik8e644982015-09-23 12:18:54 +05305982
5983 ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy,
5984 wdev, data, data_len);
c_manjeecfd1efb2015-09-25 19:32:34 +05305985 vos_ssr_unprotect(__func__);
5986
5987 return ret;
c_manjeecfd1efb2015-09-25 19:32:34 +05305988}
5989
5990
Agarwal Ashish738843c2014-09-25 12:27:56 +05305991static const struct nla_policy
5992wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5993 +1] =
5994{
5995 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5996};
5997
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305998static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305999 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05306000 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05306001 int data_len)
6002{
6003 struct net_device *dev = wdev->netdev;
6004 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6005 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6006 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6007 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
6008 eHalStatus status;
6009 u32 dfsFlag = 0;
6010
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306011 ENTER();
6012
Agarwal Ashish738843c2014-09-25 12:27:56 +05306013 status = wlan_hdd_validate_context(pHddCtx);
6014 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05306015 return -EINVAL;
6016 }
6017 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
6018 data, data_len,
6019 wlan_hdd_set_no_dfs_flag_config_policy)) {
6020 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6021 return -EINVAL;
6022 }
6023
6024 /* Parse and fetch required bandwidth kbps */
6025 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
6026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
6027 return -EINVAL;
6028 }
6029
6030 dfsFlag = nla_get_u32(
6031 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
6032 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
6033 dfsFlag);
6034
6035 pHddCtx->disable_dfs_flag = dfsFlag;
6036
6037 sme_disable_dfs_channel(hHal, dfsFlag);
6038 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306039
6040 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05306041 return 0;
6042}
Atul Mittal115287b2014-07-08 13:26:33 +05306043
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306044static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
6045 struct wireless_dev *wdev,
6046 const void *data,
6047 int data_len)
6048{
6049 int ret = 0;
6050
6051 vos_ssr_protect(__func__);
6052 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
6053 vos_ssr_unprotect(__func__);
6054
6055 return ret;
6056
6057}
6058
Mukul Sharma2a271632014-10-13 14:59:01 +05306059const struct
6060nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
6061{
6062 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
6063 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
6064};
6065
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306066static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05306067 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05306068{
6069
6070 u8 bssid[6] = {0};
6071 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6072 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6073 eHalStatus status = eHAL_STATUS_SUCCESS;
6074 v_U32_t isFwrRoamEnabled = FALSE;
6075 int ret;
6076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306077 ENTER();
6078
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306079 ret = wlan_hdd_validate_context(pHddCtx);
6080 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306081 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05306082 }
6083
6084 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
6085 data, data_len,
6086 qca_wlan_vendor_attr);
6087 if (ret){
6088 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
6089 return -EINVAL;
6090 }
6091
6092 /* Parse and fetch Enable flag */
6093 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
6094 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
6095 return -EINVAL;
6096 }
6097
6098 isFwrRoamEnabled = nla_get_u32(
6099 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
6100
6101 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
6102
6103 /* Parse and fetch bssid */
6104 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
6105 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
6106 return -EINVAL;
6107 }
6108
6109 memcpy(bssid, nla_data(
6110 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
6111 sizeof(bssid));
6112 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
6113
6114 //Update roaming
6115 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306116 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05306117 return status;
6118}
6119
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05306120static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
6121 struct wireless_dev *wdev, const void *data, int data_len)
6122{
6123 int ret = 0;
6124
6125 vos_ssr_protect(__func__);
6126 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
6127 vos_ssr_unprotect(__func__);
6128
6129 return ret;
6130}
6131
Sushant Kaushik847890c2015-09-28 16:05:17 +05306132static const struct
6133nla_policy
6134qca_wlan_vendor_get_wifi_info_policy[
6135 QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = {
6136 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 },
6137 [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 },
6138};
6139
6140
6141/**
6142 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6143 * @wiphy: pointer to wireless wiphy structure.
6144 * @wdev: pointer to wireless_dev structure.
6145 * @data: Pointer to the data to be passed via vendor interface
6146 * @data_len:Length of the data to be passed
6147 *
6148 * This is called when wlan driver needs to send wifi driver related info
6149 * (driver/fw version) to the user space application upon request.
6150 *
6151 * Return: Return the Success or Failure code.
6152 */
6153static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6154 struct wireless_dev *wdev,
6155 const void *data, int data_len)
6156{
6157 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6158 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
6159 tSirVersionString version;
6160 uint32 version_len;
6161 uint8 attr;
6162 int status;
6163 struct sk_buff *reply_skb = NULL;
6164
6165 if (VOS_FTM_MODE == hdd_get_conparam()) {
6166 hddLog(LOGE, FL("Command not allowed in FTM mode"));
6167 return -EINVAL;
6168 }
6169
6170 status = wlan_hdd_validate_context(hdd_ctx);
6171 if (0 != status) {
6172 hddLog(LOGE, FL("HDD context is not valid"));
6173 return -EINVAL;
6174 }
6175
6176 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data,
6177 data_len, qca_wlan_vendor_get_wifi_info_policy)) {
6178 hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed"));
6179 return -EINVAL;
6180 }
6181
6182 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
6183 hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"),
6184 QWLAN_VERSIONSTR);
6185 strlcpy(version, QWLAN_VERSIONSTR, sizeof(version));
6186 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION;
6187 } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) {
6188 hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"),
6189 hdd_ctx->fw_Version);
6190 strlcpy(version, hdd_ctx->fw_Version, sizeof(version));
6191 attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION;
6192 } else {
6193 hddLog(LOGE, FL("Invalid attribute in get wifi info request"));
6194 return -EINVAL;
6195 }
6196
6197 version_len = strlen(version);
6198 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
6199 version_len + NLA_HDRLEN + NLMSG_HDRLEN);
6200 if (!reply_skb) {
6201 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
6202 return -ENOMEM;
6203 }
6204
6205 if (nla_put(reply_skb, attr, version_len, version)) {
6206 hddLog(LOGE, FL("nla put fail"));
6207 kfree_skb(reply_skb);
6208 return -EINVAL;
6209 }
6210
6211 return cfg80211_vendor_cmd_reply(reply_skb);
6212}
6213
6214/**
6215 * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info
6216 * @wiphy: pointer to wireless wiphy structure.
6217 * @wdev: pointer to wireless_dev structure.
6218 * @data: Pointer to the data to be passed via vendor interface
6219 * @data_len:Length of the data to be passed
6220 * @data_len: Length of the data received
6221 *
6222 * This function is used to enable or disable the collection of packet
6223 * statistics from the firmware
6224 *
6225 * Return: 0 on success and errno on failure
6226 */
6227
6228static int
6229wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
6230 struct wireless_dev *wdev,
6231 const void *data, int data_len)
6232
6233
6234{
6235 int ret = 0;
6236
6237 vos_ssr_protect(__func__);
6238 ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy,
6239 wdev, data, data_len);
6240 vos_ssr_unprotect(__func__);
6241
6242 return ret;
6243}
6244
6245
Gupta, Kapil7c34b322015-09-30 13:12:35 +05306246/*
6247 * define short names for the global vendor params
6248 * used by __wlan_hdd_cfg80211_monitor_rssi()
6249 */
6250#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX
6251#define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID
6252#define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL
6253#define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI
6254#define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI
6255
6256/**---------------------------------------------------------------------------
6257
6258 \brief hdd_rssi_monitor_start_done - callback to be executed when rssi
6259 monitor start is completed successfully.
6260
6261 \return - None
6262
6263 --------------------------------------------------------------------------*/
6264void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6265{
6266 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6267
6268 if (NULL == pHddCtx)
6269 {
6270 hddLog(VOS_TRACE_LEVEL_ERROR,
6271 "%s: HDD context is NULL",__func__);
6272 return;
6273 }
6274
6275 if (VOS_STATUS_SUCCESS == status)
6276 {
6277 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful"));
6278 }
6279 else
6280 {
6281 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful"));
6282 }
6283
6284 return;
6285}
6286
6287/**---------------------------------------------------------------------------
6288
6289 \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor
6290 stop is completed successfully.
6291
6292 \return - None
6293
6294 --------------------------------------------------------------------------*/
6295void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status)
6296{
6297 hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext;
6298
6299 if (NULL == pHddCtx)
6300 {
6301 hddLog(VOS_TRACE_LEVEL_ERROR,
6302 "%s: HDD context is NULL",__func__);
6303 return;
6304 }
6305
6306 if (VOS_STATUS_SUCCESS == status)
6307 {
6308 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful"));
6309 }
6310 else
6311 {
6312 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful"));
6313 }
6314
6315 return;
6316}
6317
6318/**
6319 * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi
6320 * @wiphy: Pointer to wireless phy
6321 * @wdev: Pointer to wireless device
6322 * @data: Pointer to data
6323 * @data_len: Data length
6324 *
6325 * Return: 0 on success, negative errno on failure
6326 */
6327
6328static int
6329__wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy,
6330 struct wireless_dev *wdev,
6331 const void *data,
6332 int data_len)
6333{
6334 struct net_device *dev = wdev->netdev;
6335 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6336 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6337 hdd_station_ctx_t *pHddStaCtx;
6338 struct nlattr *tb[PARAM_MAX + 1];
6339 tpSirRssiMonitorReq pReq;
6340 eHalStatus status;
6341 int ret;
6342 uint32_t control;
6343 static const struct nla_policy policy[PARAM_MAX + 1] = {
6344 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6345 [PARAM_CONTROL] = { .type = NLA_U32 },
6346 [PARAM_MIN_RSSI] = { .type = NLA_S8 },
6347 [PARAM_MAX_RSSI] = { .type = NLA_S8 },
6348 };
6349
6350 ENTER();
6351
6352 ret = wlan_hdd_validate_context(hdd_ctx);
6353 if (0 != ret) {
6354 return -EINVAL;
6355 }
6356
6357 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
6358 hddLog(LOGE, FL("Not in Connected state!"));
6359 return -ENOTSUPP;
6360 }
6361
6362 if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) {
6363 hddLog(LOGE, FL("Invalid ATTR"));
6364 return -EINVAL;
6365 }
6366
6367 if (!tb[PARAM_REQUEST_ID]) {
6368 hddLog(LOGE, FL("attr request id failed"));
6369 return -EINVAL;
6370 }
6371
6372 if (!tb[PARAM_CONTROL]) {
6373 hddLog(LOGE, FL("attr control failed"));
6374 return -EINVAL;
6375 }
6376
6377 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6378
6379 pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq));
6380 if(NULL == pReq)
6381 {
6382 hddLog(LOGE,
6383 FL("vos_mem_alloc failed "));
6384 return eHAL_STATUS_FAILED_ALLOC;
6385 }
6386 vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0);
6387
6388 pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
6389 pReq->sessionId = pAdapter->sessionId;
6390 pReq->rssiMonitorCbContext = hdd_ctx;
6391 control = nla_get_u32(tb[PARAM_CONTROL]);
6392 vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
6393
6394 hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"),
6395 pReq->requestId, pReq->sessionId, control);
6396
6397 if (control == QCA_WLAN_RSSI_MONITORING_START) {
6398 if (!tb[PARAM_MIN_RSSI]) {
6399 hddLog(LOGE, FL("attr min rssi failed"));
6400 return -EINVAL;
6401 }
6402
6403 if (!tb[PARAM_MAX_RSSI]) {
6404 hddLog(LOGE, FL("attr max rssi failed"));
6405 return -EINVAL;
6406 }
6407
6408 pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]);
6409 pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]);
6410 pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done;
6411
6412 if (!(pReq->minRssi < pReq->maxRssi)) {
6413 hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"),
6414 pReq->minRssi, pReq->maxRssi);
6415 return -EINVAL;
6416 }
6417 hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"),
6418 pReq->minRssi, pReq->maxRssi);
6419 status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq);
6420
6421 }
6422 else if (control == QCA_WLAN_RSSI_MONITORING_STOP) {
6423 pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done;
6424 status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq);
6425 }
6426 else {
6427 hddLog(LOGE, FL("Invalid control cmd: %d"), control);
6428 return -EINVAL;
6429 }
6430
6431 if (!HAL_STATUS_SUCCESS(status)) {
6432 hddLog(LOGE,
6433 FL("sme_set_rssi_monitoring failed(err=%d)"), status);
6434 return -EINVAL;
6435 }
6436
6437 return 0;
6438}
6439
6440/*
6441 * done with short names for the global vendor params
6442 * used by __wlan_hdd_cfg80211_monitor_rssi()
6443 */
6444#undef PARAM_MAX
6445#undef PARAM_CONTROL
6446#undef PARAM_REQUEST_ID
6447#undef PARAM_MAX_RSSI
6448#undef PARAM_MIN_RSSI
6449
6450/**
6451 * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
6452 * @wiphy: wiphy structure pointer
6453 * @wdev: Wireless device structure pointer
6454 * @data: Pointer to the data received
6455 * @data_len: Length of @data
6456 *
6457 * Return: 0 on success; errno on failure
6458 */
6459static int
6460wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
6461 const void *data, int data_len)
6462{
6463 int ret;
6464
6465 vos_ssr_protect(__func__);
6466 ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len);
6467 vos_ssr_unprotect(__func__);
6468
6469 return ret;
6470}
6471
6472/**
6473 * hdd_rssi_threshold_breached_cb() - rssi breached NL event
6474 * @hddctx: HDD context
6475 * @data: rssi breached event data
6476 *
6477 * This function reads the rssi breached event %data and fill in the skb with
6478 * NL attributes and send up the NL event.
6479 * This callback execute in atomic context and must not invoke any
6480 * blocking calls.
6481 *
6482 * Return: none
6483 */
6484void hdd_rssi_threshold_breached_cb(void *hddctx,
6485 struct rssi_breach_event *data)
6486{
6487 hdd_context_t *pHddCtx = (hdd_context_t *)hddctx;
6488 int status;
6489 struct sk_buff *skb;
6490
6491 ENTER();
6492 status = wlan_hdd_validate_context(pHddCtx);
6493
6494 if (0 != status) {
6495 return;
6496 }
6497
6498 if (!data) {
6499 hddLog(LOGE, FL("data is null"));
6500 return;
6501 }
6502
6503 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
6504#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6505 NULL,
6506#endif
6507 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
6508 QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
6509 GFP_KERNEL);
6510
6511 if (!skb) {
6512 hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed"));
6513 return;
6514 }
6515
6516 hddLog(LOG1, "Req Id: %u Current rssi: %d",
6517 data->request_id, data->curr_rssi);
6518 hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR,
6519 MAC_ADDR_ARRAY(data->curr_bssid.bytes));
6520
6521 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID,
6522 data->request_id) ||
6523 nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID,
6524 sizeof(data->curr_bssid), data->curr_bssid.bytes) ||
6525 nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI,
6526 data->curr_rssi)) {
6527 hddLog(LOGE, FL("nla put fail"));
6528 goto fail;
6529 }
6530
6531 cfg80211_vendor_event(skb, GFP_KERNEL);
6532 return;
6533
6534fail:
6535 kfree_skb(skb);
6536 return;
6537}
6538
6539
6540
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306541/**
6542 * __wlan_hdd_cfg80211_setband() - set band
6543 * @wiphy: Pointer to wireless phy
6544 * @wdev: Pointer to wireless device
6545 * @data: Pointer to data
6546 * @data_len: Data length
6547 *
6548 * Return: 0 on success, negative errno on failure
6549 */
6550static int
6551__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6552 struct wireless_dev *wdev,
6553 const void *data,
6554 int data_len)
6555{
6556 struct net_device *dev = wdev->netdev;
6557 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6558 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
6559 int ret;
6560 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
6561 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
6562
6563 ENTER();
6564
6565 ret = wlan_hdd_validate_context(hdd_ctx);
6566 if (0 != ret) {
6567 hddLog(LOGE, FL("HDD context is not valid"));
6568 return ret;
6569 }
6570
6571 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
6572 policy)) {
6573 hddLog(LOGE, FL("Invalid ATTR"));
6574 return -EINVAL;
6575 }
6576
6577 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
6578 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
6579 return -EINVAL;
6580 }
6581
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306582 hdd_ctx->isSetBandByNL = TRUE;
6583 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306584 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05306585 hdd_ctx->isSetBandByNL = FALSE;
6586
6587 EXIT();
6588 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05306589}
6590
6591/**
6592 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
6593 * @wiphy: wiphy structure pointer
6594 * @wdev: Wireless device structure pointer
6595 * @data: Pointer to the data received
6596 * @data_len: Length of @data
6597 *
6598 * Return: 0 on success; errno on failure
6599 */
6600static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
6601 struct wireless_dev *wdev,
6602 const void *data,
6603 int data_len)
6604{
6605 int ret = 0;
6606
6607 vos_ssr_protect(__func__);
6608 ret = __wlan_hdd_cfg80211_setband(wiphy,
6609 wdev, data, data_len);
6610 vos_ssr_unprotect(__func__);
6611
6612 return ret;
6613}
6614
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05306615#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
6616/**
6617 * hdd_map_req_id_to_pattern_id() - map request id to pattern id
6618 * @hdd_ctx: HDD context
6619 * @request_id: [input] request id
6620 * @pattern_id: [output] pattern id
6621 *
6622 * This function loops through request id to pattern id array
6623 * if the slot is available, store the request id and return pattern id
6624 * if entry exists, return the pattern id
6625 *
6626 * Return: 0 on success and errno on failure
6627 */
6628static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6629 uint32_t request_id,
6630 uint8_t *pattern_id)
6631{
6632 uint32_t i;
6633
6634 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6635 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6636 {
6637 if (hdd_ctx->op_ctx.op_table[i].request_id == 0)
6638 {
6639 hdd_ctx->op_ctx.op_table[i].request_id = request_id;
6640 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6641 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6642 return 0;
6643 } else if (hdd_ctx->op_ctx.op_table[i].request_id ==
6644 request_id) {
6645 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6646 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6647 return 0;
6648 }
6649 }
6650 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6651 return -EINVAL;
6652}
6653
6654/**
6655 * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id
6656 * @hdd_ctx: HDD context
6657 * @request_id: [input] request id
6658 * @pattern_id: [output] pattern id
6659 *
6660 * This function loops through request id to pattern id array
6661 * reset request id to 0 (slot available again) and
6662 * return pattern id
6663 *
6664 * Return: 0 on success and errno on failure
6665 */
6666static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx,
6667 uint32_t request_id,
6668 uint8_t *pattern_id)
6669{
6670 uint32_t i;
6671
6672 mutex_lock(&hdd_ctx->op_ctx.op_lock);
6673 for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++)
6674 {
6675 if (hdd_ctx->op_ctx.op_table[i].request_id == request_id)
6676 {
6677 hdd_ctx->op_ctx.op_table[i].request_id = 0;
6678 *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id;
6679 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6680 return 0;
6681 }
6682 }
6683 mutex_unlock(&hdd_ctx->op_ctx.op_lock);
6684 return -EINVAL;
6685}
6686
6687
6688/*
6689 * define short names for the global vendor params
6690 * used by __wlan_hdd_cfg80211_offloaded_packets()
6691 */
6692#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX
6693#define PARAM_REQUEST_ID \
6694 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID
6695#define PARAM_CONTROL \
6696 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL
6697#define PARAM_IP_PACKET \
6698 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA
6699#define PARAM_SRC_MAC_ADDR \
6700 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR
6701#define PARAM_DST_MAC_ADDR \
6702 QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR
6703#define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD
6704
6705/**
6706 * wlan_hdd_add_tx_ptrn() - add tx pattern
6707 * @adapter: adapter pointer
6708 * @hdd_ctx: hdd context
6709 * @tb: nl attributes
6710 *
6711 * This function reads the NL attributes and forms a AddTxPtrn message
6712 * posts it to SME.
6713 *
6714 */
6715static int
6716wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6717 struct nlattr **tb)
6718{
6719 struct sSirAddPeriodicTxPtrn *add_req;
6720 eHalStatus status;
6721 uint32_t request_id, ret, len;
6722 uint8_t pattern_id = 0;
6723 v_MACADDR_t dst_addr;
6724 uint16_t eth_type = htons(ETH_P_IP);
6725
6726 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
6727 {
6728 hddLog(LOGE, FL("Not in Connected state!"));
6729 return -ENOTSUPP;
6730 }
6731
6732 add_req = vos_mem_malloc(sizeof(*add_req));
6733 if (!add_req)
6734 {
6735 hddLog(LOGE, FL("memory allocation failed"));
6736 return -ENOMEM;
6737 }
6738
6739 /* Parse and fetch request Id */
6740 if (!tb[PARAM_REQUEST_ID])
6741 {
6742 hddLog(LOGE, FL("attr request id failed"));
6743 goto fail;
6744 }
6745
6746 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6747 hddLog(LOG1, FL("Request Id: %u"), request_id);
6748 if (request_id == 0)
6749 {
6750 hddLog(LOGE, FL("request_id cannot be zero"));
6751 return -EINVAL;
6752 }
6753
6754 if (!tb[PARAM_PERIOD])
6755 {
6756 hddLog(LOGE, FL("attr period failed"));
6757 goto fail;
6758 }
6759 add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]);
6760 hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs);
6761 if (add_req->usPtrnIntervalMs == 0)
6762 {
6763 hddLog(LOGE, FL("Invalid interval zero, return failure"));
6764 goto fail;
6765 }
6766
6767 if (!tb[PARAM_SRC_MAC_ADDR])
6768 {
6769 hddLog(LOGE, FL("attr source mac address failed"));
6770 goto fail;
6771 }
6772 nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR],
6773 VOS_MAC_ADDR_SIZE);
6774 hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR,
6775 MAC_ADDR_ARRAY(add_req->macAddress));
6776
6777 if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes,
6778 VOS_MAC_ADDR_SIZE))
6779 {
6780 hddLog(LOGE,
6781 FL("input src mac address and connected ap bssid are different"));
6782 goto fail;
6783 }
6784
6785 if (!tb[PARAM_DST_MAC_ADDR])
6786 {
6787 hddLog(LOGE, FL("attr dst mac address failed"));
6788 goto fail;
6789 }
6790 nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE);
6791 hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR,
6792 MAC_ADDR_ARRAY(dst_addr.bytes));
6793
6794 if (!tb[PARAM_IP_PACKET])
6795 {
6796 hddLog(LOGE, FL("attr ip packet failed"));
6797 goto fail;
6798 }
6799 add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]);
6800 hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize);
6801
6802 if (add_req->ucPtrnSize < 0 ||
6803 add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE -
6804 HDD_ETH_HEADER_LEN))
6805 {
6806 hddLog(LOGE, FL("Invalid IP packet len: %d"),
6807 add_req->ucPtrnSize);
6808 goto fail;
6809 }
6810
6811 len = 0;
6812 vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE);
6813 len += VOS_MAC_ADDR_SIZE;
6814 vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress,
6815 VOS_MAC_ADDR_SIZE);
6816 len += VOS_MAC_ADDR_SIZE;
6817 vos_mem_copy(&add_req->ucPattern[len], &eth_type, 2);
6818 len += 2;
6819
6820 /*
6821 * This is the IP packet, add 14 bytes Ethernet (802.3) header
6822 * ------------------------------------------------------------
6823 * | 14 bytes Ethernet (802.3) header | IP header and payload |
6824 * ------------------------------------------------------------
6825 */
6826 vos_mem_copy(&add_req->ucPattern[len],
6827 nla_data(tb[PARAM_IP_PACKET]),
6828 add_req->ucPtrnSize);
6829 add_req->ucPtrnSize += len;
6830
6831 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6832 add_req->ucPattern, add_req->ucPtrnSize);
6833
6834 ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6835 if (ret)
6836 {
6837 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6838 goto fail;
6839 }
6840 add_req->ucPtrnId = pattern_id;
6841 hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId);
6842
6843 status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req);
6844 if (!HAL_STATUS_SUCCESS(status))
6845 {
6846 hddLog(LOGE,
6847 FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status);
6848 goto fail;
6849 }
6850
6851 EXIT();
6852 vos_mem_free(add_req);
6853 return 0;
6854
6855fail:
6856 vos_mem_free(add_req);
6857 return -EINVAL;
6858}
6859
6860/**
6861 * wlan_hdd_del_tx_ptrn() - delete tx pattern
6862 * @adapter: adapter pointer
6863 * @hdd_ctx: hdd context
6864 * @tb: nl attributes
6865 *
6866 * This function reads the NL attributes and forms a DelTxPtrn message
6867 * posts it to SME.
6868 *
6869 */
6870static int
6871wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
6872 struct nlattr **tb)
6873{
6874 struct sSirDelPeriodicTxPtrn *del_req;
6875 eHalStatus status;
6876 uint32_t request_id, ret;
6877 uint8_t pattern_id = 0;
6878
6879 /* Parse and fetch request Id */
6880 if (!tb[PARAM_REQUEST_ID])
6881 {
6882 hddLog(LOGE, FL("attr request id failed"));
6883 return -EINVAL;
6884 }
6885 request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
6886 if (request_id == 0)
6887 {
6888 hddLog(LOGE, FL("request_id cannot be zero"));
6889 return -EINVAL;
6890 }
6891
6892 ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id);
6893 if (ret)
6894 {
6895 hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret);
6896 return -EINVAL;
6897 }
6898
6899 del_req = vos_mem_malloc(sizeof(*del_req));
6900 if (!del_req)
6901 {
6902 hddLog(LOGE, FL("memory allocation failed"));
6903 return -ENOMEM;
6904 }
6905
6906 vos_mem_set(del_req, sizeof(*del_req), 0);
6907 vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes,
6908 VOS_MAC_ADDR_SIZE);
6909 hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress));
6910 del_req->ucPatternIdBitmap |= (0x1 << pattern_id);
6911 hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"),
6912 request_id, pattern_id, del_req->ucPatternIdBitmap);
6913
6914 status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req);
6915 if (!HAL_STATUS_SUCCESS(status))
6916 {
6917 hddLog(LOGE,
6918 FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status);
6919 goto fail;
6920 }
6921
6922 EXIT();
6923 vos_mem_free(del_req);
6924 return 0;
6925
6926fail:
6927 vos_mem_free(del_req);
6928 return -EINVAL;
6929}
6930
6931
6932/**
6933 * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets
6934 * @wiphy: Pointer to wireless phy
6935 * @wdev: Pointer to wireless device
6936 * @data: Pointer to data
6937 * @data_len: Data length
6938 *
6939 * Return: 0 on success, negative errno on failure
6940 */
6941static int
6942__wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
6943 struct wireless_dev *wdev,
6944 const void *data,
6945 int data_len)
6946{
6947 struct net_device *dev = wdev->netdev;
6948 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6949 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
6950 struct nlattr *tb[PARAM_MAX + 1];
6951 uint8_t control;
6952 int ret;
6953 static const struct nla_policy policy[PARAM_MAX + 1] =
6954 {
6955 [PARAM_REQUEST_ID] = { .type = NLA_U32 },
6956 [PARAM_CONTROL] = { .type = NLA_U32 },
6957 [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY,
6958 .len = VOS_MAC_ADDR_SIZE },
6959 [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY,
6960 .len = VOS_MAC_ADDR_SIZE },
6961 [PARAM_PERIOD] = { .type = NLA_U32 },
6962 };
6963
6964 ENTER();
6965
6966 ret = wlan_hdd_validate_context(hdd_ctx);
6967 if (0 != ret)
6968 {
6969 hddLog(LOGE, FL("HDD context is not valid"));
6970 return ret;
6971 }
6972
6973 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
6974 {
6975 hddLog(LOGE,
6976 FL("Periodic Tx Pattern Offload feature is not supported in FW!"));
6977 return -ENOTSUPP;
6978 }
6979
6980 if (nla_parse(tb, PARAM_MAX, data, data_len, policy))
6981 {
6982 hddLog(LOGE, FL("Invalid ATTR"));
6983 return -EINVAL;
6984 }
6985
6986 if (!tb[PARAM_CONTROL])
6987 {
6988 hddLog(LOGE, FL("attr control failed"));
6989 return -EINVAL;
6990 }
6991 control = nla_get_u32(tb[PARAM_CONTROL]);
6992 hddLog(LOG1, FL("Control: %d"), control);
6993
6994 if (control == WLAN_START_OFFLOADED_PACKETS)
6995 return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb);
6996 else if (control == WLAN_STOP_OFFLOADED_PACKETS)
6997 return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb);
6998 else
6999 {
7000 hddLog(LOGE, FL("Invalid control: %d"), control);
7001 return -EINVAL;
7002 }
7003}
7004
7005/*
7006 * done with short names for the global vendor params
7007 * used by __wlan_hdd_cfg80211_offloaded_packets()
7008 */
7009#undef PARAM_MAX
7010#undef PARAM_REQUEST_ID
7011#undef PARAM_CONTROL
7012#undef PARAM_IP_PACKET
7013#undef PARAM_SRC_MAC_ADDR
7014#undef PARAM_DST_MAC_ADDR
7015#undef PARAM_PERIOD
7016
7017/**
7018 * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets
7019 * @wiphy: wiphy structure pointer
7020 * @wdev: Wireless device structure pointer
7021 * @data: Pointer to the data received
7022 * @data_len: Length of @data
7023 *
7024 * Return: 0 on success; errno on failure
7025 */
7026static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy,
7027 struct wireless_dev *wdev,
7028 const void *data,
7029 int data_len)
7030{
7031 int ret = 0;
7032
7033 vos_ssr_protect(__func__);
7034 ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy,
7035 wdev, data, data_len);
7036 vos_ssr_unprotect(__func__);
7037
7038 return ret;
7039}
7040#endif
7041
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307042static const struct
7043nla_policy
7044qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = {
7045 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
7046};
7047
7048/**
7049 * wlan_hdd_cfg80211_get_link_properties() - This function is used to
7050 * get link properties like nss, rate flags and operating frequency for
7051 * the connection with the given peer.
7052 * @wiphy: WIPHY structure pointer
7053 * @wdev: Wireless device structure pointer
7054 * @data: Pointer to the data received
7055 * @data_len: Length of the data received
7056 *
7057 * This function return the above link properties on success.
7058 *
7059 * Return: 0 on success and errno on failure
7060 */
7061static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
7062 struct wireless_dev *wdev,
7063 const void *data,
7064 int data_len)
7065{
7066 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
7067 struct net_device *dev = wdev->netdev;
7068 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7069 hdd_station_ctx_t *hdd_sta_ctx;
7070 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1];
7071 uint8_t peer_mac[VOS_MAC_ADDR_SIZE];
7072 uint32_t sta_id;
7073 struct sk_buff *reply_skb;
7074 uint32_t rate_flags = 0;
7075 uint8_t nss;
7076 uint8_t final_rate_flags = 0;
7077 uint32_t freq;
7078 v_CONTEXT_t pVosContext = NULL;
7079 ptSapContext pSapCtx = NULL;
7080
7081 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
7082 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
7083 return -EINVAL;
7084 }
7085
7086 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
7087 qca_wlan_vendor_attr_policy)) {
7088 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute"));
7089 return -EINVAL;
7090 }
7091
7092 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
7093 hddLog(VOS_TRACE_LEVEL_ERROR,
7094 FL("Attribute peerMac not provided for mode=%d"),
7095 adapter->device_mode);
7096 return -EINVAL;
7097 }
7098
7099 memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
7100 sizeof(peer_mac));
7101 hddLog(VOS_TRACE_LEVEL_INFO,
7102 FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"),
7103 MAC_ADDR_ARRAY(peer_mac), adapter->device_mode);
7104
7105 if (adapter->device_mode == WLAN_HDD_INFRA_STATION ||
7106 adapter->device_mode == WLAN_HDD_P2P_CLIENT) {
7107 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
7108 if ((hdd_sta_ctx->conn_info.connState !=
7109 eConnectionState_Associated) ||
7110 !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac,
7111 VOS_MAC_ADDRESS_LEN)) {
7112 hddLog(VOS_TRACE_LEVEL_ERROR,
7113 FL("Not Associated to mac "MAC_ADDRESS_STR),
7114 MAC_ADDR_ARRAY(peer_mac));
7115 return -EINVAL;
7116 }
7117
7118 nss = 1; //pronto supports only one spatial stream
7119 freq = vos_chan_to_freq(
7120 hdd_sta_ctx->conn_info.operationChannel);
7121 rate_flags = hdd_sta_ctx->conn_info.rate_flags;
7122
7123 } else if (adapter->device_mode == WLAN_HDD_P2P_GO ||
7124 adapter->device_mode == WLAN_HDD_SOFTAP) {
7125
7126 pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext;
7127 pSapCtx = VOS_GET_SAP_CB(pVosContext);
7128 if(pSapCtx == NULL){
7129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7130 FL("psapCtx is NULL"));
7131 return -ENOENT;
7132 }
7133
7134
7135 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
7136 if (pSapCtx->aStaInfo[sta_id].isUsed &&
7137 !vos_is_macaddr_broadcast(
7138 &pSapCtx->aStaInfo[sta_id].macAddrSTA) &&
7139 vos_mem_compare(
7140 &pSapCtx->aStaInfo[sta_id].macAddrSTA,
7141 peer_mac, VOS_MAC_ADDRESS_LEN))
7142 break;
7143 }
7144
7145 if (WLAN_MAX_STA_COUNT == sta_id) {
7146 hddLog(VOS_TRACE_LEVEL_ERROR,
7147 FL("No active peer with mac="MAC_ADDRESS_STR),
7148 MAC_ADDR_ARRAY(peer_mac));
7149 return -EINVAL;
7150 }
7151
7152 nss = 1; //pronto supports only one spatial stream
7153 freq = vos_chan_to_freq(
7154 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel);
7155 rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags;
7156 } else {
7157 hddLog(VOS_TRACE_LEVEL_ERROR,
7158 FL("Not Associated! with mac"MAC_ADDRESS_STR),
7159 MAC_ADDR_ARRAY(peer_mac));
7160 return -EINVAL;
7161 }
7162
7163 if (!(rate_flags & eHAL_TX_RATE_LEGACY)) {
7164 if (rate_flags & eHAL_TX_RATE_VHT80) {
7165 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7166 final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7167 } else if (rate_flags & eHAL_TX_RATE_VHT40) {
7168 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7169 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7170 } else if (rate_flags & eHAL_TX_RATE_VHT20) {
7171 final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS;
7172 } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) {
7173 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7174 if (rate_flags & eHAL_TX_RATE_HT40)
7175 final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7176 }
7177
7178 if (rate_flags & eHAL_TX_RATE_SGI) {
7179 if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS))
7180 final_rate_flags |= RATE_INFO_FLAGS_MCS;
7181 final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI;
7182 }
7183 }
7184
7185 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
7186 sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN);
7187
7188 if (NULL == reply_skb) {
7189 hddLog(VOS_TRACE_LEVEL_ERROR,
7190 FL("getLinkProperties: skb alloc failed"));
7191 return -EINVAL;
7192 }
7193
7194 if (nla_put_u8(reply_skb,
7195 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS,
7196 nss) ||
7197 nla_put_u8(reply_skb,
7198 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS,
7199 final_rate_flags) ||
7200 nla_put_u32(reply_skb,
7201 QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ,
7202 freq)) {
7203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed"));
7204 kfree_skb(reply_skb);
7205 return -EINVAL;
7206 }
7207
7208 return cfg80211_vendor_cmd_reply(reply_skb);
7209}
7210
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307211#define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX
7212#define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM
7213#define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR
7214#define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME
7215
7216/**
7217 * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7218 * vendor command
7219 *
7220 * @wiphy: wiphy device pointer
7221 * @wdev: wireless device pointer
7222 * @data: Vendor command data buffer
7223 * @data_len: Buffer length
7224 *
7225 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7226 *
7227 * Return: EOK or other error codes.
7228 */
7229
7230static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7231 struct wireless_dev *wdev,
7232 const void *data,
7233 int data_len)
7234{
7235 struct net_device *dev = wdev->netdev;
7236 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7237 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7238 hdd_station_ctx_t *pHddStaCtx;
7239 struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1];
7240 tpSetWifiConfigParams pReq;
7241 eHalStatus status;
7242 int ret_val;
7243 static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = {
7244 [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 },
7245 [PARAM_MODULATED_DTIM] = { .type = NLA_U32 },
7246 [PARAM_GUARD_TIME] = { .type = NLA_U32},
7247 };
7248
7249 ENTER();
7250
7251 if (VOS_FTM_MODE == hdd_get_conparam()) {
7252 hddLog(LOGE, FL("Command not allowed in FTM mode"));
7253 return -EINVAL;
7254 }
7255
7256 ret_val = wlan_hdd_validate_context(pHddCtx);
7257 if (ret_val) {
7258 return ret_val;
7259 }
7260
7261 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7262
7263 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
7264 hddLog(LOGE, FL("Not in Connected state!"));
7265 return -ENOTSUPP;
7266 }
7267
7268 if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) {
7269 hddLog(LOGE, FL("Invalid ATTR"));
7270 return -EINVAL;
7271 }
7272
7273 /* check the Wifi Capability */
7274 if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) &&
7275 (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG)))
7276 {
7277 hddLog(VOS_TRACE_LEVEL_ERROR,
7278 FL("WIFICONFIG not supported by Firmware"));
7279 return -EINVAL;
7280 }
7281
7282 pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams));
7283
7284 if (!pReq) {
7285 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7286 "%s: Not able to allocate memory for tSetWifiConfigParams",
7287 __func__);
7288 return eHAL_STATUS_E_MALLOC_FAILED;
7289 }
7290
7291 vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0);
7292
7293 pReq->sessionId = pAdapter->sessionId;
7294 vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
7295
7296 if (tb[PARAM_MODULATED_DTIM]) {
7297 pReq->paramValue = nla_get_u32(
7298 tb[PARAM_MODULATED_DTIM]);
7299 hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "),
7300 pReq->paramValue);
Arun Khandavalli876886f2015-11-23 11:42:27 +05307301 pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue;
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307302 hdd_set_pwrparams(pHddCtx);
7303 if (BMPS == pmcGetPmcState(pHddCtx->hHal)) {
7304 hddLog( LOG1, FL("WifiConfig: Requesting FullPower!"));
7305
7306 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
7307 iw_full_power_cbfn, pAdapter,
7308 eSME_FULL_PWR_NEEDED_BY_HDD);
7309 }
7310 else
7311 {
7312 hddLog( LOG1, FL("WifiConfig Not in BMPS state"));
7313 }
7314 }
7315
7316 if (tb[PARAM_STATS_AVG_FACTOR]) {
7317 pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR;
7318 pReq->paramValue = nla_get_u16(
7319 tb[PARAM_STATS_AVG_FACTOR]);
7320 hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "),
7321 pReq->paramType, pReq->paramValue);
7322 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7323
7324 if (eHAL_STATUS_SUCCESS != status)
7325 {
7326 vos_mem_free(pReq);
7327 pReq = NULL;
7328 ret_val = -EPERM;
7329 return ret_val;
7330 }
7331 }
7332
7333
7334 if (tb[PARAM_GUARD_TIME]) {
7335 pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME;
7336 pReq->paramValue = nla_get_u32(
7337 tb[PARAM_GUARD_TIME]);
7338 hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "),
7339 pReq->paramType, pReq->paramValue);
7340 status = sme_set_wificonfig_params(pHddCtx->hHal, pReq);
7341
7342 if (eHAL_STATUS_SUCCESS != status)
7343 {
7344 vos_mem_free(pReq);
7345 pReq = NULL;
7346 ret_val = -EPERM;
7347 return ret_val;
7348 }
7349
7350 }
7351
7352 EXIT();
7353 return ret_val;
7354}
7355
7356/**
7357 * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration
7358 * vendor command
7359 *
7360 * @wiphy: wiphy device pointer
7361 * @wdev: wireless device pointer
7362 * @data: Vendor command data buffer
7363 * @data_len: Buffer length
7364 *
7365 * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX.
7366 *
7367 * Return: EOK or other error codes.
7368 */
7369static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
7370 struct wireless_dev *wdev,
7371 const void *data,
7372 int data_len)
7373{
7374 int ret;
7375
7376 vos_ssr_protect(__func__);
7377 ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev,
7378 data, data_len);
7379 vos_ssr_unprotect(__func__);
7380
7381 return ret;
7382}
Sunil Duttc69bccb2014-05-26 21:30:20 +05307383const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
7384{
Mukul Sharma2a271632014-10-13 14:59:01 +05307385 {
7386 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7387 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
7388 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7389 WIPHY_VENDOR_CMD_NEED_NETDEV |
7390 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307391 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05307392 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05307393
7394 {
7395 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7396 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
7397 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7398 WIPHY_VENDOR_CMD_NEED_NETDEV |
7399 WIPHY_VENDOR_CMD_NEED_RUNNING,
7400 .doit = wlan_hdd_cfg80211_nan_request
7401 },
7402
Sunil Duttc69bccb2014-05-26 21:30:20 +05307403#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7404 {
7405 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7406 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
7407 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7408 WIPHY_VENDOR_CMD_NEED_NETDEV |
7409 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307410 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05307411 },
7412
7413 {
7414 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7415 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
7416 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7417 WIPHY_VENDOR_CMD_NEED_NETDEV |
7418 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307419 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05307420 },
7421
7422 {
7423 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7424 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
7425 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7426 WIPHY_VENDOR_CMD_NEED_NETDEV |
7427 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307428 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05307429 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307430#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307431#ifdef WLAN_FEATURE_EXTSCAN
7432 {
7433 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7434 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
7435 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7436 WIPHY_VENDOR_CMD_NEED_NETDEV |
7437 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307438 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05307439 },
7440 {
7441 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7442 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
7443 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7444 WIPHY_VENDOR_CMD_NEED_NETDEV |
7445 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307446 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05307447 },
7448 {
7449 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7450 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
7451 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7452 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307453 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05307454 },
7455 {
7456 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7457 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
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_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05307462 },
7463 {
7464 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7465 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
7466 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7467 WIPHY_VENDOR_CMD_NEED_NETDEV |
7468 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307469 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05307470 },
7471 {
7472 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7473 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
7474 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7475 WIPHY_VENDOR_CMD_NEED_NETDEV |
7476 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307477 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307478 },
7479 {
7480 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7481 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
7482 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7483 WIPHY_VENDOR_CMD_NEED_NETDEV |
7484 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307485 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05307486 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307487 {
7488 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7489 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST,
7490 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7491 WIPHY_VENDOR_CMD_NEED_NETDEV |
7492 WIPHY_VENDOR_CMD_NEED_RUNNING,
7493 .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist
7494 },
7495 {
7496 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7497 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST,
7498 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7499 WIPHY_VENDOR_CMD_NEED_NETDEV |
7500 WIPHY_VENDOR_CMD_NEED_RUNNING,
7501 .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist
7502 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307503#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307504/*EXT TDLS*/
7505 {
7506 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7507 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
7508 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7509 WIPHY_VENDOR_CMD_NEED_NETDEV |
7510 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307511 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05307512 },
7513 {
7514 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7515 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
7516 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7517 WIPHY_VENDOR_CMD_NEED_NETDEV |
7518 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307519 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05307520 },
7521 {
7522 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7523 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
7524 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7525 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307526 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05307527 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05307528 {
7529 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7530 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
7531 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7532 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307533 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05307534 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05307535 {
7536 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7537 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
7538 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7539 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307540 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05307541 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307542 {
7543 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7544 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
7545 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7546 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307547 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05307548 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307549 {
7550 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7551 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
7552 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7553 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05307554 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05307555 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307556 {
7557 .info.vendor_id = QCA_NL80211_VENDOR_ID,
c_manjeecfd1efb2015-09-25 19:32:34 +05307558 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP,
7559 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7560 WIPHY_VENDOR_CMD_NEED_NETDEV |
7561 WIPHY_VENDOR_CMD_NEED_RUNNING,
7562 .doit = wlan_hdd_cfg80211_get_fw_mem_dump
7563 },
7564 {
7565 .info.vendor_id = QCA_NL80211_VENDOR_ID,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05307566 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
7567 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7568 WIPHY_VENDOR_CMD_NEED_NETDEV |
7569 WIPHY_VENDOR_CMD_NEED_RUNNING,
7570 .doit = wlan_hdd_cfg80211_setband
Sushant Kaushik8e644982015-09-23 12:18:54 +05307571 },
7572 {
7573 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7574 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START,
7575 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7576 WIPHY_VENDOR_CMD_NEED_NETDEV,
7577 .doit = wlan_hdd_cfg80211_wifi_logger_start
7578 },
Sushant Kaushik847890c2015-09-28 16:05:17 +05307579 {
7580 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7581 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
7582 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7583 WIPHY_VENDOR_CMD_NEED_NETDEV|
7584 WIPHY_VENDOR_CMD_NEED_RUNNING,
7585 .doit = wlan_hdd_cfg80211_get_wifi_info
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307586 },
7587 {
7588 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7589 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA,
7590 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7591 WIPHY_VENDOR_CMD_NEED_NETDEV |
7592 WIPHY_VENDOR_CMD_NEED_RUNNING,
7593 .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307594 },
7595 {
7596 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7597 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,
7598 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7599 WIPHY_VENDOR_CMD_NEED_NETDEV |
7600 WIPHY_VENDOR_CMD_NEED_RUNNING,
7601 .doit = wlan_hdd_cfg80211_monitor_rssi
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307602 },
7603#ifdef WLAN_FEATURE_OFFLOAD_PACKETS
7604 {
7605 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7606 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS,
7607 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7608 WIPHY_VENDOR_CMD_NEED_NETDEV |
7609 WIPHY_VENDOR_CMD_NEED_RUNNING,
7610 .doit = wlan_hdd_cfg80211_offloaded_packets
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307611 },
Srinivas Girigowda8bf64cb2015-09-30 19:50:09 +05307612#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307613 {
7614 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7615 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES,
7616 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7617 WIPHY_VENDOR_CMD_NEED_NETDEV |
7618 WIPHY_VENDOR_CMD_NEED_RUNNING,
7619 .doit = wlan_hdd_cfg80211_get_link_properties
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05307620 },
7621 {
7622 .info.vendor_id = QCA_NL80211_VENDOR_ID,
7623 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,
7624 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
7625 WIPHY_VENDOR_CMD_NEED_NETDEV |
7626 WIPHY_VENDOR_CMD_NEED_RUNNING,
7627 .doit = wlan_hdd_cfg80211_wifi_configuration_set
Deepthi Gowriae6a1662015-10-12 12:59:37 +05307628 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05307629};
7630
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007631/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05307632static const
7633struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007634{
7635#ifdef FEATURE_WLAN_CH_AVOID
7636 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05307637 .vendor_id = QCA_NL80211_VENDOR_ID,
7638 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007639 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05307640#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
7641#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7642 {
7643 /* Index = 1*/
7644 .vendor_id = QCA_NL80211_VENDOR_ID,
7645 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
7646 },
7647 {
7648 /* Index = 2*/
7649 .vendor_id = QCA_NL80211_VENDOR_ID,
7650 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
7651 },
7652 {
7653 /* Index = 3*/
7654 .vendor_id = QCA_NL80211_VENDOR_ID,
7655 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
7656 },
7657 {
7658 /* Index = 4*/
7659 .vendor_id = QCA_NL80211_VENDOR_ID,
7660 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
7661 },
7662 {
7663 /* Index = 5*/
7664 .vendor_id = QCA_NL80211_VENDOR_ID,
7665 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
7666 },
7667 {
7668 /* Index = 6*/
7669 .vendor_id = QCA_NL80211_VENDOR_ID,
7670 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
7671 },
7672#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05307673#ifdef WLAN_FEATURE_EXTSCAN
7674 {
7675 .vendor_id = QCA_NL80211_VENDOR_ID,
7676 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
7677 },
7678 {
7679 .vendor_id = QCA_NL80211_VENDOR_ID,
7680 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
7681 },
7682 {
7683 .vendor_id = QCA_NL80211_VENDOR_ID,
7684 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
7685 },
7686 {
7687 .vendor_id = QCA_NL80211_VENDOR_ID,
7688 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
7689 },
7690 {
7691 .vendor_id = QCA_NL80211_VENDOR_ID,
7692 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
7693 },
7694 {
7695 .vendor_id = QCA_NL80211_VENDOR_ID,
7696 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
7697 },
7698 {
7699 .vendor_id = QCA_NL80211_VENDOR_ID,
7700 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
7701 },
7702 {
7703 .vendor_id = QCA_NL80211_VENDOR_ID,
7704 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
7705 },
7706 {
7707 .vendor_id = QCA_NL80211_VENDOR_ID,
7708 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
7709 },
7710 {
7711 .vendor_id = QCA_NL80211_VENDOR_ID,
7712 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
7713 },
Padma, Santhosh Kumar9acee012015-08-21 19:58:01 +05307714 {
7715 .vendor_id = QCA_NL80211_VENDOR_ID,
7716 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST
7717 },
7718 {
7719 .vendor_id = QCA_NL80211_VENDOR_ID,
7720 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST
7721 },
7722 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = {
7723 .vendor_id = QCA_NL80211_VENDOR_ID,
7724 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND
7725 },
7726 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = {
7727 .vendor_id = QCA_NL80211_VENDOR_ID,
7728 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST
7729 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05307730#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05307731/*EXT TDLS*/
7732 {
7733 .vendor_id = QCA_NL80211_VENDOR_ID,
7734 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
7735 },
c_manjeecfd1efb2015-09-25 19:32:34 +05307736 [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = {
7737 .vendor_id = QCA_NL80211_VENDOR_ID,
7738 .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP
7739 },
7740
Srinivas Dasari030bad32015-02-18 23:23:54 +05307741
7742 {
7743 .vendor_id = QCA_NL80211_VENDOR_ID,
7744 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
7745 },
7746
Sushant Kaushik084f6592015-09-10 13:11:56 +05307747 {
7748 .vendor_id = QCA_NL80211_VENDOR_ID,
7749 .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO,
Gupta, Kapil7c34b322015-09-30 13:12:35 +05307750 },
7751 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {
7752 .vendor_id = QCA_NL80211_VENDOR_ID,
7753 .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI
7754 },
Padma, Santhosh Kumar7bbc7d92015-12-08 20:23:19 +05307755 [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = {
7756 .vendor_id = QCA_NL80211_VENDOR_ID,
7757 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST
7758 },
Sushant Kaushik084f6592015-09-10 13:11:56 +05307759
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08007760};
7761
Jeff Johnson295189b2012-06-20 16:38:30 -07007762/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307763 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307764 * This function is called by hdd_wlan_startup()
7765 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307766 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307768struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07007769{
7770 struct wiphy *wiphy;
7771 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307772 /*
7773 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 */
7775 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
7776
7777 if (!wiphy)
7778 {
7779 /* Print error and jump into err label and free the memory */
7780 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
7781 return NULL;
7782 }
7783
Sunil Duttc69bccb2014-05-26 21:30:20 +05307784
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 return wiphy;
7786}
7787
7788/*
7789 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307790 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 * private ioctl to change the band value
7792 */
7793int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
7794{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307795 int i, j;
7796 eNVChannelEnabledType channelEnabledState;
7797
Jeff Johnsone7245742012-09-05 17:12:55 -07007798 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307799
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307800 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307802
7803 if (NULL == wiphy->bands[i])
7804 {
7805 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
7806 __func__, i);
7807 continue;
7808 }
7809
7810 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
7811 {
7812 struct ieee80211_supported_band *band = wiphy->bands[i];
7813
7814 channelEnabledState = vos_nv_getChannelEnabledState(
7815 band->channels[j].hw_value);
7816
7817 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
7818 {
Abhishek Singh678227a2014-11-04 10:52:38 +05307819 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307820 continue;
7821 }
7822 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
7823 {
7824 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7825 continue;
7826 }
7827
7828 if (NV_CHANNEL_DISABLE == channelEnabledState ||
7829 NV_CHANNEL_INVALID == channelEnabledState)
7830 {
7831 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
7832 }
7833 else if (NV_CHANNEL_DFS == channelEnabledState)
7834 {
7835 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
7836 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
7837 }
7838 else
7839 {
7840 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
7841 |IEEE80211_CHAN_RADAR);
7842 }
7843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 }
7845 return 0;
7846}
7847/*
7848 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307849 * This function is called by hdd_wlan_startup()
7850 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 * This function is used to initialize and register wiphy structure.
7852 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307853int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 struct wiphy *wiphy,
7855 hdd_config_t *pCfg
7856 )
7857{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05307858 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05307859 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7860
Jeff Johnsone7245742012-09-05 17:12:55 -07007861 ENTER();
7862
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 /* Now bind the underlying wlan device with wiphy */
7864 set_wiphy_dev(wiphy, dev);
7865
7866 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007867
Kiet Lam6c583332013-10-14 05:37:09 +05307868#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07007869 /* the flag for the other case would be initialzed in
7870 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07007871 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05307872#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007873
Amar Singhalfddc28c2013-09-05 13:03:40 -07007874 /* This will disable updating of NL channels from passive to
7875 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307876#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7877 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
7878#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07007879 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307880#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07007881
Amar Singhala49cbc52013-10-08 18:37:44 -07007882
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007883#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07007884 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
7885 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
7886 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07007887 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05307888#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
7889 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
7890#else
7891 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
7892#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007893#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07007894
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007895#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007896 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08007897#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007898 || pCfg->isFastRoamIniFeatureEnabled
7899#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007900#ifdef FEATURE_WLAN_ESE
7901 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07007902#endif
7903 )
7904 {
7905 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
7906 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08007907#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007908#ifdef FEATURE_WLAN_TDLS
7909 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
7910 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
7911#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307912#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05307913 if (pCfg->configPNOScanSupport)
7914 {
7915 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
7916 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
7917 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
7918 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
7919 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307920#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007921
Abhishek Singh10d85972015-04-17 10:27:23 +05307922#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7923 wiphy->features |= NL80211_FEATURE_HT_IBSS;
7924#endif
7925
Amar Singhalfddc28c2013-09-05 13:03:40 -07007926#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007927 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
7928 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07007929 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07007930 driver need to determine what to do with both
7931 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07007932
7933 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07007934#else
7935 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07007936#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007937
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307938 wiphy->max_scan_ssids = MAX_SCAN_SSID;
7939
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05307940 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07007941
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307942 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
7943
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05307945 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7946 | BIT(NL80211_IFTYPE_ADHOC)
7947 | BIT(NL80211_IFTYPE_P2P_CLIENT)
7948 | BIT(NL80211_IFTYPE_P2P_GO)
7949 | BIT(NL80211_IFTYPE_AP);
7950
7951 if (VOS_MONITOR_MODE == hdd_get_conparam())
7952 {
7953 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
7954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007955
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307956 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007957 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307958#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7959 if( pCfg->enableMCC )
7960 {
7961 /* Currently, supports up to two channels */
7962 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007963
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307964 if( !pCfg->allowMCCGODiffBI )
7965 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007966
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307967 }
7968 wiphy->iface_combinations = &wlan_hdd_iface_combination;
7969 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007970#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05307971 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08007972
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 /* Before registering we need to update the ht capabilitied based
7974 * on ini values*/
7975 if( !pCfg->ShortGI20MhzEnable )
7976 {
7977 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
7978 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 }
7980
7981 if( !pCfg->ShortGI40MhzEnable )
7982 {
7983 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
7984 }
7985
7986 if( !pCfg->nChannelBondingMode5GHz )
7987 {
7988 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7989 }
Agrawal Ashish97dec502015-11-26 20:20:58 +05307990 /*
7991 * In case of static linked driver at the time of driver unload,
7992 * module exit doesn't happens. Module cleanup helps in cleaning
7993 * of static memory.
7994 * If driver load happens statically, at the time of driver unload,
7995 * wiphy flags don't get reset because of static memory.
7996 * It's better not to store channel in static memory.
7997 */
7998 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
7999 wiphy->bands[IEEE80211_BAND_2GHZ]->channels =
8000 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ));
8001 if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL)
8002 {
8003 hddLog(VOS_TRACE_LEVEL_ERROR,
8004 FL("Not enough memory to allocate channels"));
8005 return -ENOMEM;
8006 }
8007 vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels,
8008 &hdd_channels_2_4_GHZ[0],
8009 sizeof(hdd_channels_2_4_GHZ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008010
Agrawal Ashish97dec502015-11-26 20:20:58 +05308011 if (true == hdd_is_5g_supported(pHddCtx))
8012 {
8013 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
8014 wiphy->bands[IEEE80211_BAND_5GHZ]->channels =
8015 (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ));
8016 if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL)
8017 {
8018 hddLog(VOS_TRACE_LEVEL_ERROR,
8019 FL("Not enough memory to allocate channels"));
8020 vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
8021 wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL;
8022 return -ENOMEM;
8023 }
8024 vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels,
8025 &hdd_channels_5_GHZ[0],
8026 sizeof(hdd_channels_5_GHZ));
8027 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308028
8029 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8030 {
8031
8032 if (NULL == wiphy->bands[i])
8033 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05308034 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05308035 __func__, i);
8036 continue;
8037 }
8038
8039 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8040 {
8041 struct ieee80211_supported_band *band = wiphy->bands[i];
8042
8043 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
8044 {
8045 // Enable social channels for P2P
8046 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
8047 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
8048 else
8049 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8050 continue;
8051 }
8052 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
8053 {
8054 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
8055 continue;
8056 }
8057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 }
8059 /*Initialise the supported cipher suite details*/
8060 wiphy->cipher_suites = hdd_cipher_suites;
8061 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
8062
8063 /*signal strength in mBm (100*dBm) */
8064 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
8065
8066#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05308067 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07008068#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008069
Sunil Duttc69bccb2014-05-26 21:30:20 +05308070 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
8071 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08008072 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
8073 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
8074
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308075 EXIT();
8076 return 0;
8077}
8078
8079/* In this function we are registering wiphy. */
8080int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
8081{
8082 ENTER();
8083 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 if (0 > wiphy_register(wiphy))
8085 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308086 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8088 return -EIO;
8089 }
8090
8091 EXIT();
8092 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308093}
Jeff Johnson295189b2012-06-20 16:38:30 -07008094
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308095/* In this function we are updating channel list when,
8096 regulatory domain is FCC and country code is US.
8097 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
8098 As per FCC smart phone is not a indoor device.
8099 GO should not opeate on indoor channels */
8100void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
8101{
8102 int j;
8103 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8104 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
8105 //Default counrtycode from NV at the time of wiphy initialization.
8106 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
8107 &defaultCountryCode[0]))
8108 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008109 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308110 }
8111 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
8112 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308113 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
8114 {
8115 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
8116 return;
8117 }
8118 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
8119 {
8120 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
8121 // Mark UNII -1 band channel as passive
8122 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
8123 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
8124 }
8125 }
8126}
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308127/* This function registers for all frame which supplicant is interested in */
8128void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008129{
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8131 /* Register for all P2P action, public action etc frames */
8132 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
Jeff Johnsone7245742012-09-05 17:12:55 -07008133 ENTER();
Abhishek Singh16e05762015-11-30 14:29:27 +05308134 /* Register frame indication call back */
8135 sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame);
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 /* Right now we are registering these frame when driver is getting
8137 initialized. Once we will move to 2.6.37 kernel, in which we have
8138 frame register ops, we will move this code as a part of that */
8139 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308140 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8142
8143 /* GAS Initial Response */
8144 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8145 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308146
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 /* GAS Comeback Request */
8148 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8149 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8150
8151 /* GAS Comeback Response */
8152 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8153 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8154
8155 /* P2P Public Action */
8156 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308157 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 P2P_PUBLIC_ACTION_FRAME_SIZE );
8159
8160 /* P2P Action */
8161 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8162 (v_U8_t*)P2P_ACTION_FRAME,
8163 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07008164
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05308165 /* WNM BSS Transition Request frame */
8166 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8167 (v_U8_t*)WNM_BSS_ACTION_FRAME,
8168 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008169
8170 /* WNM-Notification */
8171 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
8172 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8173 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008174}
8175
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05308176void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008177{
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8179 /* Register for all P2P action, public action etc frames */
8180 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
8181
Jeff Johnsone7245742012-09-05 17:12:55 -07008182 ENTER();
8183
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 /* Right now we are registering these frame when driver is getting
8185 initialized. Once we will move to 2.6.37 kernel, in which we have
8186 frame register ops, we will move this code as a part of that */
8187 /* GAS Initial Request */
8188
8189 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8190 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
8191
8192 /* GAS Initial Response */
8193 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8194 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308195
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 /* GAS Comeback Request */
8197 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8198 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
8199
8200 /* GAS Comeback Response */
8201 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8202 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
8203
8204 /* P2P Public Action */
8205 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308206 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 P2P_PUBLIC_ACTION_FRAME_SIZE );
8208
8209 /* P2P Action */
8210 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8211 (v_U8_t*)P2P_ACTION_FRAME,
8212 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07008213 /* WNM-Notification */
8214 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
8215 (v_U8_t*)WNM_NOTIFICATION_FRAME,
8216 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07008217}
8218
8219#ifdef FEATURE_WLAN_WAPI
8220void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05308221 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07008222{
8223 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8224 tCsrRoamSetKey setKey;
8225 v_BOOL_t isConnected = TRUE;
8226 int status = 0;
8227 v_U32_t roamId= 0xFF;
8228 tANI_U8 *pKeyPtr = NULL;
8229 int n = 0;
8230
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308231 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8232 __func__, hdd_device_modetoString(pAdapter->device_mode),
8233 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008234
Gopichand Nakkalae7480202013-02-11 15:24:22 +05308235 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 setKey.keyId = key_index; // Store Key ID
8237 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
8238 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
8239 setKey.paeRole = 0 ; // the PAE role
8240 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
8241 {
8242 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
8243 }
8244 else
8245 {
8246 isConnected = hdd_connIsConnected(pHddStaCtx);
8247 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
8248 }
8249 setKey.keyLength = key_Len;
8250 pKeyPtr = setKey.Key;
8251 memcpy( pKeyPtr, key, key_Len);
8252
Arif Hussain6d2a3322013-11-17 19:50:10 -08008253 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 __func__, key_Len);
8255 for (n = 0 ; n < key_Len; n++)
8256 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
8257 __func__,n,setKey.Key[n]);
8258
8259 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
8260 if ( isConnected )
8261 {
8262 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8263 pAdapter->sessionId, &setKey, &roamId );
8264 }
8265 if ( status != 0 )
8266 {
8267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8268 "[%4d] sme_RoamSetKey returned ERROR status= %d",
8269 __LINE__, status );
8270 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
8271 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308272 /* Need to clear any trace of key value in the memory.
8273 * Thus zero out the memory even though it is local
8274 * variable.
8275 */
8276 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008277}
8278#endif /* FEATURE_WLAN_WAPI*/
8279
8280#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308281int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008282 beacon_data_t **ppBeacon,
8283 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008284#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308285int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008286 beacon_data_t **ppBeacon,
8287 struct cfg80211_beacon_data *params,
8288 int dtim_period)
8289#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308290{
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 int size;
8292 beacon_data_t *beacon = NULL;
8293 beacon_data_t *old = NULL;
8294 int head_len,tail_len;
8295
Jeff Johnsone7245742012-09-05 17:12:55 -07008296 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308298 {
8299 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8300 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008303
8304 old = pAdapter->sessionCtx.ap.beacon;
8305
8306 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308307 {
8308 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8309 FL("session(%d) old and new heads points to NULL"),
8310 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308312 }
8313
8314 if (params->tail && !params->tail_len)
8315 {
8316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8317 FL("tail_len is zero but tail is not NULL"));
8318 return -EINVAL;
8319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008320
Jeff Johnson295189b2012-06-20 16:38:30 -07008321#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
8322 /* Kernel 3.0 is not updating dtim_period for set beacon */
8323 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308324 {
8325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8326 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008329#endif
8330
8331 if(params->head)
8332 head_len = params->head_len;
8333 else
8334 head_len = old->head_len;
8335
8336 if(params->tail || !old)
8337 tail_len = params->tail_len;
8338 else
8339 tail_len = old->tail_len;
8340
8341 size = sizeof(beacon_data_t) + head_len + tail_len;
8342
8343 beacon = kzalloc(size, GFP_KERNEL);
8344
8345 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308346 {
8347 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8348 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008351
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008352#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 if(params->dtim_period || !old )
8354 beacon->dtim_period = params->dtim_period;
8355 else
8356 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008357#else
8358 if(dtim_period || !old )
8359 beacon->dtim_period = dtim_period;
8360 else
8361 beacon->dtim_period = old->dtim_period;
8362#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308363
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
8365 beacon->tail = beacon->head + head_len;
8366 beacon->head_len = head_len;
8367 beacon->tail_len = tail_len;
8368
8369 if(params->head) {
8370 memcpy (beacon->head,params->head,beacon->head_len);
8371 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308372 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 if(old)
8374 memcpy (beacon->head,old->head,beacon->head_len);
8375 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308376
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 if(params->tail) {
8378 memcpy (beacon->tail,params->tail,beacon->tail_len);
8379 }
8380 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308381 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 memcpy (beacon->tail,old->tail,beacon->tail_len);
8383 }
8384
8385 *ppBeacon = beacon;
8386
8387 kfree(old);
8388
8389 return 0;
8390
8391}
Jeff Johnson295189b2012-06-20 16:38:30 -07008392
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308393v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
8394#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
8395 const v_U8_t *pIes,
8396#else
8397 v_U8_t *pIes,
8398#endif
8399 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008400{
8401 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308402 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308404
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308406 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 elem_id = ptr[0];
8408 elem_len = ptr[1];
8409 left -= 2;
8410 if(elem_len > left)
8411 {
8412 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008413 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 eid,elem_len,left);
8415 return NULL;
8416 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308417 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008418 {
8419 return ptr;
8420 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308421
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 left -= elem_len;
8423 ptr += (elem_len + 2);
8424 }
8425 return NULL;
8426}
8427
Jeff Johnson295189b2012-06-20 16:38:30 -07008428/* Check if rate is 11g rate or not */
8429static int wlan_hdd_rate_is_11g(u8 rate)
8430{
Sanjay Devnani28322e22013-06-21 16:13:40 -07008431 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 u8 i;
8433 for (i = 0; i < 8; i++)
8434 {
8435 if(rate == gRateArray[i])
8436 return TRUE;
8437 }
8438 return FALSE;
8439}
8440
8441/* Check for 11g rate and set proper 11g only mode */
8442static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
8443 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
8444{
8445 u8 i, num_rates = pIe[0];
8446
8447 pIe += 1;
8448 for ( i = 0; i < num_rates; i++)
8449 {
8450 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
8451 {
8452 /* If rate set have 11g rate than change the mode to 11G */
8453 *pSapHw_mode = eSAP_DOT11_MODE_11g;
8454 if (pIe[i] & BASIC_RATE_MASK)
8455 {
8456 /* If we have 11g rate as basic rate, it means mode
8457 is 11g only mode.
8458 */
8459 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
8460 *pCheckRatesfor11g = FALSE;
8461 }
8462 }
8463 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
8464 {
8465 *require_ht = TRUE;
8466 }
8467 }
8468 return;
8469}
8470
8471static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
8472{
8473 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
8474 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8475 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
8476 u8 checkRatesfor11g = TRUE;
8477 u8 require_ht = FALSE;
8478 u8 *pIe=NULL;
8479
8480 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
8481
8482 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
8483 pBeacon->head_len, WLAN_EID_SUPP_RATES);
8484 if (pIe != NULL)
8485 {
8486 pIe += 1;
8487 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8488 &pConfig->SapHw_mode);
8489 }
8490
8491 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8492 WLAN_EID_EXT_SUPP_RATES);
8493 if (pIe != NULL)
8494 {
8495
8496 pIe += 1;
8497 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
8498 &pConfig->SapHw_mode);
8499 }
8500
8501 if( pConfig->channel > 14 )
8502 {
8503 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
8504 }
8505
8506 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
8507 WLAN_EID_HT_CAPABILITY);
8508
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308509 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 {
8511 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
8512 if(require_ht)
8513 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
8514 }
8515}
8516
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308517static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
8518 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
8519{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008520 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308521 v_U8_t *pIe = NULL;
8522 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8523
8524 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
8525 pBeacon->tail, pBeacon->tail_len);
8526
8527 if (pIe)
8528 {
8529 ielen = pIe[1] + 2;
8530 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8531 {
8532 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
8533 }
8534 else
8535 {
8536 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
8537 return -EINVAL;
8538 }
8539 *total_ielen += ielen;
8540 }
8541 return 0;
8542}
8543
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008544static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
8545 v_U8_t *genie, v_U8_t *total_ielen)
8546{
8547 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
8548 int left = pBeacon->tail_len;
8549 v_U8_t *ptr = pBeacon->tail;
8550 v_U8_t elem_id, elem_len;
8551 v_U16_t ielen = 0;
8552
8553 if ( NULL == ptr || 0 == left )
8554 return;
8555
8556 while (left >= 2)
8557 {
8558 elem_id = ptr[0];
8559 elem_len = ptr[1];
8560 left -= 2;
8561 if (elem_len > left)
8562 {
8563 hddLog( VOS_TRACE_LEVEL_ERROR,
8564 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
8565 elem_id, elem_len, left);
8566 return;
8567 }
8568 if (IE_EID_VENDOR == elem_id)
8569 {
8570 /* skipping the VSIE's which we don't want to include or
8571 * it will be included by existing code
8572 */
8573 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
8574#ifdef WLAN_FEATURE_WFD
8575 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
8576#endif
8577 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8578 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8579 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
8580 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
8581 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
8582 {
8583 ielen = ptr[1] + 2;
8584 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
8585 {
8586 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
8587 *total_ielen += ielen;
8588 }
8589 else
8590 {
8591 hddLog( VOS_TRACE_LEVEL_ERROR,
8592 "IE Length is too big "
8593 "IEs eid=%d elem_len=%d total_ie_lent=%d",
8594 elem_id, elem_len, *total_ielen);
8595 }
8596 }
8597 }
8598
8599 left -= elem_len;
8600 ptr += (elem_len + 2);
8601 }
8602 return;
8603}
8604
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008605#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008606static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8607 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008608#else
8609static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
8610 struct cfg80211_beacon_data *params)
8611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008612{
8613 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308614 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07008616 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008617
8618 genie = vos_mem_malloc(MAX_GENIE_LEN);
8619
8620 if(genie == NULL) {
8621
8622 return -ENOMEM;
8623 }
8624
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308625 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8626 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308628 hddLog(LOGE,
8629 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308630 ret = -EINVAL;
8631 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 }
8633
8634#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308635 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8636 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
8637 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308638 hddLog(LOGE,
8639 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308640 ret = -EINVAL;
8641 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008642 }
8643#endif
8644
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308645 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
8646 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308648 hddLog(LOGE,
8649 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308650 ret = -EINVAL;
8651 goto done;
8652 }
8653
8654 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
8655 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07008656 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008658
8659 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8660 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
8661 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8662 {
8663 hddLog(LOGE,
8664 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008665 ret = -EINVAL;
8666 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 }
8668
8669 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8670 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
8671 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8672 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8673 ==eHAL_STATUS_FAILURE)
8674 {
8675 hddLog(LOGE,
8676 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008677 ret = -EINVAL;
8678 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 }
8680
8681 // Added for ProResp IE
8682 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
8683 {
8684 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
8685 u8 probe_rsp_ie_len[3] = {0};
8686 u8 counter = 0;
8687 /* Check Probe Resp Length if it is greater then 255 then Store
8688 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
8689 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
8690 Store More then 255 bytes into One Variable.
8691 */
8692 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
8693 {
8694 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
8695 {
8696 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
8697 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
8698 }
8699 else
8700 {
8701 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
8702 rem_probe_resp_ie_len = 0;
8703 }
8704 }
8705
8706 rem_probe_resp_ie_len = 0;
8707
8708 if (probe_rsp_ie_len[0] > 0)
8709 {
8710 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8711 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
8712 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8713 probe_rsp_ie_len[0], NULL,
8714 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8715 {
8716 hddLog(LOGE,
8717 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008718 ret = -EINVAL;
8719 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 }
8721 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
8722 }
8723
8724 if (probe_rsp_ie_len[1] > 0)
8725 {
8726 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8727 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
8728 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8729 probe_rsp_ie_len[1], NULL,
8730 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8731 {
8732 hddLog(LOGE,
8733 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008734 ret = -EINVAL;
8735 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 }
8737 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
8738 }
8739
8740 if (probe_rsp_ie_len[2] > 0)
8741 {
8742 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8743 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
8744 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
8745 probe_rsp_ie_len[2], NULL,
8746 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8747 {
8748 hddLog(LOGE,
8749 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008750 ret = -EINVAL;
8751 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 }
8753 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
8754 }
8755
8756 if (probe_rsp_ie_len[1] == 0 )
8757 {
8758 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8759 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
8760 eANI_BOOLEAN_FALSE) )
8761 {
8762 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008763 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 }
8765 }
8766
8767 if (probe_rsp_ie_len[2] == 0 )
8768 {
8769 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8770 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
8771 eANI_BOOLEAN_FALSE) )
8772 {
8773 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008774 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008775 }
8776 }
8777
8778 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8779 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
8780 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8781 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8782 == eHAL_STATUS_FAILURE)
8783 {
8784 hddLog(LOGE,
8785 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008786 ret = -EINVAL;
8787 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 }
8789 }
8790 else
8791 {
8792 // Reset WNI_CFG_PROBE_RSP Flags
8793 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
8794
8795 hddLog(VOS_TRACE_LEVEL_INFO,
8796 "%s: No Probe Response IE received in set beacon",
8797 __func__);
8798 }
8799
8800 // Added for AssocResp IE
8801 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
8802 {
8803 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8804 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
8805 params->assocresp_ies_len, NULL,
8806 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
8807 {
8808 hddLog(LOGE,
8809 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008810 ret = -EINVAL;
8811 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 }
8813
8814 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8815 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
8816 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
8817 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
8818 == eHAL_STATUS_FAILURE)
8819 {
8820 hddLog(LOGE,
8821 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07008822 ret = -EINVAL;
8823 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 }
8825 }
8826 else
8827 {
8828 hddLog(VOS_TRACE_LEVEL_INFO,
8829 "%s: No Assoc Response IE received in set beacon",
8830 __func__);
8831
8832 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
8833 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8834 eANI_BOOLEAN_FALSE) )
8835 {
8836 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008837 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 }
8839 }
8840
Jeff Johnsone7245742012-09-05 17:12:55 -07008841done:
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05308843 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008844}
Jeff Johnson295189b2012-06-20 16:38:30 -07008845
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308846/*
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 * FUNCTION: wlan_hdd_validate_operation_channel
8848 * called by wlan_hdd_cfg80211_start_bss() and
8849 * wlan_hdd_cfg80211_set_channel()
8850 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308851 * channel list.
8852 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07008853VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008854{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308855
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 v_U32_t num_ch = 0;
8857 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8858 u32 indx = 0;
8859 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308860 v_U8_t fValidChannel = FALSE, count = 0;
8861 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308862
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8864
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308865 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308867 /* Validate the channel */
8868 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308870 if ( channel == rfChannels[count].channelNum )
8871 {
8872 fValidChannel = TRUE;
8873 break;
8874 }
8875 }
8876 if (fValidChannel != TRUE)
8877 {
8878 hddLog(VOS_TRACE_LEVEL_ERROR,
8879 "%s: Invalid Channel [%d]", __func__, channel);
8880 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 }
8882 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308883 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05308885 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8886 valid_ch, &num_ch))
8887 {
8888 hddLog(VOS_TRACE_LEVEL_ERROR,
8889 "%s: failed to get valid channel list", __func__);
8890 return VOS_STATUS_E_FAILURE;
8891 }
8892 for (indx = 0; indx < num_ch; indx++)
8893 {
8894 if (channel == valid_ch[indx])
8895 {
8896 break;
8897 }
8898 }
8899
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308900 if (indx >= num_ch)
8901 {
8902 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
8903 {
8904 eCsrBand band;
8905 unsigned int freq;
8906
8907 sme_GetFreqBand(hHal, &band);
8908
8909 if (eCSR_BAND_5G == band)
8910 {
8911#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
8912 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
8913 {
8914 freq = ieee80211_channel_to_frequency(channel,
8915 IEEE80211_BAND_2GHZ);
8916 }
8917 else
8918 {
8919 freq = ieee80211_channel_to_frequency(channel,
8920 IEEE80211_BAND_5GHZ);
8921 }
8922#else
8923 freq = ieee80211_channel_to_frequency(channel);
8924#endif
8925 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
8926 return VOS_STATUS_SUCCESS;
8927 }
8928 }
8929
8930 hddLog(VOS_TRACE_LEVEL_ERROR,
8931 "%s: Invalid Channel [%d]", __func__, channel);
8932 return VOS_STATUS_E_FAILURE;
8933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05308935
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308937
Jeff Johnson295189b2012-06-20 16:38:30 -07008938}
8939
Viral Modi3a32cc52013-02-08 11:14:52 -08008940/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308941 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08008942 * This function is used to set the channel number
8943 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308944static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08008945 struct ieee80211_channel *chan,
8946 enum nl80211_channel_type channel_type
8947 )
8948{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308949 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08008950 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07008951 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08008952 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308953 hdd_context_t *pHddCtx;
8954 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008955
8956 ENTER();
8957
8958 if( NULL == dev )
8959 {
8960 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008961 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08008962 return -ENODEV;
8963 }
8964 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308965
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308966 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8967 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
8968 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08008969 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308970 "%s: device_mode = %s (%d) freq = %d", __func__,
8971 hdd_device_modetoString(pAdapter->device_mode),
8972 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308973
8974 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8975 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308976 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08008977 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308978 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08008979 }
8980
8981 /*
8982 * Do freq to chan conversion
8983 * TODO: for 11a
8984 */
8985
8986 channel = ieee80211_frequency_to_channel(freq);
8987
8988 /* Check freq range */
8989 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
8990 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
8991 {
8992 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008993 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08008994 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
8995 WNI_CFG_CURRENT_CHANNEL_STAMAX);
8996 return -EINVAL;
8997 }
8998
8999 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9000
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05309001 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
9002 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08009003 {
9004 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
9005 {
9006 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009007 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08009008 return -EINVAL;
9009 }
9010 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9011 "%s: set channel to [%d] for device mode =%d",
9012 __func__, channel,pAdapter->device_mode);
9013 }
9014 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08009015 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08009016 )
9017 {
9018 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9019 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
9020 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9021
9022 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
9023 {
9024 /* Link is up then return cant set channel*/
9025 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009026 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08009027 return -EINVAL;
9028 }
9029
9030 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
9031 pHddStaCtx->conn_info.operationChannel = channel;
9032 pRoamProfile->ChannelInfo.ChannelList =
9033 &pHddStaCtx->conn_info.operationChannel;
9034 }
9035 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08009036 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08009037 )
9038 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309039 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
9040 {
9041 if(VOS_STATUS_SUCCESS !=
9042 wlan_hdd_validate_operation_channel(pAdapter,channel))
9043 {
9044 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009045 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309046 return -EINVAL;
9047 }
9048 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9049 }
9050 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08009051 {
9052 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
9053
9054 /* If auto channel selection is configured as enable/ 1 then ignore
9055 channel set by supplicant
9056 */
9057 if ( cfg_param->apAutoChannelSelection )
9058 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309059 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
9060 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08009061 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309062 "%s: set channel to auto channel (0) for device mode =%s (%d)",
9063 __func__, hdd_device_modetoString(pAdapter->device_mode),
9064 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08009065 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309066 else
9067 {
9068 if(VOS_STATUS_SUCCESS !=
9069 wlan_hdd_validate_operation_channel(pAdapter,channel))
9070 {
9071 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009072 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05309073 return -EINVAL;
9074 }
9075 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
9076 }
Viral Modi3a32cc52013-02-08 11:14:52 -08009077 }
9078 }
9079 else
9080 {
9081 hddLog(VOS_TRACE_LEVEL_FATAL,
9082 "%s: Invalid device mode failed to set valid channel", __func__);
9083 return -EINVAL;
9084 }
9085 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309086 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08009087}
9088
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309089static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
9090 struct net_device *dev,
9091 struct ieee80211_channel *chan,
9092 enum nl80211_channel_type channel_type
9093 )
9094{
9095 int ret;
9096
9097 vos_ssr_protect(__func__);
9098 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
9099 vos_ssr_unprotect(__func__);
9100
9101 return ret;
9102}
9103
Jeff Johnson295189b2012-06-20 16:38:30 -07009104#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9105static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9106 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009107#else
9108static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
9109 struct cfg80211_beacon_data *params,
9110 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309111 enum nl80211_hidden_ssid hidden_ssid,
9112 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009113#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009114{
9115 tsap_Config_t *pConfig;
9116 beacon_data_t *pBeacon = NULL;
9117 struct ieee80211_mgmt *pMgmt_frame;
9118 v_U8_t *pIe=NULL;
9119 v_U16_t capab_info;
9120 eCsrAuthType RSNAuthType;
9121 eCsrEncryptionType RSNEncryptType;
9122 eCsrEncryptionType mcRSNEncryptType;
9123 int status = VOS_STATUS_SUCCESS;
9124 tpWLAN_SAPEventCB pSapEventCallback;
9125 hdd_hostapd_state_t *pHostapdState;
9126 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
9127 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309128 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309130 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08009132 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05309133 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07009134 v_BOOL_t MFPCapable = VOS_FALSE;
9135 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309136 v_BOOL_t sapEnable11AC =
9137 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 ENTER();
9139
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309140 iniConfig = pHddCtx->cfg_ini;
9141
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
9143
9144 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
9145
9146 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
9147
9148 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
9149
9150 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
9151
9152 //channel is already set in the set_channel Call back
9153 //pConfig->channel = pCommitConfig->channel;
9154
9155 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309156 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
9158
9159 pConfig->dtim_period = pBeacon->dtim_period;
9160
Arif Hussain6d2a3322013-11-17 19:50:10 -08009161 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 pConfig->dtim_period);
9163
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08009164 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07009165 {
9166 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05309168 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
9169 {
9170 tANI_BOOLEAN restartNeeded;
9171 pConfig->ieee80211d = 1;
9172 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
9173 sme_setRegInfo(hHal, pConfig->countryCode);
9174 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
9175 }
9176 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07009178 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07009179 pConfig->ieee80211d = 1;
9180 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
9181 sme_setRegInfo(hHal, pConfig->countryCode);
9182 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009184 else
9185 {
9186 pConfig->ieee80211d = 0;
9187 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309188 /*
9189 * If auto channel is configured i.e. channel is 0,
9190 * so skip channel validation.
9191 */
9192 if( AUTO_CHANNEL_SELECT != pConfig->channel )
9193 {
9194 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
9195 {
9196 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009197 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05309198 return -EINVAL;
9199 }
9200 }
9201 else
9202 {
9203 if(1 != pHddCtx->is_dynamic_channel_range_set)
9204 {
9205 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
9206 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
9207 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
9208 }
9209 pHddCtx->is_dynamic_channel_range_set = 0;
9210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009212 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 {
9214 pConfig->ieee80211d = 0;
9215 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05309216
9217#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9218 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9219 pConfig->authType = eSAP_OPEN_SYSTEM;
9220 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9221 pConfig->authType = eSAP_SHARED_KEY;
9222 else
9223 pConfig->authType = eSAP_AUTO_SWITCH;
9224#else
9225 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
9226 pConfig->authType = eSAP_OPEN_SYSTEM;
9227 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
9228 pConfig->authType = eSAP_SHARED_KEY;
9229 else
9230 pConfig->authType = eSAP_AUTO_SWITCH;
9231#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009232
9233 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309234
9235 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
9237
9238 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
9239
9240 /*Set wps station to configured*/
9241 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
9242
9243 if(pIe)
9244 {
9245 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
9246 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009247 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07009248 return -EINVAL;
9249 }
9250 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
9251 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07009252 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 /* Check 15 bit of WPS IE as it contain information for wps state
9254 * WPS state
9255 */
9256 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
9257 {
9258 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
9259 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
9260 {
9261 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
9262 }
9263 }
9264 }
9265 else
9266 {
9267 pConfig->wps_state = SAP_WPS_DISABLED;
9268 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309269 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07009270
c_hpothufe599e92014-06-16 11:38:55 +05309271 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9272 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
9273 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
9274 eCSR_ENCRYPT_TYPE_NONE;
9275
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 pConfig->RSNWPAReqIELength = 0;
9277 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309278 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07009279 WLAN_EID_RSN);
9280 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309281 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9283 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9284 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309285 /* The actual processing may eventually be more extensive than
9286 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07009287 * by the app.
9288 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309289 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9291 &RSNEncryptType,
9292 &mcRSNEncryptType,
9293 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009294 &MFPCapable,
9295 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 pConfig->pRSNWPAReqIE[1]+2,
9297 pConfig->pRSNWPAReqIE );
9298
9299 if( VOS_STATUS_SUCCESS == status )
9300 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309301 /* Now copy over all the security attributes you have
9302 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009303 * */
9304 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9305 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9306 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9307 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309308 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009309 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9311 }
9312 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309313
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9315 pBeacon->tail, pBeacon->tail_len);
9316
9317 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
9318 {
9319 if (pConfig->pRSNWPAReqIE)
9320 {
9321 /*Mixed mode WPA/WPA2*/
9322 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
9323 pConfig->RSNWPAReqIELength += pIe[1] + 2;
9324 }
9325 else
9326 {
9327 pConfig->RSNWPAReqIELength = pIe[1] + 2;
9328 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
9329 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309330 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
9332 &RSNEncryptType,
9333 &mcRSNEncryptType,
9334 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08009335 &MFPCapable,
9336 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 pConfig->pRSNWPAReqIE[1]+2,
9338 pConfig->pRSNWPAReqIE );
9339
9340 if( VOS_STATUS_SUCCESS == status )
9341 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309342 /* Now copy over all the security attributes you have
9343 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 * */
9345 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
9346 pConfig->mcRSNEncryptType = mcRSNEncryptType;
9347 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
9348 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309349 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08009350 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
9352 }
9353 }
9354 }
9355
Jeff Johnson4416a782013-03-25 14:17:50 -07009356 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
9357 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
9358 return -EINVAL;
9359 }
9360
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
9362
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009363#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 if (params->ssid != NULL)
9365 {
9366 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
9367 pConfig->SSIDinfo.ssid.length = params->ssid_len;
9368 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9369 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9370 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009371#else
9372 if (ssid != NULL)
9373 {
9374 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
9375 pConfig->SSIDinfo.ssid.length = ssid_len;
9376 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
9377 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
9378 }
9379#endif
9380
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309381 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309383
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 /* default value */
9385 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
9386 pConfig->num_accept_mac = 0;
9387 pConfig->num_deny_mac = 0;
9388
9389 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9390 pBeacon->tail, pBeacon->tail_len);
9391
9392 /* pIe for black list is following form:
9393 type : 1 byte
9394 length : 1 byte
9395 OUI : 4 bytes
9396 acl type : 1 byte
9397 no of mac addr in black list: 1 byte
9398 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309399 */
9400 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009401 {
9402 pConfig->SapMacaddr_acl = pIe[6];
9403 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009404 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309406 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
9407 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9409 for (i = 0; i < pConfig->num_deny_mac; i++)
9410 {
9411 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9412 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 }
9415 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
9416 pBeacon->tail, pBeacon->tail_len);
9417
9418 /* pIe for white list is following form:
9419 type : 1 byte
9420 length : 1 byte
9421 OUI : 4 bytes
9422 acl type : 1 byte
9423 no of mac addr in white list: 1 byte
9424 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309425 */
9426 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 {
9428 pConfig->SapMacaddr_acl = pIe[6];
9429 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08009430 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309432 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
9433 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
9435 for (i = 0; i < pConfig->num_accept_mac; i++)
9436 {
9437 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
9438 acl_entry++;
9439 }
9440 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309441
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 wlan_hdd_set_sapHwmode(pHostapdAdapter);
9443
Jeff Johnsone7245742012-09-05 17:12:55 -07009444#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009445 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309446 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
9447 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05309448 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
9449 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08009450 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
9451 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05309452 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
9453 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009454 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309455 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07009456 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309457 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009458
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309459 /* If ACS disable and selected channel <= 14
9460 * OR
9461 * ACS enabled and ACS operating band is choosen as 2.4
9462 * AND
9463 * VHT in 2.4G Disabled
9464 * THEN
9465 * Fallback to 11N mode
9466 */
9467 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
9468 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05309469 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05309470 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009471 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05309472 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
9473 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07009474 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
9475 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009476 }
9477#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309478
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 // ht_capab is not what the name conveys,this is used for protection bitmap
9480 pConfig->ht_capab =
9481 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
9482
9483 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
9484 {
9485 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
9486 return -EINVAL;
9487 }
9488
9489 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309490 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
9492 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309493 pConfig->obssProtEnabled =
9494 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07009495
Chet Lanctot8cecea22014-02-11 19:09:36 -08009496#ifdef WLAN_FEATURE_11W
9497 pConfig->mfpCapable = MFPCapable;
9498 pConfig->mfpRequired = MFPRequired;
9499 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
9500 pConfig->mfpCapable, pConfig->mfpRequired);
9501#endif
9502
Arif Hussain6d2a3322013-11-17 19:50:10 -08009503 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08009505 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
9506 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
9507 (int)pConfig->channel);
9508 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
9509 pConfig->SapHw_mode, pConfig->privacy,
9510 pConfig->authType);
9511 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
9512 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
9513 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
9514 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009515
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309516 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 {
9518 //Bss already started. just return.
9519 //TODO Probably it should update some beacon params.
9520 hddLog( LOGE, "Bss Already started...Ignore the request");
9521 EXIT();
9522 return 0;
9523 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309524
Agarwal Ashish51325b52014-06-16 16:50:49 +05309525 if (vos_max_concurrent_connections_reached()) {
9526 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9527 return -EINVAL;
9528 }
9529
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 pConfig->persona = pHostapdAdapter->device_mode;
9531
Peng Xu2446a892014-09-05 17:21:18 +05309532 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
9533 if ( NULL != psmeConfig)
9534 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309535 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05309536 sme_GetConfigParam(hHal, psmeConfig);
9537 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05309538#ifdef WLAN_FEATURE_AP_HT40_24G
9539 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
9540 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
9541 && pHddCtx->cfg_ini->apHT40_24GEnabled)
9542 {
9543 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
9544 sme_UpdateConfig (hHal, psmeConfig);
9545 }
9546#endif
Peng Xu2446a892014-09-05 17:21:18 +05309547 vos_mem_free(psmeConfig);
9548 }
Peng Xuafc34e32014-09-25 13:23:55 +05309549 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05309550
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 pSapEventCallback = hdd_hostapd_SAPEventCB;
9552 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
9553 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
9554 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009555 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 return -EINVAL;
9557 }
9558
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309559 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
9561
9562 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309563
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565 {
9566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009567 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009568 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 VOS_ASSERT(0);
9570 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309571
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05309573 /* Initialize WMM configuation */
9574 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309575 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009576
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009577#ifdef WLAN_FEATURE_P2P_DEBUG
9578 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
9579 {
9580 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
9581 {
9582 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9583 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009584 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009585 }
9586 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
9587 {
9588 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
9589 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08009590 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009591 }
9592 }
9593#endif
9594
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 pHostapdState->bCommit = TRUE;
9596 EXIT();
9597
9598 return 0;
9599}
9600
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009601#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309602static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309603 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 struct beacon_parameters *params)
9605{
9606 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309607 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309608 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009609
9610 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309611
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309612 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9613 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
9614 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309615 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
9616 hdd_device_modetoString(pAdapter->device_mode),
9617 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009618
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309619 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9620 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309621 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009622 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309623 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009624 }
9625
Agarwal Ashish51325b52014-06-16 16:50:49 +05309626 if (vos_max_concurrent_connections_reached()) {
9627 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
9628 return -EINVAL;
9629 }
9630
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309631 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 )
9634 {
9635 beacon_data_t *old,*new;
9636
9637 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309638
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309640 {
9641 hddLog(VOS_TRACE_LEVEL_WARN,
9642 FL("already beacon info added to session(%d)"),
9643 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009646
9647 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9648
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309649 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 {
9651 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009652 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 return -EINVAL;
9654 }
9655
9656 pAdapter->sessionCtx.ap.beacon = new;
9657
9658 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9659 }
9660
9661 EXIT();
9662 return status;
9663}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309664
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309665static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
9666 struct net_device *dev,
9667 struct beacon_parameters *params)
9668{
9669 int ret;
9670
9671 vos_ssr_protect(__func__);
9672 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
9673 vos_ssr_unprotect(__func__);
9674
9675 return ret;
9676}
9677
9678static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009679 struct net_device *dev,
9680 struct beacon_parameters *params)
9681{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309682 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309683 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9684 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309685 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009686
9687 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309688
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309689 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9690 TRACE_CODE_HDD_CFG80211_SET_BEACON,
9691 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
9692 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9693 __func__, hdd_device_modetoString(pAdapter->device_mode),
9694 pAdapter->device_mode);
9695
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309696 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9697 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309698 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009699 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309700 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009701 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309702
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309703 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309705 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 {
9707 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309708
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309710
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309712 {
9713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9714 FL("session(%d) old and new heads points to NULL"),
9715 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009718
9719 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
9720
9721 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309722 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009723 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 return -EINVAL;
9725 }
9726
9727 pAdapter->sessionCtx.ap.beacon = new;
9728
9729 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
9730 }
9731
9732 EXIT();
9733 return status;
9734}
9735
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309736static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
9737 struct net_device *dev,
9738 struct beacon_parameters *params)
9739{
9740 int ret;
9741
9742 vos_ssr_protect(__func__);
9743 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
9744 vos_ssr_unprotect(__func__);
9745
9746 return ret;
9747}
9748
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009749#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9750
9751#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309752static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009753 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009754#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309755static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009756 struct net_device *dev)
9757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009758{
9759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07009760 hdd_context_t *pHddCtx = NULL;
9761 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309762 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309763 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009764
9765 ENTER();
9766
9767 if (NULL == pAdapter)
9768 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009770 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 return -ENODEV;
9772 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009773
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309774 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9775 TRACE_CODE_HDD_CFG80211_STOP_AP,
9776 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309777 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9778 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309779 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009780 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309781 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07009782 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009783
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009784 pScanInfo = &pHddCtx->scan_info;
9785
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309786 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9787 __func__, hdd_device_modetoString(pAdapter->device_mode),
9788 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009789
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309790 ret = wlan_hdd_scan_abort(pAdapter);
9791
Girish Gowli4bf7a632014-06-12 13:42:11 +05309792 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07009793 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9795 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309796
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309797 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07009798 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9800 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08009801
Jeff Johnsone7245742012-09-05 17:12:55 -07009802 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309803 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07009804 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309805 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07009806 }
9807
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309808 /* Delete all associated STAs before stopping AP/P2P GO */
9809 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05309810 hdd_hostapd_stop(dev);
9811
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009813 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 )
9815 {
9816 beacon_data_t *old;
9817
9818 old = pAdapter->sessionCtx.ap.beacon;
9819
9820 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309821 {
9822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9823 FL("session(%d) beacon data points to NULL"),
9824 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009827
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009829
9830 mutex_lock(&pHddCtx->sap_lock);
9831 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9832 {
Jeff Johnson4416a782013-03-25 14:17:50 -07009833 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 {
9835 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9836
9837 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
9838
9839 if (!VOS_IS_STATUS_SUCCESS(status))
9840 {
9841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009842 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309844 }
9845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05309847 /* BSS stopped, clear the active sessions for this device mode */
9848 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 }
9850 mutex_unlock(&pHddCtx->sap_lock);
9851
9852 if(status != VOS_STATUS_SUCCESS)
9853 {
9854 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009855 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 return -EINVAL;
9857 }
9858
Jeff Johnson4416a782013-03-25 14:17:50 -07009859 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
9861 ==eHAL_STATUS_FAILURE)
9862 {
9863 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009864 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 }
9866
Jeff Johnson4416a782013-03-25 14:17:50 -07009867 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
9869 eANI_BOOLEAN_FALSE) )
9870 {
9871 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009872 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009873 }
9874
9875 // Reset WNI_CFG_PROBE_RSP Flags
9876 wlan_hdd_reset_prob_rspies(pAdapter);
9877
9878 pAdapter->sessionCtx.ap.beacon = NULL;
9879 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07009880#ifdef WLAN_FEATURE_P2P_DEBUG
9881 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
9882 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
9883 {
9884 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
9885 "GO got removed");
9886 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
9887 }
9888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 }
9890 EXIT();
9891 return status;
9892}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009893
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309894#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9895static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
9896 struct net_device *dev)
9897{
9898 int ret;
9899
9900 vos_ssr_protect(__func__);
9901 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
9902 vos_ssr_unprotect(__func__);
9903
9904 return ret;
9905}
9906#else
9907static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
9908 struct net_device *dev)
9909{
9910 int ret;
9911
9912 vos_ssr_protect(__func__);
9913 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
9914 vos_ssr_unprotect(__func__);
9915
9916 return ret;
9917}
9918#endif
9919
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009920#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
9921
Mukul Sharmab0e0a982014-12-15 18:58:53 +05309922static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309923 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009924 struct cfg80211_ap_settings *params)
9925{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309926 hdd_adapter_t *pAdapter;
9927 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309928 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009929
9930 ENTER();
9931
Girish Gowlib143d7a2015-02-18 19:39:55 +05309932 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07009933 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05309935 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309936 return -ENODEV;
9937 }
9938
9939 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9940 if (NULL == pAdapter)
9941 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309943 "%s: HDD adapter is Null", __func__);
9944 return -ENODEV;
9945 }
9946
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309947 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9948 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
9949 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309950 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
9951 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309952 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309953 "%s: HDD adapter magic is invalid", __func__);
9954 return -ENODEV;
9955 }
9956
9957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309958 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309959 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309960 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309961 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309962 }
9963
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309964 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
9965 __func__, hdd_device_modetoString(pAdapter->device_mode),
9966 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309967
9968 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009969 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009970 )
9971 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309972 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009973
9974 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309975
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009976 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309977 {
9978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9979 FL("already beacon info added to session(%d)"),
9980 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009981 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309982 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009983
Girish Gowlib143d7a2015-02-18 19:39:55 +05309984#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9985 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
9986 &new,
9987 &params->beacon);
9988#else
9989 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
9990 &new,
9991 &params->beacon,
9992 params->dtim_period);
9993#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009994
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309995 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009996 {
9997 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05309998 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009999 return -EINVAL;
10000 }
10001 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -080010002#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -070010003 wlan_hdd_cfg80211_set_channel(wiphy, dev,
10004#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
10005 params->channel, params->channel_type);
10006#else
10007 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
10008#endif
Viral Modi3a32cc52013-02-08 11:14:52 -080010009#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010010 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010011 params->ssid_len, params->hidden_ssid,
10012 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010013 }
10014
10015 EXIT();
10016 return status;
10017}
10018
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010019static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
10020 struct net_device *dev,
10021 struct cfg80211_ap_settings *params)
10022{
10023 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010024
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010025 vos_ssr_protect(__func__);
10026 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
10027 vos_ssr_unprotect(__func__);
10028
10029 return ret;
10030}
10031
10032static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010033 struct net_device *dev,
10034 struct cfg80211_beacon_data *params)
10035{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010036 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010037 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010038 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010039
10040 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010041
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010042 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10043 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
10044 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -080010045 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010046 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010047
10048 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10049 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010050 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010051 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010052 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -070010053 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010054
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010055 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010056 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010057 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010058 {
10059 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010060
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010061 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010062
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010063 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010064 {
10065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10066 FL("session(%d) beacon data points to NULL"),
10067 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010068 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010069 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010070
10071 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
10072
10073 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010074 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010075 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010076 return -EINVAL;
10077 }
10078
10079 pAdapter->sessionCtx.ap.beacon = new;
10080
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +053010081 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
10082 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010083 }
10084
10085 EXIT();
10086 return status;
10087}
10088
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010089static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
10090 struct net_device *dev,
10091 struct cfg80211_beacon_data *params)
10092{
10093 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010094
Mukul Sharmab0e0a982014-12-15 18:58:53 +053010095 vos_ssr_protect(__func__);
10096 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
10097 vos_ssr_unprotect(__func__);
10098
10099 return ret;
10100}
10101
10102#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070010103
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010104static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 struct net_device *dev,
10106 struct bss_parameters *params)
10107{
10108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010109 hdd_context_t *pHddCtx;
10110 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010111
10112 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010113
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010114 if (NULL == pAdapter)
10115 {
10116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10117 "%s: HDD adapter is Null", __func__);
10118 return -ENODEV;
10119 }
10120 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010121 ret = wlan_hdd_validate_context(pHddCtx);
10122 if (0 != ret)
10123 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010124 return ret;
10125 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010126 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10127 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
10128 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010129 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10130 __func__, hdd_device_modetoString(pAdapter->device_mode),
10131 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010132
10133 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010135 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 {
10137 /* ap_isolate == -1 means that in change bss, upper layer doesn't
10138 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010139 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 {
10141 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010143 }
10144
10145 EXIT();
10146 return 0;
10147}
10148
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010149static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
10150 struct net_device *dev,
10151 struct bss_parameters *params)
10152{
10153 int ret;
10154
10155 vos_ssr_protect(__func__);
10156 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
10157 vos_ssr_unprotect(__func__);
10158
10159 return ret;
10160}
Kiet Lam10841362013-11-01 11:36:50 +053010161/* FUNCTION: wlan_hdd_change_country_code_cd
10162* to wait for contry code completion
10163*/
10164void* wlan_hdd_change_country_code_cb(void *pAdapter)
10165{
10166 hdd_adapter_t *call_back_pAdapter = pAdapter;
10167 complete(&call_back_pAdapter->change_country_code);
10168 return NULL;
10169}
10170
Jeff Johnson295189b2012-06-20 16:38:30 -070010171/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010172 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
10174 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010175int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 struct net_device *ndev,
10177 enum nl80211_iftype type,
10178 u32 *flags,
10179 struct vif_params *params
10180 )
10181{
10182 struct wireless_dev *wdev;
10183 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010184 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -070010185 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 tCsrRoamProfile *pRoamProfile = NULL;
10187 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010188 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010189 eMib_dot11DesiredBssType connectedBssType;
10190 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010191 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010192
10193 ENTER();
10194
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010195 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010196 {
10197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10198 "%s: Adapter context is null", __func__);
10199 return VOS_STATUS_E_FAILURE;
10200 }
10201
10202 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10203 if (!pHddCtx)
10204 {
10205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10206 "%s: HDD context is null", __func__);
10207 return VOS_STATUS_E_FAILURE;
10208 }
10209
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010210 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10211 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
10212 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010213 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010214 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010216 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 }
10218
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010219 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10220 __func__, hdd_device_modetoString(pAdapter->device_mode),
10221 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010222
Agarwal Ashish51325b52014-06-16 16:50:49 +053010223 if (vos_max_concurrent_connections_reached()) {
10224 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10225 return -EINVAL;
10226 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010227 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 wdev = ndev->ieee80211_ptr;
10229
10230#ifdef WLAN_BTAMP_FEATURE
10231 if((NL80211_IFTYPE_P2P_CLIENT == type)||
10232 (NL80211_IFTYPE_ADHOC == type)||
10233 (NL80211_IFTYPE_AP == type)||
10234 (NL80211_IFTYPE_P2P_GO == type))
10235 {
10236 pHddCtx->isAmpAllowed = VOS_FALSE;
10237 // stop AMP traffic
10238 status = WLANBAP_StopAmp();
10239 if(VOS_STATUS_SUCCESS != status )
10240 {
10241 pHddCtx->isAmpAllowed = VOS_TRUE;
10242 hddLog(VOS_TRACE_LEVEL_FATAL,
10243 "%s: Failed to stop AMP", __func__);
10244 return -EINVAL;
10245 }
10246 }
10247#endif //WLAN_BTAMP_FEATURE
10248 /* Reset the current device mode bit mask*/
10249 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
10250
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053010251 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
10252 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
10253 (type == NL80211_IFTYPE_P2P_GO)))
10254 {
10255 /* Notify Mode change in case of concurrency.
10256 * Below function invokes TDLS teardown Functionality Since TDLS is
10257 * not Supported in case of concurrency i.e Once P2P session
10258 * is detected disable offchannel and teardown TDLS links
10259 */
10260 hddLog(LOG1,
10261 FL("Device mode = %d Interface type = %d"),
10262 pAdapter->device_mode, type);
10263 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
10264 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053010265
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -070010268 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 )
10270 {
10271 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010272 if (!pWextState)
10273 {
10274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10275 "%s: pWextState is null", __func__);
10276 return VOS_STATUS_E_FAILURE;
10277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 pRoamProfile = &pWextState->roamProfile;
10279 LastBSSType = pRoamProfile->BSSType;
10280
10281 switch (type)
10282 {
10283 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010284 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 hddLog(VOS_TRACE_LEVEL_INFO,
10286 "%s: setting interface Type to INFRASTRUCTURE", __func__);
10287 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010288#ifdef WLAN_FEATURE_11AC
10289 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
10290 {
10291 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
10292 }
10293#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010294 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -070010295 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010296 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010297 //Check for sub-string p2p to confirm its a p2p interface
10298 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010299 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +053010300#ifdef FEATURE_WLAN_TDLS
10301 mutex_lock(&pHddCtx->tdls_lock);
10302 wlan_hdd_tdls_exit(pAdapter, TRUE);
10303 mutex_unlock(&pHddCtx->tdls_lock);
10304#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010305 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10306 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10307 }
10308 else
10309 {
10310 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010313 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +053010314
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 case NL80211_IFTYPE_ADHOC:
10316 hddLog(VOS_TRACE_LEVEL_INFO,
10317 "%s: setting interface Type to ADHOC", __func__);
10318 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
10319 pRoamProfile->phyMode =
10320 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -070010321 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +053010323 hdd_set_ibss_ops( pAdapter );
10324 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +053010325
10326 status = hdd_sta_id_hash_attach(pAdapter);
10327 if (VOS_STATUS_SUCCESS != status) {
10328 hddLog(VOS_TRACE_LEVEL_ERROR,
10329 FL("Failed to initialize hash for IBSS"));
10330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 break;
10332
10333 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 {
10336 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10337 "%s: setting interface Type to %s", __func__,
10338 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
10339
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010340 //Cancel any remain on channel for GO mode
10341 if (NL80211_IFTYPE_P2P_GO == type)
10342 {
10343 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
10344 }
Mohit Khanna0f232092012-09-11 14:46:08 -070010345 if (NL80211_IFTYPE_AP == type)
10346 {
10347 /* As Loading WLAN Driver one interface being created for p2p device
10348 * address. This will take one HW STA and the max number of clients
10349 * that can connect to softAP will be reduced by one. so while changing
10350 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
10351 * interface as it is not required in SoftAP mode.
10352 */
10353
10354 // Get P2P Adapter
10355 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
10356
10357 if (pP2pAdapter)
10358 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +053010359 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +053010360 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -070010361 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
10362 }
10363 }
Swaroop Goltia2e32212014-04-09 23:37:33 +053010364 //Disable IMPS & BMPS for SAP/GO
10365 if(VOS_STATUS_E_FAILURE ==
10366 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
10367 {
10368 //Fail to Exit BMPS
10369 VOS_ASSERT(0);
10370 }
Deepthi Gowri500fc472014-08-11 19:53:10 +053010371
10372 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
10373
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010374#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -070010375
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010376 /* A Mutex Lock is introduced while changing the mode to
10377 * protect the concurrent access for the Adapters by TDLS
10378 * module.
10379 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010380 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010381#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010382 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +053010383 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10386 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010387#ifdef FEATURE_WLAN_TDLS
10388 mutex_unlock(&pHddCtx->tdls_lock);
10389#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010390 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
10391 (pConfig->apRandomBssidEnabled))
10392 {
10393 /* To meet Android requirements create a randomized
10394 MAC address of the form 02:1A:11:Fx:xx:xx */
10395 get_random_bytes(&ndev->dev_addr[3], 3);
10396 ndev->dev_addr[0] = 0x02;
10397 ndev->dev_addr[1] = 0x1A;
10398 ndev->dev_addr[2] = 0x11;
10399 ndev->dev_addr[3] |= 0xF0;
10400 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
10401 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -080010402 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
10403 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -070010404 }
10405
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 hdd_set_ap_ops( pAdapter->dev );
10407
Kiet Lam10841362013-11-01 11:36:50 +053010408 /* This is for only SAP mode where users can
10409 * control country through ini.
10410 * P2P GO follows station country code
10411 * acquired during the STA scanning. */
10412 if((NL80211_IFTYPE_AP == type) &&
10413 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
10414 {
10415 int status = 0;
10416 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
10417 "%s: setting country code from INI ", __func__);
10418 init_completion(&pAdapter->change_country_code);
10419 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
10420 (void *)(tSmeChangeCountryCallback)
10421 wlan_hdd_change_country_code_cb,
10422 pConfig->apCntryCode, pAdapter,
10423 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +053010424 eSIR_FALSE,
10425 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +053010426 if (eHAL_STATUS_SUCCESS == status)
10427 {
10428 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010429 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +053010430 &pAdapter->change_country_code,
10431 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010432 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +053010433 {
10434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010435 FL("SME Timed out while setting country code %ld"),
10436 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -080010437
10438 if (pHddCtx->isLogpInProgress)
10439 {
10440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10441 "%s: LOGP in Progress. Ignore!!!", __func__);
10442 return -EAGAIN;
10443 }
Kiet Lam10841362013-11-01 11:36:50 +053010444 }
10445 }
10446 else
10447 {
10448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010449 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +053010450 return -EINVAL;
10451 }
10452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 status = hdd_init_ap_mode(pAdapter);
10454 if(status != VOS_STATUS_SUCCESS)
10455 {
10456 hddLog(VOS_TRACE_LEVEL_FATAL,
10457 "%s: Error initializing the ap mode", __func__);
10458 return -EINVAL;
10459 }
10460 hdd_set_conparam(1);
10461
Nirav Shah7e3c8132015-06-22 23:51:42 +053010462 status = hdd_sta_id_hash_attach(pAdapter);
10463 if (VOS_STATUS_SUCCESS != status)
10464 {
10465 hddLog(VOS_TRACE_LEVEL_ERROR,
10466 FL("Failed to initialize hash for AP"));
10467 return -EINVAL;
10468 }
10469
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 /*interface type changed update in wiphy structure*/
10471 if(wdev)
10472 {
10473 wdev->iftype = type;
10474 pHddCtx->change_iface = type;
10475 }
10476 else
10477 {
10478 hddLog(VOS_TRACE_LEVEL_ERROR,
10479 "%s: ERROR !!!! Wireless dev is NULL", __func__);
10480 return -EINVAL;
10481 }
10482 goto done;
10483 }
10484
10485 default:
10486 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10487 __func__);
10488 return -EOPNOTSUPP;
10489 }
10490 }
10491 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010492 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -070010493 )
10494 {
10495 switch(type)
10496 {
10497 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +053010500
10501 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010502#ifdef FEATURE_WLAN_TDLS
10503
10504 /* A Mutex Lock is introduced while changing the mode to
10505 * protect the concurrent access for the Adapters by TDLS
10506 * module.
10507 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010508 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010509#endif
c_hpothu002231a2015-02-05 14:58:51 +053010510 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -080010512 //Check for sub-string p2p to confirm its a p2p interface
10513 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010514 {
10515 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
10516 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
10517 }
10518 else
10519 {
10520 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -070010521 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -080010522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 hdd_set_conparam(0);
10524 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
10526 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010527#ifdef FEATURE_WLAN_TDLS
10528 mutex_unlock(&pHddCtx->tdls_lock);
10529#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +053010530 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 if( VOS_STATUS_SUCCESS != status )
10532 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -070010533 /* In case of JB, for P2P-GO, only change interface will be called,
10534 * This is the right place to enable back bmps_imps()
10535 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010536 if (pHddCtx->hdd_wlan_suspended)
10537 {
10538 hdd_set_pwrparams(pHddCtx);
10539 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010540 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 goto done;
10542 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -070010545 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
10546 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 goto done;
10548 default:
10549 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
10550 __func__);
10551 return -EOPNOTSUPP;
10552
10553 }
10554
10555 }
10556 else
10557 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010558 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
10559 __func__, hdd_device_modetoString(pAdapter->device_mode),
10560 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 return -EOPNOTSUPP;
10562 }
10563
10564
10565 if(pRoamProfile)
10566 {
10567 if ( LastBSSType != pRoamProfile->BSSType )
10568 {
10569 /*interface type changed update in wiphy structure*/
10570 wdev->iftype = type;
10571
10572 /*the BSS mode changed, We need to issue disconnect
10573 if connected or in IBSS disconnect state*/
10574 if ( hdd_connGetConnectedBssType(
10575 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
10576 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
10577 {
10578 /*need to issue a disconnect to CSR.*/
10579 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10580 if( eHAL_STATUS_SUCCESS ==
10581 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10582 pAdapter->sessionId,
10583 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10584 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010585 ret = wait_for_completion_interruptible_timeout(
10586 &pAdapter->disconnect_comp_var,
10587 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10588 if (ret <= 0)
10589 {
10590 hddLog(VOS_TRACE_LEVEL_ERROR,
10591 FL("wait on disconnect_comp_var failed %ld"), ret);
10592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 }
10594 }
10595 }
10596 }
10597
10598done:
10599 /*set bitmask based on updated value*/
10600 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -070010601
10602 /* Only STA mode support TM now
10603 * all other mode, TM feature should be disabled */
10604 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
10605 (~VOS_STA & pHddCtx->concurrency_mode) )
10606 {
10607 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
10608 }
10609
Jeff Johnson295189b2012-06-20 16:38:30 -070010610#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010611 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010612 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 {
10614 //we are ok to do AMP
10615 pHddCtx->isAmpAllowed = VOS_TRUE;
10616 }
10617#endif //WLAN_BTAMP_FEATURE
10618 EXIT();
10619 return 0;
10620}
10621
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +053010622/*
10623 * FUNCTION: wlan_hdd_cfg80211_change_iface
10624 * wrapper function to protect the actual implementation from SSR.
10625 */
10626int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
10627 struct net_device *ndev,
10628 enum nl80211_iftype type,
10629 u32 *flags,
10630 struct vif_params *params
10631 )
10632{
10633 int ret;
10634
10635 vos_ssr_protect(__func__);
10636 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
10637 vos_ssr_unprotect(__func__);
10638
10639 return ret;
10640}
10641
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010642#ifdef FEATURE_WLAN_TDLS
10643static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010644 struct net_device *dev,
10645#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10646 const u8 *mac,
10647#else
10648 u8 *mac,
10649#endif
10650 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010651{
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010652 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010653 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010654 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010655 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010656 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010657 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010658
10659 ENTER();
10660
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010661 if (!dev) {
10662 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
10663 return -EINVAL;
10664 }
10665
10666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10667 if (!pAdapter) {
10668 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
10669 return -EINVAL;
10670 }
10671
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010672 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010673 {
10674 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10675 "Invalid arguments");
10676 return -EINVAL;
10677 }
Hoonki Lee27511902013-03-14 18:19:06 -070010678
10679 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
10680 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
10681 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010682 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070010683 "%s: TDLS mode is disabled OR not enabled in FW."
10684 MAC_ADDRESS_STR " Request declined.",
10685 __func__, MAC_ADDR_ARRAY(mac));
10686 return -ENOTSUPP;
10687 }
10688
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010689 if (pHddCtx->isLogpInProgress)
10690 {
10691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10692 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053010693 wlan_hdd_tdls_set_link_status(pAdapter,
10694 mac,
10695 eTDLS_LINK_IDLE,
10696 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010697 return -EBUSY;
10698 }
10699
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010700 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +053010701 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010702
10703 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010705 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
10706 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053010707 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010708 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010709 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010710
10711 /* in add station, we accept existing valid staId if there is */
10712 if ((0 == update) &&
10713 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
10714 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010715 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010717 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010718 " link_status %d. staId %d. add station ignored.",
10719 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010720 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010721 return 0;
10722 }
10723 /* in change station, we accept only when staId is valid */
10724 if ((1 == update) &&
10725 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
10726 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
10727 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010728 tANI_U16 staId = pTdlsPeer->staId;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010730 "%s: " MAC_ADDRESS_STR
10731 " link status %d. staId %d. change station %s.",
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010732 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId,
10733 (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined");
10734 mutex_unlock(&pHddCtx->tdls_lock);
10735 return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010736 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010737 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010738
10739 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053010740 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010741 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10743 "%s: " MAC_ADDRESS_STR
10744 " TDLS setup is ongoing. Request declined.",
10745 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -070010746 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010747 }
10748
10749 /* first to check if we reached to maximum supported TDLS peer.
10750 TODO: for now, return -EPERM looks working fine,
10751 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010752 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10753 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010754 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10756 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010757 " TDLS Max peer already connected. Request declined."
10758 " Num of peers (%d), Max allowed (%d).",
10759 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
10760 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010761 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010762 }
10763 else
10764 {
10765 hddTdlsPeer_t *pTdlsPeer;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010766 mutex_lock(&pHddCtx->tdls_lock);
10767 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010768 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010769 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010770 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010771 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10772 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
10773 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010774 return -EPERM;
10775 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010776 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010777 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010778 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +053010779 wlan_hdd_tdls_set_link_status(pAdapter,
10780 mac,
10781 eTDLS_LINK_CONNECTING,
10782 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010783
Jeff Johnsond75fe012013-04-06 10:53:06 -070010784 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010785 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010786 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010788 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010789 if(StaParams->htcap_present)
10790 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010792 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010794 "ht_capa->extended_capabilities: %0x",
10795 StaParams->HTCap.extendedHtCapInfo);
10796 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010798 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010800 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -070010801 if(StaParams->vhtcap_present)
10802 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -070010804 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
10805 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
10806 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
10807 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010808 {
10809 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010811 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053010812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010813 "[%d]: %x ", i, StaParams->supported_rates[i]);
10814 }
Jeff Johnsond75fe012013-04-06 10:53:06 -070010815 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +053010816 else if ((1 == update) && (NULL == StaParams))
10817 {
10818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10819 "%s : update is true, but staParams is NULL. Error!", __func__);
10820 return -EPERM;
10821 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010822
10823 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
10824
10825 if (!update)
10826 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010827 /*Before adding sta make sure that device exited from BMPS*/
10828 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10829 {
10830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10831 "%s: Adding tdls peer sta. Disable BMPS", __func__);
10832 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10833 if (status != VOS_STATUS_SUCCESS) {
10834 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
10835 }
10836 }
10837
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010838 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010839 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010840 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +053010841 hddLog(VOS_TRACE_LEVEL_ERROR,
10842 FL("Failed to add TDLS peer STA. Enable Bmps"));
10843 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010844 return -EPERM;
10845 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010846 }
10847 else
10848 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010849 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010850 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053010851 if (ret != eHAL_STATUS_SUCCESS) {
10852 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
10853 return -EPERM;
10854 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010855 }
10856
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010857 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010858 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
10859
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010860 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010861 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010863 "%s: timeout waiting for tdls add station indication %ld",
10864 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010865 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010866 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010867
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010868 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
10869 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010871 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010872 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010873 }
10874
10875 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010876
10877error:
Atul Mittal115287b2014-07-08 13:26:33 +053010878 wlan_hdd_tdls_set_link_status(pAdapter,
10879 mac,
10880 eTDLS_LINK_IDLE,
10881 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010882 return -EPERM;
10883
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010884}
10885#endif
10886
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010887static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010888 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010889#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10890 const u8 *mac,
10891#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053010893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010894 struct station_parameters *params)
10895{
10896 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010897 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010898 hdd_context_t *pHddCtx;
10899 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010901 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010902#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010903 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010904 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010905 tANI_U8 isOffChannelSupported = 0;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053010906 tANI_U8 isQosWmmSta = FALSE;
Gopichand Nakkalab0856222013-03-12 22:39:05 -070010907#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010908
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010909 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010910
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053010911 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010912 if ((NULL == pAdapter))
10913 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053010915 "invalid adapter ");
10916 return -EINVAL;
10917 }
10918
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010919 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10920 TRACE_CODE_HDD_CHANGE_STATION,
10921 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +053010922 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +053010923
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010924 ret = wlan_hdd_validate_context(pHddCtx);
10925 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +053010926 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010927 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010928 }
10929
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010930 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10931
10932 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010933 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053010934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10935 "invalid HDD station context");
10936 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010937 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
10939
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010940 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10941 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010943 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -070010944 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010945 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 WLANTL_STA_AUTHENTICATED);
10947
Gopichand Nakkala29149562013-05-10 21:43:41 +053010948 if (status != VOS_STATUS_SUCCESS)
10949 {
10950 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10951 "%s: Not able to change TL state to AUTHENTICATED", __func__);
10952 return -EINVAL;
10953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 }
10955 }
Hoonki Leea6d49be2013-04-05 09:43:25 -070010956 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
10957 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +053010958#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010959 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
10960 StaParams.capability = params->capability;
10961 StaParams.uapsd_queues = params->uapsd_queues;
10962 StaParams.max_sp = params->max_sp;
10963
Naresh Jayaram3180aa42014-02-12 21:47:26 +053010964 /* Convert (first channel , number of channels) tuple to
10965 * the total list of channels. This goes with the assumption
10966 * that if the first channel is < 14, then the next channels
10967 * are an incremental of 1 else an incremental of 4 till the number
10968 * of channels.
10969 */
10970 if (0 != params->supported_channels_len) {
10971 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
10972 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
10973 {
10974 int wifi_chan_index;
10975 StaParams.supported_channels[j] = params->supported_channels[i];
10976 wifi_chan_index =
10977 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
10978 no_of_channels = params->supported_channels[i+1];
10979 for(k=1; k <= no_of_channels; k++)
10980 {
10981 StaParams.supported_channels[j+1] =
10982 StaParams.supported_channels[j] + wifi_chan_index;
10983 j+=1;
10984 }
10985 }
10986 StaParams.supported_channels_len = j;
10987 }
10988 vos_mem_copy(StaParams.supported_oper_classes,
10989 params->supported_oper_classes,
10990 params->supported_oper_classes_len);
10991 StaParams.supported_oper_classes_len =
10992 params->supported_oper_classes_len;
10993
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010994 if (0 != params->ext_capab_len)
10995 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
10996 sizeof(StaParams.extn_capability));
10997
10998 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070010999 {
11000 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011001 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011002 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011003
11004 StaParams.supported_rates_len = params->supported_rates_len;
11005
11006 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
11007 * The supported_rates array , for all the structures propogating till Add Sta
11008 * to the firmware has to be modified , if the supplicant (ieee80211) is
11009 * modified to send more rates.
11010 */
11011
11012 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
11013 */
11014 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
11015 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
11016
11017 if (0 != StaParams.supported_rates_len) {
11018 int i = 0;
11019 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
11020 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011021 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011022 "Supported Rates with Length %d", StaParams.supported_rates_len);
11023 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -070011024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011025 "[%d]: %0x", i, StaParams.supported_rates[i]);
11026 }
11027
11028 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -070011029 {
11030 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011031 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -070011032 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070011033
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011034 if (0 != params->ext_capab_len ) {
11035 /*Define A Macro : TODO Sunil*/
11036 if ((1<<4) & StaParams.extn_capability[3]) {
11037 isBufSta = 1;
11038 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011039 /* TDLS Channel Switching Support */
11040 if ((1<<6) & StaParams.extn_capability[3]) {
11041 isOffChannelSupported = 1;
11042 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011043 }
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011044
11045 if (pHddCtx->cfg_ini->fEnableTDLSWmmMode &&
11046 (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME))) {
11047
11048 /* TDLS Peer is WME/QoS capable */
11049 isQosWmmSta = TRUE;
11050 }
11051
11052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11053 "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d",
11054 __func__, isQosWmmSta, StaParams.htcap_present);
11055
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011056 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
11057 &StaParams, isBufSta,
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053011058 isOffChannelSupported,
11059 isQosWmmSta);
Naresh Jayaram3180aa42014-02-12 21:47:26 +053011060
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011061 if (VOS_STATUS_SUCCESS != status) {
11062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11063 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
11064 return -EINVAL;
11065 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011066 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
11067
11068 if (VOS_STATUS_SUCCESS != status) {
11069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11070 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
11071 return -EINVAL;
11072 }
11073 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -070011074#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +053011075 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011076 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 return status;
11078}
11079
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011080#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
11081static int wlan_hdd_change_station(struct wiphy *wiphy,
11082 struct net_device *dev,
11083 const u8 *mac,
11084 struct station_parameters *params)
11085#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011086static int wlan_hdd_change_station(struct wiphy *wiphy,
11087 struct net_device *dev,
11088 u8 *mac,
11089 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011090#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011091{
11092 int ret;
11093
11094 vos_ssr_protect(__func__);
11095 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
11096 vos_ssr_unprotect(__func__);
11097
11098 return ret;
11099}
11100
Jeff Johnson295189b2012-06-20 16:38:30 -070011101/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011102 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 * This function is used to initialize the key information
11104 */
11105#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011106static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 struct net_device *ndev,
11108 u8 key_index, bool pairwise,
11109 const u8 *mac_addr,
11110 struct key_params *params
11111 )
11112#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011113static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011114 struct net_device *ndev,
11115 u8 key_index, const u8 *mac_addr,
11116 struct key_params *params
11117 )
11118#endif
11119{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070011121 tCsrRoamSetKey setKey;
11122 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011123 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011124 v_U32_t roamId= 0xFF;
11125 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 hdd_hostapd_state_t *pHostapdState;
11127 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011128 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011129 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011130
11131 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011132
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011133 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11134 TRACE_CODE_HDD_CFG80211_ADD_KEY,
11135 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011136 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11137 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011138 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011139 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011140 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011141 }
11142
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011143 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11144 __func__, hdd_device_modetoString(pAdapter->device_mode),
11145 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011146
11147 if (CSR_MAX_NUM_KEY <= key_index)
11148 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 key_index);
11151
11152 return -EINVAL;
11153 }
11154
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011155 if (CSR_MAX_KEY_LEN < params->key_len)
11156 {
11157 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
11158 params->key_len);
11159
11160 return -EINVAL;
11161 }
11162
11163 hddLog(VOS_TRACE_LEVEL_INFO,
11164 "%s: called with key index = %d & key length %d",
11165 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011166
11167 /*extract key idx, key len and key*/
11168 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11169 setKey.keyId = key_index;
11170 setKey.keyLength = params->key_len;
11171 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
11172
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011173 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 {
11175 case WLAN_CIPHER_SUITE_WEP40:
11176 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
11177 break;
11178
11179 case WLAN_CIPHER_SUITE_WEP104:
11180 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
11181 break;
11182
11183 case WLAN_CIPHER_SUITE_TKIP:
11184 {
11185 u8 *pKey = &setKey.Key[0];
11186 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
11187
11188 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
11189
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011190 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -070011191
11192 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011193 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011194 |--------------|----------|----------|
11195 <---16bytes---><--8bytes--><--8bytes-->
11196
11197 */
11198 /*Sme expects the 32 bytes key to be in the below order
11199
11200 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011201 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -070011202 |--------------|----------|----------|
11203 <---16bytes---><--8bytes--><--8bytes-->
11204 */
11205 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011206 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011207
11208 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011209 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011210
11211 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011212 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011213
11214
11215 break;
11216 }
11217
11218 case WLAN_CIPHER_SUITE_CCMP:
11219 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
11220 break;
11221
11222#ifdef FEATURE_WLAN_WAPI
11223 case WLAN_CIPHER_SUITE_SMS4:
11224 {
11225 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11226 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
11227 params->key, params->key_len);
11228 return 0;
11229 }
11230#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011231
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011232#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 case WLAN_CIPHER_SUITE_KRK:
11234 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
11235 break;
11236#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011237
11238#ifdef WLAN_FEATURE_11W
11239 case WLAN_CIPHER_SUITE_AES_CMAC:
11240 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -070011241 break;
Chet Lanctot186b5732013-03-18 10:26:30 -070011242#endif
11243
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011247 status = -EOPNOTSUPP;
11248 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 }
11250
11251 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
11252 __func__, setKey.encType);
11253
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011254 if (
Jeff Johnson295189b2012-06-20 16:38:30 -070011255#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11256 (!pairwise)
11257#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011258 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -070011259#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011260 )
11261 {
11262 /* set group key*/
11263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11264 "%s- %d: setting Broadcast key",
11265 __func__, __LINE__);
11266 setKey.keyDirection = eSIR_RX_ONLY;
11267 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11268 }
11269 else
11270 {
11271 /* set pairwise key*/
11272 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11273 "%s- %d: setting pairwise key",
11274 __func__, __LINE__);
11275 setKey.keyDirection = eSIR_TX_RX;
11276 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11277 }
11278 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
11279 {
11280 setKey.keyDirection = eSIR_TX_RX;
11281 /*Set the group key*/
11282 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11283 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011284
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011285 if ( 0 != status )
11286 {
11287 hddLog(VOS_TRACE_LEVEL_ERROR,
11288 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011289 status = -EINVAL;
11290 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011291 }
11292 /*Save the keys here and call sme_RoamSetKey for setting
11293 the PTK after peer joins the IBSS network*/
11294 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
11295 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011296 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070011297 }
Gopichand Nakkala29149562013-05-10 21:43:41 +053011298 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
11299 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
11300 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011301 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011302 if( pHostapdState->bssState == BSS_START )
11303 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011304 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11305 vos_status = wlan_hdd_check_ula_done(pAdapter);
11306
11307 if ( vos_status != VOS_STATUS_SUCCESS )
11308 {
11309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11310 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11311 __LINE__, vos_status );
11312
11313 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11314
11315 status = -EINVAL;
11316 goto end;
11317 }
11318
Jeff Johnson295189b2012-06-20 16:38:30 -070011319 status = WLANSAP_SetKeySta( pVosContext, &setKey);
11320
11321 if ( status != eHAL_STATUS_SUCCESS )
11322 {
11323 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11324 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11325 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011326 status = -EINVAL;
11327 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 }
11329 }
11330
11331 /* Saving WEP keys */
11332 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
11333 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
11334 {
11335 //Save the wep key in ap context. Issue setkey after the BSS is started.
11336 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11337 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
11338 }
11339 else
11340 {
11341 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011342 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
11344 }
11345 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011346 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
11347 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 {
11349 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11350 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11351
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011352#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11353 if (!pairwise)
11354#else
11355 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
11356#endif
11357 {
11358 /* set group key*/
11359 if (pHddStaCtx->roam_info.deferKeyComplete)
11360 {
11361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11362 "%s- %d: Perform Set key Complete",
11363 __func__, __LINE__);
11364 hdd_PerformRoamSetKeyComplete(pAdapter);
11365 }
11366 }
11367
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
11369
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -080011370 pWextState->roamProfile.Keys.defaultIndex = key_index;
11371
11372
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070011373 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 params->key, params->key_len);
11375
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011376
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11378
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011379 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011380 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011381 __func__, setKey.peerMac[0], setKey.peerMac[1],
11382 setKey.peerMac[2], setKey.peerMac[3],
11383 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 setKey.keyDirection);
11385
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011386 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +053011387
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011388 if ( vos_status != VOS_STATUS_SUCCESS )
11389 {
11390 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
11392 __LINE__, vos_status );
11393
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011394 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011395
Nirav Shah4b53d4b2015-05-08 05:35:00 -070011396 status = -EINVAL;
11397 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011398
11399 }
11400
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011401#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011402 /* The supplicant may attempt to set the PTK once pre-authentication
11403 is done. Save the key in the UMAC and include it in the ADD BSS
11404 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011405 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011406 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011407 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011408 hddLog(VOS_TRACE_LEVEL_INFO_MED,
11409 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011410 status = 0;
11411 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +053011412 }
11413 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
11414 {
11415 hddLog(VOS_TRACE_LEVEL_ERROR,
11416 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011417 status = -EINVAL;
11418 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011419 }
11420#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -070011421
11422 /* issue set key request to SME*/
11423 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
11424 pAdapter->sessionId, &setKey, &roamId );
11425
11426 if ( 0 != status )
11427 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011428 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
11430 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011431 status = -EINVAL;
11432 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 }
11434
11435
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011436 /* in case of IBSS as there was no information available about WEP keys during
11437 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011439 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
11440 !( ( IW_AUTH_KEY_MGMT_802_1X
11441 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -070011442 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
11443 )
11444 &&
11445 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
11446 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
11447 )
11448 )
11449 {
11450 setKey.keyDirection = eSIR_RX_ONLY;
11451 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
11452
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011453 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011455 __func__, setKey.peerMac[0], setKey.peerMac[1],
11456 setKey.peerMac[2], setKey.peerMac[3],
11457 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 setKey.keyDirection);
11459
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011460 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 pAdapter->sessionId, &setKey, &roamId );
11462
11463 if ( 0 != status )
11464 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011465 hddLog(VOS_TRACE_LEVEL_ERROR,
11466 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011467 __func__, status);
11468 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011469 status = -EINVAL;
11470 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 }
11472 }
11473 }
11474
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011475end:
11476 /* Need to clear any trace of key value in the memory.
11477 * Thus zero out the memory even though it is local
11478 * variable.
11479 */
11480 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011481 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053011482 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011483}
11484
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011485#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11486static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11487 struct net_device *ndev,
11488 u8 key_index, bool pairwise,
11489 const u8 *mac_addr,
11490 struct key_params *params
11491 )
11492#else
11493static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
11494 struct net_device *ndev,
11495 u8 key_index, const u8 *mac_addr,
11496 struct key_params *params
11497 )
11498#endif
11499{
11500 int ret;
11501 vos_ssr_protect(__func__);
11502#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11503 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
11504 mac_addr, params);
11505#else
11506 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
11507 params);
11508#endif
11509 vos_ssr_unprotect(__func__);
11510
11511 return ret;
11512}
11513
Jeff Johnson295189b2012-06-20 16:38:30 -070011514/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011515 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 * This function is used to get the key information
11517 */
11518#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011519static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011520 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011522 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 const u8 *mac_addr, void *cookie,
11524 void (*callback)(void *cookie, struct key_params*)
11525 )
11526#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011527static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011528 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 struct net_device *ndev,
11530 u8 key_index, const u8 *mac_addr, void *cookie,
11531 void (*callback)(void *cookie, struct key_params*)
11532 )
11533#endif
11534{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011536 hdd_wext_state_t *pWextState = NULL;
11537 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011539 hdd_context_t *pHddCtx;
11540 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011541
11542 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011543
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011544 if (NULL == pAdapter)
11545 {
11546 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11547 "%s: HDD adapter is Null", __func__);
11548 return -ENODEV;
11549 }
11550
11551 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11552 ret = wlan_hdd_validate_context(pHddCtx);
11553 if (0 != ret)
11554 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053011555 return ret;
11556 }
11557
11558 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11559 pRoamProfile = &(pWextState->roamProfile);
11560
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011561 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11562 __func__, hdd_device_modetoString(pAdapter->device_mode),
11563 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011564
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 memset(&params, 0, sizeof(params));
11566
11567 if (CSR_MAX_NUM_KEY <= key_index)
11568 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011572
11573 switch(pRoamProfile->EncryptionType.encryptionType[0])
11574 {
11575 case eCSR_ENCRYPT_TYPE_NONE:
11576 params.cipher = IW_AUTH_CIPHER_NONE;
11577 break;
11578
11579 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
11580 case eCSR_ENCRYPT_TYPE_WEP40:
11581 params.cipher = WLAN_CIPHER_SUITE_WEP40;
11582 break;
11583
11584 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
11585 case eCSR_ENCRYPT_TYPE_WEP104:
11586 params.cipher = WLAN_CIPHER_SUITE_WEP104;
11587 break;
11588
11589 case eCSR_ENCRYPT_TYPE_TKIP:
11590 params.cipher = WLAN_CIPHER_SUITE_TKIP;
11591 break;
11592
11593 case eCSR_ENCRYPT_TYPE_AES:
11594 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
11595 break;
11596
11597 default:
11598 params.cipher = IW_AUTH_CIPHER_NONE;
11599 break;
11600 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011601
c_hpothuaaf19692014-05-17 17:01:48 +053011602 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11603 TRACE_CODE_HDD_CFG80211_GET_KEY,
11604 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011605
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
11607 params.seq_len = 0;
11608 params.seq = NULL;
11609 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
11610 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011611 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 return 0;
11613}
11614
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011615#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11616static int wlan_hdd_cfg80211_get_key(
11617 struct wiphy *wiphy,
11618 struct net_device *ndev,
11619 u8 key_index, bool pairwise,
11620 const u8 *mac_addr, void *cookie,
11621 void (*callback)(void *cookie, struct key_params*)
11622 )
11623#else
11624static int wlan_hdd_cfg80211_get_key(
11625 struct wiphy *wiphy,
11626 struct net_device *ndev,
11627 u8 key_index, const u8 *mac_addr, void *cookie,
11628 void (*callback)(void *cookie, struct key_params*)
11629 )
11630#endif
11631{
11632 int ret;
11633
11634 vos_ssr_protect(__func__);
11635#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11636 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
11637 mac_addr, cookie, callback);
11638#else
11639 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
11640 callback);
11641#endif
11642 vos_ssr_unprotect(__func__);
11643
11644 return ret;
11645}
11646
Jeff Johnson295189b2012-06-20 16:38:30 -070011647/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011648 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011649 * This function is used to delete the key information
11650 */
11651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011652static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011653 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011654 u8 key_index,
11655 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -070011656 const u8 *mac_addr
11657 )
11658#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011659static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 struct net_device *ndev,
11661 u8 key_index,
11662 const u8 *mac_addr
11663 )
11664#endif
11665{
11666 int status = 0;
11667
11668 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011669 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 //it is observed that this is invalidating peer
11671 //key index whenever re-key is done. This is affecting data link.
11672 //It should be ok to ignore del_key.
11673#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011674 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
11675 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11677 tCsrRoamSetKey setKey;
11678 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011679
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 ENTER();
11681
11682 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
11683 __func__,pAdapter->device_mode);
11684
11685 if (CSR_MAX_NUM_KEY <= key_index)
11686 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011687 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 key_index);
11689
11690 return -EINVAL;
11691 }
11692
11693 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11694 setKey.keyId = key_index;
11695
11696 if (mac_addr)
11697 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
11698 else
11699 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
11700
11701 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
11702
11703 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011704 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011705 )
11706 {
11707
11708 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11710 if( pHostapdState->bssState == BSS_START)
11711 {
11712 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011713
Jeff Johnson295189b2012-06-20 16:38:30 -070011714 if ( status != eHAL_STATUS_SUCCESS )
11715 {
11716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11717 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
11718 __LINE__, status );
11719 }
11720 }
11721 }
11722 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011723 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 )
11725 {
11726 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11727
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011728 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
11729
11730 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011731 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011732 __func__, setKey.peerMac[0], setKey.peerMac[1],
11733 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011735 if(pAdapter->sessionCtx.station.conn_info.connState ==
11736 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011738 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011739 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011740
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 if ( 0 != status )
11742 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011743 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011744 "%s: sme_RoamSetKey failure, returned %d",
11745 __func__, status);
11746 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
11747 return -EINVAL;
11748 }
11749 }
11750 }
11751#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011752 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 return status;
11754}
11755
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053011756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11757static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11758 struct net_device *ndev,
11759 u8 key_index,
11760 bool pairwise,
11761 const u8 *mac_addr
11762 )
11763#else
11764static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
11765 struct net_device *ndev,
11766 u8 key_index,
11767 const u8 *mac_addr
11768 )
11769#endif
11770{
11771 int ret;
11772
11773 vos_ssr_protect(__func__);
11774#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11775 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
11776 mac_addr);
11777#else
11778 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
11779#endif
11780 vos_ssr_unprotect(__func__);
11781
11782 return ret;
11783}
11784
Jeff Johnson295189b2012-06-20 16:38:30 -070011785/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011786 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 * This function is used to set the default tx key index
11788 */
11789#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011790static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 struct net_device *ndev,
11792 u8 key_index,
11793 bool unicast, bool multicast)
11794#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011795static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 struct net_device *ndev,
11797 u8 key_index)
11798#endif
11799{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011801 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053011802 hdd_wext_state_t *pWextState;
11803 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011804 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011805
11806 ENTER();
11807
Gopichand Nakkala29149562013-05-10 21:43:41 +053011808 if ((NULL == pAdapter))
11809 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053011811 "invalid adapter");
11812 return -EINVAL;
11813 }
11814
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011815 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11816 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
11817 pAdapter->sessionId, key_index));
11818
Gopichand Nakkala29149562013-05-10 21:43:41 +053011819 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11820 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11821
11822 if ((NULL == pWextState) || (NULL == pHddStaCtx))
11823 {
11824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11825 "invalid Wext state or HDD context");
11826 return -EINVAL;
11827 }
11828
Arif Hussain6d2a3322013-11-17 19:50:10 -080011829 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011831
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 if (CSR_MAX_NUM_KEY <= key_index)
11833 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 key_index);
11836
11837 return -EINVAL;
11838 }
11839
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011840 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11841 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011842 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011843 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011844 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011845 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011846
Jeff Johnson295189b2012-06-20 16:38:30 -070011847 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070011848 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011849 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053011851 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080011852 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011853 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080011854 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011856 {
11857 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011859
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 tCsrRoamSetKey setKey;
11861 v_U32_t roamId= 0xFF;
11862 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011863
11864 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 Keys->defaultIndex = (u8)key_index;
11868 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
11869 setKey.keyId = key_index;
11870 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011871
11872 vos_mem_copy(&setKey.Key[0],
11873 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011874 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011875
Gopichand Nakkala29149562013-05-10 21:43:41 +053011876 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011877
11878 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 &pHddStaCtx->conn_info.bssId[0],
11880 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011881
Gopichand Nakkala29149562013-05-10 21:43:41 +053011882 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
11883 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
11884 eCSR_ENCRYPT_TYPE_WEP104)
11885 {
11886 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
11887 even though ap is configured for WEP-40 encryption. In this canse the key length
11888 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
11889 type(104) and switching encryption type to 40*/
11890 pWextState->roamProfile.EncryptionType.encryptionType[0] =
11891 eCSR_ENCRYPT_TYPE_WEP40;
11892 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
11893 eCSR_ENCRYPT_TYPE_WEP40;
11894 }
11895
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011896 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011898
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011900 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011901 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011902
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 if ( 0 != status )
11904 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011905 hddLog(VOS_TRACE_LEVEL_ERROR,
11906 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 status);
11908 return -EINVAL;
11909 }
11910 }
11911 }
11912
11913 /* In SoftAp mode setting key direction for default mode */
11914 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
11915 {
11916 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
11917 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
11918 (eCSR_ENCRYPT_TYPE_AES !=
11919 pWextState->roamProfile.EncryptionType.encryptionType[0])
11920 )
11921 {
11922 /* Saving key direction for default key index to TX default */
11923 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
11924 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
11925 }
11926 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011927 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 return status;
11929}
11930
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053011931#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11932static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11933 struct net_device *ndev,
11934 u8 key_index,
11935 bool unicast, bool multicast)
11936#else
11937static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
11938 struct net_device *ndev,
11939 u8 key_index)
11940#endif
11941{
11942 int ret;
11943 vos_ssr_protect(__func__);
11944#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11945 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
11946 multicast);
11947#else
11948 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
11949#endif
11950 vos_ssr_unprotect(__func__);
11951
11952 return ret;
11953}
11954
Jeff Johnson295189b2012-06-20 16:38:30 -070011955/*
11956 * FUNCTION: wlan_hdd_cfg80211_inform_bss
11957 * This function is used to inform the BSS details to nl80211 interface.
11958 */
11959static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
11960 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
11961{
11962 struct net_device *dev = pAdapter->dev;
11963 struct wireless_dev *wdev = dev->ieee80211_ptr;
11964 struct wiphy *wiphy = wdev->wiphy;
11965 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
11966 int chan_no;
11967 int ie_length;
11968 const char *ie;
11969 unsigned int freq;
11970 struct ieee80211_channel *chan;
11971 int rssi = 0;
11972 struct cfg80211_bss *bss = NULL;
11973
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 if( NULL == pBssDesc )
11975 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011976 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 return bss;
11978 }
11979
11980 chan_no = pBssDesc->channelId;
11981 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
11982 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
11983
11984 if( NULL == ie )
11985 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011986 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 return bss;
11988 }
11989
11990#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
11991 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
11992 {
11993 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
11994 }
11995 else
11996 {
11997 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
11998 }
11999#else
12000 freq = ieee80211_channel_to_frequency(chan_no);
12001#endif
12002
12003 chan = __ieee80211_get_channel(wiphy, freq);
12004
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053012005 if (!chan) {
12006 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
12007 return NULL;
12008 }
12009
Abhishek Singhaee43942014-06-16 18:55:47 +053012010 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070012011
Anand N Sunkad9f80b742015-07-30 20:05:51 +053012012 return cfg80211_inform_bss(wiphy, chan,
12013#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12014 CFG80211_BSS_FTYPE_UNKNOWN,
12015#endif
12016 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012017 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 pBssDesc->capabilityInfo,
12019 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053012020 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070012021}
12022
12023
12024
12025/*
12026 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
12027 * This function is used to inform the BSS details to nl80211 interface.
12028 */
12029struct cfg80211_bss*
12030wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
12031 tSirBssDescription *bss_desc
12032 )
12033{
12034 /*
12035 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
12036 already exists in bss data base of cfg80211 for that particular BSS ID.
12037 Using cfg80211_inform_bss_frame to update the bss entry instead of
12038 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
12039 now there is no possibility to get the mgmt(probe response) frame from PE,
12040 converting bss_desc to ieee80211_mgmt(probe response) and passing to
12041 cfg80211_inform_bss_frame.
12042 */
12043 struct net_device *dev = pAdapter->dev;
12044 struct wireless_dev *wdev = dev->ieee80211_ptr;
12045 struct wiphy *wiphy = wdev->wiphy;
12046 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012047#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12048 qcom_ie_age *qie_age = NULL;
12049 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
12050#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012051 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012052#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 const char *ie =
12054 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
12055 unsigned int freq;
12056 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012057 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 struct cfg80211_bss *bss_status = NULL;
12059 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
12060 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070012061 hdd_context_t *pHddCtx;
12062 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070012063#ifdef WLAN_OPEN_SOURCE
12064 struct timespec ts;
12065#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012066
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012067
Wilson Yangf80a0542013-10-07 13:02:37 -070012068 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12069 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070012070 if (0 != status)
12071 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012072 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012073 }
12074
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012075 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070012076 if (!mgmt)
12077 {
12078 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12079 "%s: memory allocation failed ", __func__);
12080 return NULL;
12081 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070012082
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012084
12085#ifdef WLAN_OPEN_SOURCE
12086 /* Android does not want the timestamp from the frame.
12087 Instead it wants a monotonic increasing value */
12088 get_monotonic_boottime(&ts);
12089 mgmt->u.probe_resp.timestamp =
12090 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
12091#else
12092 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
12094 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070012095
12096#endif
12097
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
12099 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080012100
12101#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
12102 /* GPS Requirement: need age ie per entry. Using vendor specific. */
12103 /* Assuming this is the last IE, copy at the end */
12104 ie_length -=sizeof(qcom_ie_age);
12105 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
12106 qie_age->element_id = QCOM_VENDOR_IE_ID;
12107 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
12108 qie_age->oui_1 = QCOM_OUI1;
12109 qie_age->oui_2 = QCOM_OUI2;
12110 qie_age->oui_3 = QCOM_OUI3;
12111 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
12112 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
12113#endif
12114
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053012116 if (bss_desc->fProbeRsp)
12117 {
12118 mgmt->frame_control |=
12119 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
12120 }
12121 else
12122 {
12123 mgmt->frame_control |=
12124 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
12125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012126
12127#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012128 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012129 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
12130 {
12131 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
12132 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012133 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
12135
12136 {
12137 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
12138 }
12139 else
12140 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012141 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
12142 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 kfree(mgmt);
12144 return NULL;
12145 }
12146#else
12147 freq = ieee80211_channel_to_frequency(chan_no);
12148#endif
12149 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012150 /*when the band is changed on the fly using the GUI, three things are done
12151 * 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)
12152 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
12153 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
12154 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
12155 * and discards the channels correponding to previous band and calls back with zero bss results.
12156 * 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
12157 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
12158 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
12159 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
12160 * So drop the bss and continue to next bss.
12161 */
12162 if(chan == NULL)
12163 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012164 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070012165 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080012166 return NULL;
12167 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053012168 /*To keep the rssi icon of the connected AP in the scan window
12169 *and the rssi icon of the wireless networks in sync
12170 * */
12171 if (( eConnectionState_Associated ==
12172 pAdapter->sessionCtx.station.conn_info.connState ) &&
12173 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
12174 pAdapter->sessionCtx.station.conn_info.bssId,
12175 WNI_CFG_BSSID_LEN)) &&
12176 (pHddCtx->hdd_wlan_suspended == FALSE))
12177 {
12178 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
12179 rssi = (pAdapter->rssi * 100);
12180 }
12181 else
12182 {
12183 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
12184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012185
Nirav Shah20ac06f2013-12-12 18:14:06 +053012186 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053012187 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
12188 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053012189
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
12191 frame_len, rssi, GFP_KERNEL);
12192 kfree(mgmt);
12193 return bss_status;
12194}
12195
12196/*
12197 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
12198 * This function is used to update the BSS data base of CFG8011
12199 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012200struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 tCsrRoamInfo *pRoamInfo
12202 )
12203{
12204 tCsrRoamConnectedProfile roamProfile;
12205 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12206 struct cfg80211_bss *bss = NULL;
12207
12208 ENTER();
12209
12210 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
12211 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
12212
12213 if (NULL != roamProfile.pBssDesc)
12214 {
Girish Gowlif4b68022014-08-28 23:18:57 +053012215 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12216 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012217
12218 if (NULL == bss)
12219 {
12220 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
12221 __func__);
12222 }
12223
12224 sme_RoamFreeConnectProfile(hHal, &roamProfile);
12225 }
12226 else
12227 {
12228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
12229 __func__);
12230 }
12231 return bss;
12232}
12233
12234/*
12235 * FUNCTION: wlan_hdd_cfg80211_update_bss
12236 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012237static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
12238 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012240{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012241 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 tCsrScanResultInfo *pScanResult;
12243 eHalStatus status = 0;
12244 tScanResultHandle pResult;
12245 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070012246 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012247 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012249
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012250 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12251 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
12252 NO_SESSION, pAdapter->sessionId));
12253
Wilson Yangf80a0542013-10-07 13:02:37 -070012254 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12255
12256 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070012257 {
Wilson Yangf80a0542013-10-07 13:02:37 -070012258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12259 "%s:LOGP in Progress. Ignore!!!",__func__);
12260 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 }
12262
Wilson Yangf80a0542013-10-07 13:02:37 -070012263
12264 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053012265 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070012266 {
12267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12268 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
12269 return VOS_STATUS_E_PERM;
12270 }
12271
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012272 if (pAdapter->request != NULL)
12273 {
12274 if ((pAdapter->request->n_ssids == 1)
12275 && (pAdapter->request->ssids != NULL)
12276 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
12277 is_p2p_scan = true;
12278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 /*
12280 * start getting scan results and populate cgf80211 BSS database
12281 */
12282 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
12283
12284 /* no scan results */
12285 if (NULL == pResult)
12286 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
12288 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053012289 wlan_hdd_get_frame_logs(pAdapter,
12290 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 return status;
12292 }
12293
12294 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
12295
12296 while (pScanResult)
12297 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012298 /*
12299 * cfg80211_inform_bss() is not updating ie field of bss entry, if
12300 * entry already exists in bss data base of cfg80211 for that
12301 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
12302 * bss entry instead of cfg80211_inform_bss, But this call expects
12303 * mgmt packet as input. As of now there is no possibility to get
12304 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 * ieee80211_mgmt(probe response) and passing to c
12306 * fg80211_inform_bss_frame.
12307 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012308 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
12309 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
12310 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012311 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12312 continue; //Skip the non p2p bss entries
12313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
12315 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012316
Jeff Johnson295189b2012-06-20 16:38:30 -070012317
12318 if (NULL == bss_status)
12319 {
12320 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012321 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 }
12323 else
12324 {
Yue Maf49ba872013-08-19 12:04:25 -070012325 cfg80211_put_bss(
12326#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12327 wiphy,
12328#endif
12329 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 }
12331
12332 pScanResult = sme_ScanResultGetNext(hHal, pResult);
12333 }
12334
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012335 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053012336 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012337 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012338}
12339
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012340void
12341hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
12342{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012343 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080012344 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012345} /****** end hddPrintMacAddr() ******/
12346
12347void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012348hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012349{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012350 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012351 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070012352 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
12353 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
12354 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012355} /****** end hddPrintPmkId() ******/
12356
12357//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
12358//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
12359
12360//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
12361//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
12362
12363#define dump_bssid(bssid) \
12364 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012365 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
12366 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012367 }
12368
12369#define dump_pmkid(pMac, pmkid) \
12370 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070012371 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
12372 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012373 }
12374
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070012375#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012376/*
12377 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
12378 * This function is used to notify the supplicant of a new PMKSA candidate.
12379 */
12380int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012381 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012382 int index, bool preauth )
12383{
Jeff Johnsone7245742012-09-05 17:12:55 -070012384#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012385 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012386 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012387
12388 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070012389 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012390
12391 if( NULL == pRoamInfo )
12392 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012393 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012394 return -EINVAL;
12395 }
12396
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012397 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
12398 {
12399 dump_bssid(pRoamInfo->bssid);
12400 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012401 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070012402 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012403#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012404 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012405}
12406#endif //FEATURE_WLAN_LFR
12407
Yue Maef608272013-04-08 23:09:17 -070012408#ifdef FEATURE_WLAN_LFR_METRICS
12409/*
12410 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
12411 * 802.11r/LFR metrics reporting function to report preauth initiation
12412 *
12413 */
12414#define MAX_LFR_METRICS_EVENT_LENGTH 100
12415VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
12416 tCsrRoamInfo *pRoamInfo)
12417{
12418 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12419 union iwreq_data wrqu;
12420
12421 ENTER();
12422
12423 if (NULL == pAdapter)
12424 {
12425 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12426 return VOS_STATUS_E_FAILURE;
12427 }
12428
12429 /* create the event */
12430 memset(&wrqu, 0, sizeof(wrqu));
12431 memset(metrics_notification, 0, sizeof(metrics_notification));
12432
12433 wrqu.data.pointer = metrics_notification;
12434 wrqu.data.length = scnprintf(metrics_notification,
12435 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
12436 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12437
12438 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12439
12440 EXIT();
12441
12442 return VOS_STATUS_SUCCESS;
12443}
12444
12445/*
12446 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
12447 * 802.11r/LFR metrics reporting function to report preauth completion
12448 * or failure
12449 */
12450VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
12451 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
12452{
12453 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12454 union iwreq_data wrqu;
12455
12456 ENTER();
12457
12458 if (NULL == pAdapter)
12459 {
12460 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12461 return VOS_STATUS_E_FAILURE;
12462 }
12463
12464 /* create the event */
12465 memset(&wrqu, 0, sizeof(wrqu));
12466 memset(metrics_notification, 0, sizeof(metrics_notification));
12467
12468 scnprintf(metrics_notification, sizeof(metrics_notification),
12469 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
12470 MAC_ADDR_ARRAY(pRoamInfo->bssid));
12471
12472 if (1 == preauth_status)
12473 strncat(metrics_notification, " TRUE", 5);
12474 else
12475 strncat(metrics_notification, " FALSE", 6);
12476
12477 wrqu.data.pointer = metrics_notification;
12478 wrqu.data.length = strlen(metrics_notification);
12479
12480 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12481
12482 EXIT();
12483
12484 return VOS_STATUS_SUCCESS;
12485}
12486
12487/*
12488 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
12489 * 802.11r/LFR metrics reporting function to report handover initiation
12490 *
12491 */
12492VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
12493 tCsrRoamInfo *pRoamInfo)
12494{
12495 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
12496 union iwreq_data wrqu;
12497
12498 ENTER();
12499
12500 if (NULL == pAdapter)
12501 {
12502 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
12503 return VOS_STATUS_E_FAILURE;
12504 }
12505
12506 /* create the event */
12507 memset(&wrqu, 0, sizeof(wrqu));
12508 memset(metrics_notification, 0, sizeof(metrics_notification));
12509
12510 wrqu.data.pointer = metrics_notification;
12511 wrqu.data.length = scnprintf(metrics_notification,
12512 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
12513 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
12514
12515 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
12516
12517 EXIT();
12518
12519 return VOS_STATUS_SUCCESS;
12520}
12521#endif
12522
Jeff Johnson295189b2012-06-20 16:38:30 -070012523/*
12524 * FUNCTION: hdd_cfg80211_scan_done_callback
12525 * scanning callback function, called after finishing scan
12526 *
12527 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012528static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
12530{
12531 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012532 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012534 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012535 struct cfg80211_scan_request *req = NULL;
12536 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012537 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012538 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012539 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012540 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012541
12542 ENTER();
12543
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012544 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053012545 if (NULL == pHddCtx) {
12546 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012547 goto allow_suspend;
12548 }
12549
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012550#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
12551 if (!(pAdapter->dev->flags & IFF_UP))
12552 {
12553 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down"));
12554 goto allow_suspend;
12555 }
12556#endif
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012557 pScanInfo = &pHddCtx->scan_info;
12558
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 hddLog(VOS_TRACE_LEVEL_INFO,
12560 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080012561 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 __func__, halHandle, pContext, (int) scanId, (int) status);
12563
Kiet Lamac06e2c2013-10-23 16:25:07 +053012564 pScanInfo->mScanPendingCounter = 0;
12565
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012567 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 &pScanInfo->scan_req_completion_event,
12569 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012570 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012572 hddLog(VOS_TRACE_LEVEL_ERROR,
12573 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012575 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 }
12577
Yue Maef608272013-04-08 23:09:17 -070012578 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 {
12580 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070012581 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 }
12583
12584 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012585 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 {
12587 hddLog(VOS_TRACE_LEVEL_INFO,
12588 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080012589 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 (int) scanId);
12591 }
12592
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012593 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 pAdapter);
12595
12596 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012597 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012598
12599
12600 /* If any client wait scan result through WEXT
12601 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012602 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 {
12604 /* The other scan request waiting for current scan finish
12605 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012606 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012608 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 }
12610 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012611 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 {
12613 struct net_device *dev = pAdapter->dev;
12614 union iwreq_data wrqu;
12615 int we_event;
12616 char *msg;
12617
12618 memset(&wrqu, '\0', sizeof(wrqu));
12619 we_event = SIOCGIWSCAN;
12620 msg = NULL;
12621 wireless_send_event(dev, we_event, &wrqu, msg);
12622 }
12623 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012624 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625
12626 /* Get the Scan Req */
12627 req = pAdapter->request;
mukul sharmae7041822015-12-03 15:09:21 +053012628 pAdapter->request = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012629
mukul sharmae7041822015-12-03 15:09:21 +053012630 if (!req || req->wiphy == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012632 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012633 pScanInfo->mScanPending = VOS_FALSE;
mukul sharmae7041822015-12-03 15:09:21 +053012634 complete(&pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -070012635 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 }
12637
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070012639 /* Scan is no longer pending */
12640 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012641
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012642 /* last_scan_timestamp is used to decide if new scan
12643 * is needed or not on station interface. If last station
12644 * scan time and new station scan time is less then
12645 * last_scan_timestamp ; driver will return cached scan.
12646 */
12647 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
12648 {
12649 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
12650
12651 if ( req->n_channels )
12652 {
12653 for (i = 0; i < req->n_channels ; i++ )
12654 {
12655 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
12656 }
12657 /* store no of channel scanned */
12658 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
12659 }
12660
12661 }
12662
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070012663 /*
12664 * cfg80211_scan_done informing NL80211 about completion
12665 * of scanning
12666 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012667 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
12668 {
12669 aborted = true;
12670 }
mukul sharmae7041822015-12-03 15:09:21 +053012671
Mahesh A Saptasagar11296752016-01-07 17:53:02 +053012672 cfg80211_scan_done(req, aborted);
mukul sharmae7041822015-12-03 15:09:21 +053012673
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080012674 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070012675
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053012676 if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE
12677 ) && (pHddCtx->spoofMacAddr.isEnabled
12678 || pHddCtx->spoofMacAddr.isReqDeferred)) {
Siddharth Bhal76972212014-10-15 16:22:51 +053012679 /* Generate new random mac addr for next scan */
12680 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
Padma, Santhosh Kumardb2d75b2015-11-17 12:18:10 +053012681
12682 schedule_delayed_work(&pHddCtx->spoof_mac_addr_work,
12683 msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL));
Siddharth Bhal76972212014-10-15 16:22:51 +053012684 }
12685
Jeff Johnsone7245742012-09-05 17:12:55 -070012686allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070012687 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012688 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070012689
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012690 /* Acquire wakelock to handle the case where APP's tries to suspend
12691 * immediatly after the driver gets connect request(i.e after scan)
12692 * from supplicant, this result in app's is suspending and not able
12693 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053012694 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070012695
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012696#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053012697 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070012698#endif
12699
Jeff Johnson295189b2012-06-20 16:38:30 -070012700 EXIT();
12701 return 0;
12702}
12703
12704/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053012705 * FUNCTION: hdd_isConnectionInProgress
12706 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012707 *
12708 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012709v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012710{
12711 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12712 hdd_station_ctx_t *pHddStaCtx = NULL;
12713 hdd_adapter_t *pAdapter = NULL;
12714 VOS_STATUS status = 0;
12715 v_U8_t staId = 0;
12716 v_U8_t *staMac = NULL;
12717
c_hpothu9b781ba2013-12-30 20:57:45 +053012718 if (TRUE == pHddCtx->btCoexModeSet)
12719 {
12720 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053012721 FL("BTCoex Mode operation in progress"));
12722 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053012723 }
12724
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012725 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
12726
12727 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
12728 {
12729 pAdapter = pAdapterNode->pAdapter;
12730
12731 if( pAdapter )
12732 {
12733 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012734 "%s: Adapter with device mode %s (%d) exists",
12735 __func__, hdd_device_modetoString(pAdapter->device_mode),
12736 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012737 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053012738 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12739 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
12740 (eConnectionState_Connecting ==
12741 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
12742 {
12743 hddLog(VOS_TRACE_LEVEL_ERROR,
12744 "%s: %p(%d) Connection is in progress", __func__,
12745 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12746 return VOS_TRUE;
12747 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012748 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053012749 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012750 {
12751 hddLog(VOS_TRACE_LEVEL_ERROR,
12752 "%s: %p(%d) Reassociation is in progress", __func__,
12753 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
12754 return VOS_TRUE;
12755 }
12756 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012757 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
12758 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012759 {
12760 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12761 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012762 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012763 {
12764 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
12765 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012766 "%s: client " MAC_ADDRESS_STR
12767 " is in the middle of WPS/EAPOL exchange.", __func__,
12768 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012769 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012770 }
12771 }
12772 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
12773 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
12774 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012775 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
12776 ptSapContext pSapCtx = NULL;
12777 pSapCtx = VOS_GET_SAP_CB(pVosContext);
12778 if(pSapCtx == NULL){
12779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12780 FL("psapCtx is NULL"));
12781 return VOS_FALSE;
12782 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012783 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
12784 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012785 if ((pSapCtx->aStaInfo[staId].isUsed) &&
12786 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012787 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053012788 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012789
12790 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080012791 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
12792 "middle of WPS/EAPOL exchange.", __func__,
12793 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053012794 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012795 }
12796 }
12797 }
12798 }
12799 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12800 pAdapterNode = pNext;
12801 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053012802 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012803}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012804
12805/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012806 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 * this scan respond to scan trigger and update cfg80211 scan database
12808 * later, scan dump command can be used to recieve scan results
12809 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012810int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080012811#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
12812 struct net_device *dev,
12813#endif
12814 struct cfg80211_scan_request *request)
12815{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012816 hdd_adapter_t *pAdapter = NULL;
12817 hdd_context_t *pHddCtx = NULL;
12818 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012819 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 tCsrScanRequest scanRequest;
12821 tANI_U8 *channelList = NULL, i;
12822 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012823 int status;
12824 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053012826 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053012827 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053012828 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012829 v_S7_t rssi=0;
12830 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012831
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012832#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
12833 struct net_device *dev = NULL;
12834 if (NULL == request)
12835 {
12836 hddLog(VOS_TRACE_LEVEL_ERROR,
12837 "%s: scan req param null", __func__);
12838 return -EINVAL;
12839 }
12840 dev = request->wdev->netdev;
12841#endif
12842
12843 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
12844 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
12845 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12846
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 ENTER();
12848
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012849 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
12850 __func__, hdd_device_modetoString(pAdapter->device_mode),
12851 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012852
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012853 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012854 if (0 != status)
12855 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012856 return status;
12857 }
12858
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012859 if (NULL == pwextBuf)
12860 {
12861 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
12862 __func__);
12863 return -EIO;
12864 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012865 cfg_param = pHddCtx->cfg_ini;
12866 pScanInfo = &pHddCtx->scan_info;
12867
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053012868 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12869 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
12870 {
12871 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
12872 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
12873 }
12874
Jeff Johnson295189b2012-06-20 16:38:30 -070012875#ifdef WLAN_BTAMP_FEATURE
12876 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012877 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080012879 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 "%s: No scanning when AMP is on", __func__);
12881 return -EOPNOTSUPP;
12882 }
12883#endif
12884 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012885 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012887 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012888 "%s: Not scanning on device_mode = %s (%d)",
12889 __func__, hdd_device_modetoString(pAdapter->device_mode),
12890 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 return -EOPNOTSUPP;
12892 }
12893
12894 if (TRUE == pScanInfo->mScanPending)
12895 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012896 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
12897 {
12898 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
12899 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012900 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 }
12902
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053012903 // Don't allow scan if PNO scan is going on.
12904 if (pHddCtx->isPnoEnable)
12905 {
12906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12907 FL("pno scan in progress"));
12908 return -EBUSY;
12909 }
12910
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012911 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070012912 //Channel and action frame is pending
12913 //Otherwise Cancel Remain On Channel and allow Scan
12914 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080012915 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070012916 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053012917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070012918 return -EBUSY;
12919 }
12920
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
12922 {
12923 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080012924 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
12928 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053012929 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 "%s: MAX TM Level Scan not allowed", __func__);
12931 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012932 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 }
12934 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
12935
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012936 /* Check if scan is allowed at this point of time.
12937 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053012938 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080012939 {
12940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
12941 return -EBUSY;
12942 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012943
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 vos_mem_zero( &scanRequest, sizeof(scanRequest));
12945
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012946 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
12947 * Becasue of this, driver is assuming that this is not wildcard scan and so
12948 * is not aging out the scan results.
12949 */
12950 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012952 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012954
12955 if ((request->ssids) && (0 < request->n_ssids))
12956 {
12957 tCsrSSIDInfo *SsidInfo;
12958 int j;
12959 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
12960 /* Allocate num_ssid tCsrSSIDInfo structure */
12961 SsidInfo = scanRequest.SSIDs.SSIDList =
12962 ( tCsrSSIDInfo *)vos_mem_malloc(
12963 request->n_ssids*sizeof(tCsrSSIDInfo));
12964
12965 if(NULL == scanRequest.SSIDs.SSIDList)
12966 {
12967 hddLog(VOS_TRACE_LEVEL_ERROR,
12968 "%s: memory alloc failed SSIDInfo buffer", __func__);
12969 return -ENOMEM;
12970 }
12971
12972 /* copy all the ssid's and their length */
12973 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
12974 {
12975 /* get the ssid length */
12976 SsidInfo->SSID.length = request->ssids[j].ssid_len;
12977 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
12978 SsidInfo->SSID.length);
12979 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
12980 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
12981 j, SsidInfo->SSID.ssId);
12982 }
12983 /* set the scan type to active */
12984 scanRequest.scanType = eSIR_ACTIVE_SCAN;
12985 }
12986 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053012988 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12989 TRACE_CODE_HDD_CFG80211_SCAN,
12990 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 /* set the scan type to active */
12992 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053012994 else
12995 {
12996 /*Set the scan type to default type, in this case it is ACTIVE*/
12997 scanRequest.scanType = pScanInfo->scan_mode;
12998 }
12999 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
13000 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070013001
13002 /* set BSSType to default type */
13003 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
13004
13005 /*TODO: scan the requested channels only*/
13006
13007 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013008 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013010 hddLog(VOS_TRACE_LEVEL_WARN,
13011 "No of Scan Channels exceeded limit: %d", request->n_channels);
13012 request->n_channels = MAX_CHANNEL;
13013 }
13014
13015 hddLog(VOS_TRACE_LEVEL_INFO,
13016 "No of Scan Channels: %d", request->n_channels);
13017
13018
13019 if( request->n_channels )
13020 {
13021 char chList [(request->n_channels*5)+1];
13022 int len;
13023 channelList = vos_mem_malloc( request->n_channels );
13024 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053013025 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013026 hddLog(VOS_TRACE_LEVEL_ERROR,
13027 "%s: memory alloc failed channelList", __func__);
13028 status = -ENOMEM;
13029 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053013030 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013031
13032 for( i = 0, len = 0; i < request->n_channels ; i++ )
13033 {
13034 channelList[i] = request->channels[i]->hw_value;
13035 len += snprintf(chList+len, 5, "%d ", channelList[i]);
13036 }
13037
Nirav Shah20ac06f2013-12-12 18:14:06 +053013038 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013039 "Channel-List: %s ", chList);
13040 }
c_hpothu53512302014-04-15 18:49:53 +053013041
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013042 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
13043 scanRequest.ChannelInfo.ChannelList = channelList;
13044
13045 /* set requestType to full scan */
13046 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
13047
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013048 /* if there is back to back scan happening in driver with in
13049 * nDeferScanTimeInterval interval driver should defer new scan request
13050 * and should provide last cached scan results instead of new channel list.
13051 * This rule is not applicable if scan is p2p scan.
13052 * This condition will work only in case when last request no of channels
13053 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053013054 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053013055 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013056 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013057
Sushant Kaushik86592172015-04-27 16:35:03 +053013058 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
13059 /* if wps ie is NULL , then only defer scan */
13060 if ( pWpsIe == NULL &&
13061 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053013062 {
13063 if ( pScanInfo->last_scan_timestamp !=0 &&
13064 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
13065 {
13066 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
13067 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
13068 vos_mem_compare(pScanInfo->last_scan_channelList,
13069 channelList, pScanInfo->last_scan_numChannels))
13070 {
13071 hddLog(VOS_TRACE_LEVEL_WARN,
13072 " New and old station scan time differ is less then %u",
13073 pHddCtx->cfg_ini->nDeferScanTimeInterval);
13074
13075 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013076 pAdapter);
13077
Agarwal Ashish57e84372014-12-05 18:26:53 +053013078 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013079 "Return old cached scan as all channels and no of channels are same");
13080
Agarwal Ashish57e84372014-12-05 18:26:53 +053013081 if (0 > ret)
13082 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013083
Agarwal Ashish57e84372014-12-05 18:26:53 +053013084 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053013085
13086 status = eHAL_STATUS_SUCCESS;
13087 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053013088 }
13089 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053013090 }
13091
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013092 /* Flush the scan results(only p2p beacons) for STA scan and P2P
13093 * search (Flush on both full scan and social scan but not on single
13094 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
13095 */
13096
13097 /* Supplicant does single channel scan after 8-way handshake
13098 * and in that case driver shoudnt flush scan results. If
13099 * driver flushes the scan results here and unfortunately if
13100 * the AP doesnt respond to our probe req then association
13101 * fails which is not desired
13102 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013103 if ((request->n_ssids == 1)
13104 && (request->ssids != NULL)
13105 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
13106 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013107
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053013108 if( is_p2p_scan ||
13109 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013110 {
13111 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
13112 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
13113 pAdapter->sessionId );
13114 }
13115
13116 if( request->ie_len )
13117 {
13118 /* save this for future association (join requires this) */
13119 /*TODO: Array needs to be converted to dynamic allocation,
13120 * as multiple ie.s can be sent in cfg80211_scan_request structure
13121 * CR 597966
13122 */
13123 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
13124 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
13125 pScanInfo->scanAddIE.length = request->ie_len;
13126
13127 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13128 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
13129 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013130 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013131 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013133 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
13134 memcpy( pwextBuf->roamProfile.addIEScan,
13135 request->ie, request->ie_len);
13136 }
13137 else
13138 {
13139 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
13140 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 }
13142
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013143 }
13144 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
13145 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
13146
13147 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
13148 request->ie_len);
13149 if (pP2pIe != NULL)
13150 {
13151#ifdef WLAN_FEATURE_P2P_DEBUG
13152 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
13153 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
13154 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053013155 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013156 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
13157 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13158 "Go nego completed to Connection is started");
13159 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13160 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053013161 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013162 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
13163 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013165 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
13166 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
13167 "Disconnected state to Connection is started");
13168 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
13169 "for 4way Handshake");
13170 }
13171#endif
13172
13173 /* no_cck will be set during p2p find to disable 11b rates */
13174 if(TRUE == request->no_cck)
13175 {
13176 hddLog(VOS_TRACE_LEVEL_INFO,
13177 "%s: This is a P2P Search", __func__);
13178 scanRequest.p2pSearch = 1;
13179
13180 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053013181 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013182 /* set requestType to P2P Discovery */
13183 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
13184 }
13185
13186 /*
13187 Skip Dfs Channel in case of P2P Search
13188 if it is set in ini file
13189 */
13190 if(cfg_param->skipDfsChnlInP2pSearch)
13191 {
13192 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013193 }
13194 else
13195 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053013196 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013198
Agarwal Ashish4f616132013-12-30 23:32:50 +053013199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 }
13201 }
13202
13203 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
13204
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013205#ifdef FEATURE_WLAN_TDLS
13206 /* if tdls disagree scan right now, return immediately.
13207 tdls will schedule the scan when scan is allowed. (return SUCCESS)
13208 or will reject the scan if any TDLS is in progress. (return -EBUSY)
13209 */
13210 status = wlan_hdd_tdls_scan_callback (pAdapter,
13211 wiphy,
13212#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13213 dev,
13214#endif
13215 request);
13216 if(status <= 0)
13217 {
13218 if(!status)
13219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
13220 "scan rejected %d", __func__, status);
13221 else
13222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
13223 __func__, status);
13224
13225 return status;
13226 }
13227#endif
13228
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070013229 /* acquire the wakelock to avoid the apps suspend during the scan. To
13230 * address the following issues.
13231 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
13232 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
13233 * for long time, this result in apps running at full power for long time.
13234 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
13235 * be stuck in full power because of resume BMPS
13236 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013237 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070013238
Nirav Shah20ac06f2013-12-12 18:14:06 +053013239 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
13240 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013241 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
13242 scanRequest.requestType, scanRequest.scanType,
13243 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053013244 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
13245
Hanumantha Reddy Pothulaca1d1cc2015-10-26 15:37:35 +053013246 if (pHddCtx->spoofMacAddr.isEnabled &&
13247 pHddCtx->cfg_ini->enableMacSpoofing == 1)
Siddharth Bhal76972212014-10-15 16:22:51 +053013248 {
13249 hddLog(VOS_TRACE_LEVEL_INFO,
13250 "%s: MAC Spoofing enabled for current scan", __func__);
13251 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
13252 * to fill TxBds for probe request during current scan
13253 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013254 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053013255 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013256
13257 if(status != VOS_STATUS_SUCCESS)
13258 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013259 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013260 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053013261#ifdef FEATURE_WLAN_TDLS
13262 wlan_hdd_tdls_scan_done_callback(pAdapter);
13263#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053013264 goto free_mem;
13265 }
Siddharth Bhal76972212014-10-15 16:22:51 +053013266 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053013267 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070013268 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 pAdapter->sessionId, &scanRequest, &scanId,
13270 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070013271
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 if (eHAL_STATUS_SUCCESS != status)
13273 {
13274 hddLog(VOS_TRACE_LEVEL_ERROR,
13275 "%s: sme_ScanRequest returned error %d", __func__, status);
13276 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013277 if(eHAL_STATUS_RESOURCES == status)
13278 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053013279 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
13280 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070013281 status = -EBUSY;
13282 } else {
13283 status = -EIO;
13284 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053013285 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053013286
13287#ifdef FEATURE_WLAN_TDLS
13288 wlan_hdd_tdls_scan_done_callback(pAdapter);
13289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 goto free_mem;
13291 }
13292
13293 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053013294 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 pAdapter->request = request;
13296 pScanInfo->scanId = scanId;
13297
13298 complete(&pScanInfo->scan_req_completion_event);
13299
13300free_mem:
13301 if( scanRequest.SSIDs.SSIDList )
13302 {
13303 vos_mem_free(scanRequest.SSIDs.SSIDList);
13304 }
13305
13306 if( channelList )
13307 vos_mem_free( channelList );
13308
13309 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 return status;
13311}
13312
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013313int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
13314#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13315 struct net_device *dev,
13316#endif
13317 struct cfg80211_scan_request *request)
13318{
13319 int ret;
13320
13321 vos_ssr_protect(__func__);
13322 ret = __wlan_hdd_cfg80211_scan(wiphy,
13323#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
13324 dev,
13325#endif
13326 request);
13327 vos_ssr_unprotect(__func__);
13328
13329 return ret;
13330}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013331
13332void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
13333{
13334 v_U8_t iniDot11Mode =
13335 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
13336 eHddDot11Mode hddDot11Mode = iniDot11Mode;
13337
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013338 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
13339 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013340 switch ( iniDot11Mode )
13341 {
13342 case eHDD_DOT11_MODE_AUTO:
13343 case eHDD_DOT11_MODE_11ac:
13344 case eHDD_DOT11_MODE_11ac_ONLY:
13345#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053013346 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
13347 sme_IsFeatureSupportedByFW(DOT11AC) )
13348 hddDot11Mode = eHDD_DOT11_MODE_11ac;
13349 else
13350 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013351#else
13352 hddDot11Mode = eHDD_DOT11_MODE_11n;
13353#endif
13354 break;
13355 case eHDD_DOT11_MODE_11n:
13356 case eHDD_DOT11_MODE_11n_ONLY:
13357 hddDot11Mode = eHDD_DOT11_MODE_11n;
13358 break;
13359 default:
13360 hddDot11Mode = iniDot11Mode;
13361 break;
13362 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013363#ifdef WLAN_FEATURE_AP_HT40_24G
13364 if (operationChannel > SIR_11B_CHANNEL_END)
13365#endif
13366 {
13367 /* This call decides required channel bonding mode */
13368 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013369 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
13370 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053013371 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013372}
13373
Jeff Johnson295189b2012-06-20 16:38:30 -070013374/*
13375 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013376 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013378int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013379 const u8 *ssid, size_t ssid_len, const u8 *bssid,
13380 const u8 *bssid_hint, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070013381{
13382 int status = 0;
13383 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080013384 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 v_U32_t roamId;
13386 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 eCsrAuthType RSNAuthType;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013388 const u8 *pValidBssid = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013389
13390 ENTER();
13391
13392 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080013393 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13394
13395 status = wlan_hdd_validate_context(pHddCtx);
13396 if (status)
13397 {
Yue Mae36e3552014-03-05 17:06:20 -080013398 return status;
13399 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013400
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
13402 {
13403 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
13404 return -EINVAL;
13405 }
13406
13407 pRoamProfile = &pWextState->roamProfile;
13408
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013409 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013411 hdd_station_ctx_t *pHddStaCtx;
13412 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013413
Siddharth Bhalda0d1622015-04-24 15:47:49 +053013414 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
13415
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013416 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
13418 {
13419 /*QoS not enabled in cfg file*/
13420 pRoamProfile->uapsd_mask = 0;
13421 }
13422 else
13423 {
13424 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013425 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
13427 }
13428
13429 pRoamProfile->SSIDs.numOfSSIDs = 1;
13430 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
13431 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013432 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
13434 ssid, ssid_len);
13435
13436 if (bssid)
13437 {
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013438 pValidBssid = bssid;
13439 }
13440 else if (bssid_hint)
13441 {
13442 pValidBssid = bssid_hint;
13443 }
13444 if (pValidBssid)
13445 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013447 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013449 /* Save BSSID in seperate variable as well, as RoamProfile
13450 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 case of join failure we should send valid BSSID to supplicant
13452 */
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053013453 vos_mem_copy((void *)(pWextState->req_bssId), pValidBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 WNI_CFG_BSSID_LEN);
13455 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070013456 else
13457 {
13458 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
13459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013460
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013461 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
13462 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
13464 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013465 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 /*set gen ie*/
13467 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
13468 /*set auth*/
13469 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
13470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013471#ifdef FEATURE_WLAN_WAPI
13472 if (pAdapter->wapi_info.nWapiMode)
13473 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013474 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 switch (pAdapter->wapi_info.wapiAuthMode)
13476 {
13477 case WAPI_AUTH_MODE_PSK:
13478 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013479 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 pAdapter->wapi_info.wapiAuthMode);
13481 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
13482 break;
13483 }
13484 case WAPI_AUTH_MODE_CERT:
13485 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013486 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 pAdapter->wapi_info.wapiAuthMode);
13488 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
13489 break;
13490 }
13491 } // End of switch
13492 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
13493 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
13494 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013495 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 pRoamProfile->AuthType.numEntries = 1;
13497 pRoamProfile->EncryptionType.numEntries = 1;
13498 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13499 pRoamProfile->mcEncryptionType.numEntries = 1;
13500 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
13501 }
13502 }
13503#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013504#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013505 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013506 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
13507 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
13508 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013509 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
13510 sizeof (tSirGtkOffloadParams));
13511 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013512 }
13513#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 pRoamProfile->csrPersona = pAdapter->device_mode;
13515
Jeff Johnson32d95a32012-09-10 13:15:23 -070013516 if( operatingChannel )
13517 {
13518 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
13519 pRoamProfile->ChannelInfo.numOfChannels = 1;
13520 }
Chet Lanctot186b5732013-03-18 10:26:30 -070013521 else
13522 {
13523 pRoamProfile->ChannelInfo.ChannelList = NULL;
13524 pRoamProfile->ChannelInfo.numOfChannels = 0;
13525 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013526 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
13527 {
13528 hdd_select_cbmode(pAdapter,operatingChannel);
13529 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053013530
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013531 /*
13532 * Change conn_state to connecting before sme_RoamConnect(),
13533 * because sme_RoamConnect() has a direct path to call
13534 * hdd_smeRoamCallback(), which will change the conn_state
13535 * If direct path, conn_state will be accordingly changed
13536 * to NotConnected or Associated by either
13537 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
13538 * in sme_RoamCallback()
13539 * if sme_RomConnect is to be queued,
13540 * Connecting state will remain until it is completed.
13541 * If connection state is not changed,
13542 * connection state will remain in eConnectionState_NotConnected state.
13543 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
13544 * if conn state is eConnectionState_NotConnected.
13545 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
13546 * informed of connect result indication which is an issue.
13547 */
13548
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013549 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13550 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053013551 {
13552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013553 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013554 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
13555 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053013556 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013557 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 pAdapter->sessionId, pRoamProfile, &roamId);
13559
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053013560 if ((eHAL_STATUS_SUCCESS != status) &&
13561 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
13562 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013563
13564 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053013565 hddLog(VOS_TRACE_LEVEL_ERROR,
13566 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
13567 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013568 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013569 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080013570 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053013571 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080013572
13573 pRoamProfile->ChannelInfo.ChannelList = NULL;
13574 pRoamProfile->ChannelInfo.numOfChannels = 0;
13575
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 }
13577 else
13578 {
13579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
13580 return -EINVAL;
13581 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080013582 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 return status;
13584}
13585
13586/*
13587 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
13588 * This function is used to set the authentication type (OPEN/SHARED).
13589 *
13590 */
13591static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
13592 enum nl80211_auth_type auth_type)
13593{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013594 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013595 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13596
13597 ENTER();
13598
13599 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013600 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013603 hddLog(VOS_TRACE_LEVEL_INFO,
13604 "%s: set authentication type to AUTOSWITCH", __func__);
13605 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
13606 break;
13607
13608 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070013609#ifdef WLAN_FEATURE_VOWIFI_11R
13610 case NL80211_AUTHTYPE_FT:
13611#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013612 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 "%s: set authentication type to OPEN", __func__);
13614 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13615 break;
13616
13617 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013618 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 "%s: set authentication type to SHARED", __func__);
13620 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
13621 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013622#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013624 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 "%s: set authentication type to CCKM WPA", __func__);
13626 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
13627 break;
13628#endif
13629
13630
13631 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013632 hddLog(VOS_TRACE_LEVEL_ERROR,
13633 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 auth_type);
13635 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
13636 return -EINVAL;
13637 }
13638
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013639 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 pHddStaCtx->conn_info.authType;
13641 return 0;
13642}
13643
13644/*
13645 * FUNCTION: wlan_hdd_set_akm_suite
13646 * This function is used to set the key mgmt type(PSK/8021x).
13647 *
13648 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013649static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 u32 key_mgmt
13651 )
13652{
13653 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13654 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053013655 /* Should be in ieee802_11_defs.h */
13656#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
13657#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 /*set key mgmt type*/
13659 switch(key_mgmt)
13660 {
13661 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053013662 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013663#ifdef WLAN_FEATURE_VOWIFI_11R
13664 case WLAN_AKM_SUITE_FT_PSK:
13665#endif
13666 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 __func__);
13668 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
13669 break;
13670
13671 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053013672 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053013673#ifdef WLAN_FEATURE_VOWIFI_11R
13674 case WLAN_AKM_SUITE_FT_8021X:
13675#endif
13676 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 __func__);
13678 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13679 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013680#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013681#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
13682#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
13683 case WLAN_AKM_SUITE_CCKM:
13684 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
13685 __func__);
13686 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
13687 break;
13688#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070013689#ifndef WLAN_AKM_SUITE_OSEN
13690#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
13691 case WLAN_AKM_SUITE_OSEN:
13692 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
13693 __func__);
13694 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
13695 break;
13696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013697
13698 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013699 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 __func__, key_mgmt);
13701 return -EINVAL;
13702
13703 }
13704 return 0;
13705}
13706
13707/*
13708 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013709 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 * (NONE/WEP40/WEP104/TKIP/CCMP).
13711 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013712static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
13713 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 bool ucast
13715 )
13716{
13717 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013718 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13720
13721 ENTER();
13722
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013723 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053013725 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 __func__, cipher);
13727 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13728 }
13729 else
13730 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013731
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013733 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 {
13735 case IW_AUTH_CIPHER_NONE:
13736 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13737 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013738
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013740 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013742
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053013744 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013746
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 case WLAN_CIPHER_SUITE_TKIP:
13748 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
13749 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013750
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 case WLAN_CIPHER_SUITE_CCMP:
13752 encryptionType = eCSR_ENCRYPT_TYPE_AES;
13753 break;
13754#ifdef FEATURE_WLAN_WAPI
13755 case WLAN_CIPHER_SUITE_SMS4:
13756 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
13757 break;
13758#endif
13759
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013760#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 case WLAN_CIPHER_SUITE_KRK:
13762 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
13763 break;
13764#endif
13765 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013766 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 __func__, cipher);
13768 return -EOPNOTSUPP;
13769 }
13770 }
13771
13772 if (ucast)
13773 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013774 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 __func__, encryptionType);
13776 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
13777 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013778 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 encryptionType;
13780 }
13781 else
13782 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013783 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 __func__, encryptionType);
13785 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
13786 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
13787 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
13788 }
13789
13790 return 0;
13791}
13792
13793
13794/*
13795 * FUNCTION: wlan_hdd_cfg80211_set_ie
13796 * This function is used to parse WPA/RSN IE's.
13797 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013798int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013799#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13800 const u8 *ie,
13801#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013802 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013803#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 size_t ie_len
13805 )
13806{
13807 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013808#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13809 const u8 *genie = ie;
13810#else
Jeff Johnson295189b2012-06-20 16:38:30 -070013811 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013812#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 v_U16_t remLen = ie_len;
13814#ifdef FEATURE_WLAN_WAPI
13815 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
13816 u16 *tmp;
13817 v_U16_t akmsuiteCount;
13818 int *akmlist;
13819#endif
13820 ENTER();
13821
13822 /* clear previous assocAddIE */
13823 pWextState->assocAddIE.length = 0;
13824 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013825 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013826
13827 while (remLen >= 2)
13828 {
13829 v_U16_t eLen = 0;
13830 v_U8_t elementId;
13831 elementId = *genie++;
13832 eLen = *genie++;
13833 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013834
Arif Hussain6d2a3322013-11-17 19:50:10 -080013835 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013837
13838 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013840 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013841 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 -070013842 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013843 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 "%s: Invalid WPA IE", __func__);
13845 return -EINVAL;
13846 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013847 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 {
13849 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013850 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013852
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013853 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013855 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
13856 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 VOS_ASSERT(0);
13858 return -ENOMEM;
13859 }
13860 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13861 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13862 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013863
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
13865 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13866 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13867 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013868 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
13869 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
13871 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
13872 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
13873 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
13874 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
13875 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013876 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053013877 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 {
13879 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013880 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013882
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013883 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013885 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13886 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 VOS_ASSERT(0);
13888 return -ENOMEM;
13889 }
13890 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
13891 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13892 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013893
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13895 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013897#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013898 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
13899 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 /*Consider WFD IE, only for P2P Client */
13901 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
13902 {
13903 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013904 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013906
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013907 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013909 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13910 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 VOS_ASSERT(0);
13912 return -ENOMEM;
13913 }
13914 // WFD IE is saved to Additional IE ; it should be accumulated to handle
13915 // WPS IE + P2P IE + WFD IE
13916 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13917 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013918
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13920 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13921 }
13922#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013923 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013924 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013925 HS20_OUI_TYPE_SIZE)) )
13926 {
13927 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013928 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013929 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013930
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013931 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013932 {
Jeff Johnson902c9832012-12-10 14:28:09 -080013933 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13934 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013935 VOS_ASSERT(0);
13936 return -ENOMEM;
13937 }
13938 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13939 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013940
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070013941 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13942 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13943 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013944 /* Appending OSEN Information Element in Assiciation Request */
13945 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
13946 OSEN_OUI_TYPE_SIZE)) )
13947 {
13948 v_U16_t curAddIELen = pWextState->assocAddIE.length;
13949 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
13950 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070013951
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053013952 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013953 {
13954 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
13955 "Need bigger buffer space");
13956 VOS_ASSERT(0);
13957 return -ENOMEM;
13958 }
13959 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
13960 pWextState->assocAddIE.length += eLen + 2;
13961
13962 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
13963 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
13964 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
13965 }
13966
Abhishek Singh4322e622015-06-10 15:42:54 +053013967 /* Update only for WPA IE */
13968 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
13969 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013970
13971 /* populating as ADDIE in beacon frames */
13972 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013973 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070013974 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
13975 {
13976 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
13977 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
13978 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
13979 {
13980 hddLog(LOGE,
13981 "Coldn't pass "
13982 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
13983 }
13984 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
13985 else
13986 hddLog(LOGE,
13987 "Could not pass on "
13988 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
13989
13990 /* IBSS mode doesn't contain params->proberesp_ies still
13991 beaconIE's need to be populated in probe response frames */
13992 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
13993 {
13994 u16 rem_probe_resp_ie_len = eLen + 2;
13995 u8 probe_rsp_ie_len[3] = {0};
13996 u8 counter = 0;
13997
13998 /* Check Probe Resp Length if it is greater then 255 then
13999 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
14000 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
14001 not able Store More then 255 bytes into One Variable */
14002
14003 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
14004 {
14005 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
14006 {
14007 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
14008 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
14009 }
14010 else
14011 {
14012 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
14013 rem_probe_resp_ie_len = 0;
14014 }
14015 }
14016
14017 rem_probe_resp_ie_len = 0;
14018
14019 if (probe_rsp_ie_len[0] > 0)
14020 {
14021 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14022 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
14023 (tANI_U8*)(genie - 2),
14024 probe_rsp_ie_len[0], NULL,
14025 eANI_BOOLEAN_FALSE)
14026 == eHAL_STATUS_FAILURE)
14027 {
14028 hddLog(LOGE,
14029 "Could not pass"
14030 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
14031 }
14032 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
14033 }
14034
14035 if (probe_rsp_ie_len[1] > 0)
14036 {
14037 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14038 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
14039 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14040 probe_rsp_ie_len[1], NULL,
14041 eANI_BOOLEAN_FALSE)
14042 == eHAL_STATUS_FAILURE)
14043 {
14044 hddLog(LOGE,
14045 "Could not pass"
14046 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
14047 }
14048 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
14049 }
14050
14051 if (probe_rsp_ie_len[2] > 0)
14052 {
14053 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
14054 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
14055 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
14056 probe_rsp_ie_len[2], NULL,
14057 eANI_BOOLEAN_FALSE)
14058 == eHAL_STATUS_FAILURE)
14059 {
14060 hddLog(LOGE,
14061 "Could not pass"
14062 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
14063 }
14064 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
14065 }
14066
14067 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
14068 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
14069 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
14070 {
14071 hddLog(LOGE,
14072 "Could not pass"
14073 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
14074 }
14075 }
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070014076 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 break;
14078 case DOT11F_EID_RSN:
14079 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
14080 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
14081 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
14082 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
14083 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
14084 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053014085
14086 /* Appending Extended Capabilities with Interworking bit set
14087 * in Assoc Req.
14088 *
14089 * In assoc req this EXT Cap will only be taken into account if
14090 * interworkingService bit is set to 1. Currently
14091 * driver is only interested in interworkingService capability
14092 * from supplicant. If in future any other EXT Cap info is
14093 * required from supplicat, it needs to be handled while
14094 * sending Assoc Req in LIM.
14095 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014096 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014097 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014098 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014099 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014100 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014101
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053014102 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014103 {
Jeff Johnson902c9832012-12-10 14:28:09 -080014104 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
14105 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014106 VOS_ASSERT(0);
14107 return -ENOMEM;
14108 }
14109 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
14110 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014111
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014112 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
14113 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
14114 break;
14115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014116#ifdef FEATURE_WLAN_WAPI
14117 case WLAN_EID_WAPI:
14118 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014119 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 pAdapter->wapi_info.nWapiMode);
14121 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014122 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 akmsuiteCount = WPA_GET_LE16(tmp);
14124 tmp = tmp + 1;
14125 akmlist = (int *)(tmp);
14126 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
14127 {
14128 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
14129 }
14130 else
14131 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014132 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 VOS_ASSERT(0);
14134 return -EINVAL;
14135 }
14136
14137 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
14138 {
14139 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014140 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014141 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014144 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014146 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014147 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
14148 }
14149 break;
14150#endif
14151 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014152 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070014154 /* when Unknown IE is received we should break and continue
14155 * to the next IE in the buffer instead we were returning
14156 * so changing this to break */
14157 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 }
14159 genie += eLen;
14160 remLen -= eLen;
14161 }
14162 EXIT();
14163 return 0;
14164}
14165
14166/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014167 * FUNCTION: hdd_isWPAIEPresent
14168 * Parse the received IE to find the WPA IE
14169 *
14170 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014171static bool hdd_isWPAIEPresent(
14172#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
14173 const u8 *ie,
14174#else
14175 u8 *ie,
14176#endif
14177 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053014178{
14179 v_U8_t eLen = 0;
14180 v_U16_t remLen = ie_len;
14181 v_U8_t elementId = 0;
14182
14183 while (remLen >= 2)
14184 {
14185 elementId = *ie++;
14186 eLen = *ie++;
14187 remLen -= 2;
14188 if (eLen > remLen)
14189 {
14190 hddLog(VOS_TRACE_LEVEL_ERROR,
14191 "%s: IE length is wrong %d", __func__, eLen);
14192 return FALSE;
14193 }
14194 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
14195 {
14196 /* OUI - 0x00 0X50 0XF2
14197 WPA Information Element - 0x01
14198 WPA version - 0x01*/
14199 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
14200 return TRUE;
14201 }
14202 ie += eLen;
14203 remLen -= eLen;
14204 }
14205 return FALSE;
14206}
14207
14208/*
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014210 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 * parameters during connect operation.
14212 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014213int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014215 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014216{
14217 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014218 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 ENTER();
14220
14221 /*set wpa version*/
14222 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14223
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014224 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053014226 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070014227 {
14228 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14229 }
14230 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
14231 {
14232 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14233 }
14234 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014235
14236 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 pWextState->wpaVersion);
14238
14239 /*set authentication type*/
14240 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
14241
14242 if (0 > status)
14243 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014244 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 "%s: failed to set authentication type ", __func__);
14246 return status;
14247 }
14248
14249 /*set key mgmt type*/
14250 if (req->crypto.n_akm_suites)
14251 {
14252 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
14253 if (0 > status)
14254 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014255 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 __func__);
14257 return status;
14258 }
14259 }
14260
14261 /*set pairwise cipher type*/
14262 if (req->crypto.n_ciphers_pairwise)
14263 {
14264 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
14265 req->crypto.ciphers_pairwise[0], true);
14266 if (0 > status)
14267 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014268 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 "%s: failed to set unicast cipher type", __func__);
14270 return status;
14271 }
14272 }
14273 else
14274 {
14275 /*Reset previous cipher suite to none*/
14276 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
14277 if (0 > status)
14278 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014279 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 "%s: failed to set unicast cipher type", __func__);
14281 return status;
14282 }
14283 }
14284
14285 /*set group cipher type*/
14286 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
14287 false);
14288
14289 if (0 > status)
14290 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014291 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 __func__);
14293 return status;
14294 }
14295
Chet Lanctot186b5732013-03-18 10:26:30 -070014296#ifdef WLAN_FEATURE_11W
14297 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
14298#endif
14299
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
14301 if (req->ie_len)
14302 {
14303 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
14304 if ( 0 > status)
14305 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 __func__);
14308 return status;
14309 }
14310 }
14311
14312 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014313 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 {
14315 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
14316 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
14317 )
14318 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014319 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
14321 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 __func__);
14324 return -EOPNOTSUPP;
14325 }
14326 else
14327 {
14328 u8 key_len = req->key_len;
14329 u8 key_idx = req->key_idx;
14330
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014331 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 && (CSR_MAX_NUM_KEY > key_idx)
14333 )
14334 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014335 hddLog(VOS_TRACE_LEVEL_INFO,
14336 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 __func__, key_idx, key_len);
14338 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014339 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014341 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070014342 (u8)key_len;
14343 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
14344 }
14345 }
14346 }
14347 }
14348
14349 return status;
14350}
14351
14352/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014353 * FUNCTION: wlan_hdd_try_disconnect
14354 * This function is used to disconnect from previous
14355 * connection
14356 */
14357static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
14358{
14359 long ret = 0;
14360 hdd_station_ctx_t *pHddStaCtx;
14361 eMib_dot11DesiredBssType connectedBssType;
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014362 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014363
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014364 ret = wlan_hdd_validate_context(pHddCtx);
14365 if (0 != ret)
14366 {
14367 return ret;
14368 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014369 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14370
14371 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
14372
14373 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
14374 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
Abhishek Singh630ff592016-01-07 18:15:53 +053014375 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) ||
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014376 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
14377 {
Abhishek Singh19a7dd92015-12-30 16:31:51 +053014378 spin_lock_bh(&pAdapter->lock_for_active_session);
14379 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14380 {
14381 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14382 }
14383 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singhf7962582015-10-23 10:54:06 +053014384 hdd_connSetConnectionState(pHddStaCtx,
14385 eConnectionState_Disconnecting);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014386 /* Issue disconnect to CSR */
14387 INIT_COMPLETION(pAdapter->disconnect_comp_var);
14388 if( eHAL_STATUS_SUCCESS ==
14389 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14390 pAdapter->sessionId,
14391 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
14392 {
14393 ret = wait_for_completion_interruptible_timeout(
14394 &pAdapter->disconnect_comp_var,
14395 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
14396 if (0 >= ret)
14397 {
14398 hddLog(LOGE, FL("Failed to receive disconnect event"));
14399 return -EALREADY;
14400 }
14401 }
14402 }
14403 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
14404 {
14405 ret = wait_for_completion_interruptible_timeout(
14406 &pAdapter->disconnect_comp_var,
14407 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
14408 if (0 >= ret)
14409 {
14410 hddLog(LOGE, FL("Failed to receive disconnect event"));
14411 return -EALREADY;
14412 }
14413 }
14414
14415 return 0;
14416}
14417
14418/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053014419 * FUNCTION: __wlan_hdd_cfg80211_connect
14420 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014422static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014423 struct net_device *ndev,
14424 struct cfg80211_connect_params *req
14425 )
14426{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014427 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014428 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014429 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053014430 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014431
14432 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014433
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014434 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14435 TRACE_CODE_HDD_CFG80211_CONNECT,
14436 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014437 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014438 "%s: device_mode = %s (%d)", __func__,
14439 hdd_device_modetoString(pAdapter->device_mode),
14440 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014441
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014442 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014443 if (!pHddCtx)
14444 {
14445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14446 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053014447 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080014448 }
14449
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014450 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014451 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014452 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014453 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 }
14455
Agarwal Ashish51325b52014-06-16 16:50:49 +053014456
Jeff Johnson295189b2012-06-20 16:38:30 -070014457#ifdef WLAN_BTAMP_FEATURE
14458 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014459 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014461 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080014463 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 }
14465#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014466
14467 //If Device Mode is Station Concurrent Sessions Exit BMps
14468 //P2P Mode will be taken care in Open/close adapter
14469 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053014470 (vos_concurrent_open_sessions_running())) {
14471 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
14472 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014473 }
14474
14475 /*Try disconnecting if already in connected state*/
14476 status = wlan_hdd_try_disconnect(pAdapter);
14477 if ( 0 > status)
14478 {
14479 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14480 " connection"));
14481 return -EALREADY;
14482 }
Agrawal Ashish559530c2015-12-01 18:04:20 +053014483 /* Check for max concurrent connections after doing disconnect if any*/
14484 if (vos_max_concurrent_connections_reached()) {
14485 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14486 return -ECONNREFUSED;
14487 }
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014488
Jeff Johnson295189b2012-06-20 16:38:30 -070014489 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014490 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070014491
14492 if ( 0 > status)
14493 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014494 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 __func__);
14496 return status;
14497 }
Mohit Khanna765234a2012-09-11 15:08:35 -070014498 if ( req->channel )
14499 {
14500 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
14501 req->ssid_len, req->bssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014502 req->bssid_hint,
Mohit Khanna765234a2012-09-11 15:08:35 -070014503 req->channel->hw_value);
14504 }
14505 else
14506 {
14507 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Hanumantha Reddy Pothula64081b72015-09-11 15:47:32 +053014508 req->ssid_len, req->bssid,
14509 req->bssid_hint, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070014510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014511
Sushant Kaushikd7083982015-03-18 14:33:24 +053014512 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 {
14514 //ReEnable BMPS if disabled
14515 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
14516 (NULL != pHddCtx))
14517 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053014518 if (pHddCtx->hdd_wlan_suspended)
14519 {
14520 hdd_set_pwrparams(pHddCtx);
14521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 //ReEnable Bmps and Imps back
14523 hdd_enable_bmps_imps(pHddCtx);
14524 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053014525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 return status;
14527 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014528 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 EXIT();
14530 return status;
14531}
14532
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014533static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
14534 struct net_device *ndev,
14535 struct cfg80211_connect_params *req)
14536{
14537 int ret;
14538 vos_ssr_protect(__func__);
14539 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
14540 vos_ssr_unprotect(__func__);
14541
14542 return ret;
14543}
Jeff Johnson295189b2012-06-20 16:38:30 -070014544
14545/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014546 * FUNCTION: wlan_hdd_disconnect
14547 * This function is used to issue a disconnect request to SME
14548 */
14549int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
14550{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014551 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014552 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014553 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014554 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014555
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014556 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014558 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014559 if (0 != status)
14560 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014561 return status;
14562 }
Abhishek Singh07e4a892015-11-23 11:29:57 +053014563 /* Indicate sme of disconnect so that in progress connection or preauth
14564 * can be aborted
14565 */
14566 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
Sushant Kaushikb4834d22015-07-15 15:29:05 +053014567 pAdapter->sessionId);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014568 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014569
Agarwal Ashish47d18112014-08-04 19:55:07 +053014570 /* Need to apply spin lock before decreasing active sessions
14571 * as there can be chance for double decrement if context switch
14572 * Calls hdd_DisConnectHandler.
14573 */
14574
14575 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014576 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
14577 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014578 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
14579 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053014580 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
14581 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053014582
Abhishek Singhf4669da2014-05-26 15:07:49 +053014583 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053014584 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
14585
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014586 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014587
Mihir Shete182a0b22014-08-18 16:08:48 +053014588 /*
14589 * stop tx queues before deleting STA/BSS context from the firmware.
14590 * tx has to be disabled because the firmware can get busy dropping
14591 * the tx frames after BSS/STA has been deleted and will not send
14592 * back a response resulting in WDI timeout
14593 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053014594 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053014595 netif_tx_disable(pAdapter->dev);
14596 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014597
Mihir Shete182a0b22014-08-18 16:08:48 +053014598 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014599 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
14600 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014601 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
14602 {
14603 hddLog(VOS_TRACE_LEVEL_INFO,
14604 FL("status = %d, already disconnected"),
14605 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014606
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014607 }
14608 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014609 {
14610 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014611 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014612 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014613 result = -EINVAL;
14614 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014615 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014616 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014617 &pAdapter->disconnect_comp_var,
14618 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014619 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014620 {
14621 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014622 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014623 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014624 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014625 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053014626 {
14627 hddLog(VOS_TRACE_LEVEL_ERROR,
14628 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014629 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014630 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014631disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053014632 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14633 FL("Set HDD connState to eConnectionState_NotConnected"));
14634 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
14635
Abhishek Singh087de602015-10-21 17:18:55 +053014636#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
14637 /* Sending disconnect event to userspace for kernel version < 3.11
14638 * is handled by __cfg80211_disconnect call to __cfg80211_disconnected
14639 */
14640 hddLog(LOG1, FL("Send disconnected event to userspace"));
14641 cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED,
14642 NULL, 0, GFP_KERNEL);
14643#endif
14644
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014645 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053014646 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014647}
14648
14649
14650/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014651 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070014652 * This function is used to issue a disconnect request to SME
14653 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014654static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 struct net_device *dev,
14656 u16 reason
14657 )
14658{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014659 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014660 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014661 tCsrRoamProfile *pRoamProfile;
14662 hdd_station_ctx_t *pHddStaCtx;
14663 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014664#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014665 tANI_U8 staIdx;
14666#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014667
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014669
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053014670 if (!pAdapter) {
14671 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
14672 return -EINVAL;
14673 }
14674
14675 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14676 if (!pHddStaCtx) {
14677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
14678 return -EINVAL;
14679 }
14680
14681 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14682 status = wlan_hdd_validate_context(pHddCtx);
14683 if (0 != status)
14684 {
14685 return status;
14686 }
14687
14688 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
14689
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014690 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14691 TRACE_CODE_HDD_CFG80211_DISCONNECT,
14692 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014693 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
14694 __func__, hdd_device_modetoString(pAdapter->device_mode),
14695 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014696
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014697 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
14698 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070014699
Jeff Johnson295189b2012-06-20 16:38:30 -070014700 if (NULL != pRoamProfile)
14701 {
14702 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014703 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
14704 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070014705 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014706 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014708 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 switch(reason)
14710 {
14711 case WLAN_REASON_MIC_FAILURE:
14712 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
14713 break;
14714
14715 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
14716 case WLAN_REASON_DISASSOC_AP_BUSY:
14717 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
14718 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
14719 break;
14720
14721 case WLAN_REASON_PREV_AUTH_NOT_VALID:
14722 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053014723 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070014724 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
14725 break;
14726
Jeff Johnson295189b2012-06-20 16:38:30 -070014727 default:
14728 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
14729 break;
14730 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014731 pScanInfo = &pHddCtx->scan_info;
14732 if (pScanInfo->mScanPending)
14733 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014734 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014735 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053014736 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053014737 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053014738 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053014739 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014740#ifdef FEATURE_WLAN_TDLS
14741 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014742 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014743 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014744 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
14745 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014746 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014747 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014748 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014750 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080014751 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014752 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014753 status = sme_DeleteTdlsPeerSta(
14754 WLAN_HDD_GET_HAL_CTX(pAdapter),
14755 pAdapter->sessionId,
14756 mac);
14757 if (status != eHAL_STATUS_SUCCESS) {
14758 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
14759 return -EPERM;
14760 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080014761 }
14762 }
14763#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053014764 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014765 status = wlan_hdd_disconnect(pAdapter, reasonCode);
14766 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 {
14768 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014769 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 __func__, (int)status );
14771 return -EINVAL;
14772 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053014774 else
14775 {
14776 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
14777 "called while in %d state", __func__,
14778 pHddStaCtx->conn_info.connState);
14779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014780 }
14781 else
14782 {
14783 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
14784 }
14785
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014786 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 return status;
14788}
14789
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053014790static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
14791 struct net_device *dev,
14792 u16 reason
14793 )
14794{
14795 int ret;
14796 vos_ssr_protect(__func__);
14797 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
14798 vos_ssr_unprotect(__func__);
14799
14800 return ret;
14801}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053014802
Jeff Johnson295189b2012-06-20 16:38:30 -070014803/*
14804 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014805 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 * settings in IBSS mode.
14807 */
14808static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014809 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070014810 struct cfg80211_ibss_params *params
14811 )
14812{
14813 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014814 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
14816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014817
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 ENTER();
14819
14820 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070014821 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070014822
14823 if (params->ie_len && ( NULL != params->ie) )
14824 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014825 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14826 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 {
14828 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
14829 encryptionType = eCSR_ENCRYPT_TYPE_AES;
14830 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014831 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014833 tDot11fIEWPA dot11WPAIE;
14834 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014835 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014836
Wilson Yang00256342013-10-10 23:13:38 -070014837 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014838 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
14839 params->ie_len, DOT11F_EID_WPA);
14840 if ( NULL != ie )
14841 {
14842 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
14843 // Unpack the WPA IE
14844 //Skip past the EID byte and length byte - and four byte WiFi OUI
14845 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
14846 &ie[2+4],
14847 ie[1] - 4,
14848 &dot11WPAIE);
14849 /*Extract the multicast cipher, the encType for unicast
14850 cipher for wpa-none is none*/
14851 encryptionType =
14852 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
14853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070014855
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
14857
14858 if (0 > status)
14859 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 __func__);
14862 return status;
14863 }
14864 }
14865
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014866 pWextState->roamProfile.AuthType.authType[0] =
14867 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 eCSR_AUTH_TYPE_OPEN_SYSTEM;
14869
14870 if (params->privacy)
14871 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014872 /* Security enabled IBSS, At this time there is no information available
14873 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014875 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070014876 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014877 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 *enable privacy bit in beacons */
14879
14880 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
14881 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070014882 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
14883 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014884 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
14885 pWextState->roamProfile.EncryptionType.numEntries = 1;
14886 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014887 return status;
14888}
14889
14890/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014891 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014892 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014894static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 struct net_device *dev,
14896 struct cfg80211_ibss_params *params
14897 )
14898{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014899 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
14901 tCsrRoamProfile *pRoamProfile;
14902 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014903 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14904 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014905 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070014906
14907 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014908
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014909 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14910 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
14911 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014912 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053014913 "%s: device_mode = %s (%d)", __func__,
14914 hdd_device_modetoString(pAdapter->device_mode),
14915 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070014916
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014917 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014918 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014920 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014921 }
14922
14923 if (NULL == pWextState)
14924 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014925 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 __func__);
14927 return -EIO;
14928 }
14929
Agarwal Ashish51325b52014-06-16 16:50:49 +053014930 if (vos_max_concurrent_connections_reached()) {
14931 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14932 return -ECONNREFUSED;
14933 }
14934
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053014935 /*Try disconnecting if already in connected state*/
14936 status = wlan_hdd_try_disconnect(pAdapter);
14937 if ( 0 > status)
14938 {
14939 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
14940 " IBSS connection"));
14941 return -EALREADY;
14942 }
14943
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 pRoamProfile = &pWextState->roamProfile;
14945
14946 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
14947 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014948 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014949 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 return -EINVAL;
14951 }
14952
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014953 /* BSSID is provided by upper layers hence no need to AUTO generate */
14954 if (NULL != params->bssid) {
14955 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
14956 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
14957 hddLog (VOS_TRACE_LEVEL_ERROR,
14958 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
14959 return -EIO;
14960 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014961 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014962 }
krunal sonie9002db2013-11-25 14:24:17 -080014963 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
14964 {
14965 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
14966 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
14967 {
14968 hddLog (VOS_TRACE_LEVEL_ERROR,
14969 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
14970 return -EIO;
14971 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014972
14973 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080014974 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014975 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080014976 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070014977
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070014979 if (NULL !=
14980#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
14981 params->chandef.chan)
14982#else
14983 params->channel)
14984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 {
14986 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070014987 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14988 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
14989 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14990 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014991
14992 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014993 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070014994 ieee80211_frequency_to_channel(
14995#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
14996 params->chandef.chan->center_freq);
14997#else
14998 params->channel->center_freq);
14999#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015000
15001 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
15002 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015004 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
15005 __func__);
15006 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015008
15009 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015011 if (channelNum == validChan[indx])
15012 {
15013 break;
15014 }
15015 }
15016 if (indx >= numChans)
15017 {
15018 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 __func__, channelNum);
15020 return -EINVAL;
15021 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015022 /* Set the Operational Channel */
15023 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
15024 channelNum);
15025 pRoamProfile->ChannelInfo.numOfChannels = 1;
15026 pHddStaCtx->conn_info.operationChannel = channelNum;
15027 pRoamProfile->ChannelInfo.ChannelList =
15028 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 }
15030
15031 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015032 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070015033 if (status < 0)
15034 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015035 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070015036 __func__);
15037 return status;
15038 }
15039
15040 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015041 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Abhishek Singh4d924682015-11-17 15:23:06 +053015042 params->ssid_len, (const u8 *)&bssid, NULL,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070015043 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070015044
15045 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070015046 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015047
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015048 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015049 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015050}
15051
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015052static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
15053 struct net_device *dev,
15054 struct cfg80211_ibss_params *params
15055 )
15056{
15057 int ret = 0;
15058
15059 vos_ssr_protect(__func__);
15060 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
15061 vos_ssr_unprotect(__func__);
15062
15063 return ret;
15064}
15065
Jeff Johnson295189b2012-06-20 16:38:30 -070015066/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015067 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015068 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070015069 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015070static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 struct net_device *dev
15072 )
15073{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015074 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015075 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
15076 tCsrRoamProfile *pRoamProfile;
15077 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015078 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015079
15080 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015081
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015082 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15083 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
15084 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015085 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015086 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015087 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015088 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015089 }
15090
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015091 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
15092 hdd_device_modetoString(pAdapter->device_mode),
15093 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070015094 if (NULL == pWextState)
15095 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015096 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 __func__);
15098 return -EIO;
15099 }
15100
15101 pRoamProfile = &pWextState->roamProfile;
15102
15103 /* Issue disconnect only if interface type is set to IBSS */
15104 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
15105 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015106 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070015107 __func__);
15108 return -EINVAL;
15109 }
15110
15111 /* Issue Disconnect request */
15112 INIT_COMPLETION(pAdapter->disconnect_comp_var);
15113 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
15114 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
15115
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015116 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015117 return 0;
15118}
15119
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015120static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
15121 struct net_device *dev
15122 )
15123{
15124 int ret = 0;
15125
15126 vos_ssr_protect(__func__);
15127 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
15128 vos_ssr_unprotect(__func__);
15129
15130 return ret;
15131}
15132
Jeff Johnson295189b2012-06-20 16:38:30 -070015133/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015134 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 * This function is used to set the phy parameters
15136 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
15137 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015138static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 u32 changed)
15140{
15141 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15142 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015143 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015144
15145 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015146
15147 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015148 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
15149 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015150
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015151 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015152 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015153 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015154 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015155 }
15156
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
15158 {
15159 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
15160 WNI_CFG_RTS_THRESHOLD_STAMAX :
15161 wiphy->rts_threshold;
15162
15163 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015164 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015166 hddLog(VOS_TRACE_LEVEL_ERROR,
15167 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015168 __func__, rts_threshold);
15169 return -EINVAL;
15170 }
15171
15172 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
15173 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015174 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015176 hddLog(VOS_TRACE_LEVEL_ERROR,
15177 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 __func__, rts_threshold);
15179 return -EIO;
15180 }
15181
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015182 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 rts_threshold);
15184 }
15185
15186 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
15187 {
15188 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
15189 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
15190 wiphy->frag_threshold;
15191
15192 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015193 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015195 hddLog(VOS_TRACE_LEVEL_ERROR,
15196 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 frag_threshold);
15198 return -EINVAL;
15199 }
15200
15201 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
15202 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015203 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015205 hddLog(VOS_TRACE_LEVEL_ERROR,
15206 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 __func__, frag_threshold);
15208 return -EIO;
15209 }
15210
15211 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
15212 frag_threshold);
15213 }
15214
15215 if ((changed & WIPHY_PARAM_RETRY_SHORT)
15216 || (changed & WIPHY_PARAM_RETRY_LONG))
15217 {
15218 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
15219 wiphy->retry_short :
15220 wiphy->retry_long;
15221
15222 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
15223 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
15224 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 __func__, retry_value);
15227 return -EINVAL;
15228 }
15229
15230 if (changed & WIPHY_PARAM_RETRY_SHORT)
15231 {
15232 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
15233 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015234 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015236 hddLog(VOS_TRACE_LEVEL_ERROR,
15237 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 __func__, retry_value);
15239 return -EIO;
15240 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015241 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 __func__, retry_value);
15243 }
15244 else if (changed & WIPHY_PARAM_RETRY_SHORT)
15245 {
15246 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
15247 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015248 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015249 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015250 hddLog(VOS_TRACE_LEVEL_ERROR,
15251 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 __func__, retry_value);
15253 return -EIO;
15254 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015255 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 __func__, retry_value);
15257 }
15258 }
15259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015260 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015261 return 0;
15262}
15263
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015264static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
15265 u32 changed)
15266{
15267 int ret;
15268
15269 vos_ssr_protect(__func__);
15270 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
15271 vos_ssr_unprotect(__func__);
15272
15273 return ret;
15274}
15275
Jeff Johnson295189b2012-06-20 16:38:30 -070015276/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015277 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 * This function is used to set the txpower
15279 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015280static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015281#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15282 struct wireless_dev *wdev,
15283#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015284#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015285 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015286#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015287 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070015288#endif
15289 int dbm)
15290{
15291 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015292 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
15294 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015295 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015296
15297 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015298
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015299 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15300 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
15301 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015302 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015303 if (0 != status)
15304 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015305 return status;
15306 }
15307
15308 hHal = pHddCtx->hHal;
15309
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015310 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
15311 dbm, ccmCfgSetCallback,
15312 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015314 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
15316 return -EIO;
15317 }
15318
15319 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
15320 dbm);
15321
15322 switch(type)
15323 {
15324 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
15325 /* Fall through */
15326 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
15327 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
15328 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015329 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
15330 __func__);
15331 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 }
15333 break;
15334 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015335 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 __func__);
15337 return -EOPNOTSUPP;
15338 break;
15339 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015340 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
15341 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070015342 return -EIO;
15343 }
15344
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015345 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 return 0;
15347}
15348
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053015349static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
15350#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15351 struct wireless_dev *wdev,
15352#endif
15353#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15354 enum tx_power_setting type,
15355#else
15356 enum nl80211_tx_power_setting type,
15357#endif
15358 int dbm)
15359{
15360 int ret;
15361 vos_ssr_protect(__func__);
15362 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
15363#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15364 wdev,
15365#endif
15366#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
15367 type,
15368#else
15369 type,
15370#endif
15371 dbm);
15372 vos_ssr_unprotect(__func__);
15373
15374 return ret;
15375}
15376
Jeff Johnson295189b2012-06-20 16:38:30 -070015377/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015378 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 * This function is used to read the txpower
15380 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015381static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070015382#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15383 struct wireless_dev *wdev,
15384#endif
15385 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070015386{
15387
15388 hdd_adapter_t *pAdapter;
15389 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015390 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015391
Jeff Johnsone7245742012-09-05 17:12:55 -070015392 ENTER();
15393
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015394 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015395 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015396 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015397 *dbm = 0;
15398 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015399 }
15400
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
15402 if (NULL == pAdapter)
15403 {
15404 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
15405 return -ENOENT;
15406 }
15407
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015408 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15409 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
15410 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 wlan_hdd_get_classAstats(pAdapter);
15412 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
15413
Jeff Johnsone7245742012-09-05 17:12:55 -070015414 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015415 return 0;
15416}
15417
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015418static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
15419#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15420 struct wireless_dev *wdev,
15421#endif
15422 int *dbm)
15423{
15424 int ret;
15425
15426 vos_ssr_protect(__func__);
15427 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
15428#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
15429 wdev,
15430#endif
15431 dbm);
15432 vos_ssr_unprotect(__func__);
15433
15434 return ret;
15435}
15436
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015437static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015438#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15439 const u8* mac,
15440#else
15441 u8* mac,
15442#endif
15443 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070015444{
15445 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
15446 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15447 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053015448 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015449
15450 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
15451 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070015452
15453 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
15454 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
15455 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
15456 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
15457 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
15458 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
15459 tANI_U16 maxRate = 0;
15460 tANI_U16 myRate;
15461 tANI_U16 currentRate = 0;
15462 tANI_U8 maxSpeedMCS = 0;
15463 tANI_U8 maxMCSIdx = 0;
15464 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053015465 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070015466 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015467 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015468
Leo Chang6f8870f2013-03-26 18:11:36 -070015469#ifdef WLAN_FEATURE_11AC
15470 tANI_U32 vht_mcs_map;
15471 eDataRate11ACMaxMcs vhtMaxMcs;
15472#endif /* WLAN_FEATURE_11AC */
15473
Jeff Johnsone7245742012-09-05 17:12:55 -070015474 ENTER();
15475
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15477 (0 == ssidlen))
15478 {
15479 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
15480 " Invalid ssidlen, %d", __func__, ssidlen);
15481 /*To keep GUI happy*/
15482 return 0;
15483 }
15484
Mukul Sharma811205f2014-07-09 21:07:30 +053015485 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
15486 {
15487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15488 "%s: Roaming in progress, so unable to proceed this request", __func__);
15489 return 0;
15490 }
15491
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015492 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015493 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015494 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015495 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015496 }
15497
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053015498 wlan_hdd_get_station_stats(pAdapter);
15499 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070015500
Kiet Lam3b17fc82013-09-27 05:24:08 +053015501 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
15502 sinfo->filled |= STATION_INFO_SIGNAL;
15503
c_hpothu09f19542014-05-30 21:53:31 +053015504 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053015505 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
15506 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053015507 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053015508 {
15509 rate_flags = pAdapter->maxRateFlags;
15510 }
c_hpothu44ff4e02014-05-08 00:13:57 +053015511
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 //convert to the UI units of 100kbps
15513 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
15514
15515#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070015516 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 -070015517 sinfo->signal,
15518 pCfg->reportMaxLinkSpeed,
15519 myRate,
15520 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015521 (int) pCfg->linkSpeedRssiMid,
15522 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070015523 (int) rate_flags,
15524 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070015525#endif //LINKSPEED_DEBUG_ENABLED
15526
15527 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
15528 {
15529 // we do not want to necessarily report the current speed
15530 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
15531 {
15532 // report the max possible speed
15533 rssidx = 0;
15534 }
15535 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
15536 {
15537 // report the max possible speed with RSSI scaling
15538 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
15539 {
15540 // report the max possible speed
15541 rssidx = 0;
15542 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015543 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 {
15545 // report middle speed
15546 rssidx = 1;
15547 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015548 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
15549 {
15550 // report middle speed
15551 rssidx = 2;
15552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 else
15554 {
15555 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070015556 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 }
15558 }
15559 else
15560 {
15561 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
15562 hddLog(VOS_TRACE_LEVEL_ERROR,
15563 "%s: Invalid value for reportMaxLinkSpeed: %u",
15564 __func__, pCfg->reportMaxLinkSpeed);
15565 rssidx = 0;
15566 }
15567
15568 maxRate = 0;
15569
15570 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015571 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
15572 OperationalRates, &ORLeng))
15573 {
15574 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15575 /*To keep GUI happy*/
15576 return 0;
15577 }
15578
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 for (i = 0; i < ORLeng; i++)
15580 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015581 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 {
15583 /* Validate Rate Set */
15584 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
15585 {
15586 currentRate = supported_data_rate[j].supported_rate[rssidx];
15587 break;
15588 }
15589 }
15590 /* Update MAX rate */
15591 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15592 }
15593
15594 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015595 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
15596 ExtendedRates, &ERLeng))
15597 {
15598 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15599 /*To keep GUI happy*/
15600 return 0;
15601 }
15602
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 for (i = 0; i < ERLeng; i++)
15604 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015605 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 {
15607 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
15608 {
15609 currentRate = supported_data_rate[j].supported_rate[rssidx];
15610 break;
15611 }
15612 }
15613 /* Update MAX rate */
15614 maxRate = (currentRate > maxRate)?currentRate:maxRate;
15615 }
c_hpothu79aab322014-07-14 21:11:01 +053015616
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015617 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053015618 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053015619 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053015620 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 {
c_hpothu79aab322014-07-14 21:11:01 +053015622 if (rate_flags & eHAL_TX_RATE_VHT80)
15623 mode = 2;
15624 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
15625 mode = 1;
15626 else
15627 mode = 0;
15628
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053015629 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
15630 MCSRates, &MCSLeng))
15631 {
15632 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
15633 /*To keep GUI happy*/
15634 return 0;
15635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015636 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070015637#ifdef WLAN_FEATURE_11AC
15638 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015639 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015641 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015642 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070015643 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015645 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015646 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015647 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015649 maxMCSIdx = 7;
15650 }
15651 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
15652 {
15653 maxMCSIdx = 8;
15654 }
15655 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
15656 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015657 //VHT20 is supporting 0~8
15658 if (rate_flags & eHAL_TX_RATE_VHT20)
15659 maxMCSIdx = 8;
15660 else
15661 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070015662 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015663
c_hpothu79aab322014-07-14 21:11:01 +053015664 if (0 != rssidx)/*check for scaled */
15665 {
15666 //get middle rate MCS index if rssi=1/2
15667 for (i=0; i <= maxMCSIdx; i++)
15668 {
15669 if (sinfo->signal <= rssiMcsTbl[mode][i])
15670 {
15671 maxMCSIdx = i;
15672 break;
15673 }
15674 }
15675 }
15676
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015677 if (rate_flags & eHAL_TX_RATE_VHT80)
15678 {
15679 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
15680 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
15681 }
15682 else if (rate_flags & eHAL_TX_RATE_VHT40)
15683 {
15684 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
15685 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
15686 }
15687 else if (rate_flags & eHAL_TX_RATE_VHT20)
15688 {
15689 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
15690 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
15691 }
15692
Leo Chang6f8870f2013-03-26 18:11:36 -070015693 maxSpeedMCS = 1;
15694 if (currentRate > maxRate)
15695 {
15696 maxRate = currentRate;
15697 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015698
Leo Chang6f8870f2013-03-26 18:11:36 -070015699 }
15700 else
15701#endif /* WLAN_FEATURE_11AC */
15702 {
15703 if (rate_flags & eHAL_TX_RATE_HT40)
15704 {
15705 rateFlag |= 1;
15706 }
15707 if (rate_flags & eHAL_TX_RATE_SGI)
15708 {
15709 rateFlag |= 2;
15710 }
15711
Girish Gowli01abcee2014-07-31 20:18:55 +053015712 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053015713 if (rssidx == 1 || rssidx == 2)
15714 {
15715 //get middle rate MCS index if rssi=1/2
15716 for (i=0; i <= 7; i++)
15717 {
15718 if (sinfo->signal <= rssiMcsTbl[mode][i])
15719 {
15720 temp = i+1;
15721 break;
15722 }
15723 }
15724 }
c_hpothu79aab322014-07-14 21:11:01 +053015725
15726 for (i = 0; i < MCSLeng; i++)
15727 {
Leo Chang6f8870f2013-03-26 18:11:36 -070015728 for (j = 0; j < temp; j++)
15729 {
15730 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
15731 {
15732 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015733 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015734 break;
15735 }
15736 }
15737 if ((j < temp) && (currentRate > maxRate))
15738 {
15739 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070015740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053015742 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070015743 }
15744 }
15745
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015746 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
15747 {
15748 maxRate = myRate;
15749 maxSpeedMCS = 1;
15750 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015752 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053015753 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 {
15755 maxRate = myRate;
15756 if (rate_flags & eHAL_TX_RATE_LEGACY)
15757 {
15758 maxSpeedMCS = 0;
15759 }
15760 else
15761 {
15762 maxSpeedMCS = 1;
15763 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
15764 }
15765 }
15766
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015767 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070015768 {
15769 sinfo->txrate.legacy = maxRate;
15770#ifdef LINKSPEED_DEBUG_ENABLED
15771 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
15772#endif //LINKSPEED_DEBUG_ENABLED
15773 }
15774 else
15775 {
15776 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070015777#ifdef WLAN_FEATURE_11AC
15778 sinfo->txrate.nss = 1;
15779 if (rate_flags & eHAL_TX_RATE_VHT80)
15780 {
15781 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015782 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070015783 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015784 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070015785 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015786 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15787 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15788 }
15789 else if (rate_flags & eHAL_TX_RATE_VHT20)
15790 {
15791 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15792 }
15793#endif /* WLAN_FEATURE_11AC */
15794 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
15795 {
15796 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15797 if (rate_flags & eHAL_TX_RATE_HT40)
15798 {
15799 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15800 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015802 if (rate_flags & eHAL_TX_RATE_SGI)
15803 {
15804 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
15805 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053015806
Jeff Johnson295189b2012-06-20 16:38:30 -070015807#ifdef LINKSPEED_DEBUG_ENABLED
15808 pr_info("Reporting MCS rate %d flags %x\n",
15809 sinfo->txrate.mcs,
15810 sinfo->txrate.flags );
15811#endif //LINKSPEED_DEBUG_ENABLED
15812 }
15813 }
15814 else
15815 {
15816 // report current rate instead of max rate
15817
15818 if (rate_flags & eHAL_TX_RATE_LEGACY)
15819 {
15820 //provide to the UI in units of 100kbps
15821 sinfo->txrate.legacy = myRate;
15822#ifdef LINKSPEED_DEBUG_ENABLED
15823 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
15824#endif //LINKSPEED_DEBUG_ENABLED
15825 }
15826 else
15827 {
15828 //must be MCS
15829 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070015830#ifdef WLAN_FEATURE_11AC
15831 sinfo->txrate.nss = 1;
15832 if (rate_flags & eHAL_TX_RATE_VHT80)
15833 {
15834 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
15835 }
15836 else
15837#endif /* WLAN_FEATURE_11AC */
15838 {
15839 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
15840 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 if (rate_flags & eHAL_TX_RATE_SGI)
15842 {
15843 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
15844 }
15845 if (rate_flags & eHAL_TX_RATE_HT40)
15846 {
15847 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
15848 }
Leo Chang6f8870f2013-03-26 18:11:36 -070015849#ifdef WLAN_FEATURE_11AC
15850 else if (rate_flags & eHAL_TX_RATE_VHT80)
15851 {
15852 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
15853 }
15854#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070015855#ifdef LINKSPEED_DEBUG_ENABLED
15856 pr_info("Reporting actual MCS rate %d flags %x\n",
15857 sinfo->txrate.mcs,
15858 sinfo->txrate.flags );
15859#endif //LINKSPEED_DEBUG_ENABLED
15860 }
15861 }
15862 sinfo->filled |= STATION_INFO_TX_BITRATE;
15863
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070015864 sinfo->tx_packets =
15865 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
15866 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
15867 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
15868 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
15869
15870 sinfo->tx_retries =
15871 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
15872 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
15873 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
15874 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
15875
15876 sinfo->tx_failed =
15877 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
15878 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
15879 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
15880 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
15881
15882 sinfo->filled |=
15883 STATION_INFO_TX_PACKETS |
15884 STATION_INFO_TX_RETRIES |
15885 STATION_INFO_TX_FAILED;
15886
Edhar, Mahesh Kumar3cc9f232015-12-29 14:41:01 +053015887 sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt;
15888 sinfo->filled |= STATION_INFO_RX_PACKETS;
15889
15890 if (rate_flags & eHAL_TX_RATE_LEGACY)
15891 hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"),
15892 sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets,
15893 sinfo->rx_packets);
15894 else
15895 hddLog(LOG1,
15896 FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"),
15897 sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags,
15898 sinfo->tx_packets, sinfo->rx_packets);
15899
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015900 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15901 TRACE_CODE_HDD_CFG80211_GET_STA,
15902 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070015903 EXIT();
15904 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015905}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015906#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15907static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
15908 const u8* mac, struct station_info *sinfo)
15909#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015910static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
15911 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053015912#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015913{
15914 int ret;
15915
15916 vos_ssr_protect(__func__);
15917 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
15918 vos_ssr_unprotect(__func__);
15919
15920 return ret;
15921}
15922
15923static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070015924 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070015925{
15926 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015927 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070015928 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015929 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015930
Jeff Johnsone7245742012-09-05 17:12:55 -070015931 ENTER();
15932
Jeff Johnson295189b2012-06-20 16:38:30 -070015933 if (NULL == pAdapter)
15934 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080015935 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015936 return -ENODEV;
15937 }
15938
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015939 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15940 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
15941 pAdapter->sessionId, timeout));
15942
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015943 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015944 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015945 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015946 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015947 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015948 }
15949
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015950 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
15951 (TRUE == pHddCtx->hdd_wlan_suspended) &&
15952 (pHddCtx->cfg_ini->fhostArpOffload) &&
15953 (eConnectionState_Associated ==
15954 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
15955 {
Amar Singhald53568e2013-09-26 11:03:45 -070015956
15957 hddLog(VOS_TRACE_LEVEL_INFO,
15958 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053015959 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015960 if (!VOS_IS_STATUS_SUCCESS(vos_status))
15961 {
15962 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015963 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053015964 __func__, vos_status);
15965 }
15966 }
15967
Jeff Johnson295189b2012-06-20 16:38:30 -070015968 /**The get power cmd from the supplicant gets updated by the nl only
15969 *on successful execution of the function call
15970 *we are oppositely mapped w.r.t mode in the driver
15971 **/
15972 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
15973
15974 if (VOS_STATUS_E_FAILURE == vos_status)
15975 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015976 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15977 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 return -EINVAL;
15979 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015980 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070015981 return 0;
15982}
15983
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015984static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
15985 struct net_device *dev, bool mode, int timeout)
15986{
15987 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070015988
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015989 vos_ssr_protect(__func__);
15990 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
15991 vos_ssr_unprotect(__func__);
15992
15993 return ret;
15994}
Sushant Kaushik084f6592015-09-10 13:11:56 +053015995
Jeff Johnson295189b2012-06-20 16:38:30 -070015996#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015997static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
15998 struct net_device *netdev,
15999 u8 key_index)
16000{
16001 ENTER();
16002 return 0;
16003}
16004
Jeff Johnson295189b2012-06-20 16:38:30 -070016005static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016006 struct net_device *netdev,
16007 u8 key_index)
16008{
16009 int ret;
16010 vos_ssr_protect(__func__);
16011 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
16012 vos_ssr_unprotect(__func__);
16013 return ret;
16014}
16015#endif //LINUX_VERSION_CODE
16016
16017#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16018static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16019 struct net_device *dev,
16020 struct ieee80211_txq_params *params)
16021{
16022 ENTER();
16023 return 0;
16024}
16025#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16026static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
16027 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016028{
Jeff Johnsone7245742012-09-05 17:12:55 -070016029 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070016030 return 0;
16031}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016032#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070016033
16034#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
16035static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016036 struct net_device *dev,
16037 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070016038{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016039 int ret;
16040
16041 vos_ssr_protect(__func__);
16042 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
16043 vos_ssr_unprotect(__func__);
16044 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016045}
16046#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16047static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
16048 struct ieee80211_txq_params *params)
16049{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016050 int ret;
16051
16052 vos_ssr_protect(__func__);
16053 ret = __wlan_hdd_set_txq_params(wiphy, params);
16054 vos_ssr_unprotect(__func__);
16055 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070016056}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016057#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016058
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016059static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016060 struct net_device *dev,
16061 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070016062{
16063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016064 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016065 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016066 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016067 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016068 v_CONTEXT_t pVosContext = NULL;
16069 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016070
Jeff Johnsone7245742012-09-05 17:12:55 -070016071 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016072
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016073 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070016074 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016075 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016076 return -EINVAL;
16077 }
16078
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016079 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16080 TRACE_CODE_HDD_CFG80211_DEL_STA,
16081 pAdapter->sessionId, pAdapter->device_mode));
16082
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016083 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16084 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016085 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016086 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016087 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016088 }
16089
Jeff Johnson295189b2012-06-20 16:38:30 -070016090 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070016092 )
16093 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016094 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
16095 pSapCtx = VOS_GET_SAP_CB(pVosContext);
16096 if(pSapCtx == NULL){
16097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16098 FL("psapCtx is NULL"));
16099 return -ENOENT;
16100 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016101 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070016102 {
16103 v_U16_t i;
16104 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
16105 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016106 if ((pSapCtx->aStaInfo[i].isUsed) &&
16107 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070016108 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016109 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016110 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016111 ETHER_ADDR_LEN);
16112
Jeff Johnson295189b2012-06-20 16:38:30 -070016113 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016114 "%s: Delete STA with MAC::"
16115 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016116 __func__,
16117 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
16118 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070016119 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016120 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016121 }
16122 }
16123 }
16124 else
16125 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016126
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016127 vos_status = hdd_softap_GetStaId(pAdapter,
16128 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016129 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16130 {
16131 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016132 "%s: Skip this DEL STA as this is not used::"
16133 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016134 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016135 return -ENOENT;
16136 }
16137
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016138 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016139 {
16140 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080016141 "%s: Skip this DEL STA as deauth is in progress::"
16142 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016143 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016144 return -ENOENT;
16145 }
16146
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016147 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016148
Jeff Johnson295189b2012-06-20 16:38:30 -070016149 hddLog(VOS_TRACE_LEVEL_INFO,
16150 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016151 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070016152 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016153 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016154
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016155 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016156 if (!VOS_IS_STATUS_SUCCESS(vos_status))
16157 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053016158 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016159 hddLog(VOS_TRACE_LEVEL_INFO,
16160 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080016161 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016162 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016163 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080016164 return -ENOENT;
16165 }
16166
Jeff Johnson295189b2012-06-20 16:38:30 -070016167 }
16168 }
16169
16170 EXIT();
16171
16172 return 0;
16173}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016174
16175#ifdef CFG80211_DEL_STA_V2
16176static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16177 struct net_device *dev,
16178 struct station_del_parameters *param)
16179#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016180#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16181static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16182 struct net_device *dev, const u8 *mac)
16183#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016184static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
16185 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016186#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016187#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016188{
16189 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016190 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070016191
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016192 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016193
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016194#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016195 if (NULL == param) {
16196 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016197 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016198 return -EINVAL;
16199 }
16200
16201 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
16202 param->subtype, &delStaParams);
16203
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016204#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053016205 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016206 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053016207#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053016208 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
16209
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016210 vos_ssr_unprotect(__func__);
16211
16212 return ret;
16213}
16214
16215static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016216 struct net_device *dev,
16217#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16218 const u8 *mac,
16219#else
16220 u8 *mac,
16221#endif
16222 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016223{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016224 hdd_adapter_t *pAdapter;
16225 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016226 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016227#ifdef FEATURE_WLAN_TDLS
16228 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016229
Hoonki Lee11f7dda2013-02-14 16:55:44 -080016230 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016231
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016232 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16233 if (NULL == pAdapter)
16234 {
16235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16236 "%s: Adapter is NULL",__func__);
16237 return -EINVAL;
16238 }
16239 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16240 status = wlan_hdd_validate_context(pHddCtx);
16241 if (0 != status)
16242 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016243 return status;
16244 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016245
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016246 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16247 TRACE_CODE_HDD_CFG80211_ADD_STA,
16248 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016249 mask = params->sta_flags_mask;
16250
16251 set = params->sta_flags_set;
16252
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053016253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016254 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
16255 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016256
16257 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
16258 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080016259 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016260 }
16261 }
16262#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016263 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080016264 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016265}
16266
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016267#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16268static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16269 struct net_device *dev, const u8 *mac,
16270 struct station_parameters *params)
16271#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016272static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
16273 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053016274#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016275{
16276 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016277
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016278 vos_ssr_protect(__func__);
16279 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
16280 vos_ssr_unprotect(__func__);
16281
16282 return ret;
16283}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016284#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070016285
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016286static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070016287 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016288{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016289 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16290 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016291 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016292 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016293 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016294 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070016295
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016296 ENTER();
16297
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016298 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016299 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016300 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016301 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016302 return -EINVAL;
16303 }
16304
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016305 if (!pmksa) {
16306 hddLog(LOGE, FL("pmksa is NULL"));
16307 return -EINVAL;
16308 }
16309
16310 if (!pmksa->bssid || !pmksa->pmkid) {
16311 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
16312 pmksa->bssid, pmksa->pmkid);
16313 return -EINVAL;
16314 }
16315
16316 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
16317 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16318
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16320 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016321 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016322 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016323 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016324 }
16325
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016326 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016327 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16328
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016329 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
16330 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016331
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016332 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016333 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016334 &pmk_id, 1, FALSE);
16335
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016336 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16337 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
16338 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016339
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016340 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016341 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016342}
16343
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016344static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
16345 struct cfg80211_pmksa *pmksa)
16346{
16347 int ret;
16348
16349 vos_ssr_protect(__func__);
16350 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
16351 vos_ssr_unprotect(__func__);
16352
16353 return ret;
16354}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016355
Wilson Yang6507c4e2013-10-01 20:11:19 -070016356
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016357static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070016358 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016359{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016360 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16361 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016362 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016363 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016364
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016365 ENTER();
16366
Wilson Yang6507c4e2013-10-01 20:11:19 -070016367 /* Validate pAdapter */
16368 if (NULL == pAdapter)
16369 {
16370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
16371 return -EINVAL;
16372 }
16373
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016374 if (!pmksa) {
16375 hddLog(LOGE, FL("pmksa is NULL"));
16376 return -EINVAL;
16377 }
16378
16379 if (!pmksa->bssid) {
16380 hddLog(LOGE, FL("pmksa->bssid is NULL"));
16381 return -EINVAL;
16382 }
16383
Kiet Lam98c46a12014-10-31 15:34:57 -070016384 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
16385 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
16386
Wilson Yang6507c4e2013-10-01 20:11:19 -070016387 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16388 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016389 if (0 != status)
16390 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016391 return status;
16392 }
16393
16394 /*Retrieve halHandle*/
16395 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16396
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016397 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16398 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
16399 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016400 /* Delete the PMKID CSR cache */
16401 if (eHAL_STATUS_SUCCESS !=
16402 sme_RoamDelPMKIDfromCache(halHandle,
16403 pAdapter->sessionId, pmksa->bssid, FALSE)) {
16404 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
16405 MAC_ADDR_ARRAY(pmksa->bssid));
16406 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016407 }
16408
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016409 EXIT();
16410 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016411}
16412
Wilson Yang6507c4e2013-10-01 20:11:19 -070016413
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016414static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
16415 struct cfg80211_pmksa *pmksa)
16416{
16417 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016418
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016419 vos_ssr_protect(__func__);
16420 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
16421 vos_ssr_unprotect(__func__);
16422
16423 return ret;
16424
16425}
16426
16427static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016428{
Wilson Yang6507c4e2013-10-01 20:11:19 -070016429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16430 tHalHandle halHandle;
16431 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080016432 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016433
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016434 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070016435
16436 /* Validate pAdapter */
16437 if (NULL == pAdapter)
16438 {
16439 hddLog(VOS_TRACE_LEVEL_ERROR,
16440 "%s: Invalid Adapter" ,__func__);
16441 return -EINVAL;
16442 }
16443
16444 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16445 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070016446 if (0 != status)
16447 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070016448 return status;
16449 }
16450
16451 /*Retrieve halHandle*/
16452 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16453
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053016454 /* Flush the PMKID cache in CSR */
16455 if (eHAL_STATUS_SUCCESS !=
16456 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
16457 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
16458 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070016459 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016460 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080016461 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016462}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053016463
16464static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
16465{
16466 int ret;
16467
16468 vos_ssr_protect(__func__);
16469 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
16470 vos_ssr_unprotect(__func__);
16471
16472 return ret;
16473}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016474#endif
16475
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016476#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016477static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16478 struct net_device *dev,
16479 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016480{
16481 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16482 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016483 hdd_context_t *pHddCtx;
16484 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016485
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016486 ENTER();
16487
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016488 if (NULL == pAdapter)
16489 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016490 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016491 return -ENODEV;
16492 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016493 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16494 ret = wlan_hdd_validate_context(pHddCtx);
16495 if (0 != ret)
16496 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016497 return ret;
16498 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016499 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016500 if (NULL == pHddStaCtx)
16501 {
16502 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
16503 return -EINVAL;
16504 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016505
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016506 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16507 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
16508 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016509 // Added for debug on reception of Re-assoc Req.
16510 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
16511 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080016512 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016513 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080016514 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016515 }
16516
16517#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080016518 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016519 ftie->ie_len);
16520#endif
16521
16522 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053016523 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
16524 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016525 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016526
16527 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016528 return 0;
16529}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016530
16531static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
16532 struct net_device *dev,
16533 struct cfg80211_update_ft_ies_params *ftie)
16534{
16535 int ret;
16536
16537 vos_ssr_protect(__func__);
16538 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
16539 vos_ssr_unprotect(__func__);
16540
16541 return ret;
16542}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016543#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016544
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016545#ifdef FEATURE_WLAN_SCAN_PNO
16546
16547void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
16548 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
16549{
16550 int ret;
16551 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
16552 hdd_context_t *pHddCtx;
16553
Nirav Shah80830bf2013-12-31 16:35:12 +053016554 ENTER();
16555
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016556 if (NULL == pAdapter)
16557 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016559 "%s: HDD adapter is Null", __func__);
16560 return ;
16561 }
16562
16563 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16564 if (NULL == pHddCtx)
16565 {
16566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16567 "%s: HDD context is Null!!!", __func__);
16568 return ;
16569 }
16570
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016571 spin_lock(&pHddCtx->schedScan_lock);
16572 if (TRUE == pHddCtx->isWiphySuspended)
16573 {
16574 pHddCtx->isSchedScanUpdatePending = TRUE;
16575 spin_unlock(&pHddCtx->schedScan_lock);
16576 hddLog(VOS_TRACE_LEVEL_INFO,
16577 "%s: Update cfg80211 scan database after it resume", __func__);
16578 return ;
16579 }
16580 spin_unlock(&pHddCtx->schedScan_lock);
16581
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016582 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
16583
16584 if (0 > ret)
16585 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Mahesh A Saptasagarfb49cdd2015-10-16 18:41:59 +053016586 else
16587 {
16588 /* Acquire wakelock to handle the case where APP's tries to suspend
16589 * immediatly after the driver gets connect request(i.e after pno)
16590 * from supplicant, this result in app's is suspending and not able
16591 * to process the connect request to AP */
16592 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
16593 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016594 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16596 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016597}
16598
16599/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016600 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016601 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016602 */
16603static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
16604{
16605 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
16606 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016607 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016608 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16609 int status = 0;
16610 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
16611
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016612 /* The current firmware design does not allow PNO during any
16613 * active sessions. Hence, determine the active sessions
16614 * and return a failure.
16615 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016616 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
16617 {
16618 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016619 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016620
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016621 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
16622 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
16623 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
16624 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
16625 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053016626 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016627 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016628 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016629 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016630 }
16631 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16632 pAdapterNode = pNext;
16633 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016634 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016635}
16636
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016637void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
16638{
16639 hdd_adapter_t *pAdapter = callbackContext;
16640 hdd_context_t *pHddCtx;
16641
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016642 ENTER();
16643
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016644 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
16645 {
16646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16647 FL("Invalid adapter or adapter has invalid magic"));
16648 return;
16649 }
16650
16651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16652 if (0 != wlan_hdd_validate_context(pHddCtx))
16653 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016654 return;
16655 }
16656
c_hpothub53c45d2014-08-18 16:53:14 +053016657 if (VOS_STATUS_SUCCESS != status)
16658 {
16659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016660 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053016661 pHddCtx->isPnoEnable = FALSE;
16662 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016663
16664 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
16665 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016666 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016667}
16668
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016669/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016670 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
16671 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016672 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053016673static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016674 struct net_device *dev, struct cfg80211_sched_scan_request *request)
16675{
16676 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016677 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016678 hdd_context_t *pHddCtx;
16679 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016680 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053016681 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
16682 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016683 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
16684 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016685 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016686 hdd_config_t *pConfig = NULL;
16687 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016688
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016689 ENTER();
16690
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016691 if (NULL == pAdapter)
16692 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016694 "%s: HDD adapter is Null", __func__);
16695 return -ENODEV;
16696 }
16697
16698 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016699 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016700
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016701 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016702 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016703 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016704 }
16705
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016706 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016707 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16708 if (NULL == hHal)
16709 {
16710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16711 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016712 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016713 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016714 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16715 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
16716 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053016717 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016718 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053016719 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053016720 {
16721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16722 "%s: aborting the existing scan is unsuccessfull", __func__);
16723 return -EBUSY;
16724 }
16725
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016726 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016727 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053016728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053016729 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053016730 return -EBUSY;
16731 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016732
c_hpothu37f21312014-04-09 21:49:54 +053016733 if (TRUE == pHddCtx->isPnoEnable)
16734 {
16735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16736 FL("already PNO is enabled"));
16737 return -EBUSY;
16738 }
c_hpothu225aa7c2014-10-22 17:45:13 +053016739
16740 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
16741 {
16742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16743 "%s: abort ROC failed ", __func__);
16744 return -EBUSY;
16745 }
16746
c_hpothu37f21312014-04-09 21:49:54 +053016747 pHddCtx->isPnoEnable = TRUE;
16748
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016749 pnoRequest.enable = 1; /*Enable PNO */
16750 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016751
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016752 if (( !pnoRequest.ucNetworksCount ) ||
16753 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016754 {
16755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016756 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016757 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016758 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016759 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016760 goto error;
16761 }
16762
16763 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
16764 {
16765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016766 "%s: Incorrect number of channels %d",
16767 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016768 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016769 goto error;
16770 }
16771
16772 /* Framework provides one set of channels(all)
16773 * common for all saved profile */
16774 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
16775 channels_allowed, &num_channels_allowed))
16776 {
16777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16778 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016779 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016780 goto error;
16781 }
16782 /* Checking each channel against allowed channel list */
16783 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053016784 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016785 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016786 char chList [(request->n_channels*5)+1];
16787 int len;
16788 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016789 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016790 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016791 {
Nirav Shah80830bf2013-12-31 16:35:12 +053016792 if (request->channels[i]->hw_value == channels_allowed[indx])
16793 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016794 if ((!pConfig->enableDFSPnoChnlScan) &&
16795 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
16796 {
16797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16798 "%s : Dropping DFS channel : %d",
16799 __func__,channels_allowed[indx]);
16800 num_ignore_dfs_ch++;
16801 break;
16802 }
16803
Nirav Shah80830bf2013-12-31 16:35:12 +053016804 valid_ch[num_ch++] = request->channels[i]->hw_value;
16805 len += snprintf(chList+len, 5, "%d ",
16806 request->channels[i]->hw_value);
16807 break ;
16808 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016809 }
16810 }
Nirav Shah80830bf2013-12-31 16:35:12 +053016811 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016812
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053016813 /*If all channels are DFS and dropped, then ignore the PNO request*/
16814 if (num_ignore_dfs_ch == request->n_channels)
16815 {
16816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16817 "%s : All requested channels are DFS channels", __func__);
16818 ret = -EINVAL;
16819 goto error;
16820 }
16821 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016822
16823 pnoRequest.aNetworks =
16824 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16825 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016826 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016827 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16828 FL("failed to allocate memory aNetworks %u"),
16829 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16830 goto error;
16831 }
16832 vos_mem_zero(pnoRequest.aNetworks,
16833 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
16834
16835 /* Filling per profile params */
16836 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
16837 {
16838 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016839 request->match_sets[i].ssid.ssid_len;
16840
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016841 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
16842 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016843 {
16844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016845 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016846 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016847 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016848 goto error;
16849 }
16850
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016851 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016852 request->match_sets[i].ssid.ssid,
16853 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053016854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16855 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016856 i, pnoRequest.aNetworks[i].ssId.ssId);
16857 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
16858 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
16859 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016860
16861 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016862 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
16863 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016864
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016865 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016866 }
16867
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016868 for (i = 0; i < request->n_ssids; i++)
16869 {
16870 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016871 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016872 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016873 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016874 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016875 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016876 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016877 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016878 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016879 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053016880 break;
16881 }
16882 j++;
16883 }
16884 }
16885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16886 "Number of hidden networks being Configured = %d",
16887 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080016889 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016890
16891 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
16892 if (pnoRequest.p24GProbeTemplate == NULL)
16893 {
16894 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16895 FL("failed to allocate memory p24GProbeTemplate %u"),
16896 SIR_PNO_MAX_PB_REQ_SIZE);
16897 goto error;
16898 }
16899
16900 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
16901 if (pnoRequest.p5GProbeTemplate == NULL)
16902 {
16903 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16904 FL("failed to allocate memory p5GProbeTemplate %u"),
16905 SIR_PNO_MAX_PB_REQ_SIZE);
16906 goto error;
16907 }
16908
16909 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
16910 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
16911
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053016912 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
16913 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016914 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016915 pnoRequest.us24GProbeTemplateLen = request->ie_len;
16916 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
16917 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016918
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016919 pnoRequest.us5GProbeTemplateLen = request->ie_len;
16920 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
16921 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053016922 }
16923
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016924 /* Driver gets only one time interval which is hardcoded in
16925 * supplicant for 10000ms. Taking power consumption into account 6 timers
16926 * will be used, Timervalue is increased exponentially i.e 10,20,40,
16927 * 80,160,320 secs. And number of scan cycle for each timer
16928 * is configurable through INI param gPNOScanTimerRepeatValue.
16929 * If it is set to 0 only one timer will be used and PNO scan cycle
16930 * will be repeated after each interval specified by supplicant
16931 * till PNO is disabled.
16932 */
16933 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016934 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016935 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016936 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016937 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
16938
16939 tempInterval = (request->interval)/1000;
16940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16941 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
16942 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016943 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016944 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016945 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016946 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016947 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016948 tempInterval *= 2;
16949 }
16950 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016951 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053016952
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016953 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016954
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016955 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016956 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
16957 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016958 pAdapter->pno_req_status = 0;
16959
Nirav Shah80830bf2013-12-31 16:35:12 +053016960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16961 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016962 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
16963 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053016964
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016965 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016966 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016967 hdd_cfg80211_sched_scan_done_callback, pAdapter);
16968 if (eHAL_STATUS_SUCCESS != status)
16969 {
16970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053016971 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053016972 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016973 goto error;
16974 }
16975
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016976 ret = wait_for_completion_timeout(
16977 &pAdapter->pno_comp_var,
16978 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
16979 if (0 >= ret)
16980 {
16981 // Did not receive the response for PNO enable in time.
16982 // Assuming the PNO enable was success.
16983 // Returning error from here, because we timeout, results
16984 // in side effect of Wifi (Wifi Setting) not to work.
16985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16986 FL("Timed out waiting for PNO to be Enabled"));
16987 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016988 }
16989
16990 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053016991 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016992
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016993error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053016994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16995 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053016996 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053016997 if (pnoRequest.aNetworks)
16998 vos_mem_free(pnoRequest.aNetworks);
16999 if (pnoRequest.p24GProbeTemplate)
17000 vos_mem_free(pnoRequest.p24GProbeTemplate);
17001 if (pnoRequest.p5GProbeTemplate)
17002 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017003
17004 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017005 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017006}
17007
17008/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017009 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
17010 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017011 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017012static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
17013 struct net_device *dev, struct cfg80211_sched_scan_request *request)
17014{
17015 int ret;
17016
17017 vos_ssr_protect(__func__);
17018 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
17019 vos_ssr_unprotect(__func__);
17020
17021 return ret;
17022}
17023
17024/*
17025 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
17026 * Function to disable PNO
17027 */
17028static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017029 struct net_device *dev)
17030{
17031 eHalStatus status = eHAL_STATUS_FAILURE;
17032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17033 hdd_context_t *pHddCtx;
17034 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017035 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017036 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017037
17038 ENTER();
17039
17040 if (NULL == pAdapter)
17041 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017043 "%s: HDD adapter is Null", __func__);
17044 return -ENODEV;
17045 }
17046
17047 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017048
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017049 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017050 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017052 "%s: HDD context is Null", __func__);
17053 return -ENODEV;
17054 }
17055
17056 /* The return 0 is intentional when isLogpInProgress and
17057 * isLoadUnloadInProgress. We did observe a crash due to a return of
17058 * failure in sched_scan_stop , especially for a case where the unload
17059 * of the happens at the same time. The function __cfg80211_stop_sched_scan
17060 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
17061 * success. If it returns a failure , then its next invocation due to the
17062 * clean up of the second interface will have the dev pointer corresponding
17063 * to the first one leading to a crash.
17064 */
17065 if (pHddCtx->isLogpInProgress)
17066 {
17067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17068 "%s: LOGP in Progress. Ignore!!!", __func__);
Mahesh A Saptasagar0c11d822015-10-08 19:54:08 +053017069 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017070 return ret;
17071 }
17072
Mihir Shete18156292014-03-11 15:38:30 +053017073 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017074 {
17075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17076 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17077 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017078 }
17079
17080 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
17081 if (NULL == hHal)
17082 {
17083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17084 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017085 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017086 }
17087
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017088 pnoRequest.enable = 0; /* Disable PNO */
17089 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017090
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017091 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17092 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
17093 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017094
17095 INIT_COMPLETION(pAdapter->pno_comp_var);
17096 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
17097 pnoRequest.callbackContext = pAdapter;
17098 pAdapter->pno_req_status = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053017099 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017100 pAdapter->sessionId,
17101 NULL, pAdapter);
17102 if (eHAL_STATUS_SUCCESS != status)
17103 {
17104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17105 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017106 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017107 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017108 }
Hanumantha Reddy Pothula0e408dc2015-11-23 12:04:53 +053017109 ret = wait_for_completion_timeout(
17110 &pAdapter->pno_comp_var,
17111 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
17112 if (0 >= ret)
17113 {
17114 // Did not receive the response for PNO disable in time.
17115 // Assuming the PNO disable was success.
17116 // Returning error from here, because we timeout, results
17117 // in side effect of Wifi (Wifi Setting) not to work.
17118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17119 FL("Timed out waiting for PNO to be disabled"));
17120 ret = 0;
17121 }
17122
17123 ret = pAdapter->pno_req_status;
17124 pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017125
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017126error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017127 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053017128 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017129
17130 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053017131 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017132}
17133
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053017134/*
17135 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
17136 * NL interface to disable PNO
17137 */
17138static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
17139 struct net_device *dev)
17140{
17141 int ret;
17142
17143 vos_ssr_protect(__func__);
17144 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
17145 vos_ssr_unprotect(__func__);
17146
17147 return ret;
17148}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017149#endif /*FEATURE_WLAN_SCAN_PNO*/
17150
17151
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017152#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017153#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017154static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17155 struct net_device *dev,
17156 u8 *peer, u8 action_code,
17157 u8 dialog_token,
17158 u16 status_code, u32 peer_capability,
17159 const u8 *buf, size_t len)
17160#else /* TDLS_MGMT_VERSION2 */
17161#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17162static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17163 struct net_device *dev,
17164 const u8 *peer, u8 action_code,
17165 u8 dialog_token, u16 status_code,
17166 u32 peer_capability, bool initiator,
17167 const u8 *buf, size_t len)
17168#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17169static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17170 struct net_device *dev,
17171 const u8 *peer, u8 action_code,
17172 u8 dialog_token, u16 status_code,
17173 u32 peer_capability, const u8 *buf,
17174 size_t len)
17175#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17176static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17177 struct net_device *dev,
17178 u8 *peer, u8 action_code,
17179 u8 dialog_token,
17180 u16 status_code, u32 peer_capability,
17181 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017182#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017183static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17184 struct net_device *dev,
17185 u8 *peer, u8 action_code,
17186 u8 dialog_token,
17187 u16 status_code, const u8 *buf,
17188 size_t len)
17189#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017190#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017191{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017192 hdd_adapter_t *pAdapter;
17193 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017194 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070017195 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080017196 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070017197 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017198 int ret;
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017199 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017200#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053017201 u32 peer_capability = 0;
17202#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017203 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017204 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017205
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017206 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17207 if (NULL == pAdapter)
17208 {
17209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17210 "%s: Adapter is NULL",__func__);
17211 return -EINVAL;
17212 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017213 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17214 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
17215 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017216
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017217 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017218 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017219 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017221 "Invalid arguments");
17222 return -EINVAL;
17223 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017224
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017225 if (pHddCtx->isLogpInProgress)
17226 {
17227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17228 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053017229 wlan_hdd_tdls_set_link_status(pAdapter,
17230 peer,
17231 eTDLS_LINK_IDLE,
17232 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017233 return -EBUSY;
17234 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017235
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017236 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
17237 {
17238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17239 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
17240 return -EAGAIN;
17241 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017242
Hoonki Lee27511902013-03-14 18:19:06 -070017243 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017244 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017245 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017246 "%s: TDLS mode is disabled OR not enabled in FW."
17247 MAC_ADDRESS_STR " action %d declined.",
17248 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017249 return -ENOTSUPP;
17250 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017251
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017252 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
17253
17254 if( NULL == pHddStaCtx )
17255 {
17256 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17257 "%s: HDD station context NULL ",__func__);
17258 return -EINVAL;
17259 }
17260
17261 /* STA should be connected and authenticated
17262 * before sending any TDLS frames
17263 */
17264 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
17265 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
17266 {
17267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17268 "STA is not connected or unauthenticated. "
17269 "connState %u, uIsAuthenticated %u",
17270 pHddStaCtx->conn_info.connState,
17271 pHddStaCtx->conn_info.uIsAuthenticated);
17272 return -EAGAIN;
17273 }
17274
Hoonki Lee27511902013-03-14 18:19:06 -070017275 /* other than teardown frame, other mgmt frames are not sent if disabled */
17276 if (SIR_MAC_TDLS_TEARDOWN != action_code)
17277 {
17278 /* if tdls_mode is disabled to respond to peer's request */
17279 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
17280 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070017282 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017283 " TDLS mode is disabled. action %d declined.",
17284 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070017285
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017286 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070017287 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053017288
17289 if (vos_max_concurrent_connections_reached())
17290 {
17291 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
17292 return -EINVAL;
17293 }
Hoonki Lee27511902013-03-14 18:19:06 -070017294 }
17295
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017296 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
17297 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053017298 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017299 {
17300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017301 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017302 " TDLS setup is ongoing. action %d declined.",
17303 __func__, MAC_ADDR_ARRAY(peer), action_code);
17304 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017305 }
17306 }
17307
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017308 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
17309 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080017310 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017311 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
17312 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017313 {
17314 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
17315 we return error code at 'add_station()'. Hence we have this
17316 check again in addtion to add_station().
17317 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017318 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080017319 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017320 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17321 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017322 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
17323 __func__, MAC_ADDR_ARRAY(peer), action_code,
17324 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053017325 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080017326 }
17327 else
17328 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017329 /* maximum reached. tweak to send error code to peer and return
17330 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017331 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17333 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053017334 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
17335 __func__, MAC_ADDR_ARRAY(peer), status_code,
17336 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070017337 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017338 /* fall through to send setup resp with failure status
17339 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080017340 }
17341 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017342 else
17343 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017344 mutex_lock(&pHddCtx->tdls_lock);
17345 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070017346 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017347 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017348 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070017350 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
17351 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017352 return -EPERM;
17353 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017354 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017355 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080017356 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017357
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017358 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017359 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017360 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
17361 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017362
Hoonki Leea34dd892013-02-05 22:56:02 -080017363 /*Except teardown responder will not be used so just make 0*/
17364 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080017365 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080017366 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017367
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017368 mutex_lock(&pHddCtx->tdls_lock);
17369 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017370
17371 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
17372 responder = pTdlsPeer->is_responder;
17373 else
Hoonki Leea34dd892013-02-05 22:56:02 -080017374 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017375 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053017376 "%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 -070017377 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
17378 dialog_token, status_code, len);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017379 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070017380 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080017381 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017382 mutex_unlock(&pHddCtx->tdls_lock);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017383 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017384
Masti, Narayanraddi3b681932015-10-08 19:22:25 +053017385 /* Discard TDLS setup if peer is removed by user app */
17386 if ((pHddCtx->cfg_ini->fTDLSExternalControl) &&
17387 ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17388 (SIR_MAC_TDLS_SETUP_CNF == action_code) ||
17389 (SIR_MAC_TDLS_DIS_REQ == action_code))) {
17390
17391 mutex_lock(&pHddCtx->tdls_lock);
17392 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17393 if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) {
17394 mutex_unlock(&pHddCtx->tdls_lock);
17395 hddLog(LOGE, FL("TDLS External Control enabled, but peer "
17396 MAC_ADDRESS_STR " is not forced, so reject the action code %d"),
17397 MAC_ADDR_ARRAY(peer), action_code);
17398 return -EINVAL;
17399 }
17400 mutex_unlock(&pHddCtx->tdls_lock);
17401 }
17402
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017403 /* For explicit trigger of DIS_REQ come out of BMPS for
17404 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070017405 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017406 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
17407 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070017408 {
17409 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
17410 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053017411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053017412 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017413 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
17414 if (status != VOS_STATUS_SUCCESS) {
17415 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
17416 }
Hoonki Lee14621352013-04-16 17:51:19 -070017417 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017418 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017419 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017420 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
17421 }
17422 }
Hoonki Lee14621352013-04-16 17:51:19 -070017423 }
17424
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017425 /* make sure doesn't call send_mgmt() while it is pending */
17426 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
17427 {
17428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080017429 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017430 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017431 ret = -EBUSY;
17432 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017433 }
17434
17435 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017436 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
17437
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017438 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
17439 pAdapter->sessionId, peer, action_code, dialog_token,
17440 status_code, peer_capability, (tANI_U8 *)buf, len,
17441 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017442
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017443 if (VOS_STATUS_SUCCESS != status)
17444 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17446 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017447 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017448 ret = -EINVAL;
17449 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017450 }
17451
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017452 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
17453 (SIR_MAC_TDLS_DIS_RSP == action_code))
17454 {
17455 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
17456 * So we no need to wait for tdls_mgmt_comp for sending ack status.
17457 */
17458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17459 "%s: tx done for frm %u", __func__, action_code);
17460 return 0;
17461 }
17462
17463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17464 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
17465 WAIT_TIME_TDLS_MGMT);
17466
Hoonki Leed37cbb32013-04-20 00:31:14 -070017467 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
17468 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
17469
17470 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017471 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070017472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070017473 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070017474 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017475 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080017476
17477 if (pHddCtx->isLogpInProgress)
17478 {
17479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17480 "%s: LOGP in Progress. Ignore!!!", __func__);
17481 return -EAGAIN;
17482 }
Abhishek Singh837adf22015-10-01 17:37:37 +053017483 if (rc <= 0)
17484 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
17485 WLAN_LOG_INDICATOR_HOST_DRIVER,
17486 WLAN_LOG_REASON_HDD_TIME_OUT,
17487 TRUE, TRUE);
Yue Ma4f55ef32014-01-23 16:45:33 -080017488
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017489 ret = -EINVAL;
17490 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017491 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053017492 else
17493 {
17494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17495 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
17496 __func__, rc, pAdapter->mgmtTxCompletionStatus);
17497 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017498
Gopichand Nakkala05922802013-03-14 12:23:19 -070017499 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070017500 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017501 ret = max_sta_failed;
17502 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070017503 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017504
Hoonki Leea34dd892013-02-05 22:56:02 -080017505 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
17506 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017507 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017508 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17509 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017510 }
17511 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
17512 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017513 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017514 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
17515 }
Hoonki Leea34dd892013-02-05 22:56:02 -080017516 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017517
17518 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053017519
17520tx_failed:
17521 /* add_station will be called before sending TDLS_SETUP_REQ and
17522 * TDLS_SETUP_RSP and as part of add_station driver will enable
17523 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
17524 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
17525 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
17526 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
17527 */
17528
17529 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
17530 (SIR_MAC_TDLS_SETUP_RSP == action_code))
17531 wlan_hdd_tdls_check_bmps(pAdapter);
17532 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017533}
17534
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017535#if TDLS_MGMT_VERSION2
17536static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17537 u8 *peer, u8 action_code, u8 dialog_token,
17538 u16 status_code, u32 peer_capability,
17539 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017540#else /* TDLS_MGMT_VERSION2 */
17541#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
17542static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17543 struct net_device *dev,
17544 const u8 *peer, u8 action_code,
17545 u8 dialog_token, u16 status_code,
17546 u32 peer_capability, bool initiator,
17547 const u8 *buf, size_t len)
17548#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
17549static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17550 struct net_device *dev,
17551 const u8 *peer, u8 action_code,
17552 u8 dialog_token, u16 status_code,
17553 u32 peer_capability, const u8 *buf,
17554 size_t len)
17555#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
17556static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
17557 struct net_device *dev,
17558 u8 *peer, u8 action_code,
17559 u8 dialog_token,
17560 u16 status_code, u32 peer_capability,
17561 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017562#else
17563static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
17564 u8 *peer, u8 action_code, u8 dialog_token,
17565 u16 status_code, const u8 *buf, size_t len)
17566#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017567#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017568{
17569 int ret;
17570
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017571 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017572#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017573 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17574 dialog_token, status_code,
17575 peer_capability, buf, len);
17576#else /* TDLS_MGMT_VERSION2 */
17577#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
17578 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17579 dialog_token, status_code,
17580 peer_capability, initiator,
17581 buf, len);
17582#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
17583 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17584 dialog_token, status_code,
17585 peer_capability, buf, len);
17586#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
17587 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17588 dialog_token, status_code,
17589 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017590#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017591 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
17592 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017593#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017594#endif
17595 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017596
Anand N Sunkad9f80b742015-07-30 20:05:51 +053017597 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053017598}
Atul Mittal115287b2014-07-08 13:26:33 +053017599
17600int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017601#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17602 const u8 *peer,
17603#else
Atul Mittal115287b2014-07-08 13:26:33 +053017604 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017605#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017606 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053017607 cfg80211_exttdls_callback callback)
17608{
17609
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017610 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053017611 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017612 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053017613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17614 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
17615 __func__, MAC_ADDR_ARRAY(peer));
17616
17617 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17618 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17619
17620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017621 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17622 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17623 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017624 return -ENOTSUPP;
17625 }
17626
17627 /* To cater the requirement of establishing the TDLS link
17628 * irrespective of the data traffic , get an entry of TDLS peer.
17629 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017630 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017631 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
17632 if (pTdlsPeer == NULL) {
17633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17634 "%s: peer " MAC_ADDRESS_STR " not existing",
17635 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053017636 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017637 return -EINVAL;
17638 }
17639
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017640 /* check FW TDLS Off Channel capability */
17641 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017642 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053017643 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017644 {
17645 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
17646 pTdlsPeer->peerParams.global_operating_class =
17647 tdls_peer_params->global_operating_class;
17648 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
17649 pTdlsPeer->peerParams.min_bandwidth_kbps =
17650 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017651 /* check configured channel is valid, non dfs and
17652 * not current operating channel */
17653 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
17654 tdls_peer_params->channel)) &&
17655 (pHddStaCtx) &&
17656 (tdls_peer_params->channel !=
17657 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017658 {
17659 pTdlsPeer->isOffChannelConfigured = TRUE;
17660 }
17661 else
17662 {
17663 pTdlsPeer->isOffChannelConfigured = FALSE;
17664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17665 "%s: Configured Tdls Off Channel is not valid", __func__);
17666
17667 }
17668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017669 "%s: tdls_off_channel %d isOffChannelConfigured %d "
17670 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017671 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053017672 pTdlsPeer->isOffChannelConfigured,
17673 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017674 }
17675 else
17676 {
17677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053017678 "%s: TDLS off channel FW capability %d, "
17679 "host capab %d or Invalid TDLS Peer Params", __func__,
17680 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
17681 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017682 }
17683
Atul Mittal115287b2014-07-08 13:26:33 +053017684 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
17685
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017686 mutex_unlock(&pHddCtx->tdls_lock);
17687
Atul Mittal115287b2014-07-08 13:26:33 +053017688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17689 " %s TDLS Add Force Peer Failed",
17690 __func__);
17691 return -EINVAL;
17692 }
17693 /*EXT TDLS*/
17694
17695 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017696 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17698 " %s TDLS set callback Failed",
17699 __func__);
17700 return -EINVAL;
17701 }
17702
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017703 mutex_unlock(&pHddCtx->tdls_lock);
17704
Atul Mittal115287b2014-07-08 13:26:33 +053017705 return(0);
17706
17707}
17708
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017709int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
17710#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17711 const u8 *peer
17712#else
17713 u8 *peer
17714#endif
17715)
Atul Mittal115287b2014-07-08 13:26:33 +053017716{
17717
17718 hddTdlsPeer_t *pTdlsPeer;
17719 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053017720
Atul Mittal115287b2014-07-08 13:26:33 +053017721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17722 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
17723 __func__, MAC_ADDR_ARRAY(peer));
17724
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017725 if (0 != wlan_hdd_validate_context(pHddCtx)) {
17726 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
17727 return -EINVAL;
17728 }
17729
Atul Mittal115287b2014-07-08 13:26:33 +053017730 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
17731 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
17732
17733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017734 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
17735 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
17736 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053017737 return -ENOTSUPP;
17738 }
17739
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017740 mutex_lock(&pHddCtx->tdls_lock);
17741 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Atul Mittal115287b2014-07-08 13:26:33 +053017742
17743 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017744 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017745 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017746 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053017747 __func__, MAC_ADDR_ARRAY(peer));
17748 return -EINVAL;
17749 }
17750 else {
17751 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
17752 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Abhishek Singhff7c2f92016-01-05 15:28:12 +053017753 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL,
17754 pTdlsPeer->peerMac);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017755 /* if channel switch is configured, reset
17756 the channel for this peer */
17757 if (TRUE == pTdlsPeer->isOffChannelConfigured)
17758 {
17759 pTdlsPeer->peerParams.channel = 0;
17760 pTdlsPeer->isOffChannelConfigured = FALSE;
17761 }
Atul Mittal115287b2014-07-08 13:26:33 +053017762 }
17763
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017764 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017765 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017766 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053017767 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017768 }
Atul Mittal115287b2014-07-08 13:26:33 +053017769
17770 /*EXT TDLS*/
17771
17772 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017773 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053017774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17775 " %s TDLS set callback Failed",
17776 __func__);
17777 return -EINVAL;
17778 }
Atul Mittal115287b2014-07-08 13:26:33 +053017779
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017780 mutex_unlock(&pHddCtx->tdls_lock);
17781
17782 return(0);
Atul Mittal115287b2014-07-08 13:26:33 +053017783}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017784static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053017785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
17786 const u8 *peer,
17787#else
17788 u8 *peer,
17789#endif
17790 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017791{
17792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
17793 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017794 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070017795 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053017796
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017797 ENTER();
17798
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053017799 if (!pAdapter) {
17800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
17801 return -EINVAL;
17802 }
17803
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053017804 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17805 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
17806 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017807 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017808 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080017809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070017810 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017811 return -EINVAL;
17812 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017813
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017814 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017815 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017816 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053017817 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080017818 }
17819
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017820
17821 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017822 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017823 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080017824 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017825 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
17826 "Cannot process TDLS commands",
17827 pHddCtx->cfg_ini->fEnableTDLSSupport,
17828 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017829 return -ENOTSUPP;
17830 }
17831
17832 switch (oper) {
17833 case NL80211_TDLS_ENABLE_LINK:
17834 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017835 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053017836 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017837 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053017838 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017839 tANI_U16 numCurrTdlsPeers = 0;
17840 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053017841 tANI_U8 suppChannelLen = 0;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017842 tSirMacAddr peerMac;
17843 int channel;
17844 tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017845
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17847 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
17848 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017849
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017850 mutex_lock(&pHddCtx->tdls_lock);
17851 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053017852 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053017853 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017854 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053017855 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
17856 " (oper %d) not exsting. ignored",
17857 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
17858 return -EINVAL;
17859 }
17860
17861 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17862 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
17863 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
17864 "NL80211_TDLS_ENABLE_LINK");
17865
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070017866 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
17867 {
17868 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
17869 MAC_ADDRESS_STR " failed",
17870 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017871 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070017872 return -EINVAL;
17873 }
17874
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053017875 /* before starting tdls connection, set tdls
17876 * off channel established status to default value */
17877 pTdlsPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017878
17879 mutex_unlock(&pHddCtx->tdls_lock);
17880
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017881 /* TDLS Off Channel, Disable tdls channel switch,
17882 when there are more than one tdls link */
17883 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053017884 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017885 {
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017886 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017887 /* get connected peer and send disable tdls off chan */
17888 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017889 if ((connPeer) &&
17890 (connPeer->isOffChannelSupported == TRUE) &&
17891 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017892 {
17893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17894 "%s: More then one peer connected, Disable "
17895 "TDLS channel switch", __func__);
17896
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053017897 connPeer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017898 vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr));
17899 channel = connPeer->peerParams.channel;
17900
17901 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017902
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017903 ret = sme_SendTdlsChanSwitchReq(
17904 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017905 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017906 peerMac,
17907 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017908 TDLS_OFF_CHANNEL_BW_OFFSET,
17909 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017910 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017911 hddLog(VOS_TRACE_LEVEL_ERROR,
17912 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017913 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017914 }
17915 else
17916 {
17917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17918 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017919 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017920 "isOffChannelConfigured %d",
17921 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053017922 (connPeer ? (connPeer->isOffChannelSupported)
17923 : -1),
17924 (connPeer ? (connPeer->isOffChannelConfigured)
17925 : -1));
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017926 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053017927 }
17928 }
17929
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017930 mutex_lock(&pHddCtx->tdls_lock);
17931 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17932 if ( NULL == pTdlsPeer ) {
17933 mutex_unlock(&pHddCtx->tdls_lock);
17934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17935 "%s: " MAC_ADDRESS_STR
17936 " (oper %d) peer got freed in other context. ignored",
17937 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
17938 return -EINVAL;
17939 }
17940 peer_status = pTdlsPeer->link_status;
17941 mutex_unlock(&pHddCtx->tdls_lock);
17942
17943 if (eTDLS_LINK_CONNECTED != peer_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070017944 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017945 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053017946
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017947 if (0 != wlan_hdd_tdls_get_link_establish_params(
17948 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017949 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017950 return -EINVAL;
17951 }
17952 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017953
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053017954 ret = sme_SendTdlsLinkEstablishParams(
17955 WLAN_HDD_GET_HAL_CTX(pAdapter),
17956 pAdapter->sessionId, peer,
17957 &tdlsLinkEstablishParams);
17958 if (ret != VOS_STATUS_SUCCESS) {
17959 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
17960 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017961 /* Send TDLS peer UAPSD capabilities to the firmware and
17962 * register with the TL on after the response for this operation
17963 * is received .
17964 */
17965 ret = wait_for_completion_interruptible_timeout(
17966 &pAdapter->tdls_link_establish_req_comp,
17967 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Masti, Narayanraddie1892a52015-12-15 15:01:01 +053017968
17969 mutex_lock(&pHddCtx->tdls_lock);
17970 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17971 if ( NULL == pTdlsPeer ) {
17972 mutex_unlock(&pHddCtx->tdls_lock);
17973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17974 "%s %d: " MAC_ADDRESS_STR
17975 " (oper %d) peer got freed in other context. ignored",
17976 __func__, __LINE__, MAC_ADDR_ARRAY(peer),
17977 (int)oper);
17978 return -EINVAL;
17979 }
17980 peer_status = pTdlsPeer->link_status;
17981 mutex_unlock(&pHddCtx->tdls_lock);
17982
17983 if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING))
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017984 {
17985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053017986 FL("Link Establish Request Failed Status %ld"),
17987 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053017988 return -EINVAL;
17989 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053017990 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053017991
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053017992 mutex_lock(&pHddCtx->tdls_lock);
17993 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
17994 if ( NULL == pTdlsPeer ) {
17995 mutex_unlock(&pHddCtx->tdls_lock);
17996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
17997 "%s: " MAC_ADDRESS_STR
17998 " (oper %d) peer got freed in other context. ignored",
17999 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18000 return -EINVAL;
18001 }
18002
Atul Mittal115287b2014-07-08 13:26:33 +053018003 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18004 eTDLS_LINK_CONNECTED,
18005 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053018006 staDesc.ucSTAId = pTdlsPeer->staId;
18007 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Masti, Narayanraddi3d799022015-12-24 18:22:36 +053018008
18009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18010 "%s: tdlsLinkEstablishParams of peer "
18011 MAC_ADDRESS_STR "uapsdQueues: %d"
18012 "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d"
18013 "isResponder: %d peerstaId: %d",
18014 __func__,
18015 MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac),
18016 tdlsLinkEstablishParams.uapsdQueues,
18017 tdlsLinkEstablishParams.qos,
18018 tdlsLinkEstablishParams.maxSp,
18019 tdlsLinkEstablishParams.isBufSta,
18020 tdlsLinkEstablishParams.isOffChannelSupported,
18021 tdlsLinkEstablishParams.isResponder,
18022 pTdlsPeer->staId);
18023
18024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18025 "%s: StaDesc ucSTAId: %d ucQosEnabled: %d",
18026 __func__,
18027 staDesc.ucSTAId,
18028 staDesc.ucQosEnabled);
18029
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018030 ret = WLANTL_UpdateTdlsSTAClient(
18031 pHddCtx->pvosContext,
18032 &staDesc);
18033 if (ret != VOS_STATUS_SUCCESS) {
18034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
18035 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053018036
Gopichand Nakkala471708b2013-06-04 20:03:01 +053018037 /* Mark TDLS client Authenticated .*/
18038 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
18039 pTdlsPeer->staId,
18040 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018041 if (VOS_STATUS_SUCCESS == status)
18042 {
Hoonki Lee14621352013-04-16 17:51:19 -070018043 if (pTdlsPeer->is_responder == 0)
18044 {
18045 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +053018046 tdlsConnInfo_t *tdlsInfo;
18047
18048 tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId);
18049
18050 /* Initialize initiator wait callback */
18051 vos_timer_init(
18052 &pTdlsPeer->initiatorWaitTimeoutTimer,
18053 VOS_TIMER_TYPE_SW,
18054 wlan_hdd_tdls_initiator_wait_cb,
18055 tdlsInfo);
Hoonki Lee14621352013-04-16 17:51:19 -070018056
18057 wlan_hdd_tdls_timer_restart(pAdapter,
18058 &pTdlsPeer->initiatorWaitTimeoutTimer,
18059 WAIT_TIME_TDLS_INITIATOR);
18060 /* suspend initiator TX until it receives direct packet from the
18061 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018062 ret = WLANTL_SuspendDataTx(
18063 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18064 &staId, NULL);
18065 if (ret != VOS_STATUS_SUCCESS) {
18066 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
18067 }
Hoonki Lee14621352013-04-16 17:51:19 -070018068 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018069
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018070 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018071 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018072 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018073 suppChannelLen =
18074 tdlsLinkEstablishParams.supportedChannelsLen;
18075
18076 if ((suppChannelLen > 0) &&
18077 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
18078 {
18079 tANI_U8 suppPeerChannel = 0;
18080 int i = 0;
18081 for (i = 0U; i < suppChannelLen; i++)
18082 {
18083 suppPeerChannel =
18084 tdlsLinkEstablishParams.supportedChannels[i];
18085
18086 pTdlsPeer->isOffChannelSupported = FALSE;
18087 if (suppPeerChannel ==
18088 pTdlsPeer->peerParams.channel)
18089 {
18090 pTdlsPeer->isOffChannelSupported = TRUE;
18091 break;
18092 }
18093 }
18094 }
18095 else
18096 {
18097 pTdlsPeer->isOffChannelSupported = FALSE;
18098 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018099 }
18100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18101 "%s: TDLS channel switch request for channel "
18102 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018103 "%d isOffChannelSupported %d", __func__,
18104 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018105 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053018106 suppChannelLen,
18107 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053018108
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018109 /* TDLS Off Channel, Enable tdls channel switch,
18110 when their is only one tdls link and it supports */
18111 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18112 if ((numCurrTdlsPeers == 1) &&
18113 (TRUE == pTdlsPeer->isOffChannelSupported) &&
18114 (TRUE == pTdlsPeer->isOffChannelConfigured))
18115 {
18116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18117 "%s: Send TDLS channel switch request for channel %d",
18118 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018119
18120 pTdlsPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018121 vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr));
18122 channel = pTdlsPeer->peerParams.channel;
18123
18124 mutex_unlock(&pHddCtx->tdls_lock);
18125
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018126 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
18127 pAdapter->sessionId,
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018128 peerMac,
18129 channel,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018130 TDLS_OFF_CHANNEL_BW_OFFSET,
18131 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018132 if (ret != VOS_STATUS_SUCCESS) {
18133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
18134 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018135 }
18136 else
18137 {
18138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18139 "%s: TDLS channel switch request not sent"
18140 " numCurrTdlsPeers %d "
18141 "isOffChannelSupported %d "
18142 "isOffChannelConfigured %d",
18143 __func__, numCurrTdlsPeers,
18144 pTdlsPeer->isOffChannelSupported,
18145 pTdlsPeer->isOffChannelConfigured);
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018146 mutex_unlock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018147 }
18148
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070018149 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018150 else
18151 mutex_unlock(&pHddCtx->tdls_lock);
18152
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018153 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018154
18155 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018156 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
18157 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018158 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018159 int ac;
18160 uint8 ucAc[4] = { WLANTL_AC_VO,
18161 WLANTL_AC_VI,
18162 WLANTL_AC_BK,
18163 WLANTL_AC_BE };
18164 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
18165 for(ac=0; ac < 4; ac++)
18166 {
18167 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
18168 pTdlsPeer->staId, ucAc[ac],
18169 tlTid[ac], tlTid[ac], 0, 0,
18170 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018171 if (status != VOS_STATUS_SUCCESS) {
18172 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
18173 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053018174 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053018175 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018176 }
Masti, Narayanraddi09c52d52015-12-19 14:19:18 +053018177
Bhargav Shah66896792015-10-01 18:17:37 +053018178 /* stop TCP delack timer if TDLS is enable */
18179 set_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18180 hdd_manage_delack_timer(pHddCtx);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018181 }
18182 break;
18183 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080018184 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018185 tANI_U16 numCurrTdlsPeers = 0;
18186 hddTdlsPeer_t *connPeer = NULL;
18187
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18189 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
18190 __func__, MAC_ADDR_ARRAY(peer));
18191
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018192 mutex_lock(&pHddCtx->tdls_lock);
18193 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018194
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018195
Sunil Dutt41de4e22013-11-14 18:09:02 +053018196 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018197 mutex_unlock(&pHddCtx->tdls_lock);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018198 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18199 " (oper %d) not exsting. ignored",
18200 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
18201 return -EINVAL;
18202 }
18203
18204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18205 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
18206 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
18207 "NL80211_TDLS_DISABLE_LINK");
18208
Hoonki Lee5305c3a2013-04-29 23:28:59 -070018209 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080018210 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018211 long status;
18212
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053018213 /* set tdls off channel status to false for this peer */
18214 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053018215 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
18216 eTDLS_LINK_TEARING,
18217 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
18218 eTDLS_LINK_UNSPECIFIED:
18219 eTDLS_LINK_DROPPED_BY_REMOTE);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018220 mutex_unlock(&pHddCtx->tdls_lock);
18221
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018222 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
18223
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018224 status = sme_DeleteTdlsPeerSta(
18225 WLAN_HDD_GET_HAL_CTX(pAdapter),
18226 pAdapter->sessionId, peer );
18227 if (status != VOS_STATUS_SUCCESS) {
18228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
18229 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018230
18231 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
18232 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018233
18234 mutex_lock(&pHddCtx->tdls_lock);
18235 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE);
18236 if ( NULL == pTdlsPeer ) {
18237 mutex_unlock(&pHddCtx->tdls_lock);
18238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
18239 " peer was freed in other context",
18240 __func__, MAC_ADDR_ARRAY(peer));
18241 return -EINVAL;
18242 }
18243
Atul Mittal271a7652014-09-12 13:18:22 +053018244 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053018245 eTDLS_LINK_IDLE,
18246 eTDLS_LINK_UNSPECIFIED);
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018247 mutex_unlock(&pHddCtx->tdls_lock);
18248
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018249 if (status <= 0)
18250 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070018251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18252 "%s: Del station failed status %ld",
18253 __func__, status);
18254 return -EPERM;
18255 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018256
18257 /* TDLS Off Channel, Enable tdls channel switch,
18258 when their is only one tdls link and it supports */
18259 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
18260 if (numCurrTdlsPeers == 1)
18261 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018262 tSirMacAddr peerMac;
18263 int channel;
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018264
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018265 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018266 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Masti, Narayanraddi3818aea2015-10-17 15:20:28 +053018267
18268 if (connPeer == NULL) {
18269 mutex_unlock(&pHddCtx->tdls_lock);
18270 hddLog(VOS_TRACE_LEVEL_ERROR,
18271 "%s connPeer is NULL", __func__);
18272 return -EINVAL;
18273 }
18274
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018275 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
18276 channel = connPeer->peerParams.channel;
18277
18278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18279 "%s: TDLS channel switch "
18280 "isOffChannelSupported %d "
18281 "isOffChannelConfigured %d "
18282 "isOffChannelEstablished %d",
18283 __func__,
18284 (connPeer ? connPeer->isOffChannelSupported : -1),
18285 (connPeer ? connPeer->isOffChannelConfigured : -1),
18286 (connPeer ? connPeer->isOffChannelEstablished : -1));
18287
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018288 if ((connPeer) &&
18289 (connPeer->isOffChannelSupported == TRUE) &&
18290 (connPeer->isOffChannelConfigured == TRUE))
18291 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053018292 connPeer->isOffChannelEstablished = TRUE;
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018293 mutex_unlock(&pHddCtx->tdls_lock);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018294 status = sme_SendTdlsChanSwitchReq(
18295 WLAN_HDD_GET_HAL_CTX(pAdapter),
18296 pAdapter->sessionId,
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018297 peerMac,
18298 channel,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053018299 TDLS_OFF_CHANNEL_BW_OFFSET,
18300 TDLS_CHANNEL_SWITCH_ENABLE);
18301 if (status != VOS_STATUS_SUCCESS) {
18302 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
18303 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018304 }
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018305 else
18306 mutex_unlock(&pHddCtx->tdls_lock);
18307 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018308 else
18309 {
18310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18311 "%s: TDLS channel switch request not sent "
18312 "numCurrTdlsPeers %d ",
18313 __func__, numCurrTdlsPeers);
18314 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018315 }
18316 else
18317 {
Masti, Narayanraddi8208f062015-10-15 13:16:17 +053018318 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18320 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080018321 }
Bhargav Shah66896792015-10-01 18:17:37 +053018322 if (numCurrTdlsPeers == 0) {
18323 /* start TCP delack timer if TDLS is disable */
18324 clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode);
18325 hdd_manage_delack_timer(pHddCtx);
18326 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080018327 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070018328 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018329 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018330 {
Atul Mittal115287b2014-07-08 13:26:33 +053018331 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018332
Atul Mittal115287b2014-07-08 13:26:33 +053018333 if (0 != status)
18334 {
18335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018336 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053018337 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018338 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053018339 break;
18340 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018341 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053018342 {
Atul Mittal115287b2014-07-08 13:26:33 +053018343 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
18344 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053018345 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053018346 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053018347
Atul Mittal115287b2014-07-08 13:26:33 +053018348 if (0 != status)
18349 {
18350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018351 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053018352 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053018353 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053018354 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053018355 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018356 case NL80211_TDLS_DISCOVERY_REQ:
18357 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053018359 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018360 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018361 return -ENOTSUPP;
18362 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18364 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018365 return -ENOTSUPP;
18366 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018367
18368 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018369 return 0;
18370}
Chilam NG571c65a2013-01-19 12:27:36 +053018371
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018372static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018373#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
18374 const u8 *peer,
18375#else
18376 u8 *peer,
18377#endif
18378 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018379{
18380 int ret;
18381
18382 vos_ssr_protect(__func__);
18383 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
18384 vos_ssr_unprotect(__func__);
18385
18386 return ret;
18387}
18388
Chilam NG571c65a2013-01-19 12:27:36 +053018389int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
18390 struct net_device *dev, u8 *peer)
18391{
Arif Hussaina7c8e412013-11-20 11:06:42 -080018392 hddLog(VOS_TRACE_LEVEL_INFO,
18393 "tdls send discover req: "MAC_ADDRESS_STR,
18394 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053018395
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018396#if TDLS_MGMT_VERSION2
18397 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18398 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18399#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018400#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
18401 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18402 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
18403#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
18404 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18405 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18406#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
18407 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18408 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
18409#else
Chilam NG571c65a2013-01-19 12:27:36 +053018410 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
18411 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053018412#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053018413#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053018414}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018415#endif
18416
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018417#ifdef WLAN_FEATURE_GTK_OFFLOAD
18418/*
18419 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
18420 * Callback rountine called upon receiving response for
18421 * get offload info
18422 */
18423void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
18424 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
18425{
18426
18427 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018428 tANI_U8 tempReplayCounter[8];
18429 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018430
18431 ENTER();
18432
18433 if (NULL == pAdapter)
18434 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053018435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018436 "%s: HDD adapter is Null", __func__);
18437 return ;
18438 }
18439
18440 if (NULL == pGtkOffloadGetInfoRsp)
18441 {
18442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18443 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
18444 return ;
18445 }
18446
18447 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
18448 {
18449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18450 "%s: wlan Failed to get replay counter value",
18451 __func__);
18452 return ;
18453 }
18454
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018455 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18456 /* Update replay counter */
18457 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
18458 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18459
18460 {
18461 /* changing from little to big endian since supplicant
18462 * works on big endian format
18463 */
18464 int i;
18465 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
18466
18467 for (i = 0; i < 8; i++)
18468 {
18469 tempReplayCounter[7-i] = (tANI_U8)p[i];
18470 }
18471 }
18472
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018473 /* Update replay counter to NL */
18474 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018475 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018476}
18477
18478/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018479 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018480 * This function is used to offload GTK rekeying job to the firmware.
18481 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018482int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018483 struct cfg80211_gtk_rekey_data *data)
18484{
18485 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18486 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
18487 hdd_station_ctx_t *pHddStaCtx;
18488 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018489 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018490 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018491 eHalStatus status = eHAL_STATUS_FAILURE;
18492
18493 ENTER();
18494
18495 if (NULL == pAdapter)
18496 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053018497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018498 "%s: HDD adapter is Null", __func__);
18499 return -ENODEV;
18500 }
18501
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053018502 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18503 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
18504 pAdapter->sessionId, pAdapter->device_mode));
18505
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018506 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018507 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018508 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053018509 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018510 }
18511
18512 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18513 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
18514 if (NULL == hHal)
18515 {
18516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18517 "%s: HAL context is Null!!!", __func__);
18518 return -EAGAIN;
18519 }
18520
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018521 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
18522 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
18523 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
18524 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018525 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018526 {
18527 /* changing from big to little endian since driver
18528 * works on little endian format
18529 */
18530 tANI_U8 *p =
18531 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
18532 int i;
18533
18534 for (i = 0; i < 8; i++)
18535 {
18536 p[7-i] = data->replay_ctr[i];
18537 }
18538 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018539
18540 if (TRUE == pHddCtx->hdd_wlan_suspended)
18541 {
18542 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018543 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
18544 sizeof (tSirGtkOffloadParams));
18545 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018546 pAdapter->sessionId);
18547
18548 if (eHAL_STATUS_SUCCESS != status)
18549 {
18550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18551 "%s: sme_SetGTKOffload failed, returned %d",
18552 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018553
18554 /* Need to clear any trace of key value in the memory.
18555 * Thus zero out the memory even though it is local
18556 * variable.
18557 */
18558 vos_mem_zero(&hddGtkOffloadReqParams,
18559 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018560 return status;
18561 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18563 "%s: sme_SetGTKOffload successfull", __func__);
18564 }
18565 else
18566 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18568 "%s: wlan not suspended GTKOffload request is stored",
18569 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018570 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018571
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053018572 /* Need to clear any trace of key value in the memory.
18573 * Thus zero out the memory even though it is local
18574 * variable.
18575 */
18576 vos_mem_zero(&hddGtkOffloadReqParams,
18577 sizeof(hddGtkOffloadReqParams));
18578
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018579 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053018580 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018581}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053018582
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018583int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
18584 struct cfg80211_gtk_rekey_data *data)
18585{
18586 int ret;
18587
18588 vos_ssr_protect(__func__);
18589 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
18590 vos_ssr_unprotect(__func__);
18591
18592 return ret;
18593}
18594#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018595/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018596 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018597 * This function is used to set access control policy
18598 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018599static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18600 struct net_device *dev,
18601 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018602{
18603 int i;
18604 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18605 hdd_hostapd_state_t *pHostapdState;
18606 tsap_Config_t *pConfig;
18607 v_CONTEXT_t pVosContext = NULL;
18608 hdd_context_t *pHddCtx;
18609 int status;
18610
18611 ENTER();
18612
18613 if (NULL == pAdapter)
18614 {
18615 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18616 "%s: HDD adapter is Null", __func__);
18617 return -ENODEV;
18618 }
18619
18620 if (NULL == params)
18621 {
18622 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18623 "%s: params is Null", __func__);
18624 return -EINVAL;
18625 }
18626
18627 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18628 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018629 if (0 != status)
18630 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018631 return status;
18632 }
18633
18634 pVosContext = pHddCtx->pvosContext;
18635 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
18636
18637 if (NULL == pHostapdState)
18638 {
18639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18640 "%s: pHostapdState is Null", __func__);
18641 return -EINVAL;
18642 }
18643
18644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
18645 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018646 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18647 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
18648 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018649
18650 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
18651 {
18652 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
18653
18654 /* default value */
18655 pConfig->num_accept_mac = 0;
18656 pConfig->num_deny_mac = 0;
18657
18658 /**
18659 * access control policy
18660 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
18661 * listed in hostapd.deny file.
18662 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
18663 * listed in hostapd.accept file.
18664 */
18665 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
18666 {
18667 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
18668 }
18669 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
18670 {
18671 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
18672 }
18673 else
18674 {
18675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18676 "%s:Acl Policy : %d is not supported",
18677 __func__, params->acl_policy);
18678 return -ENOTSUPP;
18679 }
18680
18681 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
18682 {
18683 pConfig->num_accept_mac = params->n_acl_entries;
18684 for (i = 0; i < params->n_acl_entries; i++)
18685 {
18686 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18687 "** Add ACL MAC entry %i in WhiletList :"
18688 MAC_ADDRESS_STR, i,
18689 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18690
18691 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
18692 sizeof(qcmacaddr));
18693 }
18694 }
18695 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
18696 {
18697 pConfig->num_deny_mac = params->n_acl_entries;
18698 for (i = 0; i < params->n_acl_entries; i++)
18699 {
18700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18701 "** Add ACL MAC entry %i in BlackList :"
18702 MAC_ADDRESS_STR, i,
18703 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
18704
18705 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
18706 sizeof(qcmacaddr));
18707 }
18708 }
18709
18710 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
18711 {
18712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18713 "%s: SAP Set Mac Acl fail", __func__);
18714 return -EINVAL;
18715 }
18716 }
18717 else
18718 {
18719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053018720 "%s: Invalid device_mode = %s (%d)",
18721 __func__, hdd_device_modetoString(pAdapter->device_mode),
18722 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018723 return -EINVAL;
18724 }
18725
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018726 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053018727 return 0;
18728}
18729
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053018730static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
18731 struct net_device *dev,
18732 const struct cfg80211_acl_data *params)
18733{
18734 int ret;
18735 vos_ssr_protect(__func__);
18736 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
18737 vos_ssr_unprotect(__func__);
18738
18739 return ret;
18740}
18741
Leo Chang9056f462013-08-01 19:21:11 -070018742#ifdef WLAN_NL80211_TESTMODE
18743#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070018744void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070018745(
18746 void *pAdapter,
18747 void *indCont
18748)
18749{
Leo Changd9df8aa2013-09-26 13:32:26 -070018750 tSirLPHBInd *lphbInd;
18751 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053018752 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070018753
18754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018755 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070018756
c_hpothu73f35e62014-04-18 13:40:08 +053018757 if (pAdapter == NULL)
18758 {
18759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18760 "%s: pAdapter is NULL\n",__func__);
18761 return;
18762 }
18763
Leo Chang9056f462013-08-01 19:21:11 -070018764 if (NULL == indCont)
18765 {
18766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070018767 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070018768 return;
18769 }
18770
c_hpothu73f35e62014-04-18 13:40:08 +053018771 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070018772 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070018773 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053018774 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070018775 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070018776 GFP_ATOMIC);
18777 if (!skb)
18778 {
18779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18780 "LPHB timeout, NL buffer alloc fail");
18781 return;
18782 }
18783
Leo Changac3ba772013-10-07 09:47:04 -070018784 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070018785 {
18786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18787 "WLAN_HDD_TM_ATTR_CMD put fail");
18788 goto nla_put_failure;
18789 }
Leo Changac3ba772013-10-07 09:47:04 -070018790 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070018791 {
18792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18793 "WLAN_HDD_TM_ATTR_TYPE put fail");
18794 goto nla_put_failure;
18795 }
Leo Changac3ba772013-10-07 09:47:04 -070018796 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070018797 sizeof(tSirLPHBInd), lphbInd))
18798 {
18799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18800 "WLAN_HDD_TM_ATTR_DATA put fail");
18801 goto nla_put_failure;
18802 }
Leo Chang9056f462013-08-01 19:21:11 -070018803 cfg80211_testmode_event(skb, GFP_ATOMIC);
18804 return;
18805
18806nla_put_failure:
18807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18808 "NLA Put fail");
18809 kfree_skb(skb);
18810
18811 return;
18812}
18813#endif /* FEATURE_WLAN_LPHB */
18814
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018815static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070018816{
18817 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
18818 int err = 0;
18819#ifdef FEATURE_WLAN_LPHB
18820 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070018821 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018822
18823 ENTER();
18824
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018825 err = wlan_hdd_validate_context(pHddCtx);
18826 if (0 != err)
18827 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053018828 return err;
18829 }
Leo Chang9056f462013-08-01 19:21:11 -070018830#endif /* FEATURE_WLAN_LPHB */
18831
18832 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
18833 if (err)
18834 {
18835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18836 "%s Testmode INV ATTR", __func__);
18837 return err;
18838 }
18839
18840 if (!tb[WLAN_HDD_TM_ATTR_CMD])
18841 {
18842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18843 "%s Testmode INV CMD", __func__);
18844 return -EINVAL;
18845 }
18846
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018847 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18848 TRACE_CODE_HDD_CFG80211_TESTMODE,
18849 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070018850 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
18851 {
18852#ifdef FEATURE_WLAN_LPHB
18853 /* Low Power Heartbeat configuration request */
18854 case WLAN_HDD_TM_CMD_WLAN_HB:
18855 {
18856 int buf_len;
18857 void *buf;
18858 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080018859 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070018860
18861 if (!tb[WLAN_HDD_TM_ATTR_DATA])
18862 {
18863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18864 "%s Testmode INV DATA", __func__);
18865 return -EINVAL;
18866 }
18867
18868 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
18869 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080018870
18871 hb_params_temp =(tSirLPHBReq *)buf;
18872 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
18873 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
18874 return -EINVAL;
18875
Leo Chang9056f462013-08-01 19:21:11 -070018876 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
18877 if (NULL == hb_params)
18878 {
18879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18880 "%s Request Buffer Alloc Fail", __func__);
18881 return -EINVAL;
18882 }
18883
18884 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070018885 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
18886 hb_params,
18887 wlan_hdd_cfg80211_lphb_ind_handler);
18888 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070018889 {
Leo Changd9df8aa2013-09-26 13:32:26 -070018890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18891 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070018892 vos_mem_free(hb_params);
18893 }
Leo Chang9056f462013-08-01 19:21:11 -070018894 return 0;
18895 }
18896#endif /* FEATURE_WLAN_LPHB */
18897 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053018898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
18899 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070018900 return -EOPNOTSUPP;
18901 }
18902
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053018903 EXIT();
18904 return err;
Leo Chang9056f462013-08-01 19:21:11 -070018905}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018906
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053018907static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
18908#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
18909 struct wireless_dev *wdev,
18910#endif
18911 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018912{
18913 int ret;
18914
18915 vos_ssr_protect(__func__);
18916 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
18917 vos_ssr_unprotect(__func__);
18918
18919 return ret;
18920}
Leo Chang9056f462013-08-01 19:21:11 -070018921#endif /* CONFIG_NL80211_TESTMODE */
18922
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053018923static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018924 struct net_device *dev,
18925 int idx, struct survey_info *survey)
18926{
18927 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
18928 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053018929 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018930 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053018931 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018932 v_S7_t snr,rssi;
18933 int status, i, j, filled = 0;
18934
18935 ENTER();
18936
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018937 if (NULL == pAdapter)
18938 {
18939 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18940 "%s: HDD adapter is Null", __func__);
18941 return -ENODEV;
18942 }
18943
18944 if (NULL == wiphy)
18945 {
18946 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
18947 "%s: wiphy is Null", __func__);
18948 return -ENODEV;
18949 }
18950
18951 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
18952 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018953 if (0 != status)
18954 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018955 return status;
18956 }
18957
Mihir Sheted9072e02013-08-21 17:02:29 +053018958 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
18959
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018960 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053018961 0 != pAdapter->survey_idx ||
18962 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018963 {
18964 /* The survey dump ops when implemented completely is expected to
18965 * return a survey of all channels and the ops is called by the
18966 * kernel with incremental values of the argument 'idx' till it
18967 * returns -ENONET. But we can only support the survey for the
18968 * operating channel for now. survey_idx is used to track
18969 * that the ops is called only once and then return -ENONET for
18970 * the next iteration
18971 */
18972 pAdapter->survey_idx = 0;
18973 return -ENONET;
18974 }
18975
Mukul Sharma9d5233b2015-06-11 20:28:20 +053018976 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
18977 {
18978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
18979 "%s: Roaming in progress, hence return ", __func__);
18980 return -ENONET;
18981 }
18982
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018983 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
18984
18985 wlan_hdd_get_snr(pAdapter, &snr);
18986 wlan_hdd_get_rssi(pAdapter, &rssi);
18987
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053018988 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
18989 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
18990 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053018991 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
18992 hdd_wlan_get_freq(channel, &freq);
18993
18994
18995 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
18996 {
18997 if (NULL == wiphy->bands[i])
18998 {
18999 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
19000 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
19001 continue;
19002 }
19003
19004 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
19005 {
19006 struct ieee80211_supported_band *band = wiphy->bands[i];
19007
19008 if (band->channels[j].center_freq == (v_U16_t)freq)
19009 {
19010 survey->channel = &band->channels[j];
19011 /* The Rx BDs contain SNR values in dB for the received frames
19012 * while the supplicant expects noise. So we calculate and
19013 * return the value of noise (dBm)
19014 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
19015 */
19016 survey->noise = rssi - snr;
19017 survey->filled = SURVEY_INFO_NOISE_DBM;
19018 filled = 1;
19019 }
19020 }
19021 }
19022
19023 if (filled)
19024 pAdapter->survey_idx = 1;
19025 else
19026 {
19027 pAdapter->survey_idx = 0;
19028 return -ENONET;
19029 }
19030
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019031 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019032 return 0;
19033}
19034
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053019035static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
19036 struct net_device *dev,
19037 int idx, struct survey_info *survey)
19038{
19039 int ret;
19040
19041 vos_ssr_protect(__func__);
19042 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
19043 vos_ssr_unprotect(__func__);
19044
19045 return ret;
19046}
19047
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019048/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019049 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019050 * this is called when cfg80211 driver resume
19051 * driver updates latest sched_scan scan result(if any) to cfg80211 database
19052 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019053int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019054{
19055 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
19056 hdd_adapter_t *pAdapter;
19057 hdd_adapter_list_node_t *pAdapterNode, *pNext;
19058 VOS_STATUS status = VOS_STATUS_SUCCESS;
19059
19060 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019061
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053019062 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019063 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019064 return 0;
19065 }
19066
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019067 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
19068 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019069 spin_lock(&pHddCtx->schedScan_lock);
19070 pHddCtx->isWiphySuspended = FALSE;
19071 if (TRUE != pHddCtx->isSchedScanUpdatePending)
19072 {
19073 spin_unlock(&pHddCtx->schedScan_lock);
19074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19075 "%s: Return resume is not due to PNO indication", __func__);
19076 return 0;
19077 }
19078 // Reset flag to avoid updatating cfg80211 data old results again
19079 pHddCtx->isSchedScanUpdatePending = FALSE;
19080 spin_unlock(&pHddCtx->schedScan_lock);
19081
19082 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
19083
19084 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
19085 {
19086 pAdapter = pAdapterNode->pAdapter;
19087 if ( (NULL != pAdapter) &&
19088 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
19089 {
19090 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019091 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
19093 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019094 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019095 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019096 {
19097 /* Acquire wakelock to handle the case where APP's tries to
19098 * suspend immediately after updating the scan results. Whis
19099 * results in app's is in suspended state and not able to
19100 * process the connect request to AP
19101 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053019102 hdd_prevent_suspend_timeout(2000,
19103 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019104 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053019105 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019106
19107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19108 "%s : cfg80211 scan result database updated", __func__);
19109
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019110 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019111 return 0;
19112
19113 }
19114 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
19115 pAdapterNode = pNext;
19116 }
19117
19118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
19119 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019120 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019121 return 0;
19122}
19123
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019124int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
19125{
19126 int ret;
19127
19128 vos_ssr_protect(__func__);
19129 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
19130 vos_ssr_unprotect(__func__);
19131
19132 return ret;
19133}
19134
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019135/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019136 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019137 * this is called when cfg80211 driver suspends
19138 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019139int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019140 struct cfg80211_wowlan *wow)
19141{
19142 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019143 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019144
19145 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053019146
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019147 ret = wlan_hdd_validate_context(pHddCtx);
19148 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019149 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019150 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019151 }
19152
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053019153
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053019154 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
19155 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
19156 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019157 pHddCtx->isWiphySuspended = TRUE;
19158
19159 EXIT();
19160
19161 return 0;
19162}
19163
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053019164int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
19165 struct cfg80211_wowlan *wow)
19166{
19167 int ret;
19168
19169 vos_ssr_protect(__func__);
19170 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
19171 vos_ssr_unprotect(__func__);
19172
19173 return ret;
19174}
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +053019175
19176#ifdef FEATURE_OEM_DATA_SUPPORT
19177static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx,
19178 void *pMsg)
19179{
19180 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19181
19182 ENTER();
19183
19184 if (wlan_hdd_validate_context(pHddCtx)) {
19185 return;
19186 }
19187 if (!pMsg)
19188 {
19189 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
19190 return;
19191 }
19192
19193 send_oem_data_rsp_msg(sizeof(tOemDataRspNew), pMsg);
19194
19195 EXIT();
19196 return;
19197
19198}
19199
19200void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType,
19201 void *pMsg)
19202{
19203 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
19204
19205 ENTER();
19206
19207 if (wlan_hdd_validate_context(pHddCtx)) {
19208 return;
19209 }
19210
19211 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
19212
19213 switch(evType) {
19214 case SIR_HAL_START_OEM_DATA_RSP_IND_NEW:
19215 wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg);
19216 break;
19217 default:
19218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
19219 break;
19220 }
19221 EXIT();
19222}
19223#endif
19224
Jeff Johnson295189b2012-06-20 16:38:30 -070019225/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053019226static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070019227{
19228 .add_virtual_intf = wlan_hdd_add_virtual_intf,
19229 .del_virtual_intf = wlan_hdd_del_virtual_intf,
19230 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
19231 .change_station = wlan_hdd_change_station,
19232#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
19233 .add_beacon = wlan_hdd_cfg80211_add_beacon,
19234 .del_beacon = wlan_hdd_cfg80211_del_beacon,
19235 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019236#else
19237 .start_ap = wlan_hdd_cfg80211_start_ap,
19238 .change_beacon = wlan_hdd_cfg80211_change_beacon,
19239 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070019240#endif
19241 .change_bss = wlan_hdd_cfg80211_change_bss,
19242 .add_key = wlan_hdd_cfg80211_add_key,
19243 .get_key = wlan_hdd_cfg80211_get_key,
19244 .del_key = wlan_hdd_cfg80211_del_key,
19245 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019246#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070019247 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080019248#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019249 .scan = wlan_hdd_cfg80211_scan,
19250 .connect = wlan_hdd_cfg80211_connect,
19251 .disconnect = wlan_hdd_cfg80211_disconnect,
19252 .join_ibss = wlan_hdd_cfg80211_join_ibss,
19253 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
19254 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
19255 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
19256 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070019257 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
19258 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053019259 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070019260#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
19261 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
19262 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
19263 .set_txq_params = wlan_hdd_set_txq_params,
19264#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019265 .get_station = wlan_hdd_cfg80211_get_station,
19266 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
19267 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019268 .add_station = wlan_hdd_cfg80211_add_station,
19269#ifdef FEATURE_WLAN_LFR
19270 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
19271 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
19272 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
19273#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070019274#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
19275 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
19276#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080019277#ifdef FEATURE_WLAN_TDLS
19278 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
19279 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
19280#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053019281#ifdef WLAN_FEATURE_GTK_OFFLOAD
19282 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
19283#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053019284#ifdef FEATURE_WLAN_SCAN_PNO
19285 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
19286 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
19287#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053019288 .resume = wlan_hdd_cfg80211_resume_wlan,
19289 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053019290 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070019291#ifdef WLAN_NL80211_TESTMODE
19292 .testmode_cmd = wlan_hdd_cfg80211_testmode,
19293#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053019294 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070019295};
19296