blob: 4259d5ae8caed85c95b6f1f26e5fff7fbb0dd103 [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
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530176#define WE_SET_PROXIMITY_ENABLE 24
Jeff Johnson295189b2012-06-20 16:38:30 -0700177
178/* Private ioctls and their sub-ioctls */
179#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
180#define WE_GET_11D_STATE 1
181#define WE_IBSS_STATUS 2
182#define WE_PMC_STATE 3
183#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700184#define WE_GET_MAX_ASSOC 6
185#define WE_GET_WDI_DBG 7
186#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
187#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530188#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700189/* Private ioctls and their sub-ioctls */
190#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
191
192/* Private ioctls and their sub-ioctls */
193#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
194#define WE_WOWL_ADD_PTRN 1
195#define WE_WOWL_DEL_PTRN 2
196#if defined WLAN_FEATURE_VOWIFI
197#define WE_NEIGHBOR_REPORT_REQUEST 3
198#endif
199#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
200#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530201#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700202
203/* Private ioctls and their sub-ioctls */
204#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
205#define WE_SET_WLAN_DBG 1
206#define WE_SET_WDI_DBG 2
207#define WE_SET_SAP_CHANNELS 3
208
209/* Private ioctls and their sub-ioctls */
210#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
211#define WE_WLAN_VERSION 1
212#define WE_GET_STATS 2
213#define WE_GET_CFG 3
214#define WE_GET_WMM_STATUS 4
215#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700216#ifdef WLAN_FEATURE_11AC
217#define WE_GET_RSSI 6
218#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800219#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800220#ifdef FEATURE_WLAN_TDLS
221#define WE_GET_TDLS_PEERS 8
222#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700223#ifdef WLAN_FEATURE_11W
224#define WE_GET_11W_INFO 9
225#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530226#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530227#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700228
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530229#ifdef FEATURE_OEM_DATA_SUPPORT
230#define WE_GET_OEM_DATA_CAP 13
231#endif
232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233/* Private ioctls and their sub-ioctls */
234#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
235#define WE_CLEAR_STATS 1
236#define WE_INIT_AP 2
237#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530238#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700239#define WE_ENABLE_AMP 4
240#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530241#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700242#define WE_ENABLE_DXE_STALL_DETECT 6
243#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700244#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530245#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530246#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530247#define WE_DUMP_ROAM_TIMER_LOG 12
248#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530249#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530250#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252/* Private ioctls and their sub-ioctls */
253#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
254#define WE_LOG_DUMP_CMD 1
255
Jeff Johnson295189b2012-06-20 16:38:30 -0700256#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800257//IOCTL to configure MCC params
258#define WE_MCC_CONFIG_CREDENTIAL 3
259#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
Chilam NG571c65a2013-01-19 12:27:36 +0530261#ifdef FEATURE_WLAN_TDLS
262#define WE_TDLS_CONFIG_PARAMS 5
263#endif
264
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700265#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530266#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530267#define WE_CONFIGURE_MONITOR_MODE 10
268#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700269
Chilam Ng01120412013-02-19 18:32:21 -0800270#ifdef FEATURE_WLAN_TDLS
271#undef MAX_VAR_ARGS
272#define MAX_VAR_ARGS 10
273#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700274#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800275#endif
276
Jeff Johnson295189b2012-06-20 16:38:30 -0700277/* Private ioctls (with no sub-ioctls) */
278/* note that they must be odd so that they have "get" semantics */
279#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
280#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
281#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
282
Girish Gowli464c9c82014-06-09 19:47:53 +0530283/* (SIOCIWFIRSTPRIV + 8) is currently unused */
284/* (SIOCIWFIRSTPRIV + 16) is currently unused */
285/* (SIOCIWFIRSTPRIV + 10) is currently unused */
286/* (SIOCIWFIRSTPRIV + 12) is currently unused */
287/* (SIOCIWFIRSTPRIV + 14) is currently unused */
288/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700289
Jeff Johnsone7245742012-09-05 17:12:55 -0700290#ifdef FEATURE_OEM_DATA_SUPPORT
291/* Private ioctls for setting the measurement configuration */
292#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
293#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
294#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700295
296#ifdef WLAN_FEATURE_VOWIFI_11R
297#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
298#endif
299
300/* Private ioctl for setting the host offload feature */
301#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
302
303/* Private ioctl to get the statistics */
304#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
305
306/* Private ioctl to set the Keep Alive Params */
307#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
308#ifdef WLAN_FEATURE_PACKET_FILTERING
309/* Private ioctl to set the Packet Filtering Params */
310#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
311#endif
312
313#ifdef FEATURE_WLAN_SCAN_PNO
314/* Private ioctl to get the statistics */
315#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
316#endif
317
318#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
319
320#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
321#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700322/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700323
Jeff Johnson295189b2012-06-20 16:38:30 -0700324#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
325#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
326
327#define WLAN_STATS_INVALID 0
328#define WLAN_STATS_RETRY_CNT 1
329#define WLAN_STATS_MUL_RETRY_CNT 2
330#define WLAN_STATS_TX_FRM_CNT 3
331#define WLAN_STATS_RX_FRM_CNT 4
332#define WLAN_STATS_FRM_DUP_CNT 5
333#define WLAN_STATS_FAIL_CNT 6
334#define WLAN_STATS_RTS_FAIL_CNT 7
335#define WLAN_STATS_ACK_FAIL_CNT 8
336#define WLAN_STATS_RTS_SUC_CNT 9
337#define WLAN_STATS_RX_DISCARD_CNT 10
338#define WLAN_STATS_RX_ERROR_CNT 11
339#define WLAN_STATS_TX_BYTE_CNT 12
340
341#define WLAN_STATS_RX_BYTE_CNT 13
342#define WLAN_STATS_RX_RATE 14
343#define WLAN_STATS_TX_RATE 15
344
Jeff Johnsone7245742012-09-05 17:12:55 -0700345#define WLAN_STATS_RX_UC_BYTE_CNT 16
346#define WLAN_STATS_RX_MC_BYTE_CNT 17
347#define WLAN_STATS_RX_BC_BYTE_CNT 18
348#define WLAN_STATS_TX_UC_BYTE_CNT 19
349#define WLAN_STATS_TX_MC_BYTE_CNT 20
350#define WLAN_STATS_TX_BC_BYTE_CNT 21
351
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800352#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
353 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
354 { \
355 *__p++ = __type; \
356 *__p++ = __size; \
357 memcpy(__p, __val, __size); \
358 __p += __size; \
359 __tlen += __size + 2; \
360 } \
361 else \
362 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800363 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800364 } \
365 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
367#define VERSION_VALUE_MAX_LEN 32
368
369#define TX_PER_TRACKING_DEFAULT_RATIO 5
370#define TX_PER_TRACKING_MAX_RATIO 10
371#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
372
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530373#define WLAN_ADAPTER 0
374#define P2P_ADAPTER 1
375
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530376#define TX_PWR_MIN 6
377#define TX_PWR_MAX 22
378#define TX_PWR_DEF 50
379
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530380/*
381 * When supplicant sends SETBAND ioctl it queries for channels from
382 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
383 * This is not required if the return type from ioctl is
384 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
385 * event as part of regulatory_hint.
386 */
387enum {
388 SEND_CHANNEL_CHANGE_EVENT = 0,
389 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
390};
391
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800392/*MCC Configuration parameters */
393enum {
394 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
395 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
396 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
397 MCC_RX_DRAIN_TIME_CFG_PARAM,
398 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
399 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
400 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
401 MCC_MIN_AFTER_DTIM_CFG_PARAM,
402 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
403};
404
405int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
406 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
407
Jeff Johnson295189b2012-06-20 16:38:30 -0700408#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800409int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700410 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700411#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530412static int get_fwr_memdump(struct net_device *,
413 struct iw_request_info *,
414 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700415/**---------------------------------------------------------------------------
416
Arif Hussain0273cba2014-01-07 20:58:29 -0800417 \brief mem_alloc_copy_from_user_helper -
418
419 Helper function to allocate buffer and copy user data.
420
421 \param - wrqu - Pointer to IOCTL Data.
422 len - size
423
424 \return - On Success pointer to buffer, On failure NULL
425
426 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530427void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800428{
429 u8 *ptr = NULL;
430
431 /* in order to protect the code, an extra byte is post appended to the buffer
432 * and the null termination is added. However, when allocating (len+1) byte
433 * of memory, we need to make sure that there is no uint overflow when doing
434 * addition. In theory check len < UINT_MAX protects the uint overflow. For
435 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
436 * guess, now, it is assumed that the private command buffer size is no
437 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
438 */
439 if (len > MAX_USER_COMMAND_SIZE)
440 {
441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
442 "Invalid length");
443 return NULL;
444 }
445
446 ptr = kmalloc(len + 1, GFP_KERNEL);
447 if (NULL == ptr)
448 {
449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
450 "unable to allocate memory");
451 return NULL;
452 }
453
454 if (copy_from_user(ptr, wrqu_data, len))
455 {
456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
457 "%s: failed to copy data to user buffer", __func__);
458 kfree(ptr);
459 return NULL;
460 }
461 ptr[len] = '\0';
462 return ptr;
463}
464
Girish Gowli488ef492014-06-12 18:44:33 +0530465// Function to handle and get compatible struct iw_point passed to ioctl.
466int hdd_priv_get_data(struct iw_point *p_priv_data,
467 union iwreq_data *wrqu)
468{
469 if ((NULL == p_priv_data) || (NULL == wrqu))
470 {
471 return -EINVAL;
472 }
473
474#ifdef CONFIG_COMPAT
475 if (is_compat_task())
476 {
477 struct compat_iw_point *p_compat_priv_data;
478
479 // Compat task: typecast to campat structure and copy the members.
480 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
481
482 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
483 p_priv_data->length = p_compat_priv_data->length;
484 p_priv_data->flags = p_compat_priv_data->flags;
485 }//if(is_compat_task())
486 else
487 {
488#endif //#ifdef CONFIG_COMPAT
489
490 // Non compat task: directly copy the structure.
491 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
492
493#ifdef CONFIG_COMPAT
494 }//else of - if(is_compat_task())
495#endif //#ifdef CONFIG_COMPAT
496
497 return 0;
498}
499
Arif Hussain0273cba2014-01-07 20:58:29 -0800500/**---------------------------------------------------------------------------
501
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 \brief hdd_wlan_get_version() -
503
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700505
506 \param - pAdapter Pointer to the adapter.
507 wrqu - Pointer to IOCTL REQUEST Data.
508 extra - Pointer to char
509
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800510 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700511
512 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800513void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
514 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700515{
516 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800517 tSirVersionString wcnss_SW_version;
518 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530519 tSirVersionString iris_name;
520 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800521 char *pSWversion;
522 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800525 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
526 sizeof(wcnss_SW_version));
527 if (VOS_IS_STATUS_SUCCESS(status))
528 {
529 pSWversion = wcnss_SW_version;
530 }
531 else
532 {
533 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 }
535
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800536 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
537 sizeof(wcnss_HW_version));
538 if (VOS_IS_STATUS_SUCCESS(status))
539 {
540 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800542 else
543 {
544 pHWversion = "Unknown";
545 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700546
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530547 status = wcnss_get_iris_name(iris_name);
548
549 if (!status) {
550 pIRISversion = iris_name;
551 } else {
552 pIRISversion = "Unknown";
553 }
554
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700555 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530556 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800557 QWLAN_VERSIONSTR,
558 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530559 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800560
561 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700562}
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
565{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530566 tHalHandle hHal;
567 hdd_context_t *pHddCtx;
568 v_U32_t threshold = 0;
569 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700570
571 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530572 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
575 "%s: Adapter is NULL",__func__);
576 return -EINVAL;
577 }
578
579 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
580 ret = wlan_hdd_validate_context(pHddCtx);
581 if (0 != ret)
582 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530583 return ret;
584 }
585
586 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
587 if (NULL == hHal)
588 {
589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
590 "%s: Hal Context is NULL",__func__);
591 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 }
593
594 if ( eHAL_STATUS_SUCCESS !=
595 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
596 {
c_hpothub8245442013-11-20 23:41:09 +0530597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
598 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 return -EIO;
600 }
601 wrqu->rts.value = threshold;
602
603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800604 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700605
606 EXIT();
607
608 return 0;
609}
610
611int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
612{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530613 tHalHandle hHal;
614 hdd_context_t *pHddCtx;
615 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700616
617 ENTER();
618
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530619 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530620 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
622 "%s: Adapter is NULL",__func__);
623 return -EINVAL;
624 }
625
626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
627 status = wlan_hdd_validate_context(pHddCtx);
628 if (0 != status)
629 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530630 return status;
631 }
632
633 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
634 if (NULL == hHal)
635 {
636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
637 "%s: Hal Context is NULL",__func__);
638 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 }
640
641 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
642 != eHAL_STATUS_SUCCESS )
643 {
c_hpothub8245442013-11-20 23:41:09 +0530644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
645 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 return -EIO;
647 }
648 wrqu->frag.value = threshold;
649
650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800651 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
653 EXIT();
654
655 return 0;
656}
657
658int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
659{
Jeff Johnsone7245742012-09-05 17:12:55 -0700660 int i;
661 if (channel > 0)
662 {
663 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
664 {
665 if (channel == freq_chan_map[i].chan)
666 {
667 *pfreq = freq_chan_map[i].freq;
668 return 1;
669 }
670 }
671 }
672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800673 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700674 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700675}
676
677static v_BOOL_t
678hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
679{
680 v_BOOL_t rsnType = VOS_FALSE;
681 // is the authType supported?
682 switch (authType)
683 {
684 case eCSR_AUTH_TYPE_NONE: //never used
685 rsnType = eANI_BOOLEAN_FALSE;
686 break;
687 // MAC layer authentication types
688 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
689 rsnType = eANI_BOOLEAN_FALSE;
690 break;
691 case eCSR_AUTH_TYPE_SHARED_KEY:
692 rsnType = eANI_BOOLEAN_FALSE;
693 break;
694 case eCSR_AUTH_TYPE_AUTOSWITCH:
695 rsnType = eANI_BOOLEAN_FALSE;
696 break;
697
698 // Upper layer authentication types
699 case eCSR_AUTH_TYPE_WPA:
700 rsnType = eANI_BOOLEAN_TRUE;
701 break;
702 case eCSR_AUTH_TYPE_WPA_PSK:
703 rsnType = eANI_BOOLEAN_TRUE;
704 break;
705 case eCSR_AUTH_TYPE_WPA_NONE:
706 rsnType = eANI_BOOLEAN_TRUE;
707 break;
708#ifdef WLAN_FEATURE_VOWIFI_11R
709 case eCSR_AUTH_TYPE_FT_RSN:
710#endif
711 case eCSR_AUTH_TYPE_RSN:
712 rsnType = eANI_BOOLEAN_TRUE;
713 break;
714#ifdef WLAN_FEATURE_VOWIFI_11R
715 case eCSR_AUTH_TYPE_FT_RSN_PSK:
716#endif
717 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700718#ifdef WLAN_FEATURE_11W
719 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530720 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700721#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 rsnType = eANI_BOOLEAN_TRUE;
723 break;
724 //case eCSR_AUTH_TYPE_FAILED:
725 case eCSR_AUTH_TYPE_UNKNOWN:
726 rsnType = eANI_BOOLEAN_FALSE;
727 break;
728 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800729 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
730 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 rsnType = eANI_BOOLEAN_FALSE;
732 break;
733 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800734 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700735 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 return rsnType;
737}
738
739static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
740{
741 struct statsContext *pStatsContext;
742 hdd_adapter_t *pAdapter;
743
744 if (ioctl_debug)
745 {
746 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700747 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 }
749
750 if (NULL == pContext)
751 {
752 hddLog(VOS_TRACE_LEVEL_ERROR,
753 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700754 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 return;
756 }
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 pStatsContext = pContext;
759 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800760
761 /* there is a race condition that exists between this callback
762 function and the caller since the caller could time out either
763 before or while this code is executing. we use a spinlock to
764 serialize these actions */
765 spin_lock(&hdd_context_lock);
766
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
768 {
769 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800770 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 hddLog(VOS_TRACE_LEVEL_WARN,
772 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700773 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 if (ioctl_debug)
775 {
776 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700777 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 }
779 return;
780 }
781
Jeff Johnson72a40512013-12-19 10:14:15 -0800782 /* context is valid so caller is still waiting */
783
784 /* paranoia: invalidate the magic */
785 pStatsContext->magic = 0;
786
Sachin Ahujaa082b672015-10-05 19:51:31 +0530787 /* copy over the rssi.FW will return RSSI as -100
788 * if there are no samples to calculate the average
789 * RSSI
790 */
791 if (rssi != -100)
792 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530793 if (pAdapter->rssi > 0)
794 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800795 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800797
798 /* serialization is complete */
799 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700800}
801
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530802static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
803{
804 struct statsContext *pStatsContext;
805 hdd_adapter_t *pAdapter;
806
807 if (ioctl_debug)
808 {
809 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
810 __func__, (int)snr, (int)staId, pContext);
811 }
812
813 if (NULL == pContext)
814 {
815 hddLog(VOS_TRACE_LEVEL_ERROR,
816 "%s: Bad param, pContext [%p]",
817 __func__, pContext);
818 return;
819 }
820
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530821 pStatsContext = pContext;
822 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800823
824 /* there is a race condition that exists between this callback
825 function and the caller since the caller could time out either
826 before or while this code is executing. we use a spinlock to
827 serialize these actions */
828 spin_lock(&hdd_context_lock);
829
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530830 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
831 {
832 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800833 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530834 hddLog(VOS_TRACE_LEVEL_WARN,
835 "%s: Invalid context, pAdapter [%p] magic [%08x]",
836 __func__, pAdapter, pStatsContext->magic);
837 if (ioctl_debug)
838 {
839 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
840 __func__, pAdapter, pStatsContext->magic);
841 }
842 return;
843 }
844
Jeff Johnson72a40512013-12-19 10:14:15 -0800845 /* context is valid so caller is still waiting */
846
847 /* paranoia: invalidate the magic */
848 pStatsContext->magic = 0;
849
850 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530851 pAdapter->snr = snr;
852
Jeff Johnson72a40512013-12-19 10:14:15 -0800853 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530854 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800855
856 /* serialization is complete */
857 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530858}
859
Jeff Johnson295189b2012-06-20 16:38:30 -0700860VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
861{
862 struct statsContext context;
863 hdd_context_t *pHddCtx;
864 hdd_station_ctx_t *pHddStaCtx;
865 eHalStatus hstatus;
866 long lrc;
867
868 if (NULL == pAdapter)
869 {
870 hddLog(VOS_TRACE_LEVEL_WARN,
871 "%s: Invalid context, pAdapter", __func__);
872 return VOS_STATUS_E_FAULT;
873 }
874 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
875 {
876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
877 /* return a cached value */
878 *rssi_value = pAdapter->rssi;
879 return VOS_STATUS_SUCCESS;
880 }
881
882 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
883 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
884
mukul sharma8aec69b2015-06-10 22:28:43 +0530885 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
886 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
888 __func__, pAdapter->rssi_on_disconnect);
889 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530890 return VOS_STATUS_SUCCESS;
891 }
892
893 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
894 {
895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
896 "%s: Roaming in progress, hence return last cached RSSI", __func__);
897 *rssi_value = pAdapter->rssi;
898 return VOS_STATUS_SUCCESS;
899 }
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 init_completion(&context.completion);
902 context.pAdapter = pAdapter;
903 context.magic = RSSI_CONTEXT_MAGIC;
904
905 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
906 pHddStaCtx->conn_info.staId[ 0 ],
907 pHddStaCtx->conn_info.bssId,
908 &context, pHddCtx->pvosContext);
909 if (eHAL_STATUS_SUCCESS != hstatus)
910 {
911 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700912 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 /* we'll returned a cached value below */
914 }
915 else
916 {
917 /* request was sent -- wait for the response */
918 lrc = wait_for_completion_interruptible_timeout(&context.completion,
919 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 if (lrc <= 0)
921 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800922 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700923 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 /* we'll now returned a cached value below */
925 }
926 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800927
928 /* either we never sent a request, we sent a request and received a
929 response or we sent a request and timed out. if we never sent a
930 request or if we sent a request and got a response, we want to
931 clear the magic out of paranoia. if we timed out there is a
932 race condition such that the callback function could be
933 executing at the same time we are. of primary concern is if the
934 callback function had already verified the "magic" but had not
935 yet set the completion variable when a timeout occurred. we
936 serialize these activities by invalidating the magic while
937 holding a shared spinlock which will cause us to block if the
938 callback is currently executing */
939 spin_lock(&hdd_context_lock);
940 context.magic = 0;
941 spin_unlock(&hdd_context_lock);
942
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 *rssi_value = pAdapter->rssi;
944
945 return VOS_STATUS_SUCCESS;
946}
Siddharth Bhal64246172015-02-27 01:04:37 +0530947/**---------------------------------------------------------------------------
948
949 \brief wlan_hdd_get_frame_logs() -
950
951 This function use to get Frames log.
952
953 \param - pAdapter Pointer to the adapter.
954 flag - Specify type of request. Clear and Send request are
955 supported.
956
957 \return - none
958
959 --------------------------------------------------------------------------*/
960VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
961{
Siddharth Bhal64246172015-02-27 01:04:37 +0530962 hdd_context_t *pHddCtx;
963 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530964
965 if (NULL == pAdapter)
966 {
967 hddLog(VOS_TRACE_LEVEL_WARN,
968 "%s: Invalid context, pAdapter", __func__);
969 return VOS_STATUS_E_FAULT;
970 }
971
972 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
973 if (!pHddCtx->mgmt_frame_logging)
974 {
975 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
976 return VOS_STATUS_E_AGAIN;
977 }
978
Siddharth Bhal4507c262015-04-29 20:20:42 +0530979 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
980 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
981 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530982 {
983 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
984 return VOS_STATUS_E_INVAL;
985 }
986
Siddharth Bhal4507c262015-04-29 20:20:42 +0530987 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
988 (!pHddCtx->cfg_ini->enableBMUHWtracing))
989 {
990 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
991 return VOS_STATUS_E_INVAL;
992 }
993
Abhishek Singh611295e2015-07-09 11:11:54 +0530994 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530995 if (eHAL_STATUS_SUCCESS != hstatus)
996 {
997 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530998 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530999 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301000
1001 return VOS_STATUS_SUCCESS;
1002}
1003
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301004
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301005VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1006{
1007 struct statsContext context;
1008 hdd_context_t *pHddCtx;
1009 hdd_station_ctx_t *pHddStaCtx;
1010 eHalStatus hstatus;
1011 long lrc;
1012 int valid;
1013
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301014 ENTER();
1015
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301016 if (NULL == pAdapter)
1017 {
1018 hddLog(VOS_TRACE_LEVEL_ERROR,
1019 "%s: Invalid context, pAdapter", __func__);
1020 return VOS_STATUS_E_FAULT;
1021 }
1022
1023 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1024
1025 valid = wlan_hdd_validate_context(pHddCtx);
1026 if (0 != valid)
1027 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301028 return VOS_STATUS_E_FAULT;
1029 }
1030
1031 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1032 if (NULL == pHddStaCtx)
1033 {
1034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1035 return VOS_STATUS_E_FAULT;
1036 }
1037
1038 init_completion(&context.completion);
1039 context.pAdapter = pAdapter;
1040 context.magic = SNR_CONTEXT_MAGIC;
1041
1042 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1043 pHddStaCtx->conn_info.staId[ 0 ],
1044 pHddStaCtx->conn_info.bssId,
1045 &context);
1046 if (eHAL_STATUS_SUCCESS != hstatus)
1047 {
1048 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1049 __func__);
1050 /* we'll returned a cached value below */
1051 }
1052 else
1053 {
1054 /* request was sent -- wait for the response */
1055 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1056 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301057 if (lrc <= 0)
1058 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301060 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301061 /* we'll now returned a cached value below */
1062 }
1063 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001064
1065 /* either we never sent a request, we sent a request and received a
1066 response or we sent a request and timed out. if we never sent a
1067 request or if we sent a request and got a response, we want to
1068 clear the magic out of paranoia. if we timed out there is a
1069 race condition such that the callback function could be
1070 executing at the same time we are. of primary concern is if the
1071 callback function had already verified the "magic" but had not
1072 yet set the completion variable when a timeout occurred. we
1073 serialize these activities by invalidating the magic while
1074 holding a shared spinlock which will cause us to block if the
1075 callback is currently executing */
1076 spin_lock(&hdd_context_lock);
1077 context.magic = 0;
1078 spin_unlock(&hdd_context_lock);
1079
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301080 *snr = pAdapter->snr;
1081
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301082 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301083 return VOS_STATUS_SUCCESS;
1084}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301085
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001086#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001087
1088static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1089{
1090 struct statsContext *pStatsContext;
1091 hdd_adapter_t *pAdapter;
1092 if (ioctl_debug)
1093 {
1094 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1095 __func__, (int)rssi, (int)staId, pContext);
1096 }
1097
1098 if (NULL == pContext)
1099 {
1100 hddLog(VOS_TRACE_LEVEL_ERROR,
1101 "%s: Bad param, pContext [%p]",
1102 __func__, pContext);
1103 return;
1104 }
1105
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001106 pStatsContext = pContext;
1107 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001108
1109 /* there is a race condition that exists between this callback
1110 function and the caller since the caller could time out either
1111 before or while this code is executing. we use a spinlock to
1112 serialize these actions */
1113 spin_lock(&hdd_context_lock);
1114
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001115 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1116 {
1117 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001118 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001119 hddLog(VOS_TRACE_LEVEL_WARN,
1120 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1121 __func__, pAdapter, pStatsContext->magic);
1122 if (ioctl_debug)
1123 {
1124 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1125 __func__, pAdapter, pStatsContext->magic);
1126 }
1127 return;
1128 }
1129
Jeff Johnson72a40512013-12-19 10:14:15 -08001130 /* context is valid so caller is still waiting */
1131
1132 /* paranoia: invalidate the magic */
1133 pStatsContext->magic = 0;
1134
Sachin Ahujaa082b672015-10-05 19:51:31 +05301135 /* copy over the rssi.FW will return RSSI as -100
1136 * if there are no samples to calculate the average
1137 * RSSI
1138 */
1139 if (rssi != -100)
1140 pAdapter->rssi = rssi;
1141
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301142 if (pAdapter->rssi > 0)
1143 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001144 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001145 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001146
1147 /* serialization is complete */
1148 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001149}
1150
1151
1152
1153VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1154{
1155 struct statsContext context;
1156 hdd_context_t *pHddCtx = NULL;
1157 hdd_station_ctx_t *pHddStaCtx = NULL;
1158 eHalStatus hstatus;
1159 long lrc;
1160
1161 if (NULL == pAdapter)
1162 {
1163 hddLog(VOS_TRACE_LEVEL_WARN,
1164 "%s: Invalid context, pAdapter", __func__);
1165 return VOS_STATUS_E_FAULT;
1166 }
1167 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1168 {
1169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1170 /* return a cached value */
1171 *rssi_value = pAdapter->rssi;
1172 return VOS_STATUS_SUCCESS;
1173 }
1174
1175 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1176 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1177
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301178 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001179 {
1180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1181 /* return a cached value */
1182 *rssi_value = 0;
1183 return VOS_STATUS_SUCCESS;
1184 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301185
1186 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1187 {
1188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1189 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1190 *rssi_value = pAdapter->rssi;
1191 return VOS_STATUS_SUCCESS;
1192 }
1193
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001194 init_completion(&context.completion);
1195 context.pAdapter = pAdapter;
1196 context.magic = RSSI_CONTEXT_MAGIC;
1197
1198 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1199 pHddStaCtx->conn_info.staId[ 0 ],
1200 pHddStaCtx->conn_info.bssId,
1201 &context, pHddCtx->pvosContext);
1202 if (eHAL_STATUS_SUCCESS != hstatus)
1203 {
1204 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1205 __func__);
1206 /* we'll returned a cached value below */
1207 }
1208 else
1209 {
1210 /* request was sent -- wait for the response */
1211 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1212 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001213 if (lrc <= 0)
1214 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001215 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001216 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001217 /* we'll now returned a cached value below */
1218 }
1219 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001220
1221 /* either we never sent a request, we sent a request and received a
1222 response or we sent a request and timed out. if we never sent a
1223 request or if we sent a request and got a response, we want to
1224 clear the magic out of paranoia. if we timed out there is a
1225 race condition such that the callback function could be
1226 executing at the same time we are. of primary concern is if the
1227 callback function had already verified the "magic" but had not
1228 yet set the completion variable when a timeout occurred. we
1229 serialize these activities by invalidating the magic while
1230 holding a shared spinlock which will cause us to block if the
1231 callback is currently executing */
1232 spin_lock(&hdd_context_lock);
1233 context.magic = 0;
1234 spin_unlock(&hdd_context_lock);
1235
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001236 *rssi_value = pAdapter->rssi;
1237
1238 return VOS_STATUS_SUCCESS;
1239}
1240#endif
1241
1242
Jeff Johnson295189b2012-06-20 16:38:30 -07001243void hdd_StatisticsCB( void *pStats, void *pContext )
1244{
1245 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1246 hdd_stats_t *pStatsCache = NULL;
1247 hdd_wext_state_t *pWextState;
1248 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1249
1250 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1251 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1252 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1253 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1254 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1255 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1256
1257 if (pAdapter!= NULL)
1258 pStatsCache = &pAdapter->hdd_stats;
1259
1260
1261 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1262 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1263 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1264 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1265 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1266 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1267
1268 if (pStatsCache!=NULL)
1269 {
1270 // and copy the stats into the cache we keep in the adapter instance structure
1271 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1272 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1273 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1274 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1275 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1276 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1277 }
1278
1279 if(pAdapter)
1280 {
1281 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1282 if(pWextState)
1283 {
1284 vos_status = vos_event_set(&pWextState->vosevent);
1285 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1286 {
1287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001288 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 return;
1290 }
1291 }
1292 }
1293}
1294
1295void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1296{
1297 v_CONTEXT_t pVosContext;
1298 hdd_context_t *pHddCtx;
1299 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1300#if 0
1301 hdd_wext_state_t *pWextState;
1302 v_U32_t roamId;
1303#endif
1304
1305 ENTER();
1306
1307 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1308
1309 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1310 if (NULL == pHddCtx)
1311 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001312 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 return;
1314 }
1315#if 0
1316 pWextState = pAdapter->pWextState;
1317#endif
1318
1319 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1320 {
1321 //TODO Verify is this is really used. If yes need to fix it.
1322 hdd_reconnect_all_adapters( pHddCtx );
1323#if 0
1324 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1325 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1326 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1327
1328 if(VOS_STATUS_SUCCESS == vosStatus)
1329 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1330 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1331
1332 sme_RoamConnect(halHandle,
1333 pAdapter->sessionId, &(pWextState->roamProfile),
1334 &roamId);
1335#endif
1336 }
1337
1338 EXIT();
1339
1340}
1341
1342void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1343{
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1345
1346 /* clear WPA/RSN/WSC IE information in the profile */
1347 pWextState->roamProfile.nWPAReqIELength = 0;
1348 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1349 pWextState->roamProfile.nRSNReqIELength = 0;
1350 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1351
Chet Lanctot186b5732013-03-18 10:26:30 -07001352#ifdef FEATURE_WLAN_WAPI
1353 pWextState->roamProfile.nWAPIReqIELength = 0;
1354 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1355#endif
1356
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001358 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301360 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1362 pWextState->roamProfile.nAddIEAssocLength = 0;
1363
1364 pWextState->roamProfile.EncryptionType.numEntries = 1;
1365 pWextState->roamProfile.EncryptionType.encryptionType[0]
1366 = eCSR_ENCRYPT_TYPE_NONE;
1367
1368 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1369 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1370 = eCSR_ENCRYPT_TYPE_NONE;
1371
1372 pWextState->roamProfile.AuthType.numEntries = 1;
1373 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1374
Chet Lanctot186b5732013-03-18 10:26:30 -07001375#ifdef WLAN_FEATURE_11W
1376 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1377 pWextState->roamProfile.MFPRequired = 0;
1378 pWextState->roamProfile.MFPCapable = 0;
1379#endif
1380
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 pWextState->authKeyMgmt = 0;
1382
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301383 vos_mem_zero(&pWextState->roamProfile.Keys,
1384 sizeof(pWextState->roamProfile.Keys));
1385
Jeff Johnson295189b2012-06-20 16:38:30 -07001386#ifdef FEATURE_WLAN_WAPI
1387 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1388 pAdapter->wapi_info.nWapiMode = 0;
1389#endif
1390
1391 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1392
1393}
1394
1395void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1396{
1397 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001398
Nirav Shahf6bd2672015-03-11 12:53:15 +05301399 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001400 {
1401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301402 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001403 }
1404 else
1405 {
1406 complete(&pAdapter->ula_complete);
1407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001408}
1409
1410VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1411{
1412 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001414 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
1416 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1417 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001418 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001419
1420 /*To avoid race condition between the set key and the last EAPOL
1421 packet, notify TL to finish upper layer authentication incase if the
1422 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001423 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001424
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001425 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 {
1427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1428 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1429 __LINE__, vos_status );
1430 return vos_status;
1431
1432 }
1433
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001434 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301436 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001437 {
1438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301439 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001440 /* we'll still fall through and return success since the
1441 * connection may still get established but is just taking
1442 * too long for us to wait */
1443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 }
1445 return VOS_STATUS_SUCCESS;
1446}
1447
1448v_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)
1449{
1450
1451 int left = ie_len;
1452 v_U8_t *ptr = ie;
1453 v_U8_t elem_id,elem_len;
1454 v_U8_t eid = 0xDD;
1455
1456 if ( NULL == ie || 0 == ie_len )
1457 return NULL;
1458
1459 while(left >= 2)
1460 {
1461 elem_id = ptr[0];
1462 elem_len = ptr[1];
1463 left -= 2;
1464 if(elem_len > left)
1465 {
1466 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001467 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 eid,elem_len,left);
1469 return NULL;
1470 }
1471 if (elem_id == eid)
1472 {
1473 if(memcmp( &ptr[2], oui, oui_size)==0)
1474 return ptr;
1475 }
1476
1477 left -= elem_len;
1478 ptr += (elem_len + 2);
1479 }
1480 return NULL;
1481}
1482
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301483static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 union iwreq_data *wrqu, char *extra)
1485{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301486 hdd_adapter_t *pAdapter;
1487 hdd_context_t *pHddCtx;
1488 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301489
1490 ENTER();
1491
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301492 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1493 if (NULL == pAdapter)
1494 {
1495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1496 "%s: pAdapter is NULL\n", __func__);
1497 return -EINVAL;
1498 }
1499 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1500 ret = wlan_hdd_validate_context(pHddCtx);
1501 if (0 != ret)
1502 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301503 return ret;
1504 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301505
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301507
1508 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301509 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510}
1511
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301512static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1513 union iwreq_data *wrqu, char *extra)
1514{
1515 int ret;
1516
1517 vos_ssr_protect(__func__);
1518 ret = __iw_set_commit(dev, info, wrqu, extra);
1519 vos_ssr_unprotect(__func__);
1520
1521 return ret;
1522}
1523
1524static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 struct iw_request_info *info,
1526 char *wrqu, char *extra)
1527{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301528 hdd_adapter_t *pAdapter;
1529 hdd_context_t *pHddCtx;
1530 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301531
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301533 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1534 if (NULL == pAdapter)
1535 {
1536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1537 "%s: pAdapter is NULL\n", __func__);
1538 return -EINVAL;
1539 }
1540 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1541 ret = wlan_hdd_validate_context(pHddCtx);
1542 if (0 != ret)
1543 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301544 return ret;
1545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1547 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301548 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001549}
1550
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301551static int iw_get_name(struct net_device *dev,
1552 struct iw_request_info *info,
1553 char *wrqu, char *extra)
1554{
1555 int ret;
1556
1557 vos_ssr_protect(__func__);
1558 ret = __iw_get_name(dev, info, wrqu, extra);
1559 vos_ssr_unprotect(__func__);
1560
1561 return ret;
1562}
1563
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301564static int __iw_set_mode(struct net_device *dev,
1565 struct iw_request_info *info,
1566 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001567{
1568 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301569 hdd_adapter_t *pAdapter;
1570 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 tCsrRoamProfile *pRoamProfile;
1572 eCsrRoamBssType LastBSSType;
1573 eMib_dot11DesiredBssType connectedBssType;
1574 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301576 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001577
1578 ENTER();
1579
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301580 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 if (NULL == pAdapter)
1582 {
1583 hddLog(VOS_TRACE_LEVEL_WARN,
1584 "%s: Invalid context, pAdapter", __func__);
1585 return 0;
1586 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301587 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1588 status = wlan_hdd_validate_context(pHddCtx);
1589 if (0 != status)
1590 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301591 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 }
1593
1594 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1595 if (pWextState == NULL)
1596 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301597 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 return -EINVAL;
1599 }
1600
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 pRoamProfile = &pWextState->roamProfile;
1603 LastBSSType = pRoamProfile->BSSType;
1604
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301605 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001606
1607 switch (wrqu->mode)
1608 {
1609 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301610 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1612 // Set the phymode correctly for IBSS.
1613 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1614 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001615 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 break;
1618 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301619 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 break;
1623 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301624 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1626 break;
1627 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301628 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 return -EOPNOTSUPP;
1630 }
1631
1632 if ( LastBSSType != pRoamProfile->BSSType )
1633 {
1634 //the BSS mode changed
1635 // We need to issue disconnect if connected or in IBSS disconnect state
1636 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1637 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1638 {
1639 VOS_STATUS vosStatus;
1640 // need to issue a disconnect to CSR.
1641 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1642 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1643 pAdapter->sessionId,
1644 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1645 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301646 {
1647 long ret;
1648 ret = wait_for_completion_interruptible_timeout(
1649 &pAdapter->disconnect_comp_var,
1650 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1651 if (ret <= 0)
1652 hddLog(VOS_TRACE_LEVEL_ERROR,
1653 FL("failed wait on disconnect_comp_var %ld"), ret);
1654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 }
1656 }
1657
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 EXIT();
1659 return 0;
1660}
1661
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301662static int iw_set_mode(struct net_device *dev,
1663 struct iw_request_info *info,
1664 union iwreq_data *wrqu, char *extra)
1665{
1666 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001667
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301668 vos_ssr_protect(__func__);
1669 ret = __iw_set_mode(dev, info, wrqu, extra);
1670 vos_ssr_unprotect(__func__);
1671
1672 return ret;
1673}
1674
1675static int __iw_get_mode(struct net_device *dev,
1676 struct iw_request_info *info,
1677 union iwreq_data *wrqu,
1678 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001679{
1680
1681 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301682 hdd_adapter_t *pAdapter;
1683 hdd_context_t *pHddCtx;
1684 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001685
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301686 ENTER();
1687
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301688 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 if (NULL == pAdapter)
1690 {
1691 hddLog(VOS_TRACE_LEVEL_WARN,
1692 "%s: Invalid context, pAdapter", __func__);
1693 return 0;
1694 }
1695
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301696 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1697 ret = wlan_hdd_validate_context(pHddCtx);
1698 if (0 != ret)
1699 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301700 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1703 if (pWextState == NULL)
1704 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301705 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 return -EINVAL;
1707 }
1708
1709 switch (pWextState->roamProfile.BSSType)
1710 {
1711 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001712 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301713 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 break;
1715 case eCSR_BSS_TYPE_IBSS:
1716 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001717 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301718 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 break;
1720 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001721 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301722 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 break;
1724 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001725 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 break;
1727 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301728
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301729 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 return 0;
1731}
1732
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301733static int iw_get_mode(struct net_device *dev,
1734 struct iw_request_info *info,
1735 union iwreq_data *wrqu,
1736 char *extra)
1737{
1738 int ret;
1739
1740 vos_ssr_protect(__func__);
1741 ret = __iw_get_mode(dev, info, wrqu, extra);
1742 vos_ssr_unprotect(__func__);
1743
1744 return ret;
1745}
1746
1747static int __iw_set_freq(struct net_device *dev,
1748 struct iw_request_info *info,
1749 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001750{
1751 v_U32_t numChans = 0;
1752 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1753 v_U32_t indx = 0;
1754 v_U32_t status = 0;
1755
1756 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301757 hdd_adapter_t *pAdapter;
1758 hdd_context_t *pHddCtx;
1759 tHalHandle hHal;
1760 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301762
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 ENTER();
1764
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301765 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1766 if (NULL == pAdapter)
1767 {
1768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1769 "%s:Invalid Adapter",__func__);
1770 return -EINVAL;
1771 }
1772
1773 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1774 status = wlan_hdd_validate_context(pHddCtx);
1775 if (0 != status)
1776 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 return status;
1778 }
1779
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301780 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1781 if (NULL == hHal)
1782 {
1783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1784 "%s: Hal Context is NULL",__func__);
1785 return -EINVAL;
1786 }
1787
1788 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1789 if (NULL == pHddStaCtx)
1790 {
1791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1792 "%s:STA context is NULL",__func__);
1793 return -EINVAL;
1794 }
1795
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301797 if (NULL == pWextState)
1798 {
1799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1800 "%s: pWextState is NULL",__func__);
1801 return -EINVAL;
1802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001803
1804 pRoamProfile = &pWextState->roamProfile;
1805
Arif Hussain6d2a3322013-11-17 19:50:10 -08001806 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001807
1808 /* Link is up then return cant set channel*/
1809 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1810 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1811 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001812 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 return -EOPNOTSUPP;
1814 }
1815
1816 /* Settings by Frequency as input */
1817 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1818 (wrqu->freq.m <= (tANI_U32)5.825e8))
1819 {
1820 tANI_U32 freq = wrqu->freq.m / 100000;
1821
1822 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1823 indx++;
1824 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1825 {
1826 return -EINVAL;
1827 }
1828 wrqu->freq.e = 0;
1829 wrqu->freq.m = freq_chan_map[indx].chan;
1830
1831 }
1832
1833 if (wrqu->freq.e == 0)
1834 {
1835 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1836 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001838 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001839 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1841 return -EINVAL;
1842 }
1843
1844 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1845
1846 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1847 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1849 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 return -EIO;
1851 }
1852
1853 for (indx = 0; indx < numChans; indx++) {
1854 if (wrqu->freq.m == validChan[indx]){
1855 break;
1856 }
1857 }
1858 }
1859 else{
1860
1861 return -EINVAL;
1862 }
1863
1864 if(indx >= numChans)
1865 {
1866 return -EINVAL;
1867 }
1868
1869 /* Set the Operational Channel */
1870 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1871 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1872 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1873
Arif Hussain6d2a3322013-11-17 19:50:10 -08001874 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001875
1876 EXIT();
1877
1878 return status;
1879}
1880
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301881static int iw_set_freq(struct net_device *dev,
1882 struct iw_request_info *info,
1883 union iwreq_data *wrqu, char *extra)
1884{
1885 int ret;
1886
1887 vos_ssr_protect(__func__);
1888 ret = __iw_set_freq(dev, info, wrqu, extra);
1889 vos_ssr_unprotect(__func__);
1890
1891 return ret;
1892}
1893
1894static int __iw_get_freq(struct net_device *dev,
1895 struct iw_request_info *info,
1896 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001897{
Jeff Johnsone7245742012-09-05 17:12:55 -07001898 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301899 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 tHalHandle hHal;
1901 hdd_wext_state_t *pWextState;
1902 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301903 hdd_station_ctx_t *pHddStaCtx;
1904 hdd_context_t *pHddCtx;
1905 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001906
1907 ENTER();
1908
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301909 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1910 if (NULL == pAdapter)
1911 {
1912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1913 "%s: Adapter is NULL", __func__);
1914 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301916 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1917 ret = wlan_hdd_validate_context(pHddCtx);
1918 if (0 != ret)
1919 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301920 return ret;
1921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301923 if (NULL == hHal)
1924 {
1925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1926 "%s: Hal Context is NULL",__func__);
1927 return -EINVAL;
1928 }
1929 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1930 if (NULL == pHddStaCtx)
1931 {
1932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1933 "%s: HddStaCtx is NULL", __func__);
1934 return -EINVAL;
1935 }
1936 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1937 if (NULL == pWextState)
1938 {
1939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1940 "%s: pWextState is NULL",__func__);
1941 return -EINVAL;
1942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 pRoamProfile = &pWextState->roamProfile;
1944
1945 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1946 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001947 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 {
c_hpothub8245442013-11-20 23:41:09 +05301949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1950 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 return -EIO;
1952 }
1953 else
1954 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001955 status = hdd_wlan_get_freq(channel, &freq);
1956 if( TRUE == status )
1957 {
1958 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1959 * iwlist & iwconfig command shows frequency into proper
1960 * format (2.412 GHz instead of 246.2 MHz)*/
1961 fwrq->m = freq;
1962 fwrq->e = MHZ;
1963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 }
1965 }
1966 else
1967 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001968 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1969 * iwlist & iwconfig command shows frequency into proper
1970 * format (2.412 GHz instead of 246.2 MHz)*/
1971 fwrq->m = 0;
1972 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001973 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301974
1975 EXIT();
1976 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977}
1978
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301979static int iw_get_freq(struct net_device *dev,
1980 struct iw_request_info *info,
1981 struct iw_freq *fwrq, char *extra)
1982{
1983 int ret;
1984
1985 vos_ssr_protect(__func__);
1986 ret = __iw_get_freq(dev, info, fwrq, extra);
1987 vos_ssr_unprotect(__func__);
1988
1989 return ret;
1990}
1991
1992static int __iw_get_tx_power(struct net_device *dev,
1993 struct iw_request_info *info,
1994 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001995{
1996
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301997 hdd_adapter_t *pAdapter;
1998 hdd_context_t *pHddCtx;
1999 hdd_station_ctx_t *pHddStaCtx;
2000 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002001
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302002 ENTER();
2003
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302004 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2005 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2008 "%s: Adapter is NULL",__func__);
2009 return -EINVAL;
2010 }
2011 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2012 ret = wlan_hdd_validate_context(pHddCtx);
2013 if (0 != ret)
2014 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302015 return ret;
2016 }
2017
2018 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2019 if (NULL == pHddStaCtx)
2020 {
2021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2022 "%s: STA Context is NULL",__func__);
2023 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 }
2025
2026 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2027 {
2028 wrqu->txpower.value = 0;
2029 return 0;
2030 }
2031 wlan_hdd_get_classAstats(pAdapter);
2032 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302034 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 return 0;
2036}
2037
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302038static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 struct iw_request_info *info,
2040 union iwreq_data *wrqu, char *extra)
2041{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302042 int ret;
2043
2044 vos_ssr_protect(__func__);
2045 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2046 vos_ssr_unprotect(__func__);
2047
2048 return ret;
2049}
2050
2051static int __iw_set_tx_power(struct net_device *dev,
2052 struct iw_request_info *info,
2053 union iwreq_data *wrqu, char *extra)
2054{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302055 hdd_adapter_t *pAdapter;
2056 tHalHandle hHal;
2057 hdd_context_t *pHddCtx;
2058 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002059
2060 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302061 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2062 if (NULL == pAdapter)
2063 {
2064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2065 "%s: Adapter is NULL",__func__);
2066 return -EINVAL;
2067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302069 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2070 ret = wlan_hdd_validate_context(pHddCtx);
2071 if (0 != ret)
2072 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302073 return ret;
2074 }
2075
2076 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2077 if (NULL == hHal)
2078 {
2079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2080 "%s: Hal Context is NULL",__func__);
2081 return -EINVAL;
2082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2084 {
c_hpothub8245442013-11-20 23:41:09 +05302085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2086 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 return -EIO;
2088 }
2089
2090 EXIT();
2091
2092 return 0;
2093}
2094
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302095static int iw_set_tx_power(struct net_device *dev,
2096 struct iw_request_info *info,
2097 union iwreq_data *wrqu, char *extra)
2098{
2099 int ret;
2100
2101 vos_ssr_protect(__func__);
2102 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2103 vos_ssr_unprotect(__func__);
2104
2105 return ret;
2106}
2107
2108static int __iw_get_bitrate(struct net_device *dev,
2109 struct iw_request_info *info,
2110 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002111{
2112 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2113 eHalStatus status = eHAL_STATUS_SUCCESS;
2114 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302115 hdd_adapter_t *pAdapter;
2116 hdd_context_t *pHddCtx;
2117 hdd_station_ctx_t *pHddStaCtx;
2118 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119
2120 ENTER();
2121
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302122 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2123 if (NULL == pAdapter)
2124 {
2125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2126 "%s: Adapter is NULL",__func__);
2127 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 }
2129
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302130 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2131 ret = wlan_hdd_validate_context(pHddCtx);
2132 if (0 != ret)
2133 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302134 return ret;
2135 }
2136
2137 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2138 if (NULL == pHddStaCtx)
2139 {
2140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2141 "%s: STA Context is NULL",__func__);
2142 return -EINVAL;
2143 }
2144
2145 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 wrqu->bitrate.value = 0;
2147 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302148 else
2149 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2151 SME_SUMMARY_STATS |
2152 SME_GLOBAL_CLASSA_STATS |
2153 SME_GLOBAL_CLASSB_STATS |
2154 SME_GLOBAL_CLASSC_STATS |
2155 SME_GLOBAL_CLASSD_STATS |
2156 SME_PER_STA_STATS,
2157 hdd_StatisticsCB, 0, FALSE,
2158 pHddStaCtx->conn_info.staId[0], pAdapter );
2159
2160 if(eHAL_STATUS_SUCCESS != status)
2161 {
2162 hddLog(VOS_TRACE_LEVEL_ERROR,
2163 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002164 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 return status;
2166 }
2167
2168 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302169 if (NULL == pWextState)
2170 {
2171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2172 "%s: pWextState is NULL",__func__);
2173 return -EINVAL;
2174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002175
2176 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2177
2178 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2179 {
2180 hddLog(VOS_TRACE_LEVEL_ERROR,
2181 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002182 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 return VOS_STATUS_E_FAILURE;
2184 }
2185
2186 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2187 }
2188
2189 EXIT();
2190
2191 return vos_status;
2192}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302193
2194static int iw_get_bitrate(struct net_device *dev,
2195 struct iw_request_info *info,
2196 union iwreq_data *wrqu, char *extra)
2197{
2198 int ret;
2199
2200 vos_ssr_protect(__func__);
2201 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2202 vos_ssr_unprotect(__func__);
2203
2204 return ret;
2205}
2206
2207
Jeff Johnson295189b2012-06-20 16:38:30 -07002208/* ccm call back function */
2209
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302210static int __iw_set_bitrate(struct net_device *dev,
2211 struct iw_request_info *info,
2212 union iwreq_data *wrqu,
2213 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002214{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302215 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302217 hdd_station_ctx_t *pHddStaCtx;
2218 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2220 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2221 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2222 v_U32_t i, rate;
2223 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302224 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302227 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2228 if (NULL == pAdapter)
2229 {
2230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2231 "%s: Adapter is NULL",__func__);
2232 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 }
2234
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2236 ret = wlan_hdd_validate_context(pHddCtx);
2237 if (0 != ret)
2238 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302239 return ret;
2240 }
2241
2242 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2243 if (NULL == pHddStaCtx)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2246 "%s: STA Context is NULL",__func__);
2247 return -EINVAL;
2248 }
2249
2250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302252 if (NULL == pWextState)
2253 {
2254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2255 "%s: pWextState is NULL",__func__);
2256 return -EINVAL;
2257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002258
2259 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2260 {
2261 return -ENXIO ;
2262 }
2263
2264 rate = wrqu->bitrate.value;
2265
2266 if (rate == -1)
2267 {
2268 rate = WNI_CFG_FIXED_RATE_AUTO;
2269 valid_rate = TRUE;
2270 }
2271 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2272 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2273 {
2274 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2275 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2276 {
2277 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2278 WNI_CFG_SUPPORTED_RATES_11A,
2279 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2280 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2281 WNI_CFG_SUPPORTED_RATES_11B,
2282 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2283 {
2284 for (i = 0; i < (b_len + a_len); ++i)
2285 {
2286 /* supported rates returned is double the actual rate so we divide it by 2 */
2287 if ((supp_rates[i]&0x7F)/2 == rate)
2288 {
2289 valid_rate = TRUE;
2290 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2291 break;
2292 }
2293 }
2294 }
2295 }
2296 }
2297 if (valid_rate != TRUE)
2298 {
2299 return -EINVAL;
2300 }
2301 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2302 WNI_CFG_FIXED_RATE, rate,
2303 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2304 {
c_hpothub8245442013-11-20 23:41:09 +05302305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2306 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 return -EIO;
2308 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302309
2310 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 return 0;
2312}
2313
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302314static int iw_set_bitrate(struct net_device *dev,
2315 struct iw_request_info *info,
2316 union iwreq_data *wrqu,
2317 char *extra)
2318{
2319 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002320
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302321 vos_ssr_protect(__func__);
2322 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2323 vos_ssr_unprotect(__func__);
2324
2325 return ret;
2326}
2327
2328static int __iw_set_genie(struct net_device *dev,
2329 struct iw_request_info *info,
2330 union iwreq_data *wrqu,
2331 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002332{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302333 hdd_adapter_t *pAdapter;
2334 hdd_context_t *pHddCtx;
2335 hdd_wext_state_t *pWextState;
2336 u_int8_t *genie = NULL;
2337 u_int8_t *base_genie = NULL;
2338 v_U16_t remLen;
2339 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002340
2341 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002342
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302343 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2344 if (NULL == pAdapter)
2345 {
2346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2347 "%s: Adapter is NULL",__func__);
2348 return -EINVAL;
2349 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002350
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302351 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2352 ret = wlan_hdd_validate_context(pHddCtx);
2353 if (0 != ret)
2354 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302355 return ret;
2356 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002357
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302358 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2359 if (NULL == pWextState)
2360 {
2361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2362 "%s: pWextState is NULL",__func__);
2363 return -EINVAL;
2364 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002365
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302366 if (!wrqu->data.length) {
2367 hdd_clearRoamProfileIe(pAdapter);
2368 EXIT();
2369 return 0;
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302372 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2373 wrqu->data.length);
2374 if (NULL == base_genie)
2375 {
2376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2377 "mem_alloc_copy_from_user_helper fail");
2378 return -ENOMEM;
2379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002380
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302381 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002382
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302383 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002384
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302385 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2386
2387 /* clear any previous genIE before this call */
2388 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2389
2390 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 {
2392 v_U16_t eLen = 0;
2393 v_U8_t elementId;
2394 elementId = *genie++;
2395 eLen = *genie++;
2396 remLen -= 2;
2397
Arif Hussain6d2a3322013-11-17 19:50:10 -08002398 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 __func__, elementId, eLen);
2400
2401 switch ( elementId )
2402 {
2403 case IE_EID_VENDOR:
2404 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002405 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302406 ret = -EINVAL;
2407 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002409
2410 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2411 {
2412 v_U16_t curGenIELen = pWextState->genIE.length;
2413 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2414 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2415
2416 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2417 {
2418 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002419 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302421 ret = -EINVAL;
2422 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 }
2424 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2425 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2426 pWextState->genIE.length += eLen + 2;
2427 }
2428 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2429 {
2430 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302431 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2432 {
2433 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2434 "Need bigger buffer space");
2435 ret = -EINVAL;
2436 VOS_ASSERT(0);
2437 goto exit;
2438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2440 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2441 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2442 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2443 }
2444 else /* any vendorId except WPA IE should be accumulated to genIE */
2445 {
2446 v_U16_t curGenIELen = pWextState->genIE.length;
2447 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2448 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2449
2450 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2451 {
2452 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002453 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302455 ret = -ENOMEM;
2456 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 }
2458 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2459 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2460 pWextState->genIE.length += eLen + 2;
2461 }
2462 break;
2463 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002464 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302465 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2466 {
2467 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2468 "Need bigger buffer space");
2469 ret = -EINVAL;
2470 VOS_ASSERT(0);
2471 goto exit;
2472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2474 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2475 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2476 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2477 break;
2478
2479 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002480 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302481 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 }
2483 genie += eLen;
2484 remLen -= eLen;
2485 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302486
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302487exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002489 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302490 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002491}
2492
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302493static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 struct iw_request_info *info,
2495 union iwreq_data *wrqu,
2496 char *extra)
2497{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302498 int ret;
2499
2500 vos_ssr_protect(__func__);
2501 ret = __iw_set_genie(dev, info, wrqu, extra);
2502 vos_ssr_unprotect(__func__);
2503
2504 return ret;
2505}
2506
2507static int __iw_get_genie(struct net_device *dev,
2508 struct iw_request_info *info,
2509 union iwreq_data *wrqu,
2510 char *extra)
2511{
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302513 hdd_context_t *pHddCtx;
2514 hdd_adapter_t *pAdapter;
2515 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 eHalStatus status;
2517 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2518 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2519
2520 ENTER();
2521
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302522 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2523 if (NULL == pAdapter)
2524 {
2525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2526 "%s: Adapter is NULL",__func__);
2527 return -EINVAL;
2528 }
2529 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2530 status = wlan_hdd_validate_context(pHddCtx);
2531 if (0 != status)
2532 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302533 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 }
2535
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302537 if (NULL == pWextState)
2538 {
2539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2540 "%s: pWextState is NULL",__func__);
2541 return -EINVAL;
2542 }
2543
2544 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2545 if (NULL == pHddStaCtx)
2546 {
2547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2548 "%s: STA Context is NULL",__func__);
2549 return -EINVAL;
2550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002551
2552 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2553 {
2554 return -ENXIO;
2555 }
2556
2557 // Return something ONLY if we are associated with an RSN or WPA network
2558 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2559 pWextState->roamProfile.negotiatedAuthType))
2560 {
2561 return -ENXIO;
2562 }
2563
2564 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2565 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2566 pAdapter->sessionId,
2567 &length,
2568 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002569 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2570 if (wrqu->data.length < length)
2571 {
2572 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2573 return -EFAULT;
2574 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002575 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002576 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577
Arif Hussain6d2a3322013-11-17 19:50:10 -08002578 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002579
2580 EXIT();
2581
2582 return 0;
2583}
2584
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302585static int iw_get_genie(struct net_device *dev,
2586 struct iw_request_info *info,
2587 union iwreq_data *wrqu,
2588 char *extra)
2589{
2590 int ret;
2591
2592 vos_ssr_protect(__func__);
2593 ret = __iw_get_genie(dev, info, wrqu, extra);
2594 vos_ssr_unprotect(__func__);
2595
2596 return ret;
2597}
2598
2599
2600static int __iw_get_encode(struct net_device *dev,
2601 struct iw_request_info *info,
2602 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002603{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302604 hdd_adapter_t *pAdapter;
2605 hdd_context_t *pHddCtx;
2606 hdd_wext_state_t *pWextState;
2607 tCsrRoamProfile *pRoamProfile;
2608 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
2611 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302612 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2613 if (NULL == pAdapter)
2614 {
2615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2616 "%s: Adapter is NULL",__func__);
2617 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 }
2619
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2621 ret = wlan_hdd_validate_context(pHddCtx);
2622 if (0 != ret)
2623 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302624 return ret;
2625 }
2626 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2627 if (NULL == pWextState)
2628 {
2629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2630 "%s: pWextState is NULL",__func__);
2631 return -EINVAL;
2632 }
2633
2634 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 keyId = pRoamProfile->Keys.defaultIndex;
2636
2637 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2638 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002639 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 return -EINVAL;
2641 }
2642
2643 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2644 {
2645 dwrq->flags |= IW_ENCODE_ENABLED;
2646 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2647 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2648
2649 dwrq->flags |= (keyId + 1);
2650
2651 }
2652 else
2653 {
2654 dwrq->flags |= IW_ENCODE_DISABLED;
2655 }
2656
2657 for(i=0; i < MAX_WEP_KEYS; i++)
2658 {
2659 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2660 {
2661 continue;
2662 }
2663 else
2664 {
2665 break;
2666 }
2667 }
2668
2669 if(MAX_WEP_KEYS == i)
2670 {
2671 dwrq->flags |= IW_ENCODE_NOKEY;
2672 }
2673
2674 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2675
2676 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2677 {
2678 dwrq->flags |= IW_ENCODE_OPEN;
2679 }
2680 else
2681 {
2682 dwrq->flags |= IW_ENCODE_RESTRICTED;
2683 }
2684 EXIT();
2685 return 0;
2686}
2687
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302688static int iw_get_encode(struct net_device *dev,
2689 struct iw_request_info *info,
2690 struct iw_point *dwrq, char *extra)
2691{
2692 int ret;
2693
2694 vos_ssr_protect(__func__);
2695 ret = __iw_get_encode(dev, info, dwrq, extra);
2696 vos_ssr_unprotect(__func__);
2697
2698 return ret;
2699}
2700
Jeff Johnson295189b2012-06-20 16:38:30 -07002701#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2702#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2703
2704
2705/*
2706 * This function sends a single 'key' to LIM at all time.
2707 */
2708
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302709static int __iw_get_rts_threshold(struct net_device *dev,
2710 struct iw_request_info *info,
2711 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002712{
2713 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2714 v_U32_t status = 0;
2715
2716 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2717
2718 return status;
2719}
2720
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302721static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 struct iw_request_info *info,
2723 union iwreq_data *wrqu, char *extra)
2724{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302725 int ret;
2726
2727 vos_ssr_protect(__func__);
2728 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2729 vos_ssr_unprotect(__func__);
2730
2731 return ret;
2732}
2733
2734static int __iw_set_rts_threshold(struct net_device *dev,
2735 struct iw_request_info *info,
2736 union iwreq_data *wrqu, char *extra)
2737{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302738 hdd_adapter_t *pAdapter;
2739 hdd_context_t *pHddCtx;
2740 tHalHandle hHal;
2741 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742
2743 ENTER();
2744
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302745 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2746 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002747 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2749 "%s: Adapter is NULL",__func__);
2750 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002751 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302752
2753 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2754 ret = wlan_hdd_validate_context(pHddCtx);
2755 if (0 != ret)
2756 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302757 return ret;
2758 }
2759
2760 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2761 if (NULL == hHal)
2762 {
2763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2764 "%s: Hal Context is NULL",__func__);
2765 return -EINVAL;
2766 }
2767
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2769 {
2770 return -EINVAL;
2771 }
2772
2773 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2774 {
c_hpothub8245442013-11-20 23:41:09 +05302775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2776 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 return -EIO;
2778 }
2779
2780 EXIT();
2781
2782 return 0;
2783}
2784
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302785static int iw_set_rts_threshold(struct net_device *dev,
2786 struct iw_request_info *info,
2787 union iwreq_data *wrqu, char *extra)
2788{
2789 int ret;
2790
2791 vos_ssr_protect(__func__);
2792 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2793 vos_ssr_unprotect(__func__);
2794
2795 return ret;
2796}
2797
2798static int __iw_get_frag_threshold(struct net_device *dev,
2799 struct iw_request_info *info,
2800 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002801{
2802 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2803 v_U32_t status = 0;
2804
2805 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2806
2807 return status;
2808}
2809
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302810static int iw_get_frag_threshold(struct net_device *dev,
2811 struct iw_request_info *info,
2812 union iwreq_data *wrqu, char *extra)
2813{
2814 int ret;
2815
2816 vos_ssr_protect(__func__);
2817 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2818 vos_ssr_unprotect(__func__);
2819
2820 return ret;
2821}
2822
2823static int __iw_set_frag_threshold(struct net_device *dev,
2824 struct iw_request_info *info,
2825 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002826{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302827 hdd_adapter_t *pAdapter;
2828 hdd_context_t *pHddCtx;
2829 tHalHandle hHal;
2830 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002831
2832 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302833 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2834 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002835 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2837 "%s: Adapter is NULL",__func__);
2838 return -EINVAL;
2839 }
2840
2841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2842 ret = wlan_hdd_validate_context(pHddCtx);
2843 if (0 != ret)
2844 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302845 return ret;
2846 }
2847
2848 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2849 if (NULL == hHal)
2850 {
2851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2852 "%s: Hal Context is NULL",__func__);
2853 return -EINVAL;
2854 }
2855
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2857 {
2858 return -EINVAL;
2859 }
2860
2861 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2862 {
c_hpothub8245442013-11-20 23:41:09 +05302863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2864 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 return -EIO;
2866 }
2867
2868 EXIT();
2869
2870 return 0;
2871}
2872
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302873static int iw_set_frag_threshold(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_set_frag_threshold(dev, info, wrqu, extra);
2881 vos_ssr_unprotect(__func__);
2882
2883 return ret;
2884}
2885
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302886static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 struct iw_request_info *info,
2888 union iwreq_data *wrqu, char *extra)
2889{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302890 hdd_adapter_t *pAdapter;
2891 hdd_context_t *pHddCtx;
2892 int ret = 0;
2893
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302895 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2896 if (NULL == pAdapter)
2897 {
2898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2899 "%s: Adapter is NULL",__func__);
2900 return -EINVAL;
2901 }
2902 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2903 ret = wlan_hdd_validate_context(pHddCtx);
2904 if (0 != ret)
2905 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302906 return ret;
2907 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302908
2909 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 return -EOPNOTSUPP;
2911}
2912
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302913static int iw_get_power_mode(struct net_device *dev,
2914 struct iw_request_info *info,
2915 union iwreq_data *wrqu, char *extra)
2916{
2917 int ret;
2918
2919 vos_ssr_protect(__func__);
2920 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2921 vos_ssr_unprotect(__func__);
2922
2923 return ret;
2924}
2925static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 struct iw_request_info *info,
2927 union iwreq_data *wrqu, char *extra)
2928{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 hdd_adapter_t *pAdapter;
2930 hdd_context_t *pHddCtx;
2931 int ret = 0;
2932
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302934 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2935 if (NULL == pAdapter)
2936 {
2937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2938 "%s: Adapter is NULL",__func__);
2939 return -EINVAL;
2940 }
2941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2942 ret = wlan_hdd_validate_context(pHddCtx);
2943 if (0 != ret)
2944 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302945 return ret;
2946 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302947
2948 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 return -EOPNOTSUPP;
2950}
2951
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302952static int iw_set_power_mode(struct net_device *dev,
2953 struct iw_request_info *info,
2954 union iwreq_data *wrqu, char *extra)
2955{
2956 int ret;
2957
2958 vos_ssr_protect(__func__);
2959 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2960 vos_ssr_unprotect(__func__);
2961
2962 return ret;
2963}
2964
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302965static int __iw_get_range(struct net_device *dev,
2966 struct iw_request_info *info,
2967 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002968{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302969 hdd_adapter_t *pAdapter;
2970 tHalHandle hHal;
2971 hdd_context_t *pHddCtx;
2972 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 struct iw_range *range = (struct iw_range *) extra;
2974
2975 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2976
2977 v_U32_t num_channels = sizeof(channels);
2978 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2979 v_U32_t a_len;
2980 v_U32_t b_len;
2981 v_U32_t active_phy_mode = 0;
2982 v_U8_t index = 0, i;
2983
2984 ENTER();
2985
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302986 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2987 if (NULL == pAdapter)
2988 {
2989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2990 "%s: pAdapter is NULL", __func__);
2991 return -EINVAL;
2992 }
2993 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2994 ret = wlan_hdd_validate_context(pHddCtx);
2995 if (0 != ret)
2996 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302997 return ret;
2998 }
2999 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3000 if (NULL == hHal)
3001 {
3002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3003 "%s: pAdapter is NULL", __func__);
3004 return -EINVAL;
3005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 wrqu->data.length = sizeof(struct iw_range);
3007 memset(range, 0, sizeof(struct iw_range));
3008
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 /*Get the phy mode*/
3010 if (ccmCfgGetInt(hHal,
3011 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3012 {
3013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003014 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003015
3016 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3017 {
3018 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003019 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 if (ccmCfgGetStr(hHal,
3021 WNI_CFG_SUPPORTED_RATES_11A,
3022 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3023 {
3024 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3025 {
3026 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3027 }
3028 for (i = 0; i < a_len; i++)
3029 {
3030 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3031 }
3032 range->num_bitrates = a_len;
3033 }
3034 else
3035 {
3036 return -EIO;
3037 }
3038 }
3039 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3040 {
3041 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003042 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 if (ccmCfgGetStr(hHal,
3044 WNI_CFG_SUPPORTED_RATES_11B,
3045 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3046 {
3047 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3048 {
3049 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3050 }
3051 for (i = 0; i < b_len; i++)
3052 {
3053 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3054 }
3055 range->num_bitrates = b_len;
3056 }
3057 else
3058 {
3059 return -EIO;
3060 }
3061 }
3062 }
3063
3064 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3065 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3066 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3067
3068 range->encoding_size[0] = 5;
3069 range->encoding_size[1] = 13;
3070 range->num_encoding_sizes = 2;
3071 range->max_encoding_tokens = MAX_WEP_KEYS;
3072
3073 // we support through Wireless Extensions 22
3074 range->we_version_compiled = WIRELESS_EXT;
3075 range->we_version_source = 22;
3076
3077 /*Supported Channels and Frequencies*/
3078 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3079 {
c_hpothub8245442013-11-20 23:41:09 +05303080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3081 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 return -EIO;
3083 }
3084 if (num_channels > IW_MAX_FREQUENCIES)
3085 {
3086 num_channels = IW_MAX_FREQUENCIES;
3087 }
3088
3089 range->num_channels = num_channels;
3090 range->num_frequency = num_channels;
3091
3092 for (index=0; index < num_channels; index++)
3093 {
3094 v_U32_t frq_indx = 0;
3095
3096 range->freq[index].i = channels[index];
3097 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3098 {
3099 if(channels[index] == freq_chan_map[frq_indx].chan)
3100 {
3101 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3102 range->freq[index].e = 1;
3103 break;
3104 }
3105 frq_indx++;
3106 }
3107 }
3108
3109 /* Event capability (kernel + driver) */
3110 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3111 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3112 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3113 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3114
3115 /*Encryption capability*/
3116 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3117 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3118
3119 /* Txpower capability */
3120 range->txpower_capa = IW_TXPOW_MWATT;
3121
3122 /*Scanning capability*/
3123 #if WIRELESS_EXT >= 22
3124 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3125 #endif
3126
3127 EXIT();
3128 return 0;
3129}
3130
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303131static int iw_get_range(struct net_device *dev,
3132 struct iw_request_info *info,
3133 union iwreq_data *wrqu, char *extra)
3134{
3135 int ret;
3136
3137 vos_ssr_protect(__func__);
3138 ret = __iw_get_range(dev, info, wrqu, extra);
3139 vos_ssr_unprotect(__func__);
3140
3141 return ret;
3142}
3143
Jeff Johnson295189b2012-06-20 16:38:30 -07003144/* Callback function registered with PMC to know status of PMC request */
3145static void iw_power_callback_fn (void *pContext, eHalStatus status)
3146{
3147 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003148
3149 if (NULL == pContext)
3150 {
3151 hddLog(VOS_TRACE_LEVEL_ERROR,
3152 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003153 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 return;
3155 }
3156
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003158
Jeff Johnson72a40512013-12-19 10:14:15 -08003159 /* there is a race condition that exists between this callback
3160 function and the caller since the caller could time out either
3161 before or while this code is executing. we use a spinlock to
3162 serialize these actions */
3163 spin_lock(&hdd_context_lock);
3164
3165 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 {
3167 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003168 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003170 "%s: Invalid context, magic [%08x]",
3171 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003172
3173 if (ioctl_debug)
3174 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003175 pr_info("%s: Invalid context, magic [%08x]\n",
3176 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 }
3178 return;
3179 }
3180
Jeff Johnson72a40512013-12-19 10:14:15 -08003181 /* context is valid so caller is still waiting */
3182
3183 /* paranoia: invalidate the magic */
3184 pStatsContext->magic = 0;
3185
3186 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003188
3189 /* serialization is complete */
3190 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003191}
3192
3193/* Callback function for tx per hit */
3194void hdd_tx_per_hit_cb (void *pCallbackContext)
3195{
3196 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3197 unsigned char tx_fail[16];
3198 union iwreq_data wrqu;
3199
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303200 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003202 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 return;
3204 }
3205 memset(&wrqu, 0, sizeof(wrqu));
3206 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3207 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3208}
3209
3210void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3211{
3212 struct statsContext *pStatsContext;
3213 tCsrGlobalClassAStatsInfo *pClassAStats;
3214 hdd_adapter_t *pAdapter;
3215
3216 if (ioctl_debug)
3217 {
3218 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003219 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 }
3221
3222 if ((NULL == pStats) || (NULL == pContext))
3223 {
3224 hddLog(VOS_TRACE_LEVEL_ERROR,
3225 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003226 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 return;
3228 }
3229
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 pClassAStats = pStats;
3231 pStatsContext = pContext;
3232 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003233
3234 /* there is a race condition that exists between this callback
3235 function and the caller since the caller could time out either
3236 before or while this code is executing. we use a spinlock to
3237 serialize these actions */
3238 spin_lock(&hdd_context_lock);
3239
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3241 {
3242 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003243 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 hddLog(VOS_TRACE_LEVEL_WARN,
3245 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003246 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 if (ioctl_debug)
3248 {
3249 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003250 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 }
3252 return;
3253 }
3254
Jeff Johnson72a40512013-12-19 10:14:15 -08003255 /* context is valid so caller is still waiting */
3256
3257 /* paranoia: invalidate the magic */
3258 pStatsContext->magic = 0;
3259
3260 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3262
Jeff Johnson72a40512013-12-19 10:14:15 -08003263 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003265
3266 /* serialization is complete */
3267 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003268}
3269
3270VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3271{
3272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3273 eHalStatus hstatus;
3274 long lrc;
3275 struct statsContext context;
3276
3277 if (NULL == pAdapter)
3278 {
3279 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3280 return VOS_STATUS_E_FAULT;
3281 }
3282 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3283 {
3284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3285 return VOS_STATUS_SUCCESS;
3286 }
3287
3288 /* we are connected
3289 prepare our callback context */
3290 init_completion(&context.completion);
3291 context.pAdapter = pAdapter;
3292 context.magic = STATS_CONTEXT_MAGIC;
3293 /* query only for Class A statistics (which include link speed) */
3294 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3295 eCSR_HDD,
3296 SME_GLOBAL_CLASSA_STATS,
3297 hdd_GetClassA_statisticsCB,
3298 0, // not periodic
3299 FALSE, //non-cached results
3300 pHddStaCtx->conn_info.staId[0],
3301 &context);
3302 if (eHAL_STATUS_SUCCESS != hstatus)
3303 {
3304 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003305 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003306 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 /* we'll returned a cached value below */
3308 }
3309 else
3310 {
3311 /* request was sent -- wait for the response */
3312 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3313 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 if (lrc <= 0)
3315 {
3316 hddLog(VOS_TRACE_LEVEL_ERROR,
3317 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003318 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 }
3320 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003321
3322 /* either we never sent a request, we sent a request and received a
3323 response or we sent a request and timed out. if we never sent a
3324 request or if we sent a request and got a response, we want to
3325 clear the magic out of paranoia. if we timed out there is a
3326 race condition such that the callback function could be
3327 executing at the same time we are. of primary concern is if the
3328 callback function had already verified the "magic" but had not
3329 yet set the completion variable when a timeout occurred. we
3330 serialize these activities by invalidating the magic while
3331 holding a shared spinlock which will cause us to block if the
3332 callback is currently executing */
3333 spin_lock(&hdd_context_lock);
3334 context.magic = 0;
3335 spin_unlock(&hdd_context_lock);
3336
3337 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 return VOS_STATUS_SUCCESS;
3339}
3340
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003341static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3342{
3343 struct statsContext *pStatsContext;
3344 tCsrSummaryStatsInfo *pSummaryStats;
3345 tCsrGlobalClassAStatsInfo *pClassAStats;
3346 hdd_adapter_t *pAdapter;
3347
3348 if (ioctl_debug)
3349 {
3350 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003351 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003352 }
3353
3354 if ((NULL == pStats) || (NULL == pContext))
3355 {
3356 hddLog(VOS_TRACE_LEVEL_ERROR,
3357 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003358 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003359 return;
3360 }
3361
Jeff Johnson72a40512013-12-19 10:14:15 -08003362 /* there is a race condition that exists between this callback
3363 function and the caller since the caller could time out either
3364 before or while this code is executing. we use a spinlock to
3365 serialize these actions */
3366 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003367
3368 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3369 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3370 pStatsContext = pContext;
3371 pAdapter = pStatsContext->pAdapter;
3372 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3373 {
3374 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003375 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003376 hddLog(VOS_TRACE_LEVEL_WARN,
3377 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003378 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003379 if (ioctl_debug)
3380 {
3381 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003382 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003383 }
3384 return;
3385 }
3386
Jeff Johnson72a40512013-12-19 10:14:15 -08003387 /* context is valid so caller is still waiting */
3388
3389 /* paranoia: invalidate the magic */
3390 pStatsContext->magic = 0;
3391
3392 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003393 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3394 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3395
Jeff Johnson72a40512013-12-19 10:14:15 -08003396 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003397 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003398
3399 /* serialization is complete */
3400 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003401}
3402
3403VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3404{
3405 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3406 eHalStatus hstatus;
3407 long lrc;
3408 struct statsContext context;
3409
3410 if (NULL == pAdapter)
3411 {
3412 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3413 return VOS_STATUS_SUCCESS;
3414 }
3415
3416 /* we are connected
3417 prepare our callback context */
3418 init_completion(&context.completion);
3419 context.pAdapter = pAdapter;
3420 context.magic = STATS_CONTEXT_MAGIC;
3421
3422 /* query only for Summary & Class A statistics */
3423 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3424 eCSR_HDD,
3425 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303426 SME_GLOBAL_CLASSA_STATS |
3427 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003428 hdd_get_station_statisticsCB,
3429 0, // not periodic
3430 FALSE, //non-cached results
3431 pHddStaCtx->conn_info.staId[0],
3432 &context);
3433 if (eHAL_STATUS_SUCCESS != hstatus)
3434 {
3435 hddLog(VOS_TRACE_LEVEL_ERROR,
3436 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003437 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003438 /* we'll return with cached values */
3439 }
3440 else
3441 {
3442 /* request was sent -- wait for the response */
3443 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3444 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003445
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003446 if (lrc <= 0)
3447 {
3448 hddLog(VOS_TRACE_LEVEL_ERROR,
3449 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003450 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003451 }
3452 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003453
3454 /* either we never sent a request, we sent a request and received a
3455 response or we sent a request and timed out. if we never sent a
3456 request or if we sent a request and got a response, we want to
3457 clear the magic out of paranoia. if we timed out there is a
3458 race condition such that the callback function could be
3459 executing at the same time we are. of primary concern is if the
3460 callback function had already verified the "magic" but had not
3461 yet set the completion variable when a timeout occurred. we
3462 serialize these activities by invalidating the magic while
3463 holding a shared spinlock which will cause us to block if the
3464 callback is currently executing */
3465 spin_lock(&hdd_context_lock);
3466 context.magic = 0;
3467 spin_unlock(&hdd_context_lock);
3468
3469 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003470 return VOS_STATUS_SUCCESS;
3471}
3472
3473
Jeff Johnson295189b2012-06-20 16:38:30 -07003474/*
3475 * Support for the LINKSPEED private command
3476 * Per the WiFi framework the response must be of the form
3477 * "LinkSpeed xx"
3478 */
3479static int iw_get_linkspeed(struct net_device *dev,
3480 struct iw_request_info *info,
3481 union iwreq_data *wrqu, char *extra)
3482{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303483 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303484 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303486 int len = sizeof(v_U32_t) + 1;
3487 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303488 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303489 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303490 int rc, valid = 0;
3491
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303492 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303493 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3494 if (NULL == pAdapter)
3495 {
3496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3497 "%s: Adapter is NULL",__func__);
3498 return -EINVAL;
3499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003500
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303501 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303502 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303503 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003504 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303505 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003506 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303507 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3508 if (NULL == pHddStaCtx)
3509 {
3510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3511 "%s: STA Context is NULL",__func__);
3512 return -EINVAL;
3513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3515 {
3516 /* we are not connected so we don't have a classAstats */
3517 link_speed = 0;
3518 }
3519 else
3520 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303521 status = wlan_hdd_get_classAstats(pAdapter);
3522
3523 if (!VOS_IS_STATUS_SUCCESS(status ))
3524 {
3525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3526 return -EINVAL;
3527 }
3528
3529 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3530 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3531 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3532 &link_speed);
3533
3534 link_speed = link_speed / 10;
3535
3536 if (0 == link_speed)
3537 {
3538 /* The linkspeed returned by HAL is in units of 500kbps.
3539 * converting it to mbps.
3540 * This is required to support legacy firmware which does
3541 * not return link capacity.
3542 */
3543 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3544 }
3545
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 }
3547
3548 wrqu->data.length = len;
3549 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003550 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 if ((rc < 0) || (rc >= len))
3552 {
3553 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303554 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 return -EIO;
3556 }
3557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303558 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003560 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003561}
3562
Arif Hussain695279c2014-03-24 14:06:07 -07003563/*
3564 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3565 *
3566 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303567static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003568 struct iw_request_info *info,
3569 union iwreq_data *wrqu, char *extra)
3570{
3571 int rc;
3572
3573 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3574
3575 if (rc < 0)
3576 return rc;
3577
3578 /* a value is being successfully returned */
3579 return 0;
3580}
Jeff Johnson295189b2012-06-20 16:38:30 -07003581
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303582static int iw_get_linkspeed_priv(struct net_device *dev,
3583 struct iw_request_info *info,
3584 union iwreq_data *wrqu, char *extra)
3585{
3586 int ret;
3587
3588 vos_ssr_protect(__func__);
3589 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3590 vos_ssr_unprotect(__func__);
3591
3592 return ret;
3593}
3594
Jeff Johnson295189b2012-06-20 16:38:30 -07003595/*
3596 * Support for the RSSI & RSSI-APPROX private commands
3597 * Per the WiFi framework the response must be of the form
3598 * "<ssid> rssi <xx>"
3599 * unless we are not associated, in which case the response is
3600 * "OK"
3601 */
3602static int iw_get_rssi(struct net_device *dev,
3603 struct iw_request_info *info,
3604 union iwreq_data *wrqu, char *extra)
3605{
3606 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003607 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 int len = wrqu->data.length;
3609 v_S7_t s7Rssi = 0;
3610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3611 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3612 VOS_STATUS vosStatus;
3613 int rc;
3614
3615 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3616 (0 == ssidlen) || (ssidlen >= len))
3617 {
3618 /* we are not connected or our SSID is too long
3619 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003620 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 }
3622 else
3623 {
3624 /* we are connected with a valid SSID
3625 so we can write the SSID into the return buffer
3626 (note that it is not NUL-terminated) */
3627 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3628
3629 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3630
3631 if (VOS_STATUS_SUCCESS == vosStatus)
3632 {
3633 /* append the rssi to the ssid in the format required by
3634 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003635 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303636 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 }
3638 else
3639 {
3640 rc = -1;
3641 }
3642 }
3643
3644 /* verify that we wrote a valid response */
3645 if ((rc < 0) || (rc >= len))
3646 {
3647 // encoding or length error?
3648 hddLog(VOS_TRACE_LEVEL_ERROR,
3649 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003650 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 return -EIO;
3652 }
3653
3654 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003655 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003656}
3657
3658/*
3659 * Support for SoftAP channel range private command
3660 */
3661static int iw_softap_set_channel_range( struct net_device *dev,
3662 int startChannel,
3663 int endChannel,
3664 int band)
3665{
Jeff Johnson43971f52012-07-17 12:26:56 -07003666 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 int ret = 0;
3668 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3669 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003670 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3671
Jeff Johnson295189b2012-06-20 16:38:30 -07003672
3673 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3674 if (VOS_STATUS_SUCCESS != status)
3675 {
3676 ret = -EINVAL;
3677 }
Yathish9f22e662012-12-10 14:21:35 -08003678 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 return ret;
3680}
3681
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303682static uint8 chartohex(char c)
3683{
3684 uint8 val = 0;
3685 if (c >= '0' && c <= '9')
3686 val = c - '0';
3687 else if (c >= 'a' && c <= 'f')
3688 val = c - 'a' + 10;
3689 else if (c >= 'A' && c <= 'F')
3690 val = c - 'A' + 10;
3691 else
3692 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3693
3694 return val;
3695}
3696
3697uint8 getByte(char **buf)
3698{
3699 uint8 byte = 0;
3700 char *temp = *buf;
3701 byte = chartohex(*temp) * 16;
3702 temp++;
3703 byte += chartohex(*temp);
3704 temp++;
3705 *buf = temp;
3706 return byte;
3707}
3708
3709static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3710{
3711 tSir80211Header *macHeader;
3712 int i = 0, j = 0, length = 0;
3713 uint8 byte = 0;
3714 char *temp = pBuffer;
3715 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303716 char *pHeader;
3717 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303718
3719 macHeader = &pkt->macHeader;
3720
3721 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3722
3723 temp++;
3724
3725 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3726 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3727 pkt->encParams.keyParams.key[0].keyId);
3728
3729 for (i = 0; i< 16; i++) {
3730 pkt->encParams.keyParams.key[0].key[i]
3731 = getByte(&temp);
3732 }
3733
3734 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3735 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3736
3737 for (i = 0; i< 6; i++) {
3738 pkt->encParams.pn[i]
3739 = getByte(&temp);
3740 }
3741
3742 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3743 &pkt->encParams.pn[0], 6, 0);
3744
3745 for (i = 0, j= 5; i< 3; i++, j--) {
3746 byte = pkt->encParams.pn[i];
3747 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3748 pkt->encParams.pn[j] = byte;
3749 }
3750
3751 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303752 if (length > sizeof(tSir80211Header))
3753 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303754
Srinivas Dasari2382de62015-01-22 15:00:04 +05303755 pHeader = temp;
3756 vos_mem_zero(&header, sizeof(tSir80211Header));
3757 for (i = 0; i < length; i++) {
3758 *((uint8 *)&header + i) = getByte(&pHeader);
3759 }
3760
3761 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3762 (char *)&header, length, 0);
3763
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303764 byte = getByte(&temp);
3765
3766 macHeader->frameCtrl.protVer = byte & 0x3;
3767 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3768 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3769
3770 byte = getByte(&temp);
3771 macHeader->frameCtrl.toDS = (byte) & 0x1;
3772 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3773 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3774 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3775 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3776 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3777 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3778 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3779
3780 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3781 "macHeader->frameCtrl.type : %x "
3782 "macHeader->frameCtrl.subType : %x "
3783 "macHeader->frameCtrl.toDS : %x "
3784 "macHeader->frameCtrl.fromDS : %x "
3785 "macHeader->frameCtrl.moreFrag : %x "
3786 "macHeader->frameCtrl.retry : %x "
3787 "macHeader->frameCtrl.powerMgmt : %x "
3788 "macHeader->frameCtrl.MoreData : %x "
3789 "macHeader->frameCtrl.wep : %x "
3790 "macHeader->frameCtrl.order : %x "
3791 , macHeader->frameCtrl.protVer
3792 , macHeader->frameCtrl.type
3793 , macHeader->frameCtrl.subType
3794 , macHeader->frameCtrl.toDS
3795 , macHeader->frameCtrl.fromDS
3796 , macHeader->frameCtrl.moreFrag
3797 , macHeader->frameCtrl.retry
3798 , macHeader->frameCtrl.powerMgmt
3799 , macHeader->frameCtrl.moreData
3800 , macHeader->frameCtrl.wep
3801 , macHeader->frameCtrl.order);
3802
3803
3804 macHeader->usDurationId = getByte(&temp);
3805 macHeader->usDurationId += getByte(&temp) << 8;
3806
3807 macHeader->vA1[0] = getByte(&temp);
3808 macHeader->vA1[1] = getByte(&temp);
3809 macHeader->vA1[2] = getByte(&temp);
3810 macHeader->vA1[3] = getByte(&temp);
3811 macHeader->vA1[4] = getByte(&temp);
3812 macHeader->vA1[5] = getByte(&temp);
3813
3814 macHeader->vA2[0] = getByte(&temp);
3815 macHeader->vA2[1] = getByte(&temp);
3816 macHeader->vA2[2] = getByte(&temp);
3817 macHeader->vA2[3] = getByte(&temp);
3818 macHeader->vA2[4] = getByte(&temp);
3819 macHeader->vA2[5] = getByte(&temp);
3820
3821 macHeader->vA3[0] = getByte(&temp);
3822 macHeader->vA3[1] = getByte(&temp);
3823 macHeader->vA3[2] = getByte(&temp);
3824 macHeader->vA3[3] = getByte(&temp);
3825 macHeader->vA3[4] = getByte(&temp);
3826 macHeader->vA3[5] = getByte(&temp);
3827
3828 macHeader->sSeqCtrl = getByte(&temp);
3829 fragNum = macHeader->sSeqCtrl & 0xF;
3830 macHeader->sSeqCtrl >>= 4;
3831
3832 macHeader->sSeqCtrl += getByte(&temp) << 4;
3833
3834 macHeader->sSeqCtrl |= fragNum << 12;
3835
3836 if (length == 30 || length == 32) {
3837 macHeader->optvA4[0] = getByte(&temp);
3838 macHeader->optvA4[1] = getByte(&temp);
3839 macHeader->optvA4[2] = getByte(&temp);
3840 macHeader->optvA4[3] = getByte(&temp);
3841 macHeader->optvA4[4] = getByte(&temp);
3842 macHeader->optvA4[5] = getByte(&temp);
3843 }
3844
3845 if (length == 26 || length == 32) {
3846 macHeader->usQosCtrl = getByte(&temp);
3847 macHeader->usQosCtrl += getByte(&temp) << 8;
3848 }
3849
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303850 //parse payload
3851 length = getByte(&temp);
3852 length += getByte(&temp) << 8;
3853 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3854
3855 pkt->data.length = length;
3856
3857 for (i = 0; i< length; i++) {
3858 pkt->data.data[i] = getByte(&temp);
3859 }
3860
3861 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3862 &pkt->data.data[0], pkt->data.length, 0);
3863}
3864
3865/**---------------------------------------------------------------------------
3866
3867 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3868 encrypt message request
3869 This is an asynchronous callback function from SME when the encrypted data
3870 is received
3871
3872 \pEncInfoRsp -> Encrypted data info
3873
3874 \return - 0 for success non-zero for failure
3875 --------------------------------------------------------------------------*/
3876static void
3877hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3878{
3879 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3880
3881 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3882
3883 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3884 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3885 pEncryptedDataRsp->encryptedPayload.length);
3886 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3887 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3888 pEncryptedDataRsp->encryptedPayload.data,
3889 pEncryptedDataRsp->encryptedPayload.length, 0);
3890}
3891
Jeff Johnson295189b2012-06-20 16:38:30 -07003892VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3893{
3894 struct statsContext context;
3895 eHalStatus status;
3896 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303897 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003898
3899 if (NULL == pAdapter)
3900 {
3901 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3902 return VOS_STATUS_E_FAULT;
3903 }
3904
3905 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3906 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303907 if (pHddCtx->isLogpInProgress) {
3908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3909 "%s:LOGP in Progress. Ignore!!!", __func__);
3910 return VOS_STATUS_E_FAILURE;
3911 }
3912
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 init_completion(&context.completion);
3914
3915 context.pAdapter = pAdapter;
3916 context.magic = POWER_CONTEXT_MAGIC;
3917
3918 if (DRIVER_POWER_MODE_ACTIVE == mode)
3919 {
3920 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3921 "Full Power", __func__);
3922 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3923 iw_power_callback_fn, &context,
3924 eSME_FULL_PWR_NEEDED_BY_HDD);
3925 // Enter Full power command received from GUI this means we are disconnected
3926 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3927 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3928 if (eHAL_STATUS_PMC_PENDING == status)
3929 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003930 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 int lrc = wait_for_completion_interruptible_timeout(
3932 &context.completion,
3933 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003934
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 if (lrc <= 0)
3936 {
3937 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003938 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 }
3940 }
3941 }
3942 else if (DRIVER_POWER_MODE_AUTO == mode)
3943 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303944 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3945 * was already in BMPS state and thus either STA or P2P-CLI is in
3946 * associated state and authenticated, so even if STA connState is
3947 * not associated it can be assumed that P2P-CLI is associated and
3948 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3949 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3950 * if all condition are satisfied for entering BMPS.
3951 */
3952 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3953 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303954 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303955 hddLog(LOGE,
3956 FL("Station is associated but, still not Authenticated ignore "
3957 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303958 return VOS_STATUS_E_AGAIN;
3959 }
3960
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3962 {
3963 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3964 __func__);
3965 // Enter BMPS command received from GUI this means DHCP is completed
3966 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3967 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3968 FALSE);
3969 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3970 iw_power_callback_fn, &context);
3971 if (eHAL_STATUS_PMC_PENDING == status)
3972 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003973 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 int lrc = wait_for_completion_interruptible_timeout(
3975 &context.completion,
3976 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 if (lrc <= 0)
3978 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003979 hddLog(VOS_TRACE_LEVEL_ERROR,
3980 "%s: SME %s while requesting BMPS",
3981 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 }
3983 }
3984 }
3985 else
3986 {
3987 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3988 "enabled in the cfg");
3989 }
3990 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003991
3992 /* either we never sent a request, we sent a request and received a
3993 response or we sent a request and timed out. if we never sent a
3994 request or if we sent a request and got a response, we want to
3995 clear the magic out of paranoia. if we timed out there is a
3996 race condition such that the callback function could be
3997 executing at the same time we are. of primary concern is if the
3998 callback function had already verified the "magic" but had not
3999 yet set the completion variable when a timeout occurred. we
4000 serialize these activities by invalidating the magic while
4001 holding a shared spinlock which will cause us to block if the
4002 callback is currently executing */
4003 spin_lock(&hdd_context_lock);
4004 context.magic = 0;
4005 spin_unlock(&hdd_context_lock);
4006
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 return VOS_STATUS_SUCCESS;
4008}
4009
4010VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4011 hdd_adapter_t *pAdapter)
4012{
4013 VOS_STATUS vos_Status;
4014
4015 if ((NULL == pAdapter) || (NULL == pHddCtx))
4016 {
4017 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4018 return VOS_STATUS_E_FAULT;
4019 }
4020
4021 /**Exit from Deep sleep or standby if we get the driver
4022 START cmd from android GUI
4023 */
4024 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4025 {
4026 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4027 "from Stand by",__func__);
4028 vos_Status = hdd_exit_standby(pHddCtx);
4029 }
4030 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4031 {
4032 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4033 "from deep sleep",__func__);
4034 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4035 }
4036 else
4037 {
4038 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4039 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4040 vos_Status = VOS_STATUS_SUCCESS;
4041 }
4042
4043 return vos_Status;
4044}
4045
4046VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4047{
4048 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4049
4050 if (NULL == pHddCtx)
4051 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304052 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 return VOS_STATUS_E_FAULT;
4054 }
4055
4056 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4057 {
4058 //Execute standby procedure.
4059 //Executing standby procedure will cause the STA to
4060 //disassociate first and then the chip will be put into standby.
4061 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4062 vos_Status = hdd_enter_standby(pHddCtx);
4063 }
4064 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4065 pHddCtx->cfg_ini->nEnableDriverStop)
4066 {
4067 //Execute deep sleep procedure
4068 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004069 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 //Deep sleep not supported
4071 vos_Status = hdd_enter_standby(pHddCtx);
4072 }
4073 else
4074 {
4075 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4076 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4077 vos_Status = VOS_STATUS_SUCCESS;
4078 }
4079
4080 return vos_Status;
4081}
4082
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004083
4084void* wlan_hdd_change_country_code_callback(void *pAdapter)
4085{
4086
4087 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004088 complete(&call_back_pAdapter->change_country_code);
4089
4090 return NULL;
4091}
4092
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304093static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 struct iw_request_info *info,
4095 union iwreq_data *wrqu, char *extra)
4096{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304097 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004098 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304100 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004101 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4102
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304103 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304106
4107 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4108 if (NULL == pAdapter)
4109 {
4110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4111 "mem_alloc_copy_from_user_helper fail");
4112 return -EINVAL;
4113 }
4114 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4115 rc = wlan_hdd_validate_context(pHddCtx);
4116 if (0 != rc)
4117 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304118 return rc;
4119 }
4120
Arif Hussain24bfa702014-01-22 13:51:30 -08004121 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4122 wrqu->data.length);
4123 if (NULL == cmd)
4124 {
4125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4126 "mem_alloc_copy_from_user_helper fail");
4127 return -ENOMEM;
4128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004129
4130 if (ioctl_debug)
4131 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004132 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 }
4134
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004135 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4136 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137
Arif Hussain24bfa702014-01-22 13:51:30 -08004138 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004140 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4142 "%s: Error in iw_set_scan!", __func__);
4143 rc = -EINVAL;
4144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 }
4146 else if( strcasecmp(cmd, "start") == 0 ) {
4147
Arif Hussain6d2a3322013-11-17 19:50:10 -08004148 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004150
Arif Hussain24bfa702014-01-22 13:51:30 -08004151 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4152 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 {
4154 union iwreq_data wrqu;
4155 char buf[10];
4156
4157 memset(&wrqu, 0, sizeof(wrqu));
4158 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4159 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4160 }
4161 else
4162 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004163 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4164 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 }
4166 goto done;
4167 }
4168 else if( strcasecmp(cmd, "stop") == 0 )
4169 {
4170 union iwreq_data wrqu;
4171 char buf[10];
4172
Arif Hussain6d2a3322013-11-17 19:50:10 -08004173 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004174
4175 wlan_hdd_enter_lowpower(pHddCtx);
4176 memset(&wrqu, 0, sizeof(wrqu));
4177 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4178 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 goto done;
4180 }
4181 else if (strcasecmp(cmd, "macaddr") == 0)
4182 {
4183 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4184 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4185 }
4186 else if (strcasecmp(cmd, "scan-active") == 0)
4187 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304188 hddLog(VOS_TRACE_LEVEL_ERROR,
4189 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004190 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 ret = snprintf(cmd, cmd_len, "OK");
4192 }
4193 else if (strcasecmp(cmd, "scan-passive") == 0)
4194 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304195 hddLog(VOS_TRACE_LEVEL_ERROR,
4196 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004197 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 ret = snprintf(cmd, cmd_len, "OK");
4199 }
4200 else if( strcasecmp(cmd, "scan-mode") == 0 )
4201 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004202 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 }
4204 else if( strcasecmp(cmd, "linkspeed") == 0 )
4205 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004206 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 }
4208 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4209 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004210 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004211 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004212
4213 country_code = cmd + 8;
4214
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004215 init_completion(&pAdapter->change_country_code);
4216
Arif Hussain24bfa702014-01-22 13:51:30 -08004217 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004218 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 country_code,
4220 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304221 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304222 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304223 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004224
4225 /* Wait for completion */
4226 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4227 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4228
4229 if (lrc <= 0)
4230 {
4231 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004232 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004233 }
4234
Arif Hussain24bfa702014-01-22 13:51:30 -08004235 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004237 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004238 "%s: SME Change Country code fail", __func__);
4239 kfree(cmd);
4240 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 }
4242 }
4243 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4244 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004245 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 }
4247 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4248 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004249 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004250
Wilson Yang1be3e652013-10-09 15:18:31 -07004251 if (9 < cmd_len)
4252 {
4253 ptr = (char*)(cmd + 9);
4254
4255 }else{
4256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4257 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004258 kfree(cmd);
4259 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004260 }
4261
4262 if (1 != sscanf(ptr,"%d",&mode))
4263 {
4264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4265 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004266 kfree(cmd);
4267 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004268 }
4269
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 wlan_hdd_enter_bmps(pAdapter, mode);
4271 /*TODO:Set the power mode*/
4272 }
4273 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4274 v_U32_t pmc_state;
4275 v_U16_t value;
4276
4277 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4278 if(pmc_state == BMPS) {
4279 value = DRIVER_POWER_MODE_AUTO;
4280 }
4281 else {
4282 value = DRIVER_POWER_MODE_ACTIVE;
4283 }
4284 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4285 }
4286 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004287 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 /*TODO: set the btcoexmode*/
4289 }
4290 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4291
Arif Hussain6d2a3322013-11-17 19:50:10 -08004292 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 /*TODO: Return the btcoex status*/
4294 }
4295 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4296
Arif Hussain6d2a3322013-11-17 19:50:10 -08004297 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004298
4299 /*TODO: Enable Rx data Filter*/
4300 }
4301 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4302
Arif Hussain6d2a3322013-11-17 19:50:10 -08004303 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004304
4305 /*TODO: Disable Rx data Filter*/
4306 }
4307 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4308
Arif Hussain6d2a3322013-11-17 19:50:10 -08004309 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 /*TODO: rxfilter-statistics*/
4311 }
4312 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4313
Arif Hussain6d2a3322013-11-17 19:50:10 -08004314 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 /*TODO: rxfilter-add*/
4316 }
4317 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4318
Arif Hussain6d2a3322013-11-17 19:50:10 -08004319 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 /*TODO: rxfilter-remove*/
4321 }
4322#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004323 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4324 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4325 /*TODO: support pnosetup*/
4326 }
4327 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4328 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4329 /*TODO: support pnoforce*/
4330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4332
Arif Hussain6d2a3322013-11-17 19:50:10 -08004333 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004334 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4335 kfree(cmd);
4336 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 }
4338 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004339 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004340 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4341 kfree(cmd);
4342 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 }
4344#endif /*FEATURE_WLAN_SCAN_PNO*/
4345 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004346 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004347 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4348 kfree(cmd);
4349 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 }
4351 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4352 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004353 char *ptr;
4354
4355 if (18 < cmd_len)
4356 {
4357 ptr = (char*)(cmd + 18);
4358 }else{
4359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4360 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004361 kfree(cmd);
4362 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004363 }
4364
Jeff Johnson02797792013-10-26 19:17:13 -07004365 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004366 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4367 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4368 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4369 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4370 {
4371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4372 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004373 kfree(cmd);
4374 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004376
4377 // parameters checking
4378 // period has to be larger than 0
4379 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4380 {
4381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004382 kfree(cmd);
4383 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 }
4385
4386 // use default value 5 is the input is not reasonable. in unit of 10%
4387 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4388 {
4389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4390 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4391 }
4392
4393 // default is 5
4394 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4395 {
4396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4397 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4398 }
4399
Arif Hussain24bfa702014-01-22 13:51:30 -08004400 if (eHAL_STATUS_SUCCESS !=
4401 sme_SetTxPerTracking(pHddCtx->hHal,
4402 hdd_tx_per_hit_cb,
4403 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004405 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 }
4407 }
4408 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004409 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4410 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 }
4412done:
4413 /* many of the commands write information back into the command
4414 string using snprintf(). check the return value here in one
4415 place */
4416 if ((ret < 0) || (ret >= cmd_len))
4417 {
4418 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004419 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004421 else if (ret > 0)
4422 {
4423 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4424 {
4425 hddLog(VOS_TRACE_LEVEL_ERROR,
4426 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004427 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004428 return -EFAULT;
4429 }
4430 wrqu->data.length = ret;
4431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004432
4433 if (ioctl_debug)
4434 {
4435 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004436 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004438 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304439 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004440 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004441}
4442
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304443static int iw_set_priv(struct net_device *dev,
4444 struct iw_request_info *info,
4445 union iwreq_data *wrqu, char *extra)
4446{
4447 int ret;
4448 vos_ssr_protect(__func__);
4449 ret = __iw_set_priv(dev, info, wrqu, extra);
4450 vos_ssr_unprotect(__func__);
4451
4452 return ret;
4453}
4454
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304455static int __iw_set_nick(struct net_device *dev,
4456 struct iw_request_info *info,
4457 union iwreq_data *wrqu, char *extra)
4458{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459 hdd_adapter_t *pAdapter;
4460 hdd_context_t *pHddCtx;
4461 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304462
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304463 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304464
4465 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4466 if (NULL == pAdapter)
4467 {
4468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4469 "%s: Adapter is NULL",__func__);
4470 return -EINVAL;
4471 }
4472
4473 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4474 ret = wlan_hdd_validate_context(pHddCtx);
4475 if (0 != ret)
4476 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304477 return ret;
4478 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304479 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304480 return 0;
4481}
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483static int iw_set_nick(struct net_device *dev,
4484 struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
4486{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304487 int ret;
4488
4489 vos_ssr_protect(__func__);
4490 ret = __iw_set_nick(dev, info, wrqu, extra);
4491 vos_ssr_unprotect(__func__);
4492
4493 return ret;
4494}
4495
4496static int __iw_get_nick(struct net_device *dev,
4497 struct iw_request_info *info,
4498 union iwreq_data *wrqu, char *extra)
4499{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304500 hdd_adapter_t *pAdapter;
4501 hdd_context_t *pHddCtx;
4502 int ret = 0;
4503
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304505
4506 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4507 if (NULL == pAdapter)
4508 {
4509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4510 "%s: Adapter is NULL",__func__);
4511 return -EINVAL;
4512 }
4513
4514 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4515 ret = wlan_hdd_validate_context(pHddCtx);
4516 if (0 != ret)
4517 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304518 return ret;
4519 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304520 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 return 0;
4522}
4523
4524static int iw_get_nick(struct net_device *dev,
4525 struct iw_request_info *info,
4526 union iwreq_data *wrqu, char *extra)
4527{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304528 int ret;
4529
4530 vos_ssr_protect(__func__);
4531 ret = __iw_get_nick(dev, info, wrqu, extra);
4532 vos_ssr_unprotect(__func__);
4533
4534 return ret;
4535}
4536
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304537/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304538static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4539{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304540 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4541 hdd_context_t *pHddCtx;
4542 hdd_station_ctx_t *pHddStaCtx;
4543 v_S7_t snr = 0, rssi = 0;
4544 eHalStatus status = eHAL_STATUS_SUCCESS;
4545
4546 ENTER();
4547
4548 if (NULL == pAdapter)
4549 {
4550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4551 "%s: Adapter is NULL",__func__);
4552 return NULL;
4553 }
4554
4555 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4556 status = wlan_hdd_validate_context(pHddCtx);
4557 if (0 != status)
4558 {
4559 return NULL;
4560 }
4561
4562 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4563 if (NULL == pHddStaCtx)
4564 {
4565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4566 "%s: STA Context is NULL",__func__);
4567 return NULL;
4568 }
4569
4570 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4571 {
4572 wlan_hdd_get_station_stats(pAdapter);
4573 wlan_hdd_get_snr(pAdapter, &snr);
4574 wlan_hdd_get_rssi(pAdapter, &rssi);
4575
4576 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4577 pAdapter->iwStats.status = 0;
4578 pAdapter->iwStats.qual.qual = snr;
4579 pAdapter->iwStats.qual.level = rssi;
4580 pAdapter->iwStats.qual.noise = rssi - snr;
4581 pAdapter->iwStats.discard.code = 0;
4582 pAdapter->iwStats.discard.retries= 0;
4583 pAdapter->iwStats.miss.beacon = 0;
4584 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4585 }
4586 else
4587 {
4588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4589 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4590 return NULL;
4591 }
4592
4593 EXIT();
4594 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004595}
4596
4597static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4598{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304599
4600 struct iw_statistics *stats;
4601
4602 vos_ssr_protect(__func__);
4603 stats = __get_wireless_stats(dev);
4604 vos_ssr_unprotect(__func__);
4605
4606 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004607}
4608
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304609static int __iw_set_encode(struct net_device *dev,
4610 struct iw_request_info *info,
4611 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004612
4613{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304614 hdd_adapter_t *pAdapter;
4615 hdd_station_ctx_t *pHddStaCtx;
4616 hdd_wext_state_t *pWextState;
4617 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 struct iw_point *encoderq = &(wrqu->encoding);
4619 v_U32_t keyId;
4620 v_U8_t key_length;
4621 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4622 v_BOOL_t fKeyPresent = 0;
4623 int i;
4624 eHalStatus status = eHAL_STATUS_SUCCESS;
4625
4626
4627 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304628 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4629 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4632 "%s: Adapter is NULL",__func__);
4633 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 }
4635
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4637 status = wlan_hdd_validate_context(pHddCtx);
4638 if (0 != status)
4639 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304640 return status;
4641 }
4642 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4643 if (NULL == pWextState)
4644 {
4645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4646 "%s: pWextState is NULL ",__func__);
4647 return -EINVAL;
4648 }
4649 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4650 if (NULL == pHddStaCtx)
4651 {
4652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4653 "%s: STA Context is NULL",__func__);
4654 return -EINVAL;
4655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004656
4657 keyId = encoderq->flags & IW_ENCODE_INDEX;
4658
4659 if(keyId)
4660 {
4661 if(keyId > MAX_WEP_KEYS)
4662 {
4663 return -EINVAL;
4664 }
4665
4666 fKeyPresent = 1;
4667 keyId--;
4668 }
4669 else
4670 {
4671 fKeyPresent = 0;
4672 }
4673
4674
4675 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4676 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 if(!fKeyPresent) {
4679
4680 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4681
4682 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4683 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4684 }
4685 }
4686 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4687 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4688 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4689 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4690
4691 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4692 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4693
4694 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4695 {
4696 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4697 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004698 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304699 {
4700 long ret;
4701 ret = wait_for_completion_interruptible_timeout(
4702 &pAdapter->disconnect_comp_var,
4703 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4704 if (ret <= 0)
4705 hddLog(VOS_TRACE_LEVEL_ERROR,
4706 FL("failed wait on disconnect_comp_var %ld"), ret);
4707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 }
4709
4710 return status;
4711
4712 }
4713
4714 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4715 {
4716 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4717
4718 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4719
4720 }
4721
4722
4723 if(wrqu->data.length > 0)
4724 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004725 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004726
4727 key_length = wrqu->data.length;
4728
4729 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4730
4731 if(5 == key_length)
4732 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004733 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004734
4735 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4736 {
4737 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4738 }
4739 else
4740 {
4741 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4742 }
4743 }
4744 else if(13 == key_length)
4745 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004746 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004747
4748 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4749 {
4750 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4751 }
4752 else
4753 {
4754 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4755 }
4756 }
4757 else
4758 {
4759 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004760 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 return -EINVAL;
4762 }
4763
4764 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4765 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4766 pWextState->roamProfile.EncryptionType.numEntries = 1;
4767 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4768 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4769 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4770
4771 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4772 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4773 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4774 {
4775
4776 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4777
4778 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4779 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4780
4781 return status;
4782 }
4783 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304784 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 return 0;
4786}
4787
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304788static int iw_set_encode(struct net_device *dev,
4789 struct iw_request_info *info,
4790 union iwreq_data *wrqu,char *extra)
4791{
4792 int ret;
4793
4794 vos_ssr_protect(__func__);
4795 ret = __iw_set_encode(dev, info, wrqu, extra);
4796 vos_ssr_unprotect(__func__);
4797
4798 return ret;
4799}
4800
4801static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 struct iw_request_info *info,
4803 struct iw_point *dwrq,
4804 char *extra)
4805{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304806 hdd_adapter_t *pAdapter;
4807 hdd_wext_state_t *pWextState;
4808 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 int keyId;
4810 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4811 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304812 int i, ret = 0;
4813 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004814
4815 ENTER();
4816
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304817 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4818 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004819 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4821 "%s: Adapter is NULL",__func__);
4822 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004823 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304824 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4825 ret = wlan_hdd_validate_context(pHddCtx);
4826 if (0 != ret)
4827 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304828 return ret;
4829 }
4830 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4831 if (NULL == pWextState)
4832 {
4833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4834 "%s: pWextState is NULL",__func__);
4835 return -EINVAL;
4836 }
4837 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 keyId = pRoamProfile->Keys.defaultIndex;
4840
4841 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4842 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004843 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 return -EINVAL;
4845 }
4846
4847 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4848 {
4849 dwrq->flags |= IW_ENCODE_ENABLED;
4850 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304851 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4852 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 }
4854 else
4855 {
4856 dwrq->flags |= IW_ENCODE_DISABLED;
4857 }
4858
4859 for(i=0; i < MAX_WEP_KEYS; i++)
4860 {
4861 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4862 {
4863 continue;
4864 }
4865 else
4866 {
4867 break;
4868 }
4869 }
4870
4871 if(MAX_WEP_KEYS == i)
4872 {
4873 dwrq->flags |= IW_ENCODE_NOKEY;
4874 }
4875 else
4876 {
4877 dwrq->flags |= IW_ENCODE_ENABLED;
4878 }
4879
4880 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4881
4882 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4883 {
4884 dwrq->flags |= IW_ENCODE_DISABLED;
4885 }
4886
4887 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4888
4889 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4890 {
4891 dwrq->flags |= IW_ENCODE_OPEN;
4892 }
4893 else
4894 {
4895 dwrq->flags |= IW_ENCODE_RESTRICTED;
4896 }
4897 EXIT();
4898 return 0;
4899
4900}
4901
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304902static int iw_get_encodeext(struct net_device *dev,
4903 struct iw_request_info *info,
4904 struct iw_point *dwrq,
4905 char *extra)
4906{
4907 int ret;
4908 vos_ssr_protect(__func__);
4909 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4910 vos_ssr_unprotect(__func__);
4911
4912 return ret;
4913}
4914
4915static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 struct iw_request_info *info,
4917 union iwreq_data *wrqu, char *extra)
4918{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304919 hdd_adapter_t *pAdapter;
4920 hdd_station_ctx_t *pHddStaCtx;
4921 hdd_wext_state_t *pWextState;
4922 hdd_context_t *pHddCtx;
4923 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004924
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304925 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 v_U32_t status = 0;
4927
4928 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4929
4930 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4931
4932 int key_index;
4933 struct iw_point *encoding = &wrqu->encoding;
4934 tCsrRoamSetKey setKey;
4935 v_U32_t roamId= 0xFF;
4936 VOS_STATUS vos_status;
4937
4938 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304939 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4940 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4943 "%s: Adapter is NULL",__func__);
4944 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304946 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4947 status = wlan_hdd_validate_context(pHddCtx);
4948 if (0 != status)
4949 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304950 return status;
4951 }
4952 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4953 if (NULL == pHddStaCtx)
4954 {
4955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4956 "%s: STA Context is NULL",__func__);
4957 return -EINVAL;
4958 }
4959 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4960 if (NULL == pWextState)
4961 {
4962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4963 "%s: pWextState is NULL",__func__);
4964 return -EINVAL;
4965 }
4966 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 key_index = encoding->flags & IW_ENCODE_INDEX;
4968
4969 if(key_index > 0) {
4970
4971 /*Convert from 1-based to 0-based keying*/
4972 key_index--;
4973 }
4974 if(!ext->key_len) {
4975
4976 /*Set the encrytion type to NONE*/
4977 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4978 return status;
4979 }
4980
4981 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4982 (IW_ENCODE_ALG_WEP == ext->alg))
4983 {
4984 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4985
Agarwal Ashish971c2882013-10-30 20:11:12 +05304986 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4987 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 return -EINVAL;
4989 }
4990 else {
4991 /*Static wep, update the roam profile with the keys */
4992 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4993 key_index < CSR_MAX_NUM_KEY) {
4994 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4995 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4996
4997 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4998 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4999
5000 }
5001 }
5002 return status;
5003 }
5004
5005 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5006
5007 setKey.keyId = key_index;
5008 setKey.keyLength = ext->key_len;
5009
5010 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5011 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5012 }
5013
5014 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5015 /*Key direction for group is RX only*/
5016 setKey.keyDirection = eSIR_RX_ONLY;
5017 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5018 }
5019 else {
5020
5021 setKey.keyDirection = eSIR_TX_RX;
5022 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5023 }
5024
5025 /*For supplicant pae role is zero*/
5026 setKey.paeRole = 0;
5027
5028 switch(ext->alg)
5029 {
5030 case IW_ENCODE_ALG_NONE:
5031 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5032 break;
5033
5034 case IW_ENCODE_ALG_WEP:
5035 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5036 break;
5037
5038 case IW_ENCODE_ALG_TKIP:
5039 {
5040 v_U8_t *pKey = &setKey.Key[0];
5041
5042 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5043
5044 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5045
5046 /*Supplicant sends the 32bytes key in this order
5047
5048 |--------------|----------|----------|
5049 | Tk1 |TX-MIC | RX Mic |
5050 |--------------|----------|----------|
5051 <---16bytes---><--8bytes--><--8bytes-->
5052
5053 */
5054 /*Sme expects the 32 bytes key to be in the below order
5055
5056 |--------------|----------|----------|
5057 | Tk1 |RX-MIC | TX Mic |
5058 |--------------|----------|----------|
5059 <---16bytes---><--8bytes--><--8bytes-->
5060 */
5061 /* Copy the Temporal Key 1 (TK1) */
5062 vos_mem_copy(pKey,ext->key,16);
5063
5064 /*Copy the rx mic first*/
5065 vos_mem_copy(&pKey[16],&ext->key[24],8);
5066
5067 /*Copy the tx mic */
5068 vos_mem_copy(&pKey[24],&ext->key[16],8);
5069
5070 }
5071 break;
5072
5073 case IW_ENCODE_ALG_CCMP:
5074 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5075 break;
5076
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005077#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005078#define IW_ENCODE_ALG_KRK 6
5079 case IW_ENCODE_ALG_KRK:
5080 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5081 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005082#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005083
5084 default:
5085 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5086 break;
5087 }
5088
5089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005090 ("%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 -07005091
5092#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305093 /* The supplicant may attempt to set the PTK once pre-authentication
5094 is done. Save the key in the UMAC and include it in the ADD
5095 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305097 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305099 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5100 "%s: Update PreAuth Key success", __func__);
5101 return 0;
5102 }
5103 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5104 {
5105 hddLog(VOS_TRACE_LEVEL_ERROR,
5106 "%s: Update PreAuth Key failed", __func__);
5107 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 }
5109#endif /* WLAN_FEATURE_VOWIFI_11R */
5110
5111 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5112
5113 vos_status = wlan_hdd_check_ula_done(pAdapter);
5114 if ( vos_status != VOS_STATUS_SUCCESS )
5115 {
5116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5117 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5118 __LINE__, vos_status );
5119
5120 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5121 }
5122
5123 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5124
5125 if ( halStatus != eHAL_STATUS_SUCCESS )
5126 {
5127 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5128 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5129 __LINE__, halStatus );
5130
5131 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5132 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305133 EXIT();
5134 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005135}
5136
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305137static int iw_set_encodeext(struct net_device *dev,
5138 struct iw_request_info *info,
5139 union iwreq_data *wrqu, char *extra)
5140{
5141 int ret;
5142
5143 vos_ssr_protect(__func__);
5144 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5145 vos_ssr_unprotect(__func__);
5146
5147 return ret;
5148}
5149
5150static int __iw_set_retry(struct net_device *dev,
5151 struct iw_request_info *info,
5152 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005153{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305154 hdd_adapter_t *pAdapter;
5155 tHalHandle hHal;
5156 hdd_context_t *pHddCtx;
5157 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158
5159 ENTER();
5160
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305161 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5162 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005163 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5165 "%s: Adapter is NULL",__func__);
5166 return -EINVAL;
5167 }
5168
5169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5170 ret = wlan_hdd_validate_context(pHddCtx);
5171 if (0 != ret)
5172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305173 return ret;
5174 }
5175
5176 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5177 if (NULL == hHal)
5178 {
5179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5180 "%s: Hal Context is NULL",__func__);
5181 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005182 }
5183
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5185 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5186
Arif Hussain6d2a3322013-11-17 19:50:10 -08005187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005188
5189 return -EINVAL;
5190 }
5191
5192 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5193
5194 if((wrqu->retry.flags & IW_RETRY_LONG))
5195 {
5196 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5197 {
c_hpothub8245442013-11-20 23:41:09 +05305198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5199 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 return -EIO;
5201 }
5202 }
5203 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5204 {
5205 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5206 {
c_hpothub8245442013-11-20 23:41:09 +05305207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5208 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 return -EIO;
5210 }
5211 }
5212 }
5213 else
5214 {
5215 return -EOPNOTSUPP;
5216 }
5217
Arif Hussain6d2a3322013-11-17 19:50:10 -08005218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005219
5220 EXIT();
5221
5222 return 0;
5223
5224}
5225
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305226static int iw_set_retry(struct net_device *dev,
5227 struct iw_request_info *info,
5228 union iwreq_data *wrqu, char *extra)
5229{
5230 int ret;
5231
5232 vos_ssr_protect(__func__);
5233 ret = __iw_set_retry(dev, info, wrqu, extra);
5234 vos_ssr_unprotect(__func__);
5235
5236 return ret;
5237}
5238
5239static int __iw_get_retry(struct net_device *dev,
5240 struct iw_request_info *info,
5241 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005242{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305243 hdd_adapter_t *pAdapter;
5244 hdd_context_t *pHddCtx;
5245 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305247 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005248
5249 ENTER();
5250
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305251 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5252 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005253 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5255 "%s: Adapter is NULL",__func__);
5256 return -EINVAL;
5257 }
5258
5259 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5260 ret = wlan_hdd_validate_context(pHddCtx);
5261 if (0 != ret)
5262 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305263 return ret;
5264 }
5265
5266 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5267 if (NULL == hHal)
5268 {
5269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5270 "%s: Hal Context is NULL",__func__);
5271 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005272 }
5273
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 if((wrqu->retry.flags & IW_RETRY_LONG))
5275 {
5276 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5277
5278 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5279 {
c_hpothub8245442013-11-20 23:41:09 +05305280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5281 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 return -EIO;
5283 }
5284
5285 wrqu->retry.value = retry;
5286 }
5287 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5288 {
5289 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5290
5291 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5292 {
c_hpothub8245442013-11-20 23:41:09 +05305293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5294 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 return -EIO;
5296 }
5297
5298 wrqu->retry.value = retry;
5299 }
5300 else {
5301 return -EOPNOTSUPP;
5302 }
5303
Arif Hussain6d2a3322013-11-17 19:50:10 -08005304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005305
5306 EXIT();
5307
5308 return 0;
5309}
5310
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305311static int iw_get_retry(struct net_device *dev,
5312 struct iw_request_info *info,
5313 union iwreq_data *wrqu, char *extra)
5314{
5315 int ret;
5316
5317 vos_ssr_protect(__func__);
5318 ret = __iw_get_retry(dev, info, wrqu, extra);
5319 vos_ssr_unprotect(__func__);
5320
5321 return ret;
5322}
5323
5324static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 struct iw_request_info *info,
5326 union iwreq_data *wrqu,
5327 char *extra)
5328{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305329 hdd_adapter_t *pAdapter;
5330 hdd_context_t *pHddCtx;
5331 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5333 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305334 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005335
5336 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305337 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5338 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5341 "%s:Adapter is NULL",__func__);
5342 return -EINVAL;
5343 }
5344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5345 ret = wlan_hdd_validate_context(pHddCtx);
5346 if (0 != ret)
5347 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305348 return ret;
5349 }
5350 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5351 if (NULL == pHddStaCtx)
5352 {
5353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5354 "%s:STA context is NULL",__func__);
5355 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 }
5357
5358 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5359 switch (mlme->cmd) {
5360 case IW_MLME_DISASSOC:
5361 case IW_MLME_DEAUTH:
5362
5363 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5364 {
5365 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5366
5367 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5368 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5369
5370 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5371 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5372
Jeff Johnson43971f52012-07-17 12:26:56 -07005373 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305374 {
5375 long ret;
5376 ret = wait_for_completion_interruptible_timeout(
5377 &pAdapter->disconnect_comp_var,
5378 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5379 if (ret <= 0)
5380 hddLog(VOS_TRACE_LEVEL_ERROR,
5381 FL("failed wait on disconnect_comp_var %ld"), ret);
5382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005384 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005385 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005386
5387 /* Resetting authKeyMgmt */
5388 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5389
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305390 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 netif_tx_disable(dev);
5392 netif_carrier_off(dev);
5393
5394 }
5395 else
5396 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005397 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 -07005398 }
5399 break;
5400 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005401 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 return -EINVAL;
5403 }//end of switch
5404
5405 EXIT();
5406
5407 return status;
5408
5409}
5410
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305411static int iw_set_mlme(struct net_device *dev,
5412 struct iw_request_info *info,
5413 union iwreq_data *wrqu,
5414 char *extra)
5415{
5416 int ret;
5417
5418 vos_ssr_protect(__func__);
5419 ret = __iw_set_mlme(dev, info, wrqu, extra);
5420 vos_ssr_unprotect(__func__);
5421
5422 return ret;
5423}
5424
Jeff Johnson295189b2012-06-20 16:38:30 -07005425/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305426static int __iw_setint_getnone(struct net_device *dev,
5427 struct iw_request_info *info,
5428 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005429{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305430 hdd_adapter_t *pAdapter;
5431 tHalHandle hHal;
5432 hdd_wext_state_t *pWextState;
5433 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305434 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 int *value = (int *)extra;
5436 int sub_cmd = value[0];
5437 int set_value = value[1];
5438 int ret = 0; /* success */
5439 int enable_pbm, enable_mp;
5440#ifdef CONFIG_HAS_EARLYSUSPEND
5441 v_U8_t nEnableSuspendOld;
5442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005443
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305444 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305445 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5446 if (NULL == pAdapter)
5447 {
5448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5449 "%s: Adapter is NULL",__func__);
5450 return -EINVAL;
5451 }
5452 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5453 ret = wlan_hdd_validate_context(pHddCtx);
5454 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005455 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305456 return ret;
5457 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305458
5459 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5460 if (NULL == hHal)
5461 {
5462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5463 "%s: Hal Context is NULL",__func__);
5464 return -EINVAL;
5465 }
5466
Katya Nigameae74b62015-05-28 17:19:16 +05305467 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305468 {
Katya Nigameae74b62015-05-28 17:19:16 +05305469 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5470 if (NULL == pWextState)
5471 {
5472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5473 "%s: pWextState is NULL",__func__);
5474 return -EINVAL;
5475 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005476
Katya Nigameae74b62015-05-28 17:19:16 +05305477 INIT_COMPLETION(pWextState->completion_var);
5478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 switch(sub_cmd)
5480 {
5481 case WE_SET_11D_STATE:
5482 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005483 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005484 memset(&smeConfig, 0x00, sizeof(smeConfig));
5485
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5487
5488 sme_GetConfigParam(hHal,&smeConfig);
5489 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5490
Arif Hussain6d2a3322013-11-17 19:50:10 -08005491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005492
5493 sme_UpdateConfig(hHal,&smeConfig);
5494 }
5495 else {
5496 return -EINVAL;
5497 }
5498 break;
5499 }
5500
5501 case WE_WOWL:
5502 {
5503 switch (set_value)
5504 {
5505 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305506 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 break;
5508 case 0x01:
5509 case 0x02:
5510 case 0x03:
5511 enable_mp = (set_value & 0x01) ? 1 : 0;
5512 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005513 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5515 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5516 break;
5517 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005518 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 ret = -EINVAL;
5520 break;
5521 }
5522
5523 break;
5524 }
5525 case WE_SET_POWER:
5526 {
5527 switch (set_value)
5528 {
5529 case 0: //Full Power
5530 {
5531 struct statsContext context;
5532 eHalStatus status;
5533
5534 init_completion(&context.completion);
5535
5536 context.pAdapter = pAdapter;
5537 context.magic = POWER_CONTEXT_MAGIC;
5538
5539 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5540 iw_power_callback_fn, &context,
5541 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005542 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 {
5544 int lrc = wait_for_completion_interruptible_timeout(
5545 &context.completion,
5546 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005547
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 if (lrc <= 0)
5549 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005550 hddLog(VOS_TRACE_LEVEL_ERROR,
5551 "%s: SME %s while requesting fullpower",
5552 __func__, (0 == lrc) ?
5553 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 }
5555 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005556 /* either we have a response or we timed out. if we timed
5557 out there is a race condition such that the callback
5558 function could be executing at the same time we are. of
5559 primary concern is if the callback function had already
5560 verified the "magic" but had not yet set the completion
5561 variable when a timeout occurred. we serialize these
5562 activities by invalidating the magic while holding a
5563 shared spinlock which will cause us to block if the
5564 callback is currently executing */
5565 spin_lock(&hdd_context_lock);
5566 context.magic = 0;
5567 spin_unlock(&hdd_context_lock);
5568
Arif Hussain6d2a3322013-11-17 19:50:10 -08005569 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 break;
5571 }
5572 case 1: //Enable BMPS
5573 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5574 break;
5575 case 2: //Disable BMPS
5576 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5577 break;
5578 case 3: //Request Bmps
5579 {
5580 struct statsContext context;
5581 eHalStatus status;
5582
5583 init_completion(&context.completion);
5584
5585 context.pAdapter = pAdapter;
5586 context.magic = POWER_CONTEXT_MAGIC;
5587
5588 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5589 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005590 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 {
5592 int lrc = wait_for_completion_interruptible_timeout(
5593 &context.completion,
5594 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 if (lrc <= 0)
5596 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005597 hddLog(VOS_TRACE_LEVEL_ERROR,
5598 "%s: SME %s while requesting BMPS",
5599 __func__, (0 == lrc) ? "timeout" :
5600 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 }
5602 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005603 /* either we have a response or we timed out. if we
5604 timed out there is a race condition such that the
5605 callback function could be executing at the same
5606 time we are. of primary concern is if the callback
5607 function had already verified the "magic" but had
5608 not yet set the completion variable when a timeout
5609 occurred. we serialize these activities by
5610 invalidating the magic while holding a shared
5611 spinlock which will cause us to block if the
5612 callback is currently executing */
5613 spin_lock(&hdd_context_lock);
5614 context.magic = 0;
5615 spin_unlock(&hdd_context_lock);
5616
Arif Hussain6d2a3322013-11-17 19:50:10 -08005617 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 break;
5619 }
5620 case 4: //Enable IMPS
5621 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5622 break;
5623 case 5: //Disable IMPS
5624 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5625 break;
5626 case 6: //Enable Standby
5627 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5628 break;
5629 case 7: //Disable Standby
5630 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5631 break;
5632 case 8: //Request Standby
5633#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005634#endif
5635 break;
5636 case 9: //Start Auto Bmps Timer
5637 sme_StartAutoBmpsTimer(hHal);
5638 break;
5639 case 10://Stop Auto BMPS Timer
5640 sme_StopAutoBmpsTimer(hHal);
5641 break;
5642#ifdef CONFIG_HAS_EARLYSUSPEND
5643 case 11://suspend to standby
5644#ifdef CONFIG_HAS_EARLYSUSPEND
5645 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5646 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5648#endif
5649 break;
5650 case 12://suspend to deep sleep
5651#ifdef CONFIG_HAS_EARLYSUSPEND
5652 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5653 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5655#endif
5656 break;
5657 case 13://resume from suspend
5658#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005659#endif
5660 break;
5661#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005663 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 ret = -EINVAL;
5665 break;
5666 }
5667 break;
5668 }
5669
5670 case WE_SET_MAX_ASSOC:
5671 {
5672 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5673 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5674 {
5675 ret = -EINVAL;
5676 }
5677 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5678 set_value, NULL, eANI_BOOLEAN_FALSE)
5679 != eHAL_STATUS_SUCCESS )
5680 {
c_hpothub8245442013-11-20 23:41:09 +05305681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5682 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 ret = -EIO;
5684 }
5685 break;
5686 }
5687
5688 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5689 {
5690 if( 0 == set_value )
5691 {
5692 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5693 }
5694 else if ( 1 == set_value )
5695 {
5696 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5697 }
5698 else
5699 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005700 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 ret = -EINVAL;
5702 }
5703 break;
5704 }
5705
5706 case WE_SET_DATA_INACTIVITY_TO:
5707 {
5708 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5709 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5710 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5711 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5712 set_value,
5713 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5714 {
5715 hddLog(LOGE,"Failure: Could not pass on "
5716 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005717 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 ret = -EINVAL;
5719 }
5720 break;
5721 }
5722 case WE_SET_MAX_TX_POWER:
5723 {
5724 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5725 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5726
5727 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5728 __func__, set_value);
5729 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5730 eHAL_STATUS_SUCCESS )
5731 {
5732 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5733 __func__);
5734 return -EIO;
5735 }
5736
5737 break;
5738 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005739 case WE_SET_MAX_TX_POWER_2_4:
5740 {
5741 hddLog(VOS_TRACE_LEVEL_INFO,
5742 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5743 __func__, set_value);
5744 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5745 eHAL_STATUS_SUCCESS)
5746 {
5747 hddLog(VOS_TRACE_LEVEL_ERROR,
5748 "%s: Setting maximum tx power failed for 2.4 GHz band",
5749 __func__);
5750 return -EIO;
5751 }
5752
5753 break;
5754 }
5755 case WE_SET_MAX_TX_POWER_5_0:
5756 {
5757 hddLog(VOS_TRACE_LEVEL_INFO,
5758 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5759 __func__, set_value);
5760 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5761 eHAL_STATUS_SUCCESS)
5762 {
5763 hddLog(VOS_TRACE_LEVEL_ERROR,
5764 "%s: Setting maximum tx power failed for 5.0 GHz band",
5765 __func__);
5766 return -EIO;
5767 }
5768
5769 break;
5770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 case WE_SET_HIGHER_DTIM_TRANSITION:
5772 {
5773 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5774 (set_value == eANI_BOOLEAN_TRUE)))
5775 {
5776 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5777 ret = -EINVAL;
5778 }
5779 else
5780 {
5781 if(pAdapter->higherDtimTransition != set_value)
5782 {
5783 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005784 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 }
5786 }
5787
5788 break;
5789 }
5790
5791 case WE_SET_TM_LEVEL:
5792 {
5793 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005794 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5796
5797 break;
5798 }
5799
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305800 case WE_ENABLE_STRICT_FCC_REG:
5801 {
5802 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5803 struct wiphy *wiphy = NULL;
5804 long lrc;
5805 int status;
5806
5807 wiphy = hddCtxt->wiphy;
5808 if(wiphy == NULL)
5809 {
5810 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5811 break;
5812 }
5813 init_completion(&hddCtxt->wiphy_channel_update_event);
5814
5815 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5816
5817 status = regulatory_hint(wiphy, "00");
5818 if(status < 0)
5819 {
5820 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5821 break;
5822 }
5823
5824 /* Wait for completion */
5825 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5826 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5827 if (lrc <= 0)
5828 {
5829 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5830 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5831 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5832 }
5833 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5834
5835 break;
5836 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005837 case WE_SET_DEBUG_LOG:
5838 {
5839 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5840 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5841 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5842 break;
5843 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305844#ifdef FEATURE_WLAN_TDLS
5845 case WE_SET_TDLS_OFF_CHAN:
5846 {
5847 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5849 __func__, set_value);
5850 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5851 break;
5852 }
5853 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5854 {
5855 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5857 __func__, set_value);
5858 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5859 break;
5860 }
5861 case WE_SET_TDLS_OFF_CHAN_MODE:
5862 {
5863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5864 __func__, set_value);
5865 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5866 break;
5867 }
5868#endif
Peng Xu2446a892014-09-05 17:21:18 +05305869 case WE_SET_SCAN_BAND_PREFERENCE:
5870 {
5871 tSmeConfigParams smeConfig;
5872 memset(&smeConfig, 0x00, sizeof(smeConfig));
5873 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5874 ret = -EINVAL;
5875 break;
5876 }
5877 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5878
5879 if (eCSR_BAND_ALL == set_value ||
5880 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5881 sme_GetConfigParam(hHal, &smeConfig);
5882 smeConfig.csrConfig.scanBandPreference = set_value;
5883
5884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5885 "set band scan preference = %d\n",
5886 smeConfig.csrConfig.scanBandPreference);
5887
5888 sme_UpdateConfig(hHal, &smeConfig);
5889 }
5890 else {
5891 ret = -EINVAL;
5892 }
5893 break;
5894 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305895 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5896 * connection happens so that the params can take effect during
5897 * association. Also this should not be used in STA+p2p concurrency
5898 * as the param will also effect the STA mode.
5899 */
5900 case WE_SET_MIRACAST_VENDOR_CONFIG:
5901 {
5902 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305903
Abhishek Singh01c73d12015-03-12 15:13:44 +05305904 hddLog(LOG1, FL(
5905 "Set Miracast vendor tuning %d"), set_value);
5906
5907 if (1 == set_value || 0 == set_value)
5908 {
5909 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5910 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5911 {
5912 hddLog( LOGE, FL("set vendor miracast config failed"));
5913 ret = -EIO;
5914 }
5915 }
5916 else
5917 {
5918 hddLog(LOGE,
5919 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5920 ret = -EINVAL;
5921 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305922 break;
5923 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305924
5925 case WE_GET_FRAME_LOG:
5926 {
5927 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5928 != VOS_STATUS_SUCCESS)
5929 {
5930 ret = -EINVAL;
5931 }
5932 break;
5933 }
5934
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305935 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5936 {
5937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5938 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5939 if (set_value == 0 || set_value == 1)
5940 {
5941 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5942 set_value);
5943 }
5944 else
5945 ret = -EINVAL;
5946
5947 break;
5948 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305949 /* Bit mask value to enable RTS/CTS for different modes
5950 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5951 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5952 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5953 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5954 * for 5 GHz, VHT80 - 0x1000
5955 */
5956 case WE_SET_RTS_CTS_HTVHT:
5957 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305958
Abhishek Singh41988ba2015-05-25 19:42:29 +05305959 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5960
5961 if (eHAL_STATUS_SUCCESS !=
5962 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5963 {
5964 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5965 ret = -EINVAL;
5966 }
5967 break;
5968 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305969 case WE_SET_MONITOR_STATE:
5970 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305971 v_U32_t magic = 0;
5972 struct completion cmpVar;
5973 long waitRet = 0;
5974 tVOS_CON_MODE mode = hdd_get_conparam();
5975
5976 if( VOS_MONITOR_MODE != mode)
5977 {
5978 hddLog(LOGE, "invalid mode %d", mode);
5979 ret = -EIO;
5980 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305981
5982 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5983 if( pMonCtx == NULL )
5984 {
5985 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305986 ret = -EIO;
5987 }
5988 if (pMonCtx->state == set_value)
5989 {
5990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5991 FL("already in same mode curr_mode:%d req_mode: %d"),
5992 pMonCtx->state, set_value);
5993 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305994 }
5995 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305996 magic = MON_MODE_MSG_MAGIC;
5997 init_completion(&cmpVar);
5998 if (VOS_STATUS_SUCCESS !=
5999 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6000 pMonCtx, hdd_monPostMsgCb)) {
6001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6002 FL("failed to post MON MODE REQ"));
6003 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6004 MON_MODE_STOP : MON_MODE_START;
6005 magic = 0;
6006 ret = -EIO;
6007 break;
6008 }
6009 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6010 magic = 0;
6011 if (waitRet <= 0 ){
6012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6013 FL("failed to wait on monitor mode completion %ld"),
6014 waitRet);
6015 }
6016 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306017 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306018 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6019 {
6020 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6021 tAniWifiStartLog start_log;
6022 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6023 !vos_isPktStatsEnabled())
6024 {
6025 hddLog(LOGE, FL("per pkt stats not enabled"));
6026 return -EINVAL;
6027 }
6028 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6029
6030 if (1 == set_value || 0 == set_value)
6031 {
6032 start_log.ringId = RING_ID_PER_PACKET_STATS;
6033 start_log.flag = 0;
6034 if (set_value)
6035 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6036 else
6037 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6038
6039 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6040 }
6041 else
6042 {
6043 hddLog(LOGE,
6044 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6045 set_value);
6046 ret = -EINVAL;
6047 }
6048 break;
6049 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306050 case WE_SET_PROXIMITY_ENABLE:
6051 {
6052 sHwCalValues hwCalValues;
6053 uint16 hwCalTxPower;
6054 uint8 txPwr = TX_PWR_DEF;
Katya Nigamf0511f62015-05-05 16:40:57 +05306055
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306056 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
6057
6058 if (TRUE == set_value) {
6059 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
6060 NULL, sizeof(sHwCalValues) )
6061 != VOS_STATUS_SUCCESS) {
6062 ret = -EINVAL;
6063 break;
6064 }
6065 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
6066
6067 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
6068 hwCalTxPower, hwCalValues.calData.hwParam7);
6069
6070 txPwr = (int8)(hwCalTxPower & 0x00FF);
6071 txPwr = txPwr/10;
6072 if (txPwr < TX_PWR_MIN)
6073 txPwr = TX_PWR_MIN;
6074 if (txPwr > TX_PWR_MAX)
6075 txPwr = TX_PWR_MAX;
6076
6077 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr) !=
6078 eHAL_STATUS_SUCCESS) {
6079 hddLog(VOS_TRACE_LEVEL_ERROR,
6080 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
6081 ret = -EIO;
6082 }
6083
6084 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
6085 txPwr /= 10;
6086 if (txPwr < TX_PWR_MIN)
6087 txPwr = TX_PWR_MIN;
6088 if (txPwr > TX_PWR_MAX)
6089 txPwr = TX_PWR_MAX;
6090
6091 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr) !=
6092 eHAL_STATUS_SUCCESS) {
6093 hddLog(VOS_TRACE_LEVEL_ERROR,
6094 FL("setting tx power failed for 5GHz band %d"), txPwr);
6095 ret = -EIO;
6096 }
6097 }
6098 else if(FALSE == set_value) {
6099 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr) !=
6100 eHAL_STATUS_SUCCESS) {
6101 hddLog(VOS_TRACE_LEVEL_ERROR,
6102 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
6103 ret = -EIO;
6104 }
6105
6106 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr) !=
6107 eHAL_STATUS_SUCCESS) {
6108 hddLog(VOS_TRACE_LEVEL_ERROR,
6109 FL("setting tx power failed for 5GHz band %d"), txPwr);
6110 ret = -EIO;
6111 }
6112 }
6113 else {
6114 ret = -EINVAL;
6115 }
6116 break;
6117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 default:
6119 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006120 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 sub_cmd, set_value);
6122 break;
6123 }
6124 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306125 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 return ret;
6127}
6128
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306129static int iw_setint_getnone(struct net_device *dev,
6130 struct iw_request_info *info,
6131 union iwreq_data *wrqu, char *extra)
6132{
6133 int ret;
6134
6135 vos_ssr_protect(__func__);
6136 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6137 vos_ssr_unprotect(__func__);
6138
6139 return 0;
6140}
Jeff Johnson295189b2012-06-20 16:38:30 -07006141/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306142static int __iw_setchar_getnone(struct net_device *dev,
6143 struct iw_request_info *info,
6144 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006145{
6146 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306147 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006149 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306150 hdd_adapter_t *pAdapter;
6151 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006152#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306153 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006154#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306155 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306156 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006157
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306158 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306159
6160 if (!capable(CAP_NET_ADMIN))
6161 {
6162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6163 FL("permission check failed"));
6164 return -EPERM;
6165 }
6166
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306167 pAdapter = (netdev_priv(dev));
6168 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006169 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6171 "%s: Adapter is NULL",__func__);
6172 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006173 }
6174
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306175 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6176 ret = wlan_hdd_validate_context(pHddCtx);
6177 if (0 != ret)
6178 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306179 return ret;
6180 }
6181#ifdef WLAN_FEATURE_VOWIFI
6182 pConfig = pHddCtx->cfg_ini;
6183#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306184 /* helper function to get iwreq_data with compat handling. */
6185 if (hdd_priv_get_data(&s_priv_data, wrqu))
6186 {
6187 return -EINVAL;
6188 }
6189
6190 /* make sure all params are correctly passed to function */
6191 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6192 {
6193 return -EINVAL;
6194 }
6195
6196 sub_cmd = s_priv_data.flags;
6197
Arif Hussain0273cba2014-01-07 20:58:29 -08006198 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306199 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6200 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006201 if (NULL == pBuffer)
6202 {
6203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6204 "mem_alloc_copy_from_user_helper fail");
6205 return -ENOMEM;
6206 }
6207
6208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306209 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6211 "%s: Received data %s", __func__, pBuffer);
6212
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 switch(sub_cmd)
6214 {
6215 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006217 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 break;
6219 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006221 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 break;
6223#if defined WLAN_FEATURE_VOWIFI
6224 case WE_NEIGHBOR_REPORT_REQUEST:
6225 {
6226 tRrmNeighborReq neighborReq;
6227 tRrmNeighborRspCallbackInfo callbackInfo;
6228
6229 if (pConfig->fRrmEnable)
6230 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306232 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 if( !neighborReq.no_ssid )
6234 {
Girish Gowli552fc072014-06-14 18:26:16 +05306235 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006236 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 }
6238
6239 callbackInfo.neighborRspCallback = NULL;
6240 callbackInfo.neighborRspCallbackContext = NULL;
6241 callbackInfo.timeout = 5000; //5 seconds
6242 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6243 }
6244 else
6245 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006246 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 ret = -EINVAL;
6248 }
6249 }
6250 break;
6251#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 case WE_SET_AP_WPS_IE:
6253 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306254 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006257 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 if (VOS_STATUS_SUCCESS != vstatus)
6259 {
6260 ret = -EINVAL;
6261 }
6262 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306263 case WE_SET_ENCRYPT_MSG:
6264 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6265 if (NULL == pkt)
6266 {
6267 hddLog(VOS_TRACE_LEVEL_ERROR,
6268 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306269 ret = -ENOMEM;
6270 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306271 }
6272
6273 memset(pkt, 0, sizeof(tSirpkt80211));
6274
6275 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6276 hddLog(VOS_TRACE_LEVEL_ERROR,
6277 FL("Firmware is not DISA capable"));
6278 ret = -EINVAL;
6279 vos_mem_free(pkt);
6280 break;
6281 }
6282
6283 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6284
6285 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6286 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6287 if (eHAL_STATUS_SUCCESS != ret) {
6288 hddLog(VOS_TRACE_LEVEL_ERROR,
6289 FL("SENDEncryptMSG: fail to post WDA cmd"));
6290 ret = -EINVAL;
6291 }
6292 vos_mem_free(pkt);
6293
6294 break;
6295
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 default:
6297 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006298 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 ret = -EINVAL;
6300 break;
6301 }
6302 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006303 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306304
6305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 return ret;
6307}
6308
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306309static int iw_setchar_getnone(struct net_device *dev,
6310 struct iw_request_info *info,
6311 union iwreq_data *wrqu, char *extra)
6312{
6313 int ret;
6314
6315 vos_ssr_protect(__func__);
6316 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6317 vos_ssr_unprotect(__func__);
6318
6319 return ret;
6320}
6321
Jeff Johnson295189b2012-06-20 16:38:30 -07006322/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306323static int __iw_setnone_getint(struct net_device *dev,
6324 struct iw_request_info *info,
6325 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006326{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306327 hdd_adapter_t *pAdapter;
6328 tHalHandle hHal;
6329 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 int *value = (int *)extra;
6331 int ret = 0; /* success */
6332
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306333 ENTER();
6334
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306335 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6336 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006337 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6339 "%s: Adapter is NULL",__func__);
6340 return -EINVAL;
6341 }
6342 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6343 ret = wlan_hdd_validate_context(pHddCtx);
6344 if (0 != ret)
6345 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306346 return ret;
6347 }
6348 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6349 if (NULL == hHal)
6350 {
6351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6352 "%s: Hal Context is NULL",__func__);
6353 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006355
6356 switch (value[0])
6357 {
6358 case WE_GET_11D_STATE:
6359 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006360 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306362
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6364
Arif Hussain6d2a3322013-11-17 19:50:10 -08006365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006366
6367 break;
6368 }
6369
6370 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 break;
6373
6374 case WE_PMC_STATE:
6375 {
6376 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 break;
6379 }
6380 case WE_GET_WLAN_DBG:
6381 {
6382 vos_trace_display();
6383 *value = 0;
6384 break;
6385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 case WE_GET_MAX_ASSOC:
6387 {
6388 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6389 {
c_hpothub8245442013-11-20 23:41:09 +05306390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6391 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 ret = -EIO;
6393 }
Girish Gowli385be612014-09-18 11:17:20 +05306394#ifdef WLAN_SOFTAP_VSTA_FEATURE
6395 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6396 {
6397 if (*value > VSTA_NUM_ASSOC_STA)
6398 {
6399 *value = VSTA_NUM_ASSOC_STA;
6400 }
6401 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6402 (*value > (VSTA_NUM_ASSOC_STA -
6403 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6404 {
6405 *value = (VSTA_NUM_ASSOC_STA -
6406 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6407 }
6408 }
6409 else
6410#endif
6411 {
6412 if (*value > NUM_ASSOC_STA)
6413 {
6414 *value = NUM_ASSOC_STA;
6415 }
6416 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6417 (*value > (NUM_ASSOC_STA -
6418 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6419 {
6420 *value = (NUM_ASSOC_STA -
6421 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6422 }
6423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 break;
6425 }
6426
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 case WE_GET_WDI_DBG:
6428 {
6429 wpalTraceDisplay();
6430 *value = 0;
6431 break;
6432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006433
6434 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6435 {
6436 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6437 break;
6438 }
6439 case WE_GET_CONCURRENCY_MODE:
6440 {
6441 *value = hdd_get_concurrency_mode ( );
6442
Arif Hussain6d2a3322013-11-17 19:50:10 -08006443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 break;
6445 }
6446
Peng Xu2446a892014-09-05 17:21:18 +05306447 case WE_GET_SCAN_BAND_PREFERENCE:
6448 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306449 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306450 sme_GetConfigParam(hHal, &smeConfig);
6451 *value = smeConfig.csrConfig.scanBandPreference;
6452
6453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6454 "scanBandPreference = %d\n", *value);
6455 break;
6456 }
6457
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 default:
6459 {
6460 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6461 break;
6462 }
6463 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306464 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 return ret;
6466}
6467
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306468static int iw_setnone_getint(struct net_device *dev,
6469 struct iw_request_info *info,
6470 union iwreq_data *wrqu, char *extra)
6471{
6472 int ret;
6473
6474 vos_ssr_protect(__func__);
6475 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6476 vos_ssr_unprotect(__func__);
6477
6478 return ret;
6479
6480}
Jeff Johnson295189b2012-06-20 16:38:30 -07006481/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306482int __iw_set_three_ints_getnone(struct net_device *dev,
6483 struct iw_request_info *info,
6484 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006485{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306486 hdd_adapter_t *pAdapter;
6487 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 int *value = (int *)extra;
6489 int sub_cmd = value[0];
6490 int ret = 0;
6491
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306492 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306493
6494 if (!capable(CAP_NET_ADMIN))
6495 {
6496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6497 FL("permission check failed"));
6498 return -EPERM;
6499 }
6500
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306501 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6502 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006503 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6505 "%s: Adapter is NULL",__func__);
6506 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006507 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306508 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6509 ret = wlan_hdd_validate_context(pHddCtx);
6510 if (0 != ret)
6511 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306512 return ret;
6513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 switch(sub_cmd)
6515 {
6516 case WE_SET_WLAN_DBG:
6517 {
6518 vos_trace_setValue( value[1], value[2], value[3]);
6519 break;
6520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 case WE_SET_WDI_DBG:
6522 {
6523 wpalTraceSetLevel( value[1], value[2], value[3]);
6524 break;
6525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 case WE_SET_SAP_CHANNELS:
6527 {
6528 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6529 break;
6530 }
6531
6532 default:
6533 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006534 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 break;
6536 }
6537 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306538 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 return ret;
6540}
6541
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306542int iw_set_three_ints_getnone(struct net_device *dev,
6543 struct iw_request_info *info,
6544 union iwreq_data *wrqu, char *extra)
6545{
6546 int ret;
6547
6548 vos_ssr_protect(__func__);
6549 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6550 vos_ssr_unprotect(__func__);
6551
6552 return ret;
6553}
6554
6555static int __iw_get_char_setnone(struct net_device *dev,
6556 struct iw_request_info *info,
6557 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006558{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306559 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306561 hdd_context_t *pHddCtx;
6562 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006563#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006564 hdd_wext_state_t *pWextState;
6565#endif
6566
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306567 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306568 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006569 if (pAdapter == NULL)
6570 {
6571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6572 "%s: pAdapter is NULL!", __func__);
6573 return -EINVAL;
6574 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306575 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6576 ret = wlan_hdd_validate_context(pHddCtx);
6577 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006578 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306579 return ret;
6580 }
6581#ifdef WLAN_FEATURE_11W
6582 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6583 if (NULL == pWextState)
6584 {
6585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6586 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006587 return -EINVAL;
6588 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306589#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006590
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 switch(sub_cmd)
6592 {
6593 case WE_WLAN_VERSION:
6594 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006595 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 break;
6597 }
6598
6599 case WE_GET_STATS:
6600 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306601 tHalHandle hHal = NULL;
6602 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6604 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6605 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6606
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306607
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 snprintf(extra, WE_MAX_STR_LEN,
6609 "\nTransmit"
6610 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6611 "\n dropped BK %u, BE %u, VI %u, VO %u"
6612 "\n classified BK %u, BE %u, VI %u, VO %u"
6613 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6614 "\n queued BK %u, BE %u, VI %u, VO %u"
6615 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006616 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 "\n fetched BK %u, BE %u, VI %u, VO %u"
6618 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6619 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006620 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 "\n flushed BK %u, BE %u, VI %u, VO %u"
6622 "\n\nReceive"
6623 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6624 "\n\nResetsStats"
6625 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6626 "\n",
6627 pStats->txXmitCalled,
6628 pStats->txXmitDropped,
6629 pStats->txXmitBackPressured,
6630 pStats->txXmitQueued,
6631
6632 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6633 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6634 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6635 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6636
6637 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6638 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6639 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6640 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6641
6642 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6643 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6644 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6645 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6646
6647 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6648 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6649 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6650 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6651
6652 pStats->txFetched,
6653 pStats->txFetchEmpty,
6654 pStats->txFetchLowResources,
6655 pStats->txFetchDequeueError,
6656
6657 pStats->txFetchDequeued,
6658 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006659 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 pStats->txCompleted,
6661 pStats->txFlushed,
6662
6663 pStats->txFetchedAC[WLANTL_AC_BK],
6664 pStats->txFetchedAC[WLANTL_AC_BE],
6665 pStats->txFetchedAC[WLANTL_AC_VI],
6666 pStats->txFetchedAC[WLANTL_AC_VO],
6667
6668 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6669 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6670 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6671 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6672
6673 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6674 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6675 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6676 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6677
Ravi Joshi41914632013-10-21 23:02:21 -07006678 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6679 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6680 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6681 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6682
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 pStats->txFlushedAC[WLANTL_AC_BK],
6684 pStats->txFlushedAC[WLANTL_AC_BE],
6685 pStats->txFlushedAC[WLANTL_AC_VI],
6686 pStats->txFlushedAC[WLANTL_AC_VO],
6687
6688 pStats->rxChains,
6689 pStats->rxPackets,
6690 pStats->rxDropped,
6691 pStats->rxDelivered,
6692 pStats->rxRefused,
6693
6694 pResetStats->totalLogpResets,
6695 pResetStats->totalCMD53Failures,
6696 pResetStats->totalMutexReadFailures,
6697 pResetStats->totalMIFErrorFailures,
6698 pResetStats->totalFWHearbeatFailures,
6699 pResetStats->totalUnknownExceptions
6700 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306701 wrqu->data.length = strlen(extra);
6702
6703 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6704
6705 if (hHal)
6706 pMac = PMAC_STRUCT( hHal );
6707
6708 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6709 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6710 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306711 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6712 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6713 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6714 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306715 "\n",
6716 pMac->pmm.BmpscntSleep,
6717 pMac->pmm.BmpscntAwake,
6718 pMac->pmm.BmpsSleeReqFailCnt,
6719 pMac->pmm.BmpsWakeupReqFailCnt,
6720 pMac->pmm.ImpsCntSleep,
6721 pMac->pmm.ImpsCntAwake,
6722 pMac->pmm.ImpsSleepErrCnt,
6723 pMac->pmm.ImpsWakeupErrCnt,
6724 pMac->pmm.ImpsLastErr
6725 );
6726 }
6727
Jeff Johnson295189b2012-06-20 16:38:30 -07006728 wrqu->data.length = strlen(extra)+1;
6729 break;
6730 }
6731
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306732/* The case prints the current state of the HDD, SME, CSR, PE, TL
6733 *it can be extended for WDI Global State as well.
6734 *And currently it only checks P2P_CLIENT adapter.
6735 *P2P_DEVICE and P2P_GO have not been added as of now.
6736*/
6737 case WE_GET_STATES:
6738 {
6739 int buf = 0, len = 0;
6740 int adapter_num = 0;
6741 int count = 0, check = 1;
6742
6743 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006744 tHalHandle hHal = NULL;
6745 tpAniSirGlobal pMac = NULL;
6746 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306747
6748 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6749 hdd_adapter_t *useAdapter = NULL;
6750
6751 /* Print wlan0 or p2p0 states based on the adapter_num
6752 *by using the correct adapter
6753 */
6754 while ( adapter_num < 2 )
6755 {
6756 if ( WLAN_ADAPTER == adapter_num )
6757 {
6758 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006759 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306760 "\n\n wlan0 States:-");
6761 len += buf;
6762 }
6763 else if ( P2P_ADAPTER == adapter_num )
6764 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006765 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306766 "\n\n p2p0 States:-");
6767 len += buf;
6768
6769 if( !pHddCtx )
6770 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006771 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306772 "\n pHddCtx is NULL");
6773 len += buf;
6774 break;
6775 }
6776
6777 /*Printing p2p0 states only in the case when the device is
6778 configured as a p2p_client*/
6779 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6780 if ( !useAdapter )
6781 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006782 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306783 "\n Device not configured as P2P_CLIENT.");
6784 len += buf;
6785 break;
6786 }
6787 }
6788
6789 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006790 if (!hHal) {
6791 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6792 "\n pMac is NULL");
6793 len += buf;
6794 break;
6795 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306796 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006797 if (!pMac) {
6798 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6799 "\n pMac is NULL");
6800 len += buf;
6801 break;
6802 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306803 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6804 if( !pHddStaCtx )
6805 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006806 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306807 "\n pHddStaCtx is NULL");
6808 len += buf;
6809 break;
6810 }
6811
6812 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6813
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006814 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306815 "\n HDD Conn State - %s "
6816 "\n \n SME State:"
6817 "\n Neighbour Roam State - %s"
6818 "\n CSR State - %s"
6819 "\n CSR Substate - %s"
6820 "\n \n TL STA %d State: %s",
6821 macTraceGetHDDWlanConnState(
6822 pHddStaCtx->conn_info.connState),
6823 macTraceGetNeighbourRoamState(
6824 pMac->roam.neighborRoamInfo.neighborRoamState),
6825 macTraceGetcsrRoamState(
6826 pMac->roam.curState[useAdapter->sessionId]),
6827 macTraceGetcsrRoamSubState(
6828 pMac->roam.curSubState[useAdapter->sessionId]),
6829 pHddStaCtx->conn_info.staId[0],
6830 macTraceGetTLState(tlState)
6831 );
6832 len += buf;
6833 adapter_num++;
6834 }
6835
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006836 if (pMac) {
6837 /* Printing Lim State starting with global lim states */
6838 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6839 "\n \n LIM STATES:-"
6840 "\n Global Sme State - %s "\
6841 "\n Global mlm State - %s "\
6842 "\n",
6843 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6844 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6845 );
6846 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306847
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006848 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306849 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306850 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006851 if ( pMac->lim.gpSession[count].valid )
6852 {
6853 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6854 "\n Lim Valid Session %d:-"
6855 "\n PE Sme State - %s "
6856 "\n PE Mlm State - %s "
6857 "\n",
6858 check,
6859 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6860 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6861 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306862
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006863 len += buf;
6864 check++;
6865 }
6866 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306867 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306868 }
6869
6870 wrqu->data.length = strlen(extra)+1;
6871 break;
6872 }
6873
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 case WE_GET_CFG:
6875 {
6876 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6877 wrqu->data.length = strlen(extra)+1;
6878 break;
6879 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006880#ifdef WLAN_FEATURE_11AC
6881 case WE_GET_RSSI:
6882 {
6883 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306884 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006885 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6886 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6887 wrqu->data.length = strlen(extra)+1;
6888 break;
6889 }
6890#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306891
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006892#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006893 case WE_GET_ROAM_RSSI:
6894 {
6895 v_S7_t s7Rssi = 0;
6896 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6897 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6898 wrqu->data.length = strlen(extra)+1;
6899 break;
6900 }
6901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 case WE_GET_WMM_STATUS:
6903 {
6904 snprintf(extra, WE_MAX_STR_LEN,
6905 "\nDir: 0=up, 1=down, 3=both\n"
6906 "|------------------------|\n"
6907 "|AC | ACM |Admitted| Dir |\n"
6908 "|------------------------|\n"
6909 "|VO | %d | %3s | %d |\n"
6910 "|VI | %d | %3s | %d |\n"
6911 "|BE | %d | %3s | %d |\n"
6912 "|BK | %d | %3s | %d |\n"
6913 "|------------------------|\n",
6914 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6915 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6916 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6917 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6918 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6919 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6920 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6921 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6922 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6923 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6924 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6925 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6926
Jeff Johnsone7245742012-09-05 17:12:55 -07006927
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 wrqu->data.length = strlen(extra)+1;
6929 break;
6930 }
6931 case WE_GET_CHANNEL_LIST:
6932 {
6933 VOS_STATUS status;
6934 v_U8_t i, len;
6935 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306936 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6937 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6938 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 tChannelListInfo channel_list;
6940
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006941 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006943 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006945 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 return -EINVAL;
6947 }
6948 buf = extra;
6949
6950 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006951 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6952 * needed = 5 * number of channels. Check ifsufficient
6953 * buffer is available and then proceed to fill the buffer.
6954 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6956 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006957 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006958 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006959 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 return -EINVAL;
6961 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006962 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6963 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306964 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6965 {
6966 //Printing Country code in getChannelList
6967 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6968 {
6969 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6970 "%c ", pBuf[i]);
6971 }
6972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 for(i = 0 ; i < channel_list.num_channels; i++)
6974 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006975 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 }
6978 wrqu->data.length = strlen(extra)+1;
6979
6980 break;
6981 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006982#ifdef FEATURE_WLAN_TDLS
6983 case WE_GET_TDLS_PEERS:
6984 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006985 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006986 break;
6987 }
6988#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006989#ifdef WLAN_FEATURE_11W
6990 case WE_GET_11W_INFO:
6991 {
6992 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6993
6994 snprintf(extra, WE_MAX_STR_LEN,
6995 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6996 "\n Number of Unprotected Disassocs %d"
6997 "\n Number of Unprotected Deauths %d",
6998 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6999 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7000 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7001 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7002 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7003
7004 wrqu->data.length = strlen(extra)+1;
7005 break;
7006 }
7007#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307008 case WE_GET_SNR:
7009 {
7010 v_S7_t s7snr = 0;
7011 int status = 0;
7012 hdd_context_t *pHddCtx;
7013 hdd_station_ctx_t *pHddStaCtx;
7014
7015 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7016 status = wlan_hdd_validate_context(pHddCtx);
7017 if (0 != status)
7018 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307019 return status;
7020 }
7021
7022 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7023
7024 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7025 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7026 {
7027 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7028 " ConnectionState-%d", __func__,
7029 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7030 pHddStaCtx->conn_info.connState);
7031 return -ENONET;
7032 }
7033
7034 /*update the stats in TL*/
7035 wlan_hdd_get_station_stats(pAdapter);
7036 wlan_hdd_get_snr(pAdapter, &s7snr);
7037 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7038 wrqu->data.length = strlen(extra) + 1;
7039 break;
7040 }
7041
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307042#ifdef FEATURE_OEM_DATA_SUPPORT
7043 case WE_GET_OEM_DATA_CAP:
7044 {
7045 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7046 }
7047#endif /* FEATURE_OEM_DATA_SUPPORT */
7048
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307049 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007051 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 break;
7053 }
7054 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307055 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 return 0;
7057}
7058
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307059static int iw_get_char_setnone(struct net_device *dev,
7060 struct iw_request_info *info,
7061 union iwreq_data *wrqu, char *extra)
7062{
7063 int ret;
7064
7065 vos_ssr_protect(__func__);
7066 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7067 vos_ssr_unprotect(__func__);
7068
7069 return ret;
7070}
7071
Jeff Johnson295189b2012-06-20 16:38:30 -07007072/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307073static int __iw_setnone_getnone(struct net_device *dev,
7074 struct iw_request_info *info,
7075 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007076{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307077 hdd_adapter_t *pAdapter;
7078 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307079 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007080 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307081 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007082
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307083 ENTER();
7084
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307085 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7086 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7089 "%s: Adapter is NULL",__func__);
7090 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007091 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7093 ret = wlan_hdd_validate_context(pHddCtx);
7094 if (0 != ret)
7095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307096 return ret;
7097 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307098 /* helper function to get iwreq_data with compat handling. */
7099 if (hdd_priv_get_data(&s_priv_data, wrqu))
7100 {
7101 return -EINVAL;
7102 }
7103
7104 sub_cmd = s_priv_data.flags;
7105
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 switch (sub_cmd)
7107 {
7108 case WE_CLEAR_STATS:
7109 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7112 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7113 break;
7114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 case WE_INIT_AP:
7116 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307117 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7118
7119 /* As Soft AP mode might been changed to STA already with
7120 * killing of Hostapd, need to find the adpater by name
7121 * rather than mode */
7122 hdd_adapter_t* pAdapter_to_stop =
7123 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7124 if( pAdapter_to_stop )
7125 {
7126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7127 "Adapter with name softap.0 already "
7128 "exist, ignoring the request.\nRemove the "
7129 "adapter and try again\n");
7130 break;
7131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 pr_info("Init AP trigger\n");
7133 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7134 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7135 break;
7136 }
7137 case WE_STOP_AP:
7138 {
7139 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7140 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7141 * this is a dead code and need to find the adpater by name rather than mode */
7142 hdd_adapter_t* pAdapter_to_stop =
7143 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7144 if( pAdapter_to_stop )
7145 {
7146 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7147
7148 pr_info("Stopping AP mode\n");
7149
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307150 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7151 {
7152 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7153 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7154 }
7155
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307157 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307158 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7160
7161 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7162 pAdapter_to_stop->macAddressCurrent.bytes);
7163 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7164 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307165
7166 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7167 {
7168 /* put the device back into BMPS */
7169 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 }
7172 else
7173 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007174 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 }
7176
7177 break;
7178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007179#ifdef WLAN_BTAMP_FEATURE
7180 case WE_ENABLE_AMP:
7181 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 WLANBAP_RegisterWithHCI(pAdapter);
7184 break;
7185 }
7186 case WE_DISABLE_AMP:
7187 {
7188 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7189 VOS_STATUS status;
7190
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007192
7193 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7194 status = WLANBAP_StopAmp();
7195 if(VOS_STATUS_SUCCESS != status )
7196 {
7197 pHddCtx->isAmpAllowed = VOS_TRUE;
7198 hddLog(VOS_TRACE_LEVEL_FATAL,
7199 "%s: Failed to stop AMP", __func__);
7200 }
7201 else
7202 {
7203 //a state m/c implementation in PAL is TBD to avoid this delay
7204 msleep(500);
7205 pHddCtx->isAmpAllowed = VOS_FALSE;
7206 WLANBAP_DeregisterFromHCI();
7207 }
7208
7209 break;
7210 }
7211#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007212 case WE_ENABLE_DXE_STALL_DETECT:
7213 {
schang6295e542013-03-12 15:31:23 -07007214 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7215 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007216 break;
7217 }
7218 case WE_DISPLAY_DXE_SNAP_SHOT:
7219 {
schang6295e542013-03-12 15:31:23 -07007220 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7221 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007222 break;
7223 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307224 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7225 {
7226 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7227 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307228 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307229 break;
7230 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307231
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307232 case WE_SET_REASSOC_TRIGGER:
7233 {
7234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7235 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7236 v_U32_t roamId = 0;
7237 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307238 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7239 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307240 return 0;
7241 }
7242
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307243 case WE_STOP_OBSS_SCAN:
7244 {
7245 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7246 2.OBSS scan is stopped by Firmware during the disassociation
7247 3.OBSS stop comamnd is added for debugging purpose*/
7248 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7249 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007250
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307251 if (pAdapter == NULL)
7252 {
7253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7254 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307255 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307256 }
7257 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7258 if (pMac == NULL)
7259 {
7260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7261 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307262 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307263 }
7264 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7265 }
7266 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307267 case WE_DUMP_ROAM_TIMER_LOG:
7268 {
7269 vos_dump_roam_time_log_service();
7270 break;
7271 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307272
Mukul Sharma84f27252014-07-14 18:11:42 +05307273 case WE_RESET_ROAM_TIMER_LOG:
7274 {
7275 vos_reset_roam_timer_log();
7276 break;
7277 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307278 case WE_GET_FW_LOGS:
7279 {
7280 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7281 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307282 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307283 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307284 break;
7285 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307286 case WE_GET_FW_MEMDUMP:
7287 {
7288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7289 "FW_MEM_DUMP requested ");
7290 get_fwr_memdump(dev,info,wrqu,extra);
7291 break;
7292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 default:
7294 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007295 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 break;
7297 }
7298 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307299 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 return ret;
7301}
7302
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307303static int iw_setnone_getnone(struct net_device *dev,
7304 struct iw_request_info *info,
7305 union iwreq_data *wrqu, char *extra)
7306{
7307 int ret;
7308
7309 vos_ssr_protect(__func__);
7310 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7311 vos_ssr_unprotect(__func__);
7312
7313 return ret;
7314}
7315
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307316void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7317{
7318 /*
7319 * Function to display HDD WMM information
7320 * for Tx Queues.
7321 * Prints globala as well as per client depending
7322 * whether the clients are registered or not.
7323 */
7324 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307325 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7326 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307327 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7328 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307329 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307330
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307331 for ( i=0; i< NUM_TX_QUEUES; i++)
7332 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307333 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307334 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307335 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307336 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307337
7338 for ( i=0; i< NUM_TX_QUEUES; i++) {
7339 if (tx_queue_count[i]) {
7340 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7341 i, tx_queue_count[i]);
7342 }
7343 }
7344
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307345 if(pSapCtx == NULL){
7346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7347 FL("psapCtx is NULL"));
7348 return;
7349 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307350
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307351 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307352 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7353 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307354 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307355 {
7356 hddLog(LOGE, "******STAIndex: %d*********", i);
7357 for ( j=0; j< NUM_TX_QUEUES; j++)
7358 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307359 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7360 {
7361 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307362 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7363 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307364 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7365 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307366 }
7367 }
7368 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307369 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307370
Katya Nigam1fd24402015-02-16 14:52:19 +05307371 if(pHddStaCtx == NULL){
7372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7373 FL("pHddStaCtx is NULL"));
7374 return;
7375 }
7376
7377 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7378 if(pPeerInfo == NULL){
7379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7380 FL("ppeerinfo is NULL"));
7381 return;
7382 }
7383
7384 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7385 {
7386 if(pPeerInfo->ibssStaInfo[i].isUsed)
7387 {
7388 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7389 for ( j=0; j< NUM_TX_QUEUES; j++)
7390 {
7391 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7392 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7393 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7394 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7395 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7396 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7397 }
7398 }
7399 }
7400
7401
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307402}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307403static int __iw_set_var_ints_getnone(struct net_device *dev,
7404 struct iw_request_info *info,
7405 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007406{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307407 hdd_adapter_t *pAdapter;
7408 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307409 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307410 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007411 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307412 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307413 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007414 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307415 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007416 int cmd = 0;
7417 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307418 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007419
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307420 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307421 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307422 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7424 "%s: NULL extra buffer pointer", __func__);
7425 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307426 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307427 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7428 if (NULL == pAdapter)
7429 {
7430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7431 "%s: Adapter is NULL",__func__);
7432 return -EINVAL;
7433 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307434 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307435 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7436 ret = wlan_hdd_validate_context(pHddCtx);
7437 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007438 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307439 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007440 }
Katya Nigameae74b62015-05-28 17:19:16 +05307441 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307442 {
Katya Nigameae74b62015-05-28 17:19:16 +05307443 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7444 if (NULL == hHal)
7445 {
7446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7447 "%s: Hal Context is NULL",__func__);
7448 return -EINVAL;
7449 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307450 }
7451 sub_cmd = wrqu->data.flags;
7452
7453 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7454
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007455
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007456 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7457 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7458 {
7459 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7460 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7461 {
7462 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7463 staId = pStaCtx->conn_info.staId[0];
7464 }
7465 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7466 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7467 {
7468 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7469 staId = pAPCtx->uBCStaId;
7470 }
7471 else
7472 {
7473 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7474 return 0;
7475 }
7476 }
7477
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 switch (sub_cmd)
7479 {
7480 case WE_LOG_DUMP_CMD:
7481 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307482 if(apps_args[0] == 26) {
7483 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7484 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7485 return 0;
7486 }
7487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007489 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 apps_args[3], apps_args[4]);
7491
7492 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7493 apps_args[3], apps_args[4]);
7494
7495 }
7496 break;
7497
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 case WE_P2P_NOA_CMD:
7499 {
7500 p2p_app_setP2pPs_t p2pNoA;
7501
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307502 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7503 hddLog(LOGE,
7504 FL("Setting NoA is not allowed in Device mode:%d"),
7505 pAdapter->device_mode);
7506 return -EINVAL;
7507 }
7508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 p2pNoA.opp_ps = apps_args[0];
7510 p2pNoA.ctWindow = apps_args[1];
7511 p2pNoA.duration = apps_args[2];
7512 p2pNoA.interval = apps_args[3];
7513 p2pNoA.count = apps_args[4];
7514 p2pNoA.single_noa_duration = apps_args[5];
7515 p2pNoA.psSelection = apps_args[6];
7516
7517 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7518 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007519 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7521
7522 hdd_setP2pPs(dev, &p2pNoA);
7523
7524 }
7525 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007526
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307527 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7528 {
7529 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7530 __func__, apps_args[0], apps_args[1]);
7531 vosTraceEnable(apps_args[0], apps_args[1]);
7532 }
7533 break;
7534
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007535 case WE_MTRACE_DUMP_CMD:
7536 {
7537 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7538 "bitmask_of_module %d ",
7539 __func__, apps_args[0], apps_args[1], apps_args[2],
7540 apps_args[3]);
7541 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7542 apps_args[2], apps_args[3]);
7543
7544 }
7545 break;
7546
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007547 case WE_MCC_CONFIG_CREDENTIAL :
7548 {
7549 cmd = 287; //Command should be updated if there is any change
7550 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007551 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007552 {
7553 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7554 }
7555 else
7556 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007557 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007558 return 0;
7559 }
7560 }
7561 break;
7562
7563 case WE_MCC_CONFIG_PARAMS :
7564 {
7565 cmd = 288; //command Should be updated if there is any change
7566 // in the Riva dump command
7567 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7568 }
7569 break;
7570
Chilam NG571c65a2013-01-19 12:27:36 +05307571#ifdef FEATURE_WLAN_TDLS
7572 case WE_TDLS_CONFIG_PARAMS :
7573 {
7574 tdls_config_params_t tdlsParams;
7575
Chilam Ng01120412013-02-19 18:32:21 -08007576 tdlsParams.tdls = apps_args[0];
7577 tdlsParams.tx_period_t = apps_args[1];
7578 tdlsParams.tx_packet_n = apps_args[2];
7579 tdlsParams.discovery_period_t = apps_args[3];
7580 tdlsParams.discovery_tries_n = apps_args[4];
7581 tdlsParams.idle_timeout_t = apps_args[5];
7582 tdlsParams.idle_packet_n = apps_args[6];
7583 tdlsParams.rssi_hysteresis = apps_args[7];
7584 tdlsParams.rssi_trigger_threshold = apps_args[8];
7585 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307586
Chilam Ng01120412013-02-19 18:32:21 -08007587 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307588 }
7589 break;
7590#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307591 case WE_CONFIGURE_MONITOR_MODE:
7592 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307593 v_U32_t magic = 0;
7594 struct completion cmpVar;
7595 long waitRet = 0;
7596
Katya Nigamf0511f62015-05-05 16:40:57 +05307597 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7598 if( pMonCtx == NULL )
7599 {
7600 hddLog(LOGE, "Monitor Context NULL");
7601 break;
7602 }
7603 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7604 __func__, apps_args[0], apps_args[1], apps_args[2],
7605 apps_args[3], apps_args[4]);
7606 /* Input Validation part of FW */
7607 pMonCtx->ChannelNo = apps_args[0];
7608 pMonCtx->ChannelBW = apps_args[1];
7609 pMonCtx->crcCheckEnabled = apps_args[2];
7610 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7611 pMonCtx->is80211to803ConReq = apps_args[4];
7612 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7613 if( pMonCtx->is80211to803ConReq )
7614 pAdapter->dev->type = ARPHRD_ETHER;
7615 else
7616 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7617 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7618 {
7619 hddLog(LOGE, "%s: Filtering data packets as management and control"
7620 " cannot be converted to 802.3 ",__func__);
7621 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7622 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307623 if (MON_MODE_START == pMonCtx->state) {
7624 magic = MON_MODE_MSG_MAGIC;
7625 init_completion(&cmpVar);
7626 if (VOS_STATUS_SUCCESS !=
7627 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7628 pMonCtx, hdd_monPostMsgCb)) {
7629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7630 FL("failed to post MON MODE REQ"));
7631 magic = 0;
7632 ret = -EIO;
7633 break;
7634 }
7635 waitRet = wait_for_completion_timeout(&cmpVar,
7636 MON_MODE_MSG_TIMEOUT);
7637 magic = 0;
7638 if (waitRet <= 0 ) {
7639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7640 FL("failed to wait on monitor mode completion %ld"),
7641 waitRet);
7642 }
7643 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307644 }
7645 break;
7646
7647 case WE_SET_MONITOR_MODE_FILTER:
7648 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307649 v_U32_t magic = 0;
7650 struct completion cmpVar;
7651 long waitRet = 0;
7652
Katya Nigamf0511f62015-05-05 16:40:57 +05307653 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7654 if( pMonCtx == NULL )
7655 {
7656 hddLog(LOGE, "Monitor Context NULL");
7657 break;
7658 }
7659 /* Input Validation Part of FW */
7660 pMonCtx->numOfMacFilters=1;
7661 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7662 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7663 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7664 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7665 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7666 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7667 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7668 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7669 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7670 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7671 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7672 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307673 if (MON_MODE_START == pMonCtx->state) {
7674 magic = MON_MODE_MSG_MAGIC;
7675 init_completion(&cmpVar);
7676 if (VOS_STATUS_SUCCESS !=
7677 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7678 pMonCtx, hdd_monPostMsgCb)) {
7679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7680 FL("failed to post MON MODE REQ"));
7681 magic = 0;
7682 ret = -EIO;
7683 break;
7684 }
7685 waitRet = wait_for_completion_timeout(&cmpVar,
7686 MON_MODE_MSG_TIMEOUT);
7687 magic = 0;
7688 if (waitRet <= 0 ) {
7689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7690 FL("failed to wait on monitor mode completion %ld"),
7691 waitRet);
7692 }
7693 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307694 }
7695 break;
7696
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 default:
7698 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007699 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7700 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 }
7702 break;
7703 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307704 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 return 0;
7706}
7707
Girish Gowlifb9758e2014-11-19 15:19:17 +05307708static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7709 struct iw_request_info *info,
7710 union iwreq_data *wrqu, char *extra)
7711{
7712 int ret;
7713 union iwreq_data u_priv_wrqu;
7714 int apps_args[MAX_VAR_ARGS] = {0};
7715 int num_args;
7716
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05307717 if (!capable(CAP_NET_ADMIN))
7718 {
7719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7720 FL("permission check failed"));
7721 return -EPERM;
7722 }
7723
Girish Gowlifb9758e2014-11-19 15:19:17 +05307724 /* helper function to get iwreq_data with compat handling. */
7725 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7726 {
7727 return -EINVAL;
7728 }
7729
7730 if (NULL == u_priv_wrqu.data.pointer)
7731 {
7732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7733 "%s: NULL data pointer", __func__);
7734 return -EINVAL;
7735 }
7736
7737 num_args = u_priv_wrqu.data.length;
7738 if (num_args > MAX_VAR_ARGS)
7739 {
7740 num_args = MAX_VAR_ARGS;
7741 }
7742
7743 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7744 (sizeof(int)) * num_args))
7745 {
7746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7747 "%s: failed to copy data from user buffer", __func__);
7748 return -EFAULT;
7749 }
7750
7751 vos_ssr_protect(__func__);
7752 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7753 (char *)&apps_args);
7754 vos_ssr_unprotect(__func__);
7755
7756 return ret;
7757}
7758
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307759int iw_set_var_ints_getnone(struct net_device *dev,
7760 struct iw_request_info *info,
7761 union iwreq_data *wrqu, char *extra)
7762{
7763 int ret;
7764 vos_ssr_protect(__func__);
7765 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7766 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007767
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307768 return ret;
7769}
7770
7771static int __iw_add_tspec(struct net_device *dev,
7772 struct iw_request_info *info,
7773 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007774{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307775 hdd_adapter_t *pAdapter;
7776 hdd_station_ctx_t *pHddStaCtx;
7777 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7779 int params[HDD_WLAN_WMM_PARAM_COUNT];
7780 sme_QosWmmTspecInfo tSpec;
7781 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307782 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307783 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307785 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307786 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7787 if (NULL == pAdapter)
7788 {
7789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7790 "%s: Adapter is NULL",__func__);
7791 return -EINVAL;
7792 }
7793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7794 ret = wlan_hdd_validate_context(pHddCtx);
7795 if (0 != ret)
7796 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307797 return ret;
7798 }
7799 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7800 if (NULL == pHddStaCtx)
7801 {
7802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7803 "%s: STA Context is NULL",__func__);
7804 return -EINVAL;
7805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 // make sure the application is sufficiently priviledged
7807 // note that the kernel will do this for "set" ioctls, but since
7808 // this ioctl wants to return status to user space it must be
7809 // defined as a "get" ioctl
7810 if (!capable(CAP_NET_ADMIN))
7811 {
7812 return -EPERM;
7813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007814 // we must be associated in order to add a tspec
7815 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7816 {
7817 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7818 return 0;
7819 }
7820
7821 // since we are defined to be a "get" ioctl, and since the number
7822 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307823 // will pass down in the iwreq_data, we must copy the "set" params.
7824 // We must handle the compat for iwreq_data in 32U/64K environment.
7825
7826 // helper fucntion to get iwreq_data with compat handling.
7827 if (hdd_priv_get_data(&s_priv_data, wrqu))
7828 {
7829 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7830 return 0;
7831 }
7832
7833 // make sure all params are correctly passed to function
7834 if ((NULL == s_priv_data.pointer) ||
7835 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7836 {
7837 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7838 return 0;
7839 }
7840
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307842 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 {
7844 // hmmm, can't get them
7845 return -EIO;
7846 }
7847
7848 // clear the tspec
7849 memset(&tSpec, 0, sizeof(tSpec));
7850
7851 // validate the handle
7852 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7853 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7854 {
7855 // that one is reserved
7856 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7857 return 0;
7858 }
7859
7860 // validate the TID
7861 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7862 {
7863 // out of range
7864 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7865 return 0;
7866 }
7867 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7868
7869 // validate the direction
7870 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7871 {
7872 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7873 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7874 break;
7875
7876 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7877 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7878 break;
7879
7880 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7881 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7882 break;
7883
7884 default:
7885 // unknown
7886 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7887 return 0;
7888 }
7889
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307890 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7891
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 // validate the user priority
7893 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7894 {
7895 // out of range
7896 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7897 return 0;
7898 }
7899 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307900 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7901 {
7902 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7903 return 0;
7904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007905
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7907 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7908 tSpec.ts_info.psb, tSpec.ts_info.up);
7909
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7911 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7912 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7913 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7914 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7915 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7916 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7917 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7918 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7919 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7920 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7921 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7922
7923 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7924
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307925 // Save the expected UAPSD settings by application, this will be needed
7926 // when re-negotiating UAPSD settings during BT Coex cases.
7927 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7928
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 // validate the ts info ack policy
7930 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7931 {
7932 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7933 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7934 break;
7935
7936 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7937 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7938 break;
7939
7940 default:
7941 // unknown
7942 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7943 return 0;
7944 }
7945
7946 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307947
7948 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 return 0;
7950}
7951
7952
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307953static int iw_add_tspec(struct net_device *dev,
7954 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 union iwreq_data *wrqu, char *extra)
7956{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307957 int ret;
7958
7959 vos_ssr_protect(__func__);
7960 ret = __iw_add_tspec(dev, info, wrqu, extra);
7961 vos_ssr_unprotect(__func__);
7962
7963 return ret;
7964}
7965
7966static int __iw_del_tspec(struct net_device *dev,
7967 struct iw_request_info *info,
7968 union iwreq_data *wrqu, char *extra)
7969{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307970 hdd_adapter_t *pAdapter;
7971 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 int *params = (int *)extra;
7973 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7974 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307975 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307977 ENTER();
7978
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7980 if (NULL == pAdapter)
7981 {
7982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7983 "%s: Adapter is NULL",__func__);
7984 return -EINVAL;
7985 }
7986
7987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7988 ret = wlan_hdd_validate_context(pHddCtx);
7989 if (0 != ret)
7990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307991 return ret;
7992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 // make sure the application is sufficiently priviledged
7994 // note that the kernel will do this for "set" ioctls, but since
7995 // this ioctl wants to return status to user space it must be
7996 // defined as a "get" ioctl
7997 if (!capable(CAP_NET_ADMIN))
7998 {
7999 return -EPERM;
8000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 // although we are defined to be a "get" ioctl, the params we require
8002 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8003 // is no need to copy the params from user space
8004
8005 // validate the handle
8006 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8007 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8008 {
8009 // that one is reserved
8010 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8011 return 0;
8012 }
8013
8014 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308015
8016 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 return 0;
8018}
8019
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308020static int iw_del_tspec(struct net_device *dev,
8021 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008022 union iwreq_data *wrqu, char *extra)
8023{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308024 int ret;
8025
8026 vos_ssr_protect(__func__);
8027 ret = __iw_del_tspec(dev, info, wrqu, extra);
8028 vos_ssr_unprotect(__func__);
8029
8030 return ret;
8031}
8032
8033
8034static int __iw_get_tspec(struct net_device *dev,
8035 struct iw_request_info *info,
8036 union iwreq_data *wrqu, char *extra)
8037{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308038 hdd_adapter_t *pAdapter;
8039 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 int *params = (int *)extra;
8041 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8042 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308043 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008044
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308045 ENTER();
8046
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 // although we are defined to be a "get" ioctl, the params we require
8048 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8049 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308050 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8051 if (NULL == pAdapter)
8052 {
8053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8054 "%s: Adapter is NULL",__func__);
8055 return -EINVAL;
8056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008057
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308058 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8059 ret = wlan_hdd_validate_context(pHddCtx);
8060 if (0 != ret)
8061 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308062 return ret;
8063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 // validate the handle
8065 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8066 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8067 {
8068 // that one is reserved
8069 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8070 return 0;
8071 }
8072
8073 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308074 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 return 0;
8076}
8077
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308078static int iw_get_tspec(struct net_device *dev,
8079 struct iw_request_info *info,
8080 union iwreq_data *wrqu, char *extra)
8081{
8082 int ret;
8083
8084 vos_ssr_protect(__func__);
8085 ret = __iw_get_tspec(dev, info, wrqu, extra);
8086 vos_ssr_unprotect(__func__);
8087
8088 return ret;
8089}
8090
Jeff Johnson295189b2012-06-20 16:38:30 -07008091#ifdef WLAN_FEATURE_VOWIFI_11R
8092//
8093//
8094// Each time the supplicant has the auth_request or reassoc request
8095// IEs ready. This is pushed to the driver. The driver will inturn use
8096// it to send out the auth req and reassoc req for 11r FT Assoc.
8097//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308098static int __iw_set_fties(struct net_device *dev,
8099 struct iw_request_info *info,
8100 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008101{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308102 hdd_adapter_t *pAdapter;
8103 hdd_station_ctx_t *pHddStaCtx;
8104 hdd_context_t *pHddCtx;
8105 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 //v_CONTEXT_t pVosContext;
8107
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308108 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308109 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8110 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8113 "%s: Adapter is NULL",__func__);
8114 return -EINVAL;
8115 }
8116 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8117 ret = wlan_hdd_validate_context(pHddCtx);
8118 if (0 != ret)
8119 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308120 return ret;
8121 }
8122 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8123 if (NULL == pHddStaCtx)
8124 {
8125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8126 "%s: STA Context is NULL",__func__);
8127 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 if (!wrqu->data.length)
8130 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008131 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 return -EINVAL;
8133 }
8134 if (wrqu->data.pointer == NULL)
8135 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008136 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 return -EINVAL;
8138 }
8139
8140 // Added for debug on reception of Re-assoc Req.
8141 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8142 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008143 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008145 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 }
8147
8148#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008149 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008150#endif
8151
8152 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008153 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 wrqu->data.length);
8155
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308156 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 return 0;
8158}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308159
8160static int iw_set_fties(struct net_device *dev,
8161 struct iw_request_info *info,
8162 union iwreq_data *wrqu, char *extra)
8163{
8164 int ret;
8165
8166 vos_ssr_protect(__func__);
8167 ret = __iw_set_fties(dev, info, wrqu, extra);
8168 vos_ssr_unprotect(__func__);
8169
8170 return ret;
8171}
Jeff Johnson295189b2012-06-20 16:38:30 -07008172#endif
8173
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308174static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008175 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008177{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308178 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008179 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308180 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008181 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308182 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008183 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8184 int idx;
8185 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008186
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308187 ENTER();
8188
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308189 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8190 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008191 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8193 "%s: Adapter is NULL",__func__);
8194 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008195 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308196 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8197 ret_val = wlan_hdd_validate_context(pHddCtx);
8198 if (0 != ret_val)
8199 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308200 return ret_val;
8201 }
8202 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8203 if (NULL == hHal)
8204 {
8205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8206 "%s: Hal Context is NULL",__func__);
8207 return -EINVAL;
8208 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308209 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8210 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308211#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008212
Amar Singhalf3a6e762013-02-19 15:06:50 -08008213 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8214 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008215 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008216 hddLog(VOS_TRACE_LEVEL_ERROR,
8217 "%s: vos_mem_alloc failed", __func__);
8218 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008219 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008220
8221 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8222
8223 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8224 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8225
8226 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8227 mc_addr_list_ptr->ulMulticastAddrCnt);
8228
8229 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008230 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008231 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8232 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8233
8234 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8235 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008236 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008237
Amar Singhalf3a6e762013-02-19 15:06:50 -08008238 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8239 vos_mem_free(mc_addr_list_ptr);
8240 if (eHAL_STATUS_SUCCESS != ret_val)
8241 {
8242 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8243 __func__);
8244 return -EINVAL;
8245 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308246#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308247 }
8248 else
8249 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008250
Amar Singhalf3a6e762013-02-19 15:06:50 -08008251 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8252 "%s: Set MC BC Filter Config request: %d suspend %d",
8253 __func__, pRequest->mcastBcastFilterSetting,
8254 pHddCtx->hdd_wlan_suspended);
8255
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308256 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008257
8258 if (pHddCtx->hdd_wlan_suspended)
8259 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008260 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8261 if (NULL == wlanRxpFilterParam)
8262 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308263 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008264 "%s: vos_mem_alloc failed", __func__);
8265 return -EINVAL;
8266 }
8267
Amar Singhalf3a6e762013-02-19 15:06:50 -08008268 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8269 pRequest->mcastBcastFilterSetting;
8270 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8271
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308272 hdd_conf_hostoffload(pAdapter, TRUE);
8273 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8274 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008275
8276 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8277 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308278 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008279 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8280 wlanRxpFilterParam->setMcstBcstFilter);
8281
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308282 if (eHAL_STATUS_SUCCESS !=
8283 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8284 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008285 {
8286 hddLog(VOS_TRACE_LEVEL_ERROR,
8287 "%s: Failure to execute set HW MC/BC Filter request",
8288 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008289 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008290 return -EINVAL;
8291 }
8292
c_hpothud3ce76d2014-10-28 10:34:13 +05308293 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8294 {
8295 pHddCtx->sus_res_mcastbcast_filter =
8296 pRequest->mcastBcastFilterSetting;
8297 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008298 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008300
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 return 0;
8303}
8304
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308305static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8306 struct iw_request_info *info,
8307 union iwreq_data *wrqu, char *extra)
8308{
8309 int ret;
8310
8311 vos_ssr_protect(__func__);
8312 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8313 vos_ssr_unprotect(__func__);
8314
8315 return ret;
8316}
8317
8318static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8319 struct iw_request_info *info,
8320 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008321{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308322 hdd_adapter_t *pAdapter;
8323 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308324 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308325 int ret = 0;
8326
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308327 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008328
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308329 if (!capable(CAP_NET_ADMIN))
8330 {
8331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8332 FL("permission check failed"));
8333 return -EPERM;
8334 }
8335
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308336 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8337 if (NULL == pAdapter)
8338 {
8339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8340 "%s: Adapter is NULL",__func__);
8341 return -EINVAL;
8342 }
8343
8344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8345 ret = wlan_hdd_validate_context(pHddCtx);
8346 if (0 != ret)
8347 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308348 return ret;
8349 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308350 //Reset the filter to INI value as we have to clear the dynamic filter
8351 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308353 //Configure FW with new setting
8354 if (pHddCtx->hdd_wlan_suspended)
8355 {
8356 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8357 if (NULL == wlanRxpFilterParam)
8358 {
8359 hddLog(VOS_TRACE_LEVEL_ERROR,
8360 "%s: vos_mem_alloc failed", __func__);
8361 return -EINVAL;
8362 }
8363
8364 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8365 pHddCtx->configuredMcastBcastFilter;
8366 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8367
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308368 hdd_conf_hostoffload(pAdapter, TRUE);
8369 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8370 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308371
8372 if (eHAL_STATUS_SUCCESS !=
8373 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8374 wlanRxpFilterParam))
8375 {
8376 hddLog(VOS_TRACE_LEVEL_ERROR,
8377 "%s: Failure to execute set HW MC/BC Filter request",
8378 __func__);
8379 vos_mem_free(wlanRxpFilterParam);
8380 return -EINVAL;
8381 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308382
8383 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8384 {
8385 pHddCtx->sus_res_mcastbcast_filter =
8386 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8387 }
8388
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308389 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308390 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 return 0;
8392}
8393
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308394
8395static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8396 struct iw_request_info *info,
8397 union iwreq_data *wrqu, char *extra)
8398{
8399 int ret;
8400
8401 vos_ssr_protect(__func__);
8402 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8403 vos_ssr_unprotect(__func__);
8404
8405 return ret;
8406}
8407
8408static int __iw_set_host_offload(struct net_device *dev,
8409 struct iw_request_info *info,
8410 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008411{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308412 hdd_adapter_t *pAdapter;
8413 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008414 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308416 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008417
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308418 ENTER();
8419
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308420 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8421 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008422 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8424 "%s: Adapter is NULL",__func__);
8425 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008426 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308427 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8428 ret = wlan_hdd_validate_context(pHddCtx);
8429 if (0 != ret)
8430 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308431 return ret;
8432 }
8433
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 /* Debug display of request components. */
8435 switch (pRequest->offloadType)
8436 {
8437 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008438 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 switch (pRequest->enableOrDisable)
8440 {
8441 case WLAN_OFFLOAD_DISABLE:
8442 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8443 break;
8444 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8445 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8446 case WLAN_OFFLOAD_ENABLE:
8447 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8448 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8449 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8450 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8451 }
8452 break;
8453
8454 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008455 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008456 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 switch (pRequest->enableOrDisable)
8458 {
8459 case WLAN_OFFLOAD_DISABLE:
8460 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8461 break;
8462 case WLAN_OFFLOAD_ENABLE:
8463 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8464 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8465 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8466 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8467 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8468 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8469 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8470 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8471 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8472 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8473 }
8474 }
8475
8476 /* Execute offload request. The reason that we can copy the request information
8477 from the ioctl structure to the SME structure is that they are laid out
8478 exactly the same. Otherwise, each piece of information would have to be
8479 copied individually. */
8480 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008481 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8482 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 __func__);
8486 return -EINVAL;
8487 }
8488
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308489 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 return 0;
8491}
8492
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308493static int iw_set_host_offload(struct net_device *dev,
8494 struct iw_request_info *info,
8495 union iwreq_data *wrqu, char *extra)
8496{
8497 int ret;
8498
8499 vos_ssr_protect(__func__);
8500 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8501 vos_ssr_unprotect(__func__);
8502
8503 return ret;
8504}
8505
8506static int __iw_set_keepalive_params(struct net_device *dev,
8507 struct iw_request_info *info,
8508 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008509{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308510 hdd_adapter_t *pAdapter;
8511 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008512 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308514 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008515
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308516 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308517 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8518 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8521 "%s: Adapter is NULL",__func__);
8522 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308524 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8525 ret = wlan_hdd_validate_context(pHddCtx);
8526 if (0 != ret)
8527 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308528 return ret;
8529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008531 hddLog(VOS_TRACE_LEVEL_INFO,
8532 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8533 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008534
8535 switch (pRequest->packetType)
8536 {
8537 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008538 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 break;
8540
8541 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8542
Arif Hussain6d2a3322013-11-17 19:50:10 -08008543 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008544 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545
8546 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8547 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8548 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8549
8550 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8551 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8552 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8553
8554 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8555 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8556 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8557 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8558 break;
8559
8560 }
8561
8562 /* Execute keep alive request. The reason that we can copy the request information
8563 from the ioctl structure to the SME structure is that they are laid out
8564 exactly the same. Otherwise, each piece of information would have to be
8565 copied individually. */
8566 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8567
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308568 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8569 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008570
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008571 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008572 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008574 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 __func__);
8576 return -EINVAL;
8577 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308578 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 return 0;
8580}
8581
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308582static int iw_set_keepalive_params(struct net_device *dev,
8583 struct iw_request_info *info,
8584 union iwreq_data *wrqu, char *extra)
8585{
8586 int ret;
8587 vos_ssr_protect(__func__);
8588 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8589 vos_ssr_unprotect(__func__);
8590
8591 return ret;
8592}
8593
Jeff Johnson295189b2012-06-20 16:38:30 -07008594#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008595int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008596 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008597{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008598 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8599 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 int i=0;
8601
8602 if (pHddCtx->cfg_ini->disablePacketFilter)
8603 {
8604 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008605 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 return 0;
8607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008608 /* Debug display of request components. */
8609 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008610 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008611
8612 switch (pRequest->filterAction)
8613 {
8614 case HDD_RCV_FILTER_SET:
8615 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008616 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008617
8618 packetFilterSetReq.filterId = pRequest->filterId;
8619 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8620 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 __func__, pRequest->numParams);
8623 return -EINVAL;
8624 }
8625 packetFilterSetReq.numFieldParams = pRequest->numParams;
8626 packetFilterSetReq.coalesceTime = 0;
8627 packetFilterSetReq.filterType = 1;
8628 for (i=0; i < pRequest->numParams; i++)
8629 {
8630 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8631 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8632 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8633 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8634 packetFilterSetReq.paramsData[i].reserved = 0;
8635
Arif Hussain6d2a3322013-11-17 19:50:10 -08008636 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8638 packetFilterSetReq.filterType);
8639
Arif Hussain6d2a3322013-11-17 19:50:10 -08008640 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008641 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05308642 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
8643 (pRequest->paramsData[i].dataLength))
8644 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008645
8646 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8647 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8648 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8649 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8650
Arif Hussain6d2a3322013-11-17 19:50:10 -08008651 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8653 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8654 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8655
Arif Hussain6d2a3322013-11-17 19:50:10 -08008656 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8658 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8659 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8660 }
8661
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008662 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 __func__);
8666 return -EINVAL;
8667 }
8668
8669 break;
8670
8671 case HDD_RCV_FILTER_CLEAR:
8672
Arif Hussain6d2a3322013-11-17 19:50:10 -08008673 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008674 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008675 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008676 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008678 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 __func__);
8680 return -EINVAL;
8681 }
8682 break;
8683
8684 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008685 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008686 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 return -EINVAL;
8688 }
8689 return 0;
8690}
8691
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308692int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8693 tANI_U8 sessionId)
8694{
8695 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8696 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8697
8698 if (NULL == pHddCtx)
8699 {
8700 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8701 return -EINVAL;
8702 }
8703
8704 if (pHddCtx->isLogpInProgress)
8705 {
8706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8707 "%s:LOGP in Progress. Ignore!!!", __func__);
8708 return -EBUSY;
8709 }
8710
8711 if (pHddCtx->cfg_ini->disablePacketFilter)
8712 {
8713 hddLog(VOS_TRACE_LEVEL_ERROR,
8714 "%s: Packet Filtering Disabled. Returning ",
8715 __func__ );
8716 return -EINVAL;
8717 }
8718
8719 switch (filterType)
8720 {
8721 /* For setting IPV6 MC and UC Filter we need to configure
8722 * 2 filters, one for MC and one for UC.
8723 * The Filter ID shouldn't be swapped, which results in making
8724 * UC Filter ineffective.
8725 * We have Hardcode all the values
8726 *
8727 * Reason for a seperate UC filter is because, driver need to
8728 * specify the FW that the specific filter is for unicast
8729 * otherwise FW will not pass the unicast frames by default
8730 * through the filter. This is required to avoid any performance
8731 * hits when no unicast filter is set and only MC/BC are set.
8732 * The way driver informs host is by using the MAC protocol
8733 * layer, CMP flag set to MAX, CMP Data set to 1.
8734 */
8735
8736 case HDD_FILTER_IPV6_MC_UC:
8737 /* Setting IPV6 MC Filter below
8738 */
8739 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8740 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8741 packetFilterSetReq.numFieldParams = 2;
8742 packetFilterSetReq.paramsData[0].protocolLayer =
8743 HDD_FILTER_PROTO_TYPE_MAC;
8744 packetFilterSetReq.paramsData[0].cmpFlag =
8745 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8746 packetFilterSetReq.paramsData[0].dataOffset =
8747 WLAN_HDD_80211_FRM_DA_OFFSET;
8748 packetFilterSetReq.paramsData[0].dataLength = 1;
8749 packetFilterSetReq.paramsData[0].compareData[0] =
8750 HDD_IPV6_MC_CMP_DATA;
8751
8752 packetFilterSetReq.paramsData[1].protocolLayer =
8753 HDD_FILTER_PROTO_TYPE_ARP;
8754 packetFilterSetReq.paramsData[1].cmpFlag =
8755 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8756 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8757 packetFilterSetReq.paramsData[1].dataLength = 2;
8758 packetFilterSetReq.paramsData[1].compareData[0] =
8759 HDD_IPV6_CMP_DATA_0;
8760 packetFilterSetReq.paramsData[1].compareData[1] =
8761 HDD_IPV6_CMP_DATA_1;
8762
8763
8764 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8765 &packetFilterSetReq, sessionId))
8766 {
8767 hddLog(VOS_TRACE_LEVEL_ERROR,
8768 "%s: Failure to execute Set IPv6 Mulicast Filter",
8769 __func__);
8770 return -EINVAL;
8771 }
8772
8773 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8774
8775 /*
8776 * Setting IPV6 UC Filter below
8777 */
8778 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8779 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8780 packetFilterSetReq.numFieldParams = 2;
8781 packetFilterSetReq.paramsData[0].protocolLayer =
8782 HDD_FILTER_PROTO_TYPE_MAC;
8783 packetFilterSetReq.paramsData[0].cmpFlag =
8784 HDD_FILTER_CMP_TYPE_MAX;
8785 packetFilterSetReq.paramsData[0].dataOffset = 0;
8786 packetFilterSetReq.paramsData[0].dataLength = 1;
8787 packetFilterSetReq.paramsData[0].compareData[0] =
8788 HDD_IPV6_UC_CMP_DATA;
8789
8790 packetFilterSetReq.paramsData[1].protocolLayer =
8791 HDD_FILTER_PROTO_TYPE_ARP;
8792 packetFilterSetReq.paramsData[1].cmpFlag =
8793 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8794 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8795 packetFilterSetReq.paramsData[1].dataLength = 2;
8796 packetFilterSetReq.paramsData[1].compareData[0] =
8797 HDD_IPV6_CMP_DATA_0;
8798 packetFilterSetReq.paramsData[1].compareData[1] =
8799 HDD_IPV6_CMP_DATA_1;
8800
8801 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8802 &packetFilterSetReq, sessionId))
8803 {
8804 hddLog(VOS_TRACE_LEVEL_ERROR,
8805 "%s: Failure to execute Set IPv6 Unicast Filter",
8806 __func__);
8807 return -EINVAL;
8808 }
8809
8810 break;
8811
8812 case HDD_FILTER_IPV6_MC:
8813 /*
8814 * IPV6 UC Filter might be already set,
8815 * clear the UC Filter. As the Filter
8816 * IDs are static, we can directly clear it.
8817 */
8818 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8819 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8820 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8821 &packetFilterClrReq, sessionId))
8822 {
8823 hddLog(VOS_TRACE_LEVEL_ERROR,
8824 "%s: Failure to execute Clear IPv6 Unicast Filter",
8825 __func__);
8826 return -EINVAL;
8827 }
8828
8829 /*
8830 * Setting IPV6 MC Filter below
8831 */
8832 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8833 packetFilterSetReq.numFieldParams = 2;
8834 packetFilterSetReq.paramsData[0].protocolLayer =
8835 HDD_FILTER_PROTO_TYPE_MAC;
8836 packetFilterSetReq.paramsData[0].cmpFlag =
8837 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8838 packetFilterSetReq.paramsData[0].dataOffset =
8839 WLAN_HDD_80211_FRM_DA_OFFSET;
8840 packetFilterSetReq.paramsData[0].dataLength = 1;
8841 packetFilterSetReq.paramsData[0].compareData[0] =
8842 HDD_IPV6_MC_CMP_DATA;
8843
8844 packetFilterSetReq.paramsData[1].protocolLayer =
8845 HDD_FILTER_PROTO_TYPE_ARP;
8846 packetFilterSetReq.paramsData[1].cmpFlag =
8847 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8848 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8849 packetFilterSetReq.paramsData[1].dataLength = 2;
8850 packetFilterSetReq.paramsData[1].compareData[0] =
8851 HDD_IPV6_CMP_DATA_0;
8852 packetFilterSetReq.paramsData[1].compareData[1] =
8853 HDD_IPV6_CMP_DATA_1;
8854
8855
8856 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8857 &packetFilterSetReq, sessionId))
8858 {
8859 hddLog(VOS_TRACE_LEVEL_ERROR,
8860 "%s: Failure to execute Set IPv6 Multicast Filter",
8861 __func__);
8862 return -EINVAL;
8863 }
8864 break;
8865
8866 default :
8867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8868 "%s: Packet Filter Request: Invalid",
8869 __func__);
8870 return -EINVAL;
8871 }
8872 return 0;
8873}
8874
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308875void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008876{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308877 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308878 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008879 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308880 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008881
Yue Ma3ede6052013-08-29 00:33:26 -07008882 if (NULL == pHddCtx)
8883 {
8884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8885 return;
8886 }
8887
8888 hHal = pHddCtx->hHal;
8889
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308890 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8893 return;
8894 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308895
8896 /* Check if INI is enabled or not, other wise just return
8897 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308898 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308899 {
8900 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8901 if (NULL == pMulticastAddrs)
8902 {
8903 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8904 return;
8905 }
8906
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 if (set)
8908 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308909 /* Following pre-conditions should be satisfied before wei
8910 * configure the MC address list.
8911 */
8912 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8913 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8914 && pAdapter->mc_addr_list.mc_cnt
8915 && (eConnectionState_Associated ==
8916 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8917 {
8918 pMulticastAddrs->ulMulticastAddrCnt =
8919 pAdapter->mc_addr_list.mc_cnt;
8920 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8921 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008922 memcpy(pMulticastAddrs->multicastAddr[i],
8923 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308924 sizeof(pAdapter->mc_addr_list.addr[i]));
8925 hddLog(VOS_TRACE_LEVEL_INFO,
8926 "%s: %s multicast filter: addr ="
8927 MAC_ADDRESS_STR,
8928 __func__, set ? "setting" : "clearing",
8929 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8930 }
8931 /* Set multicast filter */
8932 sme_8023MulticastList(hHal, pAdapter->sessionId,
8933 pMulticastAddrs);
8934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308936 else
8937 {
8938 /* Need to clear only if it was previously configured
8939 */
8940 if (pAdapter->mc_addr_list.isFilterApplied)
8941 {
8942 pMulticastAddrs->ulMulticastAddrCnt = 0;
8943 sme_8023MulticastList(hHal, pAdapter->sessionId,
8944 pMulticastAddrs);
8945 }
8946
8947 }
8948 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008949 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308951 else
8952 {
8953 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308954 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308955 }
8956 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008957}
8958
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308959static int __iw_set_packet_filter_params(struct net_device *dev,
8960 struct iw_request_info *info,
8961 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308962{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308963 hdd_adapter_t *pAdapter;
8964 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008965 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308966 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308967 struct iw_point s_priv_data;
8968
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308969 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05308970
8971 if (!capable(CAP_NET_ADMIN))
8972 {
8973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8974 FL("permission check failed"));
8975 return -EPERM;
8976 }
8977
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308978 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8979 if (NULL == pAdapter)
8980 {
8981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8982 "%s: Adapter is NULL",__func__);
8983 return -EINVAL;
8984 }
8985 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8986 ret = wlan_hdd_validate_context(pHddCtx);
8987 if (0 != ret)
8988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308989 return ret;
8990 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308991 if (hdd_priv_get_data(&s_priv_data, wrqu))
8992 {
8993 return -EINVAL;
8994 }
8995
8996 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8997 {
8998 return -EINVAL;
8999 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009000
Arif Hussain0273cba2014-01-07 20:58:29 -08009001 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309002 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9003 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009004 if (NULL == pRequest)
9005 {
9006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9007 "mem_alloc_copy_from_user_helper fail");
9008 return -ENOMEM;
9009 }
9010
9011 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
9012 kfree(pRequest);
9013
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309014 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009015 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009016}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309017
9018static int iw_set_packet_filter_params(struct net_device *dev,
9019 struct iw_request_info *info,
9020 union iwreq_data *wrqu, char *extra)
9021{
9022 int ret;
9023
9024 vos_ssr_protect(__func__);
9025 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9026 vos_ssr_unprotect(__func__);
9027
9028 return ret;
9029}
Jeff Johnson295189b2012-06-20 16:38:30 -07009030#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309031static int __iw_get_statistics(struct net_device *dev,
9032 struct iw_request_info *info,
9033 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009034{
9035
9036 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9037 eHalStatus status = eHAL_STATUS_SUCCESS;
9038 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309039 hdd_adapter_t *pAdapter;
9040 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309042 int tlen = 0, ret = 0;
9043 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009044
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309045 tCsrGlobalClassAStatsInfo *aStats;
9046 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009047
9048 ENTER();
9049
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309050 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9051 if (NULL == pAdapter)
9052 {
9053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9054 "%s: Adapter is NULL",__func__);
9055 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309057 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9058 ret = wlan_hdd_validate_context(pHddCtx);
9059 if (0 != ret)
9060 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309061 return ret;
9062 }
9063 pStats = &(pAdapter->hdd_stats.summary_stat);
9064 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9065 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9067
9068 wrqu->txpower.value = 0;
9069 }
9070 else {
9071 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9072 SME_SUMMARY_STATS |
9073 SME_GLOBAL_CLASSA_STATS |
9074 SME_GLOBAL_CLASSB_STATS |
9075 SME_GLOBAL_CLASSC_STATS |
9076 SME_GLOBAL_CLASSD_STATS |
9077 SME_PER_STA_STATS,
9078 hdd_StatisticsCB, 0, FALSE,
9079 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9080
9081 if (eHAL_STATUS_SUCCESS != status)
9082 {
9083 hddLog(VOS_TRACE_LEVEL_ERROR,
9084 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009085 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 return -EINVAL;
9087 }
9088
9089 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309090 if (NULL == pWextState)
9091 {
9092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9093 "%s: pWextState is NULL",__func__);
9094 return -EINVAL;
9095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009096
9097 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9098 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9099 {
9100 hddLog(VOS_TRACE_LEVEL_ERROR,
9101 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009102 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 /*Remove the SME statistics list by passing NULL in callback argument*/
9104 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9105 SME_SUMMARY_STATS |
9106 SME_GLOBAL_CLASSA_STATS |
9107 SME_GLOBAL_CLASSB_STATS |
9108 SME_GLOBAL_CLASSC_STATS |
9109 SME_GLOBAL_CLASSD_STATS |
9110 SME_PER_STA_STATS,
9111 NULL, 0, FALSE,
9112 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9113
9114 return -EINVAL;
9115 }
9116 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9117 (tANI_U8) sizeof (pStats->retry_cnt),
9118 (char*) &(pStats->retry_cnt[0]),
9119 tlen);
9120
9121 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9122 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9123 (char*) &(pStats->multiple_retry_cnt[0]),
9124 tlen);
9125
9126 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9127 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9128 (char*) &(pStats->tx_frm_cnt[0]),
9129 tlen);
9130
9131 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9132 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9133 (char*) &(pStats->rx_frm_cnt),
9134 tlen);
9135
9136 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9137 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9138 (char*) &(pStats->frm_dup_cnt),
9139 tlen);
9140
9141 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9142 (tANI_U8) sizeof (pStats->fail_cnt),
9143 (char*) &(pStats->fail_cnt[0]),
9144 tlen);
9145
9146 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9147 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9148 (char*) &(pStats->rts_fail_cnt),
9149 tlen);
9150
9151 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9152 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9153 (char*) &(pStats->ack_fail_cnt),
9154 tlen);
9155
9156 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9157 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9158 (char*) &(pStats->rts_succ_cnt),
9159 tlen);
9160
9161 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9162 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9163 (char*) &(pStats->rx_discard_cnt),
9164 tlen);
9165
9166 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9167 (tANI_U8) sizeof (pStats->rx_error_cnt),
9168 (char*) &(pStats->rx_error_cnt),
9169 tlen);
9170
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009171 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009172 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009173 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 tlen);
9175
9176 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9177 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9178 (char*) &(dStats->rx_byte_cnt),
9179 tlen);
9180
9181 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9182 (tANI_U8) sizeof (dStats->rx_rate),
9183 (char*) &(dStats->rx_rate),
9184 tlen);
9185
9186 /* Transmit rate, in units of 500 kbit/sec */
9187 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9188 (tANI_U8) sizeof (aStats->tx_rate),
9189 (char*) &(aStats->tx_rate),
9190 tlen);
9191
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009192 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9193 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9194 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009195 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009196 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9197 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9198 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009199 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009200 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9201 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9202 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009203 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009204 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9205 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9206 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009207 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009208 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9209 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9210 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009211 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009212 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9213 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9214 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009215 tlen);
9216
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 wrqu->data.length = tlen;
9218
9219 }
9220
9221 EXIT();
9222
9223 return 0;
9224}
9225
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309226static int iw_get_statistics(struct net_device *dev,
9227 struct iw_request_info *info,
9228 union iwreq_data *wrqu, char *extra)
9229{
9230 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009231
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309232 vos_ssr_protect(__func__);
9233 ret = __iw_get_statistics(dev, info, wrqu, extra);
9234 vos_ssr_unprotect(__func__);
9235
9236 return ret;
9237}
Jeff Johnson295189b2012-06-20 16:38:30 -07009238#ifdef FEATURE_WLAN_SCAN_PNO
9239
9240/*Max Len for PNO notification*/
9241#define MAX_PNO_NOTIFY_LEN 100
9242void found_pref_network_cb (void *callbackContext,
9243 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9244{
9245 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9246 union iwreq_data wrqu;
9247 char buf[MAX_PNO_NOTIFY_LEN+1];
9248
9249 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9250 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9251
9252 // create the event
9253 memset(&wrqu, 0, sizeof(wrqu));
9254 memset(buf, 0, sizeof(buf));
9255
9256 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9257 pPrefNetworkFoundInd->ssId.ssId,
9258 (unsigned int)pPrefNetworkFoundInd->rssi);
9259
9260 wrqu.data.pointer = buf;
9261 wrqu.data.length = strlen(buf);
9262
9263 // send the event
9264
9265 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9266
9267}
9268
9269
9270/*string based input*/
9271VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9272 union iwreq_data *wrqu, char *extra, int nOffset)
9273{
9274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309275 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009276 /* pnoRequest is a large struct, so we make it static to avoid stack
9277 overflow. This API is only invoked via ioctl, so it is
9278 serialized by the kernel rtnl_lock and hence does not need to be
9279 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309280 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 char *ptr;
9282 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309283 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9285
9286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9287 "PNO data len %d data %s",
9288 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009289 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009290
9291 if (wrqu->data.length <= nOffset )
9292 {
9293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9294 return VOS_STATUS_E_FAILURE;
9295 }
9296
9297 pnoRequest.enable = 0;
9298 pnoRequest.ucNetworksCount = 0;
9299 /*-----------------------------------------------------------------------
9300 Input is string based and expected to be like this:
9301
9302 <enabled> <netw_count>
9303 for each network:
9304 <ssid_len> <ssid> <authentication> <encryption>
9305 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9306 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9307
9308 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009309 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 -07009310
9311 this translates into:
9312 -----------------------------
9313 enable PNO
9314 look for 2 networks:
9315 test - with authentication type 0 and encryption type 0,
9316 that can be found on 3 channels: 1 6 and 11 ,
9317 SSID bcast type is unknown (directed probe will be sent if AP not found)
9318 and must meet -40dBm RSSI
9319
9320 test2 - with auth and enrytption type 4/4
9321 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9322 bcast type is non-bcast (directed probe will be sent)
9323 and must not meet any RSSI threshold
9324
Jeff Johnson8301aa12013-03-28 14:27:29 -07009325 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009327 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009328
Wilson Yang623f6592013-10-08 16:33:37 -07009329 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9330 {
9331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9332 "PNO enable input is not valid %s",ptr);
9333 return VOS_STATUS_E_FAILURE;
9334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009335
9336 if ( 0 == pnoRequest.enable )
9337 {
9338 /*Disable PNO*/
9339 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309340 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9341 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 pAdapter->sessionId,
9343 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309344 if (eHAL_STATUS_SUCCESS != status)
9345 {
9346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9347 "%s: failed to disable PNO", __func__);
9348 return VOS_STATUS_E_FAILURE;
9349 }
9350 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 return VOS_STATUS_SUCCESS;
9352 }
9353
c_hpothu37f21312014-04-09 21:49:54 +05309354 if (TRUE == pHddCtx->isPnoEnable)
9355 {
9356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9357 FL("already PNO is enabled"));
9358 return -EBUSY;
9359 }
9360 pHddCtx->isPnoEnable = TRUE;
9361
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009363
9364 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9365 {
9366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9367 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309368 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009370
9371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9372 "PNO enable %d networks count %d offset %d",
9373 pnoRequest.enable,
9374 pnoRequest.ucNetworksCount,
9375 nOffset);
9376
9377 /* Parameters checking:
9378 ucNetworksCount has to be larger than 0*/
9379 if (( 0 == pnoRequest.ucNetworksCount ) ||
9380 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9381 {
9382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309383 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 }
9385
9386 ptr += nOffset;
9387
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309388 pnoRequest.aNetworks =
9389 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9390 if (pnoRequest.aNetworks == NULL)
9391 {
9392 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9393 FL("failed to allocate memory aNetworks %u"),
9394 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9395 goto error;
9396 }
9397 vos_mem_zero(pnoRequest.aNetworks,
9398 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9399
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9401 {
9402
9403 pnoRequest.aNetworks[i].ssId.length = 0;
9404
Wilson Yang623f6592013-10-08 16:33:37 -07009405 ucParams = sscanf(ptr,"%hhu %n",
9406 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9407
9408 if (1 != ucParams)
9409 {
9410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9411 "PNO ssid length input is not valid %s",ptr);
9412 return VOS_STATUS_E_FAILURE;
9413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009414
9415 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9416 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9417 {
9418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9419 "SSID Len %d is not correct for network %d",
9420 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309421 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 }
9423
9424 /*Advance to SSID*/
9425 ptr += nOffset;
9426
Jeff Johnson8301aa12013-03-28 14:27:29 -07009427 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009428 pnoRequest.aNetworks[i].ssId.length);
9429 ptr += pnoRequest.aNetworks[i].ssId.length;
9430
Jeff Johnson02797792013-10-26 19:17:13 -07009431 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009432 &(pnoRequest.aNetworks[i].authentication),
9433 &(pnoRequest.aNetworks[i].encryption),
9434 &(pnoRequest.aNetworks[i].ucChannelCount),
9435 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009436
Wilson Yang623f6592013-10-08 16:33:37 -07009437 if ( 3 != ucParams )
9438 {
9439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9440 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309441 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009442 }
9443
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009445 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009446 "auth %d encry %d channel count %d offset %d",
9447 pnoRequest.aNetworks[i].ssId.length,
9448 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9449 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9450 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9451 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9452 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9453 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9454 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9455 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9456 pnoRequest.aNetworks[i].authentication,
9457 pnoRequest.aNetworks[i].encryption,
9458 pnoRequest.aNetworks[i].ucChannelCount,
9459 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009460
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 /*Advance to channel list*/
9462 ptr += nOffset;
9463
Wilson Yang623f6592013-10-08 16:33:37 -07009464 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 {
9466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9467 "Incorrect number of channels");
9468 return VOS_STATUS_E_FAILURE;
9469 }
9470
9471 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9472 {
9473 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9474 {
Wilson Yang623f6592013-10-08 16:33:37 -07009475 if (1 != sscanf(ptr,"%hhu %n",
9476 &(pnoRequest.aNetworks[i].aChannels[j]),
9477 &nOffset))
9478 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9479 "PNO network channel input is not valid %s",ptr);
9480 return VOS_STATUS_E_FAILURE;
9481 }
9482 /*Advance to next channel number*/
9483 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 }
9485 }
9486
Jeff Johnson02797792013-10-26 19:17:13 -07009487 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009488 &(pnoRequest.aNetworks[i].bcastNetwType),
9489 &nOffset))
9490 {
9491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9492 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309493 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009495
9496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9497 "PNO bcastNetwType %d offset %d",
9498 pnoRequest.aNetworks[i].bcastNetwType,
9499 nOffset );
9500
9501 /*Advance to rssi Threshold*/
9502 ptr += nOffset;
9503
Wilson Yang623f6592013-10-08 16:33:37 -07009504 if (1 != sscanf(ptr,"%hhu %n",
9505 &(pnoRequest.aNetworks[i].rssiThreshold),
9506 &nOffset))
9507 {
9508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9509 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309510 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009512
9513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9514 "PNO rssi %d offset %d",
9515 pnoRequest.aNetworks[i].rssiThreshold,
9516 nOffset );
9517 /*Advance to next network*/
9518 ptr += nOffset;
9519 }/*For ucNetworkCount*/
9520
9521 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009522 &(pnoRequest.scanTimers.ucScanTimersCount),
9523 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009524
9525 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009526 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 {
9528 ptr += nOffset;
9529
Jeff Johnson8301aa12013-03-28 14:27:29 -07009530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9531 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 pnoRequest.scanTimers.ucScanTimersCount,
9533 nOffset );
9534
9535 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9536 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309539 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 }
9541
9542 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9543 {
Jeff Johnson02797792013-10-26 19:17:13 -07009544 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9546 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9547 &nOffset);
9548
Wilson Yang623f6592013-10-08 16:33:37 -07009549 if (2 != ucParams)
9550 {
9551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9552 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309553 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009554 }
9555
Jeff Johnson8301aa12013-03-28 14:27:29 -07009556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9557 "PNO Timer value %d Timer repeat %d offset %d",
9558 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9560 nOffset );
9561
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 ptr += nOffset;
9563 }
9564
9565 }
9566 else
9567 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9569 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9571
9572 /*Scan timers defaults to 5 minutes*/
9573 pnoRequest.scanTimers.ucScanTimersCount = 1;
9574 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9575 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9576 }
9577
Wilson Yang623f6592013-10-08 16:33:37 -07009578 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009579
9580 pnoRequest.modePNO = ucMode;
9581 /*for LA we just expose suspend option*/
9582 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9583 {
9584 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9585 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309586 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9587 if (pnoRequest.p24GProbeTemplate == NULL){
9588 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9589 FL("failed to allocate memory p24GProbeTemplate %u"),
9590 SIR_PNO_MAX_PB_REQ_SIZE);
9591 goto error;
9592 }
9593
9594 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9595 if (pnoRequest.p5GProbeTemplate == NULL){
9596 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9597 FL("failed to allocate memory p5GProbeTemplate %u"),
9598 SIR_PNO_MAX_PB_REQ_SIZE);
9599 goto error;
9600 }
9601
9602 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9603 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009604
c_hpothu37f21312014-04-09 21:49:54 +05309605 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 pAdapter->sessionId,
9607 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309608 if (eHAL_STATUS_SUCCESS == status)
9609 {
9610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9611 "%s: PNO enabled", __func__);
9612 return VOS_STATUS_SUCCESS;
9613 }
9614error:
9615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9616 "%s: Failed to enable PNO", __func__);
9617 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309618 if (pnoRequest.aNetworks)
9619 vos_mem_free(pnoRequest.aNetworks);
9620 if (pnoRequest.p24GProbeTemplate)
9621 vos_mem_free(pnoRequest.p24GProbeTemplate);
9622 if (pnoRequest.p5GProbeTemplate)
9623 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309624 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009625}/*iw_set_pno*/
9626
9627VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9628 union iwreq_data *wrqu, char *extra, int nOffset)
9629{
9630 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9631 v_U8_t rssiThreshold = 0;
9632 v_U8_t nRead;
9633
Arif Hussain7adce1b2013-11-11 22:59:34 -08009634 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 &rssiThreshold);
9636
9637 if ( 1 != nRead )
9638 {
9639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9640 "Incorrect format");
9641 return VOS_STATUS_E_FAILURE;
9642 }
9643
9644 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9645 return VOS_STATUS_SUCCESS;
9646}
9647
9648
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309649static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 struct iw_request_info *info,
9651 union iwreq_data *wrqu, char *extra)
9652{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309653 hdd_adapter_t *pAdapter;
9654 hdd_context_t *pHddCtx;
9655 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309656 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309657
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309658 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309659 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9660 if (NULL == pAdapter)
9661 {
9662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9663 "%s: Adapter is NULL",__func__);
9664 return -EINVAL;
9665 }
9666
9667 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9668 ret = wlan_hdd_validate_context(pHddCtx);
9669 if (0 != ret)
9670 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309671 return ret;
9672 }
9673
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009674
9675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009677
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309678 status = iw_set_pno(dev,info,wrqu,extra,0);
9679
9680 EXIT();
9681 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009682}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309683
9684static int iw_set_pno_priv(struct net_device *dev,
9685 struct iw_request_info *info,
9686 union iwreq_data *wrqu, char *extra)
9687{
9688 int ret;
9689
9690 vos_ssr_protect(__func__);
9691 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9692 vos_ssr_unprotect(__func__);
9693
9694 return ret;
9695}
Jeff Johnson295189b2012-06-20 16:38:30 -07009696#endif /*FEATURE_WLAN_SCAN_PNO*/
9697
9698//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309699int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009700{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309701 hdd_adapter_t *pAdapter;
9702 tHalHandle hHal;
9703 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309704 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309705 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309706 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309708 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309709 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309710 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309711
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309712 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309713 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9714 if (NULL == pAdapter)
9715 {
9716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9717 "%s: Adapter is NULL",__func__);
9718 return -EINVAL;
9719 }
9720 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9721 retval = wlan_hdd_validate_context(pHddCtx);
9722 if (0 != retval)
9723 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309724 return retval;
9725 }
9726 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9727 if (NULL == hHal)
9728 {
9729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9730 "%s: Hal Context is NULL",__func__);
9731 return -EINVAL;
9732 }
9733 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009734
Atul Mittal54378cb2014-04-02 16:51:50 +05309735 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 {
9737 case WLAN_HDD_UI_BAND_AUTO:
9738 band = eCSR_BAND_ALL;
9739 break;
9740 case WLAN_HDD_UI_BAND_5_GHZ:
9741 band = eCSR_BAND_5G;
9742 break;
9743 case WLAN_HDD_UI_BAND_2_4_GHZ:
9744 band = eCSR_BAND_24;
9745 break;
9746 default:
9747 band = eCSR_BAND_MAX;
9748 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309749 connectedBand =
9750 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009751
Atul Mittal54378cb2014-04-02 16:51:50 +05309752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009753 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009754
9755 if (band == eCSR_BAND_MAX)
9756 {
9757 /* Received change band request with invalid band value */
9758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309759 "%s: Invalid band value %u", __func__, ui_band);
9760 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009761 }
9762
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309763 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309764 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309765 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009767 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009768 band, pHddCtx->cfg_ini->nBandCapability);
9769 return -EIO;
9770 }
9771
Sushant Kaushik1165f872015-03-30 20:25:27 +05309772 if (band == eCSR_BAND_ALL)
9773 {
9774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9775 "received. Setting band same as ini value %d"),
9776 pHddCtx->cfg_ini->nBandCapability);
9777 band = pHddCtx->cfg_ini->nBandCapability;
9778 }
9779
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9781 {
9782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9783 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009784 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009785 return -EIO;
9786 }
9787
9788 if (currBand != band)
9789 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309790 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309791 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309792 /* Return failure if current country code is world regulatory domain*/
9793 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9794 pMac->scan.countryCodeCurrent[1] == '0') )
9795 {
9796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9797 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309798 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309799 return -EAGAIN;
9800 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309801 }
9802
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 /* Change band request received.
9804 * Abort pending scan requests, flush the existing scan results,
9805 * and change the band capability
9806 */
9807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9808 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009809 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009810
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309811 /* We need to change the band and flush the scan results here itself
9812 * as we may get timeout for disconnection in which we will return
9813 * with out doing any of these
9814 */
9815 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9816 {
9817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9818 "%s: failed to set the band value to %u ",
9819 __func__, band);
9820 return -EINVAL;
9821 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309822 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9823 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309824 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309825 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9826 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309827 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309828 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9829 * information available in NV so to get the channel information from kernel
9830 * we need to send regulatory hint for the currunt country
9831 * And to set the same country again we need to set the dummy country
9832 * first and then the actual country.
9833 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309834#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9835 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9836#else
9837 regulatory_hint_user("00");
9838#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309839 wait_result = wait_for_completion_interruptible_timeout(
9840 &pHddCtx->linux_reg_req,
9841 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9842
9843 /* if the country information does not exist with the kernel,
9844 then the driver callback would not be called */
9845
9846 if (wait_result >= 0)
9847 {
9848 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9849 "runtime country code is found in kernel db");
9850 }
9851 else
9852 {
9853 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9854 "runtime country code is not found"
9855 " in kernel db");
9856 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309857
9858 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309859
9860 /*
9861 * Update 11dcountry and current country here as the hint
9862 * with 00 results in 11d and current country with 00
9863 */
9864 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9865 WNI_CFG_COUNTRY_CODE_LEN);
9866 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9867 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309868#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9869 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9870#else
9871 regulatory_hint_user(curr_country);
9872#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309873 wait_result = wait_for_completion_interruptible_timeout(
9874 &pHddCtx->linux_reg_req,
9875 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9876
9877 /* if the country information does not exist with the kernel,
9878 then the driver callback would not be called */
9879 if (wait_result >= 0)
9880 {
9881 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9882 "runtime country code is found in kernel db");
9883 }
9884 else
9885 {
9886 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9887 "runtime country code is not found"
9888 " in kernel db");
9889 }
9890
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309891 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309892 }
9893 else
9894 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309895#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309896 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9897 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309898#else
9899 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9900#endif
9901
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309902 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309903 pScanInfo = &pHddCtx->scan_info;
9904 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9905 {
9906 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9907 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9908 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309909 sme_FilterScanResults(hHal, pAdapter->sessionId);
9910
9911 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309912 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9913 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 eHalStatus status = eHAL_STATUS_SUCCESS;
9916 long lrc;
9917
9918 /* STA already connected on current band, So issue disconnect first,
9919 * then change the band*/
9920
9921 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309922 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309923 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009924
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9926
9927 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9928 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9929
Jeff Johnson43971f52012-07-17 12:26:56 -07009930 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 {
9932 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009933 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 __func__, (int)status );
9935 return -EINVAL;
9936 }
9937
9938 lrc = wait_for_completion_interruptible_timeout(
9939 &pAdapter->disconnect_comp_var,
9940 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9941
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309942 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009943
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009944 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009945 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009946
9947 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9948 }
9949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309951 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309952 if (TRUE == pHddCtx->isSetBandByNL)
9953 return 0;
9954 else
9955 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009956}
9957
Atul Mittal54378cb2014-04-02 16:51:50 +05309958int hdd_setBand_helper(struct net_device *dev, const char *command)
9959{
9960 u8 band;
9961
9962 /*convert the band value from ascii to integer*/
9963 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9964
9965 return hdd_setBand(dev, band);
9966
9967}
9968
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309969static int __iw_set_band_config(struct net_device *dev,
9970 struct iw_request_info *info,
9971 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009972{
Atul Mittal54378cb2014-04-02 16:51:50 +05309973 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009974
Arif Hussain0273cba2014-01-07 20:58:29 -08009975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009976
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +05309977 if (!capable(CAP_NET_ADMIN))
9978 {
9979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9980 FL("permission check failed"));
9981 return -EPERM;
9982 }
9983
Atul Mittal54378cb2014-04-02 16:51:50 +05309984 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009985}
9986
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309987static int iw_set_band_config(struct net_device *dev,
9988 struct iw_request_info *info,
9989 union iwreq_data *wrqu, char *extra)
9990{
9991 int ret;
9992
9993 vos_ssr_protect(__func__);
9994 ret = __iw_set_band_config(dev, info, wrqu, extra);
9995 vos_ssr_unprotect(__func__);
9996
9997 return ret;
9998}
9999
c_manjeecfd1efb2015-09-25 19:32:34 +053010000static int get_fwr_memdump(struct net_device *dev,
10001 struct iw_request_info *info,
10002 union iwreq_data *wrqu, char *extra)
10003{
10004 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10005 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10006 int ret;
10007 ENTER();
10008 // HddCtx sanity
10009 ret = wlan_hdd_validate_context(pHddCtx);
10010 if (0 != ret)
10011 {
10012 return ret;
10013 }
10014 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10015 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10016 {
10017 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10018 return -EINVAL;
10019 }
10020 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10021
10022 EXIT();
10023 return ret;
10024}
10025
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010026static int __iw_set_power_params_priv(struct net_device *dev,
10027 struct iw_request_info *info,
10028 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010029{
Arif Hussain0273cba2014-01-07 20:58:29 -080010030 int ret;
10031 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010032
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10034 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010035
10036 if (!capable(CAP_NET_ADMIN))
10037 {
10038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10039 FL("permission check failed"));
10040 return -EPERM;
10041 }
10042
Arif Hussain0273cba2014-01-07 20:58:29 -080010043 /* ODD number is used for set, copy data using copy_from_user */
10044 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10045 wrqu->data.length);
10046 if (NULL == ptr)
10047 {
10048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10049 "mem_alloc_copy_from_user_helper fail");
10050 return -ENOMEM;
10051 }
10052
10053 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10054 kfree(ptr);
10055 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010056}
10057
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010058static int iw_set_power_params_priv(struct net_device *dev,
10059 struct iw_request_info *info,
10060 union iwreq_data *wrqu, char *extra)
10061{
10062 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010063
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010064 vos_ssr_protect(__func__);
10065 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10066 vos_ssr_unprotect(__func__);
10067
10068 return ret;
10069}
Jeff Johnson295189b2012-06-20 16:38:30 -070010070
10071/*string based input*/
10072VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10073 union iwreq_data *wrqu, char *extra, int nOffset)
10074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010075 hdd_adapter_t *pAdapter;
10076 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 tSirSetPowerParamsReq powerRequest;
10078 char *ptr;
10079 v_U8_t ucType;
10080 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010081 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010082
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010083 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010084 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10085 if (NULL == pAdapter)
10086 {
10087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10088 "%s: Adapter is NULL",__func__);
10089 return -EINVAL;
10090 }
10091
10092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10093 ret = wlan_hdd_validate_context(pHddCtx);
10094 if (0 != ret)
10095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010096 return ret;
10097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10099 "Power Params data len %d data %s",
10100 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010101 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010102
10103 if (wrqu->data.length <= nOffset )
10104 {
10105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10106 return VOS_STATUS_E_FAILURE;
10107 }
10108
10109 uTotalSize = wrqu->data.length - nOffset;
10110
10111 /*-----------------------------------------------------------------------
10112 Input is string based and expected to be like this:
10113
10114 <param_type> <param_value> <param_type> <param_value> ...
10115
10116 e.g:
10117 1 2 2 3 3 0 4 1 5 1
10118
10119 e.g. setting just a few:
10120 1 2 4 1
10121
10122 parameter types:
10123 -----------------------------
10124 1 - Ignore DTIM
10125 2 - Listen Interval
10126 3 - Broadcast Multicas Filter
10127 4 - Beacon Early Termination
10128 5 - Beacon Early Termination Interval
10129 -----------------------------------------------------------------------*/
10130 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10131 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10132 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10133 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10134 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10135
Arif Hussain7adce1b2013-11-11 22:59:34 -080010136 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010137
10138 while ( uTotalSize )
10139 {
Wilson Yang6f971452013-10-08 15:00:00 -070010140 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10141 {
10142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10143 "Invalid input parameter type %s",ptr);
10144 return VOS_STATUS_E_FAILURE;
10145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010146
10147 uTotalSize -= nOffset;
10148
10149 if (!uTotalSize)
10150 {
10151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010152 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 ucType, nOffset);
10154 return VOS_STATUS_E_FAILURE;
10155 }
10156
10157 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010158
Jeff Johnson02797792013-10-26 19:17:13 -070010159 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010160 {
10161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10162 "Invalid input parameter value %s",ptr);
10163 return VOS_STATUS_E_FAILURE;
10164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010165
10166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10167 "Power request parameter %d value %d offset %d",
10168 ucType, uValue, nOffset);
10169
10170 switch (ucType)
10171 {
10172 case eSIR_IGNORE_DTIM:
10173 powerRequest.uIgnoreDTIM = uValue;
10174 break;
10175 case eSIR_LISTEN_INTERVAL:
10176 powerRequest.uListenInterval = uValue;
10177 break;
10178 case eSIR_MCAST_BCAST_FILTER:
10179 powerRequest.uBcastMcastFilter = uValue;
10180 break;
10181 case eSIR_ENABLE_BET:
10182 powerRequest.uEnableBET = uValue;
10183 break;
10184 case eSIR_BET_INTERVAL:
10185 powerRequest.uBETInterval = uValue;
10186 break;
10187 default:
10188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010189 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010190 ucType, uValue, nOffset);
10191 return VOS_STATUS_E_FAILURE;
10192 }
10193
10194 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10196 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010197 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010199 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010200 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010201 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10202 {
10203 uTotalSize = 0;
10204 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010205
10206 }/*Go for as long as we have a valid string*/
10207
10208 /* put the device into full power*/
10209 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10210
10211 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010212 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010213
10214 /* put the device back to power save*/
10215 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10216
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010217 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 return VOS_STATUS_SUCCESS;
10219}/*iw_set_power_params*/
10220
Atul Mittalc0f739f2014-07-31 13:47:47 +053010221// tdlsoffchan
10222#ifdef FEATURE_WLAN_TDLS
10223
Atul Mittal87ec2422014-09-24 13:12:50 +053010224int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010225{
10226 if (offchannel < 0 || offchannel > 165)
10227 {
10228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10229 __func__, offchannel);
10230 return -1;
10231
10232 }
10233
10234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10235 __func__, tdlsOffCh, offchannel);
10236
10237 tdlsOffCh = offchannel;
10238 return 0;
10239}
10240
Atul Mittal87ec2422014-09-24 13:12:50 +053010241int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010242{
10243 if (offchanoffset == 0)
10244 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010245 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10247 __func__, tdlsOffChBwOffset);
10248
10249 return 0;
10250
10251 }
10252
10253 if ( offchanoffset == 40 )
10254 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010255 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10257 __func__, tdlsOffChBwOffset);
10258
10259 return 0;
10260
10261 }
10262 if (offchanoffset == -40)
10263 {
10264 tdlsOffChBwOffset = 3;
10265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10266 __func__, tdlsOffChBwOffset);
10267
10268 return 0;
10269
10270 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010271
10272 if ((offchanoffset == 80) &&
10273 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10274 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10275 {
10276 tdlsOffChBwOffset = 4;
10277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10278 "%s: change tdls secondary off channel offset to %u",
10279 __func__, tdlsOffChBwOffset);
10280
10281 return 0;
10282 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10284 __func__, offchanoffset);
10285 return -1;
10286}
10287
Atul Mittal87ec2422014-09-24 13:12:50 +053010288int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010289{
10290 hddTdlsPeer_t *connPeer = NULL;
10291 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10292 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010293 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010294 if (offchanmode < 0 || offchanmode > 4)
10295 {
10296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10297 "%s: Invalid tdls off channel mode %d",
10298 __func__, offchanmode);
10299 return -1;
10300 }
10301
10302 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10303 {
10304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10305 "%s: tdls off channel mode req in not associated state %d",
10306 __func__, offchanmode);
10307 return -1;
10308 }
10309
10310 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10311 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10312 {
10313 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010314 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010315 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010316 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010317 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10319 "%s: No TDLS Connected Peer", __func__);
10320 return -1;
10321 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010322 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010323 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010324 }
10325 else
10326 {
10327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10328 "%s: TDLS Connection not supported", __func__);
10329 return -1;
10330 }
10331
10332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10333 ("%s: TDLS Channel Switch in swmode=%d"),
10334 __func__, offchanmode);
10335
10336 switch (offchanmode)
10337 {
10338 case 1:/*Enable*/
10339 case 2:/*Disable*/
10340 {
10341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10342 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10343 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10344 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10345 {
10346
10347 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010348 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010349 tdlsOffCh, tdlsOffChBwOffset,
10350 offchanmode);
10351 }
10352 else
10353 {
10354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10355 "%s: TDLS Off Channel not supported", __func__);
10356 return -1;
10357 }
10358 break;
10359 }
10360 case 3:
10361 {
10362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10363 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10364 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10365
10366 break;
10367 }
10368 case 4:
10369 {
10370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10371 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10372 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10373 break;
10374 }
10375 default:
10376 {
10377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10378 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10379 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10380 break;
10381 }
10382
10383 }
10384
10385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10386 __func__, offchanmode);
10387 return 0;
10388}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010389#endif
10390
Jeff Johnson295189b2012-06-20 16:38:30 -070010391
10392// Define the Wireless Extensions to the Linux Network Device structure
10393// A number of these routines are NULL (meaning they are not implemented.)
10394
10395static const iw_handler we_handler[] =
10396{
10397 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10398 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10399 (iw_handler) NULL, /* SIOCSIWNWID */
10400 (iw_handler) NULL, /* SIOCGIWNWID */
10401 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10402 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10403 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10404 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10405 (iw_handler) NULL, /* SIOCSIWSENS */
10406 (iw_handler) NULL, /* SIOCGIWSENS */
10407 (iw_handler) NULL, /* SIOCSIWRANGE */
10408 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10409 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10410 (iw_handler) NULL, /* SIOCGIWPRIV */
10411 (iw_handler) NULL, /* SIOCSIWSTATS */
10412 (iw_handler) NULL, /* SIOCGIWSTATS */
10413 iw_handler_set_spy, /* SIOCSIWSPY */
10414 iw_handler_get_spy, /* SIOCGIWSPY */
10415 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10416 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10417 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10418 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10419 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10420 (iw_handler) NULL, /* SIOCGIWAPLIST */
10421 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10422 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10423 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10424 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10425 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10426 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10427 (iw_handler) NULL, /* -- hole -- */
10428 (iw_handler) NULL, /* -- hole -- */
10429 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10430 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10431 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10432 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10433 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10434 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10435 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10436 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10437 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10438 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10439 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10440 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10441 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10442 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10443 (iw_handler) NULL, /* -- hole -- */
10444 (iw_handler) NULL, /* -- hole -- */
10445 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10446 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10447 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10448 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10449 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10450 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10451 (iw_handler) NULL, /* SIOCSIWPMKSA */
10452};
10453
10454static const iw_handler we_private[] = {
10455
10456 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10457 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10458 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10459 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10460 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10461 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010462 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10464 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10465 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010466#ifdef FEATURE_OEM_DATA_SUPPORT
10467 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10468 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10469#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010470
Jeff Johnson295189b2012-06-20 16:38:30 -070010471#ifdef WLAN_FEATURE_VOWIFI_11R
10472 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10473#endif
10474 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10475 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10476 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10477#ifdef WLAN_FEATURE_PACKET_FILTERING
10478 ,
10479 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10480#endif
10481#ifdef FEATURE_WLAN_SCAN_PNO
10482 ,
10483 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10484#endif
10485 ,
10486 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10487 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10488 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10489 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010490 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010491};
10492
10493/*Maximum command length can be only 15 */
10494static const struct iw_priv_args we_private_args[] = {
10495
Katya Nigamf0511f62015-05-05 16:40:57 +053010496 { WE_SET_MONITOR_STATE,
10497 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10498 0, "monitor" },
10499
Jeff Johnson295189b2012-06-20 16:38:30 -070010500 /* handlers for main ioctl */
10501 { WLAN_PRIV_SET_INT_GET_NONE,
10502 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10503 0,
10504 "" },
10505
10506 /* handlers for sub-ioctl */
10507 { WE_SET_11D_STATE,
10508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10509 0,
10510 "set11Dstate" },
10511
10512 { WE_WOWL,
10513 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10514 0,
10515 "wowl" },
10516
10517 { WE_SET_POWER,
10518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10519 0,
10520 "setPower" },
10521
10522 { WE_SET_MAX_ASSOC,
10523 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10524 0,
10525 "setMaxAssoc" },
10526
10527 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10528 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10529 0,
10530 "setAutoChannel" },
10531
10532 { WE_SET_DATA_INACTIVITY_TO,
10533 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10534 0,
10535 "inactivityTO" },
10536
10537 { WE_SET_MAX_TX_POWER,
10538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10539 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010540 "setMaxTxPower" },
10541
10542 { WE_SET_MAX_TX_POWER_2_4,
10543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10544 0,
10545 "setTxMaxPower2G" },
10546
10547 { WE_SET_MAX_TX_POWER_5_0,
10548 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10549 0,
10550 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010551
10552 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10553 * as well to keep same syntax as in SAP. Now onwards, STA
10554 * will support both */
10555 { WE_SET_MAX_TX_POWER,
10556 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10557 0,
10558 "setTxMaxPower" },
10559
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10561 * 1 = enable and 0 = disable */
10562 {
10563 WE_SET_HIGHER_DTIM_TRANSITION,
10564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10565 0,
10566 "setHDtimTransn" },
10567
10568 { WE_SET_TM_LEVEL,
10569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010570 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 "setTmLevel" },
10572
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010573 { WE_ENABLE_STRICT_FCC_REG,
10574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10575 0,
10576 "setStrictFCCreg" },
10577
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010578 { WE_SET_DEBUG_LOG,
10579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10580 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010581#ifdef FEATURE_WLAN_TDLS
10582 {
10583 WE_SET_TDLS_OFF_CHAN,
10584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10585 0,
10586 "tdlsoffchan" },
10587 {
10588 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10590 0,
10591 "tdlsecchnoffst" },
10592 {
10593 WE_SET_TDLS_OFF_CHAN_MODE,
10594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10595 0,
10596 "tdlsoffchnmode" },
10597#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010598
Peng Xu2446a892014-09-05 17:21:18 +053010599 { WE_SET_SCAN_BAND_PREFERENCE,
10600 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10601 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010602 {
10603 WE_GET_FRAME_LOG,
10604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10605 0,
10606 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010607
Abhishek Singh01c73d12015-03-12 15:13:44 +053010608 { WE_SET_MIRACAST_VENDOR_CONFIG,
10609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10610 0, "setMiracstConf" },
10611
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010612#ifdef FEATURE_WLAN_TDLS
10613 {
10614 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10615 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10616 0,
10617 "tdls_2040bsscox" },
10618#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010619 { WE_SET_RTS_CTS_HTVHT,
10620 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10621 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010622 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10624 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053010625 { WE_SET_PROXIMITY_ENABLE,
10626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10627 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 /* handlers for main ioctl */
10629 { WLAN_PRIV_SET_NONE_GET_INT,
10630 0,
10631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10632 "" },
10633
10634 /* handlers for sub-ioctl */
10635 { WE_GET_11D_STATE,
10636 0,
10637 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10638 "get11Dstate" },
10639
10640 { WE_IBSS_STATUS,
10641 0,
10642 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10643 "getAdhocStatus" },
10644
10645 { WE_PMC_STATE,
10646 0,
10647 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10648 "pmcState" },
10649
10650 { WE_GET_WLAN_DBG,
10651 0,
10652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10653 "getwlandbg" },
10654
Jeff Johnson295189b2012-06-20 16:38:30 -070010655 { WE_GET_MAX_ASSOC,
10656 0,
10657 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10658 "getMaxAssoc" },
10659
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 { WE_GET_WDI_DBG,
10661 0,
10662 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10663 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010664
10665 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10666 0,
10667 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10668 "getAutoChannel" },
10669
10670 { WE_GET_CONCURRENCY_MODE,
10671 0,
10672 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10673 "getconcurrency" },
10674
Peng Xu2446a892014-09-05 17:21:18 +053010675 { WE_GET_SCAN_BAND_PREFERENCE,
10676 0,
10677 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10678 "get_scan_pref"},
10679
Jeff Johnson295189b2012-06-20 16:38:30 -070010680 /* handlers for main ioctl */
10681 { WLAN_PRIV_SET_CHAR_GET_NONE,
10682 IW_PRIV_TYPE_CHAR| 512,
10683 0,
10684 "" },
10685
10686 /* handlers for sub-ioctl */
10687 { WE_WOWL_ADD_PTRN,
10688 IW_PRIV_TYPE_CHAR| 512,
10689 0,
10690 "wowlAddPtrn" },
10691
10692 { WE_WOWL_DEL_PTRN,
10693 IW_PRIV_TYPE_CHAR| 512,
10694 0,
10695 "wowlDelPtrn" },
10696
10697#if defined WLAN_FEATURE_VOWIFI
10698 /* handlers for sub-ioctl */
10699 { WE_NEIGHBOR_REPORT_REQUEST,
10700 IW_PRIV_TYPE_CHAR | 512,
10701 0,
10702 "neighbor" },
10703#endif
10704 { WE_SET_AP_WPS_IE,
10705 IW_PRIV_TYPE_CHAR| 512,
10706 0,
10707 "set_ap_wps_ie" },
10708
10709 { WE_SET_CONFIG,
10710 IW_PRIV_TYPE_CHAR| 512,
10711 0,
10712 "setConfig" },
10713
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010714 { WE_SET_ENCRYPT_MSG,
10715 IW_PRIV_TYPE_CHAR| 512,
10716 0,
10717 "encryptMsg" },
10718
10719
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 /* handlers for main ioctl */
10721 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10722 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10723 0,
10724 "" },
10725
10726 /* handlers for sub-ioctl */
10727 { WE_SET_WLAN_DBG,
10728 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10729 0,
10730 "setwlandbg" },
10731
Jeff Johnson295189b2012-06-20 16:38:30 -070010732 { WE_SET_WDI_DBG,
10733 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10734 0,
10735 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010736
10737 { WE_SET_SAP_CHANNELS,
10738 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10739 0,
10740 "setsapchannels" },
10741
10742 /* handlers for main ioctl */
10743 { WLAN_PRIV_GET_CHAR_SET_NONE,
10744 0,
10745 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10746 "" },
10747
10748 /* handlers for sub-ioctl */
10749 { WE_WLAN_VERSION,
10750 0,
10751 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10752 "version" },
10753 { WE_GET_STATS,
10754 0,
10755 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10756 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010757 { WE_GET_STATES,
10758 0,
10759 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10760 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010761 { WE_GET_CFG,
10762 0,
10763 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10764 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010765#ifdef WLAN_FEATURE_11AC
10766 { WE_GET_RSSI,
10767 0,
10768 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10769 "getRSSI" },
10770#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010771#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010772 { WE_GET_ROAM_RSSI,
10773 0,
10774 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10775 "getRoamRSSI" },
10776#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 { WE_GET_WMM_STATUS,
10778 0,
10779 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10780 "getWmmStatus" },
10781 {
10782 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010783 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10785 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010786#ifdef FEATURE_WLAN_TDLS
10787 {
10788 WE_GET_TDLS_PEERS,
10789 0,
10790 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10791 "getTdlsPeers" },
10792#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010793#ifdef WLAN_FEATURE_11W
10794 {
10795 WE_GET_11W_INFO,
10796 0,
10797 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10798 "getPMFInfo" },
10799#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010800 { WE_GET_SNR,
10801 0,
10802 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10803 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053010804#ifdef FEATURE_OEM_DATA_SUPPORT
10805 {
10806 WE_GET_OEM_DATA_CAP,
10807 0,
10808 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10809 "getOemDataCap" },
10810#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070010811 /* handlers for main ioctl */
10812 { WLAN_PRIV_SET_NONE_GET_NONE,
10813 0,
10814 0,
10815 "" },
10816
10817 /* handlers for sub-ioctl */
10818 { WE_CLEAR_STATS,
10819 0,
10820 0,
10821 "clearStats" },
10822 { WE_INIT_AP,
10823 0,
10824 0,
10825 "initAP" },
10826 { WE_STOP_AP,
10827 0,
10828 0,
10829 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010830#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010831 { WE_ENABLE_AMP,
10832 0,
10833 0,
10834 "enableAMP" },
10835 { WE_DISABLE_AMP,
10836 0,
10837 0,
10838 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010839#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010840 { WE_ENABLE_DXE_STALL_DETECT,
10841 0,
10842 0,
10843 "dxeStallDetect" },
10844 { WE_DISPLAY_DXE_SNAP_SHOT,
10845 0,
10846 0,
10847 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010848 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10849 0,
10850 0,
10851 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010852 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010853 WE_SET_REASSOC_TRIGGER,
10854 0,
10855 0,
10856 "reassoc" },
10857 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010858 WE_STOP_OBSS_SCAN,
10859 0,
10860 0,
10861 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010862 {
10863 WE_DUMP_ROAM_TIMER_LOG,
10864 0,
10865 0,
10866 "dumpRoamDelay" },
10867 {
10868 WE_RESET_ROAM_TIMER_LOG,
10869 0,
10870 0,
10871 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010872 {
10873 WE_GET_FW_LOGS,
10874 0,
10875 0,
10876 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010877 {
10878 WE_GET_FW_MEMDUMP,
10879 0,
10880 0,
10881 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 /* handlers for main ioctl */
10883 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10884 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10885 0,
10886 "" },
10887
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010888
10889
Jeff Johnson295189b2012-06-20 16:38:30 -070010890 /* handlers for sub-ioctl */
10891 { WE_LOG_DUMP_CMD,
10892 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10893 0,
10894 "dump" },
10895
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010896 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010897 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10898 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10899 0,
10900 "setdumplog" },
10901
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010902 { WE_MTRACE_DUMP_CMD,
10903 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10904 0,
10905 "dumplog" },
10906
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010907 /* handlers for sub ioctl */
10908 {
10909 WE_MCC_CONFIG_CREDENTIAL,
10910 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10911 0,
10912 "setMccCrdnl" },
10913
10914 /* handlers for sub ioctl */
10915 {
10916 WE_MCC_CONFIG_PARAMS,
10917 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10918 0,
10919 "setMccConfig" },
10920
Chilam NG571c65a2013-01-19 12:27:36 +053010921#ifdef FEATURE_WLAN_TDLS
10922 /* handlers for sub ioctl */
10923 {
10924 WE_TDLS_CONFIG_PARAMS,
10925 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10926 0,
10927 "setTdlsConfig" },
10928#endif
10929
Katya Nigamf0511f62015-05-05 16:40:57 +053010930 {
10931 WE_CONFIGURE_MONITOR_MODE,
10932 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10933 0,
10934 "MonitorModeConf" },
10935
10936 {
10937 WE_SET_MONITOR_MODE_FILTER,
10938 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10939 0,
10940 "MonitorFilter" },
10941
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 /* handlers for main ioctl */
10943 { WLAN_PRIV_ADD_TSPEC,
10944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10945 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10946 "addTspec" },
10947
10948 /* handlers for main ioctl */
10949 { WLAN_PRIV_DEL_TSPEC,
10950 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10951 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10952 "delTspec" },
10953
10954 /* handlers for main ioctl */
10955 { WLAN_PRIV_GET_TSPEC,
10956 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10957 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10958 "getTspec" },
10959
Jeff Johnsone7245742012-09-05 17:12:55 -070010960#ifdef FEATURE_OEM_DATA_SUPPORT
10961 /* handlers for main ioctl - OEM DATA */
10962 {
10963 WLAN_PRIV_SET_OEM_DATA_REQ,
10964 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10965 0,
10966 "set_oem_data_req" },
10967
10968 /* handlers for main ioctl - OEM DATA */
10969 {
10970 WLAN_PRIV_GET_OEM_DATA_RSP,
10971 0,
10972 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10973 "get_oem_data_rsp" },
10974#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010975
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 /* handlers for main ioctl - host offload */
10977 {
10978 WLAN_PRIV_SET_HOST_OFFLOAD,
10979 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10980 0,
10981 "setHostOffload" },
10982
10983 {
10984 WLAN_GET_WLAN_STATISTICS,
10985 0,
10986 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10987 "getWlanStats" },
10988
10989 {
10990 WLAN_SET_KEEPALIVE_PARAMS,
10991 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10992 0,
10993 "setKeepAlive" },
10994#ifdef WLAN_FEATURE_PACKET_FILTERING
10995 {
10996 WLAN_SET_PACKET_FILTER_PARAMS,
10997 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10998 0,
10999 "setPktFilter" },
11000#endif
11001#ifdef FEATURE_WLAN_SCAN_PNO
11002 {
11003 WLAN_SET_PNO,
11004 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11005 0,
11006 "setpno" },
11007#endif
11008 {
11009 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011010 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011011 0,
11012 "SETBAND" },
11013 /* handlers for dynamic MC BC ioctl */
11014 {
11015 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011016 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 0,
11018 "setMCBCFilter" },
11019 {
11020 WLAN_PRIV_CLEAR_MCBC_FILTER,
11021 0,
11022 0,
11023 "clearMCBCFilter" },
11024 {
11025 WLAN_SET_POWER_PARAMS,
11026 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11027 0,
11028 "setpowerparams" },
11029 {
11030 WLAN_GET_LINK_SPEED,
11031 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011032 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011033};
11034
11035
11036
11037const struct iw_handler_def we_handler_def = {
11038 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11039 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11040 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11041
11042 .standard = (iw_handler *)we_handler,
11043 .private = (iw_handler *)we_private,
11044 .private_args = we_private_args,
11045 .get_wireless_stats = get_wireless_stats,
11046};
11047
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011048int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11049{
11050 v_U32_t cmd = 288; //Command to RIVA
11051 hdd_context_t *pHddCtx = NULL;
11052 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11053 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11054 /*
11055 *configMccParam : specify the bit which needs to be modified
11056 *allowed to update based on wlan_qcom_cfg.ini
11057 * configuration
11058 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11059 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11060 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11061 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11062 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11063 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11064 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11065 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11066 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11067 * Bit 9 : Reserved
11068 */
11069 switch (arg1)
11070 {
11071 //Update MCC SCHEDULE_TIME_SLICE parameter
11072 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11073 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11074 {
11075 if((arg2 >= 5) && (arg2 <= 20))
11076 {
11077 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11078 }
11079 else
11080 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011081 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011082 return 0;
11083 }
11084 }
11085 break;
11086
11087 //Update MCC MAX_NULL_SEND_TIME parameter
11088 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11089 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11090 {
11091 if((arg2 >= 1) && (arg2 <= 10))
11092 {
11093 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11094 }
11095 else
11096 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011097 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011098 return 0;
11099 }
11100 }
11101 break;
11102
11103 //Update MCC TX_EARLY_STOP_TIME parameter
11104 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11105 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11106 {
11107 if((arg2 >= 1) && (arg2 <= 10))
11108 {
11109 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11110 }
11111 else
11112 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011113 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011114 return 0;
11115 }
11116 }
11117 break;
11118
11119 //Update MCC RX_DRAIN_TIME parameter
11120 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11121 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11122 {
11123 if((arg2 >= 1) && (arg2 <= 10))
11124 {
11125 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11126 }
11127 else
11128 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011129 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011130 return 0;
11131 }
11132 }
11133 break;
11134
11135 //Update MCC CHANNEL_SWITCH_TIME parameter
11136 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11137 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11138 {
11139 if((arg2 >= 1) && (arg2 <= 20))
11140 {
11141 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11142 }
11143 else
11144 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011145 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011146 return 0;
11147 }
11148 }
11149 break;
11150
11151 //Update MCC MIN_CHANNEL_TIME parameter
11152 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11153 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11154 {
11155 if((arg2 >= 5) && (arg2 <= 20))
11156 {
11157 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11158 }
11159 else
11160 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011161 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011162 return 0;
11163 }
11164 }
11165 break;
11166
11167 //Update MCC PARK_BEFORE_TBTT parameter
11168 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11169 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11170 {
11171 if((arg2 >= 1) && (arg2 <= 5))
11172 {
11173 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11174 }
11175 else
11176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011177 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011178 return 0;
11179 }
11180 }
11181 break;
11182
11183 //Update MCC MIN_AFTER_DTIM parameter
11184 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11185 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11186 {
11187 if((arg2 >= 5) && (arg2 <= 15))
11188 {
11189 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11190 }
11191 else
11192 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011193 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011194 return 0;
11195 }
11196 }
11197 break;
11198
11199 //Update MCC TOO_CLOSE_MARGIN parameter
11200 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11201 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11202 {
11203 if((arg2 >= 1) && (arg2 <= 3))
11204 {
11205 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11206 }
11207 else
11208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011209 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011210 return 0;
11211 }
11212 }
11213 break;
11214
11215 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011216 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011217 __FUNCTION__,arg1);
11218 break;
11219 }
11220 return 0;
11221}
11222
Jeff Johnson295189b2012-06-20 16:38:30 -070011223int hdd_set_wext(hdd_adapter_t *pAdapter)
11224{
11225 hdd_wext_state_t *pwextBuf;
11226 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011227 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011228
11229 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11230
11231 // Now configure the roaming profile links. To SSID and bssid.
11232 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11233 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11234
11235 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11236 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11237
11238 /*Set the numOfChannels to zero to scan all the channels*/
11239 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11240 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11241
11242 /* Default is no encryption */
11243 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11244 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11245
11246 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11247 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11248
11249 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11250
11251 /* Default is no authentication */
11252 pwextBuf->roamProfile.AuthType.numEntries = 1;
11253 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11254
11255 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11256 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11257
11258 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011259 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011260
11261 hdd_clearRoamProfileIe(pAdapter);
11262
11263 return VOS_STATUS_SUCCESS;
11264
11265 }
11266
11267int hdd_register_wext(struct net_device *dev)
11268 {
11269 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11270 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11271 VOS_STATUS status;
11272
11273 ENTER();
11274
11275 // Zero the memory. This zeros the profile structure.
11276 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11277
11278 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11279
11280
11281 status = hdd_set_wext(pAdapter);
11282
11283 if(!VOS_IS_STATUS_SUCCESS(status)) {
11284
Arif Hussain6d2a3322013-11-17 19:50:10 -080011285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 return eHAL_STATUS_FAILURE;
11287 }
11288
11289 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11290 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 return eHAL_STATUS_FAILURE;
11293 }
11294
11295 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11296 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011298 return eHAL_STATUS_FAILURE;
11299 }
11300
11301 // Register as a wireless device
11302 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11303
11304 EXIT();
11305 return 0;
11306}
11307
11308int hdd_UnregisterWext(struct net_device *dev)
11309{
c_hpothu2a13bc32015-01-21 12:48:54 +053011310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11311 if (dev != NULL)
11312 {
11313 rtnl_lock();
11314 dev->wireless_handlers = NULL;
11315 rtnl_unlock();
11316 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011317
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 return 0;
11319}
11320
11321