blob: abd40270d7112eea2d6ac98fdd09075dcce23e34 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Jeff Johnson295189b2012-06-20 16:38:30 -0700175
176/* Private ioctls and their sub-ioctls */
177#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
178#define WE_GET_11D_STATE 1
179#define WE_IBSS_STATUS 2
180#define WE_PMC_STATE 3
181#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#define WE_GET_MAX_ASSOC 6
183#define WE_GET_WDI_DBG 7
184#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
185#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530186#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700187/* Private ioctls and their sub-ioctls */
188#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
189
190/* Private ioctls and their sub-ioctls */
191#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
192#define WE_WOWL_ADD_PTRN 1
193#define WE_WOWL_DEL_PTRN 2
194#if defined WLAN_FEATURE_VOWIFI
195#define WE_NEIGHBOR_REPORT_REQUEST 3
196#endif
197#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
198#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530199#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
203#define WE_SET_WLAN_DBG 1
204#define WE_SET_WDI_DBG 2
205#define WE_SET_SAP_CHANNELS 3
206
207/* Private ioctls and their sub-ioctls */
208#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
209#define WE_WLAN_VERSION 1
210#define WE_GET_STATS 2
211#define WE_GET_CFG 3
212#define WE_GET_WMM_STATUS 4
213#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700214#ifdef WLAN_FEATURE_11AC
215#define WE_GET_RSSI 6
216#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800217#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800218#ifdef FEATURE_WLAN_TDLS
219#define WE_GET_TDLS_PEERS 8
220#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700221#ifdef WLAN_FEATURE_11W
222#define WE_GET_11W_INFO 9
223#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530224#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530225#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
227/* Private ioctls and their sub-ioctls */
228#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
229#define WE_CLEAR_STATS 1
230#define WE_INIT_AP 2
231#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530232#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700233#define WE_ENABLE_AMP 4
234#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530235#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700236#define WE_ENABLE_DXE_STALL_DETECT 6
237#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700238#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530239#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530240#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530241#define WE_DUMP_ROAM_TIMER_LOG 12
242#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530243#define WE_GET_FW_LOGS 14
Mukul Sharma84f27252014-07-14 18:11:42 +0530244
Jeff Johnson295189b2012-06-20 16:38:30 -0700245/* Private ioctls and their sub-ioctls */
246#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
247#define WE_LOG_DUMP_CMD 1
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800250//IOCTL to configure MCC params
251#define WE_MCC_CONFIG_CREDENTIAL 3
252#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
Chilam NG571c65a2013-01-19 12:27:36 +0530254#ifdef FEATURE_WLAN_TDLS
255#define WE_TDLS_CONFIG_PARAMS 5
256#endif
257
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700258#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530259#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530260#define WE_CONFIGURE_MONITOR_MODE 10
261#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700262
Chilam Ng01120412013-02-19 18:32:21 -0800263#ifdef FEATURE_WLAN_TDLS
264#undef MAX_VAR_ARGS
265#define MAX_VAR_ARGS 10
266#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700267#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800268#endif
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270/* Private ioctls (with no sub-ioctls) */
271/* note that they must be odd so that they have "get" semantics */
272#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
273#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
274#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
275
Girish Gowli464c9c82014-06-09 19:47:53 +0530276/* (SIOCIWFIRSTPRIV + 8) is currently unused */
277/* (SIOCIWFIRSTPRIV + 16) is currently unused */
278/* (SIOCIWFIRSTPRIV + 10) is currently unused */
279/* (SIOCIWFIRSTPRIV + 12) is currently unused */
280/* (SIOCIWFIRSTPRIV + 14) is currently unused */
281/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700282
Jeff Johnsone7245742012-09-05 17:12:55 -0700283#ifdef FEATURE_OEM_DATA_SUPPORT
284/* Private ioctls for setting the measurement configuration */
285#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
286#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
287#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289#ifdef WLAN_FEATURE_VOWIFI_11R
290#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
291#endif
292
293/* Private ioctl for setting the host offload feature */
294#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
295
296/* Private ioctl to get the statistics */
297#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
298
299/* Private ioctl to set the Keep Alive Params */
300#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
301#ifdef WLAN_FEATURE_PACKET_FILTERING
302/* Private ioctl to set the Packet Filtering Params */
303#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
304#endif
305
306#ifdef FEATURE_WLAN_SCAN_PNO
307/* Private ioctl to get the statistics */
308#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
309#endif
310
311#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
312
313#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
314#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700315/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700316
Jeff Johnson295189b2012-06-20 16:38:30 -0700317#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
318#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
319
320#define WLAN_STATS_INVALID 0
321#define WLAN_STATS_RETRY_CNT 1
322#define WLAN_STATS_MUL_RETRY_CNT 2
323#define WLAN_STATS_TX_FRM_CNT 3
324#define WLAN_STATS_RX_FRM_CNT 4
325#define WLAN_STATS_FRM_DUP_CNT 5
326#define WLAN_STATS_FAIL_CNT 6
327#define WLAN_STATS_RTS_FAIL_CNT 7
328#define WLAN_STATS_ACK_FAIL_CNT 8
329#define WLAN_STATS_RTS_SUC_CNT 9
330#define WLAN_STATS_RX_DISCARD_CNT 10
331#define WLAN_STATS_RX_ERROR_CNT 11
332#define WLAN_STATS_TX_BYTE_CNT 12
333
334#define WLAN_STATS_RX_BYTE_CNT 13
335#define WLAN_STATS_RX_RATE 14
336#define WLAN_STATS_TX_RATE 15
337
Jeff Johnsone7245742012-09-05 17:12:55 -0700338#define WLAN_STATS_RX_UC_BYTE_CNT 16
339#define WLAN_STATS_RX_MC_BYTE_CNT 17
340#define WLAN_STATS_RX_BC_BYTE_CNT 18
341#define WLAN_STATS_TX_UC_BYTE_CNT 19
342#define WLAN_STATS_TX_MC_BYTE_CNT 20
343#define WLAN_STATS_TX_BC_BYTE_CNT 21
344
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800345#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
346 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
347 { \
348 *__p++ = __type; \
349 *__p++ = __size; \
350 memcpy(__p, __val, __size); \
351 __p += __size; \
352 __tlen += __size + 2; \
353 } \
354 else \
355 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800356 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800357 } \
358 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700359
360#define VERSION_VALUE_MAX_LEN 32
361
362#define TX_PER_TRACKING_DEFAULT_RATIO 5
363#define TX_PER_TRACKING_MAX_RATIO 10
364#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
365
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530366#define WLAN_ADAPTER 0
367#define P2P_ADAPTER 1
368
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530369/*
370 * When supplicant sends SETBAND ioctl it queries for channels from
371 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
372 * This is not required if the return type from ioctl is
373 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
374 * event as part of regulatory_hint.
375 */
376enum {
377 SEND_CHANNEL_CHANGE_EVENT = 0,
378 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
379};
380
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800381/*MCC Configuration parameters */
382enum {
383 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
384 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
385 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
386 MCC_RX_DRAIN_TIME_CFG_PARAM,
387 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
388 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
389 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
390 MCC_MIN_AFTER_DTIM_CFG_PARAM,
391 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
392};
393
394int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
395 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
396
Jeff Johnson295189b2012-06-20 16:38:30 -0700397#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800398int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700399 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700400#endif
401
Jeff Johnson295189b2012-06-20 16:38:30 -0700402/**---------------------------------------------------------------------------
403
Arif Hussain0273cba2014-01-07 20:58:29 -0800404 \brief mem_alloc_copy_from_user_helper -
405
406 Helper function to allocate buffer and copy user data.
407
408 \param - wrqu - Pointer to IOCTL Data.
409 len - size
410
411 \return - On Success pointer to buffer, On failure NULL
412
413 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530414void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800415{
416 u8 *ptr = NULL;
417
418 /* in order to protect the code, an extra byte is post appended to the buffer
419 * and the null termination is added. However, when allocating (len+1) byte
420 * of memory, we need to make sure that there is no uint overflow when doing
421 * addition. In theory check len < UINT_MAX protects the uint overflow. For
422 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
423 * guess, now, it is assumed that the private command buffer size is no
424 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
425 */
426 if (len > MAX_USER_COMMAND_SIZE)
427 {
428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
429 "Invalid length");
430 return NULL;
431 }
432
433 ptr = kmalloc(len + 1, GFP_KERNEL);
434 if (NULL == ptr)
435 {
436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
437 "unable to allocate memory");
438 return NULL;
439 }
440
441 if (copy_from_user(ptr, wrqu_data, len))
442 {
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
444 "%s: failed to copy data to user buffer", __func__);
445 kfree(ptr);
446 return NULL;
447 }
448 ptr[len] = '\0';
449 return ptr;
450}
451
Girish Gowli488ef492014-06-12 18:44:33 +0530452// Function to handle and get compatible struct iw_point passed to ioctl.
453int hdd_priv_get_data(struct iw_point *p_priv_data,
454 union iwreq_data *wrqu)
455{
456 if ((NULL == p_priv_data) || (NULL == wrqu))
457 {
458 return -EINVAL;
459 }
460
461#ifdef CONFIG_COMPAT
462 if (is_compat_task())
463 {
464 struct compat_iw_point *p_compat_priv_data;
465
466 // Compat task: typecast to campat structure and copy the members.
467 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
468
469 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
470 p_priv_data->length = p_compat_priv_data->length;
471 p_priv_data->flags = p_compat_priv_data->flags;
472 }//if(is_compat_task())
473 else
474 {
475#endif //#ifdef CONFIG_COMPAT
476
477 // Non compat task: directly copy the structure.
478 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
479
480#ifdef CONFIG_COMPAT
481 }//else of - if(is_compat_task())
482#endif //#ifdef CONFIG_COMPAT
483
484 return 0;
485}
486
Arif Hussain0273cba2014-01-07 20:58:29 -0800487/**---------------------------------------------------------------------------
488
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 \brief hdd_wlan_get_version() -
490
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700492
493 \param - pAdapter Pointer to the adapter.
494 wrqu - Pointer to IOCTL REQUEST Data.
495 extra - Pointer to char
496
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800497 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800500void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
501 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700502{
503 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504 tSirVersionString wcnss_SW_version;
505 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530506 tSirVersionString iris_name;
507 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508 char *pSWversion;
509 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700511
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
513 sizeof(wcnss_SW_version));
514 if (VOS_IS_STATUS_SUCCESS(status))
515 {
516 pSWversion = wcnss_SW_version;
517 }
518 else
519 {
520 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 }
522
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800523 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
524 sizeof(wcnss_HW_version));
525 if (VOS_IS_STATUS_SUCCESS(status))
526 {
527 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800529 else
530 {
531 pHWversion = "Unknown";
532 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530534 status = wcnss_get_iris_name(iris_name);
535
536 if (!status) {
537 pIRISversion = iris_name;
538 } else {
539 pIRISversion = "Unknown";
540 }
541
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700542 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530543 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800544 QWLAN_VERSIONSTR,
545 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530546 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800547
548 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700549}
550
Jeff Johnson295189b2012-06-20 16:38:30 -0700551int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
552{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530553 tHalHandle hHal;
554 hdd_context_t *pHddCtx;
555 v_U32_t threshold = 0;
556 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
558 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530559 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530560 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
562 "%s: Adapter is NULL",__func__);
563 return -EINVAL;
564 }
565
566 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
567 ret = wlan_hdd_validate_context(pHddCtx);
568 if (0 != ret)
569 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530570 return ret;
571 }
572
573 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
574 if (NULL == hHal)
575 {
576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
577 "%s: Hal Context is NULL",__func__);
578 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 }
580
581 if ( eHAL_STATUS_SUCCESS !=
582 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
583 {
c_hpothub8245442013-11-20 23:41:09 +0530584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
585 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 return -EIO;
587 }
588 wrqu->rts.value = threshold;
589
590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800591 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
593 EXIT();
594
595 return 0;
596}
597
598int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
599{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530600 tHalHandle hHal;
601 hdd_context_t *pHddCtx;
602 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700603
604 ENTER();
605
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530606 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530607 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
609 "%s: Adapter is NULL",__func__);
610 return -EINVAL;
611 }
612
613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
614 status = wlan_hdd_validate_context(pHddCtx);
615 if (0 != status)
616 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530617 return status;
618 }
619
620 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
621 if (NULL == hHal)
622 {
623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
624 "%s: Hal Context is NULL",__func__);
625 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 }
627
628 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
629 != eHAL_STATUS_SUCCESS )
630 {
c_hpothub8245442013-11-20 23:41:09 +0530631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
632 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 return -EIO;
634 }
635 wrqu->frag.value = threshold;
636
637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800638 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700639
640 EXIT();
641
642 return 0;
643}
644
645int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
646{
Jeff Johnsone7245742012-09-05 17:12:55 -0700647 int i;
648 if (channel > 0)
649 {
650 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
651 {
652 if (channel == freq_chan_map[i].chan)
653 {
654 *pfreq = freq_chan_map[i].freq;
655 return 1;
656 }
657 }
658 }
659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800660 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700661 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700662}
663
664static v_BOOL_t
665hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
666{
667 v_BOOL_t rsnType = VOS_FALSE;
668 // is the authType supported?
669 switch (authType)
670 {
671 case eCSR_AUTH_TYPE_NONE: //never used
672 rsnType = eANI_BOOLEAN_FALSE;
673 break;
674 // MAC layer authentication types
675 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
676 rsnType = eANI_BOOLEAN_FALSE;
677 break;
678 case eCSR_AUTH_TYPE_SHARED_KEY:
679 rsnType = eANI_BOOLEAN_FALSE;
680 break;
681 case eCSR_AUTH_TYPE_AUTOSWITCH:
682 rsnType = eANI_BOOLEAN_FALSE;
683 break;
684
685 // Upper layer authentication types
686 case eCSR_AUTH_TYPE_WPA:
687 rsnType = eANI_BOOLEAN_TRUE;
688 break;
689 case eCSR_AUTH_TYPE_WPA_PSK:
690 rsnType = eANI_BOOLEAN_TRUE;
691 break;
692 case eCSR_AUTH_TYPE_WPA_NONE:
693 rsnType = eANI_BOOLEAN_TRUE;
694 break;
695#ifdef WLAN_FEATURE_VOWIFI_11R
696 case eCSR_AUTH_TYPE_FT_RSN:
697#endif
698 case eCSR_AUTH_TYPE_RSN:
699 rsnType = eANI_BOOLEAN_TRUE;
700 break;
701#ifdef WLAN_FEATURE_VOWIFI_11R
702 case eCSR_AUTH_TYPE_FT_RSN_PSK:
703#endif
704 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700705#ifdef WLAN_FEATURE_11W
706 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530707 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700708#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 rsnType = eANI_BOOLEAN_TRUE;
710 break;
711 //case eCSR_AUTH_TYPE_FAILED:
712 case eCSR_AUTH_TYPE_UNKNOWN:
713 rsnType = eANI_BOOLEAN_FALSE;
714 break;
715 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800716 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
717 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 rsnType = eANI_BOOLEAN_FALSE;
719 break;
720 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800721 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700722 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 return rsnType;
724}
725
726static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
727{
728 struct statsContext *pStatsContext;
729 hdd_adapter_t *pAdapter;
730
731 if (ioctl_debug)
732 {
733 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700734 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 }
736
737 if (NULL == pContext)
738 {
739 hddLog(VOS_TRACE_LEVEL_ERROR,
740 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700741 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 return;
743 }
744
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 pStatsContext = pContext;
746 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800747
748 /* there is a race condition that exists between this callback
749 function and the caller since the caller could time out either
750 before or while this code is executing. we use a spinlock to
751 serialize these actions */
752 spin_lock(&hdd_context_lock);
753
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
755 {
756 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800757 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 hddLog(VOS_TRACE_LEVEL_WARN,
759 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700760 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 if (ioctl_debug)
762 {
763 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700764 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766 return;
767 }
768
Jeff Johnson72a40512013-12-19 10:14:15 -0800769 /* context is valid so caller is still waiting */
770
771 /* paranoia: invalidate the magic */
772 pStatsContext->magic = 0;
773
774 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530776 if (pAdapter->rssi > 0)
777 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800778 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800780
781 /* serialization is complete */
782 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700783}
784
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530785static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
786{
787 struct statsContext *pStatsContext;
788 hdd_adapter_t *pAdapter;
789
790 if (ioctl_debug)
791 {
792 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
793 __func__, (int)snr, (int)staId, pContext);
794 }
795
796 if (NULL == pContext)
797 {
798 hddLog(VOS_TRACE_LEVEL_ERROR,
799 "%s: Bad param, pContext [%p]",
800 __func__, pContext);
801 return;
802 }
803
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530804 pStatsContext = pContext;
805 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800806
807 /* there is a race condition that exists between this callback
808 function and the caller since the caller could time out either
809 before or while this code is executing. we use a spinlock to
810 serialize these actions */
811 spin_lock(&hdd_context_lock);
812
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530813 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
814 {
815 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800816 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530817 hddLog(VOS_TRACE_LEVEL_WARN,
818 "%s: Invalid context, pAdapter [%p] magic [%08x]",
819 __func__, pAdapter, pStatsContext->magic);
820 if (ioctl_debug)
821 {
822 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
823 __func__, pAdapter, pStatsContext->magic);
824 }
825 return;
826 }
827
Jeff Johnson72a40512013-12-19 10:14:15 -0800828 /* context is valid so caller is still waiting */
829
830 /* paranoia: invalidate the magic */
831 pStatsContext->magic = 0;
832
833 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530834 pAdapter->snr = snr;
835
Jeff Johnson72a40512013-12-19 10:14:15 -0800836 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530837 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800838
839 /* serialization is complete */
840 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530841}
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
844{
845 struct statsContext context;
846 hdd_context_t *pHddCtx;
847 hdd_station_ctx_t *pHddStaCtx;
848 eHalStatus hstatus;
849 long lrc;
850
851 if (NULL == pAdapter)
852 {
853 hddLog(VOS_TRACE_LEVEL_WARN,
854 "%s: Invalid context, pAdapter", __func__);
855 return VOS_STATUS_E_FAULT;
856 }
857 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
858 {
859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
860 /* return a cached value */
861 *rssi_value = pAdapter->rssi;
862 return VOS_STATUS_SUCCESS;
863 }
864
865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
866 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
867
mukul sharma8aec69b2015-06-10 22:28:43 +0530868 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
869 {
870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
871 *rssi_value = 0;
872 return VOS_STATUS_SUCCESS;
873 }
874
875 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
876 {
877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
878 "%s: Roaming in progress, hence return last cached RSSI", __func__);
879 *rssi_value = pAdapter->rssi;
880 return VOS_STATUS_SUCCESS;
881 }
882
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 init_completion(&context.completion);
884 context.pAdapter = pAdapter;
885 context.magic = RSSI_CONTEXT_MAGIC;
886
887 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
888 pHddStaCtx->conn_info.staId[ 0 ],
889 pHddStaCtx->conn_info.bssId,
890 &context, pHddCtx->pvosContext);
891 if (eHAL_STATUS_SUCCESS != hstatus)
892 {
893 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700894 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 /* we'll returned a cached value below */
896 }
897 else
898 {
899 /* request was sent -- wait for the response */
900 lrc = wait_for_completion_interruptible_timeout(&context.completion,
901 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 if (lrc <= 0)
903 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800904 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700905 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 /* we'll now returned a cached value below */
907 }
908 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800909
910 /* either we never sent a request, we sent a request and received a
911 response or we sent a request and timed out. if we never sent a
912 request or if we sent a request and got a response, we want to
913 clear the magic out of paranoia. if we timed out there is a
914 race condition such that the callback function could be
915 executing at the same time we are. of primary concern is if the
916 callback function had already verified the "magic" but had not
917 yet set the completion variable when a timeout occurred. we
918 serialize these activities by invalidating the magic while
919 holding a shared spinlock which will cause us to block if the
920 callback is currently executing */
921 spin_lock(&hdd_context_lock);
922 context.magic = 0;
923 spin_unlock(&hdd_context_lock);
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 *rssi_value = pAdapter->rssi;
926
927 return VOS_STATUS_SUCCESS;
928}
Siddharth Bhal64246172015-02-27 01:04:37 +0530929/**---------------------------------------------------------------------------
930
931 \brief wlan_hdd_get_frame_logs() -
932
933 This function use to get Frames log.
934
935 \param - pAdapter Pointer to the adapter.
936 flag - Specify type of request. Clear and Send request are
937 supported.
938
939 \return - none
940
941 --------------------------------------------------------------------------*/
942VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
943{
Siddharth Bhal64246172015-02-27 01:04:37 +0530944 hdd_context_t *pHddCtx;
945 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530946
947 if (NULL == pAdapter)
948 {
949 hddLog(VOS_TRACE_LEVEL_WARN,
950 "%s: Invalid context, pAdapter", __func__);
951 return VOS_STATUS_E_FAULT;
952 }
953
954 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
955 if (!pHddCtx->mgmt_frame_logging)
956 {
957 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
958 return VOS_STATUS_E_AGAIN;
959 }
960
Siddharth Bhal4507c262015-04-29 20:20:42 +0530961 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
962 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
963 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530964 {
965 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
966 return VOS_STATUS_E_INVAL;
967 }
968
Siddharth Bhal4507c262015-04-29 20:20:42 +0530969 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
970 (!pHddCtx->cfg_ini->enableBMUHWtracing))
971 {
972 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
973 return VOS_STATUS_E_INVAL;
974 }
975
Abhishek Singh611295e2015-07-09 11:11:54 +0530976 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530977 if (eHAL_STATUS_SUCCESS != hstatus)
978 {
979 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530980 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530981 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530982
983 return VOS_STATUS_SUCCESS;
984}
985
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530986
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530987VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
988{
989 struct statsContext context;
990 hdd_context_t *pHddCtx;
991 hdd_station_ctx_t *pHddStaCtx;
992 eHalStatus hstatus;
993 long lrc;
994 int valid;
995
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530996 ENTER();
997
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530998 if (NULL == pAdapter)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR,
1001 "%s: Invalid context, pAdapter", __func__);
1002 return VOS_STATUS_E_FAULT;
1003 }
1004
1005 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1006
1007 valid = wlan_hdd_validate_context(pHddCtx);
1008 if (0 != valid)
1009 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301010 return VOS_STATUS_E_FAULT;
1011 }
1012
1013 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1014 if (NULL == pHddStaCtx)
1015 {
1016 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1017 return VOS_STATUS_E_FAULT;
1018 }
1019
1020 init_completion(&context.completion);
1021 context.pAdapter = pAdapter;
1022 context.magic = SNR_CONTEXT_MAGIC;
1023
1024 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1025 pHddStaCtx->conn_info.staId[ 0 ],
1026 pHddStaCtx->conn_info.bssId,
1027 &context);
1028 if (eHAL_STATUS_SUCCESS != hstatus)
1029 {
1030 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1031 __func__);
1032 /* we'll returned a cached value below */
1033 }
1034 else
1035 {
1036 /* request was sent -- wait for the response */
1037 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1038 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301039 if (lrc <= 0)
1040 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001041 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301042 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301043 /* we'll now returned a cached value below */
1044 }
1045 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001046
1047 /* either we never sent a request, we sent a request and received a
1048 response or we sent a request and timed out. if we never sent a
1049 request or if we sent a request and got a response, we want to
1050 clear the magic out of paranoia. if we timed out there is a
1051 race condition such that the callback function could be
1052 executing at the same time we are. of primary concern is if the
1053 callback function had already verified the "magic" but had not
1054 yet set the completion variable when a timeout occurred. we
1055 serialize these activities by invalidating the magic while
1056 holding a shared spinlock which will cause us to block if the
1057 callback is currently executing */
1058 spin_lock(&hdd_context_lock);
1059 context.magic = 0;
1060 spin_unlock(&hdd_context_lock);
1061
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301062 *snr = pAdapter->snr;
1063
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301064 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301065 return VOS_STATUS_SUCCESS;
1066}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001067#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001068
1069static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1070{
1071 struct statsContext *pStatsContext;
1072 hdd_adapter_t *pAdapter;
1073 if (ioctl_debug)
1074 {
1075 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1076 __func__, (int)rssi, (int)staId, pContext);
1077 }
1078
1079 if (NULL == pContext)
1080 {
1081 hddLog(VOS_TRACE_LEVEL_ERROR,
1082 "%s: Bad param, pContext [%p]",
1083 __func__, pContext);
1084 return;
1085 }
1086
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001087 pStatsContext = pContext;
1088 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001089
1090 /* there is a race condition that exists between this callback
1091 function and the caller since the caller could time out either
1092 before or while this code is executing. we use a spinlock to
1093 serialize these actions */
1094 spin_lock(&hdd_context_lock);
1095
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001096 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1097 {
1098 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001099 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001100 hddLog(VOS_TRACE_LEVEL_WARN,
1101 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1102 __func__, pAdapter, pStatsContext->magic);
1103 if (ioctl_debug)
1104 {
1105 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1106 __func__, pAdapter, pStatsContext->magic);
1107 }
1108 return;
1109 }
1110
Jeff Johnson72a40512013-12-19 10:14:15 -08001111 /* context is valid so caller is still waiting */
1112
1113 /* paranoia: invalidate the magic */
1114 pStatsContext->magic = 0;
1115
1116 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001117 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301118 if (pAdapter->rssi > 0)
1119 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001120 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001121 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001122
1123 /* serialization is complete */
1124 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001125}
1126
1127
1128
1129VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1130{
1131 struct statsContext context;
1132 hdd_context_t *pHddCtx = NULL;
1133 hdd_station_ctx_t *pHddStaCtx = NULL;
1134 eHalStatus hstatus;
1135 long lrc;
1136
1137 if (NULL == pAdapter)
1138 {
1139 hddLog(VOS_TRACE_LEVEL_WARN,
1140 "%s: Invalid context, pAdapter", __func__);
1141 return VOS_STATUS_E_FAULT;
1142 }
1143 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1144 {
1145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1146 /* return a cached value */
1147 *rssi_value = pAdapter->rssi;
1148 return VOS_STATUS_SUCCESS;
1149 }
1150
1151 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1152 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1153
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301154 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001155 {
1156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1157 /* return a cached value */
1158 *rssi_value = 0;
1159 return VOS_STATUS_SUCCESS;
1160 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301161
1162 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1163 {
1164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1165 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1166 *rssi_value = pAdapter->rssi;
1167 return VOS_STATUS_SUCCESS;
1168 }
1169
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001170 init_completion(&context.completion);
1171 context.pAdapter = pAdapter;
1172 context.magic = RSSI_CONTEXT_MAGIC;
1173
1174 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1175 pHddStaCtx->conn_info.staId[ 0 ],
1176 pHddStaCtx->conn_info.bssId,
1177 &context, pHddCtx->pvosContext);
1178 if (eHAL_STATUS_SUCCESS != hstatus)
1179 {
1180 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1181 __func__);
1182 /* we'll returned a cached value below */
1183 }
1184 else
1185 {
1186 /* request was sent -- wait for the response */
1187 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1188 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001189 if (lrc <= 0)
1190 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001191 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001192 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001193 /* we'll now returned a cached value below */
1194 }
1195 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001196
1197 /* either we never sent a request, we sent a request and received a
1198 response or we sent a request and timed out. if we never sent a
1199 request or if we sent a request and got a response, we want to
1200 clear the magic out of paranoia. if we timed out there is a
1201 race condition such that the callback function could be
1202 executing at the same time we are. of primary concern is if the
1203 callback function had already verified the "magic" but had not
1204 yet set the completion variable when a timeout occurred. we
1205 serialize these activities by invalidating the magic while
1206 holding a shared spinlock which will cause us to block if the
1207 callback is currently executing */
1208 spin_lock(&hdd_context_lock);
1209 context.magic = 0;
1210 spin_unlock(&hdd_context_lock);
1211
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001212 *rssi_value = pAdapter->rssi;
1213
1214 return VOS_STATUS_SUCCESS;
1215}
1216#endif
1217
1218
Jeff Johnson295189b2012-06-20 16:38:30 -07001219void hdd_StatisticsCB( void *pStats, void *pContext )
1220{
1221 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1222 hdd_stats_t *pStatsCache = NULL;
1223 hdd_wext_state_t *pWextState;
1224 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1225
1226 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1227 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1228 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1229 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1230 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1231 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1232
1233 if (pAdapter!= NULL)
1234 pStatsCache = &pAdapter->hdd_stats;
1235
1236
1237 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1238 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1239 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1240 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1241 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1242 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1243
1244 if (pStatsCache!=NULL)
1245 {
1246 // and copy the stats into the cache we keep in the adapter instance structure
1247 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1248 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1249 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1250 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1251 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1252 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1253 }
1254
1255 if(pAdapter)
1256 {
1257 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1258 if(pWextState)
1259 {
1260 vos_status = vos_event_set(&pWextState->vosevent);
1261 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1262 {
1263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001264 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 return;
1266 }
1267 }
1268 }
1269}
1270
1271void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1272{
1273 v_CONTEXT_t pVosContext;
1274 hdd_context_t *pHddCtx;
1275 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1276#if 0
1277 hdd_wext_state_t *pWextState;
1278 v_U32_t roamId;
1279#endif
1280
1281 ENTER();
1282
1283 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1284
1285 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1286 if (NULL == pHddCtx)
1287 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001288 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 return;
1290 }
1291#if 0
1292 pWextState = pAdapter->pWextState;
1293#endif
1294
1295 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1296 {
1297 //TODO Verify is this is really used. If yes need to fix it.
1298 hdd_reconnect_all_adapters( pHddCtx );
1299#if 0
1300 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1301 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1302 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1303
1304 if(VOS_STATUS_SUCCESS == vosStatus)
1305 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1306 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1307
1308 sme_RoamConnect(halHandle,
1309 pAdapter->sessionId, &(pWextState->roamProfile),
1310 &roamId);
1311#endif
1312 }
1313
1314 EXIT();
1315
1316}
1317
1318void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1319{
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1321
1322 /* clear WPA/RSN/WSC IE information in the profile */
1323 pWextState->roamProfile.nWPAReqIELength = 0;
1324 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1325 pWextState->roamProfile.nRSNReqIELength = 0;
1326 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1327
Chet Lanctot186b5732013-03-18 10:26:30 -07001328#ifdef FEATURE_WLAN_WAPI
1329 pWextState->roamProfile.nWAPIReqIELength = 0;
1330 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1331#endif
1332
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001334 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301336 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1338 pWextState->roamProfile.nAddIEAssocLength = 0;
1339
1340 pWextState->roamProfile.EncryptionType.numEntries = 1;
1341 pWextState->roamProfile.EncryptionType.encryptionType[0]
1342 = eCSR_ENCRYPT_TYPE_NONE;
1343
1344 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1345 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1346 = eCSR_ENCRYPT_TYPE_NONE;
1347
1348 pWextState->roamProfile.AuthType.numEntries = 1;
1349 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1350
Chet Lanctot186b5732013-03-18 10:26:30 -07001351#ifdef WLAN_FEATURE_11W
1352 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1353 pWextState->roamProfile.MFPRequired = 0;
1354 pWextState->roamProfile.MFPCapable = 0;
1355#endif
1356
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 pWextState->authKeyMgmt = 0;
1358
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301359 vos_mem_zero(&pWextState->roamProfile.Keys,
1360 sizeof(pWextState->roamProfile.Keys));
1361
Jeff Johnson295189b2012-06-20 16:38:30 -07001362#ifdef FEATURE_WLAN_WAPI
1363 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1364 pAdapter->wapi_info.nWapiMode = 0;
1365#endif
1366
1367 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1368
1369}
1370
1371void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1372{
1373 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001374
Nirav Shahf6bd2672015-03-11 12:53:15 +05301375 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001376 {
1377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301378 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001379 }
1380 else
1381 {
1382 complete(&pAdapter->ula_complete);
1383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001384}
1385
1386VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1387{
1388 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001390 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
1392 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1393 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001394 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395
1396 /*To avoid race condition between the set key and the last EAPOL
1397 packet, notify TL to finish upper layer authentication incase if the
1398 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001399 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001401 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 {
1403 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1404 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1405 __LINE__, vos_status );
1406 return vos_status;
1407
1408 }
1409
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001410 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301412 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001413 {
1414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301415 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001416 /* we'll still fall through and return success since the
1417 * connection may still get established but is just taking
1418 * too long for us to wait */
1419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 }
1421 return VOS_STATUS_SUCCESS;
1422}
1423
1424v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len)
1425{
1426
1427 int left = ie_len;
1428 v_U8_t *ptr = ie;
1429 v_U8_t elem_id,elem_len;
1430 v_U8_t eid = 0xDD;
1431
1432 if ( NULL == ie || 0 == ie_len )
1433 return NULL;
1434
1435 while(left >= 2)
1436 {
1437 elem_id = ptr[0];
1438 elem_len = ptr[1];
1439 left -= 2;
1440 if(elem_len > left)
1441 {
1442 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001443 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 eid,elem_len,left);
1445 return NULL;
1446 }
1447 if (elem_id == eid)
1448 {
1449 if(memcmp( &ptr[2], oui, oui_size)==0)
1450 return ptr;
1451 }
1452
1453 left -= elem_len;
1454 ptr += (elem_len + 2);
1455 }
1456 return NULL;
1457}
1458
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301459static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 union iwreq_data *wrqu, char *extra)
1461{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301462 hdd_adapter_t *pAdapter;
1463 hdd_context_t *pHddCtx;
1464 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301465
1466 ENTER();
1467
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301468 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1469 if (NULL == pAdapter)
1470 {
1471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1472 "%s: pAdapter is NULL\n", __func__);
1473 return -EINVAL;
1474 }
1475 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1476 ret = wlan_hdd_validate_context(pHddCtx);
1477 if (0 != ret)
1478 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301479 return ret;
1480 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301481
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301483
1484 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301485 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486}
1487
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301488static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1489 union iwreq_data *wrqu, char *extra)
1490{
1491 int ret;
1492
1493 vos_ssr_protect(__func__);
1494 ret = __iw_set_commit(dev, info, wrqu, extra);
1495 vos_ssr_unprotect(__func__);
1496
1497 return ret;
1498}
1499
1500static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 struct iw_request_info *info,
1502 char *wrqu, char *extra)
1503{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301504 hdd_adapter_t *pAdapter;
1505 hdd_context_t *pHddCtx;
1506 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301509 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1510 if (NULL == pAdapter)
1511 {
1512 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1513 "%s: pAdapter is NULL\n", __func__);
1514 return -EINVAL;
1515 }
1516 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1517 ret = wlan_hdd_validate_context(pHddCtx);
1518 if (0 != ret)
1519 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301520 return ret;
1521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1523 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301524 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001525}
1526
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301527static int iw_get_name(struct net_device *dev,
1528 struct iw_request_info *info,
1529 char *wrqu, char *extra)
1530{
1531 int ret;
1532
1533 vos_ssr_protect(__func__);
1534 ret = __iw_get_name(dev, info, wrqu, extra);
1535 vos_ssr_unprotect(__func__);
1536
1537 return ret;
1538}
1539
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301540static int __iw_set_mode(struct net_device *dev,
1541 struct iw_request_info *info,
1542 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001543{
1544 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301545 hdd_adapter_t *pAdapter;
1546 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 tCsrRoamProfile *pRoamProfile;
1548 eCsrRoamBssType LastBSSType;
1549 eMib_dot11DesiredBssType connectedBssType;
1550 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001551 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301552 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001553
1554 ENTER();
1555
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301556 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 if (NULL == pAdapter)
1558 {
1559 hddLog(VOS_TRACE_LEVEL_WARN,
1560 "%s: Invalid context, pAdapter", __func__);
1561 return 0;
1562 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301563 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1564 status = wlan_hdd_validate_context(pHddCtx);
1565 if (0 != status)
1566 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301567 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 }
1569
1570 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1571 if (pWextState == NULL)
1572 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301573 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 return -EINVAL;
1575 }
1576
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 pRoamProfile = &pWextState->roamProfile;
1579 LastBSSType = pRoamProfile->BSSType;
1580
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301581 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
1583 switch (wrqu->mode)
1584 {
1585 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301586 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1588 // Set the phymode correctly for IBSS.
1589 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1590 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001591 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 break;
1594 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301595 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 break;
1599 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301600 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1602 break;
1603 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301604 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 return -EOPNOTSUPP;
1606 }
1607
1608 if ( LastBSSType != pRoamProfile->BSSType )
1609 {
1610 //the BSS mode changed
1611 // We need to issue disconnect if connected or in IBSS disconnect state
1612 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1613 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1614 {
1615 VOS_STATUS vosStatus;
1616 // need to issue a disconnect to CSR.
1617 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1618 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1619 pAdapter->sessionId,
1620 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1621 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301622 {
1623 long ret;
1624 ret = wait_for_completion_interruptible_timeout(
1625 &pAdapter->disconnect_comp_var,
1626 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1627 if (ret <= 0)
1628 hddLog(VOS_TRACE_LEVEL_ERROR,
1629 FL("failed wait on disconnect_comp_var %ld"), ret);
1630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 }
1632 }
1633
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 EXIT();
1635 return 0;
1636}
1637
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301638static int iw_set_mode(struct net_device *dev,
1639 struct iw_request_info *info,
1640 union iwreq_data *wrqu, char *extra)
1641{
1642 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301644 vos_ssr_protect(__func__);
1645 ret = __iw_set_mode(dev, info, wrqu, extra);
1646 vos_ssr_unprotect(__func__);
1647
1648 return ret;
1649}
1650
1651static int __iw_get_mode(struct net_device *dev,
1652 struct iw_request_info *info,
1653 union iwreq_data *wrqu,
1654 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001655{
1656
1657 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301658 hdd_adapter_t *pAdapter;
1659 hdd_context_t *pHddCtx;
1660 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301662 ENTER();
1663
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301664 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 if (NULL == pAdapter)
1666 {
1667 hddLog(VOS_TRACE_LEVEL_WARN,
1668 "%s: Invalid context, pAdapter", __func__);
1669 return 0;
1670 }
1671
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301672 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1673 ret = wlan_hdd_validate_context(pHddCtx);
1674 if (0 != ret)
1675 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301676 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1679 if (pWextState == NULL)
1680 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301681 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 return -EINVAL;
1683 }
1684
1685 switch (pWextState->roamProfile.BSSType)
1686 {
1687 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001688 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301689 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 break;
1691 case eCSR_BSS_TYPE_IBSS:
1692 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001693 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301694 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 break;
1696 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001697 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301698 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 break;
1700 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001701 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 break;
1703 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301704
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301705 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 return 0;
1707}
1708
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301709static int iw_get_mode(struct net_device *dev,
1710 struct iw_request_info *info,
1711 union iwreq_data *wrqu,
1712 char *extra)
1713{
1714 int ret;
1715
1716 vos_ssr_protect(__func__);
1717 ret = __iw_get_mode(dev, info, wrqu, extra);
1718 vos_ssr_unprotect(__func__);
1719
1720 return ret;
1721}
1722
1723static int __iw_set_freq(struct net_device *dev,
1724 struct iw_request_info *info,
1725 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001726{
1727 v_U32_t numChans = 0;
1728 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1729 v_U32_t indx = 0;
1730 v_U32_t status = 0;
1731
1732 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301733 hdd_adapter_t *pAdapter;
1734 hdd_context_t *pHddCtx;
1735 tHalHandle hHal;
1736 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 ENTER();
1740
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1742 if (NULL == pAdapter)
1743 {
1744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1745 "%s:Invalid Adapter",__func__);
1746 return -EINVAL;
1747 }
1748
1749 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1750 status = wlan_hdd_validate_context(pHddCtx);
1751 if (0 != status)
1752 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 return status;
1754 }
1755
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301756 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1757 if (NULL == hHal)
1758 {
1759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1760 "%s: Hal Context is NULL",__func__);
1761 return -EINVAL;
1762 }
1763
1764 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1765 if (NULL == pHddStaCtx)
1766 {
1767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1768 "%s:STA context is NULL",__func__);
1769 return -EINVAL;
1770 }
1771
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301773 if (NULL == pWextState)
1774 {
1775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1776 "%s: pWextState is NULL",__func__);
1777 return -EINVAL;
1778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001779
1780 pRoamProfile = &pWextState->roamProfile;
1781
Arif Hussain6d2a3322013-11-17 19:50:10 -08001782 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001783
1784 /* Link is up then return cant set channel*/
1785 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1786 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1787 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001788 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 return -EOPNOTSUPP;
1790 }
1791
1792 /* Settings by Frequency as input */
1793 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1794 (wrqu->freq.m <= (tANI_U32)5.825e8))
1795 {
1796 tANI_U32 freq = wrqu->freq.m / 100000;
1797
1798 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1799 indx++;
1800 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1801 {
1802 return -EINVAL;
1803 }
1804 wrqu->freq.e = 0;
1805 wrqu->freq.m = freq_chan_map[indx].chan;
1806
1807 }
1808
1809 if (wrqu->freq.e == 0)
1810 {
1811 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1812 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1813 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001814 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001815 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1817 return -EINVAL;
1818 }
1819
1820 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1821
1822 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1823 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1825 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 return -EIO;
1827 }
1828
1829 for (indx = 0; indx < numChans; indx++) {
1830 if (wrqu->freq.m == validChan[indx]){
1831 break;
1832 }
1833 }
1834 }
1835 else{
1836
1837 return -EINVAL;
1838 }
1839
1840 if(indx >= numChans)
1841 {
1842 return -EINVAL;
1843 }
1844
1845 /* Set the Operational Channel */
1846 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1847 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1848 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1849
Arif Hussain6d2a3322013-11-17 19:50:10 -08001850 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
1852 EXIT();
1853
1854 return status;
1855}
1856
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301857static int iw_set_freq(struct net_device *dev,
1858 struct iw_request_info *info,
1859 union iwreq_data *wrqu, char *extra)
1860{
1861 int ret;
1862
1863 vos_ssr_protect(__func__);
1864 ret = __iw_set_freq(dev, info, wrqu, extra);
1865 vos_ssr_unprotect(__func__);
1866
1867 return ret;
1868}
1869
1870static int __iw_get_freq(struct net_device *dev,
1871 struct iw_request_info *info,
1872 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001873{
Jeff Johnsone7245742012-09-05 17:12:55 -07001874 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301875 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 tHalHandle hHal;
1877 hdd_wext_state_t *pWextState;
1878 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301879 hdd_station_ctx_t *pHddStaCtx;
1880 hdd_context_t *pHddCtx;
1881 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001882
1883 ENTER();
1884
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301885 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1886 if (NULL == pAdapter)
1887 {
1888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1889 "%s: Adapter is NULL", __func__);
1890 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301892 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1893 ret = wlan_hdd_validate_context(pHddCtx);
1894 if (0 != ret)
1895 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301896 return ret;
1897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301899 if (NULL == hHal)
1900 {
1901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1902 "%s: Hal Context is NULL",__func__);
1903 return -EINVAL;
1904 }
1905 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1906 if (NULL == pHddStaCtx)
1907 {
1908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1909 "%s: HddStaCtx is NULL", __func__);
1910 return -EINVAL;
1911 }
1912 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1913 if (NULL == pWextState)
1914 {
1915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1916 "%s: pWextState is NULL",__func__);
1917 return -EINVAL;
1918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 pRoamProfile = &pWextState->roamProfile;
1920
1921 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1922 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001923 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 {
c_hpothub8245442013-11-20 23:41:09 +05301925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1926 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 return -EIO;
1928 }
1929 else
1930 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001931 status = hdd_wlan_get_freq(channel, &freq);
1932 if( TRUE == status )
1933 {
1934 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1935 * iwlist & iwconfig command shows frequency into proper
1936 * format (2.412 GHz instead of 246.2 MHz)*/
1937 fwrq->m = freq;
1938 fwrq->e = MHZ;
1939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 }
1941 }
1942 else
1943 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001944 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1945 * iwlist & iwconfig command shows frequency into proper
1946 * format (2.412 GHz instead of 246.2 MHz)*/
1947 fwrq->m = 0;
1948 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301950
1951 EXIT();
1952 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001953}
1954
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301955static int iw_get_freq(struct net_device *dev,
1956 struct iw_request_info *info,
1957 struct iw_freq *fwrq, char *extra)
1958{
1959 int ret;
1960
1961 vos_ssr_protect(__func__);
1962 ret = __iw_get_freq(dev, info, fwrq, extra);
1963 vos_ssr_unprotect(__func__);
1964
1965 return ret;
1966}
1967
1968static int __iw_get_tx_power(struct net_device *dev,
1969 struct iw_request_info *info,
1970 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001971{
1972
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301973 hdd_adapter_t *pAdapter;
1974 hdd_context_t *pHddCtx;
1975 hdd_station_ctx_t *pHddStaCtx;
1976 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301978 ENTER();
1979
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301980 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1981 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1984 "%s: Adapter is NULL",__func__);
1985 return -EINVAL;
1986 }
1987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1988 ret = wlan_hdd_validate_context(pHddCtx);
1989 if (0 != ret)
1990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301991 return ret;
1992 }
1993
1994 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1995 if (NULL == pHddStaCtx)
1996 {
1997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1998 "%s: STA Context is NULL",__func__);
1999 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 }
2001
2002 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2003 {
2004 wrqu->txpower.value = 0;
2005 return 0;
2006 }
2007 wlan_hdd_get_classAstats(pAdapter);
2008 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2009
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302010 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 return 0;
2012}
2013
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302014static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 struct iw_request_info *info,
2016 union iwreq_data *wrqu, char *extra)
2017{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302018 int ret;
2019
2020 vos_ssr_protect(__func__);
2021 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2022 vos_ssr_unprotect(__func__);
2023
2024 return ret;
2025}
2026
2027static int __iw_set_tx_power(struct net_device *dev,
2028 struct iw_request_info *info,
2029 union iwreq_data *wrqu, char *extra)
2030{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302031 hdd_adapter_t *pAdapter;
2032 tHalHandle hHal;
2033 hdd_context_t *pHddCtx;
2034 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002035
2036 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302037 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2038 if (NULL == pAdapter)
2039 {
2040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2041 "%s: Adapter is NULL",__func__);
2042 return -EINVAL;
2043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002044
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302045 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2046 ret = wlan_hdd_validate_context(pHddCtx);
2047 if (0 != ret)
2048 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302049 return ret;
2050 }
2051
2052 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2053 if (NULL == hHal)
2054 {
2055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2056 "%s: Hal Context is NULL",__func__);
2057 return -EINVAL;
2058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2060 {
c_hpothub8245442013-11-20 23:41:09 +05302061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2062 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 return -EIO;
2064 }
2065
2066 EXIT();
2067
2068 return 0;
2069}
2070
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302071static int iw_set_tx_power(struct net_device *dev,
2072 struct iw_request_info *info,
2073 union iwreq_data *wrqu, char *extra)
2074{
2075 int ret;
2076
2077 vos_ssr_protect(__func__);
2078 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2079 vos_ssr_unprotect(__func__);
2080
2081 return ret;
2082}
2083
2084static int __iw_get_bitrate(struct net_device *dev,
2085 struct iw_request_info *info,
2086 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002087{
2088 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2089 eHalStatus status = eHAL_STATUS_SUCCESS;
2090 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302091 hdd_adapter_t *pAdapter;
2092 hdd_context_t *pHddCtx;
2093 hdd_station_ctx_t *pHddStaCtx;
2094 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002095
2096 ENTER();
2097
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302098 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2099 if (NULL == pAdapter)
2100 {
2101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2102 "%s: Adapter is NULL",__func__);
2103 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 }
2105
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302106 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2107 ret = wlan_hdd_validate_context(pHddCtx);
2108 if (0 != ret)
2109 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302110 return ret;
2111 }
2112
2113 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2114 if (NULL == pHddStaCtx)
2115 {
2116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2117 "%s: STA Context is NULL",__func__);
2118 return -EINVAL;
2119 }
2120
2121 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 wrqu->bitrate.value = 0;
2123 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302124 else
2125 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2127 SME_SUMMARY_STATS |
2128 SME_GLOBAL_CLASSA_STATS |
2129 SME_GLOBAL_CLASSB_STATS |
2130 SME_GLOBAL_CLASSC_STATS |
2131 SME_GLOBAL_CLASSD_STATS |
2132 SME_PER_STA_STATS,
2133 hdd_StatisticsCB, 0, FALSE,
2134 pHddStaCtx->conn_info.staId[0], pAdapter );
2135
2136 if(eHAL_STATUS_SUCCESS != status)
2137 {
2138 hddLog(VOS_TRACE_LEVEL_ERROR,
2139 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002140 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 return status;
2142 }
2143
2144 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302145 if (NULL == pWextState)
2146 {
2147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2148 "%s: pWextState is NULL",__func__);
2149 return -EINVAL;
2150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002151
2152 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2153
2154 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2155 {
2156 hddLog(VOS_TRACE_LEVEL_ERROR,
2157 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002158 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 return VOS_STATUS_E_FAILURE;
2160 }
2161
2162 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2163 }
2164
2165 EXIT();
2166
2167 return vos_status;
2168}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302169
2170static int iw_get_bitrate(struct net_device *dev,
2171 struct iw_request_info *info,
2172 union iwreq_data *wrqu, char *extra)
2173{
2174 int ret;
2175
2176 vos_ssr_protect(__func__);
2177 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2178 vos_ssr_unprotect(__func__);
2179
2180 return ret;
2181}
2182
2183
Jeff Johnson295189b2012-06-20 16:38:30 -07002184/* ccm call back function */
2185
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302186static int __iw_set_bitrate(struct net_device *dev,
2187 struct iw_request_info *info,
2188 union iwreq_data *wrqu,
2189 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002190{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302191 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302193 hdd_station_ctx_t *pHddStaCtx;
2194 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2196 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2197 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2198 v_U32_t i, rate;
2199 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302200 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002201
2202 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302203 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2204 if (NULL == pAdapter)
2205 {
2206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2207 "%s: Adapter is NULL",__func__);
2208 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 }
2210
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302211 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2212 ret = wlan_hdd_validate_context(pHddCtx);
2213 if (0 != ret)
2214 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302215 return ret;
2216 }
2217
2218 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2219 if (NULL == pHddStaCtx)
2220 {
2221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2222 "%s: STA Context is NULL",__func__);
2223 return -EINVAL;
2224 }
2225
2226
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302228 if (NULL == pWextState)
2229 {
2230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2231 "%s: pWextState is NULL",__func__);
2232 return -EINVAL;
2233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002234
2235 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2236 {
2237 return -ENXIO ;
2238 }
2239
2240 rate = wrqu->bitrate.value;
2241
2242 if (rate == -1)
2243 {
2244 rate = WNI_CFG_FIXED_RATE_AUTO;
2245 valid_rate = TRUE;
2246 }
2247 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2248 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2249 {
2250 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2251 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2252 {
2253 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2254 WNI_CFG_SUPPORTED_RATES_11A,
2255 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2256 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2257 WNI_CFG_SUPPORTED_RATES_11B,
2258 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2259 {
2260 for (i = 0; i < (b_len + a_len); ++i)
2261 {
2262 /* supported rates returned is double the actual rate so we divide it by 2 */
2263 if ((supp_rates[i]&0x7F)/2 == rate)
2264 {
2265 valid_rate = TRUE;
2266 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2267 break;
2268 }
2269 }
2270 }
2271 }
2272 }
2273 if (valid_rate != TRUE)
2274 {
2275 return -EINVAL;
2276 }
2277 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2278 WNI_CFG_FIXED_RATE, rate,
2279 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2280 {
c_hpothub8245442013-11-20 23:41:09 +05302281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2282 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 return -EIO;
2284 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302285
2286 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 return 0;
2288}
2289
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302290static int iw_set_bitrate(struct net_device *dev,
2291 struct iw_request_info *info,
2292 union iwreq_data *wrqu,
2293 char *extra)
2294{
2295 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002296
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302297 vos_ssr_protect(__func__);
2298 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2299 vos_ssr_unprotect(__func__);
2300
2301 return ret;
2302}
2303
2304static int __iw_set_genie(struct net_device *dev,
2305 struct iw_request_info *info,
2306 union iwreq_data *wrqu,
2307 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002308{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302309 hdd_adapter_t *pAdapter;
2310 hdd_context_t *pHddCtx;
2311 hdd_wext_state_t *pWextState;
2312 u_int8_t *genie = NULL;
2313 u_int8_t *base_genie = NULL;
2314 v_U16_t remLen;
2315 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002316
2317 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002318
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302319 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2320 if (NULL == pAdapter)
2321 {
2322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2323 "%s: Adapter is NULL",__func__);
2324 return -EINVAL;
2325 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002326
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2328 ret = wlan_hdd_validate_context(pHddCtx);
2329 if (0 != ret)
2330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302331 return ret;
2332 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002333
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302334 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2335 if (NULL == pWextState)
2336 {
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2338 "%s: pWextState is NULL",__func__);
2339 return -EINVAL;
2340 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002341
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302342 if (!wrqu->data.length) {
2343 hdd_clearRoamProfileIe(pAdapter);
2344 EXIT();
2345 return 0;
2346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002347
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302348 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2349 wrqu->data.length);
2350 if (NULL == base_genie)
2351 {
2352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2353 "mem_alloc_copy_from_user_helper fail");
2354 return -ENOMEM;
2355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002356
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302357 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002358
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302359 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002360
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302361 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2362
2363 /* clear any previous genIE before this call */
2364 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2365
2366 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 {
2368 v_U16_t eLen = 0;
2369 v_U8_t elementId;
2370 elementId = *genie++;
2371 eLen = *genie++;
2372 remLen -= 2;
2373
Arif Hussain6d2a3322013-11-17 19:50:10 -08002374 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 __func__, elementId, eLen);
2376
2377 switch ( elementId )
2378 {
2379 case IE_EID_VENDOR:
2380 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002381 {
2382 kfree(base_genie);
2383 return -EINVAL;
2384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2387 {
2388 v_U16_t curGenIELen = pWextState->genIE.length;
2389 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2390 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2391
2392 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2393 {
2394 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002395 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002397 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 return -ENOMEM;
2399 }
2400 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2401 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2402 pWextState->genIE.length += eLen + 2;
2403 }
2404 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2405 {
2406 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2407 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2408 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2409 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2410 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2411 }
2412 else /* any vendorId except WPA IE should be accumulated to genIE */
2413 {
2414 v_U16_t curGenIELen = pWextState->genIE.length;
2415 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2416 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2417
2418 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2419 {
2420 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002421 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002423 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 return -ENOMEM;
2425 }
2426 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2427 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2428 pWextState->genIE.length += eLen + 2;
2429 }
2430 break;
2431 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002432 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2434 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2435 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2436 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2437 break;
2438
2439 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002440 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002441 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 return 0;
2443 }
2444 genie += eLen;
2445 remLen -= eLen;
2446 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302447
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002449 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 return 0;
2451}
2452
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302453static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 struct iw_request_info *info,
2455 union iwreq_data *wrqu,
2456 char *extra)
2457{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302458 int ret;
2459
2460 vos_ssr_protect(__func__);
2461 ret = __iw_set_genie(dev, info, wrqu, extra);
2462 vos_ssr_unprotect(__func__);
2463
2464 return ret;
2465}
2466
2467static int __iw_get_genie(struct net_device *dev,
2468 struct iw_request_info *info,
2469 union iwreq_data *wrqu,
2470 char *extra)
2471{
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302473 hdd_context_t *pHddCtx;
2474 hdd_adapter_t *pAdapter;
2475 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 eHalStatus status;
2477 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2478 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2479
2480 ENTER();
2481
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302482 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2483 if (NULL == pAdapter)
2484 {
2485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2486 "%s: Adapter is NULL",__func__);
2487 return -EINVAL;
2488 }
2489 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2490 status = wlan_hdd_validate_context(pHddCtx);
2491 if (0 != status)
2492 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302493 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 }
2495
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 if (NULL == pWextState)
2498 {
2499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2500 "%s: pWextState is NULL",__func__);
2501 return -EINVAL;
2502 }
2503
2504 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2505 if (NULL == pHddStaCtx)
2506 {
2507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2508 "%s: STA Context is NULL",__func__);
2509 return -EINVAL;
2510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
2512 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2513 {
2514 return -ENXIO;
2515 }
2516
2517 // Return something ONLY if we are associated with an RSN or WPA network
2518 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2519 pWextState->roamProfile.negotiatedAuthType))
2520 {
2521 return -ENXIO;
2522 }
2523
2524 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2525 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2526 pAdapter->sessionId,
2527 &length,
2528 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002529 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2530 if (wrqu->data.length < length)
2531 {
2532 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2533 return -EFAULT;
2534 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002535 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002536 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002537
Arif Hussain6d2a3322013-11-17 19:50:10 -08002538 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
2540 EXIT();
2541
2542 return 0;
2543}
2544
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302545static int iw_get_genie(struct net_device *dev,
2546 struct iw_request_info *info,
2547 union iwreq_data *wrqu,
2548 char *extra)
2549{
2550 int ret;
2551
2552 vos_ssr_protect(__func__);
2553 ret = __iw_get_genie(dev, info, wrqu, extra);
2554 vos_ssr_unprotect(__func__);
2555
2556 return ret;
2557}
2558
2559
2560static int __iw_get_encode(struct net_device *dev,
2561 struct iw_request_info *info,
2562 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002563{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302564 hdd_adapter_t *pAdapter;
2565 hdd_context_t *pHddCtx;
2566 hdd_wext_state_t *pWextState;
2567 tCsrRoamProfile *pRoamProfile;
2568 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002570
2571 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302572 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2573 if (NULL == pAdapter)
2574 {
2575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2576 "%s: Adapter is NULL",__func__);
2577 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 }
2579
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302580 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2581 ret = wlan_hdd_validate_context(pHddCtx);
2582 if (0 != ret)
2583 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302584 return ret;
2585 }
2586 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2587 if (NULL == pWextState)
2588 {
2589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2590 "%s: pWextState is NULL",__func__);
2591 return -EINVAL;
2592 }
2593
2594 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 keyId = pRoamProfile->Keys.defaultIndex;
2596
2597 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2598 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002599 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 return -EINVAL;
2601 }
2602
2603 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2604 {
2605 dwrq->flags |= IW_ENCODE_ENABLED;
2606 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2607 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2608
2609 dwrq->flags |= (keyId + 1);
2610
2611 }
2612 else
2613 {
2614 dwrq->flags |= IW_ENCODE_DISABLED;
2615 }
2616
2617 for(i=0; i < MAX_WEP_KEYS; i++)
2618 {
2619 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2620 {
2621 continue;
2622 }
2623 else
2624 {
2625 break;
2626 }
2627 }
2628
2629 if(MAX_WEP_KEYS == i)
2630 {
2631 dwrq->flags |= IW_ENCODE_NOKEY;
2632 }
2633
2634 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2635
2636 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2637 {
2638 dwrq->flags |= IW_ENCODE_OPEN;
2639 }
2640 else
2641 {
2642 dwrq->flags |= IW_ENCODE_RESTRICTED;
2643 }
2644 EXIT();
2645 return 0;
2646}
2647
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302648static int iw_get_encode(struct net_device *dev,
2649 struct iw_request_info *info,
2650 struct iw_point *dwrq, char *extra)
2651{
2652 int ret;
2653
2654 vos_ssr_protect(__func__);
2655 ret = __iw_get_encode(dev, info, dwrq, extra);
2656 vos_ssr_unprotect(__func__);
2657
2658 return ret;
2659}
2660
Jeff Johnson295189b2012-06-20 16:38:30 -07002661#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2662#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2663
2664
2665/*
2666 * This function sends a single 'key' to LIM at all time.
2667 */
2668
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302669static int __iw_get_rts_threshold(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002672{
2673 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2674 v_U32_t status = 0;
2675
2676 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2677
2678 return status;
2679}
2680
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302681static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 struct iw_request_info *info,
2683 union iwreq_data *wrqu, char *extra)
2684{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302685 int ret;
2686
2687 vos_ssr_protect(__func__);
2688 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2689 vos_ssr_unprotect(__func__);
2690
2691 return ret;
2692}
2693
2694static int __iw_set_rts_threshold(struct net_device *dev,
2695 struct iw_request_info *info,
2696 union iwreq_data *wrqu, char *extra)
2697{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302698 hdd_adapter_t *pAdapter;
2699 hdd_context_t *pHddCtx;
2700 tHalHandle hHal;
2701 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002702
2703 ENTER();
2704
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302705 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2706 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002707 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2709 "%s: Adapter is NULL",__func__);
2710 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002711 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302712
2713 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2714 ret = wlan_hdd_validate_context(pHddCtx);
2715 if (0 != ret)
2716 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302717 return ret;
2718 }
2719
2720 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2721 if (NULL == hHal)
2722 {
2723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2724 "%s: Hal Context is NULL",__func__);
2725 return -EINVAL;
2726 }
2727
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2729 {
2730 return -EINVAL;
2731 }
2732
2733 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2734 {
c_hpothub8245442013-11-20 23:41:09 +05302735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2736 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 return -EIO;
2738 }
2739
2740 EXIT();
2741
2742 return 0;
2743}
2744
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302745static int iw_set_rts_threshold(struct net_device *dev,
2746 struct iw_request_info *info,
2747 union iwreq_data *wrqu, char *extra)
2748{
2749 int ret;
2750
2751 vos_ssr_protect(__func__);
2752 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2753 vos_ssr_unprotect(__func__);
2754
2755 return ret;
2756}
2757
2758static int __iw_get_frag_threshold(struct net_device *dev,
2759 struct iw_request_info *info,
2760 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002761{
2762 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2763 v_U32_t status = 0;
2764
2765 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2766
2767 return status;
2768}
2769
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302770static int iw_get_frag_threshold(struct net_device *dev,
2771 struct iw_request_info *info,
2772 union iwreq_data *wrqu, char *extra)
2773{
2774 int ret;
2775
2776 vos_ssr_protect(__func__);
2777 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2778 vos_ssr_unprotect(__func__);
2779
2780 return ret;
2781}
2782
2783static int __iw_set_frag_threshold(struct net_device *dev,
2784 struct iw_request_info *info,
2785 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002786{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302787 hdd_adapter_t *pAdapter;
2788 hdd_context_t *pHddCtx;
2789 tHalHandle hHal;
2790 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791
2792 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302793 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2794 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002795 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2797 "%s: Adapter is NULL",__func__);
2798 return -EINVAL;
2799 }
2800
2801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2802 ret = wlan_hdd_validate_context(pHddCtx);
2803 if (0 != ret)
2804 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302805 return ret;
2806 }
2807
2808 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2809 if (NULL == hHal)
2810 {
2811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2812 "%s: Hal Context is NULL",__func__);
2813 return -EINVAL;
2814 }
2815
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2817 {
2818 return -EINVAL;
2819 }
2820
2821 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2822 {
c_hpothub8245442013-11-20 23:41:09 +05302823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2824 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 return -EIO;
2826 }
2827
2828 EXIT();
2829
2830 return 0;
2831}
2832
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302833static int iw_set_frag_threshold(struct net_device *dev,
2834 struct iw_request_info *info,
2835 union iwreq_data *wrqu, char *extra)
2836{
2837 int ret;
2838
2839 vos_ssr_protect(__func__);
2840 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2841 vos_ssr_unprotect(__func__);
2842
2843 return ret;
2844}
2845
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302846static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 struct iw_request_info *info,
2848 union iwreq_data *wrqu, char *extra)
2849{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302850 hdd_adapter_t *pAdapter;
2851 hdd_context_t *pHddCtx;
2852 int ret = 0;
2853
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302855 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2856 if (NULL == pAdapter)
2857 {
2858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2859 "%s: Adapter is NULL",__func__);
2860 return -EINVAL;
2861 }
2862 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2863 ret = wlan_hdd_validate_context(pHddCtx);
2864 if (0 != ret)
2865 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302866 return ret;
2867 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302868
2869 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 return -EOPNOTSUPP;
2871}
2872
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302873static int iw_get_power_mode(struct net_device *dev,
2874 struct iw_request_info *info,
2875 union iwreq_data *wrqu, char *extra)
2876{
2877 int ret;
2878
2879 vos_ssr_protect(__func__);
2880 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2881 vos_ssr_unprotect(__func__);
2882
2883 return ret;
2884}
2885static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 struct iw_request_info *info,
2887 union iwreq_data *wrqu, char *extra)
2888{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302889 hdd_adapter_t *pAdapter;
2890 hdd_context_t *pHddCtx;
2891 int ret = 0;
2892
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302894 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2895 if (NULL == pAdapter)
2896 {
2897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2898 "%s: Adapter is NULL",__func__);
2899 return -EINVAL;
2900 }
2901 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2902 ret = wlan_hdd_validate_context(pHddCtx);
2903 if (0 != ret)
2904 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302905 return ret;
2906 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302907
2908 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 return -EOPNOTSUPP;
2910}
2911
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302912static int iw_set_power_mode(struct net_device *dev,
2913 struct iw_request_info *info,
2914 union iwreq_data *wrqu, char *extra)
2915{
2916 int ret;
2917
2918 vos_ssr_protect(__func__);
2919 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2920 vos_ssr_unprotect(__func__);
2921
2922 return ret;
2923}
2924
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302925static int __iw_get_range(struct net_device *dev,
2926 struct iw_request_info *info,
2927 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002928{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 hdd_adapter_t *pAdapter;
2930 tHalHandle hHal;
2931 hdd_context_t *pHddCtx;
2932 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 struct iw_range *range = (struct iw_range *) extra;
2934
2935 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2936
2937 v_U32_t num_channels = sizeof(channels);
2938 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2939 v_U32_t a_len;
2940 v_U32_t b_len;
2941 v_U32_t active_phy_mode = 0;
2942 v_U8_t index = 0, i;
2943
2944 ENTER();
2945
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302946 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2947 if (NULL == pAdapter)
2948 {
2949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2950 "%s: pAdapter is NULL", __func__);
2951 return -EINVAL;
2952 }
2953 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2954 ret = wlan_hdd_validate_context(pHddCtx);
2955 if (0 != ret)
2956 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302957 return ret;
2958 }
2959 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2960 if (NULL == hHal)
2961 {
2962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2963 "%s: pAdapter is NULL", __func__);
2964 return -EINVAL;
2965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 wrqu->data.length = sizeof(struct iw_range);
2967 memset(range, 0, sizeof(struct iw_range));
2968
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 /*Get the phy mode*/
2970 if (ccmCfgGetInt(hHal,
2971 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2972 {
2973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002974 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002975
2976 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2977 {
2978 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002979 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 if (ccmCfgGetStr(hHal,
2981 WNI_CFG_SUPPORTED_RATES_11A,
2982 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2983 {
2984 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2985 {
2986 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2987 }
2988 for (i = 0; i < a_len; i++)
2989 {
2990 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2991 }
2992 range->num_bitrates = a_len;
2993 }
2994 else
2995 {
2996 return -EIO;
2997 }
2998 }
2999 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3000 {
3001 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003002 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 if (ccmCfgGetStr(hHal,
3004 WNI_CFG_SUPPORTED_RATES_11B,
3005 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3006 {
3007 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3008 {
3009 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3010 }
3011 for (i = 0; i < b_len; i++)
3012 {
3013 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3014 }
3015 range->num_bitrates = b_len;
3016 }
3017 else
3018 {
3019 return -EIO;
3020 }
3021 }
3022 }
3023
3024 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3025 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3026 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3027
3028 range->encoding_size[0] = 5;
3029 range->encoding_size[1] = 13;
3030 range->num_encoding_sizes = 2;
3031 range->max_encoding_tokens = MAX_WEP_KEYS;
3032
3033 // we support through Wireless Extensions 22
3034 range->we_version_compiled = WIRELESS_EXT;
3035 range->we_version_source = 22;
3036
3037 /*Supported Channels and Frequencies*/
3038 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3039 {
c_hpothub8245442013-11-20 23:41:09 +05303040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3041 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 return -EIO;
3043 }
3044 if (num_channels > IW_MAX_FREQUENCIES)
3045 {
3046 num_channels = IW_MAX_FREQUENCIES;
3047 }
3048
3049 range->num_channels = num_channels;
3050 range->num_frequency = num_channels;
3051
3052 for (index=0; index < num_channels; index++)
3053 {
3054 v_U32_t frq_indx = 0;
3055
3056 range->freq[index].i = channels[index];
3057 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3058 {
3059 if(channels[index] == freq_chan_map[frq_indx].chan)
3060 {
3061 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3062 range->freq[index].e = 1;
3063 break;
3064 }
3065 frq_indx++;
3066 }
3067 }
3068
3069 /* Event capability (kernel + driver) */
3070 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3071 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3072 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3073 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3074
3075 /*Encryption capability*/
3076 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3077 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3078
3079 /* Txpower capability */
3080 range->txpower_capa = IW_TXPOW_MWATT;
3081
3082 /*Scanning capability*/
3083 #if WIRELESS_EXT >= 22
3084 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3085 #endif
3086
3087 EXIT();
3088 return 0;
3089}
3090
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303091static int iw_get_range(struct net_device *dev,
3092 struct iw_request_info *info,
3093 union iwreq_data *wrqu, char *extra)
3094{
3095 int ret;
3096
3097 vos_ssr_protect(__func__);
3098 ret = __iw_get_range(dev, info, wrqu, extra);
3099 vos_ssr_unprotect(__func__);
3100
3101 return ret;
3102}
3103
Jeff Johnson295189b2012-06-20 16:38:30 -07003104/* Callback function registered with PMC to know status of PMC request */
3105static void iw_power_callback_fn (void *pContext, eHalStatus status)
3106{
3107 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003108
3109 if (NULL == pContext)
3110 {
3111 hddLog(VOS_TRACE_LEVEL_ERROR,
3112 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003113 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 return;
3115 }
3116
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003118
Jeff Johnson72a40512013-12-19 10:14:15 -08003119 /* there is a race condition that exists between this callback
3120 function and the caller since the caller could time out either
3121 before or while this code is executing. we use a spinlock to
3122 serialize these actions */
3123 spin_lock(&hdd_context_lock);
3124
3125 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 {
3127 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003128 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003130 "%s: Invalid context, magic [%08x]",
3131 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003132
3133 if (ioctl_debug)
3134 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003135 pr_info("%s: Invalid context, magic [%08x]\n",
3136 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 }
3138 return;
3139 }
3140
Jeff Johnson72a40512013-12-19 10:14:15 -08003141 /* context is valid so caller is still waiting */
3142
3143 /* paranoia: invalidate the magic */
3144 pStatsContext->magic = 0;
3145
3146 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003148
3149 /* serialization is complete */
3150 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003151}
3152
3153/* Callback function for tx per hit */
3154void hdd_tx_per_hit_cb (void *pCallbackContext)
3155{
3156 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3157 unsigned char tx_fail[16];
3158 union iwreq_data wrqu;
3159
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303160 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003162 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 return;
3164 }
3165 memset(&wrqu, 0, sizeof(wrqu));
3166 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3167 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3168}
3169
3170void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3171{
3172 struct statsContext *pStatsContext;
3173 tCsrGlobalClassAStatsInfo *pClassAStats;
3174 hdd_adapter_t *pAdapter;
3175
3176 if (ioctl_debug)
3177 {
3178 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003179 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 }
3181
3182 if ((NULL == pStats) || (NULL == pContext))
3183 {
3184 hddLog(VOS_TRACE_LEVEL_ERROR,
3185 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003186 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 return;
3188 }
3189
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 pClassAStats = pStats;
3191 pStatsContext = pContext;
3192 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003193
3194 /* there is a race condition that exists between this callback
3195 function and the caller since the caller could time out either
3196 before or while this code is executing. we use a spinlock to
3197 serialize these actions */
3198 spin_lock(&hdd_context_lock);
3199
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3201 {
3202 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003203 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 hddLog(VOS_TRACE_LEVEL_WARN,
3205 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003206 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 if (ioctl_debug)
3208 {
3209 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003210 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 }
3212 return;
3213 }
3214
Jeff Johnson72a40512013-12-19 10:14:15 -08003215 /* context is valid so caller is still waiting */
3216
3217 /* paranoia: invalidate the magic */
3218 pStatsContext->magic = 0;
3219
3220 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3222
Jeff Johnson72a40512013-12-19 10:14:15 -08003223 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003225
3226 /* serialization is complete */
3227 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003228}
3229
3230VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3231{
3232 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3233 eHalStatus hstatus;
3234 long lrc;
3235 struct statsContext context;
3236
3237 if (NULL == pAdapter)
3238 {
3239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3240 return VOS_STATUS_E_FAULT;
3241 }
3242 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3243 {
3244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3245 return VOS_STATUS_SUCCESS;
3246 }
3247
3248 /* we are connected
3249 prepare our callback context */
3250 init_completion(&context.completion);
3251 context.pAdapter = pAdapter;
3252 context.magic = STATS_CONTEXT_MAGIC;
3253 /* query only for Class A statistics (which include link speed) */
3254 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3255 eCSR_HDD,
3256 SME_GLOBAL_CLASSA_STATS,
3257 hdd_GetClassA_statisticsCB,
3258 0, // not periodic
3259 FALSE, //non-cached results
3260 pHddStaCtx->conn_info.staId[0],
3261 &context);
3262 if (eHAL_STATUS_SUCCESS != hstatus)
3263 {
3264 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003265 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003266 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 /* we'll returned a cached value below */
3268 }
3269 else
3270 {
3271 /* request was sent -- wait for the response */
3272 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3273 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 if (lrc <= 0)
3275 {
3276 hddLog(VOS_TRACE_LEVEL_ERROR,
3277 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003278 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 }
3280 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003281
3282 /* either we never sent a request, we sent a request and received a
3283 response or we sent a request and timed out. if we never sent a
3284 request or if we sent a request and got a response, we want to
3285 clear the magic out of paranoia. if we timed out there is a
3286 race condition such that the callback function could be
3287 executing at the same time we are. of primary concern is if the
3288 callback function had already verified the "magic" but had not
3289 yet set the completion variable when a timeout occurred. we
3290 serialize these activities by invalidating the magic while
3291 holding a shared spinlock which will cause us to block if the
3292 callback is currently executing */
3293 spin_lock(&hdd_context_lock);
3294 context.magic = 0;
3295 spin_unlock(&hdd_context_lock);
3296
3297 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 return VOS_STATUS_SUCCESS;
3299}
3300
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003301static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3302{
3303 struct statsContext *pStatsContext;
3304 tCsrSummaryStatsInfo *pSummaryStats;
3305 tCsrGlobalClassAStatsInfo *pClassAStats;
3306 hdd_adapter_t *pAdapter;
3307
3308 if (ioctl_debug)
3309 {
3310 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003311 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003312 }
3313
3314 if ((NULL == pStats) || (NULL == pContext))
3315 {
3316 hddLog(VOS_TRACE_LEVEL_ERROR,
3317 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003318 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003319 return;
3320 }
3321
Jeff Johnson72a40512013-12-19 10:14:15 -08003322 /* there is a race condition that exists between this callback
3323 function and the caller since the caller could time out either
3324 before or while this code is executing. we use a spinlock to
3325 serialize these actions */
3326 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003327
3328 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3329 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3330 pStatsContext = pContext;
3331 pAdapter = pStatsContext->pAdapter;
3332 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3333 {
3334 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003335 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003336 hddLog(VOS_TRACE_LEVEL_WARN,
3337 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003338 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003339 if (ioctl_debug)
3340 {
3341 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003342 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003343 }
3344 return;
3345 }
3346
Jeff Johnson72a40512013-12-19 10:14:15 -08003347 /* context is valid so caller is still waiting */
3348
3349 /* paranoia: invalidate the magic */
3350 pStatsContext->magic = 0;
3351
3352 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003353 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3354 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3355
Jeff Johnson72a40512013-12-19 10:14:15 -08003356 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003357 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003358
3359 /* serialization is complete */
3360 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003361}
3362
3363VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3364{
3365 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3366 eHalStatus hstatus;
3367 long lrc;
3368 struct statsContext context;
3369
3370 if (NULL == pAdapter)
3371 {
3372 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3373 return VOS_STATUS_SUCCESS;
3374 }
3375
3376 /* we are connected
3377 prepare our callback context */
3378 init_completion(&context.completion);
3379 context.pAdapter = pAdapter;
3380 context.magic = STATS_CONTEXT_MAGIC;
3381
3382 /* query only for Summary & Class A statistics */
3383 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3384 eCSR_HDD,
3385 SME_SUMMARY_STATS |
3386 SME_GLOBAL_CLASSA_STATS,
3387 hdd_get_station_statisticsCB,
3388 0, // not periodic
3389 FALSE, //non-cached results
3390 pHddStaCtx->conn_info.staId[0],
3391 &context);
3392 if (eHAL_STATUS_SUCCESS != hstatus)
3393 {
3394 hddLog(VOS_TRACE_LEVEL_ERROR,
3395 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003396 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003397 /* we'll return with cached values */
3398 }
3399 else
3400 {
3401 /* request was sent -- wait for the response */
3402 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3403 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003404
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003405 if (lrc <= 0)
3406 {
3407 hddLog(VOS_TRACE_LEVEL_ERROR,
3408 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003409 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003410 }
3411 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003412
3413 /* either we never sent a request, we sent a request and received a
3414 response or we sent a request and timed out. if we never sent a
3415 request or if we sent a request and got a response, we want to
3416 clear the magic out of paranoia. if we timed out there is a
3417 race condition such that the callback function could be
3418 executing at the same time we are. of primary concern is if the
3419 callback function had already verified the "magic" but had not
3420 yet set the completion variable when a timeout occurred. we
3421 serialize these activities by invalidating the magic while
3422 holding a shared spinlock which will cause us to block if the
3423 callback is currently executing */
3424 spin_lock(&hdd_context_lock);
3425 context.magic = 0;
3426 spin_unlock(&hdd_context_lock);
3427
3428 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003429 return VOS_STATUS_SUCCESS;
3430}
3431
3432
Jeff Johnson295189b2012-06-20 16:38:30 -07003433/*
3434 * Support for the LINKSPEED private command
3435 * Per the WiFi framework the response must be of the form
3436 * "LinkSpeed xx"
3437 */
3438static int iw_get_linkspeed(struct net_device *dev,
3439 struct iw_request_info *info,
3440 union iwreq_data *wrqu, char *extra)
3441{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303442 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303443 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303445 int len = sizeof(v_U32_t) + 1;
3446 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303447 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303448 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303449 int rc, valid = 0;
3450
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303451 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303452 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3453 if (NULL == pAdapter)
3454 {
3455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3456 "%s: Adapter is NULL",__func__);
3457 return -EINVAL;
3458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003459
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303460 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303461 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303462 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003463 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303464 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003465 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303466 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3467 if (NULL == pHddStaCtx)
3468 {
3469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3470 "%s: STA Context is NULL",__func__);
3471 return -EINVAL;
3472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3474 {
3475 /* we are not connected so we don't have a classAstats */
3476 link_speed = 0;
3477 }
3478 else
3479 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303480 status = wlan_hdd_get_classAstats(pAdapter);
3481
3482 if (!VOS_IS_STATUS_SUCCESS(status ))
3483 {
3484 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3485 return -EINVAL;
3486 }
3487
3488 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3489 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3490 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3491 &link_speed);
3492
3493 link_speed = link_speed / 10;
3494
3495 if (0 == link_speed)
3496 {
3497 /* The linkspeed returned by HAL is in units of 500kbps.
3498 * converting it to mbps.
3499 * This is required to support legacy firmware which does
3500 * not return link capacity.
3501 */
3502 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3503 }
3504
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 }
3506
3507 wrqu->data.length = len;
3508 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003509 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 if ((rc < 0) || (rc >= len))
3511 {
3512 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303513 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 return -EIO;
3515 }
3516
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303517 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003519 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003520}
3521
Arif Hussain695279c2014-03-24 14:06:07 -07003522/*
3523 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3524 *
3525 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303526static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003527 struct iw_request_info *info,
3528 union iwreq_data *wrqu, char *extra)
3529{
3530 int rc;
3531
3532 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3533
3534 if (rc < 0)
3535 return rc;
3536
3537 /* a value is being successfully returned */
3538 return 0;
3539}
Jeff Johnson295189b2012-06-20 16:38:30 -07003540
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303541static int iw_get_linkspeed_priv(struct net_device *dev,
3542 struct iw_request_info *info,
3543 union iwreq_data *wrqu, char *extra)
3544{
3545 int ret;
3546
3547 vos_ssr_protect(__func__);
3548 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3549 vos_ssr_unprotect(__func__);
3550
3551 return ret;
3552}
3553
Jeff Johnson295189b2012-06-20 16:38:30 -07003554/*
3555 * Support for the RSSI & RSSI-APPROX private commands
3556 * Per the WiFi framework the response must be of the form
3557 * "<ssid> rssi <xx>"
3558 * unless we are not associated, in which case the response is
3559 * "OK"
3560 */
3561static int iw_get_rssi(struct net_device *dev,
3562 struct iw_request_info *info,
3563 union iwreq_data *wrqu, char *extra)
3564{
3565 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003566 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 int len = wrqu->data.length;
3568 v_S7_t s7Rssi = 0;
3569 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3570 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3571 VOS_STATUS vosStatus;
3572 int rc;
3573
3574 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3575 (0 == ssidlen) || (ssidlen >= len))
3576 {
3577 /* we are not connected or our SSID is too long
3578 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003579 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 }
3581 else
3582 {
3583 /* we are connected with a valid SSID
3584 so we can write the SSID into the return buffer
3585 (note that it is not NUL-terminated) */
3586 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3587
3588 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3589
3590 if (VOS_STATUS_SUCCESS == vosStatus)
3591 {
3592 /* append the rssi to the ssid in the format required by
3593 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003594 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303595 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 }
3597 else
3598 {
3599 rc = -1;
3600 }
3601 }
3602
3603 /* verify that we wrote a valid response */
3604 if ((rc < 0) || (rc >= len))
3605 {
3606 // encoding or length error?
3607 hddLog(VOS_TRACE_LEVEL_ERROR,
3608 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003609 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 return -EIO;
3611 }
3612
3613 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003614 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003615}
3616
3617/*
3618 * Support for SoftAP channel range private command
3619 */
3620static int iw_softap_set_channel_range( struct net_device *dev,
3621 int startChannel,
3622 int endChannel,
3623 int band)
3624{
Jeff Johnson43971f52012-07-17 12:26:56 -07003625 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 int ret = 0;
3627 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3628 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003629 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3630
Jeff Johnson295189b2012-06-20 16:38:30 -07003631
3632 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3633 if (VOS_STATUS_SUCCESS != status)
3634 {
3635 ret = -EINVAL;
3636 }
Yathish9f22e662012-12-10 14:21:35 -08003637 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 return ret;
3639}
3640
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303641static uint8 chartohex(char c)
3642{
3643 uint8 val = 0;
3644 if (c >= '0' && c <= '9')
3645 val = c - '0';
3646 else if (c >= 'a' && c <= 'f')
3647 val = c - 'a' + 10;
3648 else if (c >= 'A' && c <= 'F')
3649 val = c - 'A' + 10;
3650 else
3651 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3652
3653 return val;
3654}
3655
3656uint8 getByte(char **buf)
3657{
3658 uint8 byte = 0;
3659 char *temp = *buf;
3660 byte = chartohex(*temp) * 16;
3661 temp++;
3662 byte += chartohex(*temp);
3663 temp++;
3664 *buf = temp;
3665 return byte;
3666}
3667
3668static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3669{
3670 tSir80211Header *macHeader;
3671 int i = 0, j = 0, length = 0;
3672 uint8 byte = 0;
3673 char *temp = pBuffer;
3674 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303675 char *pHeader;
3676 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303677
3678 macHeader = &pkt->macHeader;
3679
3680 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3681
3682 temp++;
3683
3684 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3685 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3686 pkt->encParams.keyParams.key[0].keyId);
3687
3688 for (i = 0; i< 16; i++) {
3689 pkt->encParams.keyParams.key[0].key[i]
3690 = getByte(&temp);
3691 }
3692
3693 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3694 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3695
3696 for (i = 0; i< 6; i++) {
3697 pkt->encParams.pn[i]
3698 = getByte(&temp);
3699 }
3700
3701 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3702 &pkt->encParams.pn[0], 6, 0);
3703
3704 for (i = 0, j= 5; i< 3; i++, j--) {
3705 byte = pkt->encParams.pn[i];
3706 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3707 pkt->encParams.pn[j] = byte;
3708 }
3709
3710 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303711 if (length > sizeof(tSir80211Header))
3712 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303713
Srinivas Dasari2382de62015-01-22 15:00:04 +05303714 pHeader = temp;
3715 vos_mem_zero(&header, sizeof(tSir80211Header));
3716 for (i = 0; i < length; i++) {
3717 *((uint8 *)&header + i) = getByte(&pHeader);
3718 }
3719
3720 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3721 (char *)&header, length, 0);
3722
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303723 byte = getByte(&temp);
3724
3725 macHeader->frameCtrl.protVer = byte & 0x3;
3726 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3727 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3728
3729 byte = getByte(&temp);
3730 macHeader->frameCtrl.toDS = (byte) & 0x1;
3731 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3732 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3733 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3734 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3735 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3736 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3737 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3738
3739 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3740 "macHeader->frameCtrl.type : %x "
3741 "macHeader->frameCtrl.subType : %x "
3742 "macHeader->frameCtrl.toDS : %x "
3743 "macHeader->frameCtrl.fromDS : %x "
3744 "macHeader->frameCtrl.moreFrag : %x "
3745 "macHeader->frameCtrl.retry : %x "
3746 "macHeader->frameCtrl.powerMgmt : %x "
3747 "macHeader->frameCtrl.MoreData : %x "
3748 "macHeader->frameCtrl.wep : %x "
3749 "macHeader->frameCtrl.order : %x "
3750 , macHeader->frameCtrl.protVer
3751 , macHeader->frameCtrl.type
3752 , macHeader->frameCtrl.subType
3753 , macHeader->frameCtrl.toDS
3754 , macHeader->frameCtrl.fromDS
3755 , macHeader->frameCtrl.moreFrag
3756 , macHeader->frameCtrl.retry
3757 , macHeader->frameCtrl.powerMgmt
3758 , macHeader->frameCtrl.moreData
3759 , macHeader->frameCtrl.wep
3760 , macHeader->frameCtrl.order);
3761
3762
3763 macHeader->usDurationId = getByte(&temp);
3764 macHeader->usDurationId += getByte(&temp) << 8;
3765
3766 macHeader->vA1[0] = getByte(&temp);
3767 macHeader->vA1[1] = getByte(&temp);
3768 macHeader->vA1[2] = getByte(&temp);
3769 macHeader->vA1[3] = getByte(&temp);
3770 macHeader->vA1[4] = getByte(&temp);
3771 macHeader->vA1[5] = getByte(&temp);
3772
3773 macHeader->vA2[0] = getByte(&temp);
3774 macHeader->vA2[1] = getByte(&temp);
3775 macHeader->vA2[2] = getByte(&temp);
3776 macHeader->vA2[3] = getByte(&temp);
3777 macHeader->vA2[4] = getByte(&temp);
3778 macHeader->vA2[5] = getByte(&temp);
3779
3780 macHeader->vA3[0] = getByte(&temp);
3781 macHeader->vA3[1] = getByte(&temp);
3782 macHeader->vA3[2] = getByte(&temp);
3783 macHeader->vA3[3] = getByte(&temp);
3784 macHeader->vA3[4] = getByte(&temp);
3785 macHeader->vA3[5] = getByte(&temp);
3786
3787 macHeader->sSeqCtrl = getByte(&temp);
3788 fragNum = macHeader->sSeqCtrl & 0xF;
3789 macHeader->sSeqCtrl >>= 4;
3790
3791 macHeader->sSeqCtrl += getByte(&temp) << 4;
3792
3793 macHeader->sSeqCtrl |= fragNum << 12;
3794
3795 if (length == 30 || length == 32) {
3796 macHeader->optvA4[0] = getByte(&temp);
3797 macHeader->optvA4[1] = getByte(&temp);
3798 macHeader->optvA4[2] = getByte(&temp);
3799 macHeader->optvA4[3] = getByte(&temp);
3800 macHeader->optvA4[4] = getByte(&temp);
3801 macHeader->optvA4[5] = getByte(&temp);
3802 }
3803
3804 if (length == 26 || length == 32) {
3805 macHeader->usQosCtrl = getByte(&temp);
3806 macHeader->usQosCtrl += getByte(&temp) << 8;
3807 }
3808
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303809 //parse payload
3810 length = getByte(&temp);
3811 length += getByte(&temp) << 8;
3812 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3813
3814 pkt->data.length = length;
3815
3816 for (i = 0; i< length; i++) {
3817 pkt->data.data[i] = getByte(&temp);
3818 }
3819
3820 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3821 &pkt->data.data[0], pkt->data.length, 0);
3822}
3823
3824/**---------------------------------------------------------------------------
3825
3826 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3827 encrypt message request
3828 This is an asynchronous callback function from SME when the encrypted data
3829 is received
3830
3831 \pEncInfoRsp -> Encrypted data info
3832
3833 \return - 0 for success non-zero for failure
3834 --------------------------------------------------------------------------*/
3835static void
3836hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3837{
3838 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3839
3840 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3841
3842 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3843 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3844 pEncryptedDataRsp->encryptedPayload.length);
3845 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3846 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3847 pEncryptedDataRsp->encryptedPayload.data,
3848 pEncryptedDataRsp->encryptedPayload.length, 0);
3849}
3850
Jeff Johnson295189b2012-06-20 16:38:30 -07003851VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3852{
3853 struct statsContext context;
3854 eHalStatus status;
3855 hdd_context_t *pHddCtx;
3856
3857 if (NULL == pAdapter)
3858 {
3859 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3860 return VOS_STATUS_E_FAULT;
3861 }
3862
3863 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303865 if (pHddCtx->isLogpInProgress) {
3866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3867 "%s:LOGP in Progress. Ignore!!!", __func__);
3868 return VOS_STATUS_E_FAILURE;
3869 }
3870
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 init_completion(&context.completion);
3872
3873 context.pAdapter = pAdapter;
3874 context.magic = POWER_CONTEXT_MAGIC;
3875
3876 if (DRIVER_POWER_MODE_ACTIVE == mode)
3877 {
3878 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3879 "Full Power", __func__);
3880 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3881 iw_power_callback_fn, &context,
3882 eSME_FULL_PWR_NEEDED_BY_HDD);
3883 // Enter Full power command received from GUI this means we are disconnected
3884 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3885 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3886 if (eHAL_STATUS_PMC_PENDING == status)
3887 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003888 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 int lrc = wait_for_completion_interruptible_timeout(
3890 &context.completion,
3891 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003892
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 if (lrc <= 0)
3894 {
3895 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003896 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 }
3898 }
3899 }
3900 else if (DRIVER_POWER_MODE_AUTO == mode)
3901 {
3902 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3903 {
3904 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3905 __func__);
3906 // Enter BMPS command received from GUI this means DHCP is completed
3907 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3908 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3909 FALSE);
3910 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3911 iw_power_callback_fn, &context);
3912 if (eHAL_STATUS_PMC_PENDING == status)
3913 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003914 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 int lrc = wait_for_completion_interruptible_timeout(
3916 &context.completion,
3917 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 if (lrc <= 0)
3919 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003920 hddLog(VOS_TRACE_LEVEL_ERROR,
3921 "%s: SME %s while requesting BMPS",
3922 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 }
3924 }
3925 }
3926 else
3927 {
3928 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3929 "enabled in the cfg");
3930 }
3931 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003932
3933 /* either we never sent a request, we sent a request and received a
3934 response or we sent a request and timed out. if we never sent a
3935 request or if we sent a request and got a response, we want to
3936 clear the magic out of paranoia. if we timed out there is a
3937 race condition such that the callback function could be
3938 executing at the same time we are. of primary concern is if the
3939 callback function had already verified the "magic" but had not
3940 yet set the completion variable when a timeout occurred. we
3941 serialize these activities by invalidating the magic while
3942 holding a shared spinlock which will cause us to block if the
3943 callback is currently executing */
3944 spin_lock(&hdd_context_lock);
3945 context.magic = 0;
3946 spin_unlock(&hdd_context_lock);
3947
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 return VOS_STATUS_SUCCESS;
3949}
3950
3951VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3952 hdd_adapter_t *pAdapter)
3953{
3954 VOS_STATUS vos_Status;
3955
3956 if ((NULL == pAdapter) || (NULL == pHddCtx))
3957 {
3958 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3959 return VOS_STATUS_E_FAULT;
3960 }
3961
3962 /**Exit from Deep sleep or standby if we get the driver
3963 START cmd from android GUI
3964 */
3965 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3966 {
3967 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3968 "from Stand by",__func__);
3969 vos_Status = hdd_exit_standby(pHddCtx);
3970 }
3971 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3972 {
3973 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3974 "from deep sleep",__func__);
3975 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3976 }
3977 else
3978 {
3979 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3980 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3981 vos_Status = VOS_STATUS_SUCCESS;
3982 }
3983
3984 return vos_Status;
3985}
3986
3987VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3988{
3989 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3990
3991 if (NULL == pHddCtx)
3992 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303993 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 return VOS_STATUS_E_FAULT;
3995 }
3996
3997 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3998 {
3999 //Execute standby procedure.
4000 //Executing standby procedure will cause the STA to
4001 //disassociate first and then the chip will be put into standby.
4002 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4003 vos_Status = hdd_enter_standby(pHddCtx);
4004 }
4005 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4006 pHddCtx->cfg_ini->nEnableDriverStop)
4007 {
4008 //Execute deep sleep procedure
4009 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004010 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 //Deep sleep not supported
4012 vos_Status = hdd_enter_standby(pHddCtx);
4013 }
4014 else
4015 {
4016 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4017 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4018 vos_Status = VOS_STATUS_SUCCESS;
4019 }
4020
4021 return vos_Status;
4022}
4023
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004024
4025void* wlan_hdd_change_country_code_callback(void *pAdapter)
4026{
4027
4028 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004029 complete(&call_back_pAdapter->change_country_code);
4030
4031 return NULL;
4032}
4033
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304034static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 struct iw_request_info *info,
4036 union iwreq_data *wrqu, char *extra)
4037{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304038 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004039 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304041 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004042 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4043
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304044 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004045
4046 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304047
4048 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4049 if (NULL == pAdapter)
4050 {
4051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4052 "mem_alloc_copy_from_user_helper fail");
4053 return -EINVAL;
4054 }
4055 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4056 rc = wlan_hdd_validate_context(pHddCtx);
4057 if (0 != rc)
4058 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304059 return rc;
4060 }
4061
Arif Hussain24bfa702014-01-22 13:51:30 -08004062 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4063 wrqu->data.length);
4064 if (NULL == cmd)
4065 {
4066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4067 "mem_alloc_copy_from_user_helper fail");
4068 return -ENOMEM;
4069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
4071 if (ioctl_debug)
4072 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004073 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 }
4075
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004076 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4077 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004078
Arif Hussain24bfa702014-01-22 13:51:30 -08004079 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004081 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4083 "%s: Error in iw_set_scan!", __func__);
4084 rc = -EINVAL;
4085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 }
4087 else if( strcasecmp(cmd, "start") == 0 ) {
4088
Arif Hussain6d2a3322013-11-17 19:50:10 -08004089 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004091
Arif Hussain24bfa702014-01-22 13:51:30 -08004092 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4093 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 union iwreq_data wrqu;
4096 char buf[10];
4097
4098 memset(&wrqu, 0, sizeof(wrqu));
4099 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4100 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4101 }
4102 else
4103 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004104 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4105 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 }
4107 goto done;
4108 }
4109 else if( strcasecmp(cmd, "stop") == 0 )
4110 {
4111 union iwreq_data wrqu;
4112 char buf[10];
4113
Arif Hussain6d2a3322013-11-17 19:50:10 -08004114 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004115
4116 wlan_hdd_enter_lowpower(pHddCtx);
4117 memset(&wrqu, 0, sizeof(wrqu));
4118 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4119 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 goto done;
4121 }
4122 else if (strcasecmp(cmd, "macaddr") == 0)
4123 {
4124 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4125 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4126 }
4127 else if (strcasecmp(cmd, "scan-active") == 0)
4128 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304129 hddLog(VOS_TRACE_LEVEL_ERROR,
4130 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004131 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 ret = snprintf(cmd, cmd_len, "OK");
4133 }
4134 else if (strcasecmp(cmd, "scan-passive") == 0)
4135 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304136 hddLog(VOS_TRACE_LEVEL_ERROR,
4137 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004138 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 ret = snprintf(cmd, cmd_len, "OK");
4140 }
4141 else if( strcasecmp(cmd, "scan-mode") == 0 )
4142 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004143 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 }
4145 else if( strcasecmp(cmd, "linkspeed") == 0 )
4146 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004147 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 }
4149 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4150 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004151 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004152 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004153
4154 country_code = cmd + 8;
4155
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004156 init_completion(&pAdapter->change_country_code);
4157
Arif Hussain24bfa702014-01-22 13:51:30 -08004158 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004159 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 country_code,
4161 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304162 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304163 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304164 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004165
4166 /* Wait for completion */
4167 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4168 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4169
4170 if (lrc <= 0)
4171 {
4172 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004173 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004174 }
4175
Arif Hussain24bfa702014-01-22 13:51:30 -08004176 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004178 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004179 "%s: SME Change Country code fail", __func__);
4180 kfree(cmd);
4181 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 }
4183 }
4184 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4185 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004186 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 }
4188 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4189 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004190 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004191
Wilson Yang1be3e652013-10-09 15:18:31 -07004192 if (9 < cmd_len)
4193 {
4194 ptr = (char*)(cmd + 9);
4195
4196 }else{
4197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4198 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004199 kfree(cmd);
4200 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004201 }
4202
4203 if (1 != sscanf(ptr,"%d",&mode))
4204 {
4205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4206 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004207 kfree(cmd);
4208 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004209 }
4210
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 wlan_hdd_enter_bmps(pAdapter, mode);
4212 /*TODO:Set the power mode*/
4213 }
4214 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4215 v_U32_t pmc_state;
4216 v_U16_t value;
4217
4218 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4219 if(pmc_state == BMPS) {
4220 value = DRIVER_POWER_MODE_AUTO;
4221 }
4222 else {
4223 value = DRIVER_POWER_MODE_ACTIVE;
4224 }
4225 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4226 }
4227 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004228 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 /*TODO: set the btcoexmode*/
4230 }
4231 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4232
Arif Hussain6d2a3322013-11-17 19:50:10 -08004233 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 /*TODO: Return the btcoex status*/
4235 }
4236 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4237
Arif Hussain6d2a3322013-11-17 19:50:10 -08004238 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004239
4240 /*TODO: Enable Rx data Filter*/
4241 }
4242 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4243
Arif Hussain6d2a3322013-11-17 19:50:10 -08004244 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004245
4246 /*TODO: Disable Rx data Filter*/
4247 }
4248 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4249
Arif Hussain6d2a3322013-11-17 19:50:10 -08004250 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 /*TODO: rxfilter-statistics*/
4252 }
4253 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4254
Arif Hussain6d2a3322013-11-17 19:50:10 -08004255 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 /*TODO: rxfilter-add*/
4257 }
4258 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4259
Arif Hussain6d2a3322013-11-17 19:50:10 -08004260 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 /*TODO: rxfilter-remove*/
4262 }
4263#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004264 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4265 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4266 /*TODO: support pnosetup*/
4267 }
4268 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4269 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4270 /*TODO: support pnoforce*/
4271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4273
Arif Hussain6d2a3322013-11-17 19:50:10 -08004274 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004275 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4276 kfree(cmd);
4277 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 }
4279 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004280 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004281 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4282 kfree(cmd);
4283 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 }
4285#endif /*FEATURE_WLAN_SCAN_PNO*/
4286 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004287 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004288 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4289 kfree(cmd);
4290 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 }
4292 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4293 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004294 char *ptr;
4295
4296 if (18 < cmd_len)
4297 {
4298 ptr = (char*)(cmd + 18);
4299 }else{
4300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4301 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004302 kfree(cmd);
4303 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004304 }
4305
Jeff Johnson02797792013-10-26 19:17:13 -07004306 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004307 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4308 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4309 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4310 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4311 {
4312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4313 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004314 kfree(cmd);
4315 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004317
4318 // parameters checking
4319 // period has to be larger than 0
4320 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4321 {
4322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004323 kfree(cmd);
4324 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 }
4326
4327 // use default value 5 is the input is not reasonable. in unit of 10%
4328 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4329 {
4330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4331 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4332 }
4333
4334 // default is 5
4335 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4336 {
4337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4338 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4339 }
4340
Arif Hussain24bfa702014-01-22 13:51:30 -08004341 if (eHAL_STATUS_SUCCESS !=
4342 sme_SetTxPerTracking(pHddCtx->hHal,
4343 hdd_tx_per_hit_cb,
4344 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004346 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 }
4348 }
4349 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004350 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4351 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 }
4353done:
4354 /* many of the commands write information back into the command
4355 string using snprintf(). check the return value here in one
4356 place */
4357 if ((ret < 0) || (ret >= cmd_len))
4358 {
4359 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004360 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004362 else if (ret > 0)
4363 {
4364 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4365 {
4366 hddLog(VOS_TRACE_LEVEL_ERROR,
4367 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004368 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004369 return -EFAULT;
4370 }
4371 wrqu->data.length = ret;
4372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004373
4374 if (ioctl_debug)
4375 {
4376 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004377 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004379 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304380 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004381 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004382}
4383
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304384static int iw_set_priv(struct net_device *dev,
4385 struct iw_request_info *info,
4386 union iwreq_data *wrqu, char *extra)
4387{
4388 int ret;
4389 vos_ssr_protect(__func__);
4390 ret = __iw_set_priv(dev, info, wrqu, extra);
4391 vos_ssr_unprotect(__func__);
4392
4393 return ret;
4394}
4395
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304396static int __iw_set_nick(struct net_device *dev,
4397 struct iw_request_info *info,
4398 union iwreq_data *wrqu, char *extra)
4399{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304400 hdd_adapter_t *pAdapter;
4401 hdd_context_t *pHddCtx;
4402 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304403
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304404 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304405
4406 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4407 if (NULL == pAdapter)
4408 {
4409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4410 "%s: Adapter is NULL",__func__);
4411 return -EINVAL;
4412 }
4413
4414 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4415 ret = wlan_hdd_validate_context(pHddCtx);
4416 if (0 != ret)
4417 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304418 return ret;
4419 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304420 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304421 return 0;
4422}
4423
Jeff Johnson295189b2012-06-20 16:38:30 -07004424static int iw_set_nick(struct net_device *dev,
4425 struct iw_request_info *info,
4426 union iwreq_data *wrqu, char *extra)
4427{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304428 int ret;
4429
4430 vos_ssr_protect(__func__);
4431 ret = __iw_set_nick(dev, info, wrqu, extra);
4432 vos_ssr_unprotect(__func__);
4433
4434 return ret;
4435}
4436
4437static int __iw_get_nick(struct net_device *dev,
4438 struct iw_request_info *info,
4439 union iwreq_data *wrqu, char *extra)
4440{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304441 hdd_adapter_t *pAdapter;
4442 hdd_context_t *pHddCtx;
4443 int ret = 0;
4444
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304446
4447 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4448 if (NULL == pAdapter)
4449 {
4450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4451 "%s: Adapter is NULL",__func__);
4452 return -EINVAL;
4453 }
4454
4455 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4456 ret = wlan_hdd_validate_context(pHddCtx);
4457 if (0 != ret)
4458 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459 return ret;
4460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 return 0;
4463}
4464
4465static int iw_get_nick(struct net_device *dev,
4466 struct iw_request_info *info,
4467 union iwreq_data *wrqu, char *extra)
4468{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304469 int ret;
4470
4471 vos_ssr_protect(__func__);
4472 ret = __iw_get_nick(dev, info, wrqu, extra);
4473 vos_ssr_unprotect(__func__);
4474
4475 return ret;
4476}
4477
4478static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4479{
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304481 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004482}
4483
4484static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4485{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304486
4487 struct iw_statistics *stats;
4488
4489 vos_ssr_protect(__func__);
4490 stats = __get_wireless_stats(dev);
4491 vos_ssr_unprotect(__func__);
4492
4493 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004494}
4495
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304496static int __iw_set_encode(struct net_device *dev,
4497 struct iw_request_info *info,
4498 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004499
4500{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304501 hdd_adapter_t *pAdapter;
4502 hdd_station_ctx_t *pHddStaCtx;
4503 hdd_wext_state_t *pWextState;
4504 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 struct iw_point *encoderq = &(wrqu->encoding);
4506 v_U32_t keyId;
4507 v_U8_t key_length;
4508 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4509 v_BOOL_t fKeyPresent = 0;
4510 int i;
4511 eHalStatus status = eHAL_STATUS_SUCCESS;
4512
4513
4514 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304515 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4516 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4519 "%s: Adapter is NULL",__func__);
4520 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 }
4522
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304523 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4524 status = wlan_hdd_validate_context(pHddCtx);
4525 if (0 != status)
4526 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304527 return status;
4528 }
4529 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4530 if (NULL == pWextState)
4531 {
4532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4533 "%s: pWextState is NULL ",__func__);
4534 return -EINVAL;
4535 }
4536 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4537 if (NULL == pHddStaCtx)
4538 {
4539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4540 "%s: STA Context is NULL",__func__);
4541 return -EINVAL;
4542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004543
4544 keyId = encoderq->flags & IW_ENCODE_INDEX;
4545
4546 if(keyId)
4547 {
4548 if(keyId > MAX_WEP_KEYS)
4549 {
4550 return -EINVAL;
4551 }
4552
4553 fKeyPresent = 1;
4554 keyId--;
4555 }
4556 else
4557 {
4558 fKeyPresent = 0;
4559 }
4560
4561
4562 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4563 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 if(!fKeyPresent) {
4566
4567 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4568
4569 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4570 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4571 }
4572 }
4573 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4574 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4575 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4576 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4577
4578 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4579 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4580
4581 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4582 {
4583 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4584 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004585 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304586 {
4587 long ret;
4588 ret = wait_for_completion_interruptible_timeout(
4589 &pAdapter->disconnect_comp_var,
4590 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4591 if (ret <= 0)
4592 hddLog(VOS_TRACE_LEVEL_ERROR,
4593 FL("failed wait on disconnect_comp_var %ld"), ret);
4594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 }
4596
4597 return status;
4598
4599 }
4600
4601 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4602 {
4603 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4604
4605 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4606
4607 }
4608
4609
4610 if(wrqu->data.length > 0)
4611 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004612 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004613
4614 key_length = wrqu->data.length;
4615
4616 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4617
4618 if(5 == key_length)
4619 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004620 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004621
4622 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4623 {
4624 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4625 }
4626 else
4627 {
4628 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4629 }
4630 }
4631 else if(13 == key_length)
4632 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004633 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634
4635 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4636 {
4637 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4638 }
4639 else
4640 {
4641 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4642 }
4643 }
4644 else
4645 {
4646 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004647 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 return -EINVAL;
4649 }
4650
4651 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4652 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4653 pWextState->roamProfile.EncryptionType.numEntries = 1;
4654 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4655 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4656 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4657
4658 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4659 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4660 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4661 {
4662
4663 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4664
4665 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4666 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4667
4668 return status;
4669 }
4670 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304671 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 return 0;
4673}
4674
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304675static int iw_set_encode(struct net_device *dev,
4676 struct iw_request_info *info,
4677 union iwreq_data *wrqu,char *extra)
4678{
4679 int ret;
4680
4681 vos_ssr_protect(__func__);
4682 ret = __iw_set_encode(dev, info, wrqu, extra);
4683 vos_ssr_unprotect(__func__);
4684
4685 return ret;
4686}
4687
4688static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 struct iw_request_info *info,
4690 struct iw_point *dwrq,
4691 char *extra)
4692{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304693 hdd_adapter_t *pAdapter;
4694 hdd_wext_state_t *pWextState;
4695 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 int keyId;
4697 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4698 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304699 int i, ret = 0;
4700 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004701
4702 ENTER();
4703
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304704 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4705 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004706 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4708 "%s: Adapter is NULL",__func__);
4709 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004710 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304711 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4712 ret = wlan_hdd_validate_context(pHddCtx);
4713 if (0 != ret)
4714 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304715 return ret;
4716 }
4717 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4718 if (NULL == pWextState)
4719 {
4720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4721 "%s: pWextState is NULL",__func__);
4722 return -EINVAL;
4723 }
4724 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004725
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 keyId = pRoamProfile->Keys.defaultIndex;
4727
4728 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4729 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004730 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 return -EINVAL;
4732 }
4733
4734 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4735 {
4736 dwrq->flags |= IW_ENCODE_ENABLED;
4737 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304738 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4739 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 }
4741 else
4742 {
4743 dwrq->flags |= IW_ENCODE_DISABLED;
4744 }
4745
4746 for(i=0; i < MAX_WEP_KEYS; i++)
4747 {
4748 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4749 {
4750 continue;
4751 }
4752 else
4753 {
4754 break;
4755 }
4756 }
4757
4758 if(MAX_WEP_KEYS == i)
4759 {
4760 dwrq->flags |= IW_ENCODE_NOKEY;
4761 }
4762 else
4763 {
4764 dwrq->flags |= IW_ENCODE_ENABLED;
4765 }
4766
4767 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4768
4769 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4770 {
4771 dwrq->flags |= IW_ENCODE_DISABLED;
4772 }
4773
4774 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4775
4776 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4777 {
4778 dwrq->flags |= IW_ENCODE_OPEN;
4779 }
4780 else
4781 {
4782 dwrq->flags |= IW_ENCODE_RESTRICTED;
4783 }
4784 EXIT();
4785 return 0;
4786
4787}
4788
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304789static int iw_get_encodeext(struct net_device *dev,
4790 struct iw_request_info *info,
4791 struct iw_point *dwrq,
4792 char *extra)
4793{
4794 int ret;
4795 vos_ssr_protect(__func__);
4796 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4797 vos_ssr_unprotect(__func__);
4798
4799 return ret;
4800}
4801
4802static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 struct iw_request_info *info,
4804 union iwreq_data *wrqu, char *extra)
4805{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304806 hdd_adapter_t *pAdapter;
4807 hdd_station_ctx_t *pHddStaCtx;
4808 hdd_wext_state_t *pWextState;
4809 hdd_context_t *pHddCtx;
4810 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004811
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304812 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 v_U32_t status = 0;
4814
4815 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4816
4817 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4818
4819 int key_index;
4820 struct iw_point *encoding = &wrqu->encoding;
4821 tCsrRoamSetKey setKey;
4822 v_U32_t roamId= 0xFF;
4823 VOS_STATUS vos_status;
4824
4825 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304826 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4827 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4830 "%s: Adapter is NULL",__func__);
4831 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304833 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4834 status = wlan_hdd_validate_context(pHddCtx);
4835 if (0 != status)
4836 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304837 return status;
4838 }
4839 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4840 if (NULL == pHddStaCtx)
4841 {
4842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4843 "%s: STA Context is NULL",__func__);
4844 return -EINVAL;
4845 }
4846 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4847 if (NULL == pWextState)
4848 {
4849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4850 "%s: pWextState is NULL",__func__);
4851 return -EINVAL;
4852 }
4853 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 key_index = encoding->flags & IW_ENCODE_INDEX;
4855
4856 if(key_index > 0) {
4857
4858 /*Convert from 1-based to 0-based keying*/
4859 key_index--;
4860 }
4861 if(!ext->key_len) {
4862
4863 /*Set the encrytion type to NONE*/
4864 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4865 return status;
4866 }
4867
4868 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4869 (IW_ENCODE_ALG_WEP == ext->alg))
4870 {
4871 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4872
Agarwal Ashish971c2882013-10-30 20:11:12 +05304873 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4874 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 return -EINVAL;
4876 }
4877 else {
4878 /*Static wep, update the roam profile with the keys */
4879 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4880 key_index < CSR_MAX_NUM_KEY) {
4881 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4882 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4883
4884 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4885 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4886
4887 }
4888 }
4889 return status;
4890 }
4891
4892 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4893
4894 setKey.keyId = key_index;
4895 setKey.keyLength = ext->key_len;
4896
4897 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4898 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4899 }
4900
4901 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4902 /*Key direction for group is RX only*/
4903 setKey.keyDirection = eSIR_RX_ONLY;
4904 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4905 }
4906 else {
4907
4908 setKey.keyDirection = eSIR_TX_RX;
4909 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4910 }
4911
4912 /*For supplicant pae role is zero*/
4913 setKey.paeRole = 0;
4914
4915 switch(ext->alg)
4916 {
4917 case IW_ENCODE_ALG_NONE:
4918 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4919 break;
4920
4921 case IW_ENCODE_ALG_WEP:
4922 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4923 break;
4924
4925 case IW_ENCODE_ALG_TKIP:
4926 {
4927 v_U8_t *pKey = &setKey.Key[0];
4928
4929 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4930
4931 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4932
4933 /*Supplicant sends the 32bytes key in this order
4934
4935 |--------------|----------|----------|
4936 | Tk1 |TX-MIC | RX Mic |
4937 |--------------|----------|----------|
4938 <---16bytes---><--8bytes--><--8bytes-->
4939
4940 */
4941 /*Sme expects the 32 bytes key to be in the below order
4942
4943 |--------------|----------|----------|
4944 | Tk1 |RX-MIC | TX Mic |
4945 |--------------|----------|----------|
4946 <---16bytes---><--8bytes--><--8bytes-->
4947 */
4948 /* Copy the Temporal Key 1 (TK1) */
4949 vos_mem_copy(pKey,ext->key,16);
4950
4951 /*Copy the rx mic first*/
4952 vos_mem_copy(&pKey[16],&ext->key[24],8);
4953
4954 /*Copy the tx mic */
4955 vos_mem_copy(&pKey[24],&ext->key[16],8);
4956
4957 }
4958 break;
4959
4960 case IW_ENCODE_ALG_CCMP:
4961 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4962 break;
4963
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004964#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004965#define IW_ENCODE_ALG_KRK 6
4966 case IW_ENCODE_ALG_KRK:
4967 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4968 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004969#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004970
4971 default:
4972 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4973 break;
4974 }
4975
4976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004977 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004978
4979#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304980 /* The supplicant may attempt to set the PTK once pre-authentication
4981 is done. Save the key in the UMAC and include it in the ADD
4982 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304984 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304986 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4987 "%s: Update PreAuth Key success", __func__);
4988 return 0;
4989 }
4990 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4991 {
4992 hddLog(VOS_TRACE_LEVEL_ERROR,
4993 "%s: Update PreAuth Key failed", __func__);
4994 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 }
4996#endif /* WLAN_FEATURE_VOWIFI_11R */
4997
4998 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4999
5000 vos_status = wlan_hdd_check_ula_done(pAdapter);
5001 if ( vos_status != VOS_STATUS_SUCCESS )
5002 {
5003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5004 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5005 __LINE__, vos_status );
5006
5007 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5008 }
5009
5010 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5011
5012 if ( halStatus != eHAL_STATUS_SUCCESS )
5013 {
5014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5015 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5016 __LINE__, halStatus );
5017
5018 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5019 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305020 EXIT();
5021 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005022}
5023
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305024static int iw_set_encodeext(struct net_device *dev,
5025 struct iw_request_info *info,
5026 union iwreq_data *wrqu, char *extra)
5027{
5028 int ret;
5029
5030 vos_ssr_protect(__func__);
5031 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5032 vos_ssr_unprotect(__func__);
5033
5034 return ret;
5035}
5036
5037static int __iw_set_retry(struct net_device *dev,
5038 struct iw_request_info *info,
5039 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005040{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305041 hdd_adapter_t *pAdapter;
5042 tHalHandle hHal;
5043 hdd_context_t *pHddCtx;
5044 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005045
5046 ENTER();
5047
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305048 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5049 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005050 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5052 "%s: Adapter is NULL",__func__);
5053 return -EINVAL;
5054 }
5055
5056 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5057 ret = wlan_hdd_validate_context(pHddCtx);
5058 if (0 != ret)
5059 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305060 return ret;
5061 }
5062
5063 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5064 if (NULL == hHal)
5065 {
5066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5067 "%s: Hal Context is NULL",__func__);
5068 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005069 }
5070
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5072 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5073
Arif Hussain6d2a3322013-11-17 19:50:10 -08005074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005075
5076 return -EINVAL;
5077 }
5078
5079 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5080
5081 if((wrqu->retry.flags & IW_RETRY_LONG))
5082 {
5083 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5084 {
c_hpothub8245442013-11-20 23:41:09 +05305085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5086 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 return -EIO;
5088 }
5089 }
5090 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5091 {
5092 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5093 {
c_hpothub8245442013-11-20 23:41:09 +05305094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5095 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 return -EIO;
5097 }
5098 }
5099 }
5100 else
5101 {
5102 return -EOPNOTSUPP;
5103 }
5104
Arif Hussain6d2a3322013-11-17 19:50:10 -08005105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005106
5107 EXIT();
5108
5109 return 0;
5110
5111}
5112
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305113static int iw_set_retry(struct net_device *dev,
5114 struct iw_request_info *info,
5115 union iwreq_data *wrqu, char *extra)
5116{
5117 int ret;
5118
5119 vos_ssr_protect(__func__);
5120 ret = __iw_set_retry(dev, info, wrqu, extra);
5121 vos_ssr_unprotect(__func__);
5122
5123 return ret;
5124}
5125
5126static int __iw_get_retry(struct net_device *dev,
5127 struct iw_request_info *info,
5128 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005129{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305130 hdd_adapter_t *pAdapter;
5131 hdd_context_t *pHddCtx;
5132 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305134 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
5136 ENTER();
5137
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305138 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5139 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005140 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5142 "%s: Adapter is NULL",__func__);
5143 return -EINVAL;
5144 }
5145
5146 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5147 ret = wlan_hdd_validate_context(pHddCtx);
5148 if (0 != ret)
5149 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305150 return ret;
5151 }
5152
5153 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5154 if (NULL == hHal)
5155 {
5156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5157 "%s: Hal Context is NULL",__func__);
5158 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005159 }
5160
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 if((wrqu->retry.flags & IW_RETRY_LONG))
5162 {
5163 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5164
5165 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5166 {
c_hpothub8245442013-11-20 23:41:09 +05305167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5168 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 return -EIO;
5170 }
5171
5172 wrqu->retry.value = retry;
5173 }
5174 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5175 {
5176 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5177
5178 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5179 {
c_hpothub8245442013-11-20 23:41:09 +05305180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5181 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 return -EIO;
5183 }
5184
5185 wrqu->retry.value = retry;
5186 }
5187 else {
5188 return -EOPNOTSUPP;
5189 }
5190
Arif Hussain6d2a3322013-11-17 19:50:10 -08005191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005192
5193 EXIT();
5194
5195 return 0;
5196}
5197
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305198static int iw_get_retry(struct net_device *dev,
5199 struct iw_request_info *info,
5200 union iwreq_data *wrqu, char *extra)
5201{
5202 int ret;
5203
5204 vos_ssr_protect(__func__);
5205 ret = __iw_get_retry(dev, info, wrqu, extra);
5206 vos_ssr_unprotect(__func__);
5207
5208 return ret;
5209}
5210
5211static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 struct iw_request_info *info,
5213 union iwreq_data *wrqu,
5214 char *extra)
5215{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305216 hdd_adapter_t *pAdapter;
5217 hdd_context_t *pHddCtx;
5218 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5220 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305221 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005222
5223 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305224 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5225 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5228 "%s:Adapter is NULL",__func__);
5229 return -EINVAL;
5230 }
5231 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5232 ret = wlan_hdd_validate_context(pHddCtx);
5233 if (0 != ret)
5234 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305235 return ret;
5236 }
5237 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5238 if (NULL == pHddStaCtx)
5239 {
5240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5241 "%s:STA context is NULL",__func__);
5242 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 }
5244
5245 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5246 switch (mlme->cmd) {
5247 case IW_MLME_DISASSOC:
5248 case IW_MLME_DEAUTH:
5249
5250 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5251 {
5252 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5253
5254 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5255 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5256
5257 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5258 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5259
Jeff Johnson43971f52012-07-17 12:26:56 -07005260 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305261 {
5262 long ret;
5263 ret = wait_for_completion_interruptible_timeout(
5264 &pAdapter->disconnect_comp_var,
5265 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5266 if (ret <= 0)
5267 hddLog(VOS_TRACE_LEVEL_ERROR,
5268 FL("failed wait on disconnect_comp_var %ld"), ret);
5269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005271 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005272 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005273
5274 /* Resetting authKeyMgmt */
5275 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5276
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305277 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 netif_tx_disable(dev);
5279 netif_carrier_off(dev);
5280
5281 }
5282 else
5283 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005284 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 }
5286 break;
5287 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005288 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 return -EINVAL;
5290 }//end of switch
5291
5292 EXIT();
5293
5294 return status;
5295
5296}
5297
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305298static int iw_set_mlme(struct net_device *dev,
5299 struct iw_request_info *info,
5300 union iwreq_data *wrqu,
5301 char *extra)
5302{
5303 int ret;
5304
5305 vos_ssr_protect(__func__);
5306 ret = __iw_set_mlme(dev, info, wrqu, extra);
5307 vos_ssr_unprotect(__func__);
5308
5309 return ret;
5310}
5311
Jeff Johnson295189b2012-06-20 16:38:30 -07005312/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305313static int __iw_setint_getnone(struct net_device *dev,
5314 struct iw_request_info *info,
5315 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005316{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305317 hdd_adapter_t *pAdapter;
5318 tHalHandle hHal;
5319 hdd_wext_state_t *pWextState;
5320 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305321 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 int *value = (int *)extra;
5323 int sub_cmd = value[0];
5324 int set_value = value[1];
5325 int ret = 0; /* success */
5326 int enable_pbm, enable_mp;
5327#ifdef CONFIG_HAS_EARLYSUSPEND
5328 v_U8_t nEnableSuspendOld;
5329#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005330
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305331 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305332 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5333 if (NULL == pAdapter)
5334 {
5335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5336 "%s: Adapter is NULL",__func__);
5337 return -EINVAL;
5338 }
5339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5340 ret = wlan_hdd_validate_context(pHddCtx);
5341 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005342 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305343 return ret;
5344 }
Katya Nigameae74b62015-05-28 17:19:16 +05305345 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305346 {
Katya Nigameae74b62015-05-28 17:19:16 +05305347 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5348 if (NULL == hHal)
5349 {
5350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5351 "%s: Hal Context is NULL",__func__);
5352 return -EINVAL;
5353 }
5354 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5355 if (NULL == pWextState)
5356 {
5357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5358 "%s: pWextState is NULL",__func__);
5359 return -EINVAL;
5360 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005361
Katya Nigameae74b62015-05-28 17:19:16 +05305362 INIT_COMPLETION(pWextState->completion_var);
5363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 switch(sub_cmd)
5365 {
5366 case WE_SET_11D_STATE:
5367 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005368 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005369 memset(&smeConfig, 0x00, sizeof(smeConfig));
5370
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5372
5373 sme_GetConfigParam(hHal,&smeConfig);
5374 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5375
Arif Hussain6d2a3322013-11-17 19:50:10 -08005376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005377
5378 sme_UpdateConfig(hHal,&smeConfig);
5379 }
5380 else {
5381 return -EINVAL;
5382 }
5383 break;
5384 }
5385
5386 case WE_WOWL:
5387 {
5388 switch (set_value)
5389 {
5390 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305391 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 break;
5393 case 0x01:
5394 case 0x02:
5395 case 0x03:
5396 enable_mp = (set_value & 0x01) ? 1 : 0;
5397 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005398 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5400 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5401 break;
5402 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005403 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 ret = -EINVAL;
5405 break;
5406 }
5407
5408 break;
5409 }
5410 case WE_SET_POWER:
5411 {
5412 switch (set_value)
5413 {
5414 case 0: //Full Power
5415 {
5416 struct statsContext context;
5417 eHalStatus status;
5418
5419 init_completion(&context.completion);
5420
5421 context.pAdapter = pAdapter;
5422 context.magic = POWER_CONTEXT_MAGIC;
5423
5424 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5425 iw_power_callback_fn, &context,
5426 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005427 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 {
5429 int lrc = wait_for_completion_interruptible_timeout(
5430 &context.completion,
5431 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005432
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 if (lrc <= 0)
5434 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005435 hddLog(VOS_TRACE_LEVEL_ERROR,
5436 "%s: SME %s while requesting fullpower",
5437 __func__, (0 == lrc) ?
5438 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 }
5440 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005441 /* either we have a response or we timed out. if we timed
5442 out there is a race condition such that the callback
5443 function could be executing at the same time we are. of
5444 primary concern is if the callback function had already
5445 verified the "magic" but had not yet set the completion
5446 variable when a timeout occurred. we serialize these
5447 activities by invalidating the magic while holding a
5448 shared spinlock which will cause us to block if the
5449 callback is currently executing */
5450 spin_lock(&hdd_context_lock);
5451 context.magic = 0;
5452 spin_unlock(&hdd_context_lock);
5453
Arif Hussain6d2a3322013-11-17 19:50:10 -08005454 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 break;
5456 }
5457 case 1: //Enable BMPS
5458 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5459 break;
5460 case 2: //Disable BMPS
5461 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5462 break;
5463 case 3: //Request Bmps
5464 {
5465 struct statsContext context;
5466 eHalStatus status;
5467
5468 init_completion(&context.completion);
5469
5470 context.pAdapter = pAdapter;
5471 context.magic = POWER_CONTEXT_MAGIC;
5472
5473 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5474 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005475 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 {
5477 int lrc = wait_for_completion_interruptible_timeout(
5478 &context.completion,
5479 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 if (lrc <= 0)
5481 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005482 hddLog(VOS_TRACE_LEVEL_ERROR,
5483 "%s: SME %s while requesting BMPS",
5484 __func__, (0 == lrc) ? "timeout" :
5485 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 }
5487 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005488 /* either we have a response or we timed out. if we
5489 timed out there is a race condition such that the
5490 callback function could be executing at the same
5491 time we are. of primary concern is if the callback
5492 function had already verified the "magic" but had
5493 not yet set the completion variable when a timeout
5494 occurred. we serialize these activities by
5495 invalidating the magic while holding a shared
5496 spinlock which will cause us to block if the
5497 callback is currently executing */
5498 spin_lock(&hdd_context_lock);
5499 context.magic = 0;
5500 spin_unlock(&hdd_context_lock);
5501
Arif Hussain6d2a3322013-11-17 19:50:10 -08005502 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 break;
5504 }
5505 case 4: //Enable IMPS
5506 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5507 break;
5508 case 5: //Disable IMPS
5509 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5510 break;
5511 case 6: //Enable Standby
5512 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5513 break;
5514 case 7: //Disable Standby
5515 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5516 break;
5517 case 8: //Request Standby
5518#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005519#endif
5520 break;
5521 case 9: //Start Auto Bmps Timer
5522 sme_StartAutoBmpsTimer(hHal);
5523 break;
5524 case 10://Stop Auto BMPS Timer
5525 sme_StopAutoBmpsTimer(hHal);
5526 break;
5527#ifdef CONFIG_HAS_EARLYSUSPEND
5528 case 11://suspend to standby
5529#ifdef CONFIG_HAS_EARLYSUSPEND
5530 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5531 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5533#endif
5534 break;
5535 case 12://suspend to deep sleep
5536#ifdef CONFIG_HAS_EARLYSUSPEND
5537 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5538 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5540#endif
5541 break;
5542 case 13://resume from suspend
5543#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005544#endif
5545 break;
5546#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005548 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 ret = -EINVAL;
5550 break;
5551 }
5552 break;
5553 }
5554
5555 case WE_SET_MAX_ASSOC:
5556 {
5557 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5558 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5559 {
5560 ret = -EINVAL;
5561 }
5562 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5563 set_value, NULL, eANI_BOOLEAN_FALSE)
5564 != eHAL_STATUS_SUCCESS )
5565 {
c_hpothub8245442013-11-20 23:41:09 +05305566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5567 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 ret = -EIO;
5569 }
5570 break;
5571 }
5572
5573 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5574 {
5575 if( 0 == set_value )
5576 {
5577 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5578 }
5579 else if ( 1 == set_value )
5580 {
5581 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5582 }
5583 else
5584 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005585 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 ret = -EINVAL;
5587 }
5588 break;
5589 }
5590
5591 case WE_SET_DATA_INACTIVITY_TO:
5592 {
5593 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5594 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5595 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5596 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5597 set_value,
5598 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5599 {
5600 hddLog(LOGE,"Failure: Could not pass on "
5601 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005602 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 ret = -EINVAL;
5604 }
5605 break;
5606 }
5607 case WE_SET_MAX_TX_POWER:
5608 {
5609 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5610 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5611
5612 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5613 __func__, set_value);
5614 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5615 eHAL_STATUS_SUCCESS )
5616 {
5617 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5618 __func__);
5619 return -EIO;
5620 }
5621
5622 break;
5623 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005624 case WE_SET_MAX_TX_POWER_2_4:
5625 {
5626 hddLog(VOS_TRACE_LEVEL_INFO,
5627 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5628 __func__, set_value);
5629 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5630 eHAL_STATUS_SUCCESS)
5631 {
5632 hddLog(VOS_TRACE_LEVEL_ERROR,
5633 "%s: Setting maximum tx power failed for 2.4 GHz band",
5634 __func__);
5635 return -EIO;
5636 }
5637
5638 break;
5639 }
5640 case WE_SET_MAX_TX_POWER_5_0:
5641 {
5642 hddLog(VOS_TRACE_LEVEL_INFO,
5643 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5644 __func__, set_value);
5645 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5646 eHAL_STATUS_SUCCESS)
5647 {
5648 hddLog(VOS_TRACE_LEVEL_ERROR,
5649 "%s: Setting maximum tx power failed for 5.0 GHz band",
5650 __func__);
5651 return -EIO;
5652 }
5653
5654 break;
5655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 case WE_SET_HIGHER_DTIM_TRANSITION:
5657 {
5658 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5659 (set_value == eANI_BOOLEAN_TRUE)))
5660 {
5661 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5662 ret = -EINVAL;
5663 }
5664 else
5665 {
5666 if(pAdapter->higherDtimTransition != set_value)
5667 {
5668 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005669 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 }
5671 }
5672
5673 break;
5674 }
5675
5676 case WE_SET_TM_LEVEL:
5677 {
5678 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005679 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5681
5682 break;
5683 }
5684
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305685 case WE_ENABLE_STRICT_FCC_REG:
5686 {
5687 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5688 struct wiphy *wiphy = NULL;
5689 long lrc;
5690 int status;
5691
5692 wiphy = hddCtxt->wiphy;
5693 if(wiphy == NULL)
5694 {
5695 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5696 break;
5697 }
5698 init_completion(&hddCtxt->wiphy_channel_update_event);
5699
5700 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5701
5702 status = regulatory_hint(wiphy, "00");
5703 if(status < 0)
5704 {
5705 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5706 break;
5707 }
5708
5709 /* Wait for completion */
5710 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5711 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5712 if (lrc <= 0)
5713 {
5714 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5715 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5716 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5717 }
5718 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5719
5720 break;
5721 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005722 case WE_SET_DEBUG_LOG:
5723 {
5724 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5725 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5726 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5727 break;
5728 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305729#ifdef FEATURE_WLAN_TDLS
5730 case WE_SET_TDLS_OFF_CHAN:
5731 {
5732 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5734 __func__, set_value);
5735 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5736 break;
5737 }
5738 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5739 {
5740 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5742 __func__, set_value);
5743 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5744 break;
5745 }
5746 case WE_SET_TDLS_OFF_CHAN_MODE:
5747 {
5748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5749 __func__, set_value);
5750 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5751 break;
5752 }
5753#endif
Peng Xu2446a892014-09-05 17:21:18 +05305754 case WE_SET_SCAN_BAND_PREFERENCE:
5755 {
5756 tSmeConfigParams smeConfig;
5757 memset(&smeConfig, 0x00, sizeof(smeConfig));
5758 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5759 ret = -EINVAL;
5760 break;
5761 }
5762 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5763
5764 if (eCSR_BAND_ALL == set_value ||
5765 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5766 sme_GetConfigParam(hHal, &smeConfig);
5767 smeConfig.csrConfig.scanBandPreference = set_value;
5768
5769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5770 "set band scan preference = %d\n",
5771 smeConfig.csrConfig.scanBandPreference);
5772
5773 sme_UpdateConfig(hHal, &smeConfig);
5774 }
5775 else {
5776 ret = -EINVAL;
5777 }
5778 break;
5779 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305780 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5781 * connection happens so that the params can take effect during
5782 * association. Also this should not be used in STA+p2p concurrency
5783 * as the param will also effect the STA mode.
5784 */
5785 case WE_SET_MIRACAST_VENDOR_CONFIG:
5786 {
5787 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305788
Abhishek Singh01c73d12015-03-12 15:13:44 +05305789 hddLog(LOG1, FL(
5790 "Set Miracast vendor tuning %d"), set_value);
5791
5792 if (1 == set_value || 0 == set_value)
5793 {
5794 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5795 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5796 {
5797 hddLog( LOGE, FL("set vendor miracast config failed"));
5798 ret = -EIO;
5799 }
5800 }
5801 else
5802 {
5803 hddLog(LOGE,
5804 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5805 ret = -EINVAL;
5806 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305807 break;
5808 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305809
5810 case WE_GET_FRAME_LOG:
5811 {
5812 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5813 != VOS_STATUS_SUCCESS)
5814 {
5815 ret = -EINVAL;
5816 }
5817 break;
5818 }
5819
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305820 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5821 {
5822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5823 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5824 if (set_value == 0 || set_value == 1)
5825 {
5826 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5827 set_value);
5828 }
5829 else
5830 ret = -EINVAL;
5831
5832 break;
5833 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305834 /* Bit mask value to enable RTS/CTS for different modes
5835 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5836 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5837 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5838 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5839 * for 5 GHz, VHT80 - 0x1000
5840 */
5841 case WE_SET_RTS_CTS_HTVHT:
5842 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305843
Abhishek Singh41988ba2015-05-25 19:42:29 +05305844 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5845
5846 if (eHAL_STATUS_SUCCESS !=
5847 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5848 {
5849 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5850 ret = -EINVAL;
5851 }
5852 break;
5853 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305854 case WE_SET_MONITOR_STATE:
5855 {
5856
5857 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5858 if( pMonCtx == NULL )
5859 {
5860 hddLog(LOGE, "Monitor Context NULL");
5861 break;
5862 }
5863 pMonCtx->state = set_value;
5864 if( set_value )
5865 wlan_hdd_mon_poststartmsg(pMonCtx);
5866 else
5867 wlan_hdd_mon_poststopmsg();
5868
5869 break;
5870 }
5871
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 default:
5873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005874 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 sub_cmd, set_value);
5876 break;
5877 }
5878 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305879 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 return ret;
5881}
5882
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305883static int iw_setint_getnone(struct net_device *dev,
5884 struct iw_request_info *info,
5885 union iwreq_data *wrqu, char *extra)
5886{
5887 int ret;
5888
5889 vos_ssr_protect(__func__);
5890 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5891 vos_ssr_unprotect(__func__);
5892
5893 return 0;
5894}
Jeff Johnson295189b2012-06-20 16:38:30 -07005895/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305896static int __iw_setchar_getnone(struct net_device *dev,
5897 struct iw_request_info *info,
5898 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005899{
5900 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305901 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005903 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305904 hdd_adapter_t *pAdapter;
5905 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005906#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305907 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005908#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305909 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305910 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005911
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305912 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305913 pAdapter = (netdev_priv(dev));
5914 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005915 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5917 "%s: Adapter is NULL",__func__);
5918 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005919 }
5920
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305921 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5922 ret = wlan_hdd_validate_context(pHddCtx);
5923 if (0 != ret)
5924 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305925 return ret;
5926 }
5927#ifdef WLAN_FEATURE_VOWIFI
5928 pConfig = pHddCtx->cfg_ini;
5929#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305930 /* helper function to get iwreq_data with compat handling. */
5931 if (hdd_priv_get_data(&s_priv_data, wrqu))
5932 {
5933 return -EINVAL;
5934 }
5935
5936 /* make sure all params are correctly passed to function */
5937 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5938 {
5939 return -EINVAL;
5940 }
5941
5942 sub_cmd = s_priv_data.flags;
5943
Arif Hussain0273cba2014-01-07 20:58:29 -08005944 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305945 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5946 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005947 if (NULL == pBuffer)
5948 {
5949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5950 "mem_alloc_copy_from_user_helper fail");
5951 return -ENOMEM;
5952 }
5953
5954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305955 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5957 "%s: Received data %s", __func__, pBuffer);
5958
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 switch(sub_cmd)
5960 {
5961 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005963 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 break;
5965 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005967 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 break;
5969#if defined WLAN_FEATURE_VOWIFI
5970 case WE_NEIGHBOR_REPORT_REQUEST:
5971 {
5972 tRrmNeighborReq neighborReq;
5973 tRrmNeighborRspCallbackInfo callbackInfo;
5974
5975 if (pConfig->fRrmEnable)
5976 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305978 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 if( !neighborReq.no_ssid )
5980 {
Girish Gowli552fc072014-06-14 18:26:16 +05305981 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005982 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 }
5984
5985 callbackInfo.neighborRspCallback = NULL;
5986 callbackInfo.neighborRspCallbackContext = NULL;
5987 callbackInfo.timeout = 5000; //5 seconds
5988 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5989 }
5990 else
5991 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005992 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 ret = -EINVAL;
5994 }
5995 }
5996 break;
5997#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 case WE_SET_AP_WPS_IE:
5999 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306000 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006003 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 if (VOS_STATUS_SUCCESS != vstatus)
6005 {
6006 ret = -EINVAL;
6007 }
6008 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306009 case WE_SET_ENCRYPT_MSG:
6010 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6011 if (NULL == pkt)
6012 {
6013 hddLog(VOS_TRACE_LEVEL_ERROR,
6014 "%s: vos_mem_alloc failed", __func__);
6015 return -ENOMEM;
6016 }
6017
6018 memset(pkt, 0, sizeof(tSirpkt80211));
6019
6020 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6021 hddLog(VOS_TRACE_LEVEL_ERROR,
6022 FL("Firmware is not DISA capable"));
6023 ret = -EINVAL;
6024 vos_mem_free(pkt);
6025 break;
6026 }
6027
6028 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6029
6030 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6031 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6032 if (eHAL_STATUS_SUCCESS != ret) {
6033 hddLog(VOS_TRACE_LEVEL_ERROR,
6034 FL("SENDEncryptMSG: fail to post WDA cmd"));
6035 ret = -EINVAL;
6036 }
6037 vos_mem_free(pkt);
6038
6039 break;
6040
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 default:
6042 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006043 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 ret = -EINVAL;
6045 break;
6046 }
6047 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006048 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306049
6050 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 return ret;
6052}
6053
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306054static int iw_setchar_getnone(struct net_device *dev,
6055 struct iw_request_info *info,
6056 union iwreq_data *wrqu, char *extra)
6057{
6058 int ret;
6059
6060 vos_ssr_protect(__func__);
6061 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6062 vos_ssr_unprotect(__func__);
6063
6064 return ret;
6065}
6066
Jeff Johnson295189b2012-06-20 16:38:30 -07006067/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306068static int __iw_setnone_getint(struct net_device *dev,
6069 struct iw_request_info *info,
6070 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006071{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306072 hdd_adapter_t *pAdapter;
6073 tHalHandle hHal;
6074 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 int *value = (int *)extra;
6076 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306077 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006078
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306079 ENTER();
6080
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306081 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6082 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006083 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6085 "%s: Adapter is NULL",__func__);
6086 return -EINVAL;
6087 }
6088 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6089 ret = wlan_hdd_validate_context(pHddCtx);
6090 if (0 != ret)
6091 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306092 return ret;
6093 }
6094 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6095 if (NULL == hHal)
6096 {
6097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6098 "%s: Hal Context is NULL",__func__);
6099 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006101
6102 switch (value[0])
6103 {
6104 case WE_GET_11D_STATE:
6105 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006106 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306108
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6110
Arif Hussain6d2a3322013-11-17 19:50:10 -08006111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006112
6113 break;
6114 }
6115
6116 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 break;
6119
6120 case WE_PMC_STATE:
6121 {
6122 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 break;
6125 }
6126 case WE_GET_WLAN_DBG:
6127 {
6128 vos_trace_display();
6129 *value = 0;
6130 break;
6131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 case WE_GET_MAX_ASSOC:
6133 {
6134 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6135 {
c_hpothub8245442013-11-20 23:41:09 +05306136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6137 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 ret = -EIO;
6139 }
Girish Gowli385be612014-09-18 11:17:20 +05306140#ifdef WLAN_SOFTAP_VSTA_FEATURE
6141 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6142 {
6143 if (*value > VSTA_NUM_ASSOC_STA)
6144 {
6145 *value = VSTA_NUM_ASSOC_STA;
6146 }
6147 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6148 (*value > (VSTA_NUM_ASSOC_STA -
6149 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6150 {
6151 *value = (VSTA_NUM_ASSOC_STA -
6152 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6153 }
6154 }
6155 else
6156#endif
6157 {
6158 if (*value > NUM_ASSOC_STA)
6159 {
6160 *value = NUM_ASSOC_STA;
6161 }
6162 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6163 (*value > (NUM_ASSOC_STA -
6164 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6165 {
6166 *value = (NUM_ASSOC_STA -
6167 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6168 }
6169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 break;
6171 }
6172
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 case WE_GET_WDI_DBG:
6174 {
6175 wpalTraceDisplay();
6176 *value = 0;
6177 break;
6178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006179
6180 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6181 {
6182 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6183 break;
6184 }
6185 case WE_GET_CONCURRENCY_MODE:
6186 {
6187 *value = hdd_get_concurrency_mode ( );
6188
Arif Hussain6d2a3322013-11-17 19:50:10 -08006189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 break;
6191 }
6192
Peng Xu2446a892014-09-05 17:21:18 +05306193 case WE_GET_SCAN_BAND_PREFERENCE:
6194 {
6195 sme_GetConfigParam(hHal, &smeConfig);
6196 *value = smeConfig.csrConfig.scanBandPreference;
6197
6198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6199 "scanBandPreference = %d\n", *value);
6200 break;
6201 }
6202
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 default:
6204 {
6205 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6206 break;
6207 }
6208 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306209 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 return ret;
6211}
6212
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306213static int iw_setnone_getint(struct net_device *dev,
6214 struct iw_request_info *info,
6215 union iwreq_data *wrqu, char *extra)
6216{
6217 int ret;
6218
6219 vos_ssr_protect(__func__);
6220 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6221 vos_ssr_unprotect(__func__);
6222
6223 return ret;
6224
6225}
Jeff Johnson295189b2012-06-20 16:38:30 -07006226/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306227int __iw_set_three_ints_getnone(struct net_device *dev,
6228 struct iw_request_info *info,
6229 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006230{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306231 hdd_adapter_t *pAdapter;
6232 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 int *value = (int *)extra;
6234 int sub_cmd = value[0];
6235 int ret = 0;
6236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306237 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306238 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6239 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006240 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6242 "%s: Adapter is NULL",__func__);
6243 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006244 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306245 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6246 ret = wlan_hdd_validate_context(pHddCtx);
6247 if (0 != ret)
6248 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306249 return ret;
6250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 switch(sub_cmd)
6252 {
6253 case WE_SET_WLAN_DBG:
6254 {
6255 vos_trace_setValue( value[1], value[2], value[3]);
6256 break;
6257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 case WE_SET_WDI_DBG:
6259 {
6260 wpalTraceSetLevel( value[1], value[2], value[3]);
6261 break;
6262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 case WE_SET_SAP_CHANNELS:
6264 {
6265 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6266 break;
6267 }
6268
6269 default:
6270 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006271 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 break;
6273 }
6274 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306275 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 return ret;
6277}
6278
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306279int iw_set_three_ints_getnone(struct net_device *dev,
6280 struct iw_request_info *info,
6281 union iwreq_data *wrqu, char *extra)
6282{
6283 int ret;
6284
6285 vos_ssr_protect(__func__);
6286 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6287 vos_ssr_unprotect(__func__);
6288
6289 return ret;
6290}
6291
6292static int __iw_get_char_setnone(struct net_device *dev,
6293 struct iw_request_info *info,
6294 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006295{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306296 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306298 hdd_context_t *pHddCtx;
6299 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006300#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006301 hdd_wext_state_t *pWextState;
6302#endif
6303
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306304 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306305 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006306 if (pAdapter == NULL)
6307 {
6308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6309 "%s: pAdapter is NULL!", __func__);
6310 return -EINVAL;
6311 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306312 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6313 ret = wlan_hdd_validate_context(pHddCtx);
6314 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006315 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306316 return ret;
6317 }
6318#ifdef WLAN_FEATURE_11W
6319 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6320 if (NULL == pWextState)
6321 {
6322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6323 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006324 return -EINVAL;
6325 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306326#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006327
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 switch(sub_cmd)
6329 {
6330 case WE_WLAN_VERSION:
6331 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006332 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 break;
6334 }
6335
6336 case WE_GET_STATS:
6337 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306338 tHalHandle hHal = NULL;
6339 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6341 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6342 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6343
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306344
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 snprintf(extra, WE_MAX_STR_LEN,
6346 "\nTransmit"
6347 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6348 "\n dropped BK %u, BE %u, VI %u, VO %u"
6349 "\n classified BK %u, BE %u, VI %u, VO %u"
6350 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6351 "\n queued BK %u, BE %u, VI %u, VO %u"
6352 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006353 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 "\n fetched BK %u, BE %u, VI %u, VO %u"
6355 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6356 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006357 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 "\n flushed BK %u, BE %u, VI %u, VO %u"
6359 "\n\nReceive"
6360 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6361 "\n\nResetsStats"
6362 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6363 "\n",
6364 pStats->txXmitCalled,
6365 pStats->txXmitDropped,
6366 pStats->txXmitBackPressured,
6367 pStats->txXmitQueued,
6368
6369 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6370 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6371 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6372 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6373
6374 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6375 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6376 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6377 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6378
6379 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6380 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6381 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6382 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6383
6384 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6385 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6386 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6387 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6388
6389 pStats->txFetched,
6390 pStats->txFetchEmpty,
6391 pStats->txFetchLowResources,
6392 pStats->txFetchDequeueError,
6393
6394 pStats->txFetchDequeued,
6395 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006396 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 pStats->txCompleted,
6398 pStats->txFlushed,
6399
6400 pStats->txFetchedAC[WLANTL_AC_BK],
6401 pStats->txFetchedAC[WLANTL_AC_BE],
6402 pStats->txFetchedAC[WLANTL_AC_VI],
6403 pStats->txFetchedAC[WLANTL_AC_VO],
6404
6405 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6406 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6407 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6408 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6409
6410 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6411 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6412 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6413 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6414
Ravi Joshi41914632013-10-21 23:02:21 -07006415 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6416 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6417 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6418 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6419
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 pStats->txFlushedAC[WLANTL_AC_BK],
6421 pStats->txFlushedAC[WLANTL_AC_BE],
6422 pStats->txFlushedAC[WLANTL_AC_VI],
6423 pStats->txFlushedAC[WLANTL_AC_VO],
6424
6425 pStats->rxChains,
6426 pStats->rxPackets,
6427 pStats->rxDropped,
6428 pStats->rxDelivered,
6429 pStats->rxRefused,
6430
6431 pResetStats->totalLogpResets,
6432 pResetStats->totalCMD53Failures,
6433 pResetStats->totalMutexReadFailures,
6434 pResetStats->totalMIFErrorFailures,
6435 pResetStats->totalFWHearbeatFailures,
6436 pResetStats->totalUnknownExceptions
6437 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306438 wrqu->data.length = strlen(extra);
6439
6440 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6441
6442 if (hHal)
6443 pMac = PMAC_STRUCT( hHal );
6444
6445 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6446 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6447 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306448 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6449 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6450 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6451 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306452 "\n",
6453 pMac->pmm.BmpscntSleep,
6454 pMac->pmm.BmpscntAwake,
6455 pMac->pmm.BmpsSleeReqFailCnt,
6456 pMac->pmm.BmpsWakeupReqFailCnt,
6457 pMac->pmm.ImpsCntSleep,
6458 pMac->pmm.ImpsCntAwake,
6459 pMac->pmm.ImpsSleepErrCnt,
6460 pMac->pmm.ImpsWakeupErrCnt,
6461 pMac->pmm.ImpsLastErr
6462 );
6463 }
6464
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 wrqu->data.length = strlen(extra)+1;
6466 break;
6467 }
6468
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306469/* The case prints the current state of the HDD, SME, CSR, PE, TL
6470 *it can be extended for WDI Global State as well.
6471 *And currently it only checks P2P_CLIENT adapter.
6472 *P2P_DEVICE and P2P_GO have not been added as of now.
6473*/
6474 case WE_GET_STATES:
6475 {
6476 int buf = 0, len = 0;
6477 int adapter_num = 0;
6478 int count = 0, check = 1;
6479
6480 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006481 tHalHandle hHal = NULL;
6482 tpAniSirGlobal pMac = NULL;
6483 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306484
6485 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6486 hdd_adapter_t *useAdapter = NULL;
6487
6488 /* Print wlan0 or p2p0 states based on the adapter_num
6489 *by using the correct adapter
6490 */
6491 while ( adapter_num < 2 )
6492 {
6493 if ( WLAN_ADAPTER == adapter_num )
6494 {
6495 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006496 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306497 "\n\n wlan0 States:-");
6498 len += buf;
6499 }
6500 else if ( P2P_ADAPTER == adapter_num )
6501 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006502 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306503 "\n\n p2p0 States:-");
6504 len += buf;
6505
6506 if( !pHddCtx )
6507 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006508 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306509 "\n pHddCtx is NULL");
6510 len += buf;
6511 break;
6512 }
6513
6514 /*Printing p2p0 states only in the case when the device is
6515 configured as a p2p_client*/
6516 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6517 if ( !useAdapter )
6518 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006519 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306520 "\n Device not configured as P2P_CLIENT.");
6521 len += buf;
6522 break;
6523 }
6524 }
6525
6526 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006527 if (!hHal) {
6528 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6529 "\n pMac is NULL");
6530 len += buf;
6531 break;
6532 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306533 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006534 if (!pMac) {
6535 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6536 "\n pMac is NULL");
6537 len += buf;
6538 break;
6539 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306540 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6541 if( !pHddStaCtx )
6542 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006543 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306544 "\n pHddStaCtx is NULL");
6545 len += buf;
6546 break;
6547 }
6548
6549 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6550
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006551 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306552 "\n HDD Conn State - %s "
6553 "\n \n SME State:"
6554 "\n Neighbour Roam State - %s"
6555 "\n CSR State - %s"
6556 "\n CSR Substate - %s"
6557 "\n \n TL STA %d State: %s",
6558 macTraceGetHDDWlanConnState(
6559 pHddStaCtx->conn_info.connState),
6560 macTraceGetNeighbourRoamState(
6561 pMac->roam.neighborRoamInfo.neighborRoamState),
6562 macTraceGetcsrRoamState(
6563 pMac->roam.curState[useAdapter->sessionId]),
6564 macTraceGetcsrRoamSubState(
6565 pMac->roam.curSubState[useAdapter->sessionId]),
6566 pHddStaCtx->conn_info.staId[0],
6567 macTraceGetTLState(tlState)
6568 );
6569 len += buf;
6570 adapter_num++;
6571 }
6572
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006573 if (pMac) {
6574 /* Printing Lim State starting with global lim states */
6575 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6576 "\n \n LIM STATES:-"
6577 "\n Global Sme State - %s "\
6578 "\n Global mlm State - %s "\
6579 "\n",
6580 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6581 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6582 );
6583 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306584
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006585 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306586 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306587 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006588 if ( pMac->lim.gpSession[count].valid )
6589 {
6590 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6591 "\n Lim Valid Session %d:-"
6592 "\n PE Sme State - %s "
6593 "\n PE Mlm State - %s "
6594 "\n",
6595 check,
6596 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6597 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6598 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306599
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006600 len += buf;
6601 check++;
6602 }
6603 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306604 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306605 }
6606
6607 wrqu->data.length = strlen(extra)+1;
6608 break;
6609 }
6610
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 case WE_GET_CFG:
6612 {
6613 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6614 wrqu->data.length = strlen(extra)+1;
6615 break;
6616 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006617#ifdef WLAN_FEATURE_11AC
6618 case WE_GET_RSSI:
6619 {
6620 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306621 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006622 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6623 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6624 wrqu->data.length = strlen(extra)+1;
6625 break;
6626 }
6627#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306628
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006629#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006630 case WE_GET_ROAM_RSSI:
6631 {
6632 v_S7_t s7Rssi = 0;
6633 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6634 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6635 wrqu->data.length = strlen(extra)+1;
6636 break;
6637 }
6638#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 case WE_GET_WMM_STATUS:
6640 {
6641 snprintf(extra, WE_MAX_STR_LEN,
6642 "\nDir: 0=up, 1=down, 3=both\n"
6643 "|------------------------|\n"
6644 "|AC | ACM |Admitted| Dir |\n"
6645 "|------------------------|\n"
6646 "|VO | %d | %3s | %d |\n"
6647 "|VI | %d | %3s | %d |\n"
6648 "|BE | %d | %3s | %d |\n"
6649 "|BK | %d | %3s | %d |\n"
6650 "|------------------------|\n",
6651 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6652 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6653 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6654 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6655 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6656 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6657 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6658 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6659 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6660 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6661 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6662 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6663
Jeff Johnsone7245742012-09-05 17:12:55 -07006664
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 wrqu->data.length = strlen(extra)+1;
6666 break;
6667 }
6668 case WE_GET_CHANNEL_LIST:
6669 {
6670 VOS_STATUS status;
6671 v_U8_t i, len;
6672 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306673 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6674 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6675 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 tChannelListInfo channel_list;
6677
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006678 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006680 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006682 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 return -EINVAL;
6684 }
6685 buf = extra;
6686
6687 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006688 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6689 * needed = 5 * number of channels. Check ifsufficient
6690 * buffer is available and then proceed to fill the buffer.
6691 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6693 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006694 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006695 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006696 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 return -EINVAL;
6698 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006699 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6700 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306701 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6702 {
6703 //Printing Country code in getChannelList
6704 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6705 {
6706 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6707 "%c ", pBuf[i]);
6708 }
6709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 for(i = 0 ; i < channel_list.num_channels; i++)
6711 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006712 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 }
6715 wrqu->data.length = strlen(extra)+1;
6716
6717 break;
6718 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006719#ifdef FEATURE_WLAN_TDLS
6720 case WE_GET_TDLS_PEERS:
6721 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006722 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006723 break;
6724 }
6725#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006726#ifdef WLAN_FEATURE_11W
6727 case WE_GET_11W_INFO:
6728 {
6729 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6730
6731 snprintf(extra, WE_MAX_STR_LEN,
6732 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6733 "\n Number of Unprotected Disassocs %d"
6734 "\n Number of Unprotected Deauths %d",
6735 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6736 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6737 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6738 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6739 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6740
6741 wrqu->data.length = strlen(extra)+1;
6742 break;
6743 }
6744#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306745 case WE_GET_SNR:
6746 {
6747 v_S7_t s7snr = 0;
6748 int status = 0;
6749 hdd_context_t *pHddCtx;
6750 hdd_station_ctx_t *pHddStaCtx;
6751
6752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6753 status = wlan_hdd_validate_context(pHddCtx);
6754 if (0 != status)
6755 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306756 return status;
6757 }
6758
6759 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6760
6761 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6762 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6763 {
6764 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6765 " ConnectionState-%d", __func__,
6766 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6767 pHddStaCtx->conn_info.connState);
6768 return -ENONET;
6769 }
6770
6771 /*update the stats in TL*/
6772 wlan_hdd_get_station_stats(pAdapter);
6773 wlan_hdd_get_snr(pAdapter, &s7snr);
6774 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6775 wrqu->data.length = strlen(extra) + 1;
6776 break;
6777 }
6778
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306779 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006781 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 break;
6783 }
6784 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306785 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006786 return 0;
6787}
6788
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306789static int iw_get_char_setnone(struct net_device *dev,
6790 struct iw_request_info *info,
6791 union iwreq_data *wrqu, char *extra)
6792{
6793 int ret;
6794
6795 vos_ssr_protect(__func__);
6796 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6797 vos_ssr_unprotect(__func__);
6798
6799 return ret;
6800}
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306803static int __iw_setnone_getnone(struct net_device *dev,
6804 struct iw_request_info *info,
6805 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006806{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306807 hdd_adapter_t *pAdapter;
6808 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306809 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006810 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306811 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006812
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306813 ENTER();
6814
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306815 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6816 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006817 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6819 "%s: Adapter is NULL",__func__);
6820 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006821 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306822 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6823 ret = wlan_hdd_validate_context(pHddCtx);
6824 if (0 != ret)
6825 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306826 return ret;
6827 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306828 /* helper function to get iwreq_data with compat handling. */
6829 if (hdd_priv_get_data(&s_priv_data, wrqu))
6830 {
6831 return -EINVAL;
6832 }
6833
6834 sub_cmd = s_priv_data.flags;
6835
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 switch (sub_cmd)
6837 {
6838 case WE_CLEAR_STATS:
6839 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6842 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6843 break;
6844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 case WE_INIT_AP:
6846 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306847 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6848
6849 /* As Soft AP mode might been changed to STA already with
6850 * killing of Hostapd, need to find the adpater by name
6851 * rather than mode */
6852 hdd_adapter_t* pAdapter_to_stop =
6853 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6854 if( pAdapter_to_stop )
6855 {
6856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6857 "Adapter with name softap.0 already "
6858 "exist, ignoring the request.\nRemove the "
6859 "adapter and try again\n");
6860 break;
6861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 pr_info("Init AP trigger\n");
6863 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6864 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6865 break;
6866 }
6867 case WE_STOP_AP:
6868 {
6869 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6870 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6871 * this is a dead code and need to find the adpater by name rather than mode */
6872 hdd_adapter_t* pAdapter_to_stop =
6873 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6874 if( pAdapter_to_stop )
6875 {
6876 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6877
6878 pr_info("Stopping AP mode\n");
6879
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306880 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6881 {
6882 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6883 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6884 }
6885
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306887 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306888 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6890
6891 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6892 pAdapter_to_stop->macAddressCurrent.bytes);
6893 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6894 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306895
6896 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6897 {
6898 /* put the device back into BMPS */
6899 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 }
6902 else
6903 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006904 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 }
6906
6907 break;
6908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006909#ifdef WLAN_BTAMP_FEATURE
6910 case WE_ENABLE_AMP:
6911 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 WLANBAP_RegisterWithHCI(pAdapter);
6914 break;
6915 }
6916 case WE_DISABLE_AMP:
6917 {
6918 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6919 VOS_STATUS status;
6920
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006922
6923 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6924 status = WLANBAP_StopAmp();
6925 if(VOS_STATUS_SUCCESS != status )
6926 {
6927 pHddCtx->isAmpAllowed = VOS_TRUE;
6928 hddLog(VOS_TRACE_LEVEL_FATAL,
6929 "%s: Failed to stop AMP", __func__);
6930 }
6931 else
6932 {
6933 //a state m/c implementation in PAL is TBD to avoid this delay
6934 msleep(500);
6935 pHddCtx->isAmpAllowed = VOS_FALSE;
6936 WLANBAP_DeregisterFromHCI();
6937 }
6938
6939 break;
6940 }
6941#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006942 case WE_ENABLE_DXE_STALL_DETECT:
6943 {
schang6295e542013-03-12 15:31:23 -07006944 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6945 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006946 break;
6947 }
6948 case WE_DISPLAY_DXE_SNAP_SHOT:
6949 {
schang6295e542013-03-12 15:31:23 -07006950 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6951 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006952 break;
6953 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306954 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6955 {
6956 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6957 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306958 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306959 break;
6960 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306961
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306962 case WE_SET_REASSOC_TRIGGER:
6963 {
6964 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6965 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6966 v_U32_t roamId = 0;
6967 tCsrRoamModifyProfileFields modProfileFields;
6968 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6969 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6970 return 0;
6971 }
6972
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306973 case WE_STOP_OBSS_SCAN:
6974 {
6975 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6976 2.OBSS scan is stopped by Firmware during the disassociation
6977 3.OBSS stop comamnd is added for debugging purpose*/
6978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6979 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006980
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306981 if (pAdapter == NULL)
6982 {
6983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6984 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306985 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306986 }
6987 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6988 if (pMac == NULL)
6989 {
6990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6991 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306992 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306993 }
6994 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6995 }
6996 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306997 case WE_DUMP_ROAM_TIMER_LOG:
6998 {
6999 vos_dump_roam_time_log_service();
7000 break;
7001 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307002
Mukul Sharma84f27252014-07-14 18:11:42 +05307003 case WE_RESET_ROAM_TIMER_LOG:
7004 {
7005 vos_reset_roam_timer_log();
7006 break;
7007 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307008 case WE_GET_FW_LOGS:
7009 {
7010 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7011 WLAN_LOG_INDICATOR_IOCTL,
7012 WLAN_LOG_REASON_CODE_UNUSED,
7013 TRUE);
7014 break;
7015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 default:
7017 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007018 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 break;
7020 }
7021 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307022 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007023 return ret;
7024}
7025
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307026static int iw_setnone_getnone(struct net_device *dev,
7027 struct iw_request_info *info,
7028 union iwreq_data *wrqu, char *extra)
7029{
7030 int ret;
7031
7032 vos_ssr_protect(__func__);
7033 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7034 vos_ssr_unprotect(__func__);
7035
7036 return ret;
7037}
7038
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307039void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7040{
7041 /*
7042 * Function to display HDD WMM information
7043 * for Tx Queues.
7044 * Prints globala as well as per client depending
7045 * whether the clients are registered or not.
7046 */
7047 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307048 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7049 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307050 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7051 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307052
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307053 for ( i=0; i< NUM_TX_QUEUES; i++)
7054 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307055 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307056
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007057 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307058 i, pAdapter->wmm_tx_queue[i].count,
7059 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307060 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307061 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307062 if(pSapCtx == NULL){
7063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7064 FL("psapCtx is NULL"));
7065 return;
7066 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307067
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307068 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307069 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7070 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307071 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307072 {
7073 hddLog(LOGE, "******STAIndex: %d*********", i);
7074 for ( j=0; j< NUM_TX_QUEUES; j++)
7075 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307076 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7077 {
7078 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7079 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d"
7080 "PrevAdress:%p, NextAddress:%p",
7081 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7082 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7083 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7084 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7085 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307086 }
7087 }
7088 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307089 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307090
Katya Nigam1fd24402015-02-16 14:52:19 +05307091 if(pHddStaCtx == NULL){
7092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7093 FL("pHddStaCtx is NULL"));
7094 return;
7095 }
7096
7097 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7098 if(pPeerInfo == NULL){
7099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7100 FL("ppeerinfo is NULL"));
7101 return;
7102 }
7103
7104 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7105 {
7106 if(pPeerInfo->ibssStaInfo[i].isUsed)
7107 {
7108 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7109 for ( j=0; j< NUM_TX_QUEUES; j++)
7110 {
7111 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7112 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7113 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7114 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7115 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7116 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7117 }
7118 }
7119 }
7120
7121
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307122}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307123static int __iw_set_var_ints_getnone(struct net_device *dev,
7124 struct iw_request_info *info,
7125 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007126{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307127 hdd_adapter_t *pAdapter;
7128 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307129 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307130 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007131 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307132 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307133 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007134 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307135 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007136 int cmd = 0;
7137 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307138 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007139
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307140 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307141 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307142 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7144 "%s: NULL extra buffer pointer", __func__);
7145 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307146 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307147 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7148 if (NULL == pAdapter)
7149 {
7150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7151 "%s: Adapter is NULL",__func__);
7152 return -EINVAL;
7153 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307154 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307155 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7156 ret = wlan_hdd_validate_context(pHddCtx);
7157 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007158 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307159 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007160 }
Katya Nigameae74b62015-05-28 17:19:16 +05307161 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307162 {
Katya Nigameae74b62015-05-28 17:19:16 +05307163 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7164 if (NULL == hHal)
7165 {
7166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7167 "%s: Hal Context is NULL",__func__);
7168 return -EINVAL;
7169 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307170 }
7171 sub_cmd = wrqu->data.flags;
7172
7173 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7174
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007175
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007176 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7177 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7178 {
7179 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7180 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7181 {
7182 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7183 staId = pStaCtx->conn_info.staId[0];
7184 }
7185 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7186 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7187 {
7188 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7189 staId = pAPCtx->uBCStaId;
7190 }
7191 else
7192 {
7193 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7194 return 0;
7195 }
7196 }
7197
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 switch (sub_cmd)
7199 {
7200 case WE_LOG_DUMP_CMD:
7201 {
7202 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007203 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 apps_args[3], apps_args[4]);
7205
7206 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7207 apps_args[3], apps_args[4]);
7208
7209 }
7210 break;
7211
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 case WE_P2P_NOA_CMD:
7213 {
7214 p2p_app_setP2pPs_t p2pNoA;
7215
7216 p2pNoA.opp_ps = apps_args[0];
7217 p2pNoA.ctWindow = apps_args[1];
7218 p2pNoA.duration = apps_args[2];
7219 p2pNoA.interval = apps_args[3];
7220 p2pNoA.count = apps_args[4];
7221 p2pNoA.single_noa_duration = apps_args[5];
7222 p2pNoA.psSelection = apps_args[6];
7223
7224 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7225 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007226 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7228
7229 hdd_setP2pPs(dev, &p2pNoA);
7230
7231 }
7232 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007233
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307234 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7235 {
7236 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7237 __func__, apps_args[0], apps_args[1]);
7238 vosTraceEnable(apps_args[0], apps_args[1]);
7239 }
7240 break;
7241
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007242 case WE_MTRACE_DUMP_CMD:
7243 {
7244 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7245 "bitmask_of_module %d ",
7246 __func__, apps_args[0], apps_args[1], apps_args[2],
7247 apps_args[3]);
7248 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7249 apps_args[2], apps_args[3]);
7250
7251 }
7252 break;
7253
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007254 case WE_MCC_CONFIG_CREDENTIAL :
7255 {
7256 cmd = 287; //Command should be updated if there is any change
7257 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007258 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007259 {
7260 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7261 }
7262 else
7263 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007264 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007265 return 0;
7266 }
7267 }
7268 break;
7269
7270 case WE_MCC_CONFIG_PARAMS :
7271 {
7272 cmd = 288; //command Should be updated if there is any change
7273 // in the Riva dump command
7274 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7275 }
7276 break;
7277
Chilam NG571c65a2013-01-19 12:27:36 +05307278#ifdef FEATURE_WLAN_TDLS
7279 case WE_TDLS_CONFIG_PARAMS :
7280 {
7281 tdls_config_params_t tdlsParams;
7282
Chilam Ng01120412013-02-19 18:32:21 -08007283 tdlsParams.tdls = apps_args[0];
7284 tdlsParams.tx_period_t = apps_args[1];
7285 tdlsParams.tx_packet_n = apps_args[2];
7286 tdlsParams.discovery_period_t = apps_args[3];
7287 tdlsParams.discovery_tries_n = apps_args[4];
7288 tdlsParams.idle_timeout_t = apps_args[5];
7289 tdlsParams.idle_packet_n = apps_args[6];
7290 tdlsParams.rssi_hysteresis = apps_args[7];
7291 tdlsParams.rssi_trigger_threshold = apps_args[8];
7292 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307293
Chilam Ng01120412013-02-19 18:32:21 -08007294 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307295 }
7296 break;
7297#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307298 case WE_CONFIGURE_MONITOR_MODE:
7299 {
7300 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7301 if( pMonCtx == NULL )
7302 {
7303 hddLog(LOGE, "Monitor Context NULL");
7304 break;
7305 }
7306 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7307 __func__, apps_args[0], apps_args[1], apps_args[2],
7308 apps_args[3], apps_args[4]);
7309 /* Input Validation part of FW */
7310 pMonCtx->ChannelNo = apps_args[0];
7311 pMonCtx->ChannelBW = apps_args[1];
7312 pMonCtx->crcCheckEnabled = apps_args[2];
7313 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7314 pMonCtx->is80211to803ConReq = apps_args[4];
7315 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7316 if( pMonCtx->is80211to803ConReq )
7317 pAdapter->dev->type = ARPHRD_ETHER;
7318 else
7319 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7320 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7321 {
7322 hddLog(LOGE, "%s: Filtering data packets as management and control"
7323 " cannot be converted to 802.3 ",__func__);
7324 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7325 }
7326 if( pMonCtx->state )
7327 wlan_hdd_mon_poststartmsg(pMonCtx);
7328 }
7329 break;
7330
7331 case WE_SET_MONITOR_MODE_FILTER:
7332 {
7333 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7334 if( pMonCtx == NULL )
7335 {
7336 hddLog(LOGE, "Monitor Context NULL");
7337 break;
7338 }
7339 /* Input Validation Part of FW */
7340 pMonCtx->numOfMacFilters=1;
7341 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7342 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7343 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7344 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7345 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7346 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7347 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7348 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7349 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7350 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7351 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7352 apps_args[6], apps_args[7], apps_args[8]);
7353 if( pMonCtx->state )
7354 wlan_hdd_mon_poststartmsg(pMonCtx);
7355 }
7356 break;
7357
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 default:
7359 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007360 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7361 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 }
7363 break;
7364 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307365 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 return 0;
7367}
7368
Girish Gowlifb9758e2014-11-19 15:19:17 +05307369static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7370 struct iw_request_info *info,
7371 union iwreq_data *wrqu, char *extra)
7372{
7373 int ret;
7374 union iwreq_data u_priv_wrqu;
7375 int apps_args[MAX_VAR_ARGS] = {0};
7376 int num_args;
7377
7378 /* helper function to get iwreq_data with compat handling. */
7379 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7380 {
7381 return -EINVAL;
7382 }
7383
7384 if (NULL == u_priv_wrqu.data.pointer)
7385 {
7386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7387 "%s: NULL data pointer", __func__);
7388 return -EINVAL;
7389 }
7390
7391 num_args = u_priv_wrqu.data.length;
7392 if (num_args > MAX_VAR_ARGS)
7393 {
7394 num_args = MAX_VAR_ARGS;
7395 }
7396
7397 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7398 (sizeof(int)) * num_args))
7399 {
7400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7401 "%s: failed to copy data from user buffer", __func__);
7402 return -EFAULT;
7403 }
7404
7405 vos_ssr_protect(__func__);
7406 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7407 (char *)&apps_args);
7408 vos_ssr_unprotect(__func__);
7409
7410 return ret;
7411}
7412
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307413int iw_set_var_ints_getnone(struct net_device *dev,
7414 struct iw_request_info *info,
7415 union iwreq_data *wrqu, char *extra)
7416{
7417 int ret;
7418 vos_ssr_protect(__func__);
7419 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7420 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007421
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307422 return ret;
7423}
7424
7425static int __iw_add_tspec(struct net_device *dev,
7426 struct iw_request_info *info,
7427 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007428{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307429 hdd_adapter_t *pAdapter;
7430 hdd_station_ctx_t *pHddStaCtx;
7431 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7433 int params[HDD_WLAN_WMM_PARAM_COUNT];
7434 sme_QosWmmTspecInfo tSpec;
7435 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307436 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307437 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007438
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307439 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307440 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7441 if (NULL == pAdapter)
7442 {
7443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7444 "%s: Adapter is NULL",__func__);
7445 return -EINVAL;
7446 }
7447 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7448 ret = wlan_hdd_validate_context(pHddCtx);
7449 if (0 != ret)
7450 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307451 return ret;
7452 }
7453 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7454 if (NULL == pHddStaCtx)
7455 {
7456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7457 "%s: STA Context is NULL",__func__);
7458 return -EINVAL;
7459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 // make sure the application is sufficiently priviledged
7461 // note that the kernel will do this for "set" ioctls, but since
7462 // this ioctl wants to return status to user space it must be
7463 // defined as a "get" ioctl
7464 if (!capable(CAP_NET_ADMIN))
7465 {
7466 return -EPERM;
7467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007468 // we must be associated in order to add a tspec
7469 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7470 {
7471 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7472 return 0;
7473 }
7474
7475 // since we are defined to be a "get" ioctl, and since the number
7476 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307477 // will pass down in the iwreq_data, we must copy the "set" params.
7478 // We must handle the compat for iwreq_data in 32U/64K environment.
7479
7480 // helper fucntion to get iwreq_data with compat handling.
7481 if (hdd_priv_get_data(&s_priv_data, wrqu))
7482 {
7483 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7484 return 0;
7485 }
7486
7487 // make sure all params are correctly passed to function
7488 if ((NULL == s_priv_data.pointer) ||
7489 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7490 {
7491 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7492 return 0;
7493 }
7494
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307496 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 {
7498 // hmmm, can't get them
7499 return -EIO;
7500 }
7501
7502 // clear the tspec
7503 memset(&tSpec, 0, sizeof(tSpec));
7504
7505 // validate the handle
7506 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7507 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7508 {
7509 // that one is reserved
7510 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7511 return 0;
7512 }
7513
7514 // validate the TID
7515 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7516 {
7517 // out of range
7518 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7519 return 0;
7520 }
7521 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7522
7523 // validate the direction
7524 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7525 {
7526 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7527 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7528 break;
7529
7530 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7531 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7532 break;
7533
7534 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7535 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7536 break;
7537
7538 default:
7539 // unknown
7540 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7541 return 0;
7542 }
7543
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307544 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7545
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 // validate the user priority
7547 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7548 {
7549 // out of range
7550 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7551 return 0;
7552 }
7553 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307554 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7555 {
7556 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7557 return 0;
7558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007559
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7561 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7562 tSpec.ts_info.psb, tSpec.ts_info.up);
7563
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7565 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7566 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7567 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7568 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7569 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7570 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7571 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7572 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7573 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7574 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7575 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7576
7577 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7578
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307579 // Save the expected UAPSD settings by application, this will be needed
7580 // when re-negotiating UAPSD settings during BT Coex cases.
7581 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7582
Jeff Johnson295189b2012-06-20 16:38:30 -07007583 // validate the ts info ack policy
7584 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7585 {
7586 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7587 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7588 break;
7589
7590 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7591 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7592 break;
7593
7594 default:
7595 // unknown
7596 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7597 return 0;
7598 }
7599
7600 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307601
7602 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 return 0;
7604}
7605
7606
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307607static int iw_add_tspec(struct net_device *dev,
7608 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 union iwreq_data *wrqu, char *extra)
7610{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307611 int ret;
7612
7613 vos_ssr_protect(__func__);
7614 ret = __iw_add_tspec(dev, info, wrqu, extra);
7615 vos_ssr_unprotect(__func__);
7616
7617 return ret;
7618}
7619
7620static int __iw_del_tspec(struct net_device *dev,
7621 struct iw_request_info *info,
7622 union iwreq_data *wrqu, char *extra)
7623{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307624 hdd_adapter_t *pAdapter;
7625 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007626 int *params = (int *)extra;
7627 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7628 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307629 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307631 ENTER();
7632
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307633 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7634 if (NULL == pAdapter)
7635 {
7636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7637 "%s: Adapter is NULL",__func__);
7638 return -EINVAL;
7639 }
7640
7641 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7642 ret = wlan_hdd_validate_context(pHddCtx);
7643 if (0 != ret)
7644 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307645 return ret;
7646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 // make sure the application is sufficiently priviledged
7648 // note that the kernel will do this for "set" ioctls, but since
7649 // this ioctl wants to return status to user space it must be
7650 // defined as a "get" ioctl
7651 if (!capable(CAP_NET_ADMIN))
7652 {
7653 return -EPERM;
7654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 // although we are defined to be a "get" ioctl, the params we require
7656 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7657 // is no need to copy the params from user space
7658
7659 // validate the handle
7660 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7661 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7662 {
7663 // that one is reserved
7664 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7665 return 0;
7666 }
7667
7668 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307669
7670 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 return 0;
7672}
7673
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307674static int iw_del_tspec(struct net_device *dev,
7675 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 union iwreq_data *wrqu, char *extra)
7677{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307678 int ret;
7679
7680 vos_ssr_protect(__func__);
7681 ret = __iw_del_tspec(dev, info, wrqu, extra);
7682 vos_ssr_unprotect(__func__);
7683
7684 return ret;
7685}
7686
7687
7688static int __iw_get_tspec(struct net_device *dev,
7689 struct iw_request_info *info,
7690 union iwreq_data *wrqu, char *extra)
7691{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307692 hdd_adapter_t *pAdapter;
7693 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 int *params = (int *)extra;
7695 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7696 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307697 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007698
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307699 ENTER();
7700
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 // although we are defined to be a "get" ioctl, the params we require
7702 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7703 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307704 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7705 if (NULL == pAdapter)
7706 {
7707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7708 "%s: Adapter is NULL",__func__);
7709 return -EINVAL;
7710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007711
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307712 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7713 ret = wlan_hdd_validate_context(pHddCtx);
7714 if (0 != ret)
7715 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307716 return ret;
7717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 // validate the handle
7719 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7720 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7721 {
7722 // that one is reserved
7723 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7724 return 0;
7725 }
7726
7727 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307728 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007729 return 0;
7730}
7731
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307732static int iw_get_tspec(struct net_device *dev,
7733 struct iw_request_info *info,
7734 union iwreq_data *wrqu, char *extra)
7735{
7736 int ret;
7737
7738 vos_ssr_protect(__func__);
7739 ret = __iw_get_tspec(dev, info, wrqu, extra);
7740 vos_ssr_unprotect(__func__);
7741
7742 return ret;
7743}
7744
Jeff Johnson295189b2012-06-20 16:38:30 -07007745#ifdef WLAN_FEATURE_VOWIFI_11R
7746//
7747//
7748// Each time the supplicant has the auth_request or reassoc request
7749// IEs ready. This is pushed to the driver. The driver will inturn use
7750// it to send out the auth req and reassoc req for 11r FT Assoc.
7751//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307752static int __iw_set_fties(struct net_device *dev,
7753 struct iw_request_info *info,
7754 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007755{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307756 hdd_adapter_t *pAdapter;
7757 hdd_station_ctx_t *pHddStaCtx;
7758 hdd_context_t *pHddCtx;
7759 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 //v_CONTEXT_t pVosContext;
7761
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307762 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307763 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7764 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007765 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7767 "%s: Adapter is NULL",__func__);
7768 return -EINVAL;
7769 }
7770 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7771 ret = wlan_hdd_validate_context(pHddCtx);
7772 if (0 != ret)
7773 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307774 return ret;
7775 }
7776 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7777 if (NULL == pHddStaCtx)
7778 {
7779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7780 "%s: STA Context is NULL",__func__);
7781 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 if (!wrqu->data.length)
7784 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007785 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 return -EINVAL;
7787 }
7788 if (wrqu->data.pointer == NULL)
7789 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007790 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 return -EINVAL;
7792 }
7793
7794 // Added for debug on reception of Re-assoc Req.
7795 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7796 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007797 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007799 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 }
7801
7802#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007803 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007804#endif
7805
7806 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007807 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 wrqu->data.length);
7809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307810 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 return 0;
7812}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307813
7814static int iw_set_fties(struct net_device *dev,
7815 struct iw_request_info *info,
7816 union iwreq_data *wrqu, char *extra)
7817{
7818 int ret;
7819
7820 vos_ssr_protect(__func__);
7821 ret = __iw_set_fties(dev, info, wrqu, extra);
7822 vos_ssr_unprotect(__func__);
7823
7824 return ret;
7825}
Jeff Johnson295189b2012-06-20 16:38:30 -07007826#endif
7827
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307828static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007829 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007831{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307832 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007833 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307834 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007835 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307836 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007837 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7838 int idx;
7839 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007840
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307841 ENTER();
7842
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307843 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7844 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007845 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7847 "%s: Adapter is NULL",__func__);
7848 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007849 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307850 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7851 ret_val = wlan_hdd_validate_context(pHddCtx);
7852 if (0 != ret_val)
7853 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307854 return ret_val;
7855 }
7856 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7857 if (NULL == hHal)
7858 {
7859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7860 "%s: Hal Context is NULL",__func__);
7861 return -EINVAL;
7862 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307863 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7864 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307865#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007866
Amar Singhalf3a6e762013-02-19 15:06:50 -08007867 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7868 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007869 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007870 hddLog(VOS_TRACE_LEVEL_ERROR,
7871 "%s: vos_mem_alloc failed", __func__);
7872 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007873 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007874
7875 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7876
7877 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7878 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7879
7880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7881 mc_addr_list_ptr->ulMulticastAddrCnt);
7882
7883 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007884 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007885 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7886 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7887
7888 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7889 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007890 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007891
Amar Singhalf3a6e762013-02-19 15:06:50 -08007892 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7893 vos_mem_free(mc_addr_list_ptr);
7894 if (eHAL_STATUS_SUCCESS != ret_val)
7895 {
7896 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7897 __func__);
7898 return -EINVAL;
7899 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307900#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307901 }
7902 else
7903 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007904
Amar Singhalf3a6e762013-02-19 15:06:50 -08007905 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7906 "%s: Set MC BC Filter Config request: %d suspend %d",
7907 __func__, pRequest->mcastBcastFilterSetting,
7908 pHddCtx->hdd_wlan_suspended);
7909
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307910 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007911
7912 if (pHddCtx->hdd_wlan_suspended)
7913 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007914 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7915 if (NULL == wlanRxpFilterParam)
7916 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307917 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007918 "%s: vos_mem_alloc failed", __func__);
7919 return -EINVAL;
7920 }
7921
Amar Singhalf3a6e762013-02-19 15:06:50 -08007922 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7923 pRequest->mcastBcastFilterSetting;
7924 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7925
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307926 hdd_conf_hostoffload(pAdapter, TRUE);
7927 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7928 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007929
7930 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7931 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307932 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007933 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7934 wlanRxpFilterParam->setMcstBcstFilter);
7935
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307936 if (eHAL_STATUS_SUCCESS !=
7937 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7938 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007939 {
7940 hddLog(VOS_TRACE_LEVEL_ERROR,
7941 "%s: Failure to execute set HW MC/BC Filter request",
7942 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007943 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007944 return -EINVAL;
7945 }
7946
c_hpothud3ce76d2014-10-28 10:34:13 +05307947 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7948 {
7949 pHddCtx->sus_res_mcastbcast_filter =
7950 pRequest->mcastBcastFilterSetting;
7951 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007952 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007954
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307955 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 return 0;
7957}
7958
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307959static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7960 struct iw_request_info *info,
7961 union iwreq_data *wrqu, char *extra)
7962{
7963 int ret;
7964
7965 vos_ssr_protect(__func__);
7966 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7967 vos_ssr_unprotect(__func__);
7968
7969 return ret;
7970}
7971
7972static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7973 struct iw_request_info *info,
7974 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007975{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307976 hdd_adapter_t *pAdapter;
7977 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307978 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307979 int ret = 0;
7980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307981 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007982
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307983 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7984 if (NULL == pAdapter)
7985 {
7986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7987 "%s: Adapter is NULL",__func__);
7988 return -EINVAL;
7989 }
7990
7991 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7992 ret = wlan_hdd_validate_context(pHddCtx);
7993 if (0 != ret)
7994 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307995 return ret;
7996 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307997 //Reset the filter to INI value as we have to clear the dynamic filter
7998 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007999
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308000 //Configure FW with new setting
8001 if (pHddCtx->hdd_wlan_suspended)
8002 {
8003 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8004 if (NULL == wlanRxpFilterParam)
8005 {
8006 hddLog(VOS_TRACE_LEVEL_ERROR,
8007 "%s: vos_mem_alloc failed", __func__);
8008 return -EINVAL;
8009 }
8010
8011 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8012 pHddCtx->configuredMcastBcastFilter;
8013 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8014
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308015 hdd_conf_hostoffload(pAdapter, TRUE);
8016 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8017 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308018
8019 if (eHAL_STATUS_SUCCESS !=
8020 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8021 wlanRxpFilterParam))
8022 {
8023 hddLog(VOS_TRACE_LEVEL_ERROR,
8024 "%s: Failure to execute set HW MC/BC Filter request",
8025 __func__);
8026 vos_mem_free(wlanRxpFilterParam);
8027 return -EINVAL;
8028 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308029
8030 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8031 {
8032 pHddCtx->sus_res_mcastbcast_filter =
8033 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8034 }
8035
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308036 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308037 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008038 return 0;
8039}
8040
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308041
8042static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8043 struct iw_request_info *info,
8044 union iwreq_data *wrqu, char *extra)
8045{
8046 int ret;
8047
8048 vos_ssr_protect(__func__);
8049 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8050 vos_ssr_unprotect(__func__);
8051
8052 return ret;
8053}
8054
8055static int __iw_set_host_offload(struct net_device *dev,
8056 struct iw_request_info *info,
8057 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008058{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308059 hdd_adapter_t *pAdapter;
8060 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008061 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308063 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008064
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308065 ENTER();
8066
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308067 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8068 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008069 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8071 "%s: Adapter is NULL",__func__);
8072 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008073 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308074 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8075 ret = wlan_hdd_validate_context(pHddCtx);
8076 if (0 != ret)
8077 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308078 return ret;
8079 }
8080
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 /* Debug display of request components. */
8082 switch (pRequest->offloadType)
8083 {
8084 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008085 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 switch (pRequest->enableOrDisable)
8087 {
8088 case WLAN_OFFLOAD_DISABLE:
8089 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8090 break;
8091 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8092 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8093 case WLAN_OFFLOAD_ENABLE:
8094 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8095 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8096 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8097 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8098 }
8099 break;
8100
8101 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008102 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008103 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 switch (pRequest->enableOrDisable)
8105 {
8106 case WLAN_OFFLOAD_DISABLE:
8107 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8108 break;
8109 case WLAN_OFFLOAD_ENABLE:
8110 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8111 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8112 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8113 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8114 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8115 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8116 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8117 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8118 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8119 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8120 }
8121 }
8122
8123 /* Execute offload request. The reason that we can copy the request information
8124 from the ioctl structure to the SME structure is that they are laid out
8125 exactly the same. Otherwise, each piece of information would have to be
8126 copied individually. */
8127 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008128 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8129 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008131 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 __func__);
8133 return -EINVAL;
8134 }
8135
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308136 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 return 0;
8138}
8139
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308140static int iw_set_host_offload(struct net_device *dev,
8141 struct iw_request_info *info,
8142 union iwreq_data *wrqu, char *extra)
8143{
8144 int ret;
8145
8146 vos_ssr_protect(__func__);
8147 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8148 vos_ssr_unprotect(__func__);
8149
8150 return ret;
8151}
8152
8153static int __iw_set_keepalive_params(struct net_device *dev,
8154 struct iw_request_info *info,
8155 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008156{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308157 hdd_adapter_t *pAdapter;
8158 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008159 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308161 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008162
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308163 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308164 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8165 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8168 "%s: Adapter is NULL",__func__);
8169 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308171 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8172 ret = wlan_hdd_validate_context(pHddCtx);
8173 if (0 != ret)
8174 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308175 return ret;
8176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008178 hddLog(VOS_TRACE_LEVEL_INFO,
8179 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8180 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008181
8182 switch (pRequest->packetType)
8183 {
8184 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008185 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 break;
8187
8188 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8189
Arif Hussain6d2a3322013-11-17 19:50:10 -08008190 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008191 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008192
8193 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8194 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8195 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8196
8197 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8198 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8199 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8200
8201 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8202 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8203 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8204 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8205 break;
8206
8207 }
8208
8209 /* Execute keep alive request. The reason that we can copy the request information
8210 from the ioctl structure to the SME structure is that they are laid out
8211 exactly the same. Otherwise, each piece of information would have to be
8212 copied individually. */
8213 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8214
Arif Hussain6d2a3322013-11-17 19:50:10 -08008215 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008216
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008217 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008218 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008220 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 __func__);
8222 return -EINVAL;
8223 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308224 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 return 0;
8226}
8227
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308228static int iw_set_keepalive_params(struct net_device *dev,
8229 struct iw_request_info *info,
8230 union iwreq_data *wrqu, char *extra)
8231{
8232 int ret;
8233 vos_ssr_protect(__func__);
8234 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8235 vos_ssr_unprotect(__func__);
8236
8237 return ret;
8238}
8239
Jeff Johnson295189b2012-06-20 16:38:30 -07008240#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008241int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008242 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008243{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008244 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8245 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 int i=0;
8247
8248 if (pHddCtx->cfg_ini->disablePacketFilter)
8249 {
8250 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008251 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 return 0;
8253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 /* Debug display of request components. */
8255 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008256 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008257
8258 switch (pRequest->filterAction)
8259 {
8260 case HDD_RCV_FILTER_SET:
8261 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008262 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008263
8264 packetFilterSetReq.filterId = pRequest->filterId;
8265 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8266 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008267 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 __func__, pRequest->numParams);
8269 return -EINVAL;
8270 }
8271 packetFilterSetReq.numFieldParams = pRequest->numParams;
8272 packetFilterSetReq.coalesceTime = 0;
8273 packetFilterSetReq.filterType = 1;
8274 for (i=0; i < pRequest->numParams; i++)
8275 {
8276 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8277 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8278 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8279 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8280 packetFilterSetReq.paramsData[i].reserved = 0;
8281
Arif Hussain6d2a3322013-11-17 19:50:10 -08008282 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008283 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8284 packetFilterSetReq.filterType);
8285
Arif Hussain6d2a3322013-11-17 19:50:10 -08008286 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8288
8289 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8290 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8291 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8292 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8293
Arif Hussain6d2a3322013-11-17 19:50:10 -08008294 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8296 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8297 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8298
Arif Hussain6d2a3322013-11-17 19:50:10 -08008299 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8301 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8302 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8303 }
8304
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008305 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 __func__);
8309 return -EINVAL;
8310 }
8311
8312 break;
8313
8314 case HDD_RCV_FILTER_CLEAR:
8315
Arif Hussain6d2a3322013-11-17 19:50:10 -08008316 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008317 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008319 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008320 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008321 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 __func__);
8323 return -EINVAL;
8324 }
8325 break;
8326
8327 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008328 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008329 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 return -EINVAL;
8331 }
8332 return 0;
8333}
8334
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308335int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8336 tANI_U8 sessionId)
8337{
8338 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8339 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8340
8341 if (NULL == pHddCtx)
8342 {
8343 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8344 return -EINVAL;
8345 }
8346
8347 if (pHddCtx->isLogpInProgress)
8348 {
8349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8350 "%s:LOGP in Progress. Ignore!!!", __func__);
8351 return -EBUSY;
8352 }
8353
8354 if (pHddCtx->cfg_ini->disablePacketFilter)
8355 {
8356 hddLog(VOS_TRACE_LEVEL_ERROR,
8357 "%s: Packet Filtering Disabled. Returning ",
8358 __func__ );
8359 return -EINVAL;
8360 }
8361
8362 switch (filterType)
8363 {
8364 /* For setting IPV6 MC and UC Filter we need to configure
8365 * 2 filters, one for MC and one for UC.
8366 * The Filter ID shouldn't be swapped, which results in making
8367 * UC Filter ineffective.
8368 * We have Hardcode all the values
8369 *
8370 * Reason for a seperate UC filter is because, driver need to
8371 * specify the FW that the specific filter is for unicast
8372 * otherwise FW will not pass the unicast frames by default
8373 * through the filter. This is required to avoid any performance
8374 * hits when no unicast filter is set and only MC/BC are set.
8375 * The way driver informs host is by using the MAC protocol
8376 * layer, CMP flag set to MAX, CMP Data set to 1.
8377 */
8378
8379 case HDD_FILTER_IPV6_MC_UC:
8380 /* Setting IPV6 MC Filter below
8381 */
8382 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8383 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8384 packetFilterSetReq.numFieldParams = 2;
8385 packetFilterSetReq.paramsData[0].protocolLayer =
8386 HDD_FILTER_PROTO_TYPE_MAC;
8387 packetFilterSetReq.paramsData[0].cmpFlag =
8388 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8389 packetFilterSetReq.paramsData[0].dataOffset =
8390 WLAN_HDD_80211_FRM_DA_OFFSET;
8391 packetFilterSetReq.paramsData[0].dataLength = 1;
8392 packetFilterSetReq.paramsData[0].compareData[0] =
8393 HDD_IPV6_MC_CMP_DATA;
8394
8395 packetFilterSetReq.paramsData[1].protocolLayer =
8396 HDD_FILTER_PROTO_TYPE_ARP;
8397 packetFilterSetReq.paramsData[1].cmpFlag =
8398 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8399 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8400 packetFilterSetReq.paramsData[1].dataLength = 2;
8401 packetFilterSetReq.paramsData[1].compareData[0] =
8402 HDD_IPV6_CMP_DATA_0;
8403 packetFilterSetReq.paramsData[1].compareData[1] =
8404 HDD_IPV6_CMP_DATA_1;
8405
8406
8407 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8408 &packetFilterSetReq, sessionId))
8409 {
8410 hddLog(VOS_TRACE_LEVEL_ERROR,
8411 "%s: Failure to execute Set IPv6 Mulicast Filter",
8412 __func__);
8413 return -EINVAL;
8414 }
8415
8416 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8417
8418 /*
8419 * Setting IPV6 UC Filter below
8420 */
8421 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8422 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8423 packetFilterSetReq.numFieldParams = 2;
8424 packetFilterSetReq.paramsData[0].protocolLayer =
8425 HDD_FILTER_PROTO_TYPE_MAC;
8426 packetFilterSetReq.paramsData[0].cmpFlag =
8427 HDD_FILTER_CMP_TYPE_MAX;
8428 packetFilterSetReq.paramsData[0].dataOffset = 0;
8429 packetFilterSetReq.paramsData[0].dataLength = 1;
8430 packetFilterSetReq.paramsData[0].compareData[0] =
8431 HDD_IPV6_UC_CMP_DATA;
8432
8433 packetFilterSetReq.paramsData[1].protocolLayer =
8434 HDD_FILTER_PROTO_TYPE_ARP;
8435 packetFilterSetReq.paramsData[1].cmpFlag =
8436 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8437 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8438 packetFilterSetReq.paramsData[1].dataLength = 2;
8439 packetFilterSetReq.paramsData[1].compareData[0] =
8440 HDD_IPV6_CMP_DATA_0;
8441 packetFilterSetReq.paramsData[1].compareData[1] =
8442 HDD_IPV6_CMP_DATA_1;
8443
8444 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8445 &packetFilterSetReq, sessionId))
8446 {
8447 hddLog(VOS_TRACE_LEVEL_ERROR,
8448 "%s: Failure to execute Set IPv6 Unicast Filter",
8449 __func__);
8450 return -EINVAL;
8451 }
8452
8453 break;
8454
8455 case HDD_FILTER_IPV6_MC:
8456 /*
8457 * IPV6 UC Filter might be already set,
8458 * clear the UC Filter. As the Filter
8459 * IDs are static, we can directly clear it.
8460 */
8461 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8462 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8463 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8464 &packetFilterClrReq, sessionId))
8465 {
8466 hddLog(VOS_TRACE_LEVEL_ERROR,
8467 "%s: Failure to execute Clear IPv6 Unicast Filter",
8468 __func__);
8469 return -EINVAL;
8470 }
8471
8472 /*
8473 * Setting IPV6 MC Filter below
8474 */
8475 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8476 packetFilterSetReq.numFieldParams = 2;
8477 packetFilterSetReq.paramsData[0].protocolLayer =
8478 HDD_FILTER_PROTO_TYPE_MAC;
8479 packetFilterSetReq.paramsData[0].cmpFlag =
8480 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8481 packetFilterSetReq.paramsData[0].dataOffset =
8482 WLAN_HDD_80211_FRM_DA_OFFSET;
8483 packetFilterSetReq.paramsData[0].dataLength = 1;
8484 packetFilterSetReq.paramsData[0].compareData[0] =
8485 HDD_IPV6_MC_CMP_DATA;
8486
8487 packetFilterSetReq.paramsData[1].protocolLayer =
8488 HDD_FILTER_PROTO_TYPE_ARP;
8489 packetFilterSetReq.paramsData[1].cmpFlag =
8490 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8491 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8492 packetFilterSetReq.paramsData[1].dataLength = 2;
8493 packetFilterSetReq.paramsData[1].compareData[0] =
8494 HDD_IPV6_CMP_DATA_0;
8495 packetFilterSetReq.paramsData[1].compareData[1] =
8496 HDD_IPV6_CMP_DATA_1;
8497
8498
8499 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8500 &packetFilterSetReq, sessionId))
8501 {
8502 hddLog(VOS_TRACE_LEVEL_ERROR,
8503 "%s: Failure to execute Set IPv6 Multicast Filter",
8504 __func__);
8505 return -EINVAL;
8506 }
8507 break;
8508
8509 default :
8510 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8511 "%s: Packet Filter Request: Invalid",
8512 __func__);
8513 return -EINVAL;
8514 }
8515 return 0;
8516}
8517
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308518void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008519{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308520 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308521 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008522 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308523 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008524
Yue Ma3ede6052013-08-29 00:33:26 -07008525 if (NULL == pHddCtx)
8526 {
8527 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8528 return;
8529 }
8530
8531 hHal = pHddCtx->hHal;
8532
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308533 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308535 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8536 return;
8537 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308538
8539 /* Check if INI is enabled or not, other wise just return
8540 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308541 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308542 {
8543 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8544 if (NULL == pMulticastAddrs)
8545 {
8546 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8547 return;
8548 }
8549
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 if (set)
8551 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308552 /* Following pre-conditions should be satisfied before wei
8553 * configure the MC address list.
8554 */
8555 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8556 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8557 && pAdapter->mc_addr_list.mc_cnt
8558 && (eConnectionState_Associated ==
8559 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8560 {
8561 pMulticastAddrs->ulMulticastAddrCnt =
8562 pAdapter->mc_addr_list.mc_cnt;
8563 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8564 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008565 memcpy(pMulticastAddrs->multicastAddr[i],
8566 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308567 sizeof(pAdapter->mc_addr_list.addr[i]));
8568 hddLog(VOS_TRACE_LEVEL_INFO,
8569 "%s: %s multicast filter: addr ="
8570 MAC_ADDRESS_STR,
8571 __func__, set ? "setting" : "clearing",
8572 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8573 }
8574 /* Set multicast filter */
8575 sme_8023MulticastList(hHal, pAdapter->sessionId,
8576 pMulticastAddrs);
8577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308579 else
8580 {
8581 /* Need to clear only if it was previously configured
8582 */
8583 if (pAdapter->mc_addr_list.isFilterApplied)
8584 {
8585 pMulticastAddrs->ulMulticastAddrCnt = 0;
8586 sme_8023MulticastList(hHal, pAdapter->sessionId,
8587 pMulticastAddrs);
8588 }
8589
8590 }
8591 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008592 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308594 else
8595 {
8596 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308597 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308598 }
8599 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008600}
8601
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308602static int __iw_set_packet_filter_params(struct net_device *dev,
8603 struct iw_request_info *info,
8604 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308605{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308606 hdd_adapter_t *pAdapter;
8607 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008608 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308609 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308610 struct iw_point s_priv_data;
8611
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308612 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308613 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8614 if (NULL == pAdapter)
8615 {
8616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8617 "%s: Adapter is NULL",__func__);
8618 return -EINVAL;
8619 }
8620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8621 ret = wlan_hdd_validate_context(pHddCtx);
8622 if (0 != ret)
8623 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308624 return ret;
8625 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308626 if (hdd_priv_get_data(&s_priv_data, wrqu))
8627 {
8628 return -EINVAL;
8629 }
8630
8631 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8632 {
8633 return -EINVAL;
8634 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008635
Arif Hussain0273cba2014-01-07 20:58:29 -08008636 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308637 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8638 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008639 if (NULL == pRequest)
8640 {
8641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8642 "mem_alloc_copy_from_user_helper fail");
8643 return -ENOMEM;
8644 }
8645
8646 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8647 kfree(pRequest);
8648
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308649 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008650 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008651}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308652
8653static int iw_set_packet_filter_params(struct net_device *dev,
8654 struct iw_request_info *info,
8655 union iwreq_data *wrqu, char *extra)
8656{
8657 int ret;
8658
8659 vos_ssr_protect(__func__);
8660 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8661 vos_ssr_unprotect(__func__);
8662
8663 return ret;
8664}
Jeff Johnson295189b2012-06-20 16:38:30 -07008665#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308666static int __iw_get_statistics(struct net_device *dev,
8667 struct iw_request_info *info,
8668 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008669{
8670
8671 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8672 eHalStatus status = eHAL_STATUS_SUCCESS;
8673 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308674 hdd_adapter_t *pAdapter;
8675 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308677 int tlen = 0, ret = 0;
8678 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008679
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308680 tCsrGlobalClassAStatsInfo *aStats;
8681 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008682
8683 ENTER();
8684
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308685 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8686 if (NULL == pAdapter)
8687 {
8688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8689 "%s: Adapter is NULL",__func__);
8690 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8693 ret = wlan_hdd_validate_context(pHddCtx);
8694 if (0 != ret)
8695 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308696 return ret;
8697 }
8698 pStats = &(pAdapter->hdd_stats.summary_stat);
8699 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8700 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008701 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8702
8703 wrqu->txpower.value = 0;
8704 }
8705 else {
8706 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8707 SME_SUMMARY_STATS |
8708 SME_GLOBAL_CLASSA_STATS |
8709 SME_GLOBAL_CLASSB_STATS |
8710 SME_GLOBAL_CLASSC_STATS |
8711 SME_GLOBAL_CLASSD_STATS |
8712 SME_PER_STA_STATS,
8713 hdd_StatisticsCB, 0, FALSE,
8714 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8715
8716 if (eHAL_STATUS_SUCCESS != status)
8717 {
8718 hddLog(VOS_TRACE_LEVEL_ERROR,
8719 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008720 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 return -EINVAL;
8722 }
8723
8724 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308725 if (NULL == pWextState)
8726 {
8727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8728 "%s: pWextState is NULL",__func__);
8729 return -EINVAL;
8730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008731
8732 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8733 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8734 {
8735 hddLog(VOS_TRACE_LEVEL_ERROR,
8736 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008737 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 /*Remove the SME statistics list by passing NULL in callback argument*/
8739 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8740 SME_SUMMARY_STATS |
8741 SME_GLOBAL_CLASSA_STATS |
8742 SME_GLOBAL_CLASSB_STATS |
8743 SME_GLOBAL_CLASSC_STATS |
8744 SME_GLOBAL_CLASSD_STATS |
8745 SME_PER_STA_STATS,
8746 NULL, 0, FALSE,
8747 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8748
8749 return -EINVAL;
8750 }
8751 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8752 (tANI_U8) sizeof (pStats->retry_cnt),
8753 (char*) &(pStats->retry_cnt[0]),
8754 tlen);
8755
8756 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8757 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8758 (char*) &(pStats->multiple_retry_cnt[0]),
8759 tlen);
8760
8761 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8762 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8763 (char*) &(pStats->tx_frm_cnt[0]),
8764 tlen);
8765
8766 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8767 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8768 (char*) &(pStats->rx_frm_cnt),
8769 tlen);
8770
8771 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8772 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8773 (char*) &(pStats->frm_dup_cnt),
8774 tlen);
8775
8776 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8777 (tANI_U8) sizeof (pStats->fail_cnt),
8778 (char*) &(pStats->fail_cnt[0]),
8779 tlen);
8780
8781 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8782 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8783 (char*) &(pStats->rts_fail_cnt),
8784 tlen);
8785
8786 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8787 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8788 (char*) &(pStats->ack_fail_cnt),
8789 tlen);
8790
8791 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8792 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8793 (char*) &(pStats->rts_succ_cnt),
8794 tlen);
8795
8796 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8797 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8798 (char*) &(pStats->rx_discard_cnt),
8799 tlen);
8800
8801 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8802 (tANI_U8) sizeof (pStats->rx_error_cnt),
8803 (char*) &(pStats->rx_error_cnt),
8804 tlen);
8805
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008806 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008807 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008808 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 tlen);
8810
8811 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8812 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8813 (char*) &(dStats->rx_byte_cnt),
8814 tlen);
8815
8816 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8817 (tANI_U8) sizeof (dStats->rx_rate),
8818 (char*) &(dStats->rx_rate),
8819 tlen);
8820
8821 /* Transmit rate, in units of 500 kbit/sec */
8822 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8823 (tANI_U8) sizeof (aStats->tx_rate),
8824 (char*) &(aStats->tx_rate),
8825 tlen);
8826
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008827 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8828 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8829 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008830 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008831 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8832 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8833 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008834 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008835 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8836 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8837 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008838 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008839 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8840 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8841 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008842 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008843 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8844 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8845 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008846 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008847 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8848 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8849 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008850 tlen);
8851
Jeff Johnson295189b2012-06-20 16:38:30 -07008852 wrqu->data.length = tlen;
8853
8854 }
8855
8856 EXIT();
8857
8858 return 0;
8859}
8860
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308861static int iw_get_statistics(struct net_device *dev,
8862 struct iw_request_info *info,
8863 union iwreq_data *wrqu, char *extra)
8864{
8865 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008866
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308867 vos_ssr_protect(__func__);
8868 ret = __iw_get_statistics(dev, info, wrqu, extra);
8869 vos_ssr_unprotect(__func__);
8870
8871 return ret;
8872}
Jeff Johnson295189b2012-06-20 16:38:30 -07008873#ifdef FEATURE_WLAN_SCAN_PNO
8874
8875/*Max Len for PNO notification*/
8876#define MAX_PNO_NOTIFY_LEN 100
8877void found_pref_network_cb (void *callbackContext,
8878 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8879{
8880 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8881 union iwreq_data wrqu;
8882 char buf[MAX_PNO_NOTIFY_LEN+1];
8883
8884 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8885 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8886
8887 // create the event
8888 memset(&wrqu, 0, sizeof(wrqu));
8889 memset(buf, 0, sizeof(buf));
8890
8891 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8892 pPrefNetworkFoundInd->ssId.ssId,
8893 (unsigned int)pPrefNetworkFoundInd->rssi);
8894
8895 wrqu.data.pointer = buf;
8896 wrqu.data.length = strlen(buf);
8897
8898 // send the event
8899
8900 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8901
8902}
8903
8904
8905/*string based input*/
8906VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8907 union iwreq_data *wrqu, char *extra, int nOffset)
8908{
8909 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308910 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008911 /* pnoRequest is a large struct, so we make it static to avoid stack
8912 overflow. This API is only invoked via ioctl, so it is
8913 serialized by the kernel rtnl_lock and hence does not need to be
8914 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308915 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008916 char *ptr;
8917 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308918 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8920
8921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8922 "PNO data len %d data %s",
8923 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008924 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008925
8926 if (wrqu->data.length <= nOffset )
8927 {
8928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8929 return VOS_STATUS_E_FAILURE;
8930 }
8931
8932 pnoRequest.enable = 0;
8933 pnoRequest.ucNetworksCount = 0;
8934 /*-----------------------------------------------------------------------
8935 Input is string based and expected to be like this:
8936
8937 <enabled> <netw_count>
8938 for each network:
8939 <ssid_len> <ssid> <authentication> <encryption>
8940 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8941 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8942
8943 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008944 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 2 5 2 300 0
Jeff Johnson295189b2012-06-20 16:38:30 -07008945
8946 this translates into:
8947 -----------------------------
8948 enable PNO
8949 look for 2 networks:
8950 test - with authentication type 0 and encryption type 0,
8951 that can be found on 3 channels: 1 6 and 11 ,
8952 SSID bcast type is unknown (directed probe will be sent if AP not found)
8953 and must meet -40dBm RSSI
8954
8955 test2 - with auth and enrytption type 4/4
8956 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8957 bcast type is non-bcast (directed probe will be sent)
8958 and must not meet any RSSI threshold
8959
Jeff Johnson8301aa12013-03-28 14:27:29 -07008960 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008962 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008963
Wilson Yang623f6592013-10-08 16:33:37 -07008964 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8965 {
8966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8967 "PNO enable input is not valid %s",ptr);
8968 return VOS_STATUS_E_FAILURE;
8969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008970
8971 if ( 0 == pnoRequest.enable )
8972 {
8973 /*Disable PNO*/
8974 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308975 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8976 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008977 pAdapter->sessionId,
8978 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308979 if (eHAL_STATUS_SUCCESS != status)
8980 {
8981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8982 "%s: failed to disable PNO", __func__);
8983 return VOS_STATUS_E_FAILURE;
8984 }
8985 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 return VOS_STATUS_SUCCESS;
8987 }
8988
c_hpothu37f21312014-04-09 21:49:54 +05308989 if (TRUE == pHddCtx->isPnoEnable)
8990 {
8991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8992 FL("already PNO is enabled"));
8993 return -EBUSY;
8994 }
8995 pHddCtx->isPnoEnable = TRUE;
8996
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008998
8999 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9000 {
9001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9002 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309003 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009005
9006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9007 "PNO enable %d networks count %d offset %d",
9008 pnoRequest.enable,
9009 pnoRequest.ucNetworksCount,
9010 nOffset);
9011
9012 /* Parameters checking:
9013 ucNetworksCount has to be larger than 0*/
9014 if (( 0 == pnoRequest.ucNetworksCount ) ||
9015 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9016 {
9017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309018 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 }
9020
9021 ptr += nOffset;
9022
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309023 pnoRequest.aNetworks =
9024 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9025 if (pnoRequest.aNetworks == NULL)
9026 {
9027 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9028 FL("failed to allocate memory aNetworks %u"),
9029 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9030 goto error;
9031 }
9032 vos_mem_zero(pnoRequest.aNetworks,
9033 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9034
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9036 {
9037
9038 pnoRequest.aNetworks[i].ssId.length = 0;
9039
Wilson Yang623f6592013-10-08 16:33:37 -07009040 ucParams = sscanf(ptr,"%hhu %n",
9041 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9042
9043 if (1 != ucParams)
9044 {
9045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9046 "PNO ssid length input is not valid %s",ptr);
9047 return VOS_STATUS_E_FAILURE;
9048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009049
9050 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9051 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9052 {
9053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9054 "SSID Len %d is not correct for network %d",
9055 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309056 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 }
9058
9059 /*Advance to SSID*/
9060 ptr += nOffset;
9061
Jeff Johnson8301aa12013-03-28 14:27:29 -07009062 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009063 pnoRequest.aNetworks[i].ssId.length);
9064 ptr += pnoRequest.aNetworks[i].ssId.length;
9065
Jeff Johnson02797792013-10-26 19:17:13 -07009066 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009067 &(pnoRequest.aNetworks[i].authentication),
9068 &(pnoRequest.aNetworks[i].encryption),
9069 &(pnoRequest.aNetworks[i].ucChannelCount),
9070 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009071
Wilson Yang623f6592013-10-08 16:33:37 -07009072 if ( 3 != ucParams )
9073 {
9074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9075 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309076 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009077 }
9078
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009080 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009081 "auth %d encry %d channel count %d offset %d",
9082 pnoRequest.aNetworks[i].ssId.length,
9083 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9084 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9085 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9086 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9087 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9088 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9089 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9090 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9091 pnoRequest.aNetworks[i].authentication,
9092 pnoRequest.aNetworks[i].encryption,
9093 pnoRequest.aNetworks[i].ucChannelCount,
9094 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009095
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 /*Advance to channel list*/
9097 ptr += nOffset;
9098
Wilson Yang623f6592013-10-08 16:33:37 -07009099 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 {
9101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9102 "Incorrect number of channels");
9103 return VOS_STATUS_E_FAILURE;
9104 }
9105
9106 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9107 {
9108 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9109 {
Wilson Yang623f6592013-10-08 16:33:37 -07009110 if (1 != sscanf(ptr,"%hhu %n",
9111 &(pnoRequest.aNetworks[i].aChannels[j]),
9112 &nOffset))
9113 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9114 "PNO network channel input is not valid %s",ptr);
9115 return VOS_STATUS_E_FAILURE;
9116 }
9117 /*Advance to next channel number*/
9118 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 }
9120 }
9121
Jeff Johnson02797792013-10-26 19:17:13 -07009122 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009123 &(pnoRequest.aNetworks[i].bcastNetwType),
9124 &nOffset))
9125 {
9126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9127 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309128 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009130
9131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9132 "PNO bcastNetwType %d offset %d",
9133 pnoRequest.aNetworks[i].bcastNetwType,
9134 nOffset );
9135
9136 /*Advance to rssi Threshold*/
9137 ptr += nOffset;
9138
Wilson Yang623f6592013-10-08 16:33:37 -07009139 if (1 != sscanf(ptr,"%hhu %n",
9140 &(pnoRequest.aNetworks[i].rssiThreshold),
9141 &nOffset))
9142 {
9143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9144 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309145 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009147
9148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9149 "PNO rssi %d offset %d",
9150 pnoRequest.aNetworks[i].rssiThreshold,
9151 nOffset );
9152 /*Advance to next network*/
9153 ptr += nOffset;
9154 }/*For ucNetworkCount*/
9155
9156 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009157 &(pnoRequest.scanTimers.ucScanTimersCount),
9158 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009159
9160 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009161 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 {
9163 ptr += nOffset;
9164
Jeff Johnson8301aa12013-03-28 14:27:29 -07009165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9166 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 pnoRequest.scanTimers.ucScanTimersCount,
9168 nOffset );
9169
9170 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9171 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309174 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 }
9176
9177 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9178 {
Jeff Johnson02797792013-10-26 19:17:13 -07009179 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009180 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9181 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9182 &nOffset);
9183
Wilson Yang623f6592013-10-08 16:33:37 -07009184 if (2 != ucParams)
9185 {
9186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9187 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309188 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009189 }
9190
Jeff Johnson8301aa12013-03-28 14:27:29 -07009191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9192 "PNO Timer value %d Timer repeat %d offset %d",
9193 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009194 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9195 nOffset );
9196
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 ptr += nOffset;
9198 }
9199
9200 }
9201 else
9202 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9204 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9206
9207 /*Scan timers defaults to 5 minutes*/
9208 pnoRequest.scanTimers.ucScanTimersCount = 1;
9209 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9210 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9211 }
9212
Wilson Yang623f6592013-10-08 16:33:37 -07009213 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009214
9215 pnoRequest.modePNO = ucMode;
9216 /*for LA we just expose suspend option*/
9217 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9218 {
9219 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9220 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309221 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9222 if (pnoRequest.p24GProbeTemplate == NULL){
9223 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9224 FL("failed to allocate memory p24GProbeTemplate %u"),
9225 SIR_PNO_MAX_PB_REQ_SIZE);
9226 goto error;
9227 }
9228
9229 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9230 if (pnoRequest.p5GProbeTemplate == NULL){
9231 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9232 FL("failed to allocate memory p5GProbeTemplate %u"),
9233 SIR_PNO_MAX_PB_REQ_SIZE);
9234 goto error;
9235 }
9236
9237 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9238 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009239
c_hpothu37f21312014-04-09 21:49:54 +05309240 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 pAdapter->sessionId,
9242 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309243 if (eHAL_STATUS_SUCCESS == status)
9244 {
9245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9246 "%s: PNO enabled", __func__);
9247 return VOS_STATUS_SUCCESS;
9248 }
9249error:
9250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9251 "%s: Failed to enable PNO", __func__);
9252 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309253 if (pnoRequest.aNetworks)
9254 vos_mem_free(pnoRequest.aNetworks);
9255 if (pnoRequest.p24GProbeTemplate)
9256 vos_mem_free(pnoRequest.p24GProbeTemplate);
9257 if (pnoRequest.p5GProbeTemplate)
9258 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309259 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009260}/*iw_set_pno*/
9261
9262VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9263 union iwreq_data *wrqu, char *extra, int nOffset)
9264{
9265 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9266 v_U8_t rssiThreshold = 0;
9267 v_U8_t nRead;
9268
Arif Hussain7adce1b2013-11-11 22:59:34 -08009269 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 &rssiThreshold);
9271
9272 if ( 1 != nRead )
9273 {
9274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9275 "Incorrect format");
9276 return VOS_STATUS_E_FAILURE;
9277 }
9278
9279 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9280 return VOS_STATUS_SUCCESS;
9281}
9282
9283
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309284static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 struct iw_request_info *info,
9286 union iwreq_data *wrqu, char *extra)
9287{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309288 hdd_adapter_t *pAdapter;
9289 hdd_context_t *pHddCtx;
9290 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309291 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309292
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309293 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309294 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9295 if (NULL == pAdapter)
9296 {
9297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9298 "%s: Adapter is NULL",__func__);
9299 return -EINVAL;
9300 }
9301
9302 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9303 ret = wlan_hdd_validate_context(pHddCtx);
9304 if (0 != ret)
9305 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309306 return ret;
9307 }
9308
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009309
9310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309313 status = iw_set_pno(dev,info,wrqu,extra,0);
9314
9315 EXIT();
9316 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009317}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309318
9319static int iw_set_pno_priv(struct net_device *dev,
9320 struct iw_request_info *info,
9321 union iwreq_data *wrqu, char *extra)
9322{
9323 int ret;
9324
9325 vos_ssr_protect(__func__);
9326 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9327 vos_ssr_unprotect(__func__);
9328
9329 return ret;
9330}
Jeff Johnson295189b2012-06-20 16:38:30 -07009331#endif /*FEATURE_WLAN_SCAN_PNO*/
9332
9333//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309334int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009335{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309336 hdd_adapter_t *pAdapter;
9337 tHalHandle hHal;
9338 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309339 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309340 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309341 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309343 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309344 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309345 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309346
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309347 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309348 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9349 if (NULL == pAdapter)
9350 {
9351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9352 "%s: Adapter is NULL",__func__);
9353 return -EINVAL;
9354 }
9355 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9356 retval = wlan_hdd_validate_context(pHddCtx);
9357 if (0 != retval)
9358 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309359 return retval;
9360 }
9361 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9362 if (NULL == hHal)
9363 {
9364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9365 "%s: Hal Context is NULL",__func__);
9366 return -EINVAL;
9367 }
9368 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009369
Atul Mittal54378cb2014-04-02 16:51:50 +05309370 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009371 {
9372 case WLAN_HDD_UI_BAND_AUTO:
9373 band = eCSR_BAND_ALL;
9374 break;
9375 case WLAN_HDD_UI_BAND_5_GHZ:
9376 band = eCSR_BAND_5G;
9377 break;
9378 case WLAN_HDD_UI_BAND_2_4_GHZ:
9379 band = eCSR_BAND_24;
9380 break;
9381 default:
9382 band = eCSR_BAND_MAX;
9383 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309384 connectedBand =
9385 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009386
Atul Mittal54378cb2014-04-02 16:51:50 +05309387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009388 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009389
9390 if (band == eCSR_BAND_MAX)
9391 {
9392 /* Received change band request with invalid band value */
9393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309394 "%s: Invalid band value %u", __func__, ui_band);
9395 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009396 }
9397
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309398 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309399 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309400 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009402 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009403 band, pHddCtx->cfg_ini->nBandCapability);
9404 return -EIO;
9405 }
9406
Sushant Kaushik1165f872015-03-30 20:25:27 +05309407 if (band == eCSR_BAND_ALL)
9408 {
9409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9410 "received. Setting band same as ini value %d"),
9411 pHddCtx->cfg_ini->nBandCapability);
9412 band = pHddCtx->cfg_ini->nBandCapability;
9413 }
9414
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9416 {
9417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9418 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009419 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 return -EIO;
9421 }
9422
9423 if (currBand != band)
9424 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309425 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309426 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309427 /* Return failure if current country code is world regulatory domain*/
9428 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9429 pMac->scan.countryCodeCurrent[1] == '0') )
9430 {
9431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9432 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309433 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309434 return -EAGAIN;
9435 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309436 }
9437
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 /* Change band request received.
9439 * Abort pending scan requests, flush the existing scan results,
9440 * and change the band capability
9441 */
9442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9443 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009444 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009445
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309446 /* We need to change the band and flush the scan results here itself
9447 * as we may get timeout for disconnection in which we will return
9448 * with out doing any of these
9449 */
9450 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9451 {
9452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9453 "%s: failed to set the band value to %u ",
9454 __func__, band);
9455 return -EINVAL;
9456 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309457 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9458 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309459 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309460 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9461 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309462 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309463 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9464 * information available in NV so to get the channel information from kernel
9465 * we need to send regulatory hint for the currunt country
9466 * And to set the same country again we need to set the dummy country
9467 * first and then the actual country.
9468 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309469#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9470 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9471#else
9472 regulatory_hint_user("00");
9473#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309474 wait_result = wait_for_completion_interruptible_timeout(
9475 &pHddCtx->linux_reg_req,
9476 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9477
9478 /* if the country information does not exist with the kernel,
9479 then the driver callback would not be called */
9480
9481 if (wait_result >= 0)
9482 {
9483 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9484 "runtime country code is found in kernel db");
9485 }
9486 else
9487 {
9488 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9489 "runtime country code is not found"
9490 " in kernel db");
9491 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309492
9493 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309494
9495 /*
9496 * Update 11dcountry and current country here as the hint
9497 * with 00 results in 11d and current country with 00
9498 */
9499 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9500 WNI_CFG_COUNTRY_CODE_LEN);
9501 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9502 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309503#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9504 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9505#else
9506 regulatory_hint_user(curr_country);
9507#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309508 wait_result = wait_for_completion_interruptible_timeout(
9509 &pHddCtx->linux_reg_req,
9510 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9511
9512 /* if the country information does not exist with the kernel,
9513 then the driver callback would not be called */
9514 if (wait_result >= 0)
9515 {
9516 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9517 "runtime country code is found in kernel db");
9518 }
9519 else
9520 {
9521 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9522 "runtime country code is not found"
9523 " in kernel db");
9524 }
9525
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309526 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309527 }
9528 else
9529 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309530#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309531 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9532 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309533#else
9534 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9535#endif
9536
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309537 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309538 pScanInfo = &pHddCtx->scan_info;
9539 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9540 {
9541 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9542 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9543 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309544 sme_FilterScanResults(hHal, pAdapter->sessionId);
9545
9546 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309547 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9548 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 eHalStatus status = eHAL_STATUS_SUCCESS;
9551 long lrc;
9552
9553 /* STA already connected on current band, So issue disconnect first,
9554 * then change the band*/
9555
9556 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309557 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309558 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009559
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9561
9562 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9563 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9564
Jeff Johnson43971f52012-07-17 12:26:56 -07009565 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 {
9567 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009568 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 __func__, (int)status );
9570 return -EINVAL;
9571 }
9572
9573 lrc = wait_for_completion_interruptible_timeout(
9574 &pAdapter->disconnect_comp_var,
9575 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9576
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309577 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009578
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009579 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009580 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
9582 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9583 }
9584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309586 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309587 if (TRUE == pHddCtx->isSetBandByNL)
9588 return 0;
9589 else
9590 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009591}
9592
Atul Mittal54378cb2014-04-02 16:51:50 +05309593int hdd_setBand_helper(struct net_device *dev, const char *command)
9594{
9595 u8 band;
9596
9597 /*convert the band value from ascii to integer*/
9598 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9599
9600 return hdd_setBand(dev, band);
9601
9602}
9603
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309604static int __iw_set_band_config(struct net_device *dev,
9605 struct iw_request_info *info,
9606 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009607{
Atul Mittal54378cb2014-04-02 16:51:50 +05309608 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009609
Arif Hussain0273cba2014-01-07 20:58:29 -08009610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009611
Atul Mittal54378cb2014-04-02 16:51:50 +05309612 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009613}
9614
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309615static int iw_set_band_config(struct net_device *dev,
9616 struct iw_request_info *info,
9617 union iwreq_data *wrqu, char *extra)
9618{
9619 int ret;
9620
9621 vos_ssr_protect(__func__);
9622 ret = __iw_set_band_config(dev, info, wrqu, extra);
9623 vos_ssr_unprotect(__func__);
9624
9625 return ret;
9626}
9627
9628static int __iw_set_power_params_priv(struct net_device *dev,
9629 struct iw_request_info *info,
9630 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009631{
Arif Hussain0273cba2014-01-07 20:58:29 -08009632 int ret;
9633 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9635 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009636 /* ODD number is used for set, copy data using copy_from_user */
9637 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9638 wrqu->data.length);
9639 if (NULL == ptr)
9640 {
9641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9642 "mem_alloc_copy_from_user_helper fail");
9643 return -ENOMEM;
9644 }
9645
9646 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9647 kfree(ptr);
9648 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009649}
9650
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309651static int iw_set_power_params_priv(struct net_device *dev,
9652 struct iw_request_info *info,
9653 union iwreq_data *wrqu, char *extra)
9654{
9655 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009656
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309657 vos_ssr_protect(__func__);
9658 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9659 vos_ssr_unprotect(__func__);
9660
9661 return ret;
9662}
Jeff Johnson295189b2012-06-20 16:38:30 -07009663
9664/*string based input*/
9665VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9666 union iwreq_data *wrqu, char *extra, int nOffset)
9667{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309668 hdd_adapter_t *pAdapter;
9669 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 tSirSetPowerParamsReq powerRequest;
9671 char *ptr;
9672 v_U8_t ucType;
9673 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309674 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309676 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309677 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9678 if (NULL == pAdapter)
9679 {
9680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9681 "%s: Adapter is NULL",__func__);
9682 return -EINVAL;
9683 }
9684
9685 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9686 ret = wlan_hdd_validate_context(pHddCtx);
9687 if (0 != ret)
9688 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309689 return ret;
9690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9692 "Power Params data len %d data %s",
9693 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009694 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009695
9696 if (wrqu->data.length <= nOffset )
9697 {
9698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9699 return VOS_STATUS_E_FAILURE;
9700 }
9701
9702 uTotalSize = wrqu->data.length - nOffset;
9703
9704 /*-----------------------------------------------------------------------
9705 Input is string based and expected to be like this:
9706
9707 <param_type> <param_value> <param_type> <param_value> ...
9708
9709 e.g:
9710 1 2 2 3 3 0 4 1 5 1
9711
9712 e.g. setting just a few:
9713 1 2 4 1
9714
9715 parameter types:
9716 -----------------------------
9717 1 - Ignore DTIM
9718 2 - Listen Interval
9719 3 - Broadcast Multicas Filter
9720 4 - Beacon Early Termination
9721 5 - Beacon Early Termination Interval
9722 -----------------------------------------------------------------------*/
9723 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9724 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9725 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9726 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9727 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9728
Arif Hussain7adce1b2013-11-11 22:59:34 -08009729 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009730
9731 while ( uTotalSize )
9732 {
Wilson Yang6f971452013-10-08 15:00:00 -07009733 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9734 {
9735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9736 "Invalid input parameter type %s",ptr);
9737 return VOS_STATUS_E_FAILURE;
9738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009739
9740 uTotalSize -= nOffset;
9741
9742 if (!uTotalSize)
9743 {
9744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009745 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 ucType, nOffset);
9747 return VOS_STATUS_E_FAILURE;
9748 }
9749
9750 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009751
Jeff Johnson02797792013-10-26 19:17:13 -07009752 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009753 {
9754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9755 "Invalid input parameter value %s",ptr);
9756 return VOS_STATUS_E_FAILURE;
9757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
9759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9760 "Power request parameter %d value %d offset %d",
9761 ucType, uValue, nOffset);
9762
9763 switch (ucType)
9764 {
9765 case eSIR_IGNORE_DTIM:
9766 powerRequest.uIgnoreDTIM = uValue;
9767 break;
9768 case eSIR_LISTEN_INTERVAL:
9769 powerRequest.uListenInterval = uValue;
9770 break;
9771 case eSIR_MCAST_BCAST_FILTER:
9772 powerRequest.uBcastMcastFilter = uValue;
9773 break;
9774 case eSIR_ENABLE_BET:
9775 powerRequest.uEnableBET = uValue;
9776 break;
9777 case eSIR_BET_INTERVAL:
9778 powerRequest.uBETInterval = uValue;
9779 break;
9780 default:
9781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009782 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 ucType, uValue, nOffset);
9784 return VOS_STATUS_E_FAILURE;
9785 }
9786
9787 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9789 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009790 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009792 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009793 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009794 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9795 {
9796 uTotalSize = 0;
9797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009798
9799 }/*Go for as long as we have a valid string*/
9800
9801 /* put the device into full power*/
9802 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9803
9804 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009805 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009806
9807 /* put the device back to power save*/
9808 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309810 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 return VOS_STATUS_SUCCESS;
9812}/*iw_set_power_params*/
9813
Atul Mittalc0f739f2014-07-31 13:47:47 +05309814// tdlsoffchan
9815#ifdef FEATURE_WLAN_TDLS
9816
Atul Mittal87ec2422014-09-24 13:12:50 +05309817int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309818{
9819 if (offchannel < 0 || offchannel > 165)
9820 {
9821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9822 __func__, offchannel);
9823 return -1;
9824
9825 }
9826
9827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9828 __func__, tdlsOffCh, offchannel);
9829
9830 tdlsOffCh = offchannel;
9831 return 0;
9832}
9833
Atul Mittal87ec2422014-09-24 13:12:50 +05309834int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309835{
9836 if (offchanoffset == 0)
9837 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309838 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9840 __func__, tdlsOffChBwOffset);
9841
9842 return 0;
9843
9844 }
9845
9846 if ( offchanoffset == 40 )
9847 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309848 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9850 __func__, tdlsOffChBwOffset);
9851
9852 return 0;
9853
9854 }
9855 if (offchanoffset == -40)
9856 {
9857 tdlsOffChBwOffset = 3;
9858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9859 __func__, tdlsOffChBwOffset);
9860
9861 return 0;
9862
9863 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309864
9865 if ((offchanoffset == 80) &&
9866 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9867 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9868 {
9869 tdlsOffChBwOffset = 4;
9870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9871 "%s: change tdls secondary off channel offset to %u",
9872 __func__, tdlsOffChBwOffset);
9873
9874 return 0;
9875 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9877 __func__, offchanoffset);
9878 return -1;
9879}
9880
Atul Mittal87ec2422014-09-24 13:12:50 +05309881int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309882{
9883 hddTdlsPeer_t *connPeer = NULL;
9884 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9885 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9886
9887 if (offchanmode < 0 || offchanmode > 4)
9888 {
9889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9890 "%s: Invalid tdls off channel mode %d",
9891 __func__, offchanmode);
9892 return -1;
9893 }
9894
9895 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9896 {
9897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9898 "%s: tdls off channel mode req in not associated state %d",
9899 __func__, offchanmode);
9900 return -1;
9901 }
9902
9903 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9904 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9905 {
9906 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309907 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309908 if (NULL == connPeer) {
9909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9910 "%s: No TDLS Connected Peer", __func__);
9911 return -1;
9912 }
9913 }
9914 else
9915 {
9916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9917 "%s: TDLS Connection not supported", __func__);
9918 return -1;
9919 }
9920
9921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9922 ("%s: TDLS Channel Switch in swmode=%d"),
9923 __func__, offchanmode);
9924
9925 switch (offchanmode)
9926 {
9927 case 1:/*Enable*/
9928 case 2:/*Disable*/
9929 {
9930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9931 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9932 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9933 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9934 {
9935
9936 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9937 pAdapter->sessionId, connPeer->peerMac,
9938 tdlsOffCh, tdlsOffChBwOffset,
9939 offchanmode);
9940 }
9941 else
9942 {
9943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9944 "%s: TDLS Off Channel not supported", __func__);
9945 return -1;
9946 }
9947 break;
9948 }
9949 case 3:
9950 {
9951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9952 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9953 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9954
9955 break;
9956 }
9957 case 4:
9958 {
9959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9960 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9961 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9962 break;
9963 }
9964 default:
9965 {
9966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9967 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9968 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9969 break;
9970 }
9971
9972 }
9973
9974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9975 __func__, offchanmode);
9976 return 0;
9977}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309978#endif
9979
Jeff Johnson295189b2012-06-20 16:38:30 -07009980
9981// Define the Wireless Extensions to the Linux Network Device structure
9982// A number of these routines are NULL (meaning they are not implemented.)
9983
9984static const iw_handler we_handler[] =
9985{
9986 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9987 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9988 (iw_handler) NULL, /* SIOCSIWNWID */
9989 (iw_handler) NULL, /* SIOCGIWNWID */
9990 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9991 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9992 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9993 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9994 (iw_handler) NULL, /* SIOCSIWSENS */
9995 (iw_handler) NULL, /* SIOCGIWSENS */
9996 (iw_handler) NULL, /* SIOCSIWRANGE */
9997 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9998 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9999 (iw_handler) NULL, /* SIOCGIWPRIV */
10000 (iw_handler) NULL, /* SIOCSIWSTATS */
10001 (iw_handler) NULL, /* SIOCGIWSTATS */
10002 iw_handler_set_spy, /* SIOCSIWSPY */
10003 iw_handler_get_spy, /* SIOCGIWSPY */
10004 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10005 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10006 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10007 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10008 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10009 (iw_handler) NULL, /* SIOCGIWAPLIST */
10010 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10011 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10012 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10013 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10014 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10015 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10016 (iw_handler) NULL, /* -- hole -- */
10017 (iw_handler) NULL, /* -- hole -- */
10018 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10019 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10020 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10021 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10022 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10023 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10024 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10025 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10026 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10027 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10028 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10029 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10030 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10031 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10032 (iw_handler) NULL, /* -- hole -- */
10033 (iw_handler) NULL, /* -- hole -- */
10034 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10035 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10036 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10037 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10038 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10039 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10040 (iw_handler) NULL, /* SIOCSIWPMKSA */
10041};
10042
10043static const iw_handler we_private[] = {
10044
10045 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10046 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10047 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10048 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10049 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10050 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010051 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10053 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10054 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010055#ifdef FEATURE_OEM_DATA_SUPPORT
10056 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10057 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010059
Jeff Johnson295189b2012-06-20 16:38:30 -070010060#ifdef WLAN_FEATURE_VOWIFI_11R
10061 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10062#endif
10063 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10064 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10065 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10066#ifdef WLAN_FEATURE_PACKET_FILTERING
10067 ,
10068 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10069#endif
10070#ifdef FEATURE_WLAN_SCAN_PNO
10071 ,
10072 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10073#endif
10074 ,
10075 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10076 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10077 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10078 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010079 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010080};
10081
10082/*Maximum command length can be only 15 */
10083static const struct iw_priv_args we_private_args[] = {
10084
Katya Nigamf0511f62015-05-05 16:40:57 +053010085 { WE_SET_MONITOR_STATE,
10086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10087 0, "monitor" },
10088
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 /* handlers for main ioctl */
10090 { WLAN_PRIV_SET_INT_GET_NONE,
10091 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10092 0,
10093 "" },
10094
10095 /* handlers for sub-ioctl */
10096 { WE_SET_11D_STATE,
10097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10098 0,
10099 "set11Dstate" },
10100
10101 { WE_WOWL,
10102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10103 0,
10104 "wowl" },
10105
10106 { WE_SET_POWER,
10107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10108 0,
10109 "setPower" },
10110
10111 { WE_SET_MAX_ASSOC,
10112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10113 0,
10114 "setMaxAssoc" },
10115
10116 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10118 0,
10119 "setAutoChannel" },
10120
10121 { WE_SET_DATA_INACTIVITY_TO,
10122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10123 0,
10124 "inactivityTO" },
10125
10126 { WE_SET_MAX_TX_POWER,
10127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10128 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010129 "setMaxTxPower" },
10130
10131 { WE_SET_MAX_TX_POWER_2_4,
10132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10133 0,
10134 "setTxMaxPower2G" },
10135
10136 { WE_SET_MAX_TX_POWER_5_0,
10137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10138 0,
10139 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010140
10141 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10142 * as well to keep same syntax as in SAP. Now onwards, STA
10143 * will support both */
10144 { WE_SET_MAX_TX_POWER,
10145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10146 0,
10147 "setTxMaxPower" },
10148
Jeff Johnson295189b2012-06-20 16:38:30 -070010149 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10150 * 1 = enable and 0 = disable */
10151 {
10152 WE_SET_HIGHER_DTIM_TRANSITION,
10153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10154 0,
10155 "setHDtimTransn" },
10156
10157 { WE_SET_TM_LEVEL,
10158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010159 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 "setTmLevel" },
10161
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010162 { WE_ENABLE_STRICT_FCC_REG,
10163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10164 0,
10165 "setStrictFCCreg" },
10166
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010167 { WE_SET_DEBUG_LOG,
10168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10169 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010170#ifdef FEATURE_WLAN_TDLS
10171 {
10172 WE_SET_TDLS_OFF_CHAN,
10173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10174 0,
10175 "tdlsoffchan" },
10176 {
10177 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10179 0,
10180 "tdlsecchnoffst" },
10181 {
10182 WE_SET_TDLS_OFF_CHAN_MODE,
10183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10184 0,
10185 "tdlsoffchnmode" },
10186#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010187
Peng Xu2446a892014-09-05 17:21:18 +053010188 { WE_SET_SCAN_BAND_PREFERENCE,
10189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10190 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010191 {
10192 WE_GET_FRAME_LOG,
10193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10194 0,
10195 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010196
Abhishek Singh01c73d12015-03-12 15:13:44 +053010197 { WE_SET_MIRACAST_VENDOR_CONFIG,
10198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10199 0, "setMiracstConf" },
10200
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010201#ifdef FEATURE_WLAN_TDLS
10202 {
10203 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10204 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10205 0,
10206 "tdls_2040bsscox" },
10207#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010208 { WE_SET_RTS_CTS_HTVHT,
10209 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10210 0, "setRtsCtsHtVht" },
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010211
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 /* handlers for main ioctl */
10213 { WLAN_PRIV_SET_NONE_GET_INT,
10214 0,
10215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10216 "" },
10217
10218 /* handlers for sub-ioctl */
10219 { WE_GET_11D_STATE,
10220 0,
10221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10222 "get11Dstate" },
10223
10224 { WE_IBSS_STATUS,
10225 0,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10227 "getAdhocStatus" },
10228
10229 { WE_PMC_STATE,
10230 0,
10231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10232 "pmcState" },
10233
10234 { WE_GET_WLAN_DBG,
10235 0,
10236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10237 "getwlandbg" },
10238
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 { WE_GET_MAX_ASSOC,
10240 0,
10241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10242 "getMaxAssoc" },
10243
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 { WE_GET_WDI_DBG,
10245 0,
10246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10247 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010248
10249 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10250 0,
10251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10252 "getAutoChannel" },
10253
10254 { WE_GET_CONCURRENCY_MODE,
10255 0,
10256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10257 "getconcurrency" },
10258
Peng Xu2446a892014-09-05 17:21:18 +053010259 { WE_GET_SCAN_BAND_PREFERENCE,
10260 0,
10261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10262 "get_scan_pref"},
10263
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 /* handlers for main ioctl */
10265 { WLAN_PRIV_SET_CHAR_GET_NONE,
10266 IW_PRIV_TYPE_CHAR| 512,
10267 0,
10268 "" },
10269
10270 /* handlers for sub-ioctl */
10271 { WE_WOWL_ADD_PTRN,
10272 IW_PRIV_TYPE_CHAR| 512,
10273 0,
10274 "wowlAddPtrn" },
10275
10276 { WE_WOWL_DEL_PTRN,
10277 IW_PRIV_TYPE_CHAR| 512,
10278 0,
10279 "wowlDelPtrn" },
10280
10281#if defined WLAN_FEATURE_VOWIFI
10282 /* handlers for sub-ioctl */
10283 { WE_NEIGHBOR_REPORT_REQUEST,
10284 IW_PRIV_TYPE_CHAR | 512,
10285 0,
10286 "neighbor" },
10287#endif
10288 { WE_SET_AP_WPS_IE,
10289 IW_PRIV_TYPE_CHAR| 512,
10290 0,
10291 "set_ap_wps_ie" },
10292
10293 { WE_SET_CONFIG,
10294 IW_PRIV_TYPE_CHAR| 512,
10295 0,
10296 "setConfig" },
10297
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010298 { WE_SET_ENCRYPT_MSG,
10299 IW_PRIV_TYPE_CHAR| 512,
10300 0,
10301 "encryptMsg" },
10302
10303
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 /* handlers for main ioctl */
10305 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10306 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10307 0,
10308 "" },
10309
10310 /* handlers for sub-ioctl */
10311 { WE_SET_WLAN_DBG,
10312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10313 0,
10314 "setwlandbg" },
10315
Jeff Johnson295189b2012-06-20 16:38:30 -070010316 { WE_SET_WDI_DBG,
10317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10318 0,
10319 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010320
10321 { WE_SET_SAP_CHANNELS,
10322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10323 0,
10324 "setsapchannels" },
10325
10326 /* handlers for main ioctl */
10327 { WLAN_PRIV_GET_CHAR_SET_NONE,
10328 0,
10329 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10330 "" },
10331
10332 /* handlers for sub-ioctl */
10333 { WE_WLAN_VERSION,
10334 0,
10335 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10336 "version" },
10337 { WE_GET_STATS,
10338 0,
10339 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10340 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010341 { WE_GET_STATES,
10342 0,
10343 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10344 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010345 { WE_GET_CFG,
10346 0,
10347 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10348 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010349#ifdef WLAN_FEATURE_11AC
10350 { WE_GET_RSSI,
10351 0,
10352 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10353 "getRSSI" },
10354#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010355#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010356 { WE_GET_ROAM_RSSI,
10357 0,
10358 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10359 "getRoamRSSI" },
10360#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 { WE_GET_WMM_STATUS,
10362 0,
10363 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10364 "getWmmStatus" },
10365 {
10366 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010367 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10369 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010370#ifdef FEATURE_WLAN_TDLS
10371 {
10372 WE_GET_TDLS_PEERS,
10373 0,
10374 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10375 "getTdlsPeers" },
10376#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010377#ifdef WLAN_FEATURE_11W
10378 {
10379 WE_GET_11W_INFO,
10380 0,
10381 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10382 "getPMFInfo" },
10383#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010384 { WE_GET_SNR,
10385 0,
10386 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10387 "getSNR" },
10388
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 /* handlers for main ioctl */
10390 { WLAN_PRIV_SET_NONE_GET_NONE,
10391 0,
10392 0,
10393 "" },
10394
10395 /* handlers for sub-ioctl */
10396 { WE_CLEAR_STATS,
10397 0,
10398 0,
10399 "clearStats" },
10400 { WE_INIT_AP,
10401 0,
10402 0,
10403 "initAP" },
10404 { WE_STOP_AP,
10405 0,
10406 0,
10407 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010408#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 { WE_ENABLE_AMP,
10410 0,
10411 0,
10412 "enableAMP" },
10413 { WE_DISABLE_AMP,
10414 0,
10415 0,
10416 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010417#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010418 { WE_ENABLE_DXE_STALL_DETECT,
10419 0,
10420 0,
10421 "dxeStallDetect" },
10422 { WE_DISPLAY_DXE_SNAP_SHOT,
10423 0,
10424 0,
10425 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010426 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10427 0,
10428 0,
10429 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010430 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010431 WE_SET_REASSOC_TRIGGER,
10432 0,
10433 0,
10434 "reassoc" },
10435 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010436 WE_STOP_OBSS_SCAN,
10437 0,
10438 0,
10439 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010440 {
10441 WE_DUMP_ROAM_TIMER_LOG,
10442 0,
10443 0,
10444 "dumpRoamDelay" },
10445 {
10446 WE_RESET_ROAM_TIMER_LOG,
10447 0,
10448 0,
10449 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010450 {
10451 WE_GET_FW_LOGS,
10452 0,
10453 0,
10454 "getFwLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 /* handlers for main ioctl */
10456 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10457 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10458 0,
10459 "" },
10460
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010461
10462
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 /* handlers for sub-ioctl */
10464 { WE_LOG_DUMP_CMD,
10465 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10466 0,
10467 "dump" },
10468
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010469 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010470 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10471 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10472 0,
10473 "setdumplog" },
10474
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010475 { WE_MTRACE_DUMP_CMD,
10476 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10477 0,
10478 "dumplog" },
10479
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010480 /* handlers for sub ioctl */
10481 {
10482 WE_MCC_CONFIG_CREDENTIAL,
10483 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10484 0,
10485 "setMccCrdnl" },
10486
10487 /* handlers for sub ioctl */
10488 {
10489 WE_MCC_CONFIG_PARAMS,
10490 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10491 0,
10492 "setMccConfig" },
10493
Chilam NG571c65a2013-01-19 12:27:36 +053010494#ifdef FEATURE_WLAN_TDLS
10495 /* handlers for sub ioctl */
10496 {
10497 WE_TDLS_CONFIG_PARAMS,
10498 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10499 0,
10500 "setTdlsConfig" },
10501#endif
10502
Katya Nigamf0511f62015-05-05 16:40:57 +053010503 {
10504 WE_CONFIGURE_MONITOR_MODE,
10505 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10506 0,
10507 "MonitorModeConf" },
10508
10509 {
10510 WE_SET_MONITOR_MODE_FILTER,
10511 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10512 0,
10513 "MonitorFilter" },
10514
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 /* handlers for main ioctl */
10516 { WLAN_PRIV_ADD_TSPEC,
10517 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10519 "addTspec" },
10520
10521 /* handlers for main ioctl */
10522 { WLAN_PRIV_DEL_TSPEC,
10523 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10525 "delTspec" },
10526
10527 /* handlers for main ioctl */
10528 { WLAN_PRIV_GET_TSPEC,
10529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10530 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10531 "getTspec" },
10532
Jeff Johnsone7245742012-09-05 17:12:55 -070010533#ifdef FEATURE_OEM_DATA_SUPPORT
10534 /* handlers for main ioctl - OEM DATA */
10535 {
10536 WLAN_PRIV_SET_OEM_DATA_REQ,
10537 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10538 0,
10539 "set_oem_data_req" },
10540
10541 /* handlers for main ioctl - OEM DATA */
10542 {
10543 WLAN_PRIV_GET_OEM_DATA_RSP,
10544 0,
10545 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10546 "get_oem_data_rsp" },
10547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010548
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 /* handlers for main ioctl - host offload */
10550 {
10551 WLAN_PRIV_SET_HOST_OFFLOAD,
10552 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10553 0,
10554 "setHostOffload" },
10555
10556 {
10557 WLAN_GET_WLAN_STATISTICS,
10558 0,
10559 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10560 "getWlanStats" },
10561
10562 {
10563 WLAN_SET_KEEPALIVE_PARAMS,
10564 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10565 0,
10566 "setKeepAlive" },
10567#ifdef WLAN_FEATURE_PACKET_FILTERING
10568 {
10569 WLAN_SET_PACKET_FILTER_PARAMS,
10570 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10571 0,
10572 "setPktFilter" },
10573#endif
10574#ifdef FEATURE_WLAN_SCAN_PNO
10575 {
10576 WLAN_SET_PNO,
10577 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10578 0,
10579 "setpno" },
10580#endif
10581 {
10582 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 0,
10585 "SETBAND" },
10586 /* handlers for dynamic MC BC ioctl */
10587 {
10588 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010589 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 0,
10591 "setMCBCFilter" },
10592 {
10593 WLAN_PRIV_CLEAR_MCBC_FILTER,
10594 0,
10595 0,
10596 "clearMCBCFilter" },
10597 {
10598 WLAN_SET_POWER_PARAMS,
10599 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10600 0,
10601 "setpowerparams" },
10602 {
10603 WLAN_GET_LINK_SPEED,
10604 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010605 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010606};
10607
10608
10609
10610const struct iw_handler_def we_handler_def = {
10611 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10612 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10613 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10614
10615 .standard = (iw_handler *)we_handler,
10616 .private = (iw_handler *)we_private,
10617 .private_args = we_private_args,
10618 .get_wireless_stats = get_wireless_stats,
10619};
10620
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010621int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10622{
10623 v_U32_t cmd = 288; //Command to RIVA
10624 hdd_context_t *pHddCtx = NULL;
10625 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10627 /*
10628 *configMccParam : specify the bit which needs to be modified
10629 *allowed to update based on wlan_qcom_cfg.ini
10630 * configuration
10631 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10632 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10633 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10634 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10635 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10636 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10637 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10638 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10639 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10640 * Bit 9 : Reserved
10641 */
10642 switch (arg1)
10643 {
10644 //Update MCC SCHEDULE_TIME_SLICE parameter
10645 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10646 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10647 {
10648 if((arg2 >= 5) && (arg2 <= 20))
10649 {
10650 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10651 }
10652 else
10653 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010654 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010655 return 0;
10656 }
10657 }
10658 break;
10659
10660 //Update MCC MAX_NULL_SEND_TIME parameter
10661 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10662 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10663 {
10664 if((arg2 >= 1) && (arg2 <= 10))
10665 {
10666 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10667 }
10668 else
10669 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010670 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010671 return 0;
10672 }
10673 }
10674 break;
10675
10676 //Update MCC TX_EARLY_STOP_TIME parameter
10677 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10678 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10679 {
10680 if((arg2 >= 1) && (arg2 <= 10))
10681 {
10682 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10683 }
10684 else
10685 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010686 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010687 return 0;
10688 }
10689 }
10690 break;
10691
10692 //Update MCC RX_DRAIN_TIME parameter
10693 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10694 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10695 {
10696 if((arg2 >= 1) && (arg2 <= 10))
10697 {
10698 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10699 }
10700 else
10701 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010702 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010703 return 0;
10704 }
10705 }
10706 break;
10707
10708 //Update MCC CHANNEL_SWITCH_TIME parameter
10709 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10710 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10711 {
10712 if((arg2 >= 1) && (arg2 <= 20))
10713 {
10714 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10715 }
10716 else
10717 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010718 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010719 return 0;
10720 }
10721 }
10722 break;
10723
10724 //Update MCC MIN_CHANNEL_TIME parameter
10725 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10726 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10727 {
10728 if((arg2 >= 5) && (arg2 <= 20))
10729 {
10730 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10731 }
10732 else
10733 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010734 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010735 return 0;
10736 }
10737 }
10738 break;
10739
10740 //Update MCC PARK_BEFORE_TBTT parameter
10741 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10742 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10743 {
10744 if((arg2 >= 1) && (arg2 <= 5))
10745 {
10746 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10747 }
10748 else
10749 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010750 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010751 return 0;
10752 }
10753 }
10754 break;
10755
10756 //Update MCC MIN_AFTER_DTIM parameter
10757 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10758 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10759 {
10760 if((arg2 >= 5) && (arg2 <= 15))
10761 {
10762 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10763 }
10764 else
10765 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010766 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010767 return 0;
10768 }
10769 }
10770 break;
10771
10772 //Update MCC TOO_CLOSE_MARGIN parameter
10773 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10774 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10775 {
10776 if((arg2 >= 1) && (arg2 <= 3))
10777 {
10778 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10779 }
10780 else
10781 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010782 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010783 return 0;
10784 }
10785 }
10786 break;
10787
10788 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010789 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010790 __FUNCTION__,arg1);
10791 break;
10792 }
10793 return 0;
10794}
10795
Jeff Johnson295189b2012-06-20 16:38:30 -070010796int hdd_set_wext(hdd_adapter_t *pAdapter)
10797{
10798 hdd_wext_state_t *pwextBuf;
10799 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010800 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010801
10802 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10803
10804 // Now configure the roaming profile links. To SSID and bssid.
10805 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10806 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10807
10808 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10809 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10810
10811 /*Set the numOfChannels to zero to scan all the channels*/
10812 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10813 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10814
10815 /* Default is no encryption */
10816 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10817 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10818
10819 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10820 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10821
10822 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10823
10824 /* Default is no authentication */
10825 pwextBuf->roamProfile.AuthType.numEntries = 1;
10826 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10827
10828 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10829 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10830
10831 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010832 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010833
10834 hdd_clearRoamProfileIe(pAdapter);
10835
10836 return VOS_STATUS_SUCCESS;
10837
10838 }
10839
10840int hdd_register_wext(struct net_device *dev)
10841 {
10842 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10843 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10844 VOS_STATUS status;
10845
10846 ENTER();
10847
10848 // Zero the memory. This zeros the profile structure.
10849 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10850
10851 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10852
10853
10854 status = hdd_set_wext(pAdapter);
10855
10856 if(!VOS_IS_STATUS_SUCCESS(status)) {
10857
Arif Hussain6d2a3322013-11-17 19:50:10 -080010858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 return eHAL_STATUS_FAILURE;
10860 }
10861
10862 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10863 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 return eHAL_STATUS_FAILURE;
10866 }
10867
10868 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10869 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 return eHAL_STATUS_FAILURE;
10872 }
10873
10874 // Register as a wireless device
10875 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10876
10877 EXIT();
10878 return 0;
10879}
10880
10881int hdd_UnregisterWext(struct net_device *dev)
10882{
c_hpothu2a13bc32015-01-21 12:48:54 +053010883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10884 if (dev != NULL)
10885 {
10886 rtnl_lock();
10887 dev->wireless_handlers = NULL;
10888 rtnl_unlock();
10889 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010890
Jeff Johnson295189b2012-06-20 16:38:30 -070010891 return 0;
10892}
10893
10894