blob: 9eadffe521f1281570d4ac3404fa04f90e3b788c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 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#ifdef FEATURE_WLAN_TDLS
94#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053095#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053096#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080097#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053098#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070099#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700100
101#define g_mode_rates_size (12)
102#define a_mode_rates_size (8)
103#define FREQ_BASE_80211G (2407)
104#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700105#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530106#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800108 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110#define HDD2GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_2GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD5GHZCHAN(freq, chan, flag) { \
120 .band = IEEE80211_BAND_5GHZ, \
121 .center_freq = (freq), \
122 .hw_value = (chan),\
123 .flags = (flag), \
124 .max_antenna_gain = 0 ,\
125 .max_power = 30, \
126}
127
128#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
129{\
130 .bitrate = rate, \
131 .hw_value = rate_id, \
132 .flags = flag, \
133}
134
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530135#ifdef WLAN_FEATURE_VOWIFI_11R
136#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
137#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
138#endif
139
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530141#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530142
Sunil Duttc69bccb2014-05-26 21:30:20 +0530143#ifdef WLAN_FEATURE_LINK_LAYER_STATS
144/*
145 * Used to allocate the size of 4096 for the link layer stats.
146 * The size of 4096 is considered assuming that all data per
147 * respective event fit with in the limit.Please take a call
148 * on the limit based on the data requirements on link layer
149 * statistics.
150 */
151#define LL_STATS_EVENT_BUF_SIZE 4096
152#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530153#ifdef WLAN_FEATURE_EXTSCAN
154/*
155 * Used to allocate the size of 4096 for the EXTScan NL data.
156 * The size of 4096 is considered assuming that all data per
157 * respective event fit with in the limit.Please take a call
158 * on the limit based on the data requirements.
159 */
160
161#define EXTSCAN_EVENT_BUF_SIZE 4096
162#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
163#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530164
Atul Mittal115287b2014-07-08 13:26:33 +0530165/*EXT TDLS*/
166/*
167 * Used to allocate the size of 4096 for the TDLS.
168 * The size of 4096 is considered assuming that all data per
169 * respective event fit with in the limit.Please take a call
170 * on the limit based on the data requirements on link layer
171 * statistics.
172 */
173#define EXTTDLS_EVENT_BUF_SIZE 4096
174
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530175static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700176{
177 WLAN_CIPHER_SUITE_WEP40,
178 WLAN_CIPHER_SUITE_WEP104,
179 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800180#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700181#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
182 WLAN_CIPHER_SUITE_KRK,
183 WLAN_CIPHER_SUITE_CCMP,
184#else
185 WLAN_CIPHER_SUITE_CCMP,
186#endif
187#ifdef FEATURE_WLAN_WAPI
188 WLAN_CIPHER_SUITE_SMS4,
189#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700190#ifdef WLAN_FEATURE_11W
191 WLAN_CIPHER_SUITE_AES_CMAC,
192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700193};
194
195static inline int is_broadcast_ether_addr(const u8 *addr)
196{
197 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
198 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
199}
200
201static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530202{
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 HDD2GHZCHAN(2412, 1, 0) ,
204 HDD2GHZCHAN(2417, 2, 0) ,
205 HDD2GHZCHAN(2422, 3, 0) ,
206 HDD2GHZCHAN(2427, 4, 0) ,
207 HDD2GHZCHAN(2432, 5, 0) ,
208 HDD2GHZCHAN(2437, 6, 0) ,
209 HDD2GHZCHAN(2442, 7, 0) ,
210 HDD2GHZCHAN(2447, 8, 0) ,
211 HDD2GHZCHAN(2452, 9, 0) ,
212 HDD2GHZCHAN(2457, 10, 0) ,
213 HDD2GHZCHAN(2462, 11, 0) ,
214 HDD2GHZCHAN(2467, 12, 0) ,
215 HDD2GHZCHAN(2472, 13, 0) ,
216 HDD2GHZCHAN(2484, 14, 0) ,
217};
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
220{
221 HDD2GHZCHAN(2412, 1, 0) ,
222 HDD2GHZCHAN(2437, 6, 0) ,
223 HDD2GHZCHAN(2462, 11, 0) ,
224};
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
226static struct ieee80211_channel hdd_channels_5_GHZ[] =
227{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700228 HDD5GHZCHAN(4920, 240, 0) ,
229 HDD5GHZCHAN(4940, 244, 0) ,
230 HDD5GHZCHAN(4960, 248, 0) ,
231 HDD5GHZCHAN(4980, 252, 0) ,
232 HDD5GHZCHAN(5040, 208, 0) ,
233 HDD5GHZCHAN(5060, 212, 0) ,
234 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 HDD5GHZCHAN(5180, 36, 0) ,
236 HDD5GHZCHAN(5200, 40, 0) ,
237 HDD5GHZCHAN(5220, 44, 0) ,
238 HDD5GHZCHAN(5240, 48, 0) ,
239 HDD5GHZCHAN(5260, 52, 0) ,
240 HDD5GHZCHAN(5280, 56, 0) ,
241 HDD5GHZCHAN(5300, 60, 0) ,
242 HDD5GHZCHAN(5320, 64, 0) ,
243 HDD5GHZCHAN(5500,100, 0) ,
244 HDD5GHZCHAN(5520,104, 0) ,
245 HDD5GHZCHAN(5540,108, 0) ,
246 HDD5GHZCHAN(5560,112, 0) ,
247 HDD5GHZCHAN(5580,116, 0) ,
248 HDD5GHZCHAN(5600,120, 0) ,
249 HDD5GHZCHAN(5620,124, 0) ,
250 HDD5GHZCHAN(5640,128, 0) ,
251 HDD5GHZCHAN(5660,132, 0) ,
252 HDD5GHZCHAN(5680,136, 0) ,
253 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800254#ifdef FEATURE_WLAN_CH144
255 HDD5GHZCHAN(5720,144, 0) ,
256#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 HDD5GHZCHAN(5745,149, 0) ,
258 HDD5GHZCHAN(5765,153, 0) ,
259 HDD5GHZCHAN(5785,157, 0) ,
260 HDD5GHZCHAN(5805,161, 0) ,
261 HDD5GHZCHAN(5825,165, 0) ,
262};
263
264static struct ieee80211_rate g_mode_rates[] =
265{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530266 HDD_G_MODE_RATETAB(10, 0x1, 0),
267 HDD_G_MODE_RATETAB(20, 0x2, 0),
268 HDD_G_MODE_RATETAB(55, 0x4, 0),
269 HDD_G_MODE_RATETAB(110, 0x8, 0),
270 HDD_G_MODE_RATETAB(60, 0x10, 0),
271 HDD_G_MODE_RATETAB(90, 0x20, 0),
272 HDD_G_MODE_RATETAB(120, 0x40, 0),
273 HDD_G_MODE_RATETAB(180, 0x80, 0),
274 HDD_G_MODE_RATETAB(240, 0x100, 0),
275 HDD_G_MODE_RATETAB(360, 0x200, 0),
276 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530278};
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280static struct ieee80211_rate a_mode_rates[] =
281{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530282 HDD_G_MODE_RATETAB(60, 0x10, 0),
283 HDD_G_MODE_RATETAB(90, 0x20, 0),
284 HDD_G_MODE_RATETAB(120, 0x40, 0),
285 HDD_G_MODE_RATETAB(180, 0x80, 0),
286 HDD_G_MODE_RATETAB(240, 0x100, 0),
287 HDD_G_MODE_RATETAB(360, 0x200, 0),
288 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 HDD_G_MODE_RATETAB(540, 0x800, 0),
290};
291
292static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
293{
294 .channels = hdd_channels_2_4_GHZ,
295 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
296 .band = IEEE80211_BAND_2GHZ,
297 .bitrates = g_mode_rates,
298 .n_bitrates = g_mode_rates_size,
299 .ht_cap.ht_supported = 1,
300 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
301 | IEEE80211_HT_CAP_GRN_FLD
302 | IEEE80211_HT_CAP_DSSSCCK40
303 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
304 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
305 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
306 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
307 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
308 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
309};
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
312{
313 .channels = hdd_social_channels_2_4_GHZ,
314 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
315 .band = IEEE80211_BAND_2GHZ,
316 .bitrates = g_mode_rates,
317 .n_bitrates = g_mode_rates_size,
318 .ht_cap.ht_supported = 1,
319 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
320 | IEEE80211_HT_CAP_GRN_FLD
321 | IEEE80211_HT_CAP_DSSSCCK40
322 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
323 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
324 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
325 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
326 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
327 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
328};
Jeff Johnson295189b2012-06-20 16:38:30 -0700329
330static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
331{
332 .channels = hdd_channels_5_GHZ,
333 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
334 .band = IEEE80211_BAND_5GHZ,
335 .bitrates = a_mode_rates,
336 .n_bitrates = a_mode_rates_size,
337 .ht_cap.ht_supported = 1,
338 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
339 | IEEE80211_HT_CAP_GRN_FLD
340 | IEEE80211_HT_CAP_DSSSCCK40
341 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
342 | IEEE80211_HT_CAP_SGI_40
343 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
344 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
345 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
346 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
347 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
348 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
349};
350
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530351/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 TX/RX direction for each kind of interface */
353static const struct ieee80211_txrx_stypes
354wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
355 [NL80211_IFTYPE_STATION] = {
356 .tx = 0xffff,
357 .rx = BIT(SIR_MAC_MGMT_ACTION) |
358 BIT(SIR_MAC_MGMT_PROBE_REQ),
359 },
360 [NL80211_IFTYPE_AP] = {
361 .tx = 0xffff,
362 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
363 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
364 BIT(SIR_MAC_MGMT_PROBE_REQ) |
365 BIT(SIR_MAC_MGMT_DISASSOC) |
366 BIT(SIR_MAC_MGMT_AUTH) |
367 BIT(SIR_MAC_MGMT_DEAUTH) |
368 BIT(SIR_MAC_MGMT_ACTION),
369 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700370 [NL80211_IFTYPE_ADHOC] = {
371 .tx = 0xffff,
372 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
373 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
374 BIT(SIR_MAC_MGMT_PROBE_REQ) |
375 BIT(SIR_MAC_MGMT_DISASSOC) |
376 BIT(SIR_MAC_MGMT_AUTH) |
377 BIT(SIR_MAC_MGMT_DEAUTH) |
378 BIT(SIR_MAC_MGMT_ACTION),
379 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 [NL80211_IFTYPE_P2P_CLIENT] = {
381 .tx = 0xffff,
382 .rx = BIT(SIR_MAC_MGMT_ACTION) |
383 BIT(SIR_MAC_MGMT_PROBE_REQ),
384 },
385 [NL80211_IFTYPE_P2P_GO] = {
386 /* This is also same as for SoftAP */
387 .tx = 0xffff,
388 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
389 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
390 BIT(SIR_MAC_MGMT_PROBE_REQ) |
391 BIT(SIR_MAC_MGMT_DISASSOC) |
392 BIT(SIR_MAC_MGMT_AUTH) |
393 BIT(SIR_MAC_MGMT_DEAUTH) |
394 BIT(SIR_MAC_MGMT_ACTION),
395 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700396};
397
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800398#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800399static const struct ieee80211_iface_limit
400wlan_hdd_iface_limit[] = {
401 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800402 /* max = 3 ; Our driver create two interfaces during driver init
403 * wlan0 and p2p0 interfaces. p2p0 is considered as station
404 * interface until a group is formed. In JB architecture, once the
405 * group is formed, interface type of p2p0 is changed to P2P GO or
406 * Client.
407 * When supplicant remove the group, it first issue a set interface
408 * cmd to change the mode back to Station. In JB this works fine as
409 * we advertize two station type interface during driver init.
410 * Some vendors create separate interface for P2P GO/Client,
411 * after group formation(Third one). But while group remove
412 * supplicant first tries to change the mode(3rd interface) to STATION
413 * But as we advertized only two sta type interfaces nl80211 was
414 * returning error for the third one which was leading to failure in
415 * delete interface. Ideally while removing the group, supplicant
416 * should not try to change the 3rd interface mode to Station type.
417 * Till we get a fix in wpa_supplicant, we advertize max STA
418 * interface type to 3
419 */
420 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800421 .types = BIT(NL80211_IFTYPE_STATION),
422 },
423 {
424 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700425 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800426 },
427 {
428 .max = 1,
429 .types = BIT(NL80211_IFTYPE_P2P_GO) |
430 BIT(NL80211_IFTYPE_P2P_CLIENT),
431 },
432};
433
434/* By default, only single channel concurrency is allowed */
435static struct ieee80211_iface_combination
436wlan_hdd_iface_combination = {
437 .limits = wlan_hdd_iface_limit,
438 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800439 /*
440 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
441 * and p2p0 interfaces during driver init
442 * Some vendors create separate interface for P2P operations.
443 * wlan0: STA interface
444 * p2p0: P2P Device interface, action frames goes
445 * through this interface.
446 * p2p-xx: P2P interface, After GO negotiation this interface is
447 * created for p2p operations(GO/CLIENT interface).
448 */
449 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800450 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
451 .beacon_int_infra_match = false,
452};
453#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455static struct cfg80211_ops wlan_hdd_cfg80211_ops;
456
457/* Data rate 100KBPS based on IE Index */
458struct index_data_rate_type
459{
460 v_U8_t beacon_rate_index;
461 v_U16_t supported_rate[4];
462};
463
464/* 11B, 11G Rate table include Basic rate and Extended rate
465 The IDX field is the rate index
466 The HI field is the rate when RSSI is strong or being ignored
467 (in this case we report actual rate)
468 The MID field is the rate when RSSI is moderate
469 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
470 The LO field is the rate when RSSI is low
471 (in this case we don't report rates, actual current rate used)
472 */
473static const struct
474{
475 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700476 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700477} supported_data_rate[] =
478{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700479/* IDX HI HM LM LO (RSSI-based index */
480 {2, { 10, 10, 10, 0}},
481 {4, { 20, 20, 10, 0}},
482 {11, { 55, 20, 10, 0}},
483 {12, { 60, 55, 20, 0}},
484 {18, { 90, 55, 20, 0}},
485 {22, {110, 55, 20, 0}},
486 {24, {120, 90, 60, 0}},
487 {36, {180, 120, 60, 0}},
488 {44, {220, 180, 60, 0}},
489 {48, {240, 180, 90, 0}},
490 {66, {330, 180, 90, 0}},
491 {72, {360, 240, 90, 0}},
492 {96, {480, 240, 120, 0}},
493 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700494};
495
496/* MCS Based rate table */
497static struct index_data_rate_type supported_mcs_rate[] =
498{
499/* MCS L20 L40 S20 S40 */
500 {0, {65, 135, 72, 150}},
501 {1, {130, 270, 144, 300}},
502 {2, {195, 405, 217, 450}},
503 {3, {260, 540, 289, 600}},
504 {4, {390, 810, 433, 900}},
505 {5, {520, 1080, 578, 1200}},
506 {6, {585, 1215, 650, 1350}},
507 {7, {650, 1350, 722, 1500}}
508};
509
Leo Chang6f8870f2013-03-26 18:11:36 -0700510#ifdef WLAN_FEATURE_11AC
511
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530512#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700513
514struct index_vht_data_rate_type
515{
516 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530517 v_U16_t supported_VHT80_rate[2];
518 v_U16_t supported_VHT40_rate[2];
519 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700520};
521
522typedef enum
523{
524 DATA_RATE_11AC_MAX_MCS_7,
525 DATA_RATE_11AC_MAX_MCS_8,
526 DATA_RATE_11AC_MAX_MCS_9,
527 DATA_RATE_11AC_MAX_MCS_NA
528} eDataRate11ACMaxMcs;
529
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530530/* SSID broadcast type */
531typedef enum eSSIDBcastType
532{
533 eBCAST_UNKNOWN = 0,
534 eBCAST_NORMAL = 1,
535 eBCAST_HIDDEN = 2,
536} tSSIDBcastType;
537
Leo Chang6f8870f2013-03-26 18:11:36 -0700538/* MCS Based VHT rate table */
539static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
540{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530541/* MCS L80 S80 L40 S40 L20 S40*/
542 {0, {293, 325}, {135, 150}, {65, 72}},
543 {1, {585, 650}, {270, 300}, {130, 144}},
544 {2, {878, 975}, {405, 450}, {195, 217}},
545 {3, {1170, 1300}, {540, 600}, {260, 289}},
546 {4, {1755, 1950}, {810, 900}, {390, 433}},
547 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
548 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
549 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
550 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
551 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700552};
553#endif /* WLAN_FEATURE_11AC */
554
c_hpothu79aab322014-07-14 21:11:01 +0530555/*array index points to MCS and array value points respective rssi*/
556static int rssiMcsTbl[][10] =
557{
558/*MCS 0 1 2 3 4 5 6 7 8 9*/
559 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
560 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
561 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
562};
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530565#ifdef FEATURE_WLAN_SCAN_PNO
566static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
567#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700568
Leo Chang9056f462013-08-01 19:21:11 -0700569#ifdef WLAN_NL80211_TESTMODE
570enum wlan_hdd_tm_attr
571{
572 WLAN_HDD_TM_ATTR_INVALID = 0,
573 WLAN_HDD_TM_ATTR_CMD = 1,
574 WLAN_HDD_TM_ATTR_DATA = 2,
575 WLAN_HDD_TM_ATTR_TYPE = 3,
576 /* keep last */
577 WLAN_HDD_TM_ATTR_AFTER_LAST,
578 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
579};
580
581enum wlan_hdd_tm_cmd
582{
583 WLAN_HDD_TM_CMD_WLAN_HB = 1,
584};
585
586#define WLAN_HDD_TM_DATA_MAX_LEN 5000
587
588static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
589{
590 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
591 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
592 .len = WLAN_HDD_TM_DATA_MAX_LEN },
593};
594#endif /* WLAN_NL80211_TESTMODE */
595
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800596#ifdef FEATURE_WLAN_CH_AVOID
597/*
598 * FUNCTION: wlan_hdd_send_avoid_freq_event
599 * This is called when wlan driver needs to send vendor specific
600 * avoid frequency range event to userspace
601 */
602int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
603 tHddAvoidFreqList *pAvoidFreqList)
604{
605 struct sk_buff *vendor_event;
606
607 ENTER();
608
609 if (!pHddCtx)
610 {
611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
612 "%s: HDD context is null", __func__);
613 return -1;
614 }
615
616 if (!pAvoidFreqList)
617 {
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
619 "%s: pAvoidFreqList is null", __func__);
620 return -1;
621 }
622
623 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
624 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530625 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800626 GFP_KERNEL);
627 if (!vendor_event)
628 {
629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
630 "%s: cfg80211_vendor_event_alloc failed", __func__);
631 return -1;
632 }
633
634 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
635 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
636
637 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
638
639 EXIT();
640 return 0;
641}
642#endif /* FEATURE_WLAN_CH_AVOID */
643
Srinivas Dasari030bad32015-02-18 23:23:54 +0530644/*
645 * FUNCTION: __wlan_hdd_cfg80211_nan_request
646 * This is called when wlan driver needs to send vendor specific
647 * nan request event.
648 */
649static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
650 struct wireless_dev *wdev,
651 const void *data, int data_len)
652{
653 tNanRequestReq nan_req;
654 VOS_STATUS status;
655 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530656 struct net_device *dev = wdev->netdev;
657 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
658 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530659 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
660
661 if (0 == data_len)
662 {
663 hddLog(VOS_TRACE_LEVEL_ERROR,
664 FL("NAN - Invalid Request, length = 0"));
665 return ret_val;
666 }
667
668 if (NULL == data)
669 {
670 hddLog(VOS_TRACE_LEVEL_ERROR,
671 FL("NAN - Invalid Request, data is NULL"));
672 return ret_val;
673 }
674
675 status = wlan_hdd_validate_context(pHddCtx);
676 if (0 != status)
677 {
678 hddLog(VOS_TRACE_LEVEL_ERROR,
679 FL("HDD context is not valid"));
680 return -EINVAL;
681 }
682
683 hddLog(LOG1, FL("Received NAN command"));
684 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
685 (tANI_U8 *)data, data_len);
686
687 /* check the NAN Capability */
688 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
689 {
690 hddLog(VOS_TRACE_LEVEL_ERROR,
691 FL("NAN is not supported by Firmware"));
692 return -EINVAL;
693 }
694
695 nan_req.request_data_len = data_len;
696 nan_req.request_data = data;
697
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530698 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530699 if (VOS_STATUS_SUCCESS == status)
700 {
701 ret_val = 0;
702 }
703 return ret_val;
704}
705
706/*
707 * FUNCTION: wlan_hdd_cfg80211_nan_request
708 * Wrapper to protect the nan vendor command from ssr
709 */
710static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
711 struct wireless_dev *wdev,
712 const void *data, int data_len)
713{
714 int ret;
715
716 vos_ssr_protect(__func__);
717 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
718 vos_ssr_unprotect(__func__);
719
720 return ret;
721}
722
723/*
724 * FUNCTION: wlan_hdd_cfg80211_nan_callback
725 * This is a callback function and it gets called
726 * when we need to report nan response event to
727 * upper layers.
728 */
729static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
730{
731 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
732 struct sk_buff *vendor_event;
733 int status;
734 tSirNanEvent *data;
735
736 ENTER();
737 if (NULL == msg)
738 {
739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
740 FL(" msg received here is null"));
741 return;
742 }
743 data = msg;
744
745 status = wlan_hdd_validate_context(pHddCtx);
746
747 if (0 != status)
748 {
749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
750 FL("HDD context is not valid"));
751 return;
752 }
753
754 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
755 data->event_data_len +
756 NLMSG_HDRLEN,
757 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
758 GFP_KERNEL);
759
760 if (!vendor_event)
761 {
762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
763 FL("cfg80211_vendor_event_alloc failed"));
764 return;
765 }
766 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
767 data->event_data_len, data->event_data))
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
771 kfree_skb(vendor_event);
772 return;
773 }
774 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
775 EXIT();
776}
777
778/*
779 * FUNCTION: wlan_hdd_cfg80211_nan_init
780 * This function is called to register the callback to sme layer
781 */
782inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
783{
784 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
785}
786
787
Sunil Duttc69bccb2014-05-26 21:30:20 +0530788#ifdef WLAN_FEATURE_LINK_LAYER_STATS
789
790static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
791 struct sk_buff *vendor_event)
792{
793 if (nla_put_u8(vendor_event,
794 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
795 stats->rate.preamble) ||
796 nla_put_u8(vendor_event,
797 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
798 stats->rate.nss) ||
799 nla_put_u8(vendor_event,
800 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
801 stats->rate.bw) ||
802 nla_put_u8(vendor_event,
803 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
804 stats->rate.rateMcsIdx) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
806 stats->rate.bitrate ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
808 stats->txMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
810 stats->rxMpdu ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
812 stats->mpduLost ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
814 stats->retries) ||
815 nla_put_u32(vendor_event,
816 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
817 stats->retriesShort ) ||
818 nla_put_u32(vendor_event,
819 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
820 stats->retriesLong))
821 {
822 hddLog(VOS_TRACE_LEVEL_ERROR,
823 FL("QCA_WLAN_VENDOR_ATTR put fail"));
824 return FALSE;
825 }
826 return TRUE;
827}
828
829static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
830 struct sk_buff *vendor_event)
831{
832 u32 i = 0;
833 struct nlattr *rateInfo;
834 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
835 stats->type) ||
836 nla_put(vendor_event,
837 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
838 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
839 nla_put_u32(vendor_event,
840 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
841 stats->capabilities) ||
842 nla_put_u32(vendor_event,
843 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
844 stats->numRate))
845 {
846 hddLog(VOS_TRACE_LEVEL_ERROR,
847 FL("QCA_WLAN_VENDOR_ATTR put fail"));
848 goto error;
849 }
850
851 rateInfo = nla_nest_start(vendor_event,
852 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530853 if(!rateInfo)
854 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530855 for (i = 0; i < stats->numRate; i++)
856 {
857 struct nlattr *rates;
858 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
859 stats->rateStats +
860 (i * sizeof(tSirWifiRateStat)));
861 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530862 if(!rates)
863 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530864
865 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
866 {
867 hddLog(VOS_TRACE_LEVEL_ERROR,
868 FL("QCA_WLAN_VENDOR_ATTR put fail"));
869 return FALSE;
870 }
871 nla_nest_end(vendor_event, rates);
872 }
873 nla_nest_end(vendor_event, rateInfo);
874
875 return TRUE;
876error:
877 return FALSE;
878}
879
880static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
881 struct sk_buff *vendor_event)
882{
883 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
884 stats->ac ) ||
885 nla_put_u32(vendor_event,
886 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
887 stats->txMpdu ) ||
888 nla_put_u32(vendor_event,
889 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
890 stats->rxMpdu ) ||
891 nla_put_u32(vendor_event,
892 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
893 stats->txMcast ) ||
894 nla_put_u32(vendor_event,
895 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
896 stats->rxMcast ) ||
897 nla_put_u32(vendor_event,
898 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
899 stats->rxAmpdu ) ||
900 nla_put_u32(vendor_event,
901 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
902 stats->txAmpdu ) ||
903 nla_put_u32(vendor_event,
904 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
905 stats->mpduLost )||
906 nla_put_u32(vendor_event,
907 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
908 stats->retries ) ||
909 nla_put_u32(vendor_event,
910 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
911 stats->retriesShort ) ||
912 nla_put_u32(vendor_event,
913 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
914 stats->retriesLong ) ||
915 nla_put_u32(vendor_event,
916 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
917 stats->contentionTimeMin ) ||
918 nla_put_u32(vendor_event,
919 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
920 stats->contentionTimeMax ) ||
921 nla_put_u32(vendor_event,
922 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
923 stats->contentionTimeAvg ) ||
924 nla_put_u32(vendor_event,
925 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
926 stats->contentionNumSamples ))
927 {
928 hddLog(VOS_TRACE_LEVEL_ERROR,
929 FL("QCA_WLAN_VENDOR_ATTR put fail") );
930 return FALSE;
931 }
932 return TRUE;
933}
934
935static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
936 struct sk_buff *vendor_event)
937{
Dino Myclec8f3f332014-07-21 16:48:27 +0530938 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
940 nla_put(vendor_event,
941 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
942 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
943 nla_put_u32(vendor_event,
944 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
945 stats->state ) ||
946 nla_put_u32(vendor_event,
947 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
948 stats->roaming ) ||
949 nla_put_u32(vendor_event,
950 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
951 stats->capabilities ) ||
952 nla_put(vendor_event,
953 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
954 strlen(stats->ssid), stats->ssid) ||
955 nla_put(vendor_event,
956 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
957 WNI_CFG_BSSID_LEN, stats->bssid) ||
958 nla_put(vendor_event,
959 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
960 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
961 nla_put(vendor_event,
962 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
963 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
964 )
965 {
966 hddLog(VOS_TRACE_LEVEL_ERROR,
967 FL("QCA_WLAN_VENDOR_ATTR put fail") );
968 return FALSE;
969 }
970 return TRUE;
971}
972
Dino Mycle3b9536d2014-07-09 22:05:24 +0530973static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
974 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530975 struct sk_buff *vendor_event)
976{
977 int i = 0;
978 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530979 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
980 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530981 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530982
Sunil Duttc69bccb2014-05-26 21:30:20 +0530983 if (FALSE == put_wifi_interface_info(
984 &pWifiIfaceStat->info,
985 vendor_event))
986 {
987 hddLog(VOS_TRACE_LEVEL_ERROR,
988 FL("QCA_WLAN_VENDOR_ATTR put fail") );
989 return FALSE;
990
991 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530992 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
993 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
994 if (NULL == pWifiIfaceStatTL)
995 {
996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
997 return FALSE;
998 }
999
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301000 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1002 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1003 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1004
1005 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1008 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301009
1010 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1011 {
1012 if (VOS_STATUS_SUCCESS ==
1013 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1014 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1015 {
1016 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1017 * obtained from TL structure
1018 */
1019
1020 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1021 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301022 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1023
Srinivas Dasari98947432014-11-07 19:41:24 +05301024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301032
Srinivas Dasari98947432014-11-07 19:41:24 +05301033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301041
Srinivas Dasari98947432014-11-07 19:41:24 +05301042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301050 }
1051 else
1052 {
1053 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1054 }
1055
Dino Mycle3b9536d2014-07-09 22:05:24 +05301056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1064 }
1065 else
1066 {
1067 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1068 }
1069
1070
Sunil Duttc69bccb2014-05-26 21:30:20 +05301071
1072 if (nla_put_u32(vendor_event,
1073 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1074 pWifiIfaceStat->beaconRx) ||
1075 nla_put_u32(vendor_event,
1076 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1077 pWifiIfaceStat->mgmtRx) ||
1078 nla_put_u32(vendor_event,
1079 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1080 pWifiIfaceStat->mgmtActionRx) ||
1081 nla_put_u32(vendor_event,
1082 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1083 pWifiIfaceStat->mgmtActionTx) ||
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_MGMT,
1086 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301087 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301088 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1089 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301090 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301091 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1092 pWifiIfaceStat->rssiAck))
1093 {
1094 hddLog(VOS_TRACE_LEVEL_ERROR,
1095 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301096 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301097 return FALSE;
1098 }
1099
1100 wmmInfo = nla_nest_start(vendor_event,
1101 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301102 if(!wmmInfo)
1103 {
1104 vos_mem_free(pWifiIfaceStatTL);
1105 return FALSE;
1106 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301107 for (i = 0; i < WIFI_AC_MAX; i++)
1108 {
1109 struct nlattr *wmmStats;
1110 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301111 if(!wmmStats)
1112 {
1113 vos_mem_free(pWifiIfaceStatTL);
1114 return FALSE;
1115 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301116 if (FALSE == put_wifi_wmm_ac_stat(
1117 &pWifiIfaceStat->AccessclassStats[i],
1118 vendor_event))
1119 {
1120 hddLog(VOS_TRACE_LEVEL_ERROR,
1121 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301122 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 return FALSE;
1124 }
1125
1126 nla_nest_end(vendor_event, wmmStats);
1127 }
1128 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return TRUE;
1131}
1132
1133static tSirWifiInterfaceMode
1134 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1135{
1136 switch (deviceMode)
1137 {
1138 case WLAN_HDD_INFRA_STATION:
1139 return WIFI_INTERFACE_STA;
1140 case WLAN_HDD_SOFTAP:
1141 return WIFI_INTERFACE_SOFTAP;
1142 case WLAN_HDD_P2P_CLIENT:
1143 return WIFI_INTERFACE_P2P_CLIENT;
1144 case WLAN_HDD_P2P_GO:
1145 return WIFI_INTERFACE_P2P_GO;
1146 case WLAN_HDD_IBSS:
1147 return WIFI_INTERFACE_IBSS;
1148 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301149 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301150 }
1151}
1152
1153static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1154 tpSirWifiInterfaceInfo pInfo)
1155{
1156 v_U8_t *staMac = NULL;
1157 hdd_station_ctx_t *pHddStaCtx;
1158 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1159 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1160
1161 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1162
1163 vos_mem_copy(pInfo->macAddr,
1164 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1165
1166 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1167 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1168 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1169 {
1170 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1171 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1172 {
1173 pInfo->state = WIFI_DISCONNECTED;
1174 }
1175 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1176 {
1177 hddLog(VOS_TRACE_LEVEL_ERROR,
1178 "%s: Session ID %d, Connection is in progress", __func__,
1179 pAdapter->sessionId);
1180 pInfo->state = WIFI_ASSOCIATING;
1181 }
1182 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1183 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1184 {
1185 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1186 hddLog(VOS_TRACE_LEVEL_ERROR,
1187 "%s: client " MAC_ADDRESS_STR
1188 " is in the middle of WPS/EAPOL exchange.", __func__,
1189 MAC_ADDR_ARRAY(staMac));
1190 pInfo->state = WIFI_AUTHENTICATING;
1191 }
1192 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1193 {
1194 pInfo->state = WIFI_ASSOCIATED;
1195 vos_mem_copy(pInfo->bssid,
1196 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1197 vos_mem_copy(pInfo->ssid,
1198 pHddStaCtx->conn_info.SSID.SSID.ssId,
1199 pHddStaCtx->conn_info.SSID.SSID.length);
1200 //NULL Terminate the string.
1201 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1202 }
1203 }
1204 vos_mem_copy(pInfo->countryStr,
1205 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1206
1207 vos_mem_copy(pInfo->apCountryStr,
1208 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1209
1210 return TRUE;
1211}
1212
1213/*
1214 * hdd_link_layer_process_peer_stats () - This function is called after
1215 * receiving Link Layer Peer statistics from FW.This function converts
1216 * the firmware data to the NL data and sends the same to the kernel/upper
1217 * layers.
1218 */
1219static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1220 v_VOID_t *pData)
1221{
1222 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1223 tpSirWifiRateStat pWifiRateStat;
1224 tpSirWifiPeerStat pWifiPeerStat;
1225 tpSirWifiPeerInfo pWifiPeerInfo;
1226 struct nlattr *peerInfo;
1227 struct sk_buff *vendor_event;
1228 int status, i;
1229
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301230 ENTER();
1231
Sunil Duttc69bccb2014-05-26 21:30:20 +05301232 status = wlan_hdd_validate_context(pHddCtx);
1233 if (0 != status)
1234 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301235 return;
1236 }
1237
1238 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1239
1240 hddLog(VOS_TRACE_LEVEL_INFO,
1241 "LL_STATS_PEER_ALL : numPeers %u",
1242 pWifiPeerStat->numPeers);
1243 {
1244 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1245 {
1246 pWifiPeerInfo = (tpSirWifiPeerInfo)
1247 ((uint8 *)pWifiPeerStat->peerInfo +
1248 ( i * sizeof(tSirWifiPeerInfo)));
1249
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301250 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1251 pWifiPeerInfo->type = WIFI_PEER_AP;
1252 }
1253 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1254 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1255 }
1256
Sunil Duttc69bccb2014-05-26 21:30:20 +05301257 hddLog(VOS_TRACE_LEVEL_INFO,
1258 " %d) LL_STATS Channel Stats "
1259 " Peer Type %u "
1260 " peerMacAddress %pM "
1261 " capabilities 0x%x "
1262 " numRate %u ",
1263 i,
1264 pWifiPeerInfo->type,
1265 pWifiPeerInfo->peerMacAddress,
1266 pWifiPeerInfo->capabilities,
1267 pWifiPeerInfo->numRate);
1268 {
1269 int j;
1270 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1271 {
1272 pWifiRateStat = (tpSirWifiRateStat)
1273 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1274 ( j * sizeof(tSirWifiRateStat)));
1275
1276 hddLog(VOS_TRACE_LEVEL_INFO,
1277 " peer Rate Stats "
1278 " preamble %u "
1279 " nss %u "
1280 " bw %u "
1281 " rateMcsIdx %u "
1282 " reserved %u "
1283 " bitrate %u "
1284 " txMpdu %u "
1285 " rxMpdu %u "
1286 " mpduLost %u "
1287 " retries %u "
1288 " retriesShort %u "
1289 " retriesLong %u",
1290 pWifiRateStat->rate.preamble,
1291 pWifiRateStat->rate.nss,
1292 pWifiRateStat->rate.bw,
1293 pWifiRateStat->rate.rateMcsIdx,
1294 pWifiRateStat->rate.reserved,
1295 pWifiRateStat->rate.bitrate,
1296 pWifiRateStat->txMpdu,
1297 pWifiRateStat->rxMpdu,
1298 pWifiRateStat->mpduLost,
1299 pWifiRateStat->retries,
1300 pWifiRateStat->retriesShort,
1301 pWifiRateStat->retriesLong);
1302 }
1303 }
1304 }
1305 }
1306
1307 /*
1308 * Allocate a size of 4096 for the peer stats comprising
1309 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1310 * sizeof (tSirWifiRateStat).Each field is put with an
1311 * NL attribute.The size of 4096 is considered assuming
1312 * that number of rates shall not exceed beyond 50 with
1313 * the sizeof (tSirWifiRateStat) being 32.
1314 */
1315 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1316 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1317 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1318 GFP_KERNEL);
1319 if (!vendor_event)
1320 {
1321 hddLog(VOS_TRACE_LEVEL_ERROR,
1322 "%s: cfg80211_vendor_event_alloc failed",
1323 __func__);
1324 return;
1325 }
1326 if (nla_put_u32(vendor_event,
1327 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1328 pWifiPeerStat->numPeers))
1329 {
1330 hddLog(VOS_TRACE_LEVEL_ERROR,
1331 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1332 kfree_skb(vendor_event);
1333 return;
1334 }
1335
1336 peerInfo = nla_nest_start(vendor_event,
1337 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301338 if(!peerInfo)
1339 {
1340 hddLog(VOS_TRACE_LEVEL_ERROR,
1341 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1342 __func__);
1343 kfree_skb(vendor_event);
1344 return;
1345 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301346
1347 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1348 pWifiPeerStat->peerInfo);
1349
1350 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1351 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301355 if(!peers)
1356 {
1357 hddLog(VOS_TRACE_LEVEL_ERROR,
1358 "%s: peer stats put fail",
1359 __func__);
1360 kfree_skb(vendor_event);
1361 return;
1362 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301363 if (FALSE == put_wifi_peer_info(
1364 pWifiPeerInfo, vendor_event))
1365 {
1366 hddLog(VOS_TRACE_LEVEL_ERROR,
1367 "%s: put_wifi_peer_info put fail", __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
1371
1372 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1373 pWifiPeerStat->peerInfo +
1374 (i * sizeof(tSirWifiPeerInfo)) +
1375 (numRate * sizeof (tSirWifiRateStat)));
1376 nla_nest_end(vendor_event, peers);
1377 }
1378 nla_nest_end(vendor_event, peerInfo);
1379 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301380
1381 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301382}
1383
1384/*
1385 * hdd_link_layer_process_iface_stats () - This function is called after
1386 * receiving Link Layer Interface statistics from FW.This function converts
1387 * the firmware data to the NL data and sends the same to the kernel/upper
1388 * layers.
1389 */
1390static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1391 v_VOID_t *pData)
1392{
1393 tpSirWifiIfaceStat pWifiIfaceStat;
1394 struct sk_buff *vendor_event;
1395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1396 int status;
1397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301398 ENTER();
1399
Sunil Duttc69bccb2014-05-26 21:30:20 +05301400 status = wlan_hdd_validate_context(pHddCtx);
1401 if (0 != status)
1402 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301403 return;
1404 }
1405 /*
1406 * Allocate a size of 4096 for the interface stats comprising
1407 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1408 * assuming that all these fit with in the limit.Please take
1409 * a call on the limit based on the data requirements on
1410 * interface statistics.
1411 */
1412 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1413 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1414 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1415 GFP_KERNEL);
1416 if (!vendor_event)
1417 {
1418 hddLog(VOS_TRACE_LEVEL_ERROR,
1419 FL("cfg80211_vendor_event_alloc failed") );
1420 return;
1421 }
1422
1423 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1424
Dino Mycle3b9536d2014-07-09 22:05:24 +05301425
1426 if (FALSE == hdd_get_interface_info( pAdapter,
1427 &pWifiIfaceStat->info))
1428 {
1429 hddLog(VOS_TRACE_LEVEL_ERROR,
1430 FL("hdd_get_interface_info get fail") );
1431 kfree_skb(vendor_event);
1432 return;
1433 }
1434
1435 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1436 vendor_event))
1437 {
1438 hddLog(VOS_TRACE_LEVEL_ERROR,
1439 FL("put_wifi_iface_stats fail") );
1440 kfree_skb(vendor_event);
1441 return;
1442 }
1443
Sunil Duttc69bccb2014-05-26 21:30:20 +05301444 hddLog(VOS_TRACE_LEVEL_INFO,
1445 "WMI_LINK_STATS_IFACE Data");
1446
1447 hddLog(VOS_TRACE_LEVEL_INFO,
1448 "LL_STATS_IFACE: "
1449 " Mode %u "
1450 " MAC %pM "
1451 " State %u "
1452 " Roaming %u "
1453 " capabilities 0x%x "
1454 " SSID %s "
1455 " BSSID %pM",
1456 pWifiIfaceStat->info.mode,
1457 pWifiIfaceStat->info.macAddr,
1458 pWifiIfaceStat->info.state,
1459 pWifiIfaceStat->info.roaming,
1460 pWifiIfaceStat->info.capabilities,
1461 pWifiIfaceStat->info.ssid,
1462 pWifiIfaceStat->info.bssid);
1463
1464 hddLog(VOS_TRACE_LEVEL_INFO,
1465 " AP country str: %c%c%c",
1466 pWifiIfaceStat->info.apCountryStr[0],
1467 pWifiIfaceStat->info.apCountryStr[1],
1468 pWifiIfaceStat->info.apCountryStr[2]);
1469
1470
1471 hddLog(VOS_TRACE_LEVEL_INFO,
1472 " Country Str Association: %c%c%c",
1473 pWifiIfaceStat->info.countryStr[0],
1474 pWifiIfaceStat->info.countryStr[1],
1475 pWifiIfaceStat->info.countryStr[2]);
1476
1477 hddLog(VOS_TRACE_LEVEL_INFO,
1478 " beaconRx %u "
1479 " mgmtRx %u "
1480 " mgmtActionRx %u "
1481 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301482 " rssiMgmt %d "
1483 " rssiData %d "
1484 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301485 pWifiIfaceStat->beaconRx,
1486 pWifiIfaceStat->mgmtRx,
1487 pWifiIfaceStat->mgmtActionRx,
1488 pWifiIfaceStat->mgmtActionTx,
1489 pWifiIfaceStat->rssiMgmt,
1490 pWifiIfaceStat->rssiData,
1491 pWifiIfaceStat->rssiAck );
1492
1493
1494 {
1495 int i;
1496 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1497 {
1498 hddLog(VOS_TRACE_LEVEL_INFO,
1499
1500 " %d) LL_STATS IFACE: "
1501 " ac: %u txMpdu: %u "
1502 " rxMpdu: %u txMcast: %u "
1503 " rxMcast: %u rxAmpdu: %u "
1504 " txAmpdu: %u mpduLost: %u "
1505 " retries: %u retriesShort: %u "
1506 " retriesLong: %u contentionTimeMin: %u "
1507 " contentionTimeMax: %u contentionTimeAvg: %u "
1508 " contentionNumSamples: %u",
1509 i,
1510 pWifiIfaceStat->AccessclassStats[i].ac,
1511 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1512 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1513 pWifiIfaceStat->AccessclassStats[i].txMcast,
1514 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1515 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1516 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1517 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1518 pWifiIfaceStat->AccessclassStats[i].retries,
1519 pWifiIfaceStat->
1520 AccessclassStats[i].retriesShort,
1521 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMin,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeMax,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionTimeAvg,
1528 pWifiIfaceStat->
1529 AccessclassStats[i].contentionNumSamples);
1530
1531 }
1532 }
1533
Sunil Duttc69bccb2014-05-26 21:30:20 +05301534 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301535
1536 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301537}
1538
1539/*
1540 * hdd_link_layer_process_radio_stats () - This function is called after
1541 * receiving Link Layer Radio statistics from FW.This function converts
1542 * the firmware data to the NL data and sends the same to the kernel/upper
1543 * layers.
1544 */
1545static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1546 v_VOID_t *pData)
1547{
1548 int status, i;
1549 tpSirWifiRadioStat pWifiRadioStat;
1550 tpSirWifiChannelStats pWifiChannelStats;
1551 struct sk_buff *vendor_event;
1552 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1553 struct nlattr *chList;
1554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301555 ENTER();
1556
Sunil Duttc69bccb2014-05-26 21:30:20 +05301557 status = wlan_hdd_validate_context(pHddCtx);
1558 if (0 != status)
1559 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301560 return;
1561 }
1562 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1563
1564 hddLog(VOS_TRACE_LEVEL_INFO,
1565 "LL_STATS_RADIO"
1566 " radio is %d onTime is %u "
1567 " txTime is %u rxTime is %u "
1568 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301569 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301570 " onTimePnoScan is %u onTimeHs20 is %u "
1571 " numChannels is %u",
1572 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1573 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1574 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301575 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301576 pWifiRadioStat->onTimeRoamScan,
1577 pWifiRadioStat->onTimePnoScan,
1578 pWifiRadioStat->onTimeHs20,
1579 pWifiRadioStat->numChannels);
1580 /*
1581 * Allocate a size of 4096 for the Radio stats comprising
1582 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1583 * (tSirWifiChannelStats).Each channel data is put with an
1584 * NL attribute.The size of 4096 is considered assuming that
1585 * number of channels shall not exceed beyond 60 with the
1586 * sizeof (tSirWifiChannelStats) being 24 bytes.
1587 */
1588
1589 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1590 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1591 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1592 GFP_KERNEL);
1593
1594 if (!vendor_event)
1595 {
1596 hddLog(VOS_TRACE_LEVEL_ERROR,
1597 FL("cfg80211_vendor_event_alloc failed") );
1598 return;
1599 }
1600
1601 if (nla_put_u32(vendor_event,
1602 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1603 pWifiRadioStat->radio) ||
1604 nla_put_u32(vendor_event,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1606 pWifiRadioStat->onTime) ||
1607 nla_put_u32(vendor_event,
1608 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1609 pWifiRadioStat->txTime) ||
1610 nla_put_u32(vendor_event,
1611 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1612 pWifiRadioStat->rxTime) ||
1613 nla_put_u32(vendor_event,
1614 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1615 pWifiRadioStat->onTimeScan) ||
1616 nla_put_u32(vendor_event,
1617 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1618 pWifiRadioStat->onTimeNbd) ||
1619 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301620 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1621 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301622 nla_put_u32(vendor_event,
1623 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1624 pWifiRadioStat->onTimeRoamScan) ||
1625 nla_put_u32(vendor_event,
1626 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1627 pWifiRadioStat->onTimePnoScan) ||
1628 nla_put_u32(vendor_event,
1629 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1630 pWifiRadioStat->onTimeHs20) ||
1631 nla_put_u32(vendor_event,
1632 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1633 pWifiRadioStat->numChannels))
1634 {
1635 hddLog(VOS_TRACE_LEVEL_ERROR,
1636 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1637 kfree_skb(vendor_event);
1638 return ;
1639 }
1640
1641 chList = nla_nest_start(vendor_event,
1642 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301643 if(!chList)
1644 {
1645 hddLog(VOS_TRACE_LEVEL_ERROR,
1646 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1647 __func__);
1648 kfree_skb(vendor_event);
1649 return;
1650 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301651 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1652 {
1653 struct nlattr *chInfo;
1654
1655 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1656 pWifiRadioStat->channels +
1657 (i * sizeof(tSirWifiChannelStats)));
1658
1659 hddLog(VOS_TRACE_LEVEL_INFO,
1660 " %d) Channel Info"
1661 " width is %u "
1662 " CenterFreq %u "
1663 " CenterFreq0 %u "
1664 " CenterFreq1 %u "
1665 " onTime %u "
1666 " ccaBusyTime %u",
1667 i,
1668 pWifiChannelStats->channel.width,
1669 pWifiChannelStats->channel.centerFreq,
1670 pWifiChannelStats->channel.centerFreq0,
1671 pWifiChannelStats->channel.centerFreq1,
1672 pWifiChannelStats->onTime,
1673 pWifiChannelStats->ccaBusyTime);
1674
1675
1676 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301677 if(!chInfo)
1678 {
1679 hddLog(VOS_TRACE_LEVEL_ERROR,
1680 "%s: failed to put chInfo",
1681 __func__);
1682 kfree_skb(vendor_event);
1683 return;
1684 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301685
1686 if (nla_put_u32(vendor_event,
1687 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1688 pWifiChannelStats->channel.width) ||
1689 nla_put_u32(vendor_event,
1690 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1691 pWifiChannelStats->channel.centerFreq) ||
1692 nla_put_u32(vendor_event,
1693 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1694 pWifiChannelStats->channel.centerFreq0) ||
1695 nla_put_u32(vendor_event,
1696 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1697 pWifiChannelStats->channel.centerFreq1) ||
1698 nla_put_u32(vendor_event,
1699 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1700 pWifiChannelStats->onTime) ||
1701 nla_put_u32(vendor_event,
1702 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1703 pWifiChannelStats->ccaBusyTime))
1704 {
1705 hddLog(VOS_TRACE_LEVEL_ERROR,
1706 FL("cfg80211_vendor_event_alloc failed") );
1707 kfree_skb(vendor_event);
1708 return ;
1709 }
1710 nla_nest_end(vendor_event, chInfo);
1711 }
1712 nla_nest_end(vendor_event, chList);
1713
1714 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301715
1716 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301717 return;
1718}
1719
1720/*
1721 * hdd_link_layer_stats_ind_callback () - This function is called after
1722 * receiving Link Layer indications from FW.This callback converts the firmware
1723 * data to the NL data and send the same to the kernel/upper layers.
1724 */
1725static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1726 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301727 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301728{
Dino Mycled3d50022014-07-07 12:58:25 +05301729 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1730 hdd_adapter_t *pAdapter = NULL;
1731 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301732 int status;
1733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301736 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 if (0 != status)
1738 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301739 return;
1740 }
1741
Dino Mycled3d50022014-07-07 12:58:25 +05301742 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1743 if (NULL == pAdapter)
1744 {
1745 hddLog(VOS_TRACE_LEVEL_ERROR,
1746 FL(" MAC address %pM does not exist with host"),
1747 macAddr);
1748 return;
1749 }
1750
Sunil Duttc69bccb2014-05-26 21:30:20 +05301751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301752 "%s: Interface: %s LLStats indType: %d", __func__,
1753 pAdapter->dev->name, indType);
1754
Sunil Duttc69bccb2014-05-26 21:30:20 +05301755 switch (indType)
1756 {
1757 case SIR_HAL_LL_STATS_RESULTS_RSP:
1758 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1761 hddLog(VOS_TRACE_LEVEL_INFO,
1762 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1763 linkLayerStatsResults->paramId);
1764 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301765 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1766 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE respId = %u",
1769 linkLayerStatsResults->respId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
1771 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1772 linkLayerStatsResults->moreResultToFollow);
1773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE result = %p",
1775 linkLayerStatsResults->result);
1776 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1777 {
1778 hdd_link_layer_process_radio_stats(pAdapter,
1779 (v_VOID_t *)linkLayerStatsResults->result);
1780 }
1781 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1782 {
1783 hdd_link_layer_process_iface_stats(pAdapter,
1784 (v_VOID_t *)linkLayerStatsResults->result);
1785 }
1786 else if ( linkLayerStatsResults->paramId &
1787 WMI_LINK_STATS_ALL_PEER )
1788 {
1789 hdd_link_layer_process_peer_stats(pAdapter,
1790 (v_VOID_t *)linkLayerStatsResults->result);
1791 } /* WMI_LINK_STATS_ALL_PEER */
1792 else
1793 {
1794 hddLog(VOS_TRACE_LEVEL_ERROR,
1795 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1796 }
1797
1798 break;
1799 }
1800 default:
1801 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1802 break;
1803 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301804
1805 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301806 return;
1807}
1808
1809const struct
1810nla_policy
1811qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1812{
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1814 { .type = NLA_U32 },
1815 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1816 { .type = NLA_U32 },
1817};
1818
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301819static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1820 struct wireless_dev *wdev,
1821 const void *data,
1822 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301823{
1824 int status;
1825 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301826 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301827 struct net_device *dev = wdev->netdev;
1828 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1829 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301830 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301831
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301832 ENTER();
1833
Sunil Duttc69bccb2014-05-26 21:30:20 +05301834 status = wlan_hdd_validate_context(pHddCtx);
1835 if (0 != status)
1836 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301837 return -EINVAL;
1838 }
1839
1840 if (NULL == pAdapter)
1841 {
1842 hddLog(VOS_TRACE_LEVEL_ERROR,
1843 FL("HDD adapter is Null"));
1844 return -ENODEV;
1845 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301846 /* check the LLStats Capability */
1847 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1848 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1849 {
1850 hddLog(VOS_TRACE_LEVEL_ERROR,
1851 FL("Link Layer Statistics not supported by Firmware"));
1852 return -EINVAL;
1853 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301854
1855 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1856 (struct nlattr *)data,
1857 data_len, qca_wlan_vendor_ll_set_policy))
1858 {
1859 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1860 return -EINVAL;
1861 }
1862 if (!tb_vendor
1863 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1864 {
1865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1866 return -EINVAL;
1867 }
1868 if (!tb_vendor[
1869 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1870 {
1871 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1872 return -EINVAL;
1873 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876
Dino Mycledf0a5d92014-07-04 09:41:55 +05301877 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301878 nla_get_u32(
1879 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1880
Dino Mycledf0a5d92014-07-04 09:41:55 +05301881 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301882 nla_get_u32(
1883 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1884
Dino Mycled3d50022014-07-07 12:58:25 +05301885 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1886 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301887
1888
1889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301892 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301893 hddLog(VOS_TRACE_LEVEL_INFO,
1894 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301895 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301896 hddLog(VOS_TRACE_LEVEL_INFO,
1897 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301898 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301899
1900 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1901 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301902 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301903 {
1904 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1905 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301906 return -EINVAL;
1907
1908 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301909
1910 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1911 if (VOS_STATUS_SUCCESS !=
1912 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1913 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1914 {
1915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1916 "WLANTL_ClearInterfaceStats Failed", __func__);
1917 return -EINVAL;
1918 }
1919
1920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1921 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1922 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1923 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1924
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301926 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 {
1928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1929 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301930 return -EINVAL;
1931 }
1932
1933 pAdapter->isLinkLayerStatsSet = 1;
1934
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301935 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301936 return 0;
1937}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301938static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1939 struct wireless_dev *wdev,
1940 const void *data,
1941 int data_len)
1942{
1943 int ret = 0;
1944
1945 vos_ssr_protect(__func__);
1946 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1947 vos_ssr_unprotect(__func__);
1948
1949 return ret;
1950}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951
1952const struct
1953nla_policy
1954qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1955{
1956 /* Unsigned 32bit value provided by the caller issuing the GET stats
1957 * command. When reporting
1958 * the stats results, the driver uses the same value to indicate
1959 * which GET request the results
1960 * correspond to.
1961 */
1962 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1963
1964 /* Unsigned 32bit value . bit mask to identify what statistics are
1965 requested for retrieval */
1966 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1967};
1968
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301969static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1970 struct wireless_dev *wdev,
1971 const void *data,
1972 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301973{
1974 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1975 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301976 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301977 struct net_device *dev = wdev->netdev;
1978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1979 int status;
1980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301981 ENTER();
1982
Sunil Duttc69bccb2014-05-26 21:30:20 +05301983 status = wlan_hdd_validate_context(pHddCtx);
1984 if (0 != status)
1985 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301986 return -EINVAL ;
1987 }
1988
1989 if (NULL == pAdapter)
1990 {
1991 hddLog(VOS_TRACE_LEVEL_FATAL,
1992 "%s: HDD adapter is Null", __func__);
1993 return -ENODEV;
1994 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301995 /* check the LLStats Capability */
1996 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1997 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1998 {
1999 hddLog(VOS_TRACE_LEVEL_ERROR,
2000 FL("Link Layer Statistics not supported by Firmware"));
2001 return -EINVAL;
2002 }
2003
Sunil Duttc69bccb2014-05-26 21:30:20 +05302004
2005 if (!pAdapter->isLinkLayerStatsSet)
2006 {
2007 hddLog(VOS_TRACE_LEVEL_FATAL,
2008 "%s: isLinkLayerStatsSet : %d",
2009 __func__, pAdapter->isLinkLayerStatsSet);
2010 return -EINVAL;
2011 }
2012
2013 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2014 (struct nlattr *)data,
2015 data_len, qca_wlan_vendor_ll_get_policy))
2016 {
2017 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2018 return -EINVAL;
2019 }
2020
2021 if (!tb_vendor
2022 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2023 {
2024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2025 return -EINVAL;
2026 }
2027
2028 if (!tb_vendor
2029 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2032 return -EINVAL;
2033 }
2034
Sunil Duttc69bccb2014-05-26 21:30:20 +05302035
Dino Mycledf0a5d92014-07-04 09:41:55 +05302036 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302037 nla_get_u32( tb_vendor[
2038 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302039 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302040 nla_get_u32( tb_vendor[
2041 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2042
Dino Mycled3d50022014-07-07 12:58:25 +05302043 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2044 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302045
2046 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302047 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302049 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302050 hddLog(VOS_TRACE_LEVEL_INFO,
2051 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302052 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302053
2054 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302055 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302056 {
2057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2058 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302059 return -EINVAL;
2060 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302061
2062 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302063 return 0;
2064}
2065
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302066static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2067 struct wireless_dev *wdev,
2068 const void *data,
2069 int data_len)
2070{
2071 int ret = 0;
2072
2073 vos_ssr_protect(__func__);
2074 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2075 vos_ssr_unprotect(__func__);
2076
2077 return ret;
2078}
2079
Sunil Duttc69bccb2014-05-26 21:30:20 +05302080const struct
2081nla_policy
2082qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2083{
2084 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2085 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2086 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2087 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2088};
2089
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302090static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2091 struct wireless_dev *wdev,
2092 const void *data,
2093 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302094{
2095 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2096 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302097 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302098 struct net_device *dev = wdev->netdev;
2099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2100 u32 statsClearReqMask;
2101 u8 stopReq;
2102 int status;
2103
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302104 ENTER();
2105
Sunil Duttc69bccb2014-05-26 21:30:20 +05302106 status = wlan_hdd_validate_context(pHddCtx);
2107 if (0 != status)
2108 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302109 return -EINVAL;
2110 }
2111
2112 if (NULL == pAdapter)
2113 {
2114 hddLog(VOS_TRACE_LEVEL_FATAL,
2115 "%s: HDD adapter is Null", __func__);
2116 return -ENODEV;
2117 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302118 /* check the LLStats Capability */
2119 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2120 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2121 {
2122 hddLog(VOS_TRACE_LEVEL_ERROR,
2123 FL("Enable LLStats Capability"));
2124 return -EINVAL;
2125 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302126
2127 if (!pAdapter->isLinkLayerStatsSet)
2128 {
2129 hddLog(VOS_TRACE_LEVEL_FATAL,
2130 "%s: isLinkLayerStatsSet : %d",
2131 __func__, pAdapter->isLinkLayerStatsSet);
2132 return -EINVAL;
2133 }
2134
2135 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2136 (struct nlattr *)data,
2137 data_len, qca_wlan_vendor_ll_clr_policy))
2138 {
2139 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2140 return -EINVAL;
2141 }
2142
2143 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2144
2145 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2146 {
2147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2148 return -EINVAL;
2149
2150 }
2151
Sunil Duttc69bccb2014-05-26 21:30:20 +05302152
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 nla_get_u32(
2155 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2156
Dino Mycledf0a5d92014-07-04 09:41:55 +05302157 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302158 nla_get_u8(
2159 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2160
2161 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302162 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302163
Dino Mycled3d50022014-07-07 12:58:25 +05302164 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2165 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302166
2167 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302168 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302169 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302170 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302171 hddLog(VOS_TRACE_LEVEL_INFO,
2172 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302173 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302174 hddLog(VOS_TRACE_LEVEL_INFO,
2175 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302176 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302177
2178 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302179 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302180 {
2181 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302182 hdd_station_ctx_t *pHddStaCtx;
2183
2184 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2185 if (VOS_STATUS_SUCCESS !=
2186 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2187 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2188 {
2189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2190 "WLANTL_ClearInterfaceStats Failed", __func__);
2191 return -EINVAL;
2192 }
2193 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2194 (statsClearReqMask & WIFI_STATS_IFACE)) {
2195 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2196 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2197 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2198 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2199 }
2200
Sunil Duttc69bccb2014-05-26 21:30:20 +05302201 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2202 2 * sizeof(u32) +
2203 NLMSG_HDRLEN);
2204
2205 if (temp_skbuff != NULL)
2206 {
2207
2208 if (nla_put_u32(temp_skbuff,
2209 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2210 statsClearReqMask) ||
2211 nla_put_u32(temp_skbuff,
2212 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2213 stopReq))
2214 {
2215 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2216 kfree_skb(temp_skbuff);
2217 return -EINVAL;
2218 }
2219 /* If the ask is to stop the stats collection as part of clear
2220 * (stopReq = 1) , ensure that no further requests of get
2221 * go to the firmware by having isLinkLayerStatsSet set to 0.
2222 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302223 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302224 * case the firmware is just asked to clear the statistics.
2225 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302226 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 pAdapter->isLinkLayerStatsSet = 0;
2228 return cfg80211_vendor_cmd_reply(temp_skbuff);
2229 }
2230 return -ENOMEM;
2231 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302232
2233 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302234 return -EINVAL;
2235}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302236static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2237 struct wireless_dev *wdev,
2238 const void *data,
2239 int data_len)
2240{
2241 int ret = 0;
2242
2243 vos_ssr_protect(__func__);
2244 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2245 vos_ssr_unprotect(__func__);
2246
2247 return ret;
2248
2249
2250}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302251#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2252
Dino Mycle6fb96c12014-06-10 11:52:40 +05302253#ifdef WLAN_FEATURE_EXTSCAN
2254static const struct nla_policy
2255wlan_hdd_extscan_config_policy
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2257{
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2259 { .type = NLA_U32 },
2260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2261 { .type = NLA_U32 },
2262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2264 { .type = NLA_U32 },
2265 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2267
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2272 { .type = NLA_U8 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2276 { .type = NLA_U32 },
2277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2278 { .type = NLA_U32 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2280 { .type = NLA_U8 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2282 { .type = NLA_U8 },
2283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2284 { .type = NLA_U8 },
2285
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2287 { .type = NLA_U32 },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2289 { .type = NLA_UNSPEC },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2291 { .type = NLA_S32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2293 { .type = NLA_S32 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2295 { .type = NLA_U32 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2297 { .type = NLA_U32 },
2298 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2299 { .type = NLA_U32 },
2300 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2301 = { .type = NLA_U32 },
2302 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2303 { .type = NLA_U32 },
2304 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2305 NLA_U32 },
2306};
2307
2308static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2309{
2310 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2311 struct sk_buff *skb = NULL;
2312 tpSirEXTScanCapabilitiesEvent pData =
2313 (tpSirEXTScanCapabilitiesEvent) pMsg;
2314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302315 ENTER();
2316
2317 if (wlan_hdd_validate_context(pHddCtx))
2318 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302319 return;
2320 }
2321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302322 if (!pMsg)
2323 {
2324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2325 return;
2326 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302327 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2328 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2329 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2330 GFP_KERNEL);
2331
2332 if (!skb) {
2333 hddLog(VOS_TRACE_LEVEL_ERROR,
2334 FL("cfg80211_vendor_event_alloc failed"));
2335 return;
2336 }
2337
2338 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2341 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2343 pData->maxRssiSampleSize);
2344 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2345 pData->maxScanReportingThreshold);
2346 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2347 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2348 pData->maxSignificantWifiChangeAPs);
2349 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2350 pData->maxBsidHistoryEntries);
2351
2352 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2353 pData->requestId) ||
2354 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2355 nla_put_u32(skb,
2356 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2357 pData->scanCacheSize) ||
2358 nla_put_u32(skb,
2359 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2360 pData->scanBuckets) ||
2361 nla_put_u32(skb,
2362 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2363 pData->maxApPerScan) ||
2364 nla_put_u32(skb,
2365 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2366 pData->maxRssiSampleSize) ||
2367 nla_put_u32(skb,
2368 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2369 pData->maxScanReportingThreshold) ||
2370 nla_put_u32(skb,
2371 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2372 pData->maxHotlistAPs) ||
2373 nla_put_u32(skb,
2374 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2375 pData->maxSignificantWifiChangeAPs) ||
2376 nla_put_u32(skb,
2377 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2378 pData->maxBsidHistoryEntries)) {
2379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2380 goto nla_put_failure;
2381 }
2382
2383 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302384 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302385 return;
2386
2387nla_put_failure:
2388 kfree_skb(skb);
2389 return;
2390}
2391
2392
2393static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2394{
2395 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2396 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2397 struct sk_buff *skb = NULL;
2398 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302401
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302402 if (wlan_hdd_validate_context(pHddCtx)){
2403 return;
2404 }
2405 if (!pMsg)
2406 {
2407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302408 return;
2409 }
2410
2411 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2412 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2413 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2414 GFP_KERNEL);
2415
2416 if (!skb) {
2417 hddLog(VOS_TRACE_LEVEL_ERROR,
2418 FL("cfg80211_vendor_event_alloc failed"));
2419 return;
2420 }
2421 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2422 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2423 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2424
2425 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2426 pData->requestId) ||
2427 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2429 goto nla_put_failure;
2430 }
2431
2432 /*
2433 * Store the Request ID for comparing with the requestID obtained
2434 * in other requests.HDD shall return a failure is the extscan_stop
2435 * request is issued with a different requestId as that of the
2436 * extscan_start request. Also, This requestId shall be used while
2437 * indicating the full scan results to the upper layers.
2438 * The requestId is stored with the assumption that the firmware
2439 * shall return the ext scan start request's requestId in ext scan
2440 * start response.
2441 */
2442 if (pData->status == 0)
2443 pMac->sme.extScanStartReqId = pData->requestId;
2444
2445
2446 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302447 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302448 return;
2449
2450nla_put_failure:
2451 kfree_skb(skb);
2452 return;
2453}
2454
2455
2456static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2457{
2458 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2459 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2460 struct sk_buff *skb = NULL;
2461
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302462 ENTER();
2463
2464 if (wlan_hdd_validate_context(pHddCtx)){
2465 return;
2466 }
2467 if (!pMsg)
2468 {
2469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302470 return;
2471 }
2472
2473 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485
2486 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2487 pData->requestId) ||
2488 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2490 goto nla_put_failure;
2491 }
2492
2493 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302494 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302495 return;
2496
2497nla_put_failure:
2498 kfree_skb(skb);
2499 return;
2500}
2501
2502
2503static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2504 void *pMsg)
2505{
2506 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2507 struct sk_buff *skb = NULL;
2508 tpSirEXTScanSetBssidHotListRspParams pData =
2509 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2510
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302511 ENTER();
2512
2513 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302514 return;
2515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302516 if (!pMsg)
2517 {
2518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2519 return;
2520 }
2521
Dino Mycle6fb96c12014-06-10 11:52:40 +05302522 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2523 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2524 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2525 GFP_KERNEL);
2526
2527 if (!skb) {
2528 hddLog(VOS_TRACE_LEVEL_ERROR,
2529 FL("cfg80211_vendor_event_alloc failed"));
2530 return;
2531 }
2532 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2533 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2534 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2535
2536 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2537 pData->requestId) ||
2538 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2539 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2540 goto nla_put_failure;
2541 }
2542
2543 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302544 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302545 return;
2546
2547nla_put_failure:
2548 kfree_skb(skb);
2549 return;
2550}
2551
2552static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2553 void *pMsg)
2554{
2555 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2556 struct sk_buff *skb = NULL;
2557 tpSirEXTScanResetBssidHotlistRspParams pData =
2558 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302560 ENTER();
2561
2562 if (wlan_hdd_validate_context(pHddCtx)) {
2563 return;
2564 }
2565 if (!pMsg)
2566 {
2567 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302568 return;
2569 }
2570
2571 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2572 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2573 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2574 GFP_KERNEL);
2575
2576 if (!skb) {
2577 hddLog(VOS_TRACE_LEVEL_ERROR,
2578 FL("cfg80211_vendor_event_alloc failed"));
2579 return;
2580 }
2581 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2582 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2583
2584 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2585 pData->requestId) ||
2586 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2588 goto nla_put_failure;
2589 }
2590
2591 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302592 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302593 return;
2594
2595nla_put_failure:
2596 kfree_skb(skb);
2597 return;
2598}
2599
2600
2601static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2602 void *pMsg)
2603{
2604 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2605 struct sk_buff *skb = NULL;
2606 tpSirEXTScanSetSignificantChangeRspParams pData =
2607 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2608
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302609 ENTER();
2610
2611 if (wlan_hdd_validate_context(pHddCtx)) {
2612 return;
2613 }
2614 if (!pMsg)
2615 {
2616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302617 return;
2618 }
2619
2620 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2621 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2622 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2623 GFP_KERNEL);
2624
2625 if (!skb) {
2626 hddLog(VOS_TRACE_LEVEL_ERROR,
2627 FL("cfg80211_vendor_event_alloc failed"));
2628 return;
2629 }
2630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2631 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2632 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2633
2634 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2635 pData->requestId) ||
2636 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2638 goto nla_put_failure;
2639 }
2640
2641 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302642 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 return;
2644
2645nla_put_failure:
2646 kfree_skb(skb);
2647 return;
2648}
2649
2650
2651static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2652 void *pMsg)
2653{
2654 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2655 struct sk_buff *skb = NULL;
2656 tpSirEXTScanResetSignificantChangeRspParams pData =
2657 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2658
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302659 ENTER();
2660
2661 if (wlan_hdd_validate_context(pHddCtx)) {
2662 return;
2663 }
2664 if (!pMsg)
2665 {
2666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302667 return;
2668 }
2669
2670 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2671 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2672 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2673 GFP_KERNEL);
2674
2675 if (!skb) {
2676 hddLog(VOS_TRACE_LEVEL_ERROR,
2677 FL("cfg80211_vendor_event_alloc failed"));
2678 return;
2679 }
2680 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2681 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2682 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2683
2684 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2685 pData->requestId) ||
2686 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2688 goto nla_put_failure;
2689 }
2690
2691 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302692 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302693 return;
2694
2695nla_put_failure:
2696 kfree_skb(skb);
2697 return;
2698}
2699
2700static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2701 void *pMsg)
2702{
2703 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2704 struct sk_buff *skb = NULL;
2705 tANI_U32 i = 0, j, resultsPerEvent;
2706 tANI_S32 totalResults;
2707 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2708 tpSirWifiScanResult pSirWifiScanResult;
2709
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302710 ENTER();
2711
2712 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302713 return;
2714 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302715 if (!pMsg)
2716 {
2717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2718 return;
2719 }
2720
Dino Mycle6fb96c12014-06-10 11:52:40 +05302721 totalResults = pData->numOfAps;
2722 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2723 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2724 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2725
2726 do{
2727 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2728 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2729 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2730
2731 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2732 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2733 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2734 GFP_KERNEL);
2735
2736 if (!skb) {
2737 hddLog(VOS_TRACE_LEVEL_ERROR,
2738 FL("cfg80211_vendor_event_alloc failed"));
2739 return;
2740 }
2741
2742 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2743
2744 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2745 pData->requestId) ||
2746 nla_put_u32(skb,
2747 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2748 resultsPerEvent)) {
2749 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2750 goto fail;
2751 }
2752 if (nla_put_u8(skb,
2753 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2754 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2755 {
2756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2757 goto fail;
2758 }
2759
2760 if (resultsPerEvent) {
2761 struct nlattr *aps;
2762
2763 aps = nla_nest_start(skb,
2764 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2765 if (!aps)
2766 {
2767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2768 goto fail;
2769 }
2770
2771 for (j = 0; j < resultsPerEvent; j++, i++) {
2772 struct nlattr *ap;
2773 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2774 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2775
2776 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2777 "Ssid (%s)"
2778 "Bssid: %pM "
2779 "Channel (%u)"
2780 "Rssi (%d)"
2781 "RTT (%u)"
2782 "RTT_SD (%u)",
2783 i,
2784 pSirWifiScanResult->ts,
2785 pSirWifiScanResult->ssid,
2786 pSirWifiScanResult->bssid,
2787 pSirWifiScanResult->channel,
2788 pSirWifiScanResult->rssi,
2789 pSirWifiScanResult->rtt,
2790 pSirWifiScanResult->rtt_sd);
2791
2792 ap = nla_nest_start(skb, j + 1);
2793 if (!ap)
2794 {
2795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2796 goto fail;
2797 }
2798
2799 if (nla_put_u64(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2801 pSirWifiScanResult->ts) )
2802 {
2803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2804 goto fail;
2805 }
2806 if (nla_put(skb,
2807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2808 sizeof(pSirWifiScanResult->ssid),
2809 pSirWifiScanResult->ssid) )
2810 {
2811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2812 goto fail;
2813 }
2814 if (nla_put(skb,
2815 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2816 sizeof(pSirWifiScanResult->bssid),
2817 pSirWifiScanResult->bssid) )
2818 {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2820 goto fail;
2821 }
2822 if (nla_put_u32(skb,
2823 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2824 pSirWifiScanResult->channel) )
2825 {
2826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2827 goto fail;
2828 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302829 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2831 pSirWifiScanResult->rssi) )
2832 {
2833 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2834 goto fail;
2835 }
2836 if (nla_put_u32(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2838 pSirWifiScanResult->rtt) )
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843 if (nla_put_u32(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2845 pSirWifiScanResult->rtt_sd))
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 nla_nest_end(skb, ap);
2852 }
2853 nla_nest_end(skb, aps);
2854
2855 }
2856 cfg80211_vendor_event(skb, GFP_KERNEL);
2857 } while (totalResults > 0);
2858
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302859 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302860 return;
2861fail:
2862 kfree_skb(skb);
2863 return;
2864}
2865
2866static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2867 void *pMsg)
2868{
2869 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2870 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2871 struct sk_buff *skb = NULL;
2872 tANI_U32 i;
2873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302874 ENTER();
2875
2876 if (wlan_hdd_validate_context(pHddCtx)) {
2877 return;
2878 }
2879 if (!pMsg)
2880 {
2881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302882 return;
2883 }
2884
2885 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2886 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2887 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2888 GFP_KERNEL);
2889
2890 if (!skb) {
2891 hddLog(VOS_TRACE_LEVEL_ERROR,
2892 FL("cfg80211_vendor_event_alloc failed"));
2893 return;
2894 }
2895 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2896 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2897 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2898 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2899
2900 for (i = 0; i < pData->numOfAps; i++) {
2901 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2902 "Ssid (%s) "
2903 "Bssid (" MAC_ADDRESS_STR ") "
2904 "Channel (%u) "
2905 "Rssi (%d) "
2906 "RTT (%u) "
2907 "RTT_SD (%u) ",
2908 i,
2909 pData->ap[i].ts,
2910 pData->ap[i].ssid,
2911 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2912 pData->ap[i].channel,
2913 pData->ap[i].rssi,
2914 pData->ap[i].rtt,
2915 pData->ap[i].rtt_sd);
2916 }
2917
2918 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2919 pData->requestId) ||
2920 nla_put_u32(skb,
2921 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2922 pData->numOfAps)) {
2923 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2924 goto fail;
2925 }
2926 if (pData->numOfAps) {
2927 struct nlattr *aps;
2928
2929 aps = nla_nest_start(skb,
2930 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2931 if (!aps)
2932 goto fail;
2933
2934 for (i = 0; i < pData->numOfAps; i++) {
2935 struct nlattr *ap;
2936
2937 ap = nla_nest_start(skb, i + 1);
2938 if (!ap)
2939 goto fail;
2940
2941 if (nla_put_u64(skb,
2942 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2943 pData->ap[i].ts) ||
2944 nla_put(skb,
2945 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2946 sizeof(pData->ap[i].ssid),
2947 pData->ap[i].ssid) ||
2948 nla_put(skb,
2949 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2950 sizeof(pData->ap[i].bssid),
2951 pData->ap[i].bssid) ||
2952 nla_put_u32(skb,
2953 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2954 pData->ap[i].channel) ||
2955 nla_put_s32(skb,
2956 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2957 pData->ap[i].rssi) ||
2958 nla_put_u32(skb,
2959 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2960 pData->ap[i].rtt) ||
2961 nla_put_u32(skb,
2962 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2963 pData->ap[i].rtt_sd))
2964 goto fail;
2965
2966 nla_nest_end(skb, ap);
2967 }
2968 nla_nest_end(skb, aps);
2969
2970 if (nla_put_u8(skb,
2971 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2972 pData->moreData))
2973 goto fail;
2974 }
2975
2976 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302977 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302978 return;
2979
2980fail:
2981 kfree_skb(skb);
2982 return;
2983
2984}
2985static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2986 void *pMsg)
2987{
2988 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2989 struct sk_buff *skb = NULL;
2990 tANI_U32 i, j;
2991 tpSirWifiSignificantChangeEvent pData =
2992 (tpSirWifiSignificantChangeEvent) pMsg;
2993
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302994 ENTER();
2995
2996 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302997 return;
2998 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302999 if (!pMsg)
3000 {
3001 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3002 return;
3003 }
3004
Dino Mycle6fb96c12014-06-10 11:52:40 +05303005 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3006 EXTSCAN_EVENT_BUF_SIZE,
3007 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3008 GFP_KERNEL);
3009
3010 if (!skb) {
3011 hddLog(VOS_TRACE_LEVEL_ERROR,
3012 FL("cfg80211_vendor_event_alloc failed"));
3013 return;
3014 }
3015 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3016 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3017 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3018 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3019 pData->numSigRssiBss);
3020 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3021
3022 for (i = 0; i < pData->numSigRssiBss; i++) {
3023 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3024 " num RSSI %u ",
3025 i, pData->sigRssiResult[i].bssid,
3026 pData->sigRssiResult[i].channel,
3027 pData->sigRssiResult[i].numRssi);
3028
3029 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3030
3031 hddLog(VOS_TRACE_LEVEL_INFO,
3032 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303033 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303034
3035 }
3036 }
3037
3038
3039 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3040 pData->requestId) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3043 pData->numSigRssiBss)) {
3044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3045 goto fail;
3046 }
3047
3048 if (pData->numSigRssiBss) {
3049 struct nlattr *aps;
3050 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3051 if (!aps)
3052 goto fail;
3053 for (i = 0; i < pData->numSigRssiBss; i++) {
3054 struct nlattr *ap;
3055
3056 ap = nla_nest_start(skb, i);
3057 if (!ap)
3058 goto fail;
3059 if (nla_put(skb,
3060 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3061 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3062 nla_put_u32(skb,
3063 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3064 pData->sigRssiResult[i].channel) ||
3065 nla_put_u32(skb,
3066 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3067 pData->sigRssiResult[i].numRssi) ||
3068 nla_put(skb,
3069 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3070 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3071 pData->sigRssiResult[i].rssi))
3072 goto fail;
3073 nla_nest_end(skb, ap);
3074 }
3075 nla_nest_end(skb, aps);
3076 if (nla_put_u8(skb,
3077 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3078 pData->moreData))
3079 goto fail;
3080 }
3081 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303083 return;
3084fail:
3085 kfree_skb(skb);
3086 return;
3087}
3088
3089static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3090 void *pMsg)
3091{
3092 struct sk_buff *skb;
3093 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3094 tpSirWifiFullScanResultEvent pData =
3095 (tpSirWifiFullScanResultEvent) (pMsg);
3096
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303097 ENTER();
3098
3099 if (wlan_hdd_validate_context(pHddCtx)) {
3100 return;
3101 }
3102 if (!pMsg)
3103 {
3104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303105 return;
3106 }
3107
3108 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3109 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3110 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3111 GFP_KERNEL);
3112
3113 if (!skb) {
3114 hddLog(VOS_TRACE_LEVEL_ERROR,
3115 FL("cfg80211_vendor_event_alloc failed"));
3116 return;
3117 }
3118
3119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3121 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3122 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3123 "Ssid (%s)"
3124 "Bssid (" MAC_ADDRESS_STR ")"
3125 "Channel (%u)"
3126 "Rssi (%d)"
3127 "RTT (%u)"
3128 "RTT_SD (%u)"),
3129 pData->ap.ts,
3130 pData->ap.ssid,
3131 MAC_ADDR_ARRAY(pData->ap.bssid),
3132 pData->ap.channel,
3133 pData->ap.rssi,
3134 pData->ap.rtt,
3135 pData->ap.rtt_sd);
3136 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3137 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3138 pData->requestId) ||
3139 nla_put_u64(skb,
3140 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3141 pData->ap.ts) ||
3142 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3143 sizeof(pData->ap.ssid),
3144 pData->ap.ssid) ||
3145 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3146 WNI_CFG_BSSID_LEN,
3147 pData->ap.bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3150 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303151 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303152 pData->ap.rssi) ||
3153 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3154 pData->ap.rtt) ||
3155 nla_put_u32(skb,
3156 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3157 pData->ap.rtt_sd) ||
3158 nla_put_u16(skb,
3159 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3160 pData->ap.beaconPeriod) ||
3161 nla_put_u16(skb,
3162 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3163 pData->ap.capability) ||
3164 nla_put_u32(skb,
3165 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3166 pData->ieLength))
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3169 goto nla_put_failure;
3170 }
3171 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3172 pData->ieLength,
3173 pData->ie))
3174 {
3175 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3176 goto nla_put_failure;
3177 }
3178
3179 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303180 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303181 return;
3182
3183nla_put_failure:
3184 kfree_skb(skb);
3185 return;
3186}
3187
3188static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3189 void *pMsg)
3190{
3191 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3192 struct sk_buff *skb = NULL;
3193 tpSirEXTScanResultsAvailableIndParams pData =
3194 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3195
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303196 ENTER();
3197
3198 if (wlan_hdd_validate_context(pHddCtx)){
3199 return;
3200 }
3201 if (!pMsg)
3202 {
3203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303204 return;
3205 }
3206
3207 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3208 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3209 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3210 GFP_KERNEL);
3211
3212 if (!skb) {
3213 hddLog(VOS_TRACE_LEVEL_ERROR,
3214 FL("cfg80211_vendor_event_alloc failed"));
3215 return;
3216 }
3217
3218 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3219 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3220 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3221 pData->numResultsAvailable);
3222 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3223 pData->requestId) ||
3224 nla_put_u32(skb,
3225 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3226 pData->numResultsAvailable)) {
3227 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3228 goto nla_put_failure;
3229 }
3230
3231 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303232 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303233 return;
3234
3235nla_put_failure:
3236 kfree_skb(skb);
3237 return;
3238}
3239
3240static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3241{
3242 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3243 struct sk_buff *skb = NULL;
3244 tpSirEXTScanProgressIndParams pData =
3245 (tpSirEXTScanProgressIndParams) pMsg;
3246
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303247 ENTER();
3248
3249 if (wlan_hdd_validate_context(pHddCtx)){
3250 return;
3251 }
3252 if (!pMsg)
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303255 return;
3256 }
3257
3258 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3259 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3260 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3261 GFP_KERNEL);
3262
3263 if (!skb) {
3264 hddLog(VOS_TRACE_LEVEL_ERROR,
3265 FL("cfg80211_vendor_event_alloc failed"));
3266 return;
3267 }
3268 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3270 pData->extScanEventType);
3271 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3272 pData->status);
3273
3274 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3275 pData->extScanEventType) ||
3276 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303277 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3278 pData->requestId) ||
3279 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303280 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3281 pData->status)) {
3282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3283 goto nla_put_failure;
3284 }
3285
3286 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303287 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303288 return;
3289
3290nla_put_failure:
3291 kfree_skb(skb);
3292 return;
3293}
3294
3295void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3296 void *pMsg)
3297{
3298 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3299
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303300 ENTER();
3301
Dino Mycle6fb96c12014-06-10 11:52:40 +05303302 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303303 return;
3304 }
3305
3306 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3307
3308
3309 switch(evType) {
3310 case SIR_HAL_EXTSCAN_START_RSP:
3311 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3312 break;
3313
3314 case SIR_HAL_EXTSCAN_STOP_RSP:
3315 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3316 break;
3317 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3318 /* There is no need to send this response to upper layer
3319 Just log the message */
3320 hddLog(VOS_TRACE_LEVEL_INFO,
3321 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3322 break;
3323 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3324 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3325 break;
3326
3327 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3328 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3329 break;
3330
3331 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3332 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3333 break;
3334
3335 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3336 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3337 break;
3338 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3339 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3340 break;
3341 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3342 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3343 break;
3344 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3345 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3346 break;
3347 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3348 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3349 break;
3350 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3351 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3352 break;
3353 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3354 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3355 break;
3356 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3357 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3358 break;
3359 default:
3360 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3361 break;
3362 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303363 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364}
3365
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303366static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3367 struct wireless_dev *wdev,
3368 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369{
Dino Myclee8843b32014-07-04 14:21:45 +05303370 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303371 struct net_device *dev = wdev->netdev;
3372 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3373 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3374 struct nlattr
3375 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3376 eHalStatus status;
3377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303378 ENTER();
3379
Dino Mycle6fb96c12014-06-10 11:52:40 +05303380 status = wlan_hdd_validate_context(pHddCtx);
3381 if (0 != status)
3382 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return -EINVAL;
3384 }
Dino Myclee8843b32014-07-04 14:21:45 +05303385 /* check the EXTScan Capability */
3386 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3387 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3388 {
3389 hddLog(VOS_TRACE_LEVEL_ERROR,
3390 FL("EXTScan not enabled/supported by Firmware"));
3391 return -EINVAL;
3392 }
3393
Dino Mycle6fb96c12014-06-10 11:52:40 +05303394 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3395 data, dataLen,
3396 wlan_hdd_extscan_config_policy)) {
3397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3398 return -EINVAL;
3399 }
3400
3401 /* Parse and fetch request Id */
3402 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3404 return -EINVAL;
3405 }
3406
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407
Dino Myclee8843b32014-07-04 14:21:45 +05303408 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303410 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303411
Dino Myclee8843b32014-07-04 14:21:45 +05303412 reqMsg.sessionId = pAdapter->sessionId;
3413 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303414
Dino Myclee8843b32014-07-04 14:21:45 +05303415 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303416 if (!HAL_STATUS_SUCCESS(status)) {
3417 hddLog(VOS_TRACE_LEVEL_ERROR,
3418 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303419 return -EINVAL;
3420 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303421 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303422 return 0;
3423}
3424
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303425static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3426 struct wireless_dev *wdev,
3427 const void *data, int dataLen)
3428{
3429 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303430
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303431 vos_ssr_protect(__func__);
3432 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3433 vos_ssr_unprotect(__func__);
3434
3435 return ret;
3436}
3437
3438static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3439 struct wireless_dev *wdev,
3440 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441{
Dino Myclee8843b32014-07-04 14:21:45 +05303442 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303443 struct net_device *dev = wdev->netdev;
3444 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3445 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3446 struct nlattr
3447 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3448 eHalStatus status;
3449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303450 ENTER();
3451
Dino Mycle6fb96c12014-06-10 11:52:40 +05303452 status = wlan_hdd_validate_context(pHddCtx);
3453 if (0 != status)
3454 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303455 return -EINVAL;
3456 }
Dino Myclee8843b32014-07-04 14:21:45 +05303457 /* check the EXTScan Capability */
3458 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3459 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3460 {
3461 hddLog(VOS_TRACE_LEVEL_ERROR,
3462 FL("EXTScan not enabled/supported by Firmware"));
3463 return -EINVAL;
3464 }
3465
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3467 data, dataLen,
3468 wlan_hdd_extscan_config_policy)) {
3469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3470 return -EINVAL;
3471 }
3472 /* Parse and fetch request Id */
3473 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3475 return -EINVAL;
3476 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477
Dino Myclee8843b32014-07-04 14:21:45 +05303478 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303479 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3480
Dino Myclee8843b32014-07-04 14:21:45 +05303481 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303482
Dino Myclee8843b32014-07-04 14:21:45 +05303483 reqMsg.sessionId = pAdapter->sessionId;
3484 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303485
3486 /* Parse and fetch flush parameter */
3487 if (!tb
3488 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3489 {
3490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3491 goto failed;
3492 }
Dino Myclee8843b32014-07-04 14:21:45 +05303493 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303494 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3495
Dino Myclee8843b32014-07-04 14:21:45 +05303496 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303497
Dino Myclee8843b32014-07-04 14:21:45 +05303498 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303499 if (!HAL_STATUS_SUCCESS(status)) {
3500 hddLog(VOS_TRACE_LEVEL_ERROR,
3501 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502 return -EINVAL;
3503 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303504 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303505 return 0;
3506
3507failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303508 return -EINVAL;
3509}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303510static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3511 struct wireless_dev *wdev,
3512 const void *data, int dataLen)
3513{
3514 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303515
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303516 vos_ssr_protect(__func__);
3517 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3518 vos_ssr_unprotect(__func__);
3519
3520 return ret;
3521}
3522
3523static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303525 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303526{
3527 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3528 struct net_device *dev = wdev->netdev;
3529 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3530 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3531 struct nlattr
3532 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr
3534 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3535 struct nlattr *apTh;
3536 eHalStatus status;
3537 tANI_U8 i = 0;
3538 int rem;
3539
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303540 ENTER();
3541
Dino Mycle6fb96c12014-06-10 11:52:40 +05303542 status = wlan_hdd_validate_context(pHddCtx);
3543 if (0 != status)
3544 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303545 return -EINVAL;
3546 }
Dino Myclee8843b32014-07-04 14:21:45 +05303547 /* check the EXTScan Capability */
3548 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3549 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3550 {
3551 hddLog(VOS_TRACE_LEVEL_ERROR,
3552 FL("EXTScan not enabled/supported by Firmware"));
3553 return -EINVAL;
3554 }
3555
Dino Mycle6fb96c12014-06-10 11:52:40 +05303556 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3557 data, dataLen,
3558 wlan_hdd_extscan_config_policy)) {
3559 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3560 return -EINVAL;
3561 }
3562
3563 /* Parse and fetch request Id */
3564 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3566 return -EINVAL;
3567 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303568 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3569 vos_mem_malloc(sizeof(*pReqMsg));
3570 if (!pReqMsg) {
3571 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3572 return -ENOMEM;
3573 }
3574
Dino Myclee8843b32014-07-04 14:21:45 +05303575
Dino Mycle6fb96c12014-06-10 11:52:40 +05303576 pReqMsg->requestId = nla_get_u32(
3577 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3578 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3579
3580 /* Parse and fetch number of APs */
3581 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3583 goto fail;
3584 }
3585
3586 pReqMsg->sessionId = pAdapter->sessionId;
3587 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3588
3589 pReqMsg->numAp = nla_get_u32(
3590 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3592
3593 nla_for_each_nested(apTh,
3594 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3595 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3596 nla_data(apTh), nla_len(apTh),
3597 NULL)) {
3598 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3599 goto fail;
3600 }
3601
3602 /* Parse and fetch MAC address */
3603 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3604 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3605 goto fail;
3606 }
3607 memcpy(pReqMsg->ap[i].bssid, nla_data(
3608 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3609 sizeof(tSirMacAddr));
3610 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3611
3612 /* Parse and fetch low RSSI */
3613 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3615 goto fail;
3616 }
3617 pReqMsg->ap[i].low = nla_get_s32(
3618 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3619 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3620
3621 /* Parse and fetch high RSSI */
3622 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3624 goto fail;
3625 }
3626 pReqMsg->ap[i].high = nla_get_s32(
3627 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3628 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3629 pReqMsg->ap[i].high);
3630
3631 /* Parse and fetch channel */
3632 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3633 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3634 goto fail;
3635 }
3636 pReqMsg->ap[i].channel = nla_get_u32(
3637 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3638 hddLog(VOS_TRACE_LEVEL_INFO,
3639 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3640 i++;
3641 }
3642 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3643 if (!HAL_STATUS_SUCCESS(status)) {
3644 hddLog(VOS_TRACE_LEVEL_ERROR,
3645 FL("sme_SetBssHotlist failed(err=%d)"), status);
3646 vos_mem_free(pReqMsg);
3647 return -EINVAL;
3648 }
3649
Dino Myclee8843b32014-07-04 14:21:45 +05303650 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303651 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303652 return 0;
3653
3654fail:
3655 vos_mem_free(pReqMsg);
3656 return -EINVAL;
3657}
3658
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303659static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3660 struct wireless_dev *wdev,
3661 const void *data, int dataLen)
3662{
3663 int ret = 0;
3664
3665 vos_ssr_protect(__func__);
3666 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3667 dataLen);
3668 vos_ssr_unprotect(__func__);
3669
3670 return ret;
3671}
3672
3673static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303675 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303676{
3677 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3678 struct net_device *dev = wdev->netdev;
3679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3680 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3681 struct nlattr
3682 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr
3684 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3685 struct nlattr *apTh;
3686 eHalStatus status;
3687 int i = 0;
3688 int rem;
3689
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303690 ENTER();
3691
Dino Mycle6fb96c12014-06-10 11:52:40 +05303692 status = wlan_hdd_validate_context(pHddCtx);
3693 if (0 != status)
3694 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303695 return -EINVAL;
3696 }
Dino Myclee8843b32014-07-04 14:21:45 +05303697 /* check the EXTScan Capability */
3698 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3699 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3700 {
3701 hddLog(VOS_TRACE_LEVEL_ERROR,
3702 FL("EXTScan not enabled/supported by Firmware"));
3703 return -EINVAL;
3704 }
3705
Dino Mycle6fb96c12014-06-10 11:52:40 +05303706 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3707 data, dataLen,
3708 wlan_hdd_extscan_config_policy)) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3710 return -EINVAL;
3711 }
3712
3713 /* Parse and fetch request Id */
3714 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3716 return -EINVAL;
3717 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303719 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3722 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303723 }
3724
Dino Myclee8843b32014-07-04 14:21:45 +05303725
3726
Dino Mycle6fb96c12014-06-10 11:52:40 +05303727 pReqMsg->requestId = nla_get_u32(
3728 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3729 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3730
3731 /* Parse and fetch RSSI sample size */
3732 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3733 {
3734 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3735 goto fail;
3736 }
3737 pReqMsg->rssiSampleSize = nla_get_u32(
3738 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3739 hddLog(VOS_TRACE_LEVEL_INFO,
3740 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3741
3742 /* Parse and fetch lost AP sample size */
3743 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3744 {
3745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3746 goto fail;
3747 }
3748 pReqMsg->lostApSampleSize = nla_get_u32(
3749 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3750 hddLog(VOS_TRACE_LEVEL_INFO,
3751 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3752 /* Parse and fetch minimum Breaching */
3753 if (!tb
3754 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3756 goto fail;
3757 }
3758 pReqMsg->minBreaching = nla_get_u32(
3759 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3760 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3761
3762 /* Parse and fetch number of APs */
3763 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3765 goto fail;
3766 }
3767 pReqMsg->numAp = nla_get_u32(
3768 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3769 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3770
3771 pReqMsg->sessionId = pAdapter->sessionId;
3772 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3773
3774 nla_for_each_nested(apTh,
3775 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3776 if(nla_parse(tb2,
3777 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3778 nla_data(apTh), nla_len(apTh),
3779 NULL)) {
3780 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3781 goto fail;
3782 }
3783
3784 /* Parse and fetch MAC address */
3785 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3787 goto fail;
3788 }
3789 memcpy(pReqMsg->ap[i].bssid, nla_data(
3790 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3791 sizeof(tSirMacAddr));
3792
3793 /* Parse and fetch low RSSI */
3794 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3796 goto fail;
3797 }
3798 pReqMsg->ap[i].low = nla_get_s32(
3799 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3800 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3801
3802 /* Parse and fetch high RSSI */
3803 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3805 goto fail;
3806 }
3807 pReqMsg->ap[i].high = nla_get_s32(
3808 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3809 hddLog(VOS_TRACE_LEVEL_INFO,
3810 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3811
3812 /* Parse and fetch channel */
3813 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3815 goto fail;
3816 }
3817 pReqMsg->ap[i].channel = nla_get_u32(
3818 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3819 hddLog(VOS_TRACE_LEVEL_INFO,
3820 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3821 i++;
3822 }
3823
3824 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3825 if (!HAL_STATUS_SUCCESS(status)) {
3826 hddLog(VOS_TRACE_LEVEL_ERROR,
3827 FL("sme_SetSignificantChange failed(err=%d)"), status);
3828 vos_mem_free(pReqMsg);
3829 return -EINVAL;
3830 }
Dino Myclee8843b32014-07-04 14:21:45 +05303831 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303832 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303833 return 0;
3834
3835fail:
3836 vos_mem_free(pReqMsg);
3837 return -EINVAL;
3838}
3839
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303840static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3841 struct wireless_dev *wdev,
3842 const void *data, int dataLen)
3843{
3844 int ret = 0;
3845
3846 vos_ssr_protect(__func__);
3847 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3848 dataLen);
3849 vos_ssr_unprotect(__func__);
3850
3851 return ret;
3852}
3853
3854static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303856 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303857{
3858 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3859 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3860 tANI_U8 numChannels = 0;
3861 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3862 tANI_U32 requestId;
3863 tWifiBand wifiBand;
3864 eHalStatus status;
3865 struct sk_buff *replySkb;
3866 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303867 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303868
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303869 ENTER();
3870
Dino Mycle6fb96c12014-06-10 11:52:40 +05303871 status = wlan_hdd_validate_context(pHddCtx);
3872 if (0 != status)
3873 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303874 return -EINVAL;
3875 }
Dino Myclee8843b32014-07-04 14:21:45 +05303876 /* check the EXTScan Capability */
3877 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3878 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3879 {
3880 hddLog(VOS_TRACE_LEVEL_ERROR,
3881 FL("EXTScan not enabled/supported by Firmware"));
3882 return -EINVAL;
3883 }
3884
Dino Mycle6fb96c12014-06-10 11:52:40 +05303885 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3886 data, dataLen,
3887 wlan_hdd_extscan_config_policy)) {
3888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3889 return -EINVAL;
3890 }
3891
3892 /* Parse and fetch request Id */
3893 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3895 return -EINVAL;
3896 }
3897 requestId = nla_get_u32(
3898 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3899 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3900
3901 /* Parse and fetch wifi band */
3902 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3903 {
3904 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3905 return -EINVAL;
3906 }
3907 wifiBand = nla_get_u32(
3908 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3909 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3910
3911 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3912 wifiBand, ChannelList,
3913 &numChannels);
3914 if (eHAL_STATUS_SUCCESS != status) {
3915 hddLog(VOS_TRACE_LEVEL_ERROR,
3916 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3917 return -EINVAL;
3918 }
3919 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3920 for (i = 0; i < numChannels; i++)
3921 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3922
3923 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3924 sizeof(u32) * numChannels +
3925 NLMSG_HDRLEN);
3926
3927 if (!replySkb) {
3928 hddLog(VOS_TRACE_LEVEL_ERROR,
3929 FL("valid channels: buffer alloc fail"));
3930 return -EINVAL;
3931 }
3932 if (nla_put_u32(replySkb,
3933 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3934 numChannels) ||
3935 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3936 sizeof(u32) * numChannels, ChannelList)) {
3937
3938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3939 kfree_skb(replySkb);
3940 return -EINVAL;
3941 }
3942
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303943 ret = cfg80211_vendor_cmd_reply(replySkb);
3944
3945 EXIT();
3946 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303947}
3948
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303949static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3950 struct wireless_dev *wdev,
3951 const void *data, int dataLen)
3952{
3953 int ret = 0;
3954
3955 vos_ssr_protect(__func__);
3956 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3957 dataLen);
3958 vos_ssr_unprotect(__func__);
3959
3960 return ret;
3961}
3962
3963static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303964 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303965 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966{
Dino Myclee8843b32014-07-04 14:21:45 +05303967 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303968 struct net_device *dev = wdev->netdev;
3969 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3970 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3971 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3972 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3973 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3974 struct nlattr *buckets;
3975 struct nlattr *channels;
3976 int rem1;
3977 int rem2;
3978 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303979 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303981 ENTER();
3982
Dino Mycle6fb96c12014-06-10 11:52:40 +05303983 status = wlan_hdd_validate_context(pHddCtx);
3984 if (0 != status)
3985 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303986 return -EINVAL;
3987 }
Dino Myclee8843b32014-07-04 14:21:45 +05303988 /* check the EXTScan Capability */
3989 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3990 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3991 {
3992 hddLog(VOS_TRACE_LEVEL_ERROR,
3993 FL("EXTScan not enabled/supported by Firmware"));
3994 return -EINVAL;
3995 }
3996
Dino Mycle6fb96c12014-06-10 11:52:40 +05303997 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3998 data, dataLen,
3999 wlan_hdd_extscan_config_policy)) {
4000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4001 return -EINVAL;
4002 }
4003
4004 /* Parse and fetch request Id */
4005 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4007 return -EINVAL;
4008 }
4009
Dino Myclee8843b32014-07-04 14:21:45 +05304010 pReqMsg = (tpSirEXTScanStartReqParams)
4011 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304012 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304013 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4014 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304015 }
4016
4017 pReqMsg->requestId = nla_get_u32(
4018 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4019 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4020
4021 pReqMsg->sessionId = pAdapter->sessionId;
4022 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4023
4024 /* Parse and fetch base period */
4025 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4027 goto fail;
4028 }
4029 pReqMsg->basePeriod = nla_get_u32(
4030 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4031 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4032 pReqMsg->basePeriod);
4033
4034 /* Parse and fetch max AP per scan */
4035 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4036 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4037 goto fail;
4038 }
4039 pReqMsg->maxAPperScan = nla_get_u32(
4040 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4041 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4042 pReqMsg->maxAPperScan);
4043
4044 /* Parse and fetch report threshold */
4045 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4047 goto fail;
4048 }
4049 pReqMsg->reportThreshold = nla_get_u8(
4050 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4051 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4052 pReqMsg->reportThreshold);
4053
4054 /* Parse and fetch number of buckets */
4055 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4056 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4057 goto fail;
4058 }
4059 pReqMsg->numBuckets = nla_get_u8(
4060 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4061 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4062 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4063 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4064 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4065 }
4066 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4067 pReqMsg->numBuckets);
4068 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4070 goto fail;
4071 }
4072
4073 nla_for_each_nested(buckets,
4074 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4075 if(nla_parse(bucket,
4076 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4077 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4078 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4079 goto fail;
4080 }
4081
4082 /* Parse and fetch bucket spec */
4083 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4085 goto fail;
4086 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304087
4088 pReqMsg->buckets[index].bucket = nla_get_u8(
4089 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4090
4091 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4092 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304093
4094 /* Parse and fetch wifi band */
4095 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4097 goto fail;
4098 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304099 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304100 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304102 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304103
4104 /* Parse and fetch period */
4105 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4106 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4107 goto fail;
4108 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304109 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304110 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4111 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304112 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304113
4114 /* Parse and fetch report events */
4115 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4117 goto fail;
4118 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304119 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304120 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4121 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304122 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304123
4124 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304125 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4126 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304127 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4128 goto fail;
4129 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304130 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304131 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4132 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304133 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304134
4135 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4137 goto fail;
4138 }
4139
4140 j = 0;
4141 nla_for_each_nested(channels,
4142 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4143 if(nla_parse(channel,
4144 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4145 nla_data(channels), nla_len(channels),
4146 NULL)) { //wlan_hdd_extscan_config_policy here
4147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4148 goto fail;
4149 }
4150
4151 /* Parse and fetch channel */
4152 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4154 goto fail;
4155 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304156 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304157 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4158 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304159 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304160
4161 /* Parse and fetch dwell time */
4162 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4163 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4164 goto fail;
4165 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304166 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304167 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4168 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304169 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304170
4171 /* Parse and fetch channel spec passive */
4172 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4173 hddLog(VOS_TRACE_LEVEL_ERROR,
4174 FL("attr channel spec passive failed"));
4175 goto fail;
4176 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304177 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304178 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4179 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304180 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304181 j++;
4182 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304183 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304184 }
4185 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4186 if (!HAL_STATUS_SUCCESS(status)) {
4187 hddLog(VOS_TRACE_LEVEL_ERROR,
4188 FL("sme_EXTScanStart failed(err=%d)"), status);
4189 vos_mem_free(pReqMsg);
4190 return -EINVAL;
4191 }
4192
Dino Myclee8843b32014-07-04 14:21:45 +05304193 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304194 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304195 return 0;
4196
4197fail:
4198 vos_mem_free(pReqMsg);
4199 return -EINVAL;
4200}
4201
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304202static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4203 struct wireless_dev *wdev,
4204 const void *data, int dataLen)
4205{
4206 int ret = 0;
4207
4208 vos_ssr_protect(__func__);
4209 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4210 vos_ssr_unprotect(__func__);
4211
4212 return ret;
4213}
4214
4215static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304217 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218{
Dino Myclee8843b32014-07-04 14:21:45 +05304219 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304220 struct net_device *dev = wdev->netdev;
4221 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4222 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4223 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4224 eHalStatus status;
4225
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304226 ENTER();
4227
Dino Mycle6fb96c12014-06-10 11:52:40 +05304228 status = wlan_hdd_validate_context(pHddCtx);
4229 if (0 != status)
4230 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304231 return -EINVAL;
4232 }
Dino Myclee8843b32014-07-04 14:21:45 +05304233 /* check the EXTScan Capability */
4234 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4235 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4236 {
4237 hddLog(VOS_TRACE_LEVEL_ERROR,
4238 FL("EXTScan not enabled/supported by Firmware"));
4239 return -EINVAL;
4240 }
4241
Dino Mycle6fb96c12014-06-10 11:52:40 +05304242 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4243 data, dataLen,
4244 wlan_hdd_extscan_config_policy)) {
4245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4246 return -EINVAL;
4247 }
4248
4249 /* Parse and fetch request Id */
4250 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4252 return -EINVAL;
4253 }
4254
Dino Myclee8843b32014-07-04 14:21:45 +05304255 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304257 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304258
Dino Myclee8843b32014-07-04 14:21:45 +05304259 reqMsg.sessionId = pAdapter->sessionId;
4260 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261
Dino Myclee8843b32014-07-04 14:21:45 +05304262 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304263 if (!HAL_STATUS_SUCCESS(status)) {
4264 hddLog(VOS_TRACE_LEVEL_ERROR,
4265 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304266 return -EINVAL;
4267 }
4268
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304270 return 0;
4271}
4272
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304273static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4274 struct wireless_dev *wdev,
4275 const void *data, int dataLen)
4276{
4277 int ret = 0;
4278
4279 vos_ssr_protect(__func__);
4280 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4281 vos_ssr_unprotect(__func__);
4282
4283 return ret;
4284}
4285
4286static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304288 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304289{
Dino Myclee8843b32014-07-04 14:21:45 +05304290 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304291 struct net_device *dev = wdev->netdev;
4292 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4293 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4294 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4295 eHalStatus status;
4296
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304297 ENTER();
4298
Dino Mycle6fb96c12014-06-10 11:52:40 +05304299 status = wlan_hdd_validate_context(pHddCtx);
4300 if (0 != status)
4301 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304302 return -EINVAL;
4303 }
Dino Myclee8843b32014-07-04 14:21:45 +05304304 /* check the EXTScan Capability */
4305 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4306 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4307 {
4308 hddLog(VOS_TRACE_LEVEL_ERROR,
4309 FL("EXTScan not enabled/supported by Firmware"));
4310 return -EINVAL;
4311 }
4312
Dino Mycle6fb96c12014-06-10 11:52:40 +05304313 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4314 data, dataLen,
4315 wlan_hdd_extscan_config_policy)) {
4316 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4317 return -EINVAL;
4318 }
4319
4320 /* Parse and fetch request Id */
4321 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4323 return -EINVAL;
4324 }
4325
Dino Myclee8843b32014-07-04 14:21:45 +05304326 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304328 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304329
Dino Myclee8843b32014-07-04 14:21:45 +05304330 reqMsg.sessionId = pAdapter->sessionId;
4331 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304332
Dino Myclee8843b32014-07-04 14:21:45 +05304333 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304334 if (!HAL_STATUS_SUCCESS(status)) {
4335 hddLog(VOS_TRACE_LEVEL_ERROR,
4336 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304337 return -EINVAL;
4338 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304339 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304340 return 0;
4341}
4342
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304343static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4344 struct wireless_dev *wdev,
4345 const void *data, int dataLen)
4346{
4347 int ret = 0;
4348
4349 vos_ssr_protect(__func__);
4350 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4351 vos_ssr_unprotect(__func__);
4352
4353 return ret;
4354}
4355
4356static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 struct wiphy *wiphy,
4358 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304359 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360{
Dino Myclee8843b32014-07-04 14:21:45 +05304361 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304362 struct net_device *dev = wdev->netdev;
4363 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4364 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4365 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4366 eHalStatus status;
4367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304368 ENTER();
4369
Dino Mycle6fb96c12014-06-10 11:52:40 +05304370 status = wlan_hdd_validate_context(pHddCtx);
4371 if (0 != status)
4372 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304373 return -EINVAL;
4374 }
Dino Myclee8843b32014-07-04 14:21:45 +05304375 /* check the EXTScan Capability */
4376 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4377 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4378 {
4379 hddLog(VOS_TRACE_LEVEL_ERROR,
4380 FL("EXTScan not enabled/supported by Firmware"));
4381 return -EINVAL;
4382 }
4383
Dino Mycle6fb96c12014-06-10 11:52:40 +05304384 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4385 data, dataLen,
4386 wlan_hdd_extscan_config_policy)) {
4387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4388 return -EINVAL;
4389 }
4390
4391 /* Parse and fetch request Id */
4392 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4393 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4394 return -EINVAL;
4395 }
4396
Dino Mycle6fb96c12014-06-10 11:52:40 +05304397
Dino Myclee8843b32014-07-04 14:21:45 +05304398 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304400 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304401
Dino Myclee8843b32014-07-04 14:21:45 +05304402 reqMsg.sessionId = pAdapter->sessionId;
4403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404
Dino Myclee8843b32014-07-04 14:21:45 +05304405 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304406 if (!HAL_STATUS_SUCCESS(status)) {
4407 hddLog(VOS_TRACE_LEVEL_ERROR,
4408 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304409 return -EINVAL;
4410 }
4411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304412 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304413 return 0;
4414}
4415
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304416static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4417 struct wiphy *wiphy,
4418 struct wireless_dev *wdev,
4419 const void *data, int dataLen)
4420{
4421 int ret = 0;
4422
4423 vos_ssr_protect(__func__);
4424 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4425 wdev, data,
4426 dataLen);
4427 vos_ssr_unprotect(__func__);
4428
4429 return ret;
4430}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304431#endif /* WLAN_FEATURE_EXTSCAN */
4432
Atul Mittal115287b2014-07-08 13:26:33 +05304433/*EXT TDLS*/
4434static const struct nla_policy
4435wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4436{
4437 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4438 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4439 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4440 {.type = NLA_S32 },
4441 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4442 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4443
4444};
4445
4446static const struct nla_policy
4447wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4448{
4449 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4450
4451};
4452
4453static const struct nla_policy
4454wlan_hdd_tdls_config_state_change_policy[
4455 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4456{
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4458 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304460 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4461 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4462 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304463
4464};
4465
4466static const struct nla_policy
4467wlan_hdd_tdls_config_get_status_policy[
4468 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4469{
4470 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4471 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4472 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304473 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4474 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4475 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304476
4477};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304478
4479static const struct nla_policy
4480wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4481{
4482 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4483};
4484
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304485static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304486 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304487 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304488 int data_len)
4489{
4490
4491 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4492 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4493
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304494 ENTER();
4495
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304496 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304497 return -EINVAL;
4498 }
4499 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4501 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304502 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304503 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4504 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4505 return -ENOTSUPP;
4506 }
4507
4508 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4509 data, data_len, wlan_hdd_mac_config)) {
4510 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4511 return -EINVAL;
4512 }
4513
4514 /* Parse and fetch mac address */
4515 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4517 return -EINVAL;
4518 }
4519
4520 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4521 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4522 VOS_MAC_ADDR_LAST_3_BYTES);
4523
Siddharth Bhal76972212014-10-15 16:22:51 +05304524 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4525
4526 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304527 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4528 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304529 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4530 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4531 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4532 {
4533 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4534 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4535 VOS_MAC_ADDRESS_LEN);
4536 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304537 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304538
Siddharth Bhal76972212014-10-15 16:22:51 +05304539 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4540 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304541 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4542 }
4543
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304544 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304545 return 0;
4546}
4547
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304548static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4549 struct wireless_dev *wdev,
4550 const void *data,
4551 int data_len)
4552{
4553 int ret = 0;
4554
4555 vos_ssr_protect(__func__);
4556 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4557 vos_ssr_unprotect(__func__);
4558
4559 return ret;
4560}
4561
4562static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304563 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304564 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304565 int data_len)
4566{
4567 u8 peer[6] = {0};
4568 struct net_device *dev = wdev->netdev;
4569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4570 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4571 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4572 eHalStatus ret;
4573 tANI_S32 state;
4574 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304575 tANI_S32 global_operating_class = 0;
4576 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304577 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304578 int retVal;
4579
4580 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304581
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304582 if (!pAdapter) {
4583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4584 return -EINVAL;
4585 }
4586
Atul Mittal115287b2014-07-08 13:26:33 +05304587 ret = wlan_hdd_validate_context(pHddCtx);
4588 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304589 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304590 return -EINVAL;
4591 }
4592 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304593 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304594 return -ENOTSUPP;
4595 }
4596 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4597 data, data_len,
4598 wlan_hdd_tdls_config_get_status_policy)) {
4599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4600 return -EINVAL;
4601 }
4602
4603 /* Parse and fetch mac address */
4604 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4605 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4606 return -EINVAL;
4607 }
4608
4609 memcpy(peer, nla_data(
4610 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4611 sizeof(peer));
4612 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4613
4614 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4615
4616 if (0 != ret) {
4617 hddLog(VOS_TRACE_LEVEL_ERROR,
4618 FL("get status Failed"));
4619 return -EINVAL;
4620 }
4621 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304622 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304623 NLMSG_HDRLEN);
4624
4625 if (!skb) {
4626 hddLog(VOS_TRACE_LEVEL_ERROR,
4627 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4628 return -EINVAL;
4629 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304630 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 +05304631 reason,
4632 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304633 global_operating_class,
4634 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304635 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304636 if (nla_put_s32(skb,
4637 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4638 state) ||
4639 nla_put_s32(skb,
4640 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4641 reason) ||
4642 nla_put_s32(skb,
4643 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4644 global_operating_class) ||
4645 nla_put_s32(skb,
4646 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4647 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304648
4649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4650 goto nla_put_failure;
4651 }
4652
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304653 retVal = cfg80211_vendor_cmd_reply(skb);
4654 EXIT();
4655 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304656
4657nla_put_failure:
4658 kfree_skb(skb);
4659 return -EINVAL;
4660}
4661
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304662static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4663 struct wireless_dev *wdev,
4664 const void *data,
4665 int data_len)
4666{
4667 int ret = 0;
4668
4669 vos_ssr_protect(__func__);
4670 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4671 vos_ssr_unprotect(__func__);
4672
4673 return ret;
4674}
4675
Atul Mittal115287b2014-07-08 13:26:33 +05304676static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4677 tANI_S32 state,
4678 tANI_S32 reason,
4679 void *ctx)
4680{
4681 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304682 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304683 tANI_S32 global_operating_class = 0;
4684 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304685 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304686
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304687 ENTER();
4688
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304689 if (!pAdapter) {
4690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4691 return -EINVAL;
4692 }
4693
4694 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304695 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304697 return -EINVAL;
4698 }
4699
4700 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304701 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304702 return -ENOTSUPP;
4703 }
4704 skb = cfg80211_vendor_event_alloc(
4705 pHddCtx->wiphy,
4706 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4707 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4708 GFP_KERNEL);
4709
4710 if (!skb) {
4711 hddLog(VOS_TRACE_LEVEL_ERROR,
4712 FL("cfg80211_vendor_event_alloc failed"));
4713 return -EINVAL;
4714 }
4715 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304716 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4717 reason,
4718 state,
4719 global_operating_class,
4720 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304721 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4722 MAC_ADDR_ARRAY(mac));
4723
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304724 if (nla_put(skb,
4725 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4726 VOS_MAC_ADDR_SIZE, mac) ||
4727 nla_put_s32(skb,
4728 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4729 state) ||
4730 nla_put_s32(skb,
4731 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4732 reason) ||
4733 nla_put_s32(skb,
4734 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4735 channel) ||
4736 nla_put_s32(skb,
4737 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4738 global_operating_class)
4739 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4741 goto nla_put_failure;
4742 }
4743
4744 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304745 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304746 return (0);
4747
4748nla_put_failure:
4749 kfree_skb(skb);
4750 return -EINVAL;
4751}
4752
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304753static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304754 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304755 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304756 int data_len)
4757{
4758 u8 peer[6] = {0};
4759 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304760 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4761 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4762 eHalStatus status;
4763 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304764 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304765 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304766
4767 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304768
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304769 if (!dev) {
4770 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4771 return -EINVAL;
4772 }
4773
4774 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4775 if (!pAdapter) {
4776 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4777 return -EINVAL;
4778 }
4779
Atul Mittal115287b2014-07-08 13:26:33 +05304780 status = wlan_hdd_validate_context(pHddCtx);
4781 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304783 return -EINVAL;
4784 }
4785 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304787 return -ENOTSUPP;
4788 }
4789 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4790 data, data_len,
4791 wlan_hdd_tdls_config_enable_policy)) {
4792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4793 return -EINVAL;
4794 }
4795
4796 /* Parse and fetch mac address */
4797 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4799 return -EINVAL;
4800 }
4801
4802 memcpy(peer, nla_data(
4803 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4804 sizeof(peer));
4805 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4806
4807 /* Parse and fetch channel */
4808 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4810 return -EINVAL;
4811 }
4812 pReqMsg.channel = nla_get_s32(
4813 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4814 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4815
4816 /* Parse and fetch global operating class */
4817 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4819 return -EINVAL;
4820 }
4821 pReqMsg.global_operating_class = nla_get_s32(
4822 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4823 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4824 pReqMsg.global_operating_class);
4825
4826 /* Parse and fetch latency ms */
4827 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4828 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4829 return -EINVAL;
4830 }
4831 pReqMsg.max_latency_ms = nla_get_s32(
4832 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4833 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4834 pReqMsg.max_latency_ms);
4835
4836 /* Parse and fetch required bandwidth kbps */
4837 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4839 return -EINVAL;
4840 }
4841
4842 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4843 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4844 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4845 pReqMsg.min_bandwidth_kbps);
4846
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304847 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304848 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304849 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304850 wlan_hdd_cfg80211_exttdls_callback);
4851
4852 EXIT();
4853 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304854}
4855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304856static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4857 struct wireless_dev *wdev,
4858 const void *data,
4859 int data_len)
4860{
4861 int ret = 0;
4862
4863 vos_ssr_protect(__func__);
4864 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4865 vos_ssr_unprotect(__func__);
4866
4867 return ret;
4868}
4869
4870static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304871 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304872 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304873 int data_len)
4874{
4875 u8 peer[6] = {0};
4876 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304877 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4878 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4879 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304880 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304881 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304882
4883 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304884
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304885 if (!dev) {
4886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4887 return -EINVAL;
4888 }
4889
4890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4891 if (!pAdapter) {
4892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4893 return -EINVAL;
4894 }
4895
Atul Mittal115287b2014-07-08 13:26:33 +05304896 status = wlan_hdd_validate_context(pHddCtx);
4897 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304899 return -EINVAL;
4900 }
4901 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304903 return -ENOTSUPP;
4904 }
4905 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4906 data, data_len,
4907 wlan_hdd_tdls_config_disable_policy)) {
4908 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4909 return -EINVAL;
4910 }
4911 /* Parse and fetch mac address */
4912 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4914 return -EINVAL;
4915 }
4916
4917 memcpy(peer, nla_data(
4918 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4919 sizeof(peer));
4920 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304922 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4923
4924 EXIT();
4925 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304926}
4927
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304928static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4929 struct wireless_dev *wdev,
4930 const void *data,
4931 int data_len)
4932{
4933 int ret = 0;
4934
4935 vos_ssr_protect(__func__);
4936 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4937 vos_ssr_unprotect(__func__);
4938
4939 return ret;
4940}
4941
Dasari Srinivas7875a302014-09-26 17:50:57 +05304942static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304943__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304944 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304945 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304946{
4947 struct net_device *dev = wdev->netdev;
4948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4949 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4950 struct sk_buff *skb = NULL;
4951 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304952 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304954 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304955
4956 ret = wlan_hdd_validate_context(pHddCtx);
4957 if (0 != ret)
4958 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304959 return ret;
4960 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304961 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4962 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4963 fset |= WIFI_FEATURE_INFRA;
4964 }
4965
4966 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4967 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4968 fset |= WIFI_FEATURE_INFRA_5G;
4969 }
4970
4971#ifdef WLAN_FEATURE_P2P
4972 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4973 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4974 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4975 fset |= WIFI_FEATURE_P2P;
4976 }
4977#endif
4978
4979 /* Soft-AP is supported currently by default */
4980 fset |= WIFI_FEATURE_SOFT_AP;
4981
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304982 /* HOTSPOT is a supplicant feature, enable it by default */
4983 fset |= WIFI_FEATURE_HOTSPOT;
4984
Dasari Srinivas7875a302014-09-26 17:50:57 +05304985#ifdef WLAN_FEATURE_EXTSCAN
4986 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4987 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4988 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4989 fset |= WIFI_FEATURE_EXTSCAN;
4990 }
4991#endif
4992
Dasari Srinivas7875a302014-09-26 17:50:57 +05304993 if (sme_IsFeatureSupportedByFW(NAN)) {
4994 hddLog(LOG1, FL("NAN is supported by firmware"));
4995 fset |= WIFI_FEATURE_NAN;
4996 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304997
4998 /* D2D RTT is not supported currently by default */
4999 if (sme_IsFeatureSupportedByFW(RTT)) {
5000 hddLog(LOG1, FL("RTT is supported by firmware"));
5001 fset |= WIFI_FEATURE_D2AP_RTT;
5002 }
5003
5004#ifdef FEATURE_WLAN_BATCH_SCAN
5005 if (fset & WIFI_FEATURE_EXTSCAN) {
5006 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5007 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5008 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5009 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5010 fset |= WIFI_FEATURE_BATCH_SCAN;
5011 }
5012#endif
5013
5014#ifdef FEATURE_WLAN_SCAN_PNO
5015 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5016 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5017 hddLog(LOG1, FL("PNO is supported by firmware"));
5018 fset |= WIFI_FEATURE_PNO;
5019 }
5020#endif
5021
5022 /* STA+STA is supported currently by default */
5023 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5024
5025#ifdef FEATURE_WLAN_TDLS
5026 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5027 sme_IsFeatureSupportedByFW(TDLS)) {
5028 hddLog(LOG1, FL("TDLS is supported by firmware"));
5029 fset |= WIFI_FEATURE_TDLS;
5030 }
5031
5032 /* TDLS_OFFCHANNEL is not supported currently by default */
5033#endif
5034
5035#ifdef WLAN_AP_STA_CONCURRENCY
5036 /* AP+STA concurrency is supported currently by default */
5037 fset |= WIFI_FEATURE_AP_STA;
5038#endif
5039
5040 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5041 NLMSG_HDRLEN);
5042
5043 if (!skb) {
5044 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5045 return -EINVAL;
5046 }
5047 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5048
5049 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5050 hddLog(LOGE, FL("nla put fail"));
5051 goto nla_put_failure;
5052 }
5053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305054 ret = cfg80211_vendor_cmd_reply(skb);
5055 EXIT();
5056 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305057
5058nla_put_failure:
5059 kfree_skb(skb);
5060 return -EINVAL;
5061}
5062
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305063static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305064wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5065 struct wireless_dev *wdev,
5066 const void *data, int data_len)
5067{
5068 int ret = 0;
5069
5070 vos_ssr_protect(__func__);
5071 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5072 vos_ssr_unprotect(__func__);
5073
5074 return ret;
5075}
5076
5077static int
5078__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305079 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305080 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305081{
5082 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5083 uint8_t i, feature_sets, max_feature_sets;
5084 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5085 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305086 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5087 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305088
5089 ENTER();
5090
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305091 ret = wlan_hdd_validate_context(pHddCtx);
5092 if (0 != ret)
5093 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305094 return ret;
5095 }
5096
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305097 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5098 data, data_len, NULL)) {
5099 hddLog(LOGE, FL("Invalid ATTR"));
5100 return -EINVAL;
5101 }
5102
5103 /* Parse and fetch max feature set */
5104 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5105 hddLog(LOGE, FL("Attr max feature set size failed"));
5106 return -EINVAL;
5107 }
5108 max_feature_sets = nla_get_u32(
5109 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5110 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5111
5112 /* Fill feature combination matrix */
5113 feature_sets = 0;
5114 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5115 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5116 WIFI_FEATURE_P2P;
5117
5118 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5119 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5120 WIFI_FEATURE_SOFT_AP;
5121
5122 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5123 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5124 WIFI_FEATURE_SOFT_AP;
5125
5126 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5127 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5128 WIFI_FEATURE_SOFT_AP |
5129 WIFI_FEATURE_P2P;
5130
5131 /* Add more feature combinations here */
5132
5133 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5134 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5135 hddLog(LOG1, "Feature set matrix");
5136 for (i = 0; i < feature_sets; i++)
5137 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5138
5139 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5140 sizeof(u32) * feature_sets +
5141 NLMSG_HDRLEN);
5142
5143 if (reply_skb) {
5144 if (nla_put_u32(reply_skb,
5145 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5146 feature_sets) ||
5147 nla_put(reply_skb,
5148 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5149 sizeof(u32) * feature_sets, feature_set_matrix)) {
5150 hddLog(LOGE, FL("nla put fail"));
5151 kfree_skb(reply_skb);
5152 return -EINVAL;
5153 }
5154
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305155 ret = cfg80211_vendor_cmd_reply(reply_skb);
5156 EXIT();
5157 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305158 }
5159 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5160 return -ENOMEM;
5161
5162max_buffer_err:
5163 hddLog(LOGE, FL("Feature set max buffer size reached. feature_sets(%d) max(%d)"),
5164 feature_sets, WLAN_HDD_MAX_FEATURE_SET);
5165 return -EINVAL;
5166}
5167
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305168static int
5169wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5170 struct wireless_dev *wdev,
5171 const void *data, int data_len)
5172{
5173 int ret = 0;
5174
5175 vos_ssr_protect(__func__);
5176 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5177 data_len);
5178 vos_ssr_unprotect(__func__);
5179
5180 return ret;
5181}
5182
Agarwal Ashish738843c2014-09-25 12:27:56 +05305183static const struct nla_policy
5184wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5185 +1] =
5186{
5187 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5188};
5189
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305190static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305191 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305192 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305193 int data_len)
5194{
5195 struct net_device *dev = wdev->netdev;
5196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5197 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5198 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5199 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5200 eHalStatus status;
5201 u32 dfsFlag = 0;
5202
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305203 ENTER();
5204
Agarwal Ashish738843c2014-09-25 12:27:56 +05305205 status = wlan_hdd_validate_context(pHddCtx);
5206 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305207 return -EINVAL;
5208 }
5209 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5210 data, data_len,
5211 wlan_hdd_set_no_dfs_flag_config_policy)) {
5212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5213 return -EINVAL;
5214 }
5215
5216 /* Parse and fetch required bandwidth kbps */
5217 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5219 return -EINVAL;
5220 }
5221
5222 dfsFlag = nla_get_u32(
5223 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5224 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5225 dfsFlag);
5226
5227 pHddCtx->disable_dfs_flag = dfsFlag;
5228
5229 sme_disable_dfs_channel(hHal, dfsFlag);
5230 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305231
5232 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305233 return 0;
5234}
Atul Mittal115287b2014-07-08 13:26:33 +05305235
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305236static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5237 struct wireless_dev *wdev,
5238 const void *data,
5239 int data_len)
5240{
5241 int ret = 0;
5242
5243 vos_ssr_protect(__func__);
5244 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5245 vos_ssr_unprotect(__func__);
5246
5247 return ret;
5248
5249}
5250
Mukul Sharma2a271632014-10-13 14:59:01 +05305251const struct
5252nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5253{
5254 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5255 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5256};
5257
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305258static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305259 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305260{
5261
5262 u8 bssid[6] = {0};
5263 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5264 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5265 eHalStatus status = eHAL_STATUS_SUCCESS;
5266 v_U32_t isFwrRoamEnabled = FALSE;
5267 int ret;
5268
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305269 ENTER();
5270
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305271 ret = wlan_hdd_validate_context(pHddCtx);
5272 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305273 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305274 }
5275
5276 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5277 data, data_len,
5278 qca_wlan_vendor_attr);
5279 if (ret){
5280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5281 return -EINVAL;
5282 }
5283
5284 /* Parse and fetch Enable flag */
5285 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5286 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5287 return -EINVAL;
5288 }
5289
5290 isFwrRoamEnabled = nla_get_u32(
5291 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5292
5293 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5294
5295 /* Parse and fetch bssid */
5296 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5298 return -EINVAL;
5299 }
5300
5301 memcpy(bssid, nla_data(
5302 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5303 sizeof(bssid));
5304 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5305
5306 //Update roaming
5307 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305308 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305309 return status;
5310}
5311
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305312static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5313 struct wireless_dev *wdev, const void *data, int data_len)
5314{
5315 int ret = 0;
5316
5317 vos_ssr_protect(__func__);
5318 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5319 vos_ssr_unprotect(__func__);
5320
5321 return ret;
5322}
5323
Sunil Duttc69bccb2014-05-26 21:30:20 +05305324const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5325{
Mukul Sharma2a271632014-10-13 14:59:01 +05305326 {
5327 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5328 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5329 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5330 WIPHY_VENDOR_CMD_NEED_NETDEV |
5331 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305332 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305333 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305334
5335 {
5336 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5337 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5338 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5339 WIPHY_VENDOR_CMD_NEED_NETDEV |
5340 WIPHY_VENDOR_CMD_NEED_RUNNING,
5341 .doit = wlan_hdd_cfg80211_nan_request
5342 },
5343
Sunil Duttc69bccb2014-05-26 21:30:20 +05305344#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5345 {
5346 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5347 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5348 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5349 WIPHY_VENDOR_CMD_NEED_NETDEV |
5350 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305351 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305352 },
5353
5354 {
5355 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5356 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5357 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5358 WIPHY_VENDOR_CMD_NEED_NETDEV |
5359 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305360 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305361 },
5362
5363 {
5364 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5365 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5366 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5367 WIPHY_VENDOR_CMD_NEED_NETDEV |
5368 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305369 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305370 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305371#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305372#ifdef WLAN_FEATURE_EXTSCAN
5373 {
5374 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5375 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5376 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5377 WIPHY_VENDOR_CMD_NEED_NETDEV |
5378 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305379 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305380 },
5381 {
5382 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5383 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5384 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5385 WIPHY_VENDOR_CMD_NEED_NETDEV |
5386 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305387 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305388 },
5389 {
5390 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5391 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5392 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5393 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305394 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305395 },
5396 {
5397 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5398 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5399 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5400 WIPHY_VENDOR_CMD_NEED_NETDEV |
5401 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305402 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305403 },
5404 {
5405 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5406 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5407 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5408 WIPHY_VENDOR_CMD_NEED_NETDEV |
5409 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305410 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305411 },
5412 {
5413 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5414 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5415 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5416 WIPHY_VENDOR_CMD_NEED_NETDEV |
5417 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305418 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305419 },
5420 {
5421 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5422 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5423 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5424 WIPHY_VENDOR_CMD_NEED_NETDEV |
5425 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305426 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305427 },
5428 {
5429 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5430 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5431 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5432 WIPHY_VENDOR_CMD_NEED_NETDEV |
5433 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305434 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305435 },
5436 {
5437 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5438 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5439 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5440 WIPHY_VENDOR_CMD_NEED_NETDEV |
5441 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305442 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305443 },
5444#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305445/*EXT TDLS*/
5446 {
5447 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5448 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5449 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5450 WIPHY_VENDOR_CMD_NEED_NETDEV |
5451 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305452 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305453 },
5454 {
5455 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5456 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5457 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5458 WIPHY_VENDOR_CMD_NEED_NETDEV |
5459 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305460 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305461 },
5462 {
5463 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5464 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5465 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5466 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305467 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305468 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305469 {
5470 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5471 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5472 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5473 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305474 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305475 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305476 {
5477 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5478 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5479 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5480 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305481 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305482 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305483 {
5484 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5485 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5486 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5487 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305488 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305489 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305490 {
5491 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5492 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5493 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5494 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305495 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305496 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305497};
5498
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005499/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305500static const
5501struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005502{
5503#ifdef FEATURE_WLAN_CH_AVOID
5504 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305505 .vendor_id = QCA_NL80211_VENDOR_ID,
5506 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005507 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305508#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5509#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5510 {
5511 /* Index = 1*/
5512 .vendor_id = QCA_NL80211_VENDOR_ID,
5513 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5514 },
5515 {
5516 /* Index = 2*/
5517 .vendor_id = QCA_NL80211_VENDOR_ID,
5518 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5519 },
5520 {
5521 /* Index = 3*/
5522 .vendor_id = QCA_NL80211_VENDOR_ID,
5523 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5524 },
5525 {
5526 /* Index = 4*/
5527 .vendor_id = QCA_NL80211_VENDOR_ID,
5528 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5529 },
5530 {
5531 /* Index = 5*/
5532 .vendor_id = QCA_NL80211_VENDOR_ID,
5533 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5534 },
5535 {
5536 /* Index = 6*/
5537 .vendor_id = QCA_NL80211_VENDOR_ID,
5538 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5539 },
5540#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305541#ifdef WLAN_FEATURE_EXTSCAN
5542 {
5543 .vendor_id = QCA_NL80211_VENDOR_ID,
5544 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5545 },
5546 {
5547 .vendor_id = QCA_NL80211_VENDOR_ID,
5548 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5549 },
5550 {
5551 .vendor_id = QCA_NL80211_VENDOR_ID,
5552 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5553 },
5554 {
5555 .vendor_id = QCA_NL80211_VENDOR_ID,
5556 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5557 },
5558 {
5559 .vendor_id = QCA_NL80211_VENDOR_ID,
5560 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5561 },
5562 {
5563 .vendor_id = QCA_NL80211_VENDOR_ID,
5564 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5565 },
5566 {
5567 .vendor_id = QCA_NL80211_VENDOR_ID,
5568 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5569 },
5570 {
5571 .vendor_id = QCA_NL80211_VENDOR_ID,
5572 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5573 },
5574 {
5575 .vendor_id = QCA_NL80211_VENDOR_ID,
5576 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5577 },
5578 {
5579 .vendor_id = QCA_NL80211_VENDOR_ID,
5580 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5581 },
5582 {
5583 .vendor_id = QCA_NL80211_VENDOR_ID,
5584 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5585 },
5586 {
5587 .vendor_id = QCA_NL80211_VENDOR_ID,
5588 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5589 },
5590 {
5591 .vendor_id = QCA_NL80211_VENDOR_ID,
5592 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5593 },
5594#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305595/*EXT TDLS*/
5596 {
5597 .vendor_id = QCA_NL80211_VENDOR_ID,
5598 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5599 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305600
5601 {
5602 .vendor_id = QCA_NL80211_VENDOR_ID,
5603 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5604 },
5605
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005606};
5607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305609 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305610 * This function is called by hdd_wlan_startup()
5611 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305612 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305614struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005615{
5616 struct wiphy *wiphy;
5617 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305618 /*
5619 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 */
5621 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5622
5623 if (!wiphy)
5624 {
5625 /* Print error and jump into err label and free the memory */
5626 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5627 return NULL;
5628 }
5629
Sunil Duttc69bccb2014-05-26 21:30:20 +05305630
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 return wiphy;
5632}
5633
5634/*
5635 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305636 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 * private ioctl to change the band value
5638 */
5639int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5640{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305641 int i, j;
5642 eNVChannelEnabledType channelEnabledState;
5643
Jeff Johnsone7245742012-09-05 17:12:55 -07005644 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305645
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305646 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305648
5649 if (NULL == wiphy->bands[i])
5650 {
5651 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5652 __func__, i);
5653 continue;
5654 }
5655
5656 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5657 {
5658 struct ieee80211_supported_band *band = wiphy->bands[i];
5659
5660 channelEnabledState = vos_nv_getChannelEnabledState(
5661 band->channels[j].hw_value);
5662
5663 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5664 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305665 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305666 continue;
5667 }
5668 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5669 {
5670 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5671 continue;
5672 }
5673
5674 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5675 NV_CHANNEL_INVALID == channelEnabledState)
5676 {
5677 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5678 }
5679 else if (NV_CHANNEL_DFS == channelEnabledState)
5680 {
5681 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5682 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5683 }
5684 else
5685 {
5686 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5687 |IEEE80211_CHAN_RADAR);
5688 }
5689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 }
5691 return 0;
5692}
5693/*
5694 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305695 * This function is called by hdd_wlan_startup()
5696 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 * This function is used to initialize and register wiphy structure.
5698 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305699int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 struct wiphy *wiphy,
5701 hdd_config_t *pCfg
5702 )
5703{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305704 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305705 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5706
Jeff Johnsone7245742012-09-05 17:12:55 -07005707 ENTER();
5708
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 /* Now bind the underlying wlan device with wiphy */
5710 set_wiphy_dev(wiphy, dev);
5711
5712 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005713
Kiet Lam6c583332013-10-14 05:37:09 +05305714#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005715 /* the flag for the other case would be initialzed in
5716 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005717 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305718#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005719
Amar Singhalfddc28c2013-09-05 13:03:40 -07005720 /* This will disable updating of NL channels from passive to
5721 * active if a beacon is received on passive channel. */
5722 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005723
Amar Singhalfddc28c2013-09-05 13:03:40 -07005724
Amar Singhala49cbc52013-10-08 18:37:44 -07005725
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005726#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005727 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5728 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5729 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005730 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305731 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005732#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005733
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005734#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005735 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005736#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005737 || pCfg->isFastRoamIniFeatureEnabled
5738#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005739#ifdef FEATURE_WLAN_ESE
5740 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005741#endif
5742 )
5743 {
5744 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5745 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005746#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005747#ifdef FEATURE_WLAN_TDLS
5748 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5749 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5750#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305751#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305752 if (pCfg->configPNOScanSupport)
5753 {
5754 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5755 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5756 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5757 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5758 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305759#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005760
Abhishek Singh10d85972015-04-17 10:27:23 +05305761#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5762 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5763#endif
5764
Amar Singhalfddc28c2013-09-05 13:03:40 -07005765#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005766 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5767 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005768 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005769 driver need to determine what to do with both
5770 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005771
5772 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005773#else
5774 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005775#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005776
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305777 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5778
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305779 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005780
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305781 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5782
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305784 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5787 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 | BIT(NL80211_IFTYPE_AP);
5789
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305790 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005791 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5793 if( pCfg->enableMCC )
5794 {
5795 /* Currently, supports up to two channels */
5796 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005797
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305798 if( !pCfg->allowMCCGODiffBI )
5799 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005800
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305801 }
5802 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5803 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005804#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305805 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 /* Before registering we need to update the ht capabilitied based
5808 * on ini values*/
5809 if( !pCfg->ShortGI20MhzEnable )
5810 {
5811 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5812 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5813 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5814 }
5815
5816 if( !pCfg->ShortGI40MhzEnable )
5817 {
5818 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5819 }
5820
5821 if( !pCfg->nChannelBondingMode5GHz )
5822 {
5823 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5824 }
5825
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305826 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305827 if (true == hdd_is_5g_supported(pHddCtx))
5828 {
5829 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5830 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305831
5832 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5833 {
5834
5835 if (NULL == wiphy->bands[i])
5836 {
5837 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5838 __func__, i);
5839 continue;
5840 }
5841
5842 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5843 {
5844 struct ieee80211_supported_band *band = wiphy->bands[i];
5845
5846 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5847 {
5848 // Enable social channels for P2P
5849 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5850 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5851 else
5852 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5853 continue;
5854 }
5855 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5856 {
5857 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5858 continue;
5859 }
5860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 }
5862 /*Initialise the supported cipher suite details*/
5863 wiphy->cipher_suites = hdd_cipher_suites;
5864 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5865
5866 /*signal strength in mBm (100*dBm) */
5867 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5868
5869#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305870 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005872
Sunil Duttc69bccb2014-05-26 21:30:20 +05305873 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5874 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005875 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5876 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5877
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305878 EXIT();
5879 return 0;
5880}
5881
5882/* In this function we are registering wiphy. */
5883int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5884{
5885 ENTER();
5886 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 if (0 > wiphy_register(wiphy))
5888 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305889 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5891 return -EIO;
5892 }
5893
5894 EXIT();
5895 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305896}
Jeff Johnson295189b2012-06-20 16:38:30 -07005897
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305898/* In this function we are updating channel list when,
5899 regulatory domain is FCC and country code is US.
5900 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5901 As per FCC smart phone is not a indoor device.
5902 GO should not opeate on indoor channels */
5903void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5904{
5905 int j;
5906 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5907 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5908 //Default counrtycode from NV at the time of wiphy initialization.
5909 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5910 &defaultCountryCode[0]))
5911 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005912 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305913 }
5914 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5915 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305916 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5917 {
5918 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5919 return;
5920 }
5921 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5922 {
5923 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5924 // Mark UNII -1 band channel as passive
5925 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5926 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5927 }
5928 }
5929}
5930
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305931/* This function registers for all frame which supplicant is interested in */
5932void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005933{
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5935 /* Register for all P2P action, public action etc frames */
5936 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5937
Jeff Johnsone7245742012-09-05 17:12:55 -07005938 ENTER();
5939
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 /* Right now we are registering these frame when driver is getting
5941 initialized. Once we will move to 2.6.37 kernel, in which we have
5942 frame register ops, we will move this code as a part of that */
5943 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305944 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5946
5947 /* GAS Initial Response */
5948 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5949 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 /* GAS Comeback Request */
5952 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5953 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5954
5955 /* GAS Comeback Response */
5956 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5957 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5958
5959 /* P2P Public Action */
5960 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305961 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 P2P_PUBLIC_ACTION_FRAME_SIZE );
5963
5964 /* P2P Action */
5965 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5966 (v_U8_t*)P2P_ACTION_FRAME,
5967 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005968
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305969 /* WNM BSS Transition Request frame */
5970 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5971 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5972 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005973
5974 /* WNM-Notification */
5975 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5976 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5977 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005978}
5979
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305980void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005981{
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5983 /* Register for all P2P action, public action etc frames */
5984 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5985
Jeff Johnsone7245742012-09-05 17:12:55 -07005986 ENTER();
5987
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 /* Right now we are registering these frame when driver is getting
5989 initialized. Once we will move to 2.6.37 kernel, in which we have
5990 frame register ops, we will move this code as a part of that */
5991 /* GAS Initial Request */
5992
5993 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5994 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5995
5996 /* GAS Initial Response */
5997 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5998 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 /* GAS Comeback Request */
6001 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6002 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6003
6004 /* GAS Comeback Response */
6005 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6006 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6007
6008 /* P2P Public Action */
6009 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306010 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 P2P_PUBLIC_ACTION_FRAME_SIZE );
6012
6013 /* P2P Action */
6014 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6015 (v_U8_t*)P2P_ACTION_FRAME,
6016 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006017 /* WNM-Notification */
6018 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6019 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6020 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006021}
6022
6023#ifdef FEATURE_WLAN_WAPI
6024void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6025 const u8 *mac_addr, u8 *key , int key_Len)
6026{
6027 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6028 tCsrRoamSetKey setKey;
6029 v_BOOL_t isConnected = TRUE;
6030 int status = 0;
6031 v_U32_t roamId= 0xFF;
6032 tANI_U8 *pKeyPtr = NULL;
6033 int n = 0;
6034
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306035 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6036 __func__, hdd_device_modetoString(pAdapter->device_mode),
6037 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006038
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306039 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 setKey.keyId = key_index; // Store Key ID
6041 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6042 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6043 setKey.paeRole = 0 ; // the PAE role
6044 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6045 {
6046 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6047 }
6048 else
6049 {
6050 isConnected = hdd_connIsConnected(pHddStaCtx);
6051 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6052 }
6053 setKey.keyLength = key_Len;
6054 pKeyPtr = setKey.Key;
6055 memcpy( pKeyPtr, key, key_Len);
6056
Arif Hussain6d2a3322013-11-17 19:50:10 -08006057 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 __func__, key_Len);
6059 for (n = 0 ; n < key_Len; n++)
6060 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6061 __func__,n,setKey.Key[n]);
6062
6063 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6064 if ( isConnected )
6065 {
6066 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6067 pAdapter->sessionId, &setKey, &roamId );
6068 }
6069 if ( status != 0 )
6070 {
6071 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6072 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6073 __LINE__, status );
6074 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6075 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306076 /* Need to clear any trace of key value in the memory.
6077 * Thus zero out the memory even though it is local
6078 * variable.
6079 */
6080 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006081}
6082#endif /* FEATURE_WLAN_WAPI*/
6083
6084#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306085int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 beacon_data_t **ppBeacon,
6087 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006088#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306089int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006090 beacon_data_t **ppBeacon,
6091 struct cfg80211_beacon_data *params,
6092 int dtim_period)
6093#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306094{
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 int size;
6096 beacon_data_t *beacon = NULL;
6097 beacon_data_t *old = NULL;
6098 int head_len,tail_len;
6099
Jeff Johnsone7245742012-09-05 17:12:55 -07006100 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306102 {
6103 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6104 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006107
6108 old = pAdapter->sessionCtx.ap.beacon;
6109
6110 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306111 {
6112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6113 FL("session(%d) old and new heads points to NULL"),
6114 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306116 }
6117
6118 if (params->tail && !params->tail_len)
6119 {
6120 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6121 FL("tail_len is zero but tail is not NULL"));
6122 return -EINVAL;
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124
Jeff Johnson295189b2012-06-20 16:38:30 -07006125#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6126 /* Kernel 3.0 is not updating dtim_period for set beacon */
6127 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306128 {
6129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6130 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006133#endif
6134
6135 if(params->head)
6136 head_len = params->head_len;
6137 else
6138 head_len = old->head_len;
6139
6140 if(params->tail || !old)
6141 tail_len = params->tail_len;
6142 else
6143 tail_len = old->tail_len;
6144
6145 size = sizeof(beacon_data_t) + head_len + tail_len;
6146
6147 beacon = kzalloc(size, GFP_KERNEL);
6148
6149 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306150 {
6151 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6152 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006155
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006156#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 if(params->dtim_period || !old )
6158 beacon->dtim_period = params->dtim_period;
6159 else
6160 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006161#else
6162 if(dtim_period || !old )
6163 beacon->dtim_period = dtim_period;
6164 else
6165 beacon->dtim_period = old->dtim_period;
6166#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306167
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6169 beacon->tail = beacon->head + head_len;
6170 beacon->head_len = head_len;
6171 beacon->tail_len = tail_len;
6172
6173 if(params->head) {
6174 memcpy (beacon->head,params->head,beacon->head_len);
6175 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306176 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 if(old)
6178 memcpy (beacon->head,old->head,beacon->head_len);
6179 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306180
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 if(params->tail) {
6182 memcpy (beacon->tail,params->tail,beacon->tail_len);
6183 }
6184 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306185 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 memcpy (beacon->tail,old->tail,beacon->tail_len);
6187 }
6188
6189 *ppBeacon = beacon;
6190
6191 kfree(old);
6192
6193 return 0;
6194
6195}
Jeff Johnson295189b2012-06-20 16:38:30 -07006196
6197v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6198{
6199 int left = length;
6200 v_U8_t *ptr = pIes;
6201 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306202
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306204 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 elem_id = ptr[0];
6206 elem_len = ptr[1];
6207 left -= 2;
6208 if(elem_len > left)
6209 {
6210 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006211 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 eid,elem_len,left);
6213 return NULL;
6214 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306215 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 {
6217 return ptr;
6218 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306219
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 left -= elem_len;
6221 ptr += (elem_len + 2);
6222 }
6223 return NULL;
6224}
6225
Jeff Johnson295189b2012-06-20 16:38:30 -07006226/* Check if rate is 11g rate or not */
6227static int wlan_hdd_rate_is_11g(u8 rate)
6228{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006229 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 u8 i;
6231 for (i = 0; i < 8; i++)
6232 {
6233 if(rate == gRateArray[i])
6234 return TRUE;
6235 }
6236 return FALSE;
6237}
6238
6239/* Check for 11g rate and set proper 11g only mode */
6240static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6241 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6242{
6243 u8 i, num_rates = pIe[0];
6244
6245 pIe += 1;
6246 for ( i = 0; i < num_rates; i++)
6247 {
6248 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6249 {
6250 /* If rate set have 11g rate than change the mode to 11G */
6251 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6252 if (pIe[i] & BASIC_RATE_MASK)
6253 {
6254 /* If we have 11g rate as basic rate, it means mode
6255 is 11g only mode.
6256 */
6257 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6258 *pCheckRatesfor11g = FALSE;
6259 }
6260 }
6261 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6262 {
6263 *require_ht = TRUE;
6264 }
6265 }
6266 return;
6267}
6268
6269static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6270{
6271 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6272 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6273 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6274 u8 checkRatesfor11g = TRUE;
6275 u8 require_ht = FALSE;
6276 u8 *pIe=NULL;
6277
6278 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6279
6280 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6281 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6282 if (pIe != NULL)
6283 {
6284 pIe += 1;
6285 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6286 &pConfig->SapHw_mode);
6287 }
6288
6289 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6290 WLAN_EID_EXT_SUPP_RATES);
6291 if (pIe != NULL)
6292 {
6293
6294 pIe += 1;
6295 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6296 &pConfig->SapHw_mode);
6297 }
6298
6299 if( pConfig->channel > 14 )
6300 {
6301 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6302 }
6303
6304 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6305 WLAN_EID_HT_CAPABILITY);
6306
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306307 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 {
6309 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6310 if(require_ht)
6311 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6312 }
6313}
6314
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306315static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6316 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6317{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006318 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306319 v_U8_t *pIe = NULL;
6320 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6321
6322 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6323 pBeacon->tail, pBeacon->tail_len);
6324
6325 if (pIe)
6326 {
6327 ielen = pIe[1] + 2;
6328 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6329 {
6330 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6331 }
6332 else
6333 {
6334 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6335 return -EINVAL;
6336 }
6337 *total_ielen += ielen;
6338 }
6339 return 0;
6340}
6341
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006342static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6343 v_U8_t *genie, v_U8_t *total_ielen)
6344{
6345 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6346 int left = pBeacon->tail_len;
6347 v_U8_t *ptr = pBeacon->tail;
6348 v_U8_t elem_id, elem_len;
6349 v_U16_t ielen = 0;
6350
6351 if ( NULL == ptr || 0 == left )
6352 return;
6353
6354 while (left >= 2)
6355 {
6356 elem_id = ptr[0];
6357 elem_len = ptr[1];
6358 left -= 2;
6359 if (elem_len > left)
6360 {
6361 hddLog( VOS_TRACE_LEVEL_ERROR,
6362 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6363 elem_id, elem_len, left);
6364 return;
6365 }
6366 if (IE_EID_VENDOR == elem_id)
6367 {
6368 /* skipping the VSIE's which we don't want to include or
6369 * it will be included by existing code
6370 */
6371 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6372#ifdef WLAN_FEATURE_WFD
6373 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6374#endif
6375 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6376 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6377 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6378 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6379 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6380 {
6381 ielen = ptr[1] + 2;
6382 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6383 {
6384 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6385 *total_ielen += ielen;
6386 }
6387 else
6388 {
6389 hddLog( VOS_TRACE_LEVEL_ERROR,
6390 "IE Length is too big "
6391 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6392 elem_id, elem_len, *total_ielen);
6393 }
6394 }
6395 }
6396
6397 left -= elem_len;
6398 ptr += (elem_len + 2);
6399 }
6400 return;
6401}
6402
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006403#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006404static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6405 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006406#else
6407static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6408 struct cfg80211_beacon_data *params)
6409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006410{
6411 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306412 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006414 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006415
6416 genie = vos_mem_malloc(MAX_GENIE_LEN);
6417
6418 if(genie == NULL) {
6419
6420 return -ENOMEM;
6421 }
6422
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306423 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6424 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306426 hddLog(LOGE,
6427 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306428 ret = -EINVAL;
6429 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 }
6431
6432#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306433 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6434 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6435 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306436 hddLog(LOGE,
6437 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306438 ret = -EINVAL;
6439 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 }
6441#endif
6442
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306443 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6444 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306446 hddLog(LOGE,
6447 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306448 ret = -EINVAL;
6449 goto done;
6450 }
6451
6452 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6453 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006454 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006456
6457 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6458 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6459 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6460 {
6461 hddLog(LOGE,
6462 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006463 ret = -EINVAL;
6464 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 }
6466
6467 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6468 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6469 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6470 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6471 ==eHAL_STATUS_FAILURE)
6472 {
6473 hddLog(LOGE,
6474 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006475 ret = -EINVAL;
6476 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 }
6478
6479 // Added for ProResp IE
6480 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6481 {
6482 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6483 u8 probe_rsp_ie_len[3] = {0};
6484 u8 counter = 0;
6485 /* Check Probe Resp Length if it is greater then 255 then Store
6486 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6487 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6488 Store More then 255 bytes into One Variable.
6489 */
6490 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6491 {
6492 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6493 {
6494 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6495 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6496 }
6497 else
6498 {
6499 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6500 rem_probe_resp_ie_len = 0;
6501 }
6502 }
6503
6504 rem_probe_resp_ie_len = 0;
6505
6506 if (probe_rsp_ie_len[0] > 0)
6507 {
6508 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6509 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6510 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6511 probe_rsp_ie_len[0], NULL,
6512 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6513 {
6514 hddLog(LOGE,
6515 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006516 ret = -EINVAL;
6517 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
6519 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6520 }
6521
6522 if (probe_rsp_ie_len[1] > 0)
6523 {
6524 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6525 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6526 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6527 probe_rsp_ie_len[1], NULL,
6528 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6529 {
6530 hddLog(LOGE,
6531 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006532 ret = -EINVAL;
6533 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 }
6535 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6536 }
6537
6538 if (probe_rsp_ie_len[2] > 0)
6539 {
6540 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6541 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6542 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6543 probe_rsp_ie_len[2], NULL,
6544 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6545 {
6546 hddLog(LOGE,
6547 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006548 ret = -EINVAL;
6549 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 }
6551 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6552 }
6553
6554 if (probe_rsp_ie_len[1] == 0 )
6555 {
6556 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6557 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6558 eANI_BOOLEAN_FALSE) )
6559 {
6560 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006561 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 }
6563 }
6564
6565 if (probe_rsp_ie_len[2] == 0 )
6566 {
6567 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6568 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6569 eANI_BOOLEAN_FALSE) )
6570 {
6571 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006572 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 }
6574 }
6575
6576 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6577 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6578 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6579 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6580 == eHAL_STATUS_FAILURE)
6581 {
6582 hddLog(LOGE,
6583 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006584 ret = -EINVAL;
6585 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 }
6587 }
6588 else
6589 {
6590 // Reset WNI_CFG_PROBE_RSP Flags
6591 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6592
6593 hddLog(VOS_TRACE_LEVEL_INFO,
6594 "%s: No Probe Response IE received in set beacon",
6595 __func__);
6596 }
6597
6598 // Added for AssocResp IE
6599 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6600 {
6601 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6602 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6603 params->assocresp_ies_len, NULL,
6604 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6605 {
6606 hddLog(LOGE,
6607 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006608 ret = -EINVAL;
6609 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 }
6611
6612 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6613 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6614 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6615 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6616 == eHAL_STATUS_FAILURE)
6617 {
6618 hddLog(LOGE,
6619 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006620 ret = -EINVAL;
6621 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 }
6623 }
6624 else
6625 {
6626 hddLog(VOS_TRACE_LEVEL_INFO,
6627 "%s: No Assoc Response IE received in set beacon",
6628 __func__);
6629
6630 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6631 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6632 eANI_BOOLEAN_FALSE) )
6633 {
6634 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006635 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 }
6637 }
6638
Jeff Johnsone7245742012-09-05 17:12:55 -07006639done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306641 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006642}
Jeff Johnson295189b2012-06-20 16:38:30 -07006643
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306644/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 * FUNCTION: wlan_hdd_validate_operation_channel
6646 * called by wlan_hdd_cfg80211_start_bss() and
6647 * wlan_hdd_cfg80211_set_channel()
6648 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306649 * channel list.
6650 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006651VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006652{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306653
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 v_U32_t num_ch = 0;
6655 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6656 u32 indx = 0;
6657 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306658 v_U8_t fValidChannel = FALSE, count = 0;
6659 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306660
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6662
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306663 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306665 /* Validate the channel */
6666 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306668 if ( channel == rfChannels[count].channelNum )
6669 {
6670 fValidChannel = TRUE;
6671 break;
6672 }
6673 }
6674 if (fValidChannel != TRUE)
6675 {
6676 hddLog(VOS_TRACE_LEVEL_ERROR,
6677 "%s: Invalid Channel [%d]", __func__, channel);
6678 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 }
6680 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306681 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306683 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6684 valid_ch, &num_ch))
6685 {
6686 hddLog(VOS_TRACE_LEVEL_ERROR,
6687 "%s: failed to get valid channel list", __func__);
6688 return VOS_STATUS_E_FAILURE;
6689 }
6690 for (indx = 0; indx < num_ch; indx++)
6691 {
6692 if (channel == valid_ch[indx])
6693 {
6694 break;
6695 }
6696 }
6697
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306698 if (indx >= num_ch)
6699 {
6700 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6701 {
6702 eCsrBand band;
6703 unsigned int freq;
6704
6705 sme_GetFreqBand(hHal, &band);
6706
6707 if (eCSR_BAND_5G == band)
6708 {
6709#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6710 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6711 {
6712 freq = ieee80211_channel_to_frequency(channel,
6713 IEEE80211_BAND_2GHZ);
6714 }
6715 else
6716 {
6717 freq = ieee80211_channel_to_frequency(channel,
6718 IEEE80211_BAND_5GHZ);
6719 }
6720#else
6721 freq = ieee80211_channel_to_frequency(channel);
6722#endif
6723 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6724 return VOS_STATUS_SUCCESS;
6725 }
6726 }
6727
6728 hddLog(VOS_TRACE_LEVEL_ERROR,
6729 "%s: Invalid Channel [%d]", __func__, channel);
6730 return VOS_STATUS_E_FAILURE;
6731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306733
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306735
Jeff Johnson295189b2012-06-20 16:38:30 -07006736}
6737
Viral Modi3a32cc52013-02-08 11:14:52 -08006738/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306739 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006740 * This function is used to set the channel number
6741 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306742static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006743 struct ieee80211_channel *chan,
6744 enum nl80211_channel_type channel_type
6745 )
6746{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306747 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006748 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006749 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006750 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306751 hdd_context_t *pHddCtx;
6752 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006753
6754 ENTER();
6755
6756 if( NULL == dev )
6757 {
6758 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006759 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006760 return -ENODEV;
6761 }
6762 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306763
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306764 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6765 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6766 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006767 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306768 "%s: device_mode = %s (%d) freq = %d", __func__,
6769 hdd_device_modetoString(pAdapter->device_mode),
6770 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306771
6772 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6773 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306774 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006775 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306776 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006777 }
6778
6779 /*
6780 * Do freq to chan conversion
6781 * TODO: for 11a
6782 */
6783
6784 channel = ieee80211_frequency_to_channel(freq);
6785
6786 /* Check freq range */
6787 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6788 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6789 {
6790 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006791 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006792 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6793 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6794 return -EINVAL;
6795 }
6796
6797 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6798
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306799 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6800 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006801 {
6802 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6803 {
6804 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006805 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006806 return -EINVAL;
6807 }
6808 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6809 "%s: set channel to [%d] for device mode =%d",
6810 __func__, channel,pAdapter->device_mode);
6811 }
6812 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006813 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006814 )
6815 {
6816 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6817 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6818 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6819
6820 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6821 {
6822 /* Link is up then return cant set channel*/
6823 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006824 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006825 return -EINVAL;
6826 }
6827
6828 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6829 pHddStaCtx->conn_info.operationChannel = channel;
6830 pRoamProfile->ChannelInfo.ChannelList =
6831 &pHddStaCtx->conn_info.operationChannel;
6832 }
6833 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006834 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006835 )
6836 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306837 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6838 {
6839 if(VOS_STATUS_SUCCESS !=
6840 wlan_hdd_validate_operation_channel(pAdapter,channel))
6841 {
6842 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006843 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306844 return -EINVAL;
6845 }
6846 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6847 }
6848 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006849 {
6850 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6851
6852 /* If auto channel selection is configured as enable/ 1 then ignore
6853 channel set by supplicant
6854 */
6855 if ( cfg_param->apAutoChannelSelection )
6856 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306857 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6858 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306860 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6861 __func__, hdd_device_modetoString(pAdapter->device_mode),
6862 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006863 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306864 else
6865 {
6866 if(VOS_STATUS_SUCCESS !=
6867 wlan_hdd_validate_operation_channel(pAdapter,channel))
6868 {
6869 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006870 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306871 return -EINVAL;
6872 }
6873 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6874 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006875 }
6876 }
6877 else
6878 {
6879 hddLog(VOS_TRACE_LEVEL_FATAL,
6880 "%s: Invalid device mode failed to set valid channel", __func__);
6881 return -EINVAL;
6882 }
6883 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306884 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006885}
6886
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306887static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6888 struct net_device *dev,
6889 struct ieee80211_channel *chan,
6890 enum nl80211_channel_type channel_type
6891 )
6892{
6893 int ret;
6894
6895 vos_ssr_protect(__func__);
6896 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6897 vos_ssr_unprotect(__func__);
6898
6899 return ret;
6900}
6901
Jeff Johnson295189b2012-06-20 16:38:30 -07006902#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6903static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6904 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006905#else
6906static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6907 struct cfg80211_beacon_data *params,
6908 const u8 *ssid, size_t ssid_len,
6909 enum nl80211_hidden_ssid hidden_ssid)
6910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006911{
6912 tsap_Config_t *pConfig;
6913 beacon_data_t *pBeacon = NULL;
6914 struct ieee80211_mgmt *pMgmt_frame;
6915 v_U8_t *pIe=NULL;
6916 v_U16_t capab_info;
6917 eCsrAuthType RSNAuthType;
6918 eCsrEncryptionType RSNEncryptType;
6919 eCsrEncryptionType mcRSNEncryptType;
6920 int status = VOS_STATUS_SUCCESS;
6921 tpWLAN_SAPEventCB pSapEventCallback;
6922 hdd_hostapd_state_t *pHostapdState;
6923 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6924 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306925 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306927 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006929 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306930 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006931 v_BOOL_t MFPCapable = VOS_FALSE;
6932 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306933 v_BOOL_t sapEnable11AC =
6934 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 ENTER();
6936
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306937 iniConfig = pHddCtx->cfg_ini;
6938
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6940
6941 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6942
6943 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6944
6945 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6946
6947 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6948
6949 //channel is already set in the set_channel Call back
6950 //pConfig->channel = pCommitConfig->channel;
6951
6952 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306953 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6955
6956 pConfig->dtim_period = pBeacon->dtim_period;
6957
Arif Hussain6d2a3322013-11-17 19:50:10 -08006958 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 pConfig->dtim_period);
6960
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006961 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006962 {
6963 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306965 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6966 {
6967 tANI_BOOLEAN restartNeeded;
6968 pConfig->ieee80211d = 1;
6969 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6970 sme_setRegInfo(hHal, pConfig->countryCode);
6971 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6972 }
6973 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006975 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006976 pConfig->ieee80211d = 1;
6977 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6978 sme_setRegInfo(hHal, pConfig->countryCode);
6979 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006981 else
6982 {
6983 pConfig->ieee80211d = 0;
6984 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306985 /*
6986 * If auto channel is configured i.e. channel is 0,
6987 * so skip channel validation.
6988 */
6989 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6990 {
6991 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6992 {
6993 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006994 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306995 return -EINVAL;
6996 }
6997 }
6998 else
6999 {
7000 if(1 != pHddCtx->is_dynamic_channel_range_set)
7001 {
7002 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7003 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7004 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7005 }
7006 pHddCtx->is_dynamic_channel_range_set = 0;
7007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007009 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 {
7011 pConfig->ieee80211d = 0;
7012 }
7013 pConfig->authType = eSAP_AUTO_SWITCH;
7014
7015 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307016
7017 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7019
7020 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7021
7022 /*Set wps station to configured*/
7023 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7024
7025 if(pIe)
7026 {
7027 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7028 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007029 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 return -EINVAL;
7031 }
7032 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7033 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007034 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 /* Check 15 bit of WPS IE as it contain information for wps state
7036 * WPS state
7037 */
7038 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7039 {
7040 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7041 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7042 {
7043 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7044 }
7045 }
7046 }
7047 else
7048 {
7049 pConfig->wps_state = SAP_WPS_DISABLED;
7050 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307051 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007052
c_hpothufe599e92014-06-16 11:38:55 +05307053 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7054 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7055 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7056 eCSR_ENCRYPT_TYPE_NONE;
7057
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 pConfig->RSNWPAReqIELength = 0;
7059 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307060 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 WLAN_EID_RSN);
7062 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307063 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007064 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7065 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7066 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307067 /* The actual processing may eventually be more extensive than
7068 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 * by the app.
7070 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307071 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7073 &RSNEncryptType,
7074 &mcRSNEncryptType,
7075 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007076 &MFPCapable,
7077 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 pConfig->pRSNWPAReqIE[1]+2,
7079 pConfig->pRSNWPAReqIE );
7080
7081 if( VOS_STATUS_SUCCESS == status )
7082 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307083 /* Now copy over all the security attributes you have
7084 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 * */
7086 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7087 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7088 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7089 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307090 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007091 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7093 }
7094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307095
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7097 pBeacon->tail, pBeacon->tail_len);
7098
7099 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7100 {
7101 if (pConfig->pRSNWPAReqIE)
7102 {
7103 /*Mixed mode WPA/WPA2*/
7104 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7105 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7106 }
7107 else
7108 {
7109 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7110 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7111 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307112 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7114 &RSNEncryptType,
7115 &mcRSNEncryptType,
7116 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007117 &MFPCapable,
7118 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 pConfig->pRSNWPAReqIE[1]+2,
7120 pConfig->pRSNWPAReqIE );
7121
7122 if( VOS_STATUS_SUCCESS == status )
7123 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307124 /* Now copy over all the security attributes you have
7125 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 * */
7127 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7128 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7129 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7130 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307131 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007132 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7134 }
7135 }
7136 }
7137
Jeff Johnson4416a782013-03-25 14:17:50 -07007138 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7139 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7140 return -EINVAL;
7141 }
7142
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7144
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007145#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 if (params->ssid != NULL)
7147 {
7148 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7149 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7150 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7151 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7152 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007153#else
7154 if (ssid != NULL)
7155 {
7156 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7157 pConfig->SSIDinfo.ssid.length = ssid_len;
7158 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7159 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7160 }
7161#endif
7162
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307163 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307165
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 /* default value */
7167 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7168 pConfig->num_accept_mac = 0;
7169 pConfig->num_deny_mac = 0;
7170
7171 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7172 pBeacon->tail, pBeacon->tail_len);
7173
7174 /* pIe for black list is following form:
7175 type : 1 byte
7176 length : 1 byte
7177 OUI : 4 bytes
7178 acl type : 1 byte
7179 no of mac addr in black list: 1 byte
7180 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307181 */
7182 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 {
7184 pConfig->SapMacaddr_acl = pIe[6];
7185 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007186 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307188 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7189 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7191 for (i = 0; i < pConfig->num_deny_mac; i++)
7192 {
7193 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7194 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 }
7197 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7198 pBeacon->tail, pBeacon->tail_len);
7199
7200 /* pIe for white list is following form:
7201 type : 1 byte
7202 length : 1 byte
7203 OUI : 4 bytes
7204 acl type : 1 byte
7205 no of mac addr in white list: 1 byte
7206 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307207 */
7208 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 {
7210 pConfig->SapMacaddr_acl = pIe[6];
7211 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007212 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307214 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7215 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7217 for (i = 0; i < pConfig->num_accept_mac; i++)
7218 {
7219 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7220 acl_entry++;
7221 }
7222 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307223
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7225
Jeff Johnsone7245742012-09-05 17:12:55 -07007226#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007227 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307228 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7229 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307230 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7231 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007232 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7233 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307234 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7235 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007236 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307237 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007238 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307239 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007240
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307241 /* If ACS disable and selected channel <= 14
7242 * OR
7243 * ACS enabled and ACS operating band is choosen as 2.4
7244 * AND
7245 * VHT in 2.4G Disabled
7246 * THEN
7247 * Fallback to 11N mode
7248 */
7249 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7250 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307251 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307252 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007253 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307254 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7255 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007256 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7257 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007258 }
7259#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307260
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 // ht_capab is not what the name conveys,this is used for protection bitmap
7262 pConfig->ht_capab =
7263 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7264
7265 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7266 {
7267 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7268 return -EINVAL;
7269 }
7270
7271 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307272 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7274 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307275 pConfig->obssProtEnabled =
7276 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007277
Chet Lanctot8cecea22014-02-11 19:09:36 -08007278#ifdef WLAN_FEATURE_11W
7279 pConfig->mfpCapable = MFPCapable;
7280 pConfig->mfpRequired = MFPRequired;
7281 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7282 pConfig->mfpCapable, pConfig->mfpRequired);
7283#endif
7284
Arif Hussain6d2a3322013-11-17 19:50:10 -08007285 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007287 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7288 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7289 (int)pConfig->channel);
7290 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7291 pConfig->SapHw_mode, pConfig->privacy,
7292 pConfig->authType);
7293 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7294 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7295 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7296 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007297
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307298 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 {
7300 //Bss already started. just return.
7301 //TODO Probably it should update some beacon params.
7302 hddLog( LOGE, "Bss Already started...Ignore the request");
7303 EXIT();
7304 return 0;
7305 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307306
Agarwal Ashish51325b52014-06-16 16:50:49 +05307307 if (vos_max_concurrent_connections_reached()) {
7308 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7309 return -EINVAL;
7310 }
7311
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 pConfig->persona = pHostapdAdapter->device_mode;
7313
Peng Xu2446a892014-09-05 17:21:18 +05307314 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7315 if ( NULL != psmeConfig)
7316 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307317 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307318 sme_GetConfigParam(hHal, psmeConfig);
7319 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307320#ifdef WLAN_FEATURE_AP_HT40_24G
7321 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7322 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7323 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7324 {
7325 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7326 sme_UpdateConfig (hHal, psmeConfig);
7327 }
7328#endif
Peng Xu2446a892014-09-05 17:21:18 +05307329 vos_mem_free(psmeConfig);
7330 }
Peng Xuafc34e32014-09-25 13:23:55 +05307331 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307332
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 pSapEventCallback = hdd_hostapd_SAPEventCB;
7334 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7335 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007337 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 return -EINVAL;
7339 }
7340
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307341 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7343
7344 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307345
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347 {
7348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007349 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007350 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 VOS_ASSERT(0);
7352 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307355 /* Initialize WMM configuation */
7356 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307357 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007358
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007359#ifdef WLAN_FEATURE_P2P_DEBUG
7360 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7361 {
7362 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7363 {
7364 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7365 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007366 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007367 }
7368 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7369 {
7370 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7371 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007372 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007373 }
7374 }
7375#endif
7376
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 pHostapdState->bCommit = TRUE;
7378 EXIT();
7379
7380 return 0;
7381}
7382
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007383#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307384static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307385 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 struct beacon_parameters *params)
7387{
7388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307389 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307390 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007391
7392 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307393
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307394 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7395 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7396 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307397 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7398 hdd_device_modetoString(pAdapter->device_mode),
7399 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007400
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307401 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7402 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307403 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007404 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307405 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007406 }
7407
Agarwal Ashish51325b52014-06-16 16:50:49 +05307408 if (vos_max_concurrent_connections_reached()) {
7409 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7410 return -EINVAL;
7411 }
7412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307413 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 )
7416 {
7417 beacon_data_t *old,*new;
7418
7419 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307422 {
7423 hddLog(VOS_TRACE_LEVEL_WARN,
7424 FL("already beacon info added to session(%d)"),
7425 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7430
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307431 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 {
7433 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007434 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 return -EINVAL;
7436 }
7437
7438 pAdapter->sessionCtx.ap.beacon = new;
7439
7440 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7441 }
7442
7443 EXIT();
7444 return status;
7445}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307446
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307447static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7448 struct net_device *dev,
7449 struct beacon_parameters *params)
7450{
7451 int ret;
7452
7453 vos_ssr_protect(__func__);
7454 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7455 vos_ssr_unprotect(__func__);
7456
7457 return ret;
7458}
7459
7460static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 struct net_device *dev,
7462 struct beacon_parameters *params)
7463{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7466 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307467 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007468
7469 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307470
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307471 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7472 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7473 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7474 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7475 __func__, hdd_device_modetoString(pAdapter->device_mode),
7476 pAdapter->device_mode);
7477
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307478 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7479 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307480 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007481 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307482 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007483 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307484
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307485 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307487 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 {
7489 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307490
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307494 {
7495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7496 FL("session(%d) old and new heads points to NULL"),
7497 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007500
7501 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7502
7503 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307504 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007505 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 return -EINVAL;
7507 }
7508
7509 pAdapter->sessionCtx.ap.beacon = new;
7510
7511 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7512 }
7513
7514 EXIT();
7515 return status;
7516}
7517
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307518static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7519 struct net_device *dev,
7520 struct beacon_parameters *params)
7521{
7522 int ret;
7523
7524 vos_ssr_protect(__func__);
7525 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7526 vos_ssr_unprotect(__func__);
7527
7528 return ret;
7529}
7530
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007531#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7532
7533#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307534static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007536#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307537static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007538 struct net_device *dev)
7539#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007540{
7541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007542 hdd_context_t *pHddCtx = NULL;
7543 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307544 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307545 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007546
7547 ENTER();
7548
7549 if (NULL == pAdapter)
7550 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007552 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 return -ENODEV;
7554 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007555
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307556 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7557 TRACE_CODE_HDD_CFG80211_STOP_AP,
7558 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307559 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7560 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307561 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007562 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307563 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007564 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007565
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007566 pScanInfo = &pHddCtx->scan_info;
7567
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307568 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7569 __func__, hdd_device_modetoString(pAdapter->device_mode),
7570 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007571
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307572 ret = wlan_hdd_scan_abort(pAdapter);
7573
Girish Gowli4bf7a632014-06-12 13:42:11 +05307574 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007575 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7577 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307578
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307579 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007580 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7582 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007583
Jeff Johnsone7245742012-09-05 17:12:55 -07007584 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307585 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007586 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307587 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007588 }
7589
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307590 /* Delete all associated STAs before stopping AP/P2P GO */
7591 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307592 hdd_hostapd_stop(dev);
7593
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 )
7597 {
7598 beacon_data_t *old;
7599
7600 old = pAdapter->sessionCtx.ap.beacon;
7601
7602 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307603 {
7604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 FL("session(%d) beacon data points to NULL"),
7606 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007611
7612 mutex_lock(&pHddCtx->sap_lock);
7613 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7614 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007615 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 {
7617 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7618
7619 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7620
7621 if (!VOS_IS_STATUS_SUCCESS(status))
7622 {
7623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007624 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307626 }
7627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307629 /* BSS stopped, clear the active sessions for this device mode */
7630 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 }
7632 mutex_unlock(&pHddCtx->sap_lock);
7633
7634 if(status != VOS_STATUS_SUCCESS)
7635 {
7636 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007637 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 return -EINVAL;
7639 }
7640
Jeff Johnson4416a782013-03-25 14:17:50 -07007641 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7643 ==eHAL_STATUS_FAILURE)
7644 {
7645 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007646 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 }
7648
Jeff Johnson4416a782013-03-25 14:17:50 -07007649 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7651 eANI_BOOLEAN_FALSE) )
7652 {
7653 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007654 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 }
7656
7657 // Reset WNI_CFG_PROBE_RSP Flags
7658 wlan_hdd_reset_prob_rspies(pAdapter);
7659
7660 pAdapter->sessionCtx.ap.beacon = NULL;
7661 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007662#ifdef WLAN_FEATURE_P2P_DEBUG
7663 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7664 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7665 {
7666 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7667 "GO got removed");
7668 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7669 }
7670#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 }
7672 EXIT();
7673 return status;
7674}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007675
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307676#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7677static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7678 struct net_device *dev)
7679{
7680 int ret;
7681
7682 vos_ssr_protect(__func__);
7683 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7684 vos_ssr_unprotect(__func__);
7685
7686 return ret;
7687}
7688#else
7689static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7690 struct net_device *dev)
7691{
7692 int ret;
7693
7694 vos_ssr_protect(__func__);
7695 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7696 vos_ssr_unprotect(__func__);
7697
7698 return ret;
7699}
7700#endif
7701
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007702#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7703
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307704static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307705 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007706 struct cfg80211_ap_settings *params)
7707{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307708 hdd_adapter_t *pAdapter;
7709 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307710 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007711
7712 ENTER();
7713
Girish Gowlib143d7a2015-02-18 19:39:55 +05307714 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007715 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307717 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307718 return -ENODEV;
7719 }
7720
7721 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7722 if (NULL == pAdapter)
7723 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307725 "%s: HDD adapter is Null", __func__);
7726 return -ENODEV;
7727 }
7728
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307729 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7730 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7731 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307732 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7733 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307735 "%s: HDD adapter magic is invalid", __func__);
7736 return -ENODEV;
7737 }
7738
7739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307740 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307741 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307742 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307743 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307744 }
7745
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307746 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7747 __func__, hdd_device_modetoString(pAdapter->device_mode),
7748 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307749
7750 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007751 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007752 )
7753 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307754 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007755
7756 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307757
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007758 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307759 {
7760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7761 FL("already beacon info added to session(%d)"),
7762 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007763 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307764 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007765
Girish Gowlib143d7a2015-02-18 19:39:55 +05307766#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7767 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7768 &new,
7769 &params->beacon);
7770#else
7771 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7772 &new,
7773 &params->beacon,
7774 params->dtim_period);
7775#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007776
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307777 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007778 {
7779 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307780 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007781 return -EINVAL;
7782 }
7783 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007784#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007785 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7786#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7787 params->channel, params->channel_type);
7788#else
7789 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7790#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007791#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007792 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
7793 params->ssid_len, params->hidden_ssid);
7794 }
7795
7796 EXIT();
7797 return status;
7798}
7799
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307800static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7801 struct net_device *dev,
7802 struct cfg80211_ap_settings *params)
7803{
7804 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007805
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307806 vos_ssr_protect(__func__);
7807 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7808 vos_ssr_unprotect(__func__);
7809
7810 return ret;
7811}
7812
7813static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007814 struct net_device *dev,
7815 struct cfg80211_beacon_data *params)
7816{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307818 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307819 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007820
7821 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307822
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307823 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7824 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7825 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007826 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007827 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307828
7829 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7830 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307831 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007832 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307833 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007834 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007835
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307836 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007837 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307838 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007839 {
7840 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307841
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007842 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307843
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007844 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307845 {
7846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7847 FL("session(%d) beacon data points to NULL"),
7848 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007849 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307850 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007851
7852 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7853
7854 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307855 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007856 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007857 return -EINVAL;
7858 }
7859
7860 pAdapter->sessionCtx.ap.beacon = new;
7861
7862 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
7863 }
7864
7865 EXIT();
7866 return status;
7867}
7868
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307869static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7870 struct net_device *dev,
7871 struct cfg80211_beacon_data *params)
7872{
7873 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007874
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307875 vos_ssr_protect(__func__);
7876 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7877 vos_ssr_unprotect(__func__);
7878
7879 return ret;
7880}
7881
7882#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007883
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307884static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 struct net_device *dev,
7886 struct bss_parameters *params)
7887{
7888 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307889 hdd_context_t *pHddCtx;
7890 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007891
7892 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307893
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307894 if (NULL == pAdapter)
7895 {
7896 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7897 "%s: HDD adapter is Null", __func__);
7898 return -ENODEV;
7899 }
7900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307901 ret = wlan_hdd_validate_context(pHddCtx);
7902 if (0 != ret)
7903 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307904 return ret;
7905 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307906 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7907 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7908 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307909 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7910 __func__, hdd_device_modetoString(pAdapter->device_mode),
7911 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007912
7913 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307915 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 {
7917 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7918 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307919 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 {
7921 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007923 }
7924
7925 EXIT();
7926 return 0;
7927}
7928
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307929static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7930 struct net_device *dev,
7931 struct bss_parameters *params)
7932{
7933 int ret;
7934
7935 vos_ssr_protect(__func__);
7936 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7937 vos_ssr_unprotect(__func__);
7938
7939 return ret;
7940}
Kiet Lam10841362013-11-01 11:36:50 +05307941/* FUNCTION: wlan_hdd_change_country_code_cd
7942* to wait for contry code completion
7943*/
7944void* wlan_hdd_change_country_code_cb(void *pAdapter)
7945{
7946 hdd_adapter_t *call_back_pAdapter = pAdapter;
7947 complete(&call_back_pAdapter->change_country_code);
7948 return NULL;
7949}
7950
Jeff Johnson295189b2012-06-20 16:38:30 -07007951/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307952 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7954 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307955int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 struct net_device *ndev,
7957 enum nl80211_iftype type,
7958 u32 *flags,
7959 struct vif_params *params
7960 )
7961{
7962 struct wireless_dev *wdev;
7963 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007964 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007965 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 tCsrRoamProfile *pRoamProfile = NULL;
7967 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307968 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 eMib_dot11DesiredBssType connectedBssType;
7970 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307971 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007972
7973 ENTER();
7974
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307975 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007976 {
7977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7978 "%s: Adapter context is null", __func__);
7979 return VOS_STATUS_E_FAILURE;
7980 }
7981
7982 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7983 if (!pHddCtx)
7984 {
7985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7986 "%s: HDD context is null", __func__);
7987 return VOS_STATUS_E_FAILURE;
7988 }
7989
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307990 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7991 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7992 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307993 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307994 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307996 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 }
7998
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307999 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8000 __func__, hdd_device_modetoString(pAdapter->device_mode),
8001 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008002
Agarwal Ashish51325b52014-06-16 16:50:49 +05308003 if (vos_max_concurrent_connections_reached()) {
8004 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8005 return -EINVAL;
8006 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308007 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 wdev = ndev->ieee80211_ptr;
8009
8010#ifdef WLAN_BTAMP_FEATURE
8011 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8012 (NL80211_IFTYPE_ADHOC == type)||
8013 (NL80211_IFTYPE_AP == type)||
8014 (NL80211_IFTYPE_P2P_GO == type))
8015 {
8016 pHddCtx->isAmpAllowed = VOS_FALSE;
8017 // stop AMP traffic
8018 status = WLANBAP_StopAmp();
8019 if(VOS_STATUS_SUCCESS != status )
8020 {
8021 pHddCtx->isAmpAllowed = VOS_TRUE;
8022 hddLog(VOS_TRACE_LEVEL_FATAL,
8023 "%s: Failed to stop AMP", __func__);
8024 return -EINVAL;
8025 }
8026 }
8027#endif //WLAN_BTAMP_FEATURE
8028 /* Reset the current device mode bit mask*/
8029 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8030
8031 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008033 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 )
8035 {
8036 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008037 if (!pWextState)
8038 {
8039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8040 "%s: pWextState is null", __func__);
8041 return VOS_STATUS_E_FAILURE;
8042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 pRoamProfile = &pWextState->roamProfile;
8044 LastBSSType = pRoamProfile->BSSType;
8045
8046 switch (type)
8047 {
8048 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 hddLog(VOS_TRACE_LEVEL_INFO,
8051 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8052 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008053#ifdef WLAN_FEATURE_11AC
8054 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8055 {
8056 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8057 }
8058#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308059 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008060 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008062 //Check for sub-string p2p to confirm its a p2p interface
8063 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308064 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008065 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8066 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8067 }
8068 else
8069 {
8070 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008071 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308074
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 case NL80211_IFTYPE_ADHOC:
8076 hddLog(VOS_TRACE_LEVEL_INFO,
8077 "%s: setting interface Type to ADHOC", __func__);
8078 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8079 pRoamProfile->phyMode =
8080 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008081 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308083 hdd_set_ibss_ops( pAdapter );
8084 hdd_ibss_init_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 break;
8086
8087 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 {
8090 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8091 "%s: setting interface Type to %s", __func__,
8092 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8093
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008094 //Cancel any remain on channel for GO mode
8095 if (NL80211_IFTYPE_P2P_GO == type)
8096 {
8097 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8098 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008099 if (NL80211_IFTYPE_AP == type)
8100 {
8101 /* As Loading WLAN Driver one interface being created for p2p device
8102 * address. This will take one HW STA and the max number of clients
8103 * that can connect to softAP will be reduced by one. so while changing
8104 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8105 * interface as it is not required in SoftAP mode.
8106 */
8107
8108 // Get P2P Adapter
8109 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8110
8111 if (pP2pAdapter)
8112 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308113 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308114 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008115 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8116 }
8117 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308118 //Disable IMPS & BMPS for SAP/GO
8119 if(VOS_STATUS_E_FAILURE ==
8120 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8121 {
8122 //Fail to Exit BMPS
8123 VOS_ASSERT(0);
8124 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308125
8126 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8127
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308128#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008129
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308130 /* A Mutex Lock is introduced while changing the mode to
8131 * protect the concurrent access for the Adapters by TDLS
8132 * module.
8133 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308134 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308135#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308137 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8140 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308141#ifdef FEATURE_WLAN_TDLS
8142 mutex_unlock(&pHddCtx->tdls_lock);
8143#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008144 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8145 (pConfig->apRandomBssidEnabled))
8146 {
8147 /* To meet Android requirements create a randomized
8148 MAC address of the form 02:1A:11:Fx:xx:xx */
8149 get_random_bytes(&ndev->dev_addr[3], 3);
8150 ndev->dev_addr[0] = 0x02;
8151 ndev->dev_addr[1] = 0x1A;
8152 ndev->dev_addr[2] = 0x11;
8153 ndev->dev_addr[3] |= 0xF0;
8154 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8155 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008156 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8157 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008158 }
8159
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 hdd_set_ap_ops( pAdapter->dev );
8161
Kiet Lam10841362013-11-01 11:36:50 +05308162 /* This is for only SAP mode where users can
8163 * control country through ini.
8164 * P2P GO follows station country code
8165 * acquired during the STA scanning. */
8166 if((NL80211_IFTYPE_AP == type) &&
8167 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8168 {
8169 int status = 0;
8170 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8171 "%s: setting country code from INI ", __func__);
8172 init_completion(&pAdapter->change_country_code);
8173 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8174 (void *)(tSmeChangeCountryCallback)
8175 wlan_hdd_change_country_code_cb,
8176 pConfig->apCntryCode, pAdapter,
8177 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308178 eSIR_FALSE,
8179 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308180 if (eHAL_STATUS_SUCCESS == status)
8181 {
8182 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308183 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308184 &pAdapter->change_country_code,
8185 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308186 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308187 {
8188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308189 FL("SME Timed out while setting country code %ld"),
8190 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008191
8192 if (pHddCtx->isLogpInProgress)
8193 {
8194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8195 "%s: LOGP in Progress. Ignore!!!", __func__);
8196 return -EAGAIN;
8197 }
Kiet Lam10841362013-11-01 11:36:50 +05308198 }
8199 }
8200 else
8201 {
8202 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008203 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308204 return -EINVAL;
8205 }
8206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 status = hdd_init_ap_mode(pAdapter);
8208 if(status != VOS_STATUS_SUCCESS)
8209 {
8210 hddLog(VOS_TRACE_LEVEL_FATAL,
8211 "%s: Error initializing the ap mode", __func__);
8212 return -EINVAL;
8213 }
8214 hdd_set_conparam(1);
8215
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 /*interface type changed update in wiphy structure*/
8217 if(wdev)
8218 {
8219 wdev->iftype = type;
8220 pHddCtx->change_iface = type;
8221 }
8222 else
8223 {
8224 hddLog(VOS_TRACE_LEVEL_ERROR,
8225 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8226 return -EINVAL;
8227 }
8228 goto done;
8229 }
8230
8231 default:
8232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8233 __func__);
8234 return -EOPNOTSUPP;
8235 }
8236 }
8237 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 )
8240 {
8241 switch(type)
8242 {
8243 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308246
8247 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308248#ifdef FEATURE_WLAN_TDLS
8249
8250 /* A Mutex Lock is introduced while changing the mode to
8251 * protect the concurrent access for the Adapters by TDLS
8252 * module.
8253 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308254 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308255#endif
c_hpothu002231a2015-02-05 14:58:51 +05308256 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008258 //Check for sub-string p2p to confirm its a p2p interface
8259 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008260 {
8261 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8262 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8263 }
8264 else
8265 {
8266 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 hdd_set_conparam(0);
8270 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008271 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8272 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308273#ifdef FEATURE_WLAN_TDLS
8274 mutex_unlock(&pHddCtx->tdls_lock);
8275#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308276 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 if( VOS_STATUS_SUCCESS != status )
8278 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008279 /* In case of JB, for P2P-GO, only change interface will be called,
8280 * This is the right place to enable back bmps_imps()
8281 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308282 if (pHddCtx->hdd_wlan_suspended)
8283 {
8284 hdd_set_pwrparams(pHddCtx);
8285 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008286 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 goto done;
8288 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8292 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 goto done;
8294 default:
8295 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8296 __func__);
8297 return -EOPNOTSUPP;
8298
8299 }
8300
8301 }
8302 else
8303 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308304 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8305 __func__, hdd_device_modetoString(pAdapter->device_mode),
8306 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 return -EOPNOTSUPP;
8308 }
8309
8310
8311 if(pRoamProfile)
8312 {
8313 if ( LastBSSType != pRoamProfile->BSSType )
8314 {
8315 /*interface type changed update in wiphy structure*/
8316 wdev->iftype = type;
8317
8318 /*the BSS mode changed, We need to issue disconnect
8319 if connected or in IBSS disconnect state*/
8320 if ( hdd_connGetConnectedBssType(
8321 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8322 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8323 {
8324 /*need to issue a disconnect to CSR.*/
8325 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8326 if( eHAL_STATUS_SUCCESS ==
8327 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8328 pAdapter->sessionId,
8329 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8330 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308331 ret = wait_for_completion_interruptible_timeout(
8332 &pAdapter->disconnect_comp_var,
8333 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8334 if (ret <= 0)
8335 {
8336 hddLog(VOS_TRACE_LEVEL_ERROR,
8337 FL("wait on disconnect_comp_var failed %ld"), ret);
8338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 }
8340 }
8341 }
8342 }
8343
8344done:
8345 /*set bitmask based on updated value*/
8346 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008347
8348 /* Only STA mode support TM now
8349 * all other mode, TM feature should be disabled */
8350 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8351 (~VOS_STA & pHddCtx->concurrency_mode) )
8352 {
8353 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8354 }
8355
Jeff Johnson295189b2012-06-20 16:38:30 -07008356#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308357 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308358 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 {
8360 //we are ok to do AMP
8361 pHddCtx->isAmpAllowed = VOS_TRUE;
8362 }
8363#endif //WLAN_BTAMP_FEATURE
8364 EXIT();
8365 return 0;
8366}
8367
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308368/*
8369 * FUNCTION: wlan_hdd_cfg80211_change_iface
8370 * wrapper function to protect the actual implementation from SSR.
8371 */
8372int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8373 struct net_device *ndev,
8374 enum nl80211_iftype type,
8375 u32 *flags,
8376 struct vif_params *params
8377 )
8378{
8379 int ret;
8380
8381 vos_ssr_protect(__func__);
8382 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8383 vos_ssr_unprotect(__func__);
8384
8385 return ret;
8386}
8387
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008388#ifdef FEATURE_WLAN_TDLS
8389static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8390 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8391{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008392 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008393 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308394 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308395 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308396 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008397
8398 ENTER();
8399
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308400 if (!dev) {
8401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8402 return -EINVAL;
8403 }
8404
8405 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8406 if (!pAdapter) {
8407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8408 return -EINVAL;
8409 }
8410
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308411 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008412 {
8413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8414 "Invalid arguments");
8415 return -EINVAL;
8416 }
Hoonki Lee27511902013-03-14 18:19:06 -07008417
8418 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8419 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8420 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008422 "%s: TDLS mode is disabled OR not enabled in FW."
8423 MAC_ADDRESS_STR " Request declined.",
8424 __func__, MAC_ADDR_ARRAY(mac));
8425 return -ENOTSUPP;
8426 }
8427
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008428 if (pHddCtx->isLogpInProgress)
8429 {
8430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8431 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308432 wlan_hdd_tdls_set_link_status(pAdapter,
8433 mac,
8434 eTDLS_LINK_IDLE,
8435 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008436 return -EBUSY;
8437 }
8438
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308439 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008440
8441 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008443 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8444 __func__, MAC_ADDR_ARRAY(mac), update);
8445 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008446 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008447
8448 /* in add station, we accept existing valid staId if there is */
8449 if ((0 == update) &&
8450 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8451 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008452 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308453 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008454 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008455 " link_status %d. staId %d. add station ignored.",
8456 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8457 return 0;
8458 }
8459 /* in change station, we accept only when staId is valid */
8460 if ((1 == update) &&
8461 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8462 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8463 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008465 "%s: " MAC_ADDRESS_STR
8466 " link status %d. staId %d. change station %s.",
8467 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8468 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8469 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008470 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008471
8472 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308473 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008474 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008475 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8476 "%s: " MAC_ADDRESS_STR
8477 " TDLS setup is ongoing. Request declined.",
8478 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008479 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008480 }
8481
8482 /* first to check if we reached to maximum supported TDLS peer.
8483 TODO: for now, return -EPERM looks working fine,
8484 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308485 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8486 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008487 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008488 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8489 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308490 " TDLS Max peer already connected. Request declined."
8491 " Num of peers (%d), Max allowed (%d).",
8492 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8493 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008494 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008495 }
8496 else
8497 {
8498 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308499 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008500 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008501 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8503 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8504 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008505 return -EPERM;
8506 }
8507 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008508 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308509 wlan_hdd_tdls_set_link_status(pAdapter,
8510 mac,
8511 eTDLS_LINK_CONNECTING,
8512 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008513
Jeff Johnsond75fe012013-04-06 10:53:06 -07008514 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308515 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008516 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008518 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008519 if(StaParams->htcap_present)
8520 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008522 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008524 "ht_capa->extended_capabilities: %0x",
8525 StaParams->HTCap.extendedHtCapInfo);
8526 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008528 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008530 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008531 if(StaParams->vhtcap_present)
8532 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008534 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8535 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8536 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8537 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008538 {
8539 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008541 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008543 "[%d]: %x ", i, StaParams->supported_rates[i]);
8544 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008545 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308546 else if ((1 == update) && (NULL == StaParams))
8547 {
8548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8549 "%s : update is true, but staParams is NULL. Error!", __func__);
8550 return -EPERM;
8551 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008552
8553 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8554
8555 if (!update)
8556 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308557 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008558 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308559 if (ret != eHAL_STATUS_SUCCESS) {
8560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8561 return -EPERM;
8562 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008563 }
8564 else
8565 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308566 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008567 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308568 if (ret != eHAL_STATUS_SUCCESS) {
8569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8570 return -EPERM;
8571 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008572 }
8573
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308574 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008575 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8576
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308577 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008578 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308580 "%s: timeout waiting for tdls add station indication %ld",
8581 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008582 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008583 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308584
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008585 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8586 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008588 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008589 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008590 }
8591
8592 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008593
8594error:
Atul Mittal115287b2014-07-08 13:26:33 +05308595 wlan_hdd_tdls_set_link_status(pAdapter,
8596 mac,
8597 eTDLS_LINK_IDLE,
8598 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008599 return -EPERM;
8600
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008601}
8602#endif
8603
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308604static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 struct net_device *dev,
8606 u8 *mac,
8607 struct station_parameters *params)
8608{
8609 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308610 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308611 hdd_context_t *pHddCtx;
8612 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308614 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008615#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008616 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008617 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308618 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008619#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008620
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308621 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308622
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308623 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308624 if ((NULL == pAdapter))
8625 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308627 "invalid adapter ");
8628 return -EINVAL;
8629 }
8630
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308631 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8632 TRACE_CODE_HDD_CHANGE_STATION,
8633 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308634 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308635
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308636 ret = wlan_hdd_validate_context(pHddCtx);
8637 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308638 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308639 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308640 }
8641
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308642 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8643
8644 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008645 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8647 "invalid HDD station context");
8648 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8651
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008652 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8653 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008654 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008655 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308657 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 WLANTL_STA_AUTHENTICATED);
8659
Gopichand Nakkala29149562013-05-10 21:43:41 +05308660 if (status != VOS_STATUS_SUCCESS)
8661 {
8662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8663 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8664 return -EINVAL;
8665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 }
8667 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008668 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8669 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308670#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008671 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8672 StaParams.capability = params->capability;
8673 StaParams.uapsd_queues = params->uapsd_queues;
8674 StaParams.max_sp = params->max_sp;
8675
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308676 /* Convert (first channel , number of channels) tuple to
8677 * the total list of channels. This goes with the assumption
8678 * that if the first channel is < 14, then the next channels
8679 * are an incremental of 1 else an incremental of 4 till the number
8680 * of channels.
8681 */
8682 if (0 != params->supported_channels_len) {
8683 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8684 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8685 {
8686 int wifi_chan_index;
8687 StaParams.supported_channels[j] = params->supported_channels[i];
8688 wifi_chan_index =
8689 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8690 no_of_channels = params->supported_channels[i+1];
8691 for(k=1; k <= no_of_channels; k++)
8692 {
8693 StaParams.supported_channels[j+1] =
8694 StaParams.supported_channels[j] + wifi_chan_index;
8695 j+=1;
8696 }
8697 }
8698 StaParams.supported_channels_len = j;
8699 }
8700 vos_mem_copy(StaParams.supported_oper_classes,
8701 params->supported_oper_classes,
8702 params->supported_oper_classes_len);
8703 StaParams.supported_oper_classes_len =
8704 params->supported_oper_classes_len;
8705
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008706 if (0 != params->ext_capab_len)
8707 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8708 sizeof(StaParams.extn_capability));
8709
8710 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008711 {
8712 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008713 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008714 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008715
8716 StaParams.supported_rates_len = params->supported_rates_len;
8717
8718 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8719 * The supported_rates array , for all the structures propogating till Add Sta
8720 * to the firmware has to be modified , if the supplicant (ieee80211) is
8721 * modified to send more rates.
8722 */
8723
8724 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8725 */
8726 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8727 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8728
8729 if (0 != StaParams.supported_rates_len) {
8730 int i = 0;
8731 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8732 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008734 "Supported Rates with Length %d", StaParams.supported_rates_len);
8735 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008737 "[%d]: %0x", i, StaParams.supported_rates[i]);
8738 }
8739
8740 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008741 {
8742 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008743 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008744 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008745
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008746 if (0 != params->ext_capab_len ) {
8747 /*Define A Macro : TODO Sunil*/
8748 if ((1<<4) & StaParams.extn_capability[3]) {
8749 isBufSta = 1;
8750 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308751 /* TDLS Channel Switching Support */
8752 if ((1<<6) & StaParams.extn_capability[3]) {
8753 isOffChannelSupported = 1;
8754 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008755 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308756 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8757 &StaParams, isBufSta,
8758 isOffChannelSupported);
8759
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308760 if (VOS_STATUS_SUCCESS != status) {
8761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8762 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8763 return -EINVAL;
8764 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008765 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8766
8767 if (VOS_STATUS_SUCCESS != status) {
8768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8769 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8770 return -EINVAL;
8771 }
8772 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008773#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308774 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008775 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008776 return status;
8777}
8778
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308779static int wlan_hdd_change_station(struct wiphy *wiphy,
8780 struct net_device *dev,
8781 u8 *mac,
8782 struct station_parameters *params)
8783{
8784 int ret;
8785
8786 vos_ssr_protect(__func__);
8787 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8788 vos_ssr_unprotect(__func__);
8789
8790 return ret;
8791}
8792
Jeff Johnson295189b2012-06-20 16:38:30 -07008793/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308794 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 * This function is used to initialize the key information
8796 */
8797#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308798static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 struct net_device *ndev,
8800 u8 key_index, bool pairwise,
8801 const u8 *mac_addr,
8802 struct key_params *params
8803 )
8804#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308805static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 struct net_device *ndev,
8807 u8 key_index, const u8 *mac_addr,
8808 struct key_params *params
8809 )
8810#endif
8811{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008812 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 tCsrRoamSetKey setKey;
8814 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308815 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008816 v_U32_t roamId= 0xFF;
8817 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 hdd_hostapd_state_t *pHostapdState;
8819 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008820 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308821 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008822
8823 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308824
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308825 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8826 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8827 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308828 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8829 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308830 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008831 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308832 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008833 }
8834
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308835 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8836 __func__, hdd_device_modetoString(pAdapter->device_mode),
8837 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008838
8839 if (CSR_MAX_NUM_KEY <= key_index)
8840 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008841 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 key_index);
8843
8844 return -EINVAL;
8845 }
8846
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008847 if (CSR_MAX_KEY_LEN < params->key_len)
8848 {
8849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8850 params->key_len);
8851
8852 return -EINVAL;
8853 }
8854
8855 hddLog(VOS_TRACE_LEVEL_INFO,
8856 "%s: called with key index = %d & key length %d",
8857 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008858
8859 /*extract key idx, key len and key*/
8860 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8861 setKey.keyId = key_index;
8862 setKey.keyLength = params->key_len;
8863 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8864
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008865 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 {
8867 case WLAN_CIPHER_SUITE_WEP40:
8868 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8869 break;
8870
8871 case WLAN_CIPHER_SUITE_WEP104:
8872 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8873 break;
8874
8875 case WLAN_CIPHER_SUITE_TKIP:
8876 {
8877 u8 *pKey = &setKey.Key[0];
8878 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8879
8880 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8881
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008882 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008883
8884 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008885 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 |--------------|----------|----------|
8887 <---16bytes---><--8bytes--><--8bytes-->
8888
8889 */
8890 /*Sme expects the 32 bytes key to be in the below order
8891
8892 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008893 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 |--------------|----------|----------|
8895 <---16bytes---><--8bytes--><--8bytes-->
8896 */
8897 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008898 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008899
8900 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008901 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008902
8903 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008904 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008905
8906
8907 break;
8908 }
8909
8910 case WLAN_CIPHER_SUITE_CCMP:
8911 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8912 break;
8913
8914#ifdef FEATURE_WLAN_WAPI
8915 case WLAN_CIPHER_SUITE_SMS4:
8916 {
8917 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8918 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8919 params->key, params->key_len);
8920 return 0;
8921 }
8922#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008923
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008924#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 case WLAN_CIPHER_SUITE_KRK:
8926 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8927 break;
8928#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008929
8930#ifdef WLAN_FEATURE_11W
8931 case WLAN_CIPHER_SUITE_AES_CMAC:
8932 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008933 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008934#endif
8935
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008937 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308939 status = -EOPNOTSUPP;
8940 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 }
8942
8943 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8944 __func__, setKey.encType);
8945
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008946 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8948 (!pairwise)
8949#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008950 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008951#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008952 )
8953 {
8954 /* set group key*/
8955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8956 "%s- %d: setting Broadcast key",
8957 __func__, __LINE__);
8958 setKey.keyDirection = eSIR_RX_ONLY;
8959 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8960 }
8961 else
8962 {
8963 /* set pairwise key*/
8964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8965 "%s- %d: setting pairwise key",
8966 __func__, __LINE__);
8967 setKey.keyDirection = eSIR_TX_RX;
8968 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8969 }
8970 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8971 {
8972 setKey.keyDirection = eSIR_TX_RX;
8973 /*Set the group key*/
8974 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8975 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008976
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008977 if ( 0 != status )
8978 {
8979 hddLog(VOS_TRACE_LEVEL_ERROR,
8980 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308981 status = -EINVAL;
8982 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008983 }
8984 /*Save the keys here and call sme_RoamSetKey for setting
8985 the PTK after peer joins the IBSS network*/
8986 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8987 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308988 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008989 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308990 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8991 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8992 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008994 if( pHostapdState->bssState == BSS_START )
8995 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8997
8998 if ( status != eHAL_STATUS_SUCCESS )
8999 {
9000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9001 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9002 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309003 status = -EINVAL;
9004 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 }
9006 }
9007
9008 /* Saving WEP keys */
9009 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9010 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9011 {
9012 //Save the wep key in ap context. Issue setkey after the BSS is started.
9013 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9014 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9015 }
9016 else
9017 {
9018 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009019 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009020 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9021 }
9022 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009023 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9024 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 {
9026 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9027 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9028
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309029#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9030 if (!pairwise)
9031#else
9032 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9033#endif
9034 {
9035 /* set group key*/
9036 if (pHddStaCtx->roam_info.deferKeyComplete)
9037 {
9038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9039 "%s- %d: Perform Set key Complete",
9040 __func__, __LINE__);
9041 hdd_PerformRoamSetKeyComplete(pAdapter);
9042 }
9043 }
9044
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9046
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009047 pWextState->roamProfile.Keys.defaultIndex = key_index;
9048
9049
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009050 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 params->key, params->key_len);
9052
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309053
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9055
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309056 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309058 __func__, setKey.peerMac[0], setKey.peerMac[1],
9059 setKey.peerMac[2], setKey.peerMac[3],
9060 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 setKey.keyDirection);
9062
Nirav Shah4f765af2015-01-21 19:51:30 +05309063 /* Wait for EAPOL M4 before setting key.
9064 * No need to consider Dynamic WEP as we will receive M8.
9065 */
9066 if ( (setKey.encType == eCSR_ENCRYPT_TYPE_AES ||
9067 setKey.encType == eCSR_ENCRYPT_TYPE_TKIP) &&
9068 ( 1
9069#if defined WLAN_FEATURE_VOWIFI_11R
9070 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN
9071 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN_PSK
9072#endif
9073#ifdef FEATURE_WLAN_ESE
9074 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_WPA
9075 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_RSN
9076#endif
9077 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 {
Nirav Shah4f765af2015-01-21 19:51:30 +05309079 vos_status = wlan_hdd_check_ula_done(pAdapter);
9080
9081 if ( vos_status != VOS_STATUS_SUCCESS )
9082 {
9083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9085 __LINE__, vos_status );
9086
Nirav Shah4f765af2015-01-21 19:51:30 +05309087 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009088
Nirav Shah4f765af2015-01-21 19:51:30 +05309089 status = -EINVAL;
9090 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009091
Nirav Shah4f765af2015-01-21 19:51:30 +05309092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 }
9094
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009095#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309096 /* The supplicant may attempt to set the PTK once pre-authentication
9097 is done. Save the key in the UMAC and include it in the ADD BSS
9098 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009099 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309100 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009101 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309102 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9103 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309104 status = 0;
9105 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309106 }
9107 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9108 {
9109 hddLog(VOS_TRACE_LEVEL_ERROR,
9110 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309111 status = -EINVAL;
9112 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009113 }
9114#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009115
9116 /* issue set key request to SME*/
9117 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9118 pAdapter->sessionId, &setKey, &roamId );
9119
9120 if ( 0 != status )
9121 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309122 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9124 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309125 status = -EINVAL;
9126 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 }
9128
9129
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309130 /* in case of IBSS as there was no information available about WEP keys during
9131 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309133 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9134 !( ( IW_AUTH_KEY_MGMT_802_1X
9135 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9137 )
9138 &&
9139 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9140 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9141 )
9142 )
9143 {
9144 setKey.keyDirection = eSIR_RX_ONLY;
9145 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9146
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309147 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309149 __func__, setKey.peerMac[0], setKey.peerMac[1],
9150 setKey.peerMac[2], setKey.peerMac[3],
9151 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 setKey.keyDirection);
9153
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309154 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 pAdapter->sessionId, &setKey, &roamId );
9156
9157 if ( 0 != status )
9158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309159 hddLog(VOS_TRACE_LEVEL_ERROR,
9160 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 __func__, status);
9162 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309163 status = -EINVAL;
9164 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009165 }
9166 }
9167 }
9168
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309169end:
9170 /* Need to clear any trace of key value in the memory.
9171 * Thus zero out the memory even though it is local
9172 * variable.
9173 */
9174 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309175 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309176 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009177}
9178
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309179#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9180static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9181 struct net_device *ndev,
9182 u8 key_index, bool pairwise,
9183 const u8 *mac_addr,
9184 struct key_params *params
9185 )
9186#else
9187static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9188 struct net_device *ndev,
9189 u8 key_index, const u8 *mac_addr,
9190 struct key_params *params
9191 )
9192#endif
9193{
9194 int ret;
9195 vos_ssr_protect(__func__);
9196#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9197 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9198 mac_addr, params);
9199#else
9200 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9201 params);
9202#endif
9203 vos_ssr_unprotect(__func__);
9204
9205 return ret;
9206}
9207
Jeff Johnson295189b2012-06-20 16:38:30 -07009208/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309209 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 * This function is used to get the key information
9211 */
9212#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309213static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309214 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309216 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 const u8 *mac_addr, void *cookie,
9218 void (*callback)(void *cookie, struct key_params*)
9219 )
9220#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309221static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309222 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 struct net_device *ndev,
9224 u8 key_index, const u8 *mac_addr, void *cookie,
9225 void (*callback)(void *cookie, struct key_params*)
9226 )
9227#endif
9228{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309229 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309230 hdd_wext_state_t *pWextState = NULL;
9231 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309233 hdd_context_t *pHddCtx;
9234 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235
9236 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309237
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309238 if (NULL == pAdapter)
9239 {
9240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9241 "%s: HDD adapter is Null", __func__);
9242 return -ENODEV;
9243 }
9244
9245 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9246 ret = wlan_hdd_validate_context(pHddCtx);
9247 if (0 != ret)
9248 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309249 return ret;
9250 }
9251
9252 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9253 pRoamProfile = &(pWextState->roamProfile);
9254
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309255 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9256 __func__, hdd_device_modetoString(pAdapter->device_mode),
9257 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309258
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 memset(&params, 0, sizeof(params));
9260
9261 if (CSR_MAX_NUM_KEY <= key_index)
9262 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009266
9267 switch(pRoamProfile->EncryptionType.encryptionType[0])
9268 {
9269 case eCSR_ENCRYPT_TYPE_NONE:
9270 params.cipher = IW_AUTH_CIPHER_NONE;
9271 break;
9272
9273 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9274 case eCSR_ENCRYPT_TYPE_WEP40:
9275 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9276 break;
9277
9278 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9279 case eCSR_ENCRYPT_TYPE_WEP104:
9280 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9281 break;
9282
9283 case eCSR_ENCRYPT_TYPE_TKIP:
9284 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9285 break;
9286
9287 case eCSR_ENCRYPT_TYPE_AES:
9288 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9289 break;
9290
9291 default:
9292 params.cipher = IW_AUTH_CIPHER_NONE;
9293 break;
9294 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309295
c_hpothuaaf19692014-05-17 17:01:48 +05309296 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9297 TRACE_CODE_HDD_CFG80211_GET_KEY,
9298 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309299
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9301 params.seq_len = 0;
9302 params.seq = NULL;
9303 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9304 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 return 0;
9307}
9308
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309309#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9310static int wlan_hdd_cfg80211_get_key(
9311 struct wiphy *wiphy,
9312 struct net_device *ndev,
9313 u8 key_index, bool pairwise,
9314 const u8 *mac_addr, void *cookie,
9315 void (*callback)(void *cookie, struct key_params*)
9316 )
9317#else
9318static int wlan_hdd_cfg80211_get_key(
9319 struct wiphy *wiphy,
9320 struct net_device *ndev,
9321 u8 key_index, const u8 *mac_addr, void *cookie,
9322 void (*callback)(void *cookie, struct key_params*)
9323 )
9324#endif
9325{
9326 int ret;
9327
9328 vos_ssr_protect(__func__);
9329#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9330 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9331 mac_addr, cookie, callback);
9332#else
9333 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9334 callback);
9335#endif
9336 vos_ssr_unprotect(__func__);
9337
9338 return ret;
9339}
9340
Jeff Johnson295189b2012-06-20 16:38:30 -07009341/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309342 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 * This function is used to delete the key information
9344 */
9345#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309346static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309348 u8 key_index,
9349 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 const u8 *mac_addr
9351 )
9352#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309353static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 struct net_device *ndev,
9355 u8 key_index,
9356 const u8 *mac_addr
9357 )
9358#endif
9359{
9360 int status = 0;
9361
9362 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309363 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 //it is observed that this is invalidating peer
9365 //key index whenever re-key is done. This is affecting data link.
9366 //It should be ok to ignore del_key.
9367#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309368 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9369 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9371 tCsrRoamSetKey setKey;
9372 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309373
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 ENTER();
9375
9376 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9377 __func__,pAdapter->device_mode);
9378
9379 if (CSR_MAX_NUM_KEY <= key_index)
9380 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309381 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 key_index);
9383
9384 return -EINVAL;
9385 }
9386
9387 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9388 setKey.keyId = key_index;
9389
9390 if (mac_addr)
9391 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9392 else
9393 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9394
9395 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9396
9397 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309399 )
9400 {
9401
9402 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9404 if( pHostapdState->bssState == BSS_START)
9405 {
9406 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309407
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 if ( status != eHAL_STATUS_SUCCESS )
9409 {
9410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9411 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9412 __LINE__, status );
9413 }
9414 }
9415 }
9416 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309417 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 )
9419 {
9420 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9421
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309422 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9423
9424 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309426 __func__, setKey.peerMac[0], setKey.peerMac[1],
9427 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309429 if(pAdapter->sessionCtx.station.conn_info.connState ==
9430 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309432 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309434
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 if ( 0 != status )
9436 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309437 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 "%s: sme_RoamSetKey failure, returned %d",
9439 __func__, status);
9440 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9441 return -EINVAL;
9442 }
9443 }
9444 }
9445#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009446 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 return status;
9448}
9449
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9451static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9452 struct net_device *ndev,
9453 u8 key_index,
9454 bool pairwise,
9455 const u8 *mac_addr
9456 )
9457#else
9458static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9459 struct net_device *ndev,
9460 u8 key_index,
9461 const u8 *mac_addr
9462 )
9463#endif
9464{
9465 int ret;
9466
9467 vos_ssr_protect(__func__);
9468#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9469 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9470 mac_addr);
9471#else
9472 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9473#endif
9474 vos_ssr_unprotect(__func__);
9475
9476 return ret;
9477}
9478
Jeff Johnson295189b2012-06-20 16:38:30 -07009479/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309480 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 * This function is used to set the default tx key index
9482 */
9483#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309484static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 struct net_device *ndev,
9486 u8 key_index,
9487 bool unicast, bool multicast)
9488#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309489static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 struct net_device *ndev,
9491 u8 key_index)
9492#endif
9493{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309494 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309495 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309496 hdd_wext_state_t *pWextState;
9497 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309498 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009499
9500 ENTER();
9501
Gopichand Nakkala29149562013-05-10 21:43:41 +05309502 if ((NULL == pAdapter))
9503 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309505 "invalid adapter");
9506 return -EINVAL;
9507 }
9508
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309509 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9510 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9511 pAdapter->sessionId, key_index));
9512
Gopichand Nakkala29149562013-05-10 21:43:41 +05309513 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9514 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9515
9516 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9517 {
9518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9519 "invalid Wext state or HDD context");
9520 return -EINVAL;
9521 }
9522
Arif Hussain6d2a3322013-11-17 19:50:10 -08009523 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309525
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 if (CSR_MAX_NUM_KEY <= key_index)
9527 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309528 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 key_index);
9530
9531 return -EINVAL;
9532 }
9533
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309534 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9535 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309536 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009537 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309538 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009539 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309540
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309543 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309545 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009546 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309547 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009548 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309550 {
9551 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309553
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 tCsrRoamSetKey setKey;
9555 v_U32_t roamId= 0xFF;
9556 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309557
9558 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309560
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 Keys->defaultIndex = (u8)key_index;
9562 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9563 setKey.keyId = key_index;
9564 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565
9566 vos_mem_copy(&setKey.Key[0],
9567 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309569
Gopichand Nakkala29149562013-05-10 21:43:41 +05309570 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309571
9572 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 &pHddStaCtx->conn_info.bssId[0],
9574 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309575
Gopichand Nakkala29149562013-05-10 21:43:41 +05309576 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9577 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9578 eCSR_ENCRYPT_TYPE_WEP104)
9579 {
9580 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9581 even though ap is configured for WEP-40 encryption. In this canse the key length
9582 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9583 type(104) and switching encryption type to 40*/
9584 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9585 eCSR_ENCRYPT_TYPE_WEP40;
9586 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9587 eCSR_ENCRYPT_TYPE_WEP40;
9588 }
9589
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309590 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309592
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309594 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309596
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 if ( 0 != status )
9598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309599 hddLog(VOS_TRACE_LEVEL_ERROR,
9600 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 status);
9602 return -EINVAL;
9603 }
9604 }
9605 }
9606
9607 /* In SoftAp mode setting key direction for default mode */
9608 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9609 {
9610 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9611 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9612 (eCSR_ENCRYPT_TYPE_AES !=
9613 pWextState->roamProfile.EncryptionType.encryptionType[0])
9614 )
9615 {
9616 /* Saving key direction for default key index to TX default */
9617 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9618 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9619 }
9620 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309621 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 return status;
9623}
9624
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9626static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9627 struct net_device *ndev,
9628 u8 key_index,
9629 bool unicast, bool multicast)
9630#else
9631static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9632 struct net_device *ndev,
9633 u8 key_index)
9634#endif
9635{
9636 int ret;
9637 vos_ssr_protect(__func__);
9638#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9639 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9640 multicast);
9641#else
9642 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9643#endif
9644 vos_ssr_unprotect(__func__);
9645
9646 return ret;
9647}
9648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649/*
9650 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9651 * This function is used to inform the BSS details to nl80211 interface.
9652 */
9653static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9654 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9655{
9656 struct net_device *dev = pAdapter->dev;
9657 struct wireless_dev *wdev = dev->ieee80211_ptr;
9658 struct wiphy *wiphy = wdev->wiphy;
9659 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9660 int chan_no;
9661 int ie_length;
9662 const char *ie;
9663 unsigned int freq;
9664 struct ieee80211_channel *chan;
9665 int rssi = 0;
9666 struct cfg80211_bss *bss = NULL;
9667
9668 ENTER();
9669
9670 if( NULL == pBssDesc )
9671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009672 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 return bss;
9674 }
9675
9676 chan_no = pBssDesc->channelId;
9677 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9678 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9679
9680 if( NULL == ie )
9681 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009682 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 return bss;
9684 }
9685
9686#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9687 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9688 {
9689 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9690 }
9691 else
9692 {
9693 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9694 }
9695#else
9696 freq = ieee80211_channel_to_frequency(chan_no);
9697#endif
9698
9699 chan = __ieee80211_get_channel(wiphy, freq);
9700
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309701 if (!chan) {
9702 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9703 return NULL;
9704 }
9705
Abhishek Singhaee43942014-06-16 18:55:47 +05309706 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009707
Abhishek Singhaee43942014-06-16 18:55:47 +05309708 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309709 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 pBssDesc->capabilityInfo,
9711 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309712 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009713}
9714
9715
9716
9717/*
9718 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9719 * This function is used to inform the BSS details to nl80211 interface.
9720 */
9721struct cfg80211_bss*
9722wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9723 tSirBssDescription *bss_desc
9724 )
9725{
9726 /*
9727 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9728 already exists in bss data base of cfg80211 for that particular BSS ID.
9729 Using cfg80211_inform_bss_frame to update the bss entry instead of
9730 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9731 now there is no possibility to get the mgmt(probe response) frame from PE,
9732 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9733 cfg80211_inform_bss_frame.
9734 */
9735 struct net_device *dev = pAdapter->dev;
9736 struct wireless_dev *wdev = dev->ieee80211_ptr;
9737 struct wiphy *wiphy = wdev->wiphy;
9738 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009739#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9740 qcom_ie_age *qie_age = NULL;
9741 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9742#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 const char *ie =
9746 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9747 unsigned int freq;
9748 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309749 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009750 struct cfg80211_bss *bss_status = NULL;
9751 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9752 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009753 hdd_context_t *pHddCtx;
9754 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009755#ifdef WLAN_OPEN_SOURCE
9756 struct timespec ts;
9757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309759 ENTER();
9760
Wilson Yangf80a0542013-10-07 13:02:37 -07009761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9762 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009763 if (0 != status)
9764 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009765 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009766 }
9767
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309768 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009769 if (!mgmt)
9770 {
9771 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9772 "%s: memory allocation failed ", __func__);
9773 return NULL;
9774 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009775
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009777
9778#ifdef WLAN_OPEN_SOURCE
9779 /* Android does not want the timestamp from the frame.
9780 Instead it wants a monotonic increasing value */
9781 get_monotonic_boottime(&ts);
9782 mgmt->u.probe_resp.timestamp =
9783 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9784#else
9785 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9787 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009788
9789#endif
9790
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9792 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009793
9794#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9795 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9796 /* Assuming this is the last IE, copy at the end */
9797 ie_length -=sizeof(qcom_ie_age);
9798 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9799 qie_age->element_id = QCOM_VENDOR_IE_ID;
9800 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9801 qie_age->oui_1 = QCOM_OUI1;
9802 qie_age->oui_2 = QCOM_OUI2;
9803 qie_age->oui_3 = QCOM_OUI3;
9804 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9805 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9806#endif
9807
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309809 if (bss_desc->fProbeRsp)
9810 {
9811 mgmt->frame_control |=
9812 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9813 }
9814 else
9815 {
9816 mgmt->frame_control |=
9817 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009819
9820#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309821 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9823 {
9824 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9825 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309826 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9828
9829 {
9830 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9831 }
9832 else
9833 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9835 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 kfree(mgmt);
9837 return NULL;
9838 }
9839#else
9840 freq = ieee80211_channel_to_frequency(chan_no);
9841#endif
9842 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009843 /*when the band is changed on the fly using the GUI, three things are done
9844 * 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)
9845 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9846 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9847 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9848 * and discards the channels correponding to previous band and calls back with zero bss results.
9849 * 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
9850 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9851 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9852 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9853 * So drop the bss and continue to next bss.
9854 */
9855 if(chan == NULL)
9856 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009858 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009859 return NULL;
9860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309862 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 * */
9864 if (( eConnectionState_Associated ==
9865 pAdapter->sessionCtx.station.conn_info.connState ) &&
9866 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9867 pAdapter->sessionCtx.station.conn_info.bssId,
9868 WNI_CFG_BSSID_LEN)))
9869 {
9870 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9871 rssi = (pAdapter->rssi * 100);
9872 }
9873 else
9874 {
9875 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9876 }
9877
Nirav Shah20ac06f2013-12-12 18:14:06 +05309878 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
9879 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9880 chan->center_freq, (int)(rssi/100));
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9883 frame_len, rssi, GFP_KERNEL);
9884 kfree(mgmt);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309885 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 return bss_status;
9887}
9888
9889/*
9890 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9891 * This function is used to update the BSS data base of CFG8011
9892 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309893struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009894 tCsrRoamInfo *pRoamInfo
9895 )
9896{
9897 tCsrRoamConnectedProfile roamProfile;
9898 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9899 struct cfg80211_bss *bss = NULL;
9900
9901 ENTER();
9902
9903 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9904 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9905
9906 if (NULL != roamProfile.pBssDesc)
9907 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309908 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9909 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009910
9911 if (NULL == bss)
9912 {
9913 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9914 __func__);
9915 }
9916
9917 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9918 }
9919 else
9920 {
9921 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9922 __func__);
9923 }
9924 return bss;
9925}
9926
9927/*
9928 * FUNCTION: wlan_hdd_cfg80211_update_bss
9929 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309930static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9931 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309933{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 tCsrScanResultInfo *pScanResult;
9936 eHalStatus status = 0;
9937 tScanResultHandle pResult;
9938 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009939 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009940
9941 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309942
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309943 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9944 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9945 NO_SESSION, pAdapter->sessionId));
9946
Wilson Yangf80a0542013-10-07 13:02:37 -07009947 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9948
9949 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9952 "%s:LOGP in Progress. Ignore!!!",__func__);
9953 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 }
9955
Wilson Yangf80a0542013-10-07 13:02:37 -07009956
9957 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309958 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009959 {
9960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9961 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9962 return VOS_STATUS_E_PERM;
9963 }
9964
9965
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 /*
9967 * start getting scan results and populate cgf80211 BSS database
9968 */
9969 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9970
9971 /* no scan results */
9972 if (NULL == pResult)
9973 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309974 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9975 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 return status;
9977 }
9978
9979 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9980
9981 while (pScanResult)
9982 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309983 /*
9984 * cfg80211_inform_bss() is not updating ie field of bss entry, if
9985 * entry already exists in bss data base of cfg80211 for that
9986 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
9987 * bss entry instead of cfg80211_inform_bss, But this call expects
9988 * mgmt packet as input. As of now there is no possibility to get
9989 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 * ieee80211_mgmt(probe response) and passing to c
9991 * fg80211_inform_bss_frame.
9992 * */
9993
9994 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9995 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309996
Jeff Johnson295189b2012-06-20 16:38:30 -07009997
9998 if (NULL == bss_status)
9999 {
10000 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010001 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 }
10003 else
10004 {
Yue Maf49ba872013-08-19 12:04:25 -070010005 cfg80211_put_bss(
10006#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10007 wiphy,
10008#endif
10009 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 }
10011
10012 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10013 }
10014
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010015 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010016
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010017 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010018}
10019
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010020void
10021hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10022{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010023 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010024 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010025} /****** end hddPrintMacAddr() ******/
10026
10027void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010028hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010029{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010030 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010031 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010032 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10033 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10034 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010035} /****** end hddPrintPmkId() ******/
10036
10037//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10038//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10039
10040//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10041//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10042
10043#define dump_bssid(bssid) \
10044 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010045 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10046 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010047 }
10048
10049#define dump_pmkid(pMac, pmkid) \
10050 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010051 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10052 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010053 }
10054
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010055#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010056/*
10057 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10058 * This function is used to notify the supplicant of a new PMKSA candidate.
10059 */
10060int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010061 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010062 int index, bool preauth )
10063{
Jeff Johnsone7245742012-09-05 17:12:55 -070010064#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010065 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010066 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010067
10068 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010069 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010070
10071 if( NULL == pRoamInfo )
10072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010073 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010074 return -EINVAL;
10075 }
10076
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010077 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10078 {
10079 dump_bssid(pRoamInfo->bssid);
10080 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010081 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010082 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010083#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010084 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010085}
10086#endif //FEATURE_WLAN_LFR
10087
Yue Maef608272013-04-08 23:09:17 -070010088#ifdef FEATURE_WLAN_LFR_METRICS
10089/*
10090 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10091 * 802.11r/LFR metrics reporting function to report preauth initiation
10092 *
10093 */
10094#define MAX_LFR_METRICS_EVENT_LENGTH 100
10095VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10096 tCsrRoamInfo *pRoamInfo)
10097{
10098 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10099 union iwreq_data wrqu;
10100
10101 ENTER();
10102
10103 if (NULL == pAdapter)
10104 {
10105 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10106 return VOS_STATUS_E_FAILURE;
10107 }
10108
10109 /* create the event */
10110 memset(&wrqu, 0, sizeof(wrqu));
10111 memset(metrics_notification, 0, sizeof(metrics_notification));
10112
10113 wrqu.data.pointer = metrics_notification;
10114 wrqu.data.length = scnprintf(metrics_notification,
10115 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10116 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10117
10118 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10119
10120 EXIT();
10121
10122 return VOS_STATUS_SUCCESS;
10123}
10124
10125/*
10126 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10127 * 802.11r/LFR metrics reporting function to report preauth completion
10128 * or failure
10129 */
10130VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10131 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10132{
10133 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10134 union iwreq_data wrqu;
10135
10136 ENTER();
10137
10138 if (NULL == pAdapter)
10139 {
10140 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10141 return VOS_STATUS_E_FAILURE;
10142 }
10143
10144 /* create the event */
10145 memset(&wrqu, 0, sizeof(wrqu));
10146 memset(metrics_notification, 0, sizeof(metrics_notification));
10147
10148 scnprintf(metrics_notification, sizeof(metrics_notification),
10149 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10150 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10151
10152 if (1 == preauth_status)
10153 strncat(metrics_notification, " TRUE", 5);
10154 else
10155 strncat(metrics_notification, " FALSE", 6);
10156
10157 wrqu.data.pointer = metrics_notification;
10158 wrqu.data.length = strlen(metrics_notification);
10159
10160 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10161
10162 EXIT();
10163
10164 return VOS_STATUS_SUCCESS;
10165}
10166
10167/*
10168 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10169 * 802.11r/LFR metrics reporting function to report handover initiation
10170 *
10171 */
10172VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10173 tCsrRoamInfo *pRoamInfo)
10174{
10175 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10176 union iwreq_data wrqu;
10177
10178 ENTER();
10179
10180 if (NULL == pAdapter)
10181 {
10182 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10183 return VOS_STATUS_E_FAILURE;
10184 }
10185
10186 /* create the event */
10187 memset(&wrqu, 0, sizeof(wrqu));
10188 memset(metrics_notification, 0, sizeof(metrics_notification));
10189
10190 wrqu.data.pointer = metrics_notification;
10191 wrqu.data.length = scnprintf(metrics_notification,
10192 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10193 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10194
10195 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10196
10197 EXIT();
10198
10199 return VOS_STATUS_SUCCESS;
10200}
10201#endif
10202
Jeff Johnson295189b2012-06-20 16:38:30 -070010203/*
10204 * FUNCTION: hdd_cfg80211_scan_done_callback
10205 * scanning callback function, called after finishing scan
10206 *
10207 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010208static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10210{
10211 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010212 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010214 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 struct cfg80211_scan_request *req = NULL;
10216 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010217 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010218 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010219 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010220 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010221
10222 ENTER();
10223
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10225 if (0 != wlan_hdd_validate_context(pHddCtx)) {
10226 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
10227 goto allow_suspend;
10228 }
10229
10230 pScanInfo = &pHddCtx->scan_info;
10231
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 hddLog(VOS_TRACE_LEVEL_INFO,
10233 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010234 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 __func__, halHandle, pContext, (int) scanId, (int) status);
10236
Kiet Lamac06e2c2013-10-23 16:25:07 +053010237 pScanInfo->mScanPendingCounter = 0;
10238
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010240 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 &pScanInfo->scan_req_completion_event,
10242 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010243 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010245 hddLog(VOS_TRACE_LEVEL_ERROR,
10246 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010248 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 }
10250
Yue Maef608272013-04-08 23:09:17 -070010251 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 {
10253 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010254 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 }
10256
10257 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010258 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 {
10260 hddLog(VOS_TRACE_LEVEL_INFO,
10261 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010262 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010263 (int) scanId);
10264 }
10265
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010266 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 pAdapter);
10268
10269 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010270 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010271
10272
10273 /* If any client wait scan result through WEXT
10274 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010275 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 {
10277 /* The other scan request waiting for current scan finish
10278 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010279 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010280 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010281 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 }
10283 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010284 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 {
10286 struct net_device *dev = pAdapter->dev;
10287 union iwreq_data wrqu;
10288 int we_event;
10289 char *msg;
10290
10291 memset(&wrqu, '\0', sizeof(wrqu));
10292 we_event = SIOCGIWSCAN;
10293 msg = NULL;
10294 wireless_send_event(dev, we_event, &wrqu, msg);
10295 }
10296 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010297 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298
10299 /* Get the Scan Req */
10300 req = pAdapter->request;
10301
10302 if (!req)
10303 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010304 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010305 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010306 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 }
10308
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010310 /* Scan is no longer pending */
10311 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010312
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010313 /* last_scan_timestamp is used to decide if new scan
10314 * is needed or not on station interface. If last station
10315 * scan time and new station scan time is less then
10316 * last_scan_timestamp ; driver will return cached scan.
10317 */
10318 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10319 {
10320 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10321
10322 if ( req->n_channels )
10323 {
10324 for (i = 0; i < req->n_channels ; i++ )
10325 {
10326 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10327 }
10328 /* store no of channel scanned */
10329 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10330 }
10331
10332 }
10333
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010334 /*
10335 * cfg80211_scan_done informing NL80211 about completion
10336 * of scanning
10337 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010338 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10339 {
10340 aborted = true;
10341 }
10342 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010343 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010344
Siddharth Bhal76972212014-10-15 16:22:51 +053010345 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10346 /* Generate new random mac addr for next scan */
10347 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10348 hdd_processSpoofMacAddrRequest(pHddCtx);
10349 }
10350
Jeff Johnsone7245742012-09-05 17:12:55 -070010351allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010352 /* release the wake lock at the end of the scan*/
10353 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010354
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010355 /* Acquire wakelock to handle the case where APP's tries to suspend
10356 * immediatly after the driver gets connect request(i.e after scan)
10357 * from supplicant, this result in app's is suspending and not able
10358 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010359 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010360
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010361#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010362 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010363#endif
10364
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 EXIT();
10366 return 0;
10367}
10368
10369/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010370 * FUNCTION: hdd_isConnectionInProgress
10371 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010372 *
10373 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010374v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010375{
10376 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10377 hdd_station_ctx_t *pHddStaCtx = NULL;
10378 hdd_adapter_t *pAdapter = NULL;
10379 VOS_STATUS status = 0;
10380 v_U8_t staId = 0;
10381 v_U8_t *staMac = NULL;
10382
c_hpothu9b781ba2013-12-30 20:57:45 +053010383 if (TRUE == pHddCtx->btCoexModeSet)
10384 {
10385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010386 FL("BTCoex Mode operation in progress"));
10387 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010388 }
10389
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010390 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10391
10392 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10393 {
10394 pAdapter = pAdapterNode->pAdapter;
10395
10396 if( pAdapter )
10397 {
10398 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010399 "%s: Adapter with device mode %s (%d) exists",
10400 __func__, hdd_device_modetoString(pAdapter->device_mode),
10401 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010402 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010403 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10404 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10405 (eConnectionState_Connecting ==
10406 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10407 {
10408 hddLog(VOS_TRACE_LEVEL_ERROR,
10409 "%s: %p(%d) Connection is in progress", __func__,
10410 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10411 return VOS_TRUE;
10412 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010413 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010414 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010415 {
10416 hddLog(VOS_TRACE_LEVEL_ERROR,
10417 "%s: %p(%d) Reassociation is in progress", __func__,
10418 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10419 return VOS_TRUE;
10420 }
10421 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010422 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10423 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010424 {
10425 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10426 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010427 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010428 {
10429 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10430 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010431 "%s: client " MAC_ADDRESS_STR
10432 " is in the middle of WPS/EAPOL exchange.", __func__,
10433 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010434 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010435 }
10436 }
10437 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10438 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10439 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010440 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10441 ptSapContext pSapCtx = NULL;
10442 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10443 if(pSapCtx == NULL){
10444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10445 FL("psapCtx is NULL"));
10446 return VOS_FALSE;
10447 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010448 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10449 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010450 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10451 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010452 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010453 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010454
10455 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010456 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10457 "middle of WPS/EAPOL exchange.", __func__,
10458 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010459 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010460 }
10461 }
10462 }
10463 }
10464 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10465 pAdapterNode = pNext;
10466 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010467 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010468}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010469
10470/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010471 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 * this scan respond to scan trigger and update cfg80211 scan database
10473 * later, scan dump command can be used to recieve scan results
10474 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010475int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010476#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10477 struct net_device *dev,
10478#endif
10479 struct cfg80211_scan_request *request)
10480{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010481 hdd_adapter_t *pAdapter = NULL;
10482 hdd_context_t *pHddCtx = NULL;
10483 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010484 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010485 tCsrScanRequest scanRequest;
10486 tANI_U8 *channelList = NULL, i;
10487 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010488 int status;
10489 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010491 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010492
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010493#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10494 struct net_device *dev = NULL;
10495 if (NULL == request)
10496 {
10497 hddLog(VOS_TRACE_LEVEL_ERROR,
10498 "%s: scan req param null", __func__);
10499 return -EINVAL;
10500 }
10501 dev = request->wdev->netdev;
10502#endif
10503
10504 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10505 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10506 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10507
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 ENTER();
10509
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010510 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10511 __func__, hdd_device_modetoString(pAdapter->device_mode),
10512 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010513
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010514 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010515 if (0 != status)
10516 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010517 return status;
10518 }
10519
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010520 if (NULL == pwextBuf)
10521 {
10522 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10523 __func__);
10524 return -EIO;
10525 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010526 cfg_param = pHddCtx->cfg_ini;
10527 pScanInfo = &pHddCtx->scan_info;
10528
Jeff Johnson295189b2012-06-20 16:38:30 -070010529#ifdef WLAN_BTAMP_FEATURE
10530 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010531 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010533 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 "%s: No scanning when AMP is on", __func__);
10535 return -EOPNOTSUPP;
10536 }
10537#endif
10538 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010539 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010541 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010542 "%s: Not scanning on device_mode = %s (%d)",
10543 __func__, hdd_device_modetoString(pAdapter->device_mode),
10544 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010545 return -EOPNOTSUPP;
10546 }
10547
10548 if (TRUE == pScanInfo->mScanPending)
10549 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010550 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10551 {
10552 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10553 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010554 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 }
10556
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010557 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010558 //Channel and action frame is pending
10559 //Otherwise Cancel Remain On Channel and allow Scan
10560 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010561 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010562 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010564 return -EBUSY;
10565 }
10566
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10568 {
10569 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010570 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10574 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010575 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 "%s: MAX TM Level Scan not allowed", __func__);
10577 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010578 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010579 }
10580 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10581
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010582 /* Check if scan is allowed at this point of time.
10583 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010584 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010585 {
10586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10587 return -EBUSY;
10588 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010589
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10591
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010592 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10593 (int)request->n_ssids);
10594
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010595
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010596 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10597 * Becasue of this, driver is assuming that this is not wildcard scan and so
10598 * is not aging out the scan results.
10599 */
10600 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010602 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010604
10605 if ((request->ssids) && (0 < request->n_ssids))
10606 {
10607 tCsrSSIDInfo *SsidInfo;
10608 int j;
10609 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10610 /* Allocate num_ssid tCsrSSIDInfo structure */
10611 SsidInfo = scanRequest.SSIDs.SSIDList =
10612 ( tCsrSSIDInfo *)vos_mem_malloc(
10613 request->n_ssids*sizeof(tCsrSSIDInfo));
10614
10615 if(NULL == scanRequest.SSIDs.SSIDList)
10616 {
10617 hddLog(VOS_TRACE_LEVEL_ERROR,
10618 "%s: memory alloc failed SSIDInfo buffer", __func__);
10619 return -ENOMEM;
10620 }
10621
10622 /* copy all the ssid's and their length */
10623 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10624 {
10625 /* get the ssid length */
10626 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10627 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10628 SsidInfo->SSID.length);
10629 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10630 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10631 j, SsidInfo->SSID.ssId);
10632 }
10633 /* set the scan type to active */
10634 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10635 }
10636 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010638 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10639 TRACE_CODE_HDD_CFG80211_SCAN,
10640 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 /* set the scan type to active */
10642 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010643 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010644 else
10645 {
10646 /*Set the scan type to default type, in this case it is ACTIVE*/
10647 scanRequest.scanType = pScanInfo->scan_mode;
10648 }
10649 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10650 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010651
10652 /* set BSSType to default type */
10653 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10654
10655 /*TODO: scan the requested channels only*/
10656
10657 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010658 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010660 hddLog(VOS_TRACE_LEVEL_WARN,
10661 "No of Scan Channels exceeded limit: %d", request->n_channels);
10662 request->n_channels = MAX_CHANNEL;
10663 }
10664
10665 hddLog(VOS_TRACE_LEVEL_INFO,
10666 "No of Scan Channels: %d", request->n_channels);
10667
10668
10669 if( request->n_channels )
10670 {
10671 char chList [(request->n_channels*5)+1];
10672 int len;
10673 channelList = vos_mem_malloc( request->n_channels );
10674 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010675 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010676 hddLog(VOS_TRACE_LEVEL_ERROR,
10677 "%s: memory alloc failed channelList", __func__);
10678 status = -ENOMEM;
10679 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010680 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010681
10682 for( i = 0, len = 0; i < request->n_channels ; i++ )
10683 {
10684 channelList[i] = request->channels[i]->hw_value;
10685 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10686 }
10687
Nirav Shah20ac06f2013-12-12 18:14:06 +053010688 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010689 "Channel-List: %s ", chList);
10690 }
c_hpothu53512302014-04-15 18:49:53 +053010691
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010692 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10693 scanRequest.ChannelInfo.ChannelList = channelList;
10694
10695 /* set requestType to full scan */
10696 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10697
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010698 /* if there is back to back scan happening in driver with in
10699 * nDeferScanTimeInterval interval driver should defer new scan request
10700 * and should provide last cached scan results instead of new channel list.
10701 * This rule is not applicable if scan is p2p scan.
10702 * This condition will work only in case when last request no of channels
10703 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010704 * This should be done only in connected state
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010705 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010706
Agarwal Ashish57e84372014-12-05 18:26:53 +053010707 if ((VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
10708 {
10709 if ( pScanInfo->last_scan_timestamp !=0 &&
10710 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10711 {
10712 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10713 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10714 vos_mem_compare(pScanInfo->last_scan_channelList,
10715 channelList, pScanInfo->last_scan_numChannels))
10716 {
10717 hddLog(VOS_TRACE_LEVEL_WARN,
10718 " New and old station scan time differ is less then %u",
10719 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10720
10721 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010722 pAdapter);
10723
Agarwal Ashish57e84372014-12-05 18:26:53 +053010724 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010725 "Return old cached scan as all channels and no of channels are same");
10726
Agarwal Ashish57e84372014-12-05 18:26:53 +053010727 if (0 > ret)
10728 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010729
Agarwal Ashish57e84372014-12-05 18:26:53 +053010730 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010731
10732 status = eHAL_STATUS_SUCCESS;
10733 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010734 }
10735 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010736 }
10737
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010738 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10739 * search (Flush on both full scan and social scan but not on single
10740 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10741 */
10742
10743 /* Supplicant does single channel scan after 8-way handshake
10744 * and in that case driver shoudnt flush scan results. If
10745 * driver flushes the scan results here and unfortunately if
10746 * the AP doesnt respond to our probe req then association
10747 * fails which is not desired
10748 */
10749
10750 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
10751 {
10752 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10753 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10754 pAdapter->sessionId );
10755 }
10756
10757 if( request->ie_len )
10758 {
10759 /* save this for future association (join requires this) */
10760 /*TODO: Array needs to be converted to dynamic allocation,
10761 * as multiple ie.s can be sent in cfg80211_scan_request structure
10762 * CR 597966
10763 */
10764 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10765 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10766 pScanInfo->scanAddIE.length = request->ie_len;
10767
10768 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10769 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10770 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010772 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010774 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10775 memcpy( pwextBuf->roamProfile.addIEScan,
10776 request->ie, request->ie_len);
10777 }
10778 else
10779 {
10780 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10781 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010782 }
10783
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010784 }
10785 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10786 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10787
10788 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10789 request->ie_len);
10790 if (pP2pIe != NULL)
10791 {
10792#ifdef WLAN_FEATURE_P2P_DEBUG
10793 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10794 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10795 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010796 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010797 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10798 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10799 "Go nego completed to Connection is started");
10800 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10801 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010802 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010803 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10804 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010805 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010806 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10807 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10808 "Disconnected state to Connection is started");
10809 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10810 "for 4way Handshake");
10811 }
10812#endif
10813
10814 /* no_cck will be set during p2p find to disable 11b rates */
10815 if(TRUE == request->no_cck)
10816 {
10817 hddLog(VOS_TRACE_LEVEL_INFO,
10818 "%s: This is a P2P Search", __func__);
10819 scanRequest.p2pSearch = 1;
10820
10821 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010822 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010823 /* set requestType to P2P Discovery */
10824 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10825 }
10826
10827 /*
10828 Skip Dfs Channel in case of P2P Search
10829 if it is set in ini file
10830 */
10831 if(cfg_param->skipDfsChnlInP2pSearch)
10832 {
10833 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010834 }
10835 else
10836 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010837 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010839
Agarwal Ashish4f616132013-12-30 23:32:50 +053010840 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010841 }
10842 }
10843
10844 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10845
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010846#ifdef FEATURE_WLAN_TDLS
10847 /* if tdls disagree scan right now, return immediately.
10848 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10849 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10850 */
10851 status = wlan_hdd_tdls_scan_callback (pAdapter,
10852 wiphy,
10853#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10854 dev,
10855#endif
10856 request);
10857 if(status <= 0)
10858 {
10859 if(!status)
10860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10861 "scan rejected %d", __func__, status);
10862 else
10863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10864 __func__, status);
10865
10866 return status;
10867 }
10868#endif
10869
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010870 /* acquire the wakelock to avoid the apps suspend during the scan. To
10871 * address the following issues.
10872 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10873 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10874 * for long time, this result in apps running at full power for long time.
10875 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
10876 * be stuck in full power because of resume BMPS
10877 */
10878 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010879
Nirav Shah20ac06f2013-12-12 18:14:06 +053010880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10881 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010882 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10883 scanRequest.requestType, scanRequest.scanType,
10884 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010885 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10886
Siddharth Bhal76972212014-10-15 16:22:51 +053010887 if (pHddCtx->spoofMacAddr.isEnabled)
10888 {
10889 hddLog(VOS_TRACE_LEVEL_INFO,
10890 "%s: MAC Spoofing enabled for current scan", __func__);
10891 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10892 * to fill TxBds for probe request during current scan
10893 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010894 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053010895 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010896
10897 if(status != VOS_STATUS_SUCCESS)
10898 {
10899 hdd_allow_suspend();
10900 status = -EFAULT;
10901 goto free_mem;
10902 }
Siddharth Bhal76972212014-10-15 16:22:51 +053010903 }
10904
Jeff Johnsone7245742012-09-05 17:12:55 -070010905 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010906 pAdapter->sessionId, &scanRequest, &scanId,
10907 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010908
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 if (eHAL_STATUS_SUCCESS != status)
10910 {
10911 hddLog(VOS_TRACE_LEVEL_ERROR,
10912 "%s: sme_ScanRequest returned error %d", __func__, status);
10913 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010914 if(eHAL_STATUS_RESOURCES == status)
10915 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10917 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010918 status = -EBUSY;
10919 } else {
10920 status = -EIO;
10921 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010922 hdd_allow_suspend();
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010923
10924#ifdef FEATURE_WLAN_TDLS
10925 wlan_hdd_tdls_scan_done_callback(pAdapter);
10926#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 goto free_mem;
10928 }
10929
10930 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010931 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010932 pAdapter->request = request;
10933 pScanInfo->scanId = scanId;
10934
10935 complete(&pScanInfo->scan_req_completion_event);
10936
10937free_mem:
10938 if( scanRequest.SSIDs.SSIDList )
10939 {
10940 vos_mem_free(scanRequest.SSIDs.SSIDList);
10941 }
10942
10943 if( channelList )
10944 vos_mem_free( channelList );
10945
10946 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 return status;
10948}
10949
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010950int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10951#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10952 struct net_device *dev,
10953#endif
10954 struct cfg80211_scan_request *request)
10955{
10956 int ret;
10957
10958 vos_ssr_protect(__func__);
10959 ret = __wlan_hdd_cfg80211_scan(wiphy,
10960#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10961 dev,
10962#endif
10963 request);
10964 vos_ssr_unprotect(__func__);
10965
10966 return ret;
10967}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010968
10969void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
10970{
10971 v_U8_t iniDot11Mode =
10972 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
10973 eHddDot11Mode hddDot11Mode = iniDot11Mode;
10974
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010975 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
10976 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010977 switch ( iniDot11Mode )
10978 {
10979 case eHDD_DOT11_MODE_AUTO:
10980 case eHDD_DOT11_MODE_11ac:
10981 case eHDD_DOT11_MODE_11ac_ONLY:
10982#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053010983 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
10984 sme_IsFeatureSupportedByFW(DOT11AC) )
10985 hddDot11Mode = eHDD_DOT11_MODE_11ac;
10986 else
10987 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010988#else
10989 hddDot11Mode = eHDD_DOT11_MODE_11n;
10990#endif
10991 break;
10992 case eHDD_DOT11_MODE_11n:
10993 case eHDD_DOT11_MODE_11n_ONLY:
10994 hddDot11Mode = eHDD_DOT11_MODE_11n;
10995 break;
10996 default:
10997 hddDot11Mode = iniDot11Mode;
10998 break;
10999 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011000#ifdef WLAN_FEATURE_AP_HT40_24G
11001 if (operationChannel > SIR_11B_CHANNEL_END)
11002#endif
11003 {
11004 /* This call decides required channel bonding mode */
11005 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011006 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11007 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011008 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011009}
11010
Jeff Johnson295189b2012-06-20 16:38:30 -070011011/*
11012 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011013 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011015int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011016 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011017{
11018 int status = 0;
11019 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011020 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 v_U32_t roamId;
11022 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 eCsrAuthType RSNAuthType;
11024
11025 ENTER();
11026
11027 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011028 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11029
11030 status = wlan_hdd_validate_context(pHddCtx);
11031 if (status)
11032 {
Yue Mae36e3552014-03-05 17:06:20 -080011033 return status;
11034 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011035
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11037 {
11038 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11039 return -EINVAL;
11040 }
11041
11042 pRoamProfile = &pWextState->roamProfile;
11043
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011044 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011046 hdd_station_ctx_t *pHddStaCtx;
11047 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011048
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011049 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011050 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11051 {
11052 /*QoS not enabled in cfg file*/
11053 pRoamProfile->uapsd_mask = 0;
11054 }
11055 else
11056 {
11057 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011058 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011059 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11060 }
11061
11062 pRoamProfile->SSIDs.numOfSSIDs = 1;
11063 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11064 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011065 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11067 ssid, ssid_len);
11068
11069 if (bssid)
11070 {
11071 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11072 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11073 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011074 /* Save BSSID in seperate variable as well, as RoamProfile
11075 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 case of join failure we should send valid BSSID to supplicant
11077 */
11078 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11079 WNI_CFG_BSSID_LEN);
11080 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011081 else
11082 {
11083 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011085
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011086 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11087 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011088 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11089 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011090 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 /*set gen ie*/
11092 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11093 /*set auth*/
11094 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011096#ifdef FEATURE_WLAN_WAPI
11097 if (pAdapter->wapi_info.nWapiMode)
11098 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011099 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 switch (pAdapter->wapi_info.wapiAuthMode)
11101 {
11102 case WAPI_AUTH_MODE_PSK:
11103 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011104 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 pAdapter->wapi_info.wapiAuthMode);
11106 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11107 break;
11108 }
11109 case WAPI_AUTH_MODE_CERT:
11110 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011111 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011112 pAdapter->wapi_info.wapiAuthMode);
11113 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11114 break;
11115 }
11116 } // End of switch
11117 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11118 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11119 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011120 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011121 pRoamProfile->AuthType.numEntries = 1;
11122 pRoamProfile->EncryptionType.numEntries = 1;
11123 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11124 pRoamProfile->mcEncryptionType.numEntries = 1;
11125 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11126 }
11127 }
11128#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011129#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011130 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011131 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11132 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11133 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011134 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11135 sizeof (tSirGtkOffloadParams));
11136 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011137 }
11138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 pRoamProfile->csrPersona = pAdapter->device_mode;
11140
Jeff Johnson32d95a32012-09-10 13:15:23 -070011141 if( operatingChannel )
11142 {
11143 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11144 pRoamProfile->ChannelInfo.numOfChannels = 1;
11145 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011146 else
11147 {
11148 pRoamProfile->ChannelInfo.ChannelList = NULL;
11149 pRoamProfile->ChannelInfo.numOfChannels = 0;
11150 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011151 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11152 {
11153 hdd_select_cbmode(pAdapter,operatingChannel);
11154 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011155
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011156 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11157 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011158 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011159 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011160 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11161 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011162 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11163 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011164 {
11165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11166 "%s: Set HDD connState to eConnectionState_Connecting",
11167 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011168 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11169 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011170 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011171 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 pAdapter->sessionId, pRoamProfile, &roamId);
11173
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011174 if ((eHAL_STATUS_SUCCESS != status) &&
11175 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11176 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011177
11178 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11180 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11181 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011182 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011183 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011184 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011185
11186 pRoamProfile->ChannelInfo.ChannelList = NULL;
11187 pRoamProfile->ChannelInfo.numOfChannels = 0;
11188
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 }
11190 else
11191 {
11192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11193 return -EINVAL;
11194 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011195 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 return status;
11197}
11198
11199/*
11200 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11201 * This function is used to set the authentication type (OPEN/SHARED).
11202 *
11203 */
11204static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11205 enum nl80211_auth_type auth_type)
11206{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011207 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11209
11210 ENTER();
11211
11212 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011213 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011215 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011216 hddLog(VOS_TRACE_LEVEL_INFO,
11217 "%s: set authentication type to AUTOSWITCH", __func__);
11218 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11219 break;
11220
11221 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011222#ifdef WLAN_FEATURE_VOWIFI_11R
11223 case NL80211_AUTHTYPE_FT:
11224#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011225 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 "%s: set authentication type to OPEN", __func__);
11227 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11228 break;
11229
11230 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011231 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 "%s: set authentication type to SHARED", __func__);
11233 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11234 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011235#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011237 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 "%s: set authentication type to CCKM WPA", __func__);
11239 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11240 break;
11241#endif
11242
11243
11244 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011245 hddLog(VOS_TRACE_LEVEL_ERROR,
11246 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011247 auth_type);
11248 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11249 return -EINVAL;
11250 }
11251
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011252 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011253 pHddStaCtx->conn_info.authType;
11254 return 0;
11255}
11256
11257/*
11258 * FUNCTION: wlan_hdd_set_akm_suite
11259 * This function is used to set the key mgmt type(PSK/8021x).
11260 *
11261 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011262static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011263 u32 key_mgmt
11264 )
11265{
11266 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11267 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011268 /* Should be in ieee802_11_defs.h */
11269#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11270#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 /*set key mgmt type*/
11272 switch(key_mgmt)
11273 {
11274 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011275 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011276#ifdef WLAN_FEATURE_VOWIFI_11R
11277 case WLAN_AKM_SUITE_FT_PSK:
11278#endif
11279 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011280 __func__);
11281 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11282 break;
11283
11284 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011285 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011286#ifdef WLAN_FEATURE_VOWIFI_11R
11287 case WLAN_AKM_SUITE_FT_8021X:
11288#endif
11289 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011290 __func__);
11291 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11292 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011293#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011294#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11295#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11296 case WLAN_AKM_SUITE_CCKM:
11297 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11298 __func__);
11299 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11300 break;
11301#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011302#ifndef WLAN_AKM_SUITE_OSEN
11303#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11304 case WLAN_AKM_SUITE_OSEN:
11305 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11306 __func__);
11307 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11308 break;
11309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011310
11311 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011312 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 __func__, key_mgmt);
11314 return -EINVAL;
11315
11316 }
11317 return 0;
11318}
11319
11320/*
11321 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011322 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 * (NONE/WEP40/WEP104/TKIP/CCMP).
11324 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011325static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11326 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011327 bool ucast
11328 )
11329{
11330 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011331 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11333
11334 ENTER();
11335
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011336 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011337 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011338 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011339 __func__, cipher);
11340 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11341 }
11342 else
11343 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011344
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011346 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 {
11348 case IW_AUTH_CIPHER_NONE:
11349 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11350 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011351
Jeff Johnson295189b2012-06-20 16:38:30 -070011352 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011353 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011355
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011357 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011359
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 case WLAN_CIPHER_SUITE_TKIP:
11361 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11362 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011363
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 case WLAN_CIPHER_SUITE_CCMP:
11365 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11366 break;
11367#ifdef FEATURE_WLAN_WAPI
11368 case WLAN_CIPHER_SUITE_SMS4:
11369 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11370 break;
11371#endif
11372
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011373#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 case WLAN_CIPHER_SUITE_KRK:
11375 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11376 break;
11377#endif
11378 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011380 __func__, cipher);
11381 return -EOPNOTSUPP;
11382 }
11383 }
11384
11385 if (ucast)
11386 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011387 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 __func__, encryptionType);
11389 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11390 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011391 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 encryptionType;
11393 }
11394 else
11395 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011396 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 __func__, encryptionType);
11398 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11399 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11400 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11401 }
11402
11403 return 0;
11404}
11405
11406
11407/*
11408 * FUNCTION: wlan_hdd_cfg80211_set_ie
11409 * This function is used to parse WPA/RSN IE's.
11410 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011411int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11412 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011413 size_t ie_len
11414 )
11415{
11416 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11417 u8 *genie = ie;
11418 v_U16_t remLen = ie_len;
11419#ifdef FEATURE_WLAN_WAPI
11420 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11421 u16 *tmp;
11422 v_U16_t akmsuiteCount;
11423 int *akmlist;
11424#endif
11425 ENTER();
11426
11427 /* clear previous assocAddIE */
11428 pWextState->assocAddIE.length = 0;
11429 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011430 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011431
11432 while (remLen >= 2)
11433 {
11434 v_U16_t eLen = 0;
11435 v_U8_t elementId;
11436 elementId = *genie++;
11437 eLen = *genie++;
11438 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011439
Arif Hussain6d2a3322013-11-17 19:50:10 -080011440 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011441 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011442
11443 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011445 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011446 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 -070011447 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011448 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 "%s: Invalid WPA IE", __func__);
11450 return -EINVAL;
11451 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011452 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 {
11454 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011455 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011457
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011458 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011460 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11461 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 VOS_ASSERT(0);
11463 return -ENOMEM;
11464 }
11465 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11466 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11467 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011468
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11470 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11471 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11472 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011473 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11474 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11476 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11477 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11478 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11479 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11480 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011481 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011482 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 {
11484 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011485 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011487
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011488 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011490 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11491 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 VOS_ASSERT(0);
11493 return -ENOMEM;
11494 }
11495 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11496 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11497 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11500 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011502#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011503 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11504 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011505 /*Consider WFD IE, only for P2P Client */
11506 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11507 {
11508 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011509 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011510 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011511
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011512 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011513 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011514 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11515 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 VOS_ASSERT(0);
11517 return -ENOMEM;
11518 }
11519 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11520 // WPS IE + P2P IE + WFD IE
11521 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11522 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011523
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11525 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11526 }
11527#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011528 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011529 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011530 HS20_OUI_TYPE_SIZE)) )
11531 {
11532 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011533 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011534 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011535
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011536 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011537 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011538 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11539 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011540 VOS_ASSERT(0);
11541 return -ENOMEM;
11542 }
11543 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11544 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011545
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011546 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11547 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11548 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011549 /* Appending OSEN Information Element in Assiciation Request */
11550 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11551 OSEN_OUI_TYPE_SIZE)) )
11552 {
11553 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11554 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11555 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011556
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011557 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011558 {
11559 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11560 "Need bigger buffer space");
11561 VOS_ASSERT(0);
11562 return -ENOMEM;
11563 }
11564 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11565 pWextState->assocAddIE.length += eLen + 2;
11566
11567 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11568 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11569 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11570 }
11571
11572 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011573 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
11574
11575 /* populating as ADDIE in beacon frames */
11576 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11577 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11578 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11579 {
11580 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11581 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11582 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11583 {
11584 hddLog(LOGE,
11585 "Coldn't pass "
11586 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11587 }
11588 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11589 else
11590 hddLog(LOGE,
11591 "Could not pass on "
11592 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11593
11594 /* IBSS mode doesn't contain params->proberesp_ies still
11595 beaconIE's need to be populated in probe response frames */
11596 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11597 {
11598 u16 rem_probe_resp_ie_len = eLen + 2;
11599 u8 probe_rsp_ie_len[3] = {0};
11600 u8 counter = 0;
11601
11602 /* Check Probe Resp Length if it is greater then 255 then
11603 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11604 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11605 not able Store More then 255 bytes into One Variable */
11606
11607 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11608 {
11609 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11610 {
11611 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11612 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11613 }
11614 else
11615 {
11616 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11617 rem_probe_resp_ie_len = 0;
11618 }
11619 }
11620
11621 rem_probe_resp_ie_len = 0;
11622
11623 if (probe_rsp_ie_len[0] > 0)
11624 {
11625 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11626 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11627 (tANI_U8*)(genie - 2),
11628 probe_rsp_ie_len[0], NULL,
11629 eANI_BOOLEAN_FALSE)
11630 == eHAL_STATUS_FAILURE)
11631 {
11632 hddLog(LOGE,
11633 "Could not pass"
11634 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11635 }
11636 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11637 }
11638
11639 if (probe_rsp_ie_len[1] > 0)
11640 {
11641 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11642 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11643 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11644 probe_rsp_ie_len[1], NULL,
11645 eANI_BOOLEAN_FALSE)
11646 == eHAL_STATUS_FAILURE)
11647 {
11648 hddLog(LOGE,
11649 "Could not pass"
11650 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11651 }
11652 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11653 }
11654
11655 if (probe_rsp_ie_len[2] > 0)
11656 {
11657 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11658 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11659 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11660 probe_rsp_ie_len[2], NULL,
11661 eANI_BOOLEAN_FALSE)
11662 == eHAL_STATUS_FAILURE)
11663 {
11664 hddLog(LOGE,
11665 "Could not pass"
11666 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11667 }
11668 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11669 }
11670
11671 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11672 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11673 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11674 {
11675 hddLog(LOGE,
11676 "Could not pass"
11677 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11678 }
11679 }
11680 else
11681 {
11682 // Reset WNI_CFG_PROBE_RSP Flags
11683 wlan_hdd_reset_prob_rspies(pAdapter);
11684
11685 hddLog(VOS_TRACE_LEVEL_INFO,
11686 "%s: No Probe Response IE received in set beacon",
11687 __func__);
11688 }
11689 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 break;
11691 case DOT11F_EID_RSN:
11692 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11693 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11694 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11695 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11696 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11697 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011698
11699 /* Appending Extended Capabilities with Interworking bit set
11700 * in Assoc Req.
11701 *
11702 * In assoc req this EXT Cap will only be taken into account if
11703 * interworkingService bit is set to 1. Currently
11704 * driver is only interested in interworkingService capability
11705 * from supplicant. If in future any other EXT Cap info is
11706 * required from supplicat, it needs to be handled while
11707 * sending Assoc Req in LIM.
11708 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011709 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011710 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011711 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011712 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011713 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011714
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011715 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011716 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011717 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11718 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011719 VOS_ASSERT(0);
11720 return -ENOMEM;
11721 }
11722 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11723 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011724
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011725 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11726 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11727 break;
11728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011729#ifdef FEATURE_WLAN_WAPI
11730 case WLAN_EID_WAPI:
11731 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011732 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 pAdapter->wapi_info.nWapiMode);
11734 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011735 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 akmsuiteCount = WPA_GET_LE16(tmp);
11737 tmp = tmp + 1;
11738 akmlist = (int *)(tmp);
11739 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11740 {
11741 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11742 }
11743 else
11744 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011745 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 VOS_ASSERT(0);
11747 return -EINVAL;
11748 }
11749
11750 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11751 {
11752 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011753 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011755 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011757 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011759 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11761 }
11762 break;
11763#endif
11764 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011765 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011767 /* when Unknown IE is received we should break and continue
11768 * to the next IE in the buffer instead we were returning
11769 * so changing this to break */
11770 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 }
11772 genie += eLen;
11773 remLen -= eLen;
11774 }
11775 EXIT();
11776 return 0;
11777}
11778
11779/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011780 * FUNCTION: hdd_isWPAIEPresent
11781 * Parse the received IE to find the WPA IE
11782 *
11783 */
11784static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11785{
11786 v_U8_t eLen = 0;
11787 v_U16_t remLen = ie_len;
11788 v_U8_t elementId = 0;
11789
11790 while (remLen >= 2)
11791 {
11792 elementId = *ie++;
11793 eLen = *ie++;
11794 remLen -= 2;
11795 if (eLen > remLen)
11796 {
11797 hddLog(VOS_TRACE_LEVEL_ERROR,
11798 "%s: IE length is wrong %d", __func__, eLen);
11799 return FALSE;
11800 }
11801 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11802 {
11803 /* OUI - 0x00 0X50 0XF2
11804 WPA Information Element - 0x01
11805 WPA version - 0x01*/
11806 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11807 return TRUE;
11808 }
11809 ie += eLen;
11810 remLen -= eLen;
11811 }
11812 return FALSE;
11813}
11814
11815/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011817 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 * parameters during connect operation.
11819 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011820int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 struct cfg80211_connect_params *req
11822 )
11823{
11824 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011825 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 ENTER();
11827
11828 /*set wpa version*/
11829 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11830
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011831 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011833 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 {
11835 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11836 }
11837 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11838 {
11839 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11840 }
11841 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842
11843 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 pWextState->wpaVersion);
11845
11846 /*set authentication type*/
11847 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11848
11849 if (0 > status)
11850 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011851 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 "%s: failed to set authentication type ", __func__);
11853 return status;
11854 }
11855
11856 /*set key mgmt type*/
11857 if (req->crypto.n_akm_suites)
11858 {
11859 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11860 if (0 > status)
11861 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011862 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 __func__);
11864 return status;
11865 }
11866 }
11867
11868 /*set pairwise cipher type*/
11869 if (req->crypto.n_ciphers_pairwise)
11870 {
11871 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
11872 req->crypto.ciphers_pairwise[0], true);
11873 if (0 > status)
11874 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011875 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011876 "%s: failed to set unicast cipher type", __func__);
11877 return status;
11878 }
11879 }
11880 else
11881 {
11882 /*Reset previous cipher suite to none*/
11883 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
11884 if (0 > status)
11885 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011886 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 "%s: failed to set unicast cipher type", __func__);
11888 return status;
11889 }
11890 }
11891
11892 /*set group cipher type*/
11893 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
11894 false);
11895
11896 if (0 > status)
11897 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011898 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 __func__);
11900 return status;
11901 }
11902
Chet Lanctot186b5732013-03-18 10:26:30 -070011903#ifdef WLAN_FEATURE_11W
11904 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11905#endif
11906
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11908 if (req->ie_len)
11909 {
11910 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11911 if ( 0 > status)
11912 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 __func__);
11915 return status;
11916 }
11917 }
11918
11919 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011920 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 {
11922 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11923 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11924 )
11925 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011926 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11928 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011929 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 __func__);
11931 return -EOPNOTSUPP;
11932 }
11933 else
11934 {
11935 u8 key_len = req->key_len;
11936 u8 key_idx = req->key_idx;
11937
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011938 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 && (CSR_MAX_NUM_KEY > key_idx)
11940 )
11941 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011942 hddLog(VOS_TRACE_LEVEL_INFO,
11943 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 __func__, key_idx, key_len);
11945 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011946 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011948 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 (u8)key_len;
11950 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11951 }
11952 }
11953 }
11954 }
11955
11956 return status;
11957}
11958
11959/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011960 * FUNCTION: wlan_hdd_try_disconnect
11961 * This function is used to disconnect from previous
11962 * connection
11963 */
11964static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
11965{
11966 long ret = 0;
11967 hdd_station_ctx_t *pHddStaCtx;
11968 eMib_dot11DesiredBssType connectedBssType;
11969
11970 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11971
11972 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
11973
11974 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
11975 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
11976 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
11977 {
11978 /* Issue disconnect to CSR */
11979 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11980 if( eHAL_STATUS_SUCCESS ==
11981 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11982 pAdapter->sessionId,
11983 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11984 {
11985 ret = wait_for_completion_interruptible_timeout(
11986 &pAdapter->disconnect_comp_var,
11987 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11988 if (0 >= ret)
11989 {
11990 hddLog(LOGE, FL("Failed to receive disconnect event"));
11991 return -EALREADY;
11992 }
11993 }
11994 }
11995 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
11996 {
11997 ret = wait_for_completion_interruptible_timeout(
11998 &pAdapter->disconnect_comp_var,
11999 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12000 if (0 >= ret)
12001 {
12002 hddLog(LOGE, FL("Failed to receive disconnect event"));
12003 return -EALREADY;
12004 }
12005 }
12006
12007 return 0;
12008}
12009
12010/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012011 * FUNCTION: __wlan_hdd_cfg80211_connect
12012 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012013 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012014static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 struct net_device *ndev,
12016 struct cfg80211_connect_params *req
12017 )
12018{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012019 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012020 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012022 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012023
12024 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012025
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012026 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12027 TRACE_CODE_HDD_CFG80211_CONNECT,
12028 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012029 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012030 "%s: device_mode = %s (%d)", __func__,
12031 hdd_device_modetoString(pAdapter->device_mode),
12032 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012033
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012034 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012035 if (!pHddCtx)
12036 {
12037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12038 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012039 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012040 }
12041
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012042 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012043 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012045 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 }
12047
Agarwal Ashish51325b52014-06-16 16:50:49 +053012048 if (vos_max_concurrent_connections_reached()) {
12049 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12050 return -ECONNREFUSED;
12051 }
12052
Jeff Johnson295189b2012-06-20 16:38:30 -070012053#ifdef WLAN_BTAMP_FEATURE
12054 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012055 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012057 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012059 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 }
12061#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012062
12063 //If Device Mode is Station Concurrent Sessions Exit BMps
12064 //P2P Mode will be taken care in Open/close adapter
12065 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012066 (vos_concurrent_open_sessions_running())) {
12067 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12068 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012069 }
12070
12071 /*Try disconnecting if already in connected state*/
12072 status = wlan_hdd_try_disconnect(pAdapter);
12073 if ( 0 > status)
12074 {
12075 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12076 " connection"));
12077 return -EALREADY;
12078 }
12079
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012081 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012082
12083 if ( 0 > status)
12084 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 __func__);
12087 return status;
12088 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012089 if ( req->channel )
12090 {
12091 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12092 req->ssid_len, req->bssid,
12093 req->channel->hw_value);
12094 }
12095 else
12096 {
12097 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012098 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012099 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012100
Sushant Kaushikd7083982015-03-18 14:33:24 +053012101 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 {
12103 //ReEnable BMPS if disabled
12104 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12105 (NULL != pHddCtx))
12106 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012107 if (pHddCtx->hdd_wlan_suspended)
12108 {
12109 hdd_set_pwrparams(pHddCtx);
12110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 //ReEnable Bmps and Imps back
12112 hdd_enable_bmps_imps(pHddCtx);
12113 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012114 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 return status;
12116 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012117 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 EXIT();
12119 return status;
12120}
12121
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012122static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12123 struct net_device *ndev,
12124 struct cfg80211_connect_params *req)
12125{
12126 int ret;
12127 vos_ssr_protect(__func__);
12128 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12129 vos_ssr_unprotect(__func__);
12130
12131 return ret;
12132}
Jeff Johnson295189b2012-06-20 16:38:30 -070012133
12134/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012135 * FUNCTION: wlan_hdd_disconnect
12136 * This function is used to issue a disconnect request to SME
12137 */
12138int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12139{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012140 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012141 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012142 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012143 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012144
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012145 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012147 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012148 if (0 != status)
12149 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012150 return status;
12151 }
12152
12153 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012154
Agarwal Ashish47d18112014-08-04 19:55:07 +053012155 /* Need to apply spin lock before decreasing active sessions
12156 * as there can be chance for double decrement if context switch
12157 * Calls hdd_DisConnectHandler.
12158 */
12159
12160 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012161 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12162 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012163 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12164 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012165 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12166 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012167
Abhishek Singhf4669da2014-05-26 15:07:49 +053012168 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012169 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12170
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012171 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012172
Mihir Shete182a0b22014-08-18 16:08:48 +053012173 /*
12174 * stop tx queues before deleting STA/BSS context from the firmware.
12175 * tx has to be disabled because the firmware can get busy dropping
12176 * the tx frames after BSS/STA has been deleted and will not send
12177 * back a response resulting in WDI timeout
12178 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012179 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012180 netif_tx_disable(pAdapter->dev);
12181 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012182
Mihir Shete182a0b22014-08-18 16:08:48 +053012183 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012184 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12185 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012186 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12187 {
12188 hddLog(VOS_TRACE_LEVEL_INFO,
12189 FL("status = %d, already disconnected"),
12190 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012191
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012192 }
12193 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012194 {
12195 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012196 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012197 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012198 result = -EINVAL;
12199 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012200 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012201 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012202 &pAdapter->disconnect_comp_var,
12203 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012204 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012205 {
12206 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012207 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012208 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012209 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012210 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012211 {
12212 hddLog(VOS_TRACE_LEVEL_ERROR,
12213 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012214 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012215 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012216disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012217 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12218 FL("Set HDD connState to eConnectionState_NotConnected"));
12219 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12220
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012221 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012222 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012223}
12224
12225
12226/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012227 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 * This function is used to issue a disconnect request to SME
12229 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012230static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 struct net_device *dev,
12232 u16 reason
12233 )
12234{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012235 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012236 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012237 tCsrRoamProfile *pRoamProfile;
12238 hdd_station_ctx_t *pHddStaCtx;
12239 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012240#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012241 tANI_U8 staIdx;
12242#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012243
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012245
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012246 if (!pAdapter) {
12247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12248 return -EINVAL;
12249 }
12250
12251 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12252 if (!pHddStaCtx) {
12253 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12254 return -EINVAL;
12255 }
12256
12257 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12258 status = wlan_hdd_validate_context(pHddCtx);
12259 if (0 != status)
12260 {
12261 return status;
12262 }
12263
12264 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12265
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012266 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12267 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12268 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012269 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12270 __func__, hdd_device_modetoString(pAdapter->device_mode),
12271 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012272
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012273 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12274 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012275
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 if (NULL != pRoamProfile)
12277 {
12278 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012279 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12280 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012281 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012282 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012284 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 switch(reason)
12286 {
12287 case WLAN_REASON_MIC_FAILURE:
12288 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12289 break;
12290
12291 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12292 case WLAN_REASON_DISASSOC_AP_BUSY:
12293 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12294 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12295 break;
12296
12297 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12298 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012299 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12301 break;
12302
Jeff Johnson295189b2012-06-20 16:38:30 -070012303 default:
12304 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12305 break;
12306 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012307 pScanInfo = &pHddCtx->scan_info;
12308 if (pScanInfo->mScanPending)
12309 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012310 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012311 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012312 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012313 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012315
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012316#ifdef FEATURE_WLAN_TDLS
12317 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012318 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012319 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012320 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12321 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012322 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012323 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012324 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012326 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012327 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012328 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012329 status = sme_DeleteTdlsPeerSta(
12330 WLAN_HDD_GET_HAL_CTX(pAdapter),
12331 pAdapter->sessionId,
12332 mac);
12333 if (status != eHAL_STATUS_SUCCESS) {
12334 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12335 return -EPERM;
12336 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012337 }
12338 }
12339#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012340 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012341 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12342 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 {
12344 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012345 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 __func__, (int)status );
12347 return -EINVAL;
12348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012350 else
12351 {
12352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12353 "called while in %d state", __func__,
12354 pHddStaCtx->conn_info.connState);
12355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012356 }
12357 else
12358 {
12359 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12360 }
12361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012362 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 return status;
12364}
12365
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012366static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12367 struct net_device *dev,
12368 u16 reason
12369 )
12370{
12371 int ret;
12372 vos_ssr_protect(__func__);
12373 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12374 vos_ssr_unprotect(__func__);
12375
12376 return ret;
12377}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012378
Jeff Johnson295189b2012-06-20 16:38:30 -070012379/*
12380 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012381 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 * settings in IBSS mode.
12383 */
12384static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012385 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 struct cfg80211_ibss_params *params
12387 )
12388{
12389 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012390 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12392 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012393
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 ENTER();
12395
12396 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012397 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012398
12399 if (params->ie_len && ( NULL != params->ie) )
12400 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012401 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12402 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 {
12404 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12405 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12406 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012407 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012409 tDot11fIEWPA dot11WPAIE;
12410 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012411 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012412
Wilson Yang00256342013-10-10 23:13:38 -070012413 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012414 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12415 params->ie_len, DOT11F_EID_WPA);
12416 if ( NULL != ie )
12417 {
12418 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12419 // Unpack the WPA IE
12420 //Skip past the EID byte and length byte - and four byte WiFi OUI
12421 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12422 &ie[2+4],
12423 ie[1] - 4,
12424 &dot11WPAIE);
12425 /*Extract the multicast cipher, the encType for unicast
12426 cipher for wpa-none is none*/
12427 encryptionType =
12428 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012431
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12433
12434 if (0 > status)
12435 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012436 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 __func__);
12438 return status;
12439 }
12440 }
12441
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012442 pWextState->roamProfile.AuthType.authType[0] =
12443 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12445
12446 if (params->privacy)
12447 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012448 /* Security enabled IBSS, At this time there is no information available
12449 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012451 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012453 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 *enable privacy bit in beacons */
12455
12456 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12457 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012458 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12459 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12461 pWextState->roamProfile.EncryptionType.numEntries = 1;
12462 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 return status;
12464}
12465
12466/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012467 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012468 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012470static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 struct net_device *dev,
12472 struct cfg80211_ibss_params *params
12473 )
12474{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012475 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12477 tCsrRoamProfile *pRoamProfile;
12478 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012479 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012480 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12481 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012482
12483 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012484
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012485 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12486 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12487 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012488 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012489 "%s: device_mode = %s (%d)", __func__,
12490 hdd_device_modetoString(pAdapter->device_mode),
12491 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012492
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012493 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012494 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012495 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012496 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 }
12498
12499 if (NULL == pWextState)
12500 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012501 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012502 __func__);
12503 return -EIO;
12504 }
12505
Agarwal Ashish51325b52014-06-16 16:50:49 +053012506 if (vos_max_concurrent_connections_reached()) {
12507 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12508 return -ECONNREFUSED;
12509 }
12510
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012511 /*Try disconnecting if already in connected state*/
12512 status = wlan_hdd_try_disconnect(pAdapter);
12513 if ( 0 > status)
12514 {
12515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12516 " IBSS connection"));
12517 return -EALREADY;
12518 }
12519
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 pRoamProfile = &pWextState->roamProfile;
12521
12522 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12523 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012524 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012525 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 return -EINVAL;
12527 }
12528
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012529 /* BSSID is provided by upper layers hence no need to AUTO generate */
12530 if (NULL != params->bssid) {
12531 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12532 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12533 hddLog (VOS_TRACE_LEVEL_ERROR,
12534 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12535 return -EIO;
12536 }
12537 }
krunal sonie9002db2013-11-25 14:24:17 -080012538 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12539 {
12540 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12541 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12542 {
12543 hddLog (VOS_TRACE_LEVEL_ERROR,
12544 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12545 return -EIO;
12546 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012547 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012548 if (!params->bssid)
12549 {
12550 hddLog (VOS_TRACE_LEVEL_ERROR,
12551 "%s:Failed memory allocation", __func__);
12552 return -EIO;
12553 }
12554 vos_mem_copy((v_U8_t *)params->bssid,
12555 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12556 VOS_MAC_ADDR_SIZE);
12557 alloc_bssid = VOS_TRUE;
12558 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012559
Jeff Johnson295189b2012-06-20 16:38:30 -070012560 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012561 if (NULL !=
12562#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12563 params->chandef.chan)
12564#else
12565 params->channel)
12566#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 {
12568 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012569 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12570 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12571 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12572 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012573
12574 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012575 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012576 ieee80211_frequency_to_channel(
12577#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12578 params->chandef.chan->center_freq);
12579#else
12580 params->channel->center_freq);
12581#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012582
12583 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12584 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12587 __func__);
12588 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012590
12591 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012593 if (channelNum == validChan[indx])
12594 {
12595 break;
12596 }
12597 }
12598 if (indx >= numChans)
12599 {
12600 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 __func__, channelNum);
12602 return -EINVAL;
12603 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012604 /* Set the Operational Channel */
12605 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12606 channelNum);
12607 pRoamProfile->ChannelInfo.numOfChannels = 1;
12608 pHddStaCtx->conn_info.operationChannel = channelNum;
12609 pRoamProfile->ChannelInfo.ChannelList =
12610 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 }
12612
12613 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012614 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 if (status < 0)
12616 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012617 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 __func__);
12619 return status;
12620 }
12621
12622 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012623 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012624 params->ssid_len, params->bssid,
12625 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012626
12627 if (0 > status)
12628 {
12629 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12630 return status;
12631 }
12632
krunal sonie9002db2013-11-25 14:24:17 -080012633 if (NULL != params->bssid &&
12634 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12635 alloc_bssid == VOS_TRUE)
12636 {
12637 vos_mem_free(params->bssid);
12638 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012639 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 return 0;
12641}
12642
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012643static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12644 struct net_device *dev,
12645 struct cfg80211_ibss_params *params
12646 )
12647{
12648 int ret = 0;
12649
12650 vos_ssr_protect(__func__);
12651 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12652 vos_ssr_unprotect(__func__);
12653
12654 return ret;
12655}
12656
Jeff Johnson295189b2012-06-20 16:38:30 -070012657/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012658 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012659 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012661static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 struct net_device *dev
12663 )
12664{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012665 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012666 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12667 tCsrRoamProfile *pRoamProfile;
12668 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012669 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012670
12671 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012672
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012673 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12674 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12675 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012676 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012677 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012678 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012679 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012680 }
12681
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12683 hdd_device_modetoString(pAdapter->device_mode),
12684 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 if (NULL == pWextState)
12686 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012687 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 __func__);
12689 return -EIO;
12690 }
12691
12692 pRoamProfile = &pWextState->roamProfile;
12693
12694 /* Issue disconnect only if interface type is set to IBSS */
12695 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12696 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012697 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012698 __func__);
12699 return -EINVAL;
12700 }
12701
12702 /* Issue Disconnect request */
12703 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12704 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12705 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12706
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012707 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 return 0;
12709}
12710
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012711static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12712 struct net_device *dev
12713 )
12714{
12715 int ret = 0;
12716
12717 vos_ssr_protect(__func__);
12718 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12719 vos_ssr_unprotect(__func__);
12720
12721 return ret;
12722}
12723
Jeff Johnson295189b2012-06-20 16:38:30 -070012724/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012725 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 * This function is used to set the phy parameters
12727 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12728 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012729static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 u32 changed)
12731{
12732 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12733 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012734 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012735
12736 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012737
12738 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012739 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12740 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012742 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012743 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012744 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012745 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012746 }
12747
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12749 {
12750 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12751 WNI_CFG_RTS_THRESHOLD_STAMAX :
12752 wiphy->rts_threshold;
12753
12754 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012755 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012757 hddLog(VOS_TRACE_LEVEL_ERROR,
12758 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 __func__, rts_threshold);
12760 return -EINVAL;
12761 }
12762
12763 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12764 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012765 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012767 hddLog(VOS_TRACE_LEVEL_ERROR,
12768 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 __func__, rts_threshold);
12770 return -EIO;
12771 }
12772
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012773 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 rts_threshold);
12775 }
12776
12777 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12778 {
12779 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12780 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12781 wiphy->frag_threshold;
12782
12783 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012784 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012785 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012786 hddLog(VOS_TRACE_LEVEL_ERROR,
12787 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 frag_threshold);
12789 return -EINVAL;
12790 }
12791
12792 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12793 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012794 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012796 hddLog(VOS_TRACE_LEVEL_ERROR,
12797 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012798 __func__, frag_threshold);
12799 return -EIO;
12800 }
12801
12802 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12803 frag_threshold);
12804 }
12805
12806 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12807 || (changed & WIPHY_PARAM_RETRY_LONG))
12808 {
12809 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12810 wiphy->retry_short :
12811 wiphy->retry_long;
12812
12813 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12814 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12815 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012816 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 __func__, retry_value);
12818 return -EINVAL;
12819 }
12820
12821 if (changed & WIPHY_PARAM_RETRY_SHORT)
12822 {
12823 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12824 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012825 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012827 hddLog(VOS_TRACE_LEVEL_ERROR,
12828 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 __func__, retry_value);
12830 return -EIO;
12831 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012832 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 __func__, retry_value);
12834 }
12835 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12836 {
12837 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12838 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012839 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012841 hddLog(VOS_TRACE_LEVEL_ERROR,
12842 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 __func__, retry_value);
12844 return -EIO;
12845 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012846 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 __func__, retry_value);
12848 }
12849 }
12850
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012851 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 return 0;
12853}
12854
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012855static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12856 u32 changed)
12857{
12858 int ret;
12859
12860 vos_ssr_protect(__func__);
12861 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12862 vos_ssr_unprotect(__func__);
12863
12864 return ret;
12865}
12866
Jeff Johnson295189b2012-06-20 16:38:30 -070012867/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012868 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 * This function is used to set the txpower
12870 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012871static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012872#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12873 struct wireless_dev *wdev,
12874#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012875#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012876 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012877#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012878 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012879#endif
12880 int dbm)
12881{
12882 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012883 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12885 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012886 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012887
12888 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012889
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012890 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12891 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
12892 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012893 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012894 if (0 != status)
12895 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012896 return status;
12897 }
12898
12899 hHal = pHddCtx->hHal;
12900
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012901 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
12902 dbm, ccmCfgSetCallback,
12903 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012905 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
12907 return -EIO;
12908 }
12909
12910 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
12911 dbm);
12912
12913 switch(type)
12914 {
12915 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12916 /* Fall through */
12917 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12918 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12919 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012920 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12921 __func__);
12922 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 }
12924 break;
12925 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 __func__);
12928 return -EOPNOTSUPP;
12929 break;
12930 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012931 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12932 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 return -EIO;
12934 }
12935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012936 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 return 0;
12938}
12939
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012940static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12941#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12942 struct wireless_dev *wdev,
12943#endif
12944#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12945 enum tx_power_setting type,
12946#else
12947 enum nl80211_tx_power_setting type,
12948#endif
12949 int dbm)
12950{
12951 int ret;
12952 vos_ssr_protect(__func__);
12953 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12954#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12955 wdev,
12956#endif
12957#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12958 type,
12959#else
12960 type,
12961#endif
12962 dbm);
12963 vos_ssr_unprotect(__func__);
12964
12965 return ret;
12966}
12967
Jeff Johnson295189b2012-06-20 16:38:30 -070012968/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012969 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 * This function is used to read the txpower
12971 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012972static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012973#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12974 struct wireless_dev *wdev,
12975#endif
12976 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070012977{
12978
12979 hdd_adapter_t *pAdapter;
12980 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012981 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012982
Jeff Johnsone7245742012-09-05 17:12:55 -070012983 ENTER();
12984
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012985 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012986 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012987 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012988 *dbm = 0;
12989 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012990 }
12991
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
12993 if (NULL == pAdapter)
12994 {
12995 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
12996 return -ENOENT;
12997 }
12998
12999 wlan_hdd_get_classAstats(pAdapter);
13000 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13001
Jeff Johnsone7245742012-09-05 17:12:55 -070013002 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 return 0;
13004}
13005
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013006static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13007#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13008 struct wireless_dev *wdev,
13009#endif
13010 int *dbm)
13011{
13012 int ret;
13013
13014 vos_ssr_protect(__func__);
13015 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13016#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13017 wdev,
13018#endif
13019 dbm);
13020 vos_ssr_unprotect(__func__);
13021
13022 return ret;
13023}
13024
13025
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013026static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 u8* mac, struct station_info *sinfo)
13028{
13029 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13030 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13031 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013032 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013033
13034 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13035 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013036
13037 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13038 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13039 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13040 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13041 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13042 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13043 tANI_U16 maxRate = 0;
13044 tANI_U16 myRate;
13045 tANI_U16 currentRate = 0;
13046 tANI_U8 maxSpeedMCS = 0;
13047 tANI_U8 maxMCSIdx = 0;
13048 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013049 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013050 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013051 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013052
Leo Chang6f8870f2013-03-26 18:11:36 -070013053#ifdef WLAN_FEATURE_11AC
13054 tANI_U32 vht_mcs_map;
13055 eDataRate11ACMaxMcs vhtMaxMcs;
13056#endif /* WLAN_FEATURE_11AC */
13057
Jeff Johnsone7245742012-09-05 17:12:55 -070013058 ENTER();
13059
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13061 (0 == ssidlen))
13062 {
13063 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13064 " Invalid ssidlen, %d", __func__, ssidlen);
13065 /*To keep GUI happy*/
13066 return 0;
13067 }
13068
Mukul Sharma811205f2014-07-09 21:07:30 +053013069 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13070 {
13071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13072 "%s: Roaming in progress, so unable to proceed this request", __func__);
13073 return 0;
13074 }
13075
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013076 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013077 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013078 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013079 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013080 }
13081
Jeff Johnson295189b2012-06-20 16:38:30 -070013082
Kiet Lam3b17fc82013-09-27 05:24:08 +053013083 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13084 sinfo->filled |= STATION_INFO_SIGNAL;
13085
c_hpothu09f19542014-05-30 21:53:31 +053013086 wlan_hdd_get_station_stats(pAdapter);
13087 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13088
13089 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013090 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13091 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013092 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013093 {
13094 rate_flags = pAdapter->maxRateFlags;
13095 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013096
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 //convert to the UI units of 100kbps
13098 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13099
13100#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013101 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 -070013102 sinfo->signal,
13103 pCfg->reportMaxLinkSpeed,
13104 myRate,
13105 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013106 (int) pCfg->linkSpeedRssiMid,
13107 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013108 (int) rate_flags,
13109 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013110#endif //LINKSPEED_DEBUG_ENABLED
13111
13112 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13113 {
13114 // we do not want to necessarily report the current speed
13115 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13116 {
13117 // report the max possible speed
13118 rssidx = 0;
13119 }
13120 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13121 {
13122 // report the max possible speed with RSSI scaling
13123 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13124 {
13125 // report the max possible speed
13126 rssidx = 0;
13127 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013128 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 {
13130 // report middle speed
13131 rssidx = 1;
13132 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013133 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13134 {
13135 // report middle speed
13136 rssidx = 2;
13137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 else
13139 {
13140 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013141 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 }
13143 }
13144 else
13145 {
13146 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13147 hddLog(VOS_TRACE_LEVEL_ERROR,
13148 "%s: Invalid value for reportMaxLinkSpeed: %u",
13149 __func__, pCfg->reportMaxLinkSpeed);
13150 rssidx = 0;
13151 }
13152
13153 maxRate = 0;
13154
13155 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013156 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13157 OperationalRates, &ORLeng))
13158 {
13159 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13160 /*To keep GUI happy*/
13161 return 0;
13162 }
13163
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 for (i = 0; i < ORLeng; i++)
13165 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013166 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 {
13168 /* Validate Rate Set */
13169 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13170 {
13171 currentRate = supported_data_rate[j].supported_rate[rssidx];
13172 break;
13173 }
13174 }
13175 /* Update MAX rate */
13176 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13177 }
13178
13179 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013180 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13181 ExtendedRates, &ERLeng))
13182 {
13183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13184 /*To keep GUI happy*/
13185 return 0;
13186 }
13187
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 for (i = 0; i < ERLeng; i++)
13189 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013190 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 {
13192 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13193 {
13194 currentRate = supported_data_rate[j].supported_rate[rssidx];
13195 break;
13196 }
13197 }
13198 /* Update MAX rate */
13199 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13200 }
c_hpothu79aab322014-07-14 21:11:01 +053013201
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013202 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013203 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013204 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013205 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 {
c_hpothu79aab322014-07-14 21:11:01 +053013207 if (rate_flags & eHAL_TX_RATE_VHT80)
13208 mode = 2;
13209 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13210 mode = 1;
13211 else
13212 mode = 0;
13213
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013214 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13215 MCSRates, &MCSLeng))
13216 {
13217 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13218 /*To keep GUI happy*/
13219 return 0;
13220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013222#ifdef WLAN_FEATURE_11AC
13223 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013224 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013226 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013227 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013228 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013230 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013232 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013234 maxMCSIdx = 7;
13235 }
13236 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13237 {
13238 maxMCSIdx = 8;
13239 }
13240 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13241 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013242 //VHT20 is supporting 0~8
13243 if (rate_flags & eHAL_TX_RATE_VHT20)
13244 maxMCSIdx = 8;
13245 else
13246 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013247 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013248
c_hpothu79aab322014-07-14 21:11:01 +053013249 if (0 != rssidx)/*check for scaled */
13250 {
13251 //get middle rate MCS index if rssi=1/2
13252 for (i=0; i <= maxMCSIdx; i++)
13253 {
13254 if (sinfo->signal <= rssiMcsTbl[mode][i])
13255 {
13256 maxMCSIdx = i;
13257 break;
13258 }
13259 }
13260 }
13261
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013262 if (rate_flags & eHAL_TX_RATE_VHT80)
13263 {
13264 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13265 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13266 }
13267 else if (rate_flags & eHAL_TX_RATE_VHT40)
13268 {
13269 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13270 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13271 }
13272 else if (rate_flags & eHAL_TX_RATE_VHT20)
13273 {
13274 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13275 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13276 }
13277
Leo Chang6f8870f2013-03-26 18:11:36 -070013278 maxSpeedMCS = 1;
13279 if (currentRate > maxRate)
13280 {
13281 maxRate = currentRate;
13282 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013283
Leo Chang6f8870f2013-03-26 18:11:36 -070013284 }
13285 else
13286#endif /* WLAN_FEATURE_11AC */
13287 {
13288 if (rate_flags & eHAL_TX_RATE_HT40)
13289 {
13290 rateFlag |= 1;
13291 }
13292 if (rate_flags & eHAL_TX_RATE_SGI)
13293 {
13294 rateFlag |= 2;
13295 }
13296
Girish Gowli01abcee2014-07-31 20:18:55 +053013297 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013298 if (rssidx == 1 || rssidx == 2)
13299 {
13300 //get middle rate MCS index if rssi=1/2
13301 for (i=0; i <= 7; i++)
13302 {
13303 if (sinfo->signal <= rssiMcsTbl[mode][i])
13304 {
13305 temp = i+1;
13306 break;
13307 }
13308 }
13309 }
c_hpothu79aab322014-07-14 21:11:01 +053013310
13311 for (i = 0; i < MCSLeng; i++)
13312 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013313 for (j = 0; j < temp; j++)
13314 {
13315 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13316 {
13317 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
13318 break;
13319 }
13320 }
13321 if ((j < temp) && (currentRate > maxRate))
13322 {
13323 maxRate = currentRate;
13324 maxSpeedMCS = 1;
13325 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
13326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 }
13328 }
13329 }
13330
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013331 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13332 {
13333 maxRate = myRate;
13334 maxSpeedMCS = 1;
13335 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013338 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 {
13340 maxRate = myRate;
13341 if (rate_flags & eHAL_TX_RATE_LEGACY)
13342 {
13343 maxSpeedMCS = 0;
13344 }
13345 else
13346 {
13347 maxSpeedMCS = 1;
13348 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13349 }
13350 }
13351
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013352 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 {
13354 sinfo->txrate.legacy = maxRate;
13355#ifdef LINKSPEED_DEBUG_ENABLED
13356 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13357#endif //LINKSPEED_DEBUG_ENABLED
13358 }
13359 else
13360 {
13361 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013362#ifdef WLAN_FEATURE_11AC
13363 sinfo->txrate.nss = 1;
13364 if (rate_flags & eHAL_TX_RATE_VHT80)
13365 {
13366 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013367 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013368 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013369 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013370 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013371 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13372 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13373 }
13374 else if (rate_flags & eHAL_TX_RATE_VHT20)
13375 {
13376 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13377 }
13378#endif /* WLAN_FEATURE_11AC */
13379 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13380 {
13381 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13382 if (rate_flags & eHAL_TX_RATE_HT40)
13383 {
13384 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13385 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 if (rate_flags & eHAL_TX_RATE_SGI)
13388 {
13389 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13390 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013391
Jeff Johnson295189b2012-06-20 16:38:30 -070013392#ifdef LINKSPEED_DEBUG_ENABLED
13393 pr_info("Reporting MCS rate %d flags %x\n",
13394 sinfo->txrate.mcs,
13395 sinfo->txrate.flags );
13396#endif //LINKSPEED_DEBUG_ENABLED
13397 }
13398 }
13399 else
13400 {
13401 // report current rate instead of max rate
13402
13403 if (rate_flags & eHAL_TX_RATE_LEGACY)
13404 {
13405 //provide to the UI in units of 100kbps
13406 sinfo->txrate.legacy = myRate;
13407#ifdef LINKSPEED_DEBUG_ENABLED
13408 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13409#endif //LINKSPEED_DEBUG_ENABLED
13410 }
13411 else
13412 {
13413 //must be MCS
13414 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013415#ifdef WLAN_FEATURE_11AC
13416 sinfo->txrate.nss = 1;
13417 if (rate_flags & eHAL_TX_RATE_VHT80)
13418 {
13419 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13420 }
13421 else
13422#endif /* WLAN_FEATURE_11AC */
13423 {
13424 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 if (rate_flags & eHAL_TX_RATE_SGI)
13427 {
13428 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13429 }
13430 if (rate_flags & eHAL_TX_RATE_HT40)
13431 {
13432 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13433 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013434#ifdef WLAN_FEATURE_11AC
13435 else if (rate_flags & eHAL_TX_RATE_VHT80)
13436 {
13437 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13438 }
13439#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013440#ifdef LINKSPEED_DEBUG_ENABLED
13441 pr_info("Reporting actual MCS rate %d flags %x\n",
13442 sinfo->txrate.mcs,
13443 sinfo->txrate.flags );
13444#endif //LINKSPEED_DEBUG_ENABLED
13445 }
13446 }
13447 sinfo->filled |= STATION_INFO_TX_BITRATE;
13448
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013449 sinfo->tx_packets =
13450 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13451 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13452 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13453 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13454
13455 sinfo->tx_retries =
13456 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13457 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13458 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13459 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13460
13461 sinfo->tx_failed =
13462 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13463 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13464 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13465 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13466
13467 sinfo->filled |=
13468 STATION_INFO_TX_PACKETS |
13469 STATION_INFO_TX_RETRIES |
13470 STATION_INFO_TX_FAILED;
13471
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013472 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13473 TRACE_CODE_HDD_CFG80211_GET_STA,
13474 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013475 EXIT();
13476 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013477}
13478
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013479static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13480 u8* mac, struct station_info *sinfo)
13481{
13482 int ret;
13483
13484 vos_ssr_protect(__func__);
13485 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13486 vos_ssr_unprotect(__func__);
13487
13488 return ret;
13489}
13490
13491static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013492 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013493{
13494 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013495 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013497 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013498
Jeff Johnsone7245742012-09-05 17:12:55 -070013499 ENTER();
13500
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 if (NULL == pAdapter)
13502 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013503 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 return -ENODEV;
13505 }
13506
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013507 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13508 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13509 pAdapter->sessionId, timeout));
13510
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013511 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013512 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013513 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013514 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013515 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013516 }
13517
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013518 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13519 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13520 (pHddCtx->cfg_ini->fhostArpOffload) &&
13521 (eConnectionState_Associated ==
13522 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13523 {
Amar Singhald53568e2013-09-26 11:03:45 -070013524
13525 hddLog(VOS_TRACE_LEVEL_INFO,
13526 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013527 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013528 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13529 {
13530 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013531 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013532 __func__, vos_status);
13533 }
13534 }
13535
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 /**The get power cmd from the supplicant gets updated by the nl only
13537 *on successful execution of the function call
13538 *we are oppositely mapped w.r.t mode in the driver
13539 **/
13540 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13541
13542 if (VOS_STATUS_E_FAILURE == vos_status)
13543 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13545 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 return -EINVAL;
13547 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013548 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 return 0;
13550}
13551
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013552static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13553 struct net_device *dev, bool mode, int timeout)
13554{
13555 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013556
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013557 vos_ssr_protect(__func__);
13558 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13559 vos_ssr_unprotect(__func__);
13560
13561 return ret;
13562}
Jeff Johnson295189b2012-06-20 16:38:30 -070013563#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013564static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13565 struct net_device *netdev,
13566 u8 key_index)
13567{
13568 ENTER();
13569 return 0;
13570}
13571
Jeff Johnson295189b2012-06-20 16:38:30 -070013572static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013573 struct net_device *netdev,
13574 u8 key_index)
13575{
13576 int ret;
13577 vos_ssr_protect(__func__);
13578 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13579 vos_ssr_unprotect(__func__);
13580 return ret;
13581}
13582#endif //LINUX_VERSION_CODE
13583
13584#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13585static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13586 struct net_device *dev,
13587 struct ieee80211_txq_params *params)
13588{
13589 ENTER();
13590 return 0;
13591}
13592#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13593static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13594 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013595{
Jeff Johnsone7245742012-09-05 17:12:55 -070013596 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 return 0;
13598}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013599#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013600
13601#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13602static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013603 struct net_device *dev,
13604 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013605{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013606 int ret;
13607
13608 vos_ssr_protect(__func__);
13609 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13610 vos_ssr_unprotect(__func__);
13611 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013612}
13613#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13614static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13615 struct ieee80211_txq_params *params)
13616{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013617 int ret;
13618
13619 vos_ssr_protect(__func__);
13620 ret = __wlan_hdd_set_txq_params(wiphy, params);
13621 vos_ssr_unprotect(__func__);
13622 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013623}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013625
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013626static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013627 struct net_device *dev,
13628 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013629{
13630 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013631 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013632 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013633 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013634 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013635 v_CONTEXT_t pVosContext = NULL;
13636 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013637
Jeff Johnsone7245742012-09-05 17:12:55 -070013638 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013639
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013640 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013642 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 return -EINVAL;
13644 }
13645
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013646 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13647 TRACE_CODE_HDD_CFG80211_DEL_STA,
13648 pAdapter->sessionId, pAdapter->device_mode));
13649
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013650 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13651 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013652 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013653 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013654 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013655 }
13656
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 )
13660 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013661 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13662 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13663 if(pSapCtx == NULL){
13664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13665 FL("psapCtx is NULL"));
13666 return -ENOENT;
13667 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013668 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 {
13670 v_U16_t i;
13671 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13672 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013673 if ((pSapCtx->aStaInfo[i].isUsed) &&
13674 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013676 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013677 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013678 ETHER_ADDR_LEN);
13679
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013681 "%s: Delete STA with MAC::"
13682 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013683 __func__,
13684 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13685 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013686 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013687 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 }
13689 }
13690 }
13691 else
13692 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013693
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013694 vos_status = hdd_softap_GetStaId(pAdapter,
13695 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013696 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13697 {
13698 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013699 "%s: Skip this DEL STA as this is not used::"
13700 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013701 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013702 return -ENOENT;
13703 }
13704
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013705 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013706 {
13707 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013708 "%s: Skip this DEL STA as deauth is in progress::"
13709 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013710 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013711 return -ENOENT;
13712 }
13713
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013714 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013715
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 hddLog(VOS_TRACE_LEVEL_INFO,
13717 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013718 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013720 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013721
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013722 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013723 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13724 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013725 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013726 hddLog(VOS_TRACE_LEVEL_INFO,
13727 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013728 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013729 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013730 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013731 return -ENOENT;
13732 }
13733
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 }
13735 }
13736
13737 EXIT();
13738
13739 return 0;
13740}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013741
13742#ifdef CFG80211_DEL_STA_V2
13743static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13744 struct net_device *dev,
13745 struct station_del_parameters *param)
13746#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013747static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13748 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013749#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013750{
13751 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013752 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013753
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013754 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013755
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013756#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013757 if (NULL == param) {
13758 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013759 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013760 return -EINVAL;
13761 }
13762
13763 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13764 param->subtype, &delStaParams);
13765
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013766#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013767 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013768 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013769#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013770 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13771
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013772 vos_ssr_unprotect(__func__);
13773
13774 return ret;
13775}
13776
13777static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013778 struct net_device *dev, u8 *mac, struct station_parameters *params)
13779{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013780 hdd_adapter_t *pAdapter;
13781 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013782 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013783#ifdef FEATURE_WLAN_TDLS
13784 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013785
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013786 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013787
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013788 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13789 if (NULL == pAdapter)
13790 {
13791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13792 "%s: Adapter is NULL",__func__);
13793 return -EINVAL;
13794 }
13795 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13796 status = wlan_hdd_validate_context(pHddCtx);
13797 if (0 != status)
13798 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013799 return status;
13800 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013801
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013802 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13803 TRACE_CODE_HDD_CFG80211_ADD_STA,
13804 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013805 mask = params->sta_flags_mask;
13806
13807 set = params->sta_flags_set;
13808
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013810 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13811 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013812
13813 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13814 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013815 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013816 }
13817 }
13818#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013819 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013820 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013821}
13822
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013823static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13824 struct net_device *dev, u8 *mac, struct station_parameters *params)
13825{
13826 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013827
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013828 vos_ssr_protect(__func__);
13829 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13830 vos_ssr_unprotect(__func__);
13831
13832 return ret;
13833}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013834#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013835
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013836static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013837 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013838{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013839 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13840 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013841 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013842 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013843 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013844 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013845
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013846 ENTER();
13847
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013848 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013849 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013850 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013852 return -EINVAL;
13853 }
13854
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013855 if (!pmksa) {
13856 hddLog(LOGE, FL("pmksa is NULL"));
13857 return -EINVAL;
13858 }
13859
13860 if (!pmksa->bssid || !pmksa->pmkid) {
13861 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
13862 pmksa->bssid, pmksa->pmkid);
13863 return -EINVAL;
13864 }
13865
13866 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
13867 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13868
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013869 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13870 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013871 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013872 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013873 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013874 }
13875
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013876 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013877 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13878
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013879 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
13880 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013881
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013882 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013883 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013884 &pmk_id, 1, FALSE);
13885
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013886 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13887 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
13888 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013889
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013890 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013891 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013892}
13893
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013894static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
13895 struct cfg80211_pmksa *pmksa)
13896{
13897 int ret;
13898
13899 vos_ssr_protect(__func__);
13900 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
13901 vos_ssr_unprotect(__func__);
13902
13903 return ret;
13904}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013905
Wilson Yang6507c4e2013-10-01 20:11:19 -070013906
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013907static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070013908 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013909{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013910 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13911 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013912 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013913 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013914
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013915 ENTER();
13916
Wilson Yang6507c4e2013-10-01 20:11:19 -070013917 /* Validate pAdapter */
13918 if (NULL == pAdapter)
13919 {
13920 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
13921 return -EINVAL;
13922 }
13923
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013924 if (!pmksa) {
13925 hddLog(LOGE, FL("pmksa is NULL"));
13926 return -EINVAL;
13927 }
13928
13929 if (!pmksa->bssid) {
13930 hddLog(LOGE, FL("pmksa->bssid is NULL"));
13931 return -EINVAL;
13932 }
13933
Kiet Lam98c46a12014-10-31 15:34:57 -070013934 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
13935 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13936
Wilson Yang6507c4e2013-10-01 20:11:19 -070013937 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13938 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013939 if (0 != status)
13940 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013941 return status;
13942 }
13943
13944 /*Retrieve halHandle*/
13945 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13946
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013947 /* Delete the PMKID CSR cache */
13948 if (eHAL_STATUS_SUCCESS !=
13949 sme_RoamDelPMKIDfromCache(halHandle,
13950 pAdapter->sessionId, pmksa->bssid, FALSE)) {
13951 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
13952 MAC_ADDR_ARRAY(pmksa->bssid));
13953 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013954 }
13955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013956 EXIT();
13957 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013958}
13959
Wilson Yang6507c4e2013-10-01 20:11:19 -070013960
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013961static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
13962 struct cfg80211_pmksa *pmksa)
13963{
13964 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013965
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013966 vos_ssr_protect(__func__);
13967 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
13968 vos_ssr_unprotect(__func__);
13969
13970 return ret;
13971
13972}
13973
13974static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013975{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13977 tHalHandle halHandle;
13978 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013979 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013981 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070013982
13983 /* Validate pAdapter */
13984 if (NULL == pAdapter)
13985 {
13986 hddLog(VOS_TRACE_LEVEL_ERROR,
13987 "%s: Invalid Adapter" ,__func__);
13988 return -EINVAL;
13989 }
13990
13991 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13992 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013993 if (0 != status)
13994 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013995 return status;
13996 }
13997
13998 /*Retrieve halHandle*/
13999 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14000
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014001 /* Flush the PMKID cache in CSR */
14002 if (eHAL_STATUS_SUCCESS !=
14003 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14005 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014006 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014007 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014008 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014009}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014010
14011static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14012{
14013 int ret;
14014
14015 vos_ssr_protect(__func__);
14016 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14017 vos_ssr_unprotect(__func__);
14018
14019 return ret;
14020}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014021#endif
14022
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014023#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014024static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14025 struct net_device *dev,
14026 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014027{
14028 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14029 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014030 hdd_context_t *pHddCtx;
14031 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014032
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014033 ENTER();
14034
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014035 if (NULL == pAdapter)
14036 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014037 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014038 return -ENODEV;
14039 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014040 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14041 ret = wlan_hdd_validate_context(pHddCtx);
14042 if (0 != ret)
14043 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014044 return ret;
14045 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014046 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014047 if (NULL == pHddStaCtx)
14048 {
14049 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14050 return -EINVAL;
14051 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014052
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014053 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14054 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14055 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014056 // Added for debug on reception of Re-assoc Req.
14057 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14058 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014059 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014060 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014061 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014062 }
14063
14064#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014065 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014066 ftie->ie_len);
14067#endif
14068
14069 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014070 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14071 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014072 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014073
14074 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014075 return 0;
14076}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014077
14078static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14079 struct net_device *dev,
14080 struct cfg80211_update_ft_ies_params *ftie)
14081{
14082 int ret;
14083
14084 vos_ssr_protect(__func__);
14085 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14086 vos_ssr_unprotect(__func__);
14087
14088 return ret;
14089}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014090#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014091
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014092#ifdef FEATURE_WLAN_SCAN_PNO
14093
14094void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14095 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14096{
14097 int ret;
14098 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14099 hdd_context_t *pHddCtx;
14100
Nirav Shah80830bf2013-12-31 16:35:12 +053014101 ENTER();
14102
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014103 if (NULL == pAdapter)
14104 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014106 "%s: HDD adapter is Null", __func__);
14107 return ;
14108 }
14109
14110 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14111 if (NULL == pHddCtx)
14112 {
14113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14114 "%s: HDD context is Null!!!", __func__);
14115 return ;
14116 }
14117
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014118 spin_lock(&pHddCtx->schedScan_lock);
14119 if (TRUE == pHddCtx->isWiphySuspended)
14120 {
14121 pHddCtx->isSchedScanUpdatePending = TRUE;
14122 spin_unlock(&pHddCtx->schedScan_lock);
14123 hddLog(VOS_TRACE_LEVEL_INFO,
14124 "%s: Update cfg80211 scan database after it resume", __func__);
14125 return ;
14126 }
14127 spin_unlock(&pHddCtx->schedScan_lock);
14128
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014129 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14130
14131 if (0 > ret)
14132 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14133
14134 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14136 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014137}
14138
14139/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014140 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014141 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014142 */
14143static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14144{
14145 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14146 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014147 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014148 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14149 int status = 0;
14150 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14151
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014152 /* The current firmware design does not allow PNO during any
14153 * active sessions. Hence, determine the active sessions
14154 * and return a failure.
14155 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014156 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14157 {
14158 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014159 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014160
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014161 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14162 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14163 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14164 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14165 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014166 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014167 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014168 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014169 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014170 }
14171 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14172 pAdapterNode = pNext;
14173 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014174 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014175}
14176
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014177void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14178{
14179 hdd_adapter_t *pAdapter = callbackContext;
14180 hdd_context_t *pHddCtx;
14181
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014182 ENTER();
14183
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014184 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14185 {
14186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14187 FL("Invalid adapter or adapter has invalid magic"));
14188 return;
14189 }
14190
14191 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14192 if (0 != wlan_hdd_validate_context(pHddCtx))
14193 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014194 return;
14195 }
14196
c_hpothub53c45d2014-08-18 16:53:14 +053014197 if (VOS_STATUS_SUCCESS != status)
14198 {
14199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014200 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014201 pHddCtx->isPnoEnable = FALSE;
14202 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014203
14204 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14205 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014206 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014207}
14208
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014209/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014210 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14211 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014212 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014213static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014214 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14215{
14216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014217 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014218 hdd_context_t *pHddCtx;
14219 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014220 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014221 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14222 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014223 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14224 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014225 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014226 hdd_config_t *pConfig = NULL;
14227 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014228
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014229 ENTER();
14230
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014231 if (NULL == pAdapter)
14232 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014234 "%s: HDD adapter is Null", __func__);
14235 return -ENODEV;
14236 }
14237
14238 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014239 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014240
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014241 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014242 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014243 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014244 }
14245
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014246 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014247 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14248 if (NULL == hHal)
14249 {
14250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14251 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014252 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014253 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014254 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014255 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014256 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014257 {
14258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14259 "%s: aborting the existing scan is unsuccessfull", __func__);
14260 return -EBUSY;
14261 }
14262
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014263 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014264 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014266 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014267 return -EBUSY;
14268 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014269
c_hpothu37f21312014-04-09 21:49:54 +053014270 if (TRUE == pHddCtx->isPnoEnable)
14271 {
14272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14273 FL("already PNO is enabled"));
14274 return -EBUSY;
14275 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014276
14277 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14278 {
14279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14280 "%s: abort ROC failed ", __func__);
14281 return -EBUSY;
14282 }
14283
c_hpothu37f21312014-04-09 21:49:54 +053014284 pHddCtx->isPnoEnable = TRUE;
14285
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014286 pnoRequest.enable = 1; /*Enable PNO */
14287 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014288
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014289 if (( !pnoRequest.ucNetworksCount ) ||
14290 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014291 {
14292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014293 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014294 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014295 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014296 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014297 goto error;
14298 }
14299
14300 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14301 {
14302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014303 "%s: Incorrect number of channels %d",
14304 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014305 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014306 goto error;
14307 }
14308
14309 /* Framework provides one set of channels(all)
14310 * common for all saved profile */
14311 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14312 channels_allowed, &num_channels_allowed))
14313 {
14314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14315 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014316 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014317 goto error;
14318 }
14319 /* Checking each channel against allowed channel list */
14320 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014321 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014322 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014323 char chList [(request->n_channels*5)+1];
14324 int len;
14325 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014326 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014327 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014328 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014329 if (request->channels[i]->hw_value == channels_allowed[indx])
14330 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014331 if ((!pConfig->enableDFSPnoChnlScan) &&
14332 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14333 {
14334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14335 "%s : Dropping DFS channel : %d",
14336 __func__,channels_allowed[indx]);
14337 num_ignore_dfs_ch++;
14338 break;
14339 }
14340
Nirav Shah80830bf2013-12-31 16:35:12 +053014341 valid_ch[num_ch++] = request->channels[i]->hw_value;
14342 len += snprintf(chList+len, 5, "%d ",
14343 request->channels[i]->hw_value);
14344 break ;
14345 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014346 }
14347 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014348 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014349
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014350 /*If all channels are DFS and dropped, then ignore the PNO request*/
14351 if (num_ignore_dfs_ch == request->n_channels)
14352 {
14353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14354 "%s : All requested channels are DFS channels", __func__);
14355 ret = -EINVAL;
14356 goto error;
14357 }
14358 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014359
14360 pnoRequest.aNetworks =
14361 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14362 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014363 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014364 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14365 FL("failed to allocate memory aNetworks %u"),
14366 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14367 goto error;
14368 }
14369 vos_mem_zero(pnoRequest.aNetworks,
14370 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14371
14372 /* Filling per profile params */
14373 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14374 {
14375 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014376 request->match_sets[i].ssid.ssid_len;
14377
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014378 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14379 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014380 {
14381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014382 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014383 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014384 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014385 goto error;
14386 }
14387
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014388 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014389 request->match_sets[i].ssid.ssid,
14390 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14392 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014393 i, pnoRequest.aNetworks[i].ssId.ssId);
14394 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14395 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14396 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014397
14398 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014399 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14400 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014401
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014402 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014403 }
14404
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014405 for (i = 0; i < request->n_ssids; i++)
14406 {
14407 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014408 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014409 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014410 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014411 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014412 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014413 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014414 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014415 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014416 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014417 break;
14418 }
14419 j++;
14420 }
14421 }
14422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14423 "Number of hidden networks being Configured = %d",
14424 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014426 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014427
14428 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14429 if (pnoRequest.p24GProbeTemplate == NULL)
14430 {
14431 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14432 FL("failed to allocate memory p24GProbeTemplate %u"),
14433 SIR_PNO_MAX_PB_REQ_SIZE);
14434 goto error;
14435 }
14436
14437 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14438 if (pnoRequest.p5GProbeTemplate == NULL)
14439 {
14440 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14441 FL("failed to allocate memory p5GProbeTemplate %u"),
14442 SIR_PNO_MAX_PB_REQ_SIZE);
14443 goto error;
14444 }
14445
14446 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14447 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14448
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014449 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14450 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014451 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014452 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14453 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14454 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014455
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014456 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14457 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14458 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014459 }
14460
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014461 /* Driver gets only one time interval which is hardcoded in
14462 * supplicant for 10000ms. Taking power consumption into account 6 timers
14463 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14464 * 80,160,320 secs. And number of scan cycle for each timer
14465 * is configurable through INI param gPNOScanTimerRepeatValue.
14466 * If it is set to 0 only one timer will be used and PNO scan cycle
14467 * will be repeated after each interval specified by supplicant
14468 * till PNO is disabled.
14469 */
14470 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014471 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014472 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014473 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014474 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14475
14476 tempInterval = (request->interval)/1000;
14477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14478 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14479 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014480 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014481 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014482 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014483 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014484 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014485 tempInterval *= 2;
14486 }
14487 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014488 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014489
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014490 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014491
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014492 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014493 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14494 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014495 pAdapter->pno_req_status = 0;
14496
Nirav Shah80830bf2013-12-31 16:35:12 +053014497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14498 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014499 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14500 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014501
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014502 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014503 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014504 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14505 if (eHAL_STATUS_SUCCESS != status)
14506 {
14507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014508 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014509 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014510 goto error;
14511 }
14512
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014513 ret = wait_for_completion_timeout(
14514 &pAdapter->pno_comp_var,
14515 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14516 if (0 >= ret)
14517 {
14518 // Did not receive the response for PNO enable in time.
14519 // Assuming the PNO enable was success.
14520 // Returning error from here, because we timeout, results
14521 // in side effect of Wifi (Wifi Setting) not to work.
14522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14523 FL("Timed out waiting for PNO to be Enabled"));
14524 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014525 }
14526
14527 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014528 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014529
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014530error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14532 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014533 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014534 if (pnoRequest.aNetworks)
14535 vos_mem_free(pnoRequest.aNetworks);
14536 if (pnoRequest.p24GProbeTemplate)
14537 vos_mem_free(pnoRequest.p24GProbeTemplate);
14538 if (pnoRequest.p5GProbeTemplate)
14539 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014540
14541 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014542 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014543}
14544
14545/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014546 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14547 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014548 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014549static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14550 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14551{
14552 int ret;
14553
14554 vos_ssr_protect(__func__);
14555 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14556 vos_ssr_unprotect(__func__);
14557
14558 return ret;
14559}
14560
14561/*
14562 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14563 * Function to disable PNO
14564 */
14565static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014566 struct net_device *dev)
14567{
14568 eHalStatus status = eHAL_STATUS_FAILURE;
14569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14570 hdd_context_t *pHddCtx;
14571 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014572 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014573 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014574
14575 ENTER();
14576
14577 if (NULL == pAdapter)
14578 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014580 "%s: HDD adapter is Null", __func__);
14581 return -ENODEV;
14582 }
14583
14584 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014585
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014586 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014587 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014589 "%s: HDD context is Null", __func__);
14590 return -ENODEV;
14591 }
14592
14593 /* The return 0 is intentional when isLogpInProgress and
14594 * isLoadUnloadInProgress. We did observe a crash due to a return of
14595 * failure in sched_scan_stop , especially for a case where the unload
14596 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14597 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14598 * success. If it returns a failure , then its next invocation due to the
14599 * clean up of the second interface will have the dev pointer corresponding
14600 * to the first one leading to a crash.
14601 */
14602 if (pHddCtx->isLogpInProgress)
14603 {
14604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14605 "%s: LOGP in Progress. Ignore!!!", __func__);
14606 return ret;
14607 }
14608
Mihir Shete18156292014-03-11 15:38:30 +053014609 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014610 {
14611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14612 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14613 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014614 }
14615
14616 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14617 if (NULL == hHal)
14618 {
14619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14620 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014621 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014622 }
14623
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014624 pnoRequest.enable = 0; /* Disable PNO */
14625 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014626
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014627 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014628 pAdapter->sessionId,
14629 NULL, pAdapter);
14630 if (eHAL_STATUS_SUCCESS != status)
14631 {
14632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14633 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014634 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014635 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014636 }
c_hpothu37f21312014-04-09 21:49:54 +053014637 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014638
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014639error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014640 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014641 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014642
14643 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014644 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014645}
14646
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014647/*
14648 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14649 * NL interface to disable PNO
14650 */
14651static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14652 struct net_device *dev)
14653{
14654 int ret;
14655
14656 vos_ssr_protect(__func__);
14657 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14658 vos_ssr_unprotect(__func__);
14659
14660 return ret;
14661}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014662#endif /*FEATURE_WLAN_SCAN_PNO*/
14663
14664
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014665#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014666#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014667static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014668 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014669 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14670#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014671static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014672 u8 *peer, u8 action_code, u8 dialog_token,
14673 u16 status_code, const u8 *buf, size_t len)
14674#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014675{
14676
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014677 hdd_adapter_t *pAdapter;
14678 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014679 u8 peerMac[6];
14680 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014681 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014682 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014683 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014684 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014685#if !(TDLS_MGMT_VERSION2)
14686 u32 peer_capability = 0;
14687#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014688 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014689
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014690 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14691 if (NULL == pAdapter)
14692 {
14693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14694 "%s: Adapter is NULL",__func__);
14695 return -EINVAL;
14696 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014697 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14698 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14699 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014700 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014701 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014702 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014704 "Invalid arguments");
14705 return -EINVAL;
14706 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014707 if (pHddCtx->isLogpInProgress)
14708 {
14709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14710 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014711 wlan_hdd_tdls_set_link_status(pAdapter,
14712 peer,
14713 eTDLS_LINK_IDLE,
14714 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014715 return -EBUSY;
14716 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014717 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14718 {
14719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14720 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14721 return -EAGAIN;
14722 }
Hoonki Lee27511902013-03-14 18:19:06 -070014723 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014724 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014725 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014726 "%s: TDLS mode is disabled OR not enabled in FW."
14727 MAC_ADDRESS_STR " action %d declined.",
14728 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014729 return -ENOTSUPP;
14730 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014731
Hoonki Lee27511902013-03-14 18:19:06 -070014732 /* other than teardown frame, other mgmt frames are not sent if disabled */
14733 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14734 {
14735 /* if tdls_mode is disabled to respond to peer's request */
14736 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14737 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014739 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014740 " TDLS mode is disabled. action %d declined.",
14741 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014742
14743 return -ENOTSUPP;
14744 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014745
14746 if (vos_max_concurrent_connections_reached())
14747 {
14748 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14749 return -EINVAL;
14750 }
Hoonki Lee27511902013-03-14 18:19:06 -070014751 }
14752
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014753 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14754 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014755 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014756 {
14757 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014758 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014759 " TDLS setup is ongoing. action %d declined.",
14760 __func__, MAC_ADDR_ARRAY(peer), action_code);
14761 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014762 }
14763 }
14764
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014765 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14766 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014767 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014768 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14769 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014770 {
14771 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14772 we return error code at 'add_station()'. Hence we have this
14773 check again in addtion to add_station().
14774 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014775 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014776 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14778 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014779 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14780 __func__, MAC_ADDR_ARRAY(peer), action_code,
14781 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014782 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014783 }
14784 else
14785 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014786 /* maximum reached. tweak to send error code to peer and return
14787 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014788 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014789 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14790 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014791 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14792 __func__, MAC_ADDR_ARRAY(peer), status_code,
14793 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014794 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014795 /* fall through to send setup resp with failure status
14796 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014797 }
14798 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014799 else
14800 {
14801 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014802 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014803 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014804 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014806 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14807 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014808 return -EPERM;
14809 }
14810 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014811 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014812 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014813
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014814 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014815 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014816 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14817 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014818
Hoonki Leea34dd892013-02-05 22:56:02 -080014819 /*Except teardown responder will not be used so just make 0*/
14820 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014821 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014822 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014823
14824 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014825 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014826
14827 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14828 responder = pTdlsPeer->is_responder;
14829 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014830 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014831 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014832 "%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 -070014833 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14834 dialog_token, status_code, len);
14835 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014836 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014837 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014838
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014839 /* For explicit trigger of DIS_REQ come out of BMPS for
14840 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014841 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014842 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14843 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014844 {
14845 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14846 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014848 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014849 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14850 if (status != VOS_STATUS_SUCCESS) {
14851 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
14852 }
Hoonki Lee14621352013-04-16 17:51:19 -070014853 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014854 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
14855 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
14856 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
14857 }
14858 }
Hoonki Lee14621352013-04-16 17:51:19 -070014859 }
14860
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014861 /* make sure doesn't call send_mgmt() while it is pending */
14862 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
14863 {
14864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014865 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014866 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014867 ret = -EBUSY;
14868 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014869 }
14870
14871 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014872 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
14873
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014874 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053014875 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014876
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014877 if (VOS_STATUS_SUCCESS != status)
14878 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14880 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014881 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014882 ret = -EINVAL;
14883 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014884 }
14885
Hoonki Leed37cbb32013-04-20 00:31:14 -070014886 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
14887 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
14888
14889 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014890 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070014891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014892 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070014893 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014894 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080014895
14896 if (pHddCtx->isLogpInProgress)
14897 {
14898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14899 "%s: LOGP in Progress. Ignore!!!", __func__);
14900 return -EAGAIN;
14901 }
14902
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014903 ret = -EINVAL;
14904 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014905 }
14906
Gopichand Nakkala05922802013-03-14 12:23:19 -070014907 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070014908 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014909 ret = max_sta_failed;
14910 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070014911 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014912
Hoonki Leea34dd892013-02-05 22:56:02 -080014913 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
14914 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014915 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
14916 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14917 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014918 }
14919 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
14920 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014921 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
14922 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14923 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014924 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014925
14926 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014927
14928tx_failed:
14929 /* add_station will be called before sending TDLS_SETUP_REQ and
14930 * TDLS_SETUP_RSP and as part of add_station driver will enable
14931 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
14932 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
14933 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
14934 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
14935 */
14936
14937 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
14938 (SIR_MAC_TDLS_SETUP_RSP == action_code))
14939 wlan_hdd_tdls_check_bmps(pAdapter);
14940 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014941}
14942
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014943#if TDLS_MGMT_VERSION2
14944static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14945 u8 *peer, u8 action_code, u8 dialog_token,
14946 u16 status_code, u32 peer_capability,
14947 const u8 *buf, size_t len)
14948#else
14949static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14950 u8 *peer, u8 action_code, u8 dialog_token,
14951 u16 status_code, const u8 *buf, size_t len)
14952#endif
14953{
14954 int ret;
14955
14956 vos_ssr_protect(__func__);
14957#if TDLS_MGMT_VERSION2
14958 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14959 status_code, peer_capability, buf, len);
14960#else
14961 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14962 status_code, buf, len);
14963#endif
14964 vos_ssr_unprotect(__func__);
14965
14966 return ret;
14967}
Atul Mittal115287b2014-07-08 13:26:33 +053014968
14969int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
14970 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014971 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053014972 cfg80211_exttdls_callback callback)
14973{
14974
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014975 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053014976 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053014977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053014978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14979 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
14980 __func__, MAC_ADDR_ARRAY(peer));
14981
14982 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
14983 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
14984
14985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014986 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
14987 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
14988 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053014989 return -ENOTSUPP;
14990 }
14991
14992 /* To cater the requirement of establishing the TDLS link
14993 * irrespective of the data traffic , get an entry of TDLS peer.
14994 */
14995 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
14996 if (pTdlsPeer == NULL) {
14997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14998 "%s: peer " MAC_ADDRESS_STR " not existing",
14999 __func__, MAC_ADDR_ARRAY(peer));
15000 return -EINVAL;
15001 }
15002
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015003 /* check FW TDLS Off Channel capability */
15004 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
15005 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015006 {
15007 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15008 pTdlsPeer->peerParams.global_operating_class =
15009 tdls_peer_params->global_operating_class;
15010 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15011 pTdlsPeer->peerParams.min_bandwidth_kbps =
15012 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015013 /* check configured channel is valid, non dfs and
15014 * not current operating channel */
15015 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15016 tdls_peer_params->channel)) &&
15017 (pHddStaCtx) &&
15018 (tdls_peer_params->channel !=
15019 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015020 {
15021 pTdlsPeer->isOffChannelConfigured = TRUE;
15022 }
15023 else
15024 {
15025 pTdlsPeer->isOffChannelConfigured = FALSE;
15026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15027 "%s: Configured Tdls Off Channel is not valid", __func__);
15028
15029 }
15030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015031 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15032 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015033 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015034 pTdlsPeer->isOffChannelConfigured,
15035 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015036 }
15037 else
15038 {
15039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015040 "%s: TDLS off channel FW capability %d or "
15041 "Invalid TDLS Peer Params", __func__,
15042 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015043 }
15044
Atul Mittal115287b2014-07-08 13:26:33 +053015045 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15046
15047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15048 " %s TDLS Add Force Peer Failed",
15049 __func__);
15050 return -EINVAL;
15051 }
15052 /*EXT TDLS*/
15053
15054 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15056 " %s TDLS set callback Failed",
15057 __func__);
15058 return -EINVAL;
15059 }
15060
15061 return(0);
15062
15063}
15064
15065int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15066{
15067
15068 hddTdlsPeer_t *pTdlsPeer;
15069 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15071 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15072 __func__, MAC_ADDR_ARRAY(peer));
15073
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015074 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15075 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15076 return -EINVAL;
15077 }
15078
Atul Mittal115287b2014-07-08 13:26:33 +053015079 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15080 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15081
15082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015083 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15084 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15085 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015086 return -ENOTSUPP;
15087 }
15088
15089
15090 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15091
15092 if ( NULL == pTdlsPeer ) {
15093 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
15094 " peer not exsting",
15095 __func__, MAC_ADDR_ARRAY(peer));
15096 return -EINVAL;
15097 }
15098 else {
15099 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15100 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015101 /* if channel switch is configured, reset
15102 the channel for this peer */
15103 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15104 {
15105 pTdlsPeer->peerParams.channel = 0;
15106 pTdlsPeer->isOffChannelConfigured = FALSE;
15107 }
Atul Mittal115287b2014-07-08 13:26:33 +053015108 }
15109
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015110 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15111 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015112 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015113 }
Atul Mittal115287b2014-07-08 13:26:33 +053015114
15115 /*EXT TDLS*/
15116
15117 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15118
15119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15120 " %s TDLS set callback Failed",
15121 __func__);
15122 return -EINVAL;
15123 }
15124 return(0);
15125
15126}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015127static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015128 u8 *peer, enum nl80211_tdls_operation oper)
15129{
15130 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15131 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015132 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015133 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015134
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015135 ENTER();
15136
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015137 if (!pAdapter) {
15138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15139 return -EINVAL;
15140 }
15141
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015142 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15143 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15144 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015145 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015146 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015148 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015149 return -EINVAL;
15150 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015151
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015152 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015153 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015154 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015155 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015156 }
15157
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015158
15159 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015160 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015161 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015163 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15164 "Cannot process TDLS commands",
15165 pHddCtx->cfg_ini->fEnableTDLSSupport,
15166 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015167 return -ENOTSUPP;
15168 }
15169
15170 switch (oper) {
15171 case NL80211_TDLS_ENABLE_LINK:
15172 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015173 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015174 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015175 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015176 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015177 tANI_U16 numCurrTdlsPeers = 0;
15178 hddTdlsPeer_t *connPeer = NULL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015179
Sunil Dutt41de4e22013-11-14 18:09:02 +053015180 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015181 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015182 if ( NULL == pTdlsPeer ) {
15183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15184 " (oper %d) not exsting. ignored",
15185 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15186 return -EINVAL;
15187 }
15188
15189 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15190 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15191 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15192 "NL80211_TDLS_ENABLE_LINK");
15193
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015194 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15195 {
15196 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15197 MAC_ADDRESS_STR " failed",
15198 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15199 return -EINVAL;
15200 }
15201
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015202 /* TDLS Off Channel, Disable tdls channel switch,
15203 when there are more than one tdls link */
15204 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015205 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015206 {
15207 /* get connected peer and send disable tdls off chan */
15208 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15209 if (connPeer && (connPeer->isOffChannelConfigured == TRUE))
15210 {
15211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15212 "%s: More then one peer connected, Disable "
15213 "TDLS channel switch", __func__);
15214
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015215 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015216 ret = sme_SendTdlsChanSwitchReq(
15217 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015218 pAdapter->sessionId,
15219 connPeer->peerMac,
15220 connPeer->peerParams.channel,
15221 TDLS_OFF_CHANNEL_BW_OFFSET,
15222 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015223 if (ret != VOS_STATUS_SUCCESS) {
15224 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel request"));
15225 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015226 }
15227 else
15228 {
15229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15230 "%s: No TDLS Connected Peer or "
15231 "isOffChannelConfigured %d",
15232 __func__,
15233 (connPeer ? connPeer->isOffChannelConfigured : -1));
15234 }
15235 }
15236
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015237 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015238 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015239 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015240
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015241 if (0 != wlan_hdd_tdls_get_link_establish_params(
15242 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015244 return -EINVAL;
15245 }
15246 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015247
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015248 ret = sme_SendTdlsLinkEstablishParams(
15249 WLAN_HDD_GET_HAL_CTX(pAdapter),
15250 pAdapter->sessionId, peer,
15251 &tdlsLinkEstablishParams);
15252 if (ret != VOS_STATUS_SUCCESS) {
15253 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15254 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015255 /* Send TDLS peer UAPSD capabilities to the firmware and
15256 * register with the TL on after the response for this operation
15257 * is received .
15258 */
15259 ret = wait_for_completion_interruptible_timeout(
15260 &pAdapter->tdls_link_establish_req_comp,
15261 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15262 if (ret <= 0)
15263 {
15264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15265 "%s: Link Establish Request Faled Status %ld",
15266 __func__, ret);
15267 return -EINVAL;
15268 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015269 }
Atul Mittal115287b2014-07-08 13:26:33 +053015270 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15271 eTDLS_LINK_CONNECTED,
15272 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015273 staDesc.ucSTAId = pTdlsPeer->staId;
15274 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015275 ret = WLANTL_UpdateTdlsSTAClient(
15276 pHddCtx->pvosContext,
15277 &staDesc);
15278 if (ret != VOS_STATUS_SUCCESS) {
15279 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15280 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015281
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015282 /* Mark TDLS client Authenticated .*/
15283 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15284 pTdlsPeer->staId,
15285 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015286 if (VOS_STATUS_SUCCESS == status)
15287 {
Hoonki Lee14621352013-04-16 17:51:19 -070015288 if (pTdlsPeer->is_responder == 0)
15289 {
15290 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15291
15292 wlan_hdd_tdls_timer_restart(pAdapter,
15293 &pTdlsPeer->initiatorWaitTimeoutTimer,
15294 WAIT_TIME_TDLS_INITIATOR);
15295 /* suspend initiator TX until it receives direct packet from the
15296 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015297 ret = WLANTL_SuspendDataTx(
15298 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15299 &staId, NULL);
15300 if (ret != VOS_STATUS_SUCCESS) {
15301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15302 }
Hoonki Lee14621352013-04-16 17:51:19 -070015303 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015304
15305 /* TDLS Off Channel, Enable tdls channel switch,
15306 when their is only one tdls link and it supports */
15307 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15308 if ((numCurrTdlsPeers == 1) &&
15309 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15310 (TRUE == pTdlsPeer->isOffChannelConfigured))
15311 {
15312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15313 "%s: Send TDLS channel switch request for channel %d",
15314 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015315
15316 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015317 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15318 pAdapter->sessionId,
15319 pTdlsPeer->peerMac,
15320 pTdlsPeer->peerParams.channel,
15321 TDLS_OFF_CHANNEL_BW_OFFSET,
15322 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015323 if (ret != VOS_STATUS_SUCCESS) {
15324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15325 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015326 }
15327 else
15328 {
15329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15330 "%s: TDLS channel switch request not sent"
15331 " numCurrTdlsPeers %d "
15332 "isOffChannelSupported %d "
15333 "isOffChannelConfigured %d",
15334 __func__, numCurrTdlsPeers,
15335 pTdlsPeer->isOffChannelSupported,
15336 pTdlsPeer->isOffChannelConfigured);
15337 }
15338
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015339 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015340 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015341
15342 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015343 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15344 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015345 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015346 int ac;
15347 uint8 ucAc[4] = { WLANTL_AC_VO,
15348 WLANTL_AC_VI,
15349 WLANTL_AC_BK,
15350 WLANTL_AC_BE };
15351 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15352 for(ac=0; ac < 4; ac++)
15353 {
15354 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15355 pTdlsPeer->staId, ucAc[ac],
15356 tlTid[ac], tlTid[ac], 0, 0,
15357 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015358 if (status != VOS_STATUS_SUCCESS) {
15359 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15360 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015361 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015362 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015363 }
15364
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015365 }
15366 break;
15367 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015368 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015369 tANI_U16 numCurrTdlsPeers = 0;
15370 hddTdlsPeer_t *connPeer = NULL;
15371
Sunil Dutt41de4e22013-11-14 18:09:02 +053015372 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15373
15374 if ( NULL == pTdlsPeer ) {
15375 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15376 " (oper %d) not exsting. ignored",
15377 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15378 return -EINVAL;
15379 }
15380
15381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15382 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15383 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15384 "NL80211_TDLS_DISABLE_LINK");
15385
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015386 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015387 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015388 long status;
15389
Atul Mittal271a7652014-09-12 13:18:22 +053015390
15391 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15392 eTDLS_LINK_TEARING,
15393 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15394 eTDLS_LINK_UNSPECIFIED:
15395 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015396 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15397
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015398 status = sme_DeleteTdlsPeerSta(
15399 WLAN_HDD_GET_HAL_CTX(pAdapter),
15400 pAdapter->sessionId, peer );
15401 if (status != VOS_STATUS_SUCCESS) {
15402 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15403 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015404
15405 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15406 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015407 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015408 eTDLS_LINK_IDLE,
15409 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015410 if (status <= 0)
15411 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15413 "%s: Del station failed status %ld",
15414 __func__, status);
15415 return -EPERM;
15416 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015417
15418 /* TDLS Off Channel, Enable tdls channel switch,
15419 when their is only one tdls link and it supports */
15420 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15421 if (numCurrTdlsPeers == 1)
15422 {
15423 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15424 if ((connPeer) &&
15425 (connPeer->isOffChannelSupported == TRUE) &&
15426 (connPeer->isOffChannelConfigured == TRUE))
15427 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015428 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015429 status = sme_SendTdlsChanSwitchReq(
15430 WLAN_HDD_GET_HAL_CTX(pAdapter),
15431 pAdapter->sessionId,
15432 connPeer->peerMac,
15433 connPeer->peerParams.channel,
15434 TDLS_OFF_CHANNEL_BW_OFFSET,
15435 TDLS_CHANNEL_SWITCH_ENABLE);
15436 if (status != VOS_STATUS_SUCCESS) {
15437 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15438 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015439 }
15440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15441 "%s: TDLS channel switch "
15442 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015443 "isOffChannelConfigured %d "
15444 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015445 __func__,
15446 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015447 (connPeer ? connPeer->isOffChannelConfigured : -1),
15448 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015449 }
15450 else
15451 {
15452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15453 "%s: TDLS channel switch request not sent "
15454 "numCurrTdlsPeers %d ",
15455 __func__, numCurrTdlsPeers);
15456 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015457 }
15458 else
15459 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15461 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015462 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015463 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015464 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015465 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015466 {
Atul Mittal115287b2014-07-08 13:26:33 +053015467 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015468
Atul Mittal115287b2014-07-08 13:26:33 +053015469 if (0 != status)
15470 {
15471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15472 "%s: Error in TDLS Teardown", __func__);
15473 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015474 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015475 break;
15476 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015477 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015478 {
Atul Mittal115287b2014-07-08 13:26:33 +053015479 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15480 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015481 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015482 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015483
Atul Mittal115287b2014-07-08 13:26:33 +053015484 if (0 != status)
15485 {
15486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15487 "%s: Error in TDLS Setup", __func__);
15488 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015489 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015490 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015491 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015492 case NL80211_TDLS_DISCOVERY_REQ:
15493 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
15495 "%s: We don't support in-driver setup/teardown/discovery "
15496 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015497 return -ENOTSUPP;
15498 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15500 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015501 return -ENOTSUPP;
15502 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015503
15504 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015505 return 0;
15506}
Chilam NG571c65a2013-01-19 12:27:36 +053015507
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015508static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15509 u8 *peer, enum nl80211_tdls_operation oper)
15510{
15511 int ret;
15512
15513 vos_ssr_protect(__func__);
15514 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15515 vos_ssr_unprotect(__func__);
15516
15517 return ret;
15518}
15519
Chilam NG571c65a2013-01-19 12:27:36 +053015520int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15521 struct net_device *dev, u8 *peer)
15522{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015523 hddLog(VOS_TRACE_LEVEL_INFO,
15524 "tdls send discover req: "MAC_ADDRESS_STR,
15525 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015526
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015527#if TDLS_MGMT_VERSION2
15528 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15529 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15530#else
Chilam NG571c65a2013-01-19 12:27:36 +053015531 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15532 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015533#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015534}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015535#endif
15536
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015537#ifdef WLAN_FEATURE_GTK_OFFLOAD
15538/*
15539 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15540 * Callback rountine called upon receiving response for
15541 * get offload info
15542 */
15543void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15544 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15545{
15546
15547 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015548 tANI_U8 tempReplayCounter[8];
15549 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015550
15551 ENTER();
15552
15553 if (NULL == pAdapter)
15554 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015555 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015556 "%s: HDD adapter is Null", __func__);
15557 return ;
15558 }
15559
15560 if (NULL == pGtkOffloadGetInfoRsp)
15561 {
15562 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15563 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15564 return ;
15565 }
15566
15567 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15568 {
15569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15570 "%s: wlan Failed to get replay counter value",
15571 __func__);
15572 return ;
15573 }
15574
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015575 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15576 /* Update replay counter */
15577 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15578 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15579
15580 {
15581 /* changing from little to big endian since supplicant
15582 * works on big endian format
15583 */
15584 int i;
15585 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15586
15587 for (i = 0; i < 8; i++)
15588 {
15589 tempReplayCounter[7-i] = (tANI_U8)p[i];
15590 }
15591 }
15592
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015593 /* Update replay counter to NL */
15594 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015595 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015596}
15597
15598/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015599 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015600 * This function is used to offload GTK rekeying job to the firmware.
15601 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015602int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015603 struct cfg80211_gtk_rekey_data *data)
15604{
15605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15606 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15607 hdd_station_ctx_t *pHddStaCtx;
15608 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015609 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015610 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015611 eHalStatus status = eHAL_STATUS_FAILURE;
15612
15613 ENTER();
15614
15615 if (NULL == pAdapter)
15616 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015618 "%s: HDD adapter is Null", __func__);
15619 return -ENODEV;
15620 }
15621
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015622 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15623 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15624 pAdapter->sessionId, pAdapter->device_mode));
15625
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015626 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015627 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015628 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015629 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015630 }
15631
15632 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15633 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15634 if (NULL == hHal)
15635 {
15636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15637 "%s: HAL context is Null!!!", __func__);
15638 return -EAGAIN;
15639 }
15640
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015641 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15642 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15643 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15644 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015645 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015646 {
15647 /* changing from big to little endian since driver
15648 * works on little endian format
15649 */
15650 tANI_U8 *p =
15651 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15652 int i;
15653
15654 for (i = 0; i < 8; i++)
15655 {
15656 p[7-i] = data->replay_ctr[i];
15657 }
15658 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015659
15660 if (TRUE == pHddCtx->hdd_wlan_suspended)
15661 {
15662 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015663 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15664 sizeof (tSirGtkOffloadParams));
15665 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015666 pAdapter->sessionId);
15667
15668 if (eHAL_STATUS_SUCCESS != status)
15669 {
15670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15671 "%s: sme_SetGTKOffload failed, returned %d",
15672 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015673
15674 /* Need to clear any trace of key value in the memory.
15675 * Thus zero out the memory even though it is local
15676 * variable.
15677 */
15678 vos_mem_zero(&hddGtkOffloadReqParams,
15679 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015680 return status;
15681 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15683 "%s: sme_SetGTKOffload successfull", __func__);
15684 }
15685 else
15686 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15688 "%s: wlan not suspended GTKOffload request is stored",
15689 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015690 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015691
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015692 /* Need to clear any trace of key value in the memory.
15693 * Thus zero out the memory even though it is local
15694 * variable.
15695 */
15696 vos_mem_zero(&hddGtkOffloadReqParams,
15697 sizeof(hddGtkOffloadReqParams));
15698
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015699 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015700 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015701}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015702
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015703int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15704 struct cfg80211_gtk_rekey_data *data)
15705{
15706 int ret;
15707
15708 vos_ssr_protect(__func__);
15709 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15710 vos_ssr_unprotect(__func__);
15711
15712 return ret;
15713}
15714#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015715/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015716 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015717 * This function is used to set access control policy
15718 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015719static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15720 struct net_device *dev,
15721 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015722{
15723 int i;
15724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15725 hdd_hostapd_state_t *pHostapdState;
15726 tsap_Config_t *pConfig;
15727 v_CONTEXT_t pVosContext = NULL;
15728 hdd_context_t *pHddCtx;
15729 int status;
15730
15731 ENTER();
15732
15733 if (NULL == pAdapter)
15734 {
15735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15736 "%s: HDD adapter is Null", __func__);
15737 return -ENODEV;
15738 }
15739
15740 if (NULL == params)
15741 {
15742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15743 "%s: params is Null", __func__);
15744 return -EINVAL;
15745 }
15746
15747 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15748 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015749 if (0 != status)
15750 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015751 return status;
15752 }
15753
15754 pVosContext = pHddCtx->pvosContext;
15755 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15756
15757 if (NULL == pHostapdState)
15758 {
15759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15760 "%s: pHostapdState is Null", __func__);
15761 return -EINVAL;
15762 }
15763
15764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15765 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
15766
15767 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15768 {
15769 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15770
15771 /* default value */
15772 pConfig->num_accept_mac = 0;
15773 pConfig->num_deny_mac = 0;
15774
15775 /**
15776 * access control policy
15777 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15778 * listed in hostapd.deny file.
15779 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15780 * listed in hostapd.accept file.
15781 */
15782 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15783 {
15784 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
15785 }
15786 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
15787 {
15788 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
15789 }
15790 else
15791 {
15792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15793 "%s:Acl Policy : %d is not supported",
15794 __func__, params->acl_policy);
15795 return -ENOTSUPP;
15796 }
15797
15798 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
15799 {
15800 pConfig->num_accept_mac = params->n_acl_entries;
15801 for (i = 0; i < params->n_acl_entries; i++)
15802 {
15803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15804 "** Add ACL MAC entry %i in WhiletList :"
15805 MAC_ADDRESS_STR, i,
15806 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15807
15808 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
15809 sizeof(qcmacaddr));
15810 }
15811 }
15812 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
15813 {
15814 pConfig->num_deny_mac = params->n_acl_entries;
15815 for (i = 0; i < params->n_acl_entries; i++)
15816 {
15817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15818 "** Add ACL MAC entry %i in BlackList :"
15819 MAC_ADDRESS_STR, i,
15820 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15821
15822 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
15823 sizeof(qcmacaddr));
15824 }
15825 }
15826
15827 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
15828 {
15829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15830 "%s: SAP Set Mac Acl fail", __func__);
15831 return -EINVAL;
15832 }
15833 }
15834 else
15835 {
15836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015837 "%s: Invalid device_mode = %s (%d)",
15838 __func__, hdd_device_modetoString(pAdapter->device_mode),
15839 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015840 return -EINVAL;
15841 }
15842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015843 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015844 return 0;
15845}
15846
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015847static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15848 struct net_device *dev,
15849 const struct cfg80211_acl_data *params)
15850{
15851 int ret;
15852 vos_ssr_protect(__func__);
15853 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
15854 vos_ssr_unprotect(__func__);
15855
15856 return ret;
15857}
15858
Leo Chang9056f462013-08-01 19:21:11 -070015859#ifdef WLAN_NL80211_TESTMODE
15860#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070015861void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070015862(
15863 void *pAdapter,
15864 void *indCont
15865)
15866{
Leo Changd9df8aa2013-09-26 13:32:26 -070015867 tSirLPHBInd *lphbInd;
15868 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053015869 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070015870
15871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015872 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070015873
c_hpothu73f35e62014-04-18 13:40:08 +053015874 if (pAdapter == NULL)
15875 {
15876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15877 "%s: pAdapter is NULL\n",__func__);
15878 return;
15879 }
15880
Leo Chang9056f462013-08-01 19:21:11 -070015881 if (NULL == indCont)
15882 {
15883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015884 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070015885 return;
15886 }
15887
c_hpothu73f35e62014-04-18 13:40:08 +053015888 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070015889 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070015890 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053015891 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070015892 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070015893 GFP_ATOMIC);
15894 if (!skb)
15895 {
15896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15897 "LPHB timeout, NL buffer alloc fail");
15898 return;
15899 }
15900
Leo Changac3ba772013-10-07 09:47:04 -070015901 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070015902 {
15903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15904 "WLAN_HDD_TM_ATTR_CMD put fail");
15905 goto nla_put_failure;
15906 }
Leo Changac3ba772013-10-07 09:47:04 -070015907 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070015908 {
15909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15910 "WLAN_HDD_TM_ATTR_TYPE put fail");
15911 goto nla_put_failure;
15912 }
Leo Changac3ba772013-10-07 09:47:04 -070015913 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070015914 sizeof(tSirLPHBInd), lphbInd))
15915 {
15916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15917 "WLAN_HDD_TM_ATTR_DATA put fail");
15918 goto nla_put_failure;
15919 }
Leo Chang9056f462013-08-01 19:21:11 -070015920 cfg80211_testmode_event(skb, GFP_ATOMIC);
15921 return;
15922
15923nla_put_failure:
15924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15925 "NLA Put fail");
15926 kfree_skb(skb);
15927
15928 return;
15929}
15930#endif /* FEATURE_WLAN_LPHB */
15931
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015932static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070015933{
15934 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
15935 int err = 0;
15936#ifdef FEATURE_WLAN_LPHB
15937 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070015938 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015939
15940 ENTER();
15941
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015942 err = wlan_hdd_validate_context(pHddCtx);
15943 if (0 != err)
15944 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015945 return err;
15946 }
Leo Chang9056f462013-08-01 19:21:11 -070015947#endif /* FEATURE_WLAN_LPHB */
15948
15949 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
15950 if (err)
15951 {
15952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15953 "%s Testmode INV ATTR", __func__);
15954 return err;
15955 }
15956
15957 if (!tb[WLAN_HDD_TM_ATTR_CMD])
15958 {
15959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15960 "%s Testmode INV CMD", __func__);
15961 return -EINVAL;
15962 }
15963
15964 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
15965 {
15966#ifdef FEATURE_WLAN_LPHB
15967 /* Low Power Heartbeat configuration request */
15968 case WLAN_HDD_TM_CMD_WLAN_HB:
15969 {
15970 int buf_len;
15971 void *buf;
15972 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080015973 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070015974
15975 if (!tb[WLAN_HDD_TM_ATTR_DATA])
15976 {
15977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15978 "%s Testmode INV DATA", __func__);
15979 return -EINVAL;
15980 }
15981
15982 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
15983 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080015984
15985 hb_params_temp =(tSirLPHBReq *)buf;
15986 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
15987 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
15988 return -EINVAL;
15989
Leo Chang9056f462013-08-01 19:21:11 -070015990 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
15991 if (NULL == hb_params)
15992 {
15993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15994 "%s Request Buffer Alloc Fail", __func__);
15995 return -EINVAL;
15996 }
15997
15998 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070015999 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16000 hb_params,
16001 wlan_hdd_cfg80211_lphb_ind_handler);
16002 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016003 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16005 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016006 vos_mem_free(hb_params);
16007 }
Leo Chang9056f462013-08-01 19:21:11 -070016008 return 0;
16009 }
16010#endif /* FEATURE_WLAN_LPHB */
16011 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16013 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016014 return -EOPNOTSUPP;
16015 }
16016
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016017 EXIT();
16018 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016019}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016020
16021static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16022{
16023 int ret;
16024
16025 vos_ssr_protect(__func__);
16026 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16027 vos_ssr_unprotect(__func__);
16028
16029 return ret;
16030}
Leo Chang9056f462013-08-01 19:21:11 -070016031#endif /* CONFIG_NL80211_TESTMODE */
16032
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016033static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016034 struct net_device *dev,
16035 int idx, struct survey_info *survey)
16036{
16037 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16038 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016039 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016040 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016041 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016042 v_S7_t snr,rssi;
16043 int status, i, j, filled = 0;
16044
16045 ENTER();
16046
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016047 if (NULL == pAdapter)
16048 {
16049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16050 "%s: HDD adapter is Null", __func__);
16051 return -ENODEV;
16052 }
16053
16054 if (NULL == wiphy)
16055 {
16056 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16057 "%s: wiphy is Null", __func__);
16058 return -ENODEV;
16059 }
16060
16061 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16062 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016063 if (0 != status)
16064 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016065 return status;
16066 }
16067
Mihir Sheted9072e02013-08-21 17:02:29 +053016068 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16069
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016070 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016071 0 != pAdapter->survey_idx ||
16072 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016073 {
16074 /* The survey dump ops when implemented completely is expected to
16075 * return a survey of all channels and the ops is called by the
16076 * kernel with incremental values of the argument 'idx' till it
16077 * returns -ENONET. But we can only support the survey for the
16078 * operating channel for now. survey_idx is used to track
16079 * that the ops is called only once and then return -ENONET for
16080 * the next iteration
16081 */
16082 pAdapter->survey_idx = 0;
16083 return -ENONET;
16084 }
16085
16086 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16087
16088 wlan_hdd_get_snr(pAdapter, &snr);
16089 wlan_hdd_get_rssi(pAdapter, &rssi);
16090
16091 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16092 hdd_wlan_get_freq(channel, &freq);
16093
16094
16095 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16096 {
16097 if (NULL == wiphy->bands[i])
16098 {
16099 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16100 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16101 continue;
16102 }
16103
16104 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16105 {
16106 struct ieee80211_supported_band *band = wiphy->bands[i];
16107
16108 if (band->channels[j].center_freq == (v_U16_t)freq)
16109 {
16110 survey->channel = &band->channels[j];
16111 /* The Rx BDs contain SNR values in dB for the received frames
16112 * while the supplicant expects noise. So we calculate and
16113 * return the value of noise (dBm)
16114 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16115 */
16116 survey->noise = rssi - snr;
16117 survey->filled = SURVEY_INFO_NOISE_DBM;
16118 filled = 1;
16119 }
16120 }
16121 }
16122
16123 if (filled)
16124 pAdapter->survey_idx = 1;
16125 else
16126 {
16127 pAdapter->survey_idx = 0;
16128 return -ENONET;
16129 }
16130
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016131 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016132 return 0;
16133}
16134
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016135static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16136 struct net_device *dev,
16137 int idx, struct survey_info *survey)
16138{
16139 int ret;
16140
16141 vos_ssr_protect(__func__);
16142 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16143 vos_ssr_unprotect(__func__);
16144
16145 return ret;
16146}
16147
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016148/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016149 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016150 * this is called when cfg80211 driver resume
16151 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16152 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016153int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016154{
16155 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16156 hdd_adapter_t *pAdapter;
16157 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16158 VOS_STATUS status = VOS_STATUS_SUCCESS;
16159
16160 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016161
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016162 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016163 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016164 return 0;
16165 }
16166
16167 spin_lock(&pHddCtx->schedScan_lock);
16168 pHddCtx->isWiphySuspended = FALSE;
16169 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16170 {
16171 spin_unlock(&pHddCtx->schedScan_lock);
16172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16173 "%s: Return resume is not due to PNO indication", __func__);
16174 return 0;
16175 }
16176 // Reset flag to avoid updatating cfg80211 data old results again
16177 pHddCtx->isSchedScanUpdatePending = FALSE;
16178 spin_unlock(&pHddCtx->schedScan_lock);
16179
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016180
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016181 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16182
16183 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16184 {
16185 pAdapter = pAdapterNode->pAdapter;
16186 if ( (NULL != pAdapter) &&
16187 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16188 {
16189 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016190 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16192 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016193 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016194 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016195 {
16196 /* Acquire wakelock to handle the case where APP's tries to
16197 * suspend immediately after updating the scan results. Whis
16198 * results in app's is in suspended state and not able to
16199 * process the connect request to AP
16200 */
16201 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016202 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016203 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016204
16205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16206 "%s : cfg80211 scan result database updated", __func__);
16207
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016208 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016209 return 0;
16210
16211 }
16212 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16213 pAdapterNode = pNext;
16214 }
16215
16216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16217 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016218 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016219 return 0;
16220}
16221
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016222int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16223{
16224 int ret;
16225
16226 vos_ssr_protect(__func__);
16227 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16228 vos_ssr_unprotect(__func__);
16229
16230 return ret;
16231}
16232
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016233/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016234 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016235 * this is called when cfg80211 driver suspends
16236 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016237int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016238 struct cfg80211_wowlan *wow)
16239{
16240 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016241 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016242
16243 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016244
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016245 ret = wlan_hdd_validate_context(pHddCtx);
16246 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016247 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016248 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016249 }
16250
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016251
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016252 pHddCtx->isWiphySuspended = TRUE;
16253
16254 EXIT();
16255
16256 return 0;
16257}
16258
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016259int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16260 struct cfg80211_wowlan *wow)
16261{
16262 int ret;
16263
16264 vos_ssr_protect(__func__);
16265 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16266 vos_ssr_unprotect(__func__);
16267
16268 return ret;
16269}
Jeff Johnson295189b2012-06-20 16:38:30 -070016270/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016271static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016272{
16273 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16274 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16275 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16276 .change_station = wlan_hdd_change_station,
16277#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16278 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16279 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16280 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016281#else
16282 .start_ap = wlan_hdd_cfg80211_start_ap,
16283 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16284 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016285#endif
16286 .change_bss = wlan_hdd_cfg80211_change_bss,
16287 .add_key = wlan_hdd_cfg80211_add_key,
16288 .get_key = wlan_hdd_cfg80211_get_key,
16289 .del_key = wlan_hdd_cfg80211_del_key,
16290 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016291#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016292 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016293#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 .scan = wlan_hdd_cfg80211_scan,
16295 .connect = wlan_hdd_cfg80211_connect,
16296 .disconnect = wlan_hdd_cfg80211_disconnect,
16297 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16298 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16299 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16300 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16301 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016302 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16303 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016304 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016305#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16306 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16307 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16308 .set_txq_params = wlan_hdd_set_txq_params,
16309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 .get_station = wlan_hdd_cfg80211_get_station,
16311 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16312 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016313 .add_station = wlan_hdd_cfg80211_add_station,
16314#ifdef FEATURE_WLAN_LFR
16315 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16316 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16317 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16318#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016319#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16320 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16321#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016322#ifdef FEATURE_WLAN_TDLS
16323 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16324 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16325#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016326#ifdef WLAN_FEATURE_GTK_OFFLOAD
16327 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16328#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016329#ifdef FEATURE_WLAN_SCAN_PNO
16330 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16331 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16332#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016333 .resume = wlan_hdd_cfg80211_resume_wlan,
16334 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016335 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016336#ifdef WLAN_NL80211_TESTMODE
16337 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16338#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016339 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016340};
16341