blob: 5c5e7d8cb1fee3854f0cd37419dd372e47ce62b4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05302 * Copyright (c) 2011-2018 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"
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530108#include "wlan_hdd_request_manager.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#ifdef CONFIG_HAS_EARLYSUSPEND
111extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
112extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
113#endif
114
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800116#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530120#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123// tdlsoffchan
124#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530125static int tdlsOffCh = 1;
126static int tdlsOffChBwOffset = 0;
127#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530128
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700129static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132/* To Validate Channel against the Frequency and Vice-Versa */
133static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
134 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
135 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
136 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
137 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
138 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
139 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
140 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800141 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
142 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800144#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146/* Private ioctls and their sub-ioctls */
147#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
148#define WE_SET_11D_STATE 1
149#define WE_WOWL 2
150#define WE_SET_POWER 3
151#define WE_SET_MAX_ASSOC 4
152#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
153#define WE_SET_DATA_INACTIVITY_TO 6
154#define WE_SET_MAX_TX_POWER 7
155#define WE_SET_HIGHER_DTIM_TRANSITION 8
156#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530157#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700158#define WE_SET_MAX_TX_POWER_2_4 11
159#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800160/* Private IOCTL for debug connection issues */
161#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530162// tdlsoffchan
163#ifdef FEATURE_WLAN_TDLS
164#define WE_SET_TDLS_OFF_CHAN 14
165#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
166#define WE_SET_TDLS_OFF_CHAN_MODE 16
167#endif
Peng Xu2446a892014-09-05 17:21:18 +0530168#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530169#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530170#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530171#ifdef FEATURE_WLAN_TDLS
172#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
173#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530174#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530175#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530176#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530177#define WE_SET_PROXIMITY_ENABLE 24
Manjeet Singh3ed79242017-01-11 19:04:32 +0530178#define WE_CAP_TSF 25
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +0530179#define WE_SET_MODULATED_DTIM 26
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530180#define WLAN_SET_DYNNAMIC_AGGREGATION 27
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
184#define WE_GET_11D_STATE 1
185#define WE_IBSS_STATUS 2
186#define WE_PMC_STATE 3
187#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700188#define WE_GET_MAX_ASSOC 6
189#define WE_GET_WDI_DBG 7
190#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
191#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530192#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530193#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700194/* Private ioctls and their sub-ioctls */
195#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
196
197/* Private ioctls and their sub-ioctls */
198#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
199#define WE_WOWL_ADD_PTRN 1
200#define WE_WOWL_DEL_PTRN 2
201#if defined WLAN_FEATURE_VOWIFI
202#define WE_NEIGHBOR_REPORT_REQUEST 3
203#endif
204#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
205#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530206#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208/* Private ioctls and their sub-ioctls */
209#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
210#define WE_SET_WLAN_DBG 1
211#define WE_SET_WDI_DBG 2
212#define WE_SET_SAP_CHANNELS 3
213
214/* Private ioctls and their sub-ioctls */
215#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
216#define WE_WLAN_VERSION 1
217#define WE_GET_STATS 2
218#define WE_GET_CFG 3
219#define WE_GET_WMM_STATUS 4
220#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700221#ifdef WLAN_FEATURE_11AC
222#define WE_GET_RSSI 6
223#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800224#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800225#ifdef FEATURE_WLAN_TDLS
226#define WE_GET_TDLS_PEERS 8
227#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700228#ifdef WLAN_FEATURE_11W
229#define WE_GET_11W_INFO 9
230#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530231#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530232#ifdef WLAN_FEATURE_RMC
233#define WE_GET_IBSS_STA_INFO 11
234#endif
235#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700236
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530237#ifdef FEATURE_OEM_DATA_SUPPORT
238#define WE_GET_OEM_DATA_CAP 13
239#endif
240
Jeff Johnson295189b2012-06-20 16:38:30 -0700241/* Private ioctls and their sub-ioctls */
242#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
243#define WE_CLEAR_STATS 1
244#define WE_INIT_AP 2
245#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530246#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700247#define WE_ENABLE_AMP 4
248#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530249#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700250#define WE_ENABLE_DXE_STALL_DETECT 6
251#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700252#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530253#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530254#ifdef WLAN_FEATURE_RMC
255#define WE_IBSS_GET_PEER_INFO_ALL 10
256#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530257#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530258#define WE_DUMP_ROAM_TIMER_LOG 12
259#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530260#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530261#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263/* Private ioctls and their sub-ioctls */
264#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
265#define WE_LOG_DUMP_CMD 1
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800268//IOCTL to configure MCC params
269#define WE_MCC_CONFIG_CREDENTIAL 3
270#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
Chilam NG571c65a2013-01-19 12:27:36 +0530272#ifdef FEATURE_WLAN_TDLS
273#define WE_TDLS_CONFIG_PARAMS 5
274#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530275#ifdef WLAN_FEATURE_RMC
276#define WE_IBSS_GET_PEER_INFO 6
277#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530278
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700279#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530280#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530281#define WE_CONFIGURE_MONITOR_MODE 10
282#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700283
Chilam Ng01120412013-02-19 18:32:21 -0800284#ifdef FEATURE_WLAN_TDLS
285#undef MAX_VAR_ARGS
286#define MAX_VAR_ARGS 10
287#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700288#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800289#endif
290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291/* Private ioctls (with no sub-ioctls) */
292/* note that they must be odd so that they have "get" semantics */
293#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
294#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
295#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
296
Girish Gowli464c9c82014-06-09 19:47:53 +0530297/* (SIOCIWFIRSTPRIV + 8) is currently unused */
298/* (SIOCIWFIRSTPRIV + 16) is currently unused */
299/* (SIOCIWFIRSTPRIV + 10) is currently unused */
300/* (SIOCIWFIRSTPRIV + 12) is currently unused */
301/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manjeet Singh3ed79242017-01-11 19:04:32 +0530302#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
303#define WE_GET_TSF 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700304
Jeff Johnsone7245742012-09-05 17:12:55 -0700305#ifdef FEATURE_OEM_DATA_SUPPORT
306/* Private ioctls for setting the measurement configuration */
307#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
308#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700310
311#ifdef WLAN_FEATURE_VOWIFI_11R
312#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
313#endif
314
315/* Private ioctl for setting the host offload feature */
316#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
317
318/* Private ioctl to get the statistics */
319#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
320
321/* Private ioctl to set the Keep Alive Params */
322#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
323#ifdef WLAN_FEATURE_PACKET_FILTERING
324/* Private ioctl to set the Packet Filtering Params */
325#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
326#endif
327
328#ifdef FEATURE_WLAN_SCAN_PNO
329/* Private ioctl to get the statistics */
330#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
331#endif
332
333#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
334
335#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
336#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700337/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700338
Jeff Johnson295189b2012-06-20 16:38:30 -0700339#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
340#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
341
342#define WLAN_STATS_INVALID 0
343#define WLAN_STATS_RETRY_CNT 1
344#define WLAN_STATS_MUL_RETRY_CNT 2
345#define WLAN_STATS_TX_FRM_CNT 3
346#define WLAN_STATS_RX_FRM_CNT 4
347#define WLAN_STATS_FRM_DUP_CNT 5
348#define WLAN_STATS_FAIL_CNT 6
349#define WLAN_STATS_RTS_FAIL_CNT 7
350#define WLAN_STATS_ACK_FAIL_CNT 8
351#define WLAN_STATS_RTS_SUC_CNT 9
352#define WLAN_STATS_RX_DISCARD_CNT 10
353#define WLAN_STATS_RX_ERROR_CNT 11
354#define WLAN_STATS_TX_BYTE_CNT 12
355
356#define WLAN_STATS_RX_BYTE_CNT 13
357#define WLAN_STATS_RX_RATE 14
358#define WLAN_STATS_TX_RATE 15
359
Jeff Johnsone7245742012-09-05 17:12:55 -0700360#define WLAN_STATS_RX_UC_BYTE_CNT 16
361#define WLAN_STATS_RX_MC_BYTE_CNT 17
362#define WLAN_STATS_RX_BC_BYTE_CNT 18
363#define WLAN_STATS_TX_UC_BYTE_CNT 19
364#define WLAN_STATS_TX_MC_BYTE_CNT 20
365#define WLAN_STATS_TX_BC_BYTE_CNT 21
366
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800367#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
368 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
369 { \
370 *__p++ = __type; \
371 *__p++ = __size; \
372 memcpy(__p, __val, __size); \
373 __p += __size; \
374 __tlen += __size + 2; \
375 } \
376 else \
377 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800378 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800379 } \
380 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382#define VERSION_VALUE_MAX_LEN 32
383
384#define TX_PER_TRACKING_DEFAULT_RATIO 5
385#define TX_PER_TRACKING_MAX_RATIO 10
386#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
387
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530388#define WLAN_ADAPTER 0
389#define P2P_ADAPTER 1
390
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530391#define TX_PWR_MIN 6
392#define TX_PWR_MAX 22
393#define TX_PWR_DEF 50
394
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530395/* Dynamic Aggregation */
396#define DISABLE_AGGREGATION 0
397#define ENABLE_AGGREGATION 1
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530398/*
399 * When supplicant sends SETBAND ioctl it queries for channels from
400 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
401 * This is not required if the return type from ioctl is
402 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
403 * event as part of regulatory_hint.
404 */
405enum {
406 SEND_CHANNEL_CHANGE_EVENT = 0,
407 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
408};
409
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800410/*MCC Configuration parameters */
411enum {
412 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
413 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
414 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
415 MCC_RX_DRAIN_TIME_CFG_PARAM,
416 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
417 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
418 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
419 MCC_MIN_AFTER_DTIM_CFG_PARAM,
420 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
421};
422
423int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
424 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530427int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700428#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530429static int get_fwr_memdump(struct net_device *,
430 struct iw_request_info *,
431 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700432/**---------------------------------------------------------------------------
433
Arif Hussain0273cba2014-01-07 20:58:29 -0800434 \brief mem_alloc_copy_from_user_helper -
435
436 Helper function to allocate buffer and copy user data.
437
438 \param - wrqu - Pointer to IOCTL Data.
439 len - size
440
441 \return - On Success pointer to buffer, On failure NULL
442
443 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530444void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800445{
446 u8 *ptr = NULL;
447
448 /* in order to protect the code, an extra byte is post appended to the buffer
449 * and the null termination is added. However, when allocating (len+1) byte
450 * of memory, we need to make sure that there is no uint overflow when doing
451 * addition. In theory check len < UINT_MAX protects the uint overflow. For
452 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
453 * guess, now, it is assumed that the private command buffer size is no
454 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
455 */
456 if (len > MAX_USER_COMMAND_SIZE)
457 {
458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
459 "Invalid length");
460 return NULL;
461 }
462
463 ptr = kmalloc(len + 1, GFP_KERNEL);
464 if (NULL == ptr)
465 {
466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
467 "unable to allocate memory");
468 return NULL;
469 }
470
471 if (copy_from_user(ptr, wrqu_data, len))
472 {
473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
474 "%s: failed to copy data to user buffer", __func__);
475 kfree(ptr);
476 return NULL;
477 }
478 ptr[len] = '\0';
479 return ptr;
480}
481
Girish Gowli488ef492014-06-12 18:44:33 +0530482// Function to handle and get compatible struct iw_point passed to ioctl.
483int hdd_priv_get_data(struct iw_point *p_priv_data,
484 union iwreq_data *wrqu)
485{
486 if ((NULL == p_priv_data) || (NULL == wrqu))
487 {
488 return -EINVAL;
489 }
490
491#ifdef CONFIG_COMPAT
492 if (is_compat_task())
493 {
494 struct compat_iw_point *p_compat_priv_data;
495
496 // Compat task: typecast to campat structure and copy the members.
497 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
498
499 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
500 p_priv_data->length = p_compat_priv_data->length;
501 p_priv_data->flags = p_compat_priv_data->flags;
502 }//if(is_compat_task())
503 else
504 {
505#endif //#ifdef CONFIG_COMPAT
506
507 // Non compat task: directly copy the structure.
508 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
509
510#ifdef CONFIG_COMPAT
511 }//else of - if(is_compat_task())
512#endif //#ifdef CONFIG_COMPAT
513
514 return 0;
515}
516
Arif Hussain0273cba2014-01-07 20:58:29 -0800517/**---------------------------------------------------------------------------
518
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 \brief hdd_wlan_get_version() -
520
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800521 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523 \param - pAdapter Pointer to the adapter.
524 wrqu - Pointer to IOCTL REQUEST Data.
525 extra - Pointer to char
526
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800530void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
531 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700532{
533 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800534 tSirVersionString wcnss_SW_version;
535 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530536 tSirVersionString iris_name;
537 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800538 char *pSWversion;
539 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800542 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
543 sizeof(wcnss_SW_version));
544 if (VOS_IS_STATUS_SUCCESS(status))
545 {
546 pSWversion = wcnss_SW_version;
547 }
548 else
549 {
550 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 }
552
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800553 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
554 sizeof(wcnss_HW_version));
555 if (VOS_IS_STATUS_SUCCESS(status))
556 {
557 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800559 else
560 {
561 pHWversion = "Unknown";
562 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530564 status = wcnss_get_iris_name(iris_name);
565
566 if (!status) {
567 pIRISversion = iris_name;
568 } else {
569 pIRISversion = "Unknown";
570 }
571
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700572 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530573 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800574 QWLAN_VERSIONSTR,
575 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530576 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800577
578 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579}
580
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530581#ifdef WLAN_FEATURE_RMC
582void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
583{
584 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
585 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
586 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
587 v_U8_t i;
588
589 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
590 {
591 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
592 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
593 for (i = 0; i < pPeerInfo->numPeers; i++)
594 {
595 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
596 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
597 }
598 }
599 else
600 {
601 hddLog(LOGE,
602 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
603 }
604
605 complete(&pAdapter->ibss_peer_info_comp);
606}
607
608v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
609{
610 v_U8_t idx;
611 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
612
613 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
614 {
615 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
616 staIdx == pHddStaCtx->conn_info.staId[ idx ])
617 {
618 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
619 }
620 }
621 return NULL;
622}
623
624eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
625{
626 eHalStatus status = eHAL_STATUS_FAILURE;
627 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
628 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
629 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
630
631 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
632 VOS_FALSE, staIdx);
633
634 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
635
636 if (eHAL_STATUS_SUCCESS == status)
637 {
638 long ret;
639 ret = wait_for_completion_interruptible_timeout
640 (&pAdapter->ibss_peer_info_comp,
641 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
642 if (ret <= 0)
643 {
644 hddLog(VOS_TRACE_LEVEL_ERROR,
645 FL("failed wait on ibss_peer_info_comp %ld"), ret);
646 return eHAL_STATUS_FAILURE;
647 }
648
649 /** Print the peer info */
650 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
651 pr_info("============================================================");
652 {
653 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
654 staIdx);
655 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
656
657 if (NULL != macAddr)
658 {
659 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
660 MAC_ADDR_ARRAY(macAddr->bytes),
661 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
662 }
663 else
664 {
665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
666 " ERROR: PEER MAC ADDRESS NOT FOUND ");
667 }
668 }
669 }
670 else
671 {
672 hddLog(VOS_TRACE_LEVEL_WARN,
673 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
674 }
675
676 return status;
677}
678
679eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
680{
681 eHalStatus status = eHAL_STATUS_FAILURE;
682 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
683 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
684 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
685 int i;
686
687 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
688 VOS_TRUE, 0xFF);
689 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
690
691 if (eHAL_STATUS_SUCCESS == status)
692 {
693 long ret;
694 ret = wait_for_completion_interruptible_timeout
695 (&pAdapter->ibss_peer_info_comp,
696 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
697 if (ret <= 0)
698 {
699 hddLog(VOS_TRACE_LEVEL_ERROR,
700 FL("failed wait on ibss_peer_info_comp %ld"), ret);
701 return eHAL_STATUS_FAILURE;
702 }
703
704 /** Print the peer info */
705 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
706 pr_info("============================================================");
707 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
708 {
709 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
710 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
711 staIdx);
712 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
713
714 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
715 if (NULL != macAddr)
716 {
717 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
718 MAC_ADDR_ARRAY(macAddr->bytes),
719 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
720 }
721 else
722 {
723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
724 " ERROR: PEER MAC ADDRESS NOT FOUND ");
725 }
726 }
727 }
728 else
729 {
730 hddLog(VOS_TRACE_LEVEL_WARN,
731 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
732 }
733
734 return status;
735}
736#endif /* WLAN_FEATURE_RMC */
737
Jeff Johnson295189b2012-06-20 16:38:30 -0700738int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
739{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530740 tHalHandle hHal;
741 hdd_context_t *pHddCtx;
742 v_U32_t threshold = 0;
743 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700744
745 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530746 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530747 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
749 "%s: Adapter is NULL",__func__);
750 return -EINVAL;
751 }
752
753 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
754 ret = wlan_hdd_validate_context(pHddCtx);
755 if (0 != ret)
756 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530757 return ret;
758 }
759
760 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
761 if (NULL == hHal)
762 {
763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
764 "%s: Hal Context is NULL",__func__);
765 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 }
767
768 if ( eHAL_STATUS_SUCCESS !=
769 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
770 {
c_hpothub8245442013-11-20 23:41:09 +0530771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
772 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 return -EIO;
774 }
775 wrqu->rts.value = threshold;
776
777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800778 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779
780 EXIT();
781
782 return 0;
783}
784
785int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
786{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530787 tHalHandle hHal;
788 hdd_context_t *pHddCtx;
789 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790
791 ENTER();
792
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530793 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
796 "%s: Adapter is NULL",__func__);
797 return -EINVAL;
798 }
799
800 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
801 status = wlan_hdd_validate_context(pHddCtx);
802 if (0 != status)
803 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530804 return status;
805 }
806
807 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
808 if (NULL == hHal)
809 {
810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
811 "%s: Hal Context is NULL",__func__);
812 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 }
814
815 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
816 != eHAL_STATUS_SUCCESS )
817 {
c_hpothub8245442013-11-20 23:41:09 +0530818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
819 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 return -EIO;
821 }
822 wrqu->frag.value = threshold;
823
824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800825 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 EXIT();
828
829 return 0;
830}
831
832int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
833{
Jeff Johnsone7245742012-09-05 17:12:55 -0700834 int i;
835 if (channel > 0)
836 {
837 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
838 {
839 if (channel == freq_chan_map[i].chan)
840 {
841 *pfreq = freq_chan_map[i].freq;
842 return 1;
843 }
844 }
845 }
846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800847 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700848 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700849}
850
851static v_BOOL_t
852hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
853{
854 v_BOOL_t rsnType = VOS_FALSE;
855 // is the authType supported?
856 switch (authType)
857 {
858 case eCSR_AUTH_TYPE_NONE: //never used
859 rsnType = eANI_BOOLEAN_FALSE;
860 break;
861 // MAC layer authentication types
862 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
863 rsnType = eANI_BOOLEAN_FALSE;
864 break;
865 case eCSR_AUTH_TYPE_SHARED_KEY:
866 rsnType = eANI_BOOLEAN_FALSE;
867 break;
868 case eCSR_AUTH_TYPE_AUTOSWITCH:
869 rsnType = eANI_BOOLEAN_FALSE;
870 break;
871
872 // Upper layer authentication types
873 case eCSR_AUTH_TYPE_WPA:
874 rsnType = eANI_BOOLEAN_TRUE;
875 break;
876 case eCSR_AUTH_TYPE_WPA_PSK:
877 rsnType = eANI_BOOLEAN_TRUE;
878 break;
879 case eCSR_AUTH_TYPE_WPA_NONE:
880 rsnType = eANI_BOOLEAN_TRUE;
881 break;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 case eCSR_AUTH_TYPE_FT_RSN:
884#endif
885 case eCSR_AUTH_TYPE_RSN:
886 rsnType = eANI_BOOLEAN_TRUE;
887 break;
888#ifdef WLAN_FEATURE_VOWIFI_11R
889 case eCSR_AUTH_TYPE_FT_RSN_PSK:
890#endif
891 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700892#ifdef WLAN_FEATURE_11W
893 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530894 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 rsnType = eANI_BOOLEAN_TRUE;
897 break;
898 //case eCSR_AUTH_TYPE_FAILED:
899 case eCSR_AUTH_TYPE_UNKNOWN:
900 rsnType = eANI_BOOLEAN_FALSE;
901 break;
902 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800903 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
904 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 rsnType = eANI_BOOLEAN_FALSE;
906 break;
907 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800908 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700909 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 return rsnType;
911}
912
Jeff Johnson295189b2012-06-20 16:38:30 -0700913
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530914struct snr_priv {
915 int8_t snr;
916};
917
918/**
919 * hdd_get_snr_cb() - "Get SNR" callback function
920 * @snr: Current SNR of the station
921 * @sta_id: ID of the station
922 * @context: opaque context originally passed to SME. HDD always passes
923 * a cookie for the request context
924 *
925 * Return: None
926 */
927static void hdd_get_snr_cb(tANI_S8 snr, tANI_U32 staId, void *context)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530928{
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530929 struct hdd_request *request;
930 struct snr_priv *priv;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530931
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530932 request = hdd_request_get(context);
933 if (!request) {
934 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
935 return;
936 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530937
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530938 /* propagate response back to requesting thread */
939 priv = hdd_request_priv(request);
940 priv->snr = snr;
941 hdd_request_complete(request);
942 hdd_request_put(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530943}
944
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530945struct rssi_priv {
946 v_S7_t rssi;
947};
948
949static void hdd_get_rssi_cb( v_S7_t rssi, tANI_U32 staId, void *context )
950{
951 struct hdd_request *request;
952 struct rssi_priv *priv;
953
954 if (ioctl_debug) {
955 pr_info("%s: rssi [%d] STA [%d] context [%pK]\n",
956 __func__, (int)rssi, (int)staId, context);
957 }
958
959 request = hdd_request_get(context);
960 if (!request) {
961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
962 return;
963 }
964
965 priv = hdd_request_priv(request);
966 priv->rssi = rssi;
967
968 hdd_request_complete(request);
969 hdd_request_put(request);
970}
971
Jeff Johnson295189b2012-06-20 16:38:30 -0700972VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
973{
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 hdd_context_t *pHddCtx;
975 hdd_station_ctx_t *pHddStaCtx;
976 eHalStatus hstatus;
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530977 int ret;
978 void *cookie;
979 struct hdd_request *request;
980 struct rssi_priv *priv;
981 static const struct hdd_request_params params = {
982 .priv_size = sizeof(*priv),
983 .timeout_ms = WLAN_WAIT_TIME_STATS,
984 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 if (NULL == pAdapter)
987 {
988 hddLog(VOS_TRACE_LEVEL_WARN,
989 "%s: Invalid context, pAdapter", __func__);
990 return VOS_STATUS_E_FAULT;
991 }
992 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
993 {
994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
995 /* return a cached value */
996 *rssi_value = pAdapter->rssi;
997 return VOS_STATUS_SUCCESS;
998 }
999
1000 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1001 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1002
mukul sharma8aec69b2015-06-10 22:28:43 +05301003 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1004 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1006 __func__, pAdapter->rssi_on_disconnect);
1007 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301008 return VOS_STATUS_SUCCESS;
1009 }
1010
1011 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1012 {
1013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1014 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1015 *rssi_value = pAdapter->rssi;
1016 return VOS_STATUS_SUCCESS;
1017 }
1018
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301019 request = hdd_request_alloc(&params);
1020 if (!request) {
1021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1022 return VOS_STATUS_E_NOMEM;
1023 }
1024 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301026 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pHddStaCtx->conn_info.staId[ 0 ],
1028 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301029 cookie, pHddCtx->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 if (eHAL_STATUS_SUCCESS != hstatus)
1031 {
1032 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001033 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /* we'll returned a cached value below */
1035 }
1036 else
1037 {
1038 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301039 ret = hdd_request_wait_for_response(request);
1040 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 {
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301042 hddLog(VOS_TRACE_LEVEL_ERROR,
1043 FL("SME timeout while retrieving RSSI"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 /* we'll now returned a cached value below */
1045 }
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301046 else
1047 {
1048 priv = hdd_request_priv(request);
1049 pAdapter->rssi = priv->rssi;
1050 /*
1051 * copy over the rssi.FW will return RSSI as -100 if
1052 * there are no samples to calculate the averag RSSI
1053 */
1054 if (priv->rssi != -100)
1055 pAdapter->rssi = priv->rssi;
Jeff Johnson72a40512013-12-19 10:14:15 -08001056
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301057 if (pAdapter->rssi > 0)
1058 pAdapter->rssi = 0;
1059 }
1060 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301063 hddLog(VOS_TRACE_LEVEL_INFO,
1064 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301066 /*
1067 * either we never sent a request, we sent a request and received a
1068 * response or we sent a request and timed out. Regardless we are
1069 * done with the request.
1070 */
1071 hdd_request_put(request);
1072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 return VOS_STATUS_SUCCESS;
1074}
Siddharth Bhal64246172015-02-27 01:04:37 +05301075/**---------------------------------------------------------------------------
1076
1077 \brief wlan_hdd_get_frame_logs() -
1078
1079 This function use to get Frames log.
1080
1081 \param - pAdapter Pointer to the adapter.
1082 flag - Specify type of request. Clear and Send request are
1083 supported.
1084
1085 \return - none
1086
1087 --------------------------------------------------------------------------*/
1088VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1089{
Siddharth Bhal64246172015-02-27 01:04:37 +05301090 hdd_context_t *pHddCtx;
1091 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301092
1093 if (NULL == pAdapter)
1094 {
1095 hddLog(VOS_TRACE_LEVEL_WARN,
1096 "%s: Invalid context, pAdapter", __func__);
1097 return VOS_STATUS_E_FAULT;
1098 }
1099
1100 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1101 if (!pHddCtx->mgmt_frame_logging)
1102 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301103 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301104 return VOS_STATUS_E_AGAIN;
1105 }
1106
Siddharth Bhal4507c262015-04-29 20:20:42 +05301107 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1108 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1109 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301110 {
1111 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1112 return VOS_STATUS_E_INVAL;
1113 }
1114
Siddharth Bhal4507c262015-04-29 20:20:42 +05301115 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1116 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1119 return VOS_STATUS_E_INVAL;
1120 }
1121
Abhishek Singh611295e2015-07-09 11:11:54 +05301122 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301123 if (eHAL_STATUS_SUCCESS != hstatus)
1124 {
1125 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301126 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301127 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301128
1129 return VOS_STATUS_SUCCESS;
1130}
1131
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301132
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301133VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1134{
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301135 hdd_context_t *pHddCtx;
1136 hdd_station_ctx_t *pHddStaCtx;
1137 eHalStatus hstatus;
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301138 int ret;
1139 void *cookie;
1140 struct hdd_request *request;
1141 struct snr_priv *priv;
1142 static const struct hdd_request_params params = {
1143 .priv_size = sizeof(*priv),
1144 .timeout_ms = WLAN_WAIT_TIME_STATS,
1145 };
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301147 ENTER();
1148
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301149 if (NULL == pAdapter)
1150 {
1151 hddLog(VOS_TRACE_LEVEL_ERROR,
1152 "%s: Invalid context, pAdapter", __func__);
1153 return VOS_STATUS_E_FAULT;
1154 }
1155
1156 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1157
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301158 ret = wlan_hdd_validate_context(pHddCtx);
1159 if (0 != ret)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301160 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301161 return VOS_STATUS_E_FAULT;
1162 }
1163
1164 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1165 if (NULL == pHddStaCtx)
1166 {
1167 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1168 return VOS_STATUS_E_FAULT;
1169 }
1170
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301171 request = hdd_request_alloc(&params);
1172 if (!request) {
1173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1174 return VOS_STATUS_E_FAULT;
1175 }
1176 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301177
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301178 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_get_snr_cb,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301179 pHddStaCtx->conn_info.staId[ 0 ],
1180 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301181 cookie);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301182 if (eHAL_STATUS_SUCCESS != hstatus)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1185 __func__);
1186 /* we'll returned a cached value below */
1187 }
1188 else
1189 {
1190 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301191 ret = hdd_request_wait_for_response(request);
1192 if (ret) {
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 FL("SME timed out while retrieving SNR"));
1195 /* we'll now returned a cached value below */
1196 } else {
1197 /* update the adapter with the fresh results */
1198 priv = hdd_request_priv(request);
1199 pAdapter->snr = priv->snr;
1200 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301201 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001202
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301203 /*
1204 * either we never sent a request, we sent a request and
1205 * received a response or we sent a request and timed out.
1206 * regardless we are done with the request.
1207 */
1208 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001209
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301210 *snr = pAdapter->snr;
1211
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301212 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301213 return VOS_STATUS_SUCCESS;
1214}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301215
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001216#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001217
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1219{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001220 hdd_context_t *pHddCtx = NULL;
1221 hdd_station_ctx_t *pHddStaCtx = NULL;
1222 eHalStatus hstatus;
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301223 int ret;
1224 void *cookie;
1225 struct hdd_request *request;
1226 struct rssi_priv *priv;
1227 static const struct hdd_request_params params = {
1228 .priv_size = sizeof(*priv),
1229 .timeout_ms = WLAN_WAIT_TIME_STATS,
1230 };
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001231
1232 if (NULL == pAdapter)
1233 {
1234 hddLog(VOS_TRACE_LEVEL_WARN,
1235 "%s: Invalid context, pAdapter", __func__);
1236 return VOS_STATUS_E_FAULT;
1237 }
1238 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1239 {
1240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1241 /* return a cached value */
1242 *rssi_value = pAdapter->rssi;
1243 return VOS_STATUS_SUCCESS;
1244 }
1245
1246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1247 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1248
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301249 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001250 {
1251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1252 /* return a cached value */
1253 *rssi_value = 0;
1254 return VOS_STATUS_SUCCESS;
1255 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301256
1257 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1258 {
1259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1260 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1261 *rssi_value = pAdapter->rssi;
1262 return VOS_STATUS_SUCCESS;
1263 }
1264
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301265 request = hdd_request_alloc(&params);
1266 if (!request) {
1267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1268 return VOS_STATUS_E_NOMEM;
1269 }
1270 cookie = hdd_request_cookie(request);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001271
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301272 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001273 pHddStaCtx->conn_info.staId[ 0 ],
1274 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301275 cookie, pHddCtx->pvosContext);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001276 if (eHAL_STATUS_SUCCESS != hstatus)
1277 {
1278 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1279 __func__);
1280 /* we'll returned a cached value below */
1281 }
1282 else
1283 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301284 ret = hdd_request_wait_for_response(request);
1285 if(ret)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001286 /* request was sent -- wait for the response */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001287 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301288 hddLog(VOS_TRACE_LEVEL_ERROR,
1289 FL(" SME timeout while retrieving RSSI"));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001290 /* we'll now returned a cached value below */
1291 }
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301292 else
1293 {
1294 priv = hdd_request_priv(request);
1295 pAdapter->rssi = priv->rssi;
1296 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001297 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001298
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301299 /*
1300 * either we never sent a request, we sent a request and received a
1301 * response or we sent a request and timed out. Regardless we are
1302 * done with the request.
1303 */
1304 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001305
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001306 *rssi_value = pAdapter->rssi;
1307
1308 return VOS_STATUS_SUCCESS;
1309}
1310#endif
1311
1312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313void hdd_StatisticsCB( void *pStats, void *pContext )
1314{
1315 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1316 hdd_stats_t *pStatsCache = NULL;
1317 hdd_wext_state_t *pWextState;
1318 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1319
1320 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1321 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1322 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1323 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1324 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1325 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1326
1327 if (pAdapter!= NULL)
1328 pStatsCache = &pAdapter->hdd_stats;
1329
1330
1331 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1332 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1333 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1334 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1335 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1336 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1337
1338 if (pStatsCache!=NULL)
1339 {
1340 // and copy the stats into the cache we keep in the adapter instance structure
1341 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1342 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1343 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1344 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1345 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1346 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1347 }
1348
1349 if(pAdapter)
1350 {
1351 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1352 if(pWextState)
1353 {
1354 vos_status = vos_event_set(&pWextState->vosevent);
1355 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1356 {
1357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001358 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 return;
1360 }
1361 }
1362 }
1363}
1364
1365void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1366{
1367 v_CONTEXT_t pVosContext;
1368 hdd_context_t *pHddCtx;
1369 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1370#if 0
1371 hdd_wext_state_t *pWextState;
1372 v_U32_t roamId;
1373#endif
1374
1375 ENTER();
1376
1377 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1378
1379 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1380 if (NULL == pHddCtx)
1381 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 return;
1384 }
1385#if 0
1386 pWextState = pAdapter->pWextState;
1387#endif
1388
1389 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1390 {
1391 //TODO Verify is this is really used. If yes need to fix it.
1392 hdd_reconnect_all_adapters( pHddCtx );
1393#if 0
1394 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1395 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1396 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1397
1398 if(VOS_STATUS_SUCCESS == vosStatus)
1399 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1400 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1401
1402 sme_RoamConnect(halHandle,
1403 pAdapter->sessionId, &(pWextState->roamProfile),
1404 &roamId);
1405#endif
1406 }
1407
1408 EXIT();
1409
1410}
1411
1412void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1413{
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1415
1416 /* clear WPA/RSN/WSC IE information in the profile */
1417 pWextState->roamProfile.nWPAReqIELength = 0;
1418 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1419 pWextState->roamProfile.nRSNReqIELength = 0;
1420 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1421
Chet Lanctot186b5732013-03-18 10:26:30 -07001422#ifdef FEATURE_WLAN_WAPI
1423 pWextState->roamProfile.nWAPIReqIELength = 0;
1424 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1425#endif
1426
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001428 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301430 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1432 pWextState->roamProfile.nAddIEAssocLength = 0;
1433
1434 pWextState->roamProfile.EncryptionType.numEntries = 1;
1435 pWextState->roamProfile.EncryptionType.encryptionType[0]
1436 = eCSR_ENCRYPT_TYPE_NONE;
1437
1438 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1439 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1440 = eCSR_ENCRYPT_TYPE_NONE;
1441
1442 pWextState->roamProfile.AuthType.numEntries = 1;
1443 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1444
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301445 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001446#ifdef WLAN_FEATURE_11W
1447 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1448 pWextState->roamProfile.MFPRequired = 0;
1449 pWextState->roamProfile.MFPCapable = 0;
1450#endif
1451
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 pWextState->authKeyMgmt = 0;
1453
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301454 vos_mem_zero(&pWextState->roamProfile.Keys,
1455 sizeof(pWextState->roamProfile.Keys));
1456
Jeff Johnson295189b2012-06-20 16:38:30 -07001457#ifdef FEATURE_WLAN_WAPI
1458 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1459 pAdapter->wapi_info.nWapiMode = 0;
1460#endif
1461
1462 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1463
1464}
1465
1466void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1467{
1468 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469
Nirav Shahf6bd2672015-03-11 12:53:15 +05301470 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001471 {
1472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301473 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001474 }
1475 else
1476 {
1477 complete(&pAdapter->ula_complete);
1478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001479}
1480
1481VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1482{
1483 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001485 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
1487 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1488 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001489 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
1491 /*To avoid race condition between the set key and the last EAPOL
1492 packet, notify TL to finish upper layer authentication incase if the
1493 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001494 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001496 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 {
1498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1499 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1500 __LINE__, vos_status );
1501 return vos_status;
1502
1503 }
1504
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001505 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301507 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001508 {
1509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301510 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001511 /* we'll still fall through and return success since the
1512 * connection may still get established but is just taking
1513 * too long for us to wait */
1514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 }
1516 return VOS_STATUS_SUCCESS;
1517}
1518
1519v_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)
1520{
1521
1522 int left = ie_len;
1523 v_U8_t *ptr = ie;
1524 v_U8_t elem_id,elem_len;
1525 v_U8_t eid = 0xDD;
1526
1527 if ( NULL == ie || 0 == ie_len )
1528 return NULL;
1529
1530 while(left >= 2)
1531 {
1532 elem_id = ptr[0];
1533 elem_len = ptr[1];
1534 left -= 2;
1535 if(elem_len > left)
1536 {
1537 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001538 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 eid,elem_len,left);
1540 return NULL;
1541 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301542 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 {
1544 if(memcmp( &ptr[2], oui, oui_size)==0)
1545 return ptr;
1546 }
1547
1548 left -= elem_len;
1549 ptr += (elem_len + 2);
1550 }
1551 return NULL;
1552}
1553
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301554static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 union iwreq_data *wrqu, char *extra)
1556{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301557 hdd_adapter_t *pAdapter;
1558 hdd_context_t *pHddCtx;
1559 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560
1561 ENTER();
1562
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301563 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1564 if (NULL == pAdapter)
1565 {
1566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1567 "%s: pAdapter is NULL\n", __func__);
1568 return -EINVAL;
1569 }
1570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1571 ret = wlan_hdd_validate_context(pHddCtx);
1572 if (0 != ret)
1573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301574 return ret;
1575 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301576
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301578
1579 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301580 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581}
1582
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301583static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1584 union iwreq_data *wrqu, char *extra)
1585{
1586 int ret;
1587
1588 vos_ssr_protect(__func__);
1589 ret = __iw_set_commit(dev, info, wrqu, extra);
1590 vos_ssr_unprotect(__func__);
1591
1592 return ret;
1593}
1594
1595static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 struct iw_request_info *info,
1597 char *wrqu, char *extra)
1598{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301599 hdd_adapter_t *pAdapter;
1600 hdd_context_t *pHddCtx;
1601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301602
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1605 if (NULL == pAdapter)
1606 {
1607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1608 "%s: pAdapter is NULL\n", __func__);
1609 return -EINVAL;
1610 }
1611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1612 ret = wlan_hdd_validate_context(pHddCtx);
1613 if (0 != ret)
1614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301615 return ret;
1616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1618 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301619 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001620}
1621
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301622static int iw_get_name(struct net_device *dev,
1623 struct iw_request_info *info,
1624 char *wrqu, char *extra)
1625{
1626 int ret;
1627
1628 vos_ssr_protect(__func__);
1629 ret = __iw_get_name(dev, info, wrqu, extra);
1630 vos_ssr_unprotect(__func__);
1631
1632 return ret;
1633}
1634
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301635static int __iw_set_mode(struct net_device *dev,
1636 struct iw_request_info *info,
1637 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001638{
1639 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301640 hdd_adapter_t *pAdapter;
1641 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 tCsrRoamProfile *pRoamProfile;
1643 eCsrRoamBssType LastBSSType;
1644 eMib_dot11DesiredBssType connectedBssType;
1645 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301647 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
1649 ENTER();
1650
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301651 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 if (NULL == pAdapter)
1653 {
1654 hddLog(VOS_TRACE_LEVEL_WARN,
1655 "%s: Invalid context, pAdapter", __func__);
1656 return 0;
1657 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1659 status = wlan_hdd_validate_context(pHddCtx);
1660 if (0 != status)
1661 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301662 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 }
1664
1665 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1666 if (pWextState == NULL)
1667 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301668 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 return -EINVAL;
1670 }
1671
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 pRoamProfile = &pWextState->roamProfile;
1674 LastBSSType = pRoamProfile->BSSType;
1675
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301676 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
1678 switch (wrqu->mode)
1679 {
1680 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301681 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1683 // Set the phymode correctly for IBSS.
1684 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1685 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001686 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 break;
1689 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301690 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 break;
1694 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301695 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1697 break;
1698 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301699 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 return -EOPNOTSUPP;
1701 }
1702
1703 if ( LastBSSType != pRoamProfile->BSSType )
1704 {
1705 //the BSS mode changed
1706 // We need to issue disconnect if connected or in IBSS disconnect state
1707 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1708 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1709 {
1710 VOS_STATUS vosStatus;
1711 // need to issue a disconnect to CSR.
1712 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1713 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1714 pAdapter->sessionId,
1715 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1716 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301717 {
1718 long ret;
1719 ret = wait_for_completion_interruptible_timeout(
1720 &pAdapter->disconnect_comp_var,
1721 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1722 if (ret <= 0)
1723 hddLog(VOS_TRACE_LEVEL_ERROR,
1724 FL("failed wait on disconnect_comp_var %ld"), ret);
1725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 }
1727 }
1728
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 EXIT();
1730 return 0;
1731}
1732
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301733static int iw_set_mode(struct net_device *dev,
1734 struct iw_request_info *info,
1735 union iwreq_data *wrqu, char *extra)
1736{
1737 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001738
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301739 vos_ssr_protect(__func__);
1740 ret = __iw_set_mode(dev, info, wrqu, extra);
1741 vos_ssr_unprotect(__func__);
1742
1743 return ret;
1744}
1745
1746static int __iw_get_mode(struct net_device *dev,
1747 struct iw_request_info *info,
1748 union iwreq_data *wrqu,
1749 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001750{
1751
1752 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301753 hdd_adapter_t *pAdapter;
1754 hdd_context_t *pHddCtx;
1755 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001756
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301757 ENTER();
1758
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301759 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 if (NULL == pAdapter)
1761 {
1762 hddLog(VOS_TRACE_LEVEL_WARN,
1763 "%s: Invalid context, pAdapter", __func__);
1764 return 0;
1765 }
1766
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301767 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1768 ret = wlan_hdd_validate_context(pHddCtx);
1769 if (0 != ret)
1770 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301771 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1774 if (pWextState == NULL)
1775 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301776 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 return -EINVAL;
1778 }
1779
1780 switch (pWextState->roamProfile.BSSType)
1781 {
1782 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001783 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301784 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 break;
1786 case eCSR_BSS_TYPE_IBSS:
1787 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001788 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301789 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 break;
1791 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001792 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301793 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 break;
1795 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001796 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 break;
1798 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301799
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301800 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 return 0;
1802}
1803
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301804static int iw_get_mode(struct net_device *dev,
1805 struct iw_request_info *info,
1806 union iwreq_data *wrqu,
1807 char *extra)
1808{
1809 int ret;
1810
1811 vos_ssr_protect(__func__);
1812 ret = __iw_get_mode(dev, info, wrqu, extra);
1813 vos_ssr_unprotect(__func__);
1814
1815 return ret;
1816}
1817
1818static int __iw_set_freq(struct net_device *dev,
1819 struct iw_request_info *info,
1820 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001821{
1822 v_U32_t numChans = 0;
1823 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1824 v_U32_t indx = 0;
1825 v_U32_t status = 0;
1826
1827 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301828 hdd_adapter_t *pAdapter;
1829 hdd_context_t *pHddCtx;
1830 tHalHandle hHal;
1831 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 ENTER();
1835
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301836 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1837 if (NULL == pAdapter)
1838 {
1839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1840 "%s:Invalid Adapter",__func__);
1841 return -EINVAL;
1842 }
1843
1844 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1845 status = wlan_hdd_validate_context(pHddCtx);
1846 if (0 != status)
1847 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 return status;
1849 }
1850
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301851 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1852 if (NULL == hHal)
1853 {
1854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1855 "%s: Hal Context is NULL",__func__);
1856 return -EINVAL;
1857 }
1858
1859 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1860 if (NULL == pHddStaCtx)
1861 {
1862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1863 "%s:STA context is NULL",__func__);
1864 return -EINVAL;
1865 }
1866
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301868 if (NULL == pWextState)
1869 {
1870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1871 "%s: pWextState is NULL",__func__);
1872 return -EINVAL;
1873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001874
1875 pRoamProfile = &pWextState->roamProfile;
1876
Arif Hussain6d2a3322013-11-17 19:50:10 -08001877 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001878
1879 /* Link is up then return cant set channel*/
1880 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1881 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1882 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001883 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 return -EOPNOTSUPP;
1885 }
1886
1887 /* Settings by Frequency as input */
1888 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1889 (wrqu->freq.m <= (tANI_U32)5.825e8))
1890 {
1891 tANI_U32 freq = wrqu->freq.m / 100000;
1892
1893 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1894 indx++;
1895 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1896 {
1897 return -EINVAL;
1898 }
1899 wrqu->freq.e = 0;
1900 wrqu->freq.m = freq_chan_map[indx].chan;
1901
1902 }
1903
1904 if (wrqu->freq.e == 0)
1905 {
1906 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1907 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1908 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001909 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001910 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1912 return -EINVAL;
1913 }
1914
1915 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1916
1917 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1918 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1920 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 return -EIO;
1922 }
1923
1924 for (indx = 0; indx < numChans; indx++) {
1925 if (wrqu->freq.m == validChan[indx]){
1926 break;
1927 }
1928 }
1929 }
1930 else{
1931
1932 return -EINVAL;
1933 }
1934
1935 if(indx >= numChans)
1936 {
1937 return -EINVAL;
1938 }
1939
1940 /* Set the Operational Channel */
1941 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1942 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1943 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1944
Arif Hussain6d2a3322013-11-17 19:50:10 -08001945 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001946
1947 EXIT();
1948
1949 return status;
1950}
1951
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301952static int iw_set_freq(struct net_device *dev,
1953 struct iw_request_info *info,
1954 union iwreq_data *wrqu, char *extra)
1955{
1956 int ret;
1957
1958 vos_ssr_protect(__func__);
1959 ret = __iw_set_freq(dev, info, wrqu, extra);
1960 vos_ssr_unprotect(__func__);
1961
1962 return ret;
1963}
1964
1965static int __iw_get_freq(struct net_device *dev,
1966 struct iw_request_info *info,
1967 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001968{
Jeff Johnsone7245742012-09-05 17:12:55 -07001969 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301970 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 tHalHandle hHal;
1972 hdd_wext_state_t *pWextState;
1973 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301974 hdd_station_ctx_t *pHddStaCtx;
1975 hdd_context_t *pHddCtx;
1976 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977
1978 ENTER();
1979
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301980 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1981 if (NULL == pAdapter)
1982 {
1983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1984 "%s: Adapter is NULL", __func__);
1985 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1988 ret = wlan_hdd_validate_context(pHddCtx);
1989 if (0 != ret)
1990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301991 return ret;
1992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301994 if (NULL == hHal)
1995 {
1996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1997 "%s: Hal Context is NULL",__func__);
1998 return -EINVAL;
1999 }
2000 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2001 if (NULL == pHddStaCtx)
2002 {
2003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2004 "%s: HddStaCtx is NULL", __func__);
2005 return -EINVAL;
2006 }
2007 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2008 if (NULL == pWextState)
2009 {
2010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2011 "%s: pWextState is NULL",__func__);
2012 return -EINVAL;
2013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 pRoamProfile = &pWextState->roamProfile;
2015
2016 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2017 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002018 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 {
c_hpothub8245442013-11-20 23:41:09 +05302020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2021 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 return -EIO;
2023 }
2024 else
2025 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002026 status = hdd_wlan_get_freq(channel, &freq);
2027 if( TRUE == status )
2028 {
2029 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2030 * iwlist & iwconfig command shows frequency into proper
2031 * format (2.412 GHz instead of 246.2 MHz)*/
2032 fwrq->m = freq;
2033 fwrq->e = MHZ;
2034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 }
2036 }
2037 else
2038 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002039 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2040 * iwlist & iwconfig command shows frequency into proper
2041 * format (2.412 GHz instead of 246.2 MHz)*/
2042 fwrq->m = 0;
2043 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302045
2046 EXIT();
2047 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002048}
2049
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302050static int iw_get_freq(struct net_device *dev,
2051 struct iw_request_info *info,
2052 struct iw_freq *fwrq, char *extra)
2053{
2054 int ret;
2055
2056 vos_ssr_protect(__func__);
2057 ret = __iw_get_freq(dev, info, fwrq, extra);
2058 vos_ssr_unprotect(__func__);
2059
2060 return ret;
2061}
2062
2063static int __iw_get_tx_power(struct net_device *dev,
2064 struct iw_request_info *info,
2065 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002066{
2067
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 hdd_adapter_t *pAdapter;
2069 hdd_context_t *pHddCtx;
2070 hdd_station_ctx_t *pHddStaCtx;
2071 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302073 ENTER();
2074
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302075 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2076 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2079 "%s: Adapter is NULL",__func__);
2080 return -EINVAL;
2081 }
2082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2083 ret = wlan_hdd_validate_context(pHddCtx);
2084 if (0 != ret)
2085 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302086 return ret;
2087 }
2088
2089 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2090 if (NULL == pHddStaCtx)
2091 {
2092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2093 "%s: STA Context is NULL",__func__);
2094 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 }
2096
2097 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2098 {
2099 wrqu->txpower.value = 0;
2100 return 0;
2101 }
2102 wlan_hdd_get_classAstats(pAdapter);
2103 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2104
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302105 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 return 0;
2107}
2108
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302109static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 struct iw_request_info *info,
2111 union iwreq_data *wrqu, char *extra)
2112{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302113 int ret;
2114
2115 vos_ssr_protect(__func__);
2116 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2117 vos_ssr_unprotect(__func__);
2118
2119 return ret;
2120}
2121
2122static int __iw_set_tx_power(struct net_device *dev,
2123 struct iw_request_info *info,
2124 union iwreq_data *wrqu, char *extra)
2125{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302126 hdd_adapter_t *pAdapter;
2127 tHalHandle hHal;
2128 hdd_context_t *pHddCtx;
2129 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002130
2131 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302132 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2133 if (NULL == pAdapter)
2134 {
2135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2136 "%s: Adapter is NULL",__func__);
2137 return -EINVAL;
2138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002139
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302140 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2141 ret = wlan_hdd_validate_context(pHddCtx);
2142 if (0 != ret)
2143 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302144 return ret;
2145 }
2146
2147 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2148 if (NULL == hHal)
2149 {
2150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2151 "%s: Hal Context is NULL",__func__);
2152 return -EINVAL;
2153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2155 {
c_hpothub8245442013-11-20 23:41:09 +05302156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2157 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 return -EIO;
2159 }
2160
2161 EXIT();
2162
2163 return 0;
2164}
2165
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302166static int iw_set_tx_power(struct net_device *dev,
2167 struct iw_request_info *info,
2168 union iwreq_data *wrqu, char *extra)
2169{
2170 int ret;
2171
2172 vos_ssr_protect(__func__);
2173 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2174 vos_ssr_unprotect(__func__);
2175
2176 return ret;
2177}
2178
2179static int __iw_get_bitrate(struct net_device *dev,
2180 struct iw_request_info *info,
2181 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002182{
2183 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2184 eHalStatus status = eHAL_STATUS_SUCCESS;
2185 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302186 hdd_adapter_t *pAdapter;
2187 hdd_context_t *pHddCtx;
2188 hdd_station_ctx_t *pHddStaCtx;
2189 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190
2191 ENTER();
2192
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302193 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2194 if (NULL == pAdapter)
2195 {
2196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2197 "%s: Adapter is NULL",__func__);
2198 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 }
2200
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302201 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2202 ret = wlan_hdd_validate_context(pHddCtx);
2203 if (0 != ret)
2204 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302205 return ret;
2206 }
2207
2208 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2209 if (NULL == pHddStaCtx)
2210 {
2211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2212 "%s: STA Context is NULL",__func__);
2213 return -EINVAL;
2214 }
2215
2216 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 wrqu->bitrate.value = 0;
2218 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302219 else
2220 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2222 SME_SUMMARY_STATS |
2223 SME_GLOBAL_CLASSA_STATS |
2224 SME_GLOBAL_CLASSB_STATS |
2225 SME_GLOBAL_CLASSC_STATS |
2226 SME_GLOBAL_CLASSD_STATS |
2227 SME_PER_STA_STATS,
2228 hdd_StatisticsCB, 0, FALSE,
2229 pHddStaCtx->conn_info.staId[0], pAdapter );
2230
2231 if(eHAL_STATUS_SUCCESS != status)
2232 {
2233 hddLog(VOS_TRACE_LEVEL_ERROR,
2234 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002235 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 return status;
2237 }
2238
2239 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302240 if (NULL == pWextState)
2241 {
2242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2243 "%s: pWextState is NULL",__func__);
2244 return -EINVAL;
2245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2248
2249 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2250 {
2251 hddLog(VOS_TRACE_LEVEL_ERROR,
2252 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002253 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 return VOS_STATUS_E_FAILURE;
2255 }
2256
2257 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2258 }
2259
2260 EXIT();
2261
2262 return vos_status;
2263}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302264
2265static int iw_get_bitrate(struct net_device *dev,
2266 struct iw_request_info *info,
2267 union iwreq_data *wrqu, char *extra)
2268{
2269 int ret;
2270
2271 vos_ssr_protect(__func__);
2272 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2273 vos_ssr_unprotect(__func__);
2274
2275 return ret;
2276}
2277
2278
Jeff Johnson295189b2012-06-20 16:38:30 -07002279/* ccm call back function */
2280
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302281static int __iw_set_bitrate(struct net_device *dev,
2282 struct iw_request_info *info,
2283 union iwreq_data *wrqu,
2284 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002285{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302286 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302288 hdd_station_ctx_t *pHddStaCtx;
2289 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2291 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2292 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2293 v_U32_t i, rate;
2294 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302295 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002296
2297 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302298 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2299 if (NULL == pAdapter)
2300 {
2301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2302 "%s: Adapter is NULL",__func__);
2303 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302306 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2307 ret = wlan_hdd_validate_context(pHddCtx);
2308 if (0 != ret)
2309 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302310 return ret;
2311 }
2312
2313 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2314 if (NULL == pHddStaCtx)
2315 {
2316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2317 "%s: STA Context is NULL",__func__);
2318 return -EINVAL;
2319 }
2320
2321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302323 if (NULL == pWextState)
2324 {
2325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2326 "%s: pWextState is NULL",__func__);
2327 return -EINVAL;
2328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002329
2330 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2331 {
2332 return -ENXIO ;
2333 }
2334
2335 rate = wrqu->bitrate.value;
2336
2337 if (rate == -1)
2338 {
2339 rate = WNI_CFG_FIXED_RATE_AUTO;
2340 valid_rate = TRUE;
2341 }
2342 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2343 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2344 {
2345 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2346 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2347 {
2348 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2349 WNI_CFG_SUPPORTED_RATES_11A,
2350 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2351 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2352 WNI_CFG_SUPPORTED_RATES_11B,
2353 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2354 {
2355 for (i = 0; i < (b_len + a_len); ++i)
2356 {
2357 /* supported rates returned is double the actual rate so we divide it by 2 */
2358 if ((supp_rates[i]&0x7F)/2 == rate)
2359 {
2360 valid_rate = TRUE;
2361 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2362 break;
2363 }
2364 }
2365 }
2366 }
2367 }
2368 if (valid_rate != TRUE)
2369 {
2370 return -EINVAL;
2371 }
2372 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2373 WNI_CFG_FIXED_RATE, rate,
2374 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2375 {
c_hpothub8245442013-11-20 23:41:09 +05302376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2377 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 return -EIO;
2379 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302380
2381 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 return 0;
2383}
2384
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302385static int iw_set_bitrate(struct net_device *dev,
2386 struct iw_request_info *info,
2387 union iwreq_data *wrqu,
2388 char *extra)
2389{
2390 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002391
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302392 vos_ssr_protect(__func__);
2393 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2394 vos_ssr_unprotect(__func__);
2395
2396 return ret;
2397}
2398
2399static int __iw_set_genie(struct net_device *dev,
2400 struct iw_request_info *info,
2401 union iwreq_data *wrqu,
2402 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002403{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302404 hdd_adapter_t *pAdapter;
2405 hdd_context_t *pHddCtx;
2406 hdd_wext_state_t *pWextState;
2407 u_int8_t *genie = NULL;
2408 u_int8_t *base_genie = NULL;
2409 v_U16_t remLen;
2410 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002411
2412 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002413
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302414 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2415 if (NULL == pAdapter)
2416 {
2417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2418 "%s: Adapter is NULL",__func__);
2419 return -EINVAL;
2420 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002421
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302422 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2423 ret = wlan_hdd_validate_context(pHddCtx);
2424 if (0 != ret)
2425 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302426 return ret;
2427 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002428
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302429 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2430 if (NULL == pWextState)
2431 {
2432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2433 "%s: pWextState is NULL",__func__);
2434 return -EINVAL;
2435 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002436
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302437 if (!wrqu->data.length) {
2438 hdd_clearRoamProfileIe(pAdapter);
2439 EXIT();
2440 return 0;
2441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002442
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302443 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2444 wrqu->data.length);
2445 if (NULL == base_genie)
2446 {
2447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2448 "mem_alloc_copy_from_user_helper fail");
2449 return -ENOMEM;
2450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302452 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002453
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302454 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002455
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302456 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2457
2458 /* clear any previous genIE before this call */
2459 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2460
2461 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 {
2463 v_U16_t eLen = 0;
2464 v_U8_t elementId;
2465 elementId = *genie++;
2466 eLen = *genie++;
2467 remLen -= 2;
2468
Arif Hussain6d2a3322013-11-17 19:50:10 -08002469 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 __func__, elementId, eLen);
2471
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302472 if (remLen < eLen) {
2473 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2474 remLen, eLen);
2475 ret = -EINVAL;
2476 goto exit;
2477 }
2478
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 switch ( elementId )
2480 {
2481 case IE_EID_VENDOR:
2482 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002483 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302484 ret = -EINVAL;
2485 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002487
2488 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2489 {
2490 v_U16_t curGenIELen = pWextState->genIE.length;
2491 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2492 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2493
2494 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2495 {
2496 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002497 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302499 ret = -EINVAL;
2500 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 }
2502 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2503 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2504 pWextState->genIE.length += eLen + 2;
2505 }
2506 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2507 {
2508 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302509 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2510 {
2511 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2512 "Need bigger buffer space");
2513 ret = -EINVAL;
2514 VOS_ASSERT(0);
2515 goto exit;
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2518 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2519 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2520 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2521 }
2522 else /* any vendorId except WPA IE should be accumulated to genIE */
2523 {
2524 v_U16_t curGenIELen = pWextState->genIE.length;
2525 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2526 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2527
2528 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2529 {
2530 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002531 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302533 ret = -ENOMEM;
2534 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 }
2536 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2537 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2538 pWextState->genIE.length += eLen + 2;
2539 }
2540 break;
2541 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002542 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302543 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2544 {
2545 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2546 "Need bigger buffer space");
2547 ret = -EINVAL;
2548 VOS_ASSERT(0);
2549 goto exit;
2550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2552 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2553 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2554 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2555 break;
2556
2557 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002558 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302559 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302562
2563 /* Move genie only if next element is present */
2564 if (remLen >= 2)
2565 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302567
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302568exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002570 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302571 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002572}
2573
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302574static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 struct iw_request_info *info,
2576 union iwreq_data *wrqu,
2577 char *extra)
2578{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302579 int ret;
2580
2581 vos_ssr_protect(__func__);
2582 ret = __iw_set_genie(dev, info, wrqu, extra);
2583 vos_ssr_unprotect(__func__);
2584
2585 return ret;
2586}
2587
2588static int __iw_get_genie(struct net_device *dev,
2589 struct iw_request_info *info,
2590 union iwreq_data *wrqu,
2591 char *extra)
2592{
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302594 hdd_context_t *pHddCtx;
2595 hdd_adapter_t *pAdapter;
2596 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 eHalStatus status;
2598 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2599 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2600
2601 ENTER();
2602
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2604 if (NULL == pAdapter)
2605 {
2606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2607 "%s: Adapter is NULL",__func__);
2608 return -EINVAL;
2609 }
2610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2611 status = wlan_hdd_validate_context(pHddCtx);
2612 if (0 != status)
2613 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302614 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 }
2616
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302618 if (NULL == pWextState)
2619 {
2620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2621 "%s: pWextState is NULL",__func__);
2622 return -EINVAL;
2623 }
2624
2625 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2626 if (NULL == pHddStaCtx)
2627 {
2628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2629 "%s: STA Context is NULL",__func__);
2630 return -EINVAL;
2631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002632
2633 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2634 {
2635 return -ENXIO;
2636 }
2637
2638 // Return something ONLY if we are associated with an RSN or WPA network
2639 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2640 pWextState->roamProfile.negotiatedAuthType))
2641 {
2642 return -ENXIO;
2643 }
2644
2645 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2646 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2647 pAdapter->sessionId,
2648 &length,
2649 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302650 if (eHAL_STATUS_SUCCESS != status) {
2651 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002652 return -EFAULT;
2653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002654
Manjeet Singh715d47e2016-08-02 19:08:02 +05302655 wrqu->data.length = length;
2656 if (length > DOT11F_IE_RSN_MAX_LEN) {
2657 hddLog(LOGE,
2658 FL("invalid buffer length length:%d"), length);
2659 return -E2BIG;
2660 }
2661
2662 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2663
2664 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002665
2666 EXIT();
2667
2668 return 0;
2669}
2670
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302671static int iw_get_genie(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu,
2674 char *extra)
2675{
2676 int ret;
2677
2678 vos_ssr_protect(__func__);
2679 ret = __iw_get_genie(dev, info, wrqu, extra);
2680 vos_ssr_unprotect(__func__);
2681
2682 return ret;
2683}
2684
2685
2686static int __iw_get_encode(struct net_device *dev,
2687 struct iw_request_info *info,
2688 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002689{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302690 hdd_adapter_t *pAdapter;
2691 hdd_context_t *pHddCtx;
2692 hdd_wext_state_t *pWextState;
2693 tCsrRoamProfile *pRoamProfile;
2694 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002696
2697 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302698 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2699 if (NULL == pAdapter)
2700 {
2701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2702 "%s: Adapter is NULL",__func__);
2703 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 }
2705
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302706 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2707 ret = wlan_hdd_validate_context(pHddCtx);
2708 if (0 != ret)
2709 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302710 return ret;
2711 }
2712 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2713 if (NULL == pWextState)
2714 {
2715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2716 "%s: pWextState is NULL",__func__);
2717 return -EINVAL;
2718 }
2719
2720 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 keyId = pRoamProfile->Keys.defaultIndex;
2722
2723 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2724 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002725 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 return -EINVAL;
2727 }
2728
2729 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2730 {
2731 dwrq->flags |= IW_ENCODE_ENABLED;
2732 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2733 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2734
2735 dwrq->flags |= (keyId + 1);
2736
2737 }
2738 else
2739 {
2740 dwrq->flags |= IW_ENCODE_DISABLED;
2741 }
2742
2743 for(i=0; i < MAX_WEP_KEYS; i++)
2744 {
2745 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2746 {
2747 continue;
2748 }
2749 else
2750 {
2751 break;
2752 }
2753 }
2754
2755 if(MAX_WEP_KEYS == i)
2756 {
2757 dwrq->flags |= IW_ENCODE_NOKEY;
2758 }
2759
2760 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2761
2762 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2763 {
2764 dwrq->flags |= IW_ENCODE_OPEN;
2765 }
2766 else
2767 {
2768 dwrq->flags |= IW_ENCODE_RESTRICTED;
2769 }
2770 EXIT();
2771 return 0;
2772}
2773
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302774static int iw_get_encode(struct net_device *dev,
2775 struct iw_request_info *info,
2776 struct iw_point *dwrq, char *extra)
2777{
2778 int ret;
2779
2780 vos_ssr_protect(__func__);
2781 ret = __iw_get_encode(dev, info, dwrq, extra);
2782 vos_ssr_unprotect(__func__);
2783
2784 return ret;
2785}
2786
Jeff Johnson295189b2012-06-20 16:38:30 -07002787#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2788#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2789
2790
2791/*
2792 * This function sends a single 'key' to LIM at all time.
2793 */
2794
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302795static int __iw_get_rts_threshold(struct net_device *dev,
2796 struct iw_request_info *info,
2797 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002798{
2799 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2800 v_U32_t status = 0;
2801
2802 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2803
2804 return status;
2805}
2806
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302807static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 struct iw_request_info *info,
2809 union iwreq_data *wrqu, char *extra)
2810{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302811 int ret;
2812
2813 vos_ssr_protect(__func__);
2814 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2815 vos_ssr_unprotect(__func__);
2816
2817 return ret;
2818}
2819
2820static int __iw_set_rts_threshold(struct net_device *dev,
2821 struct iw_request_info *info,
2822 union iwreq_data *wrqu, char *extra)
2823{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302824 hdd_adapter_t *pAdapter;
2825 hdd_context_t *pHddCtx;
2826 tHalHandle hHal;
2827 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002828
2829 ENTER();
2830
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302831 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2832 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002833 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2835 "%s: Adapter is NULL",__func__);
2836 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002837 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302838
2839 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2840 ret = wlan_hdd_validate_context(pHddCtx);
2841 if (0 != ret)
2842 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302843 return ret;
2844 }
2845
2846 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2847 if (NULL == hHal)
2848 {
2849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2850 "%s: Hal Context is NULL",__func__);
2851 return -EINVAL;
2852 }
2853
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2855 {
2856 return -EINVAL;
2857 }
2858
2859 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2860 {
c_hpothub8245442013-11-20 23:41:09 +05302861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2862 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 return -EIO;
2864 }
2865
2866 EXIT();
2867
2868 return 0;
2869}
2870
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302871static int iw_set_rts_threshold(struct net_device *dev,
2872 struct iw_request_info *info,
2873 union iwreq_data *wrqu, char *extra)
2874{
2875 int ret;
2876
2877 vos_ssr_protect(__func__);
2878 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2879 vos_ssr_unprotect(__func__);
2880
2881 return ret;
2882}
2883
2884static int __iw_get_frag_threshold(struct net_device *dev,
2885 struct iw_request_info *info,
2886 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002887{
2888 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2889 v_U32_t status = 0;
2890
2891 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2892
2893 return status;
2894}
2895
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302896static int iw_get_frag_threshold(struct net_device *dev,
2897 struct iw_request_info *info,
2898 union iwreq_data *wrqu, char *extra)
2899{
2900 int ret;
2901
2902 vos_ssr_protect(__func__);
2903 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2904 vos_ssr_unprotect(__func__);
2905
2906 return ret;
2907}
2908
2909static int __iw_set_frag_threshold(struct net_device *dev,
2910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002912{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302913 hdd_adapter_t *pAdapter;
2914 hdd_context_t *pHddCtx;
2915 tHalHandle hHal;
2916 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002917
2918 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302919 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2920 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002921 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2923 "%s: Adapter is NULL",__func__);
2924 return -EINVAL;
2925 }
2926
2927 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2928 ret = wlan_hdd_validate_context(pHddCtx);
2929 if (0 != ret)
2930 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302931 return ret;
2932 }
2933
2934 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2935 if (NULL == hHal)
2936 {
2937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2938 "%s: Hal Context is NULL",__func__);
2939 return -EINVAL;
2940 }
2941
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2943 {
2944 return -EINVAL;
2945 }
2946
2947 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2948 {
c_hpothub8245442013-11-20 23:41:09 +05302949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2950 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 return -EIO;
2952 }
2953
2954 EXIT();
2955
2956 return 0;
2957}
2958
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302959static int iw_set_frag_threshold(struct net_device *dev,
2960 struct iw_request_info *info,
2961 union iwreq_data *wrqu, char *extra)
2962{
2963 int ret;
2964
2965 vos_ssr_protect(__func__);
2966 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2967 vos_ssr_unprotect(__func__);
2968
2969 return ret;
2970}
2971
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302972static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 struct iw_request_info *info,
2974 union iwreq_data *wrqu, char *extra)
2975{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302976 hdd_adapter_t *pAdapter;
2977 hdd_context_t *pHddCtx;
2978 int ret = 0;
2979
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302981 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2982 if (NULL == pAdapter)
2983 {
2984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2985 "%s: Adapter is NULL",__func__);
2986 return -EINVAL;
2987 }
2988 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2989 ret = wlan_hdd_validate_context(pHddCtx);
2990 if (0 != ret)
2991 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302992 return ret;
2993 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302994
2995 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 return -EOPNOTSUPP;
2997}
2998
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302999static int iw_get_power_mode(struct net_device *dev,
3000 struct iw_request_info *info,
3001 union iwreq_data *wrqu, char *extra)
3002{
3003 int ret;
3004
3005 vos_ssr_protect(__func__);
3006 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3007 vos_ssr_unprotect(__func__);
3008
3009 return ret;
3010}
3011static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 struct iw_request_info *info,
3013 union iwreq_data *wrqu, char *extra)
3014{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303015 hdd_adapter_t *pAdapter;
3016 hdd_context_t *pHddCtx;
3017 int ret = 0;
3018
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303020 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3021 if (NULL == pAdapter)
3022 {
3023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3024 "%s: Adapter is NULL",__func__);
3025 return -EINVAL;
3026 }
3027 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3028 ret = wlan_hdd_validate_context(pHddCtx);
3029 if (0 != ret)
3030 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303031 return ret;
3032 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303033
3034 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 return -EOPNOTSUPP;
3036}
3037
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303038static int iw_set_power_mode(struct net_device *dev,
3039 struct iw_request_info *info,
3040 union iwreq_data *wrqu, char *extra)
3041{
3042 int ret;
3043
3044 vos_ssr_protect(__func__);
3045 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3046 vos_ssr_unprotect(__func__);
3047
3048 return ret;
3049}
3050
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303051static int __iw_get_range(struct net_device *dev,
3052 struct iw_request_info *info,
3053 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003054{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303055 hdd_adapter_t *pAdapter;
3056 tHalHandle hHal;
3057 hdd_context_t *pHddCtx;
3058 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 struct iw_range *range = (struct iw_range *) extra;
3060
3061 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3062
3063 v_U32_t num_channels = sizeof(channels);
3064 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3065 v_U32_t a_len;
3066 v_U32_t b_len;
3067 v_U32_t active_phy_mode = 0;
3068 v_U8_t index = 0, i;
3069
3070 ENTER();
3071
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303072 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3073 if (NULL == pAdapter)
3074 {
3075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3076 "%s: pAdapter is NULL", __func__);
3077 return -EINVAL;
3078 }
3079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3080 ret = wlan_hdd_validate_context(pHddCtx);
3081 if (0 != ret)
3082 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303083 return ret;
3084 }
3085 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3086 if (NULL == hHal)
3087 {
3088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: pAdapter is NULL", __func__);
3090 return -EINVAL;
3091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 wrqu->data.length = sizeof(struct iw_range);
3093 memset(range, 0, sizeof(struct iw_range));
3094
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 /*Get the phy mode*/
3096 if (ccmCfgGetInt(hHal,
3097 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3098 {
3099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003100 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003101
3102 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3103 {
3104 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003105 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 if (ccmCfgGetStr(hHal,
3107 WNI_CFG_SUPPORTED_RATES_11A,
3108 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3109 {
3110 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3111 {
3112 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3113 }
3114 for (i = 0; i < a_len; i++)
3115 {
3116 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3117 }
3118 range->num_bitrates = a_len;
3119 }
3120 else
3121 {
3122 return -EIO;
3123 }
3124 }
3125 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3126 {
3127 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003128 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 if (ccmCfgGetStr(hHal,
3130 WNI_CFG_SUPPORTED_RATES_11B,
3131 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3132 {
3133 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3134 {
3135 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3136 }
3137 for (i = 0; i < b_len; i++)
3138 {
3139 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3140 }
3141 range->num_bitrates = b_len;
3142 }
3143 else
3144 {
3145 return -EIO;
3146 }
3147 }
3148 }
3149
3150 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3151 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3152 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3153
3154 range->encoding_size[0] = 5;
3155 range->encoding_size[1] = 13;
3156 range->num_encoding_sizes = 2;
3157 range->max_encoding_tokens = MAX_WEP_KEYS;
3158
3159 // we support through Wireless Extensions 22
3160 range->we_version_compiled = WIRELESS_EXT;
3161 range->we_version_source = 22;
3162
3163 /*Supported Channels and Frequencies*/
3164 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3165 {
c_hpothub8245442013-11-20 23:41:09 +05303166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3167 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 return -EIO;
3169 }
3170 if (num_channels > IW_MAX_FREQUENCIES)
3171 {
3172 num_channels = IW_MAX_FREQUENCIES;
3173 }
3174
3175 range->num_channels = num_channels;
3176 range->num_frequency = num_channels;
3177
3178 for (index=0; index < num_channels; index++)
3179 {
3180 v_U32_t frq_indx = 0;
3181
3182 range->freq[index].i = channels[index];
3183 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3184 {
3185 if(channels[index] == freq_chan_map[frq_indx].chan)
3186 {
3187 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3188 range->freq[index].e = 1;
3189 break;
3190 }
3191 frq_indx++;
3192 }
3193 }
3194
3195 /* Event capability (kernel + driver) */
3196 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3197 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3198 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3199 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3200
3201 /*Encryption capability*/
3202 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3203 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3204
3205 /* Txpower capability */
3206 range->txpower_capa = IW_TXPOW_MWATT;
3207
3208 /*Scanning capability*/
3209 #if WIRELESS_EXT >= 22
3210 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3211 #endif
3212
3213 EXIT();
3214 return 0;
3215}
3216
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303217static int iw_get_range(struct net_device *dev,
3218 struct iw_request_info *info,
3219 union iwreq_data *wrqu, char *extra)
3220{
3221 int ret;
3222
3223 vos_ssr_protect(__func__);
3224 ret = __iw_get_range(dev, info, wrqu, extra);
3225 vos_ssr_unprotect(__func__);
3226
3227 return ret;
3228}
3229
Jeff Johnson295189b2012-06-20 16:38:30 -07003230/* Callback function for tx per hit */
3231void hdd_tx_per_hit_cb (void *pCallbackContext)
3232{
3233 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3234 unsigned char tx_fail[16];
3235 union iwreq_data wrqu;
3236
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303237 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003239 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 return;
3241 }
3242 memset(&wrqu, 0, sizeof(wrqu));
3243 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3244 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3245}
3246
3247void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3248{
3249 struct statsContext *pStatsContext;
3250 tCsrGlobalClassAStatsInfo *pClassAStats;
3251 hdd_adapter_t *pAdapter;
3252
3253 if (ioctl_debug)
3254 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003255 pr_info("%s: pStats [%pK] pContext [%pK]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003256 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 }
3258
3259 if ((NULL == pStats) || (NULL == pContext))
3260 {
3261 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003262 "%s: Bad param, pStats [%pK] pContext [%pK]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003263 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 return;
3265 }
3266
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 pClassAStats = pStats;
3268 pStatsContext = pContext;
3269 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003270
3271 /* there is a race condition that exists between this callback
3272 function and the caller since the caller could time out either
3273 before or while this code is executing. we use a spinlock to
3274 serialize these actions */
3275 spin_lock(&hdd_context_lock);
3276
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3278 {
3279 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003280 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003282 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003283 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 if (ioctl_debug)
3285 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003286 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003287 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 }
3289 return;
3290 }
3291
Jeff Johnson72a40512013-12-19 10:14:15 -08003292 /* context is valid so caller is still waiting */
3293
3294 /* paranoia: invalidate the magic */
3295 pStatsContext->magic = 0;
3296
3297 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3299
Jeff Johnson72a40512013-12-19 10:14:15 -08003300 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003302
3303 /* serialization is complete */
3304 spin_unlock(&hdd_context_lock);
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303305
3306}
3307
3308struct stats_class_a_ctx {
3309 tCsrGlobalClassAStatsInfo class_a_stats;
3310};
3311
3312void hdd_get_class_a_statistics_cb(void *stats, void *context)
3313{
3314 struct hdd_request *request;
3315 struct stats_class_a_ctx *priv;
3316
3317 if (ioctl_debug) {
3318 pr_info("%s: stats [%pK] context [%pK]\n",
3319 __func__, stats, context);
3320 }
3321
3322 if (NULL == stats) {
3323 hddLog(VOS_TRACE_LEVEL_ERROR,
3324 "%s: Bad param, stats [%pK]",
3325 __func__, stats);
3326 return;
3327 }
3328
3329 request = hdd_request_get(context);
3330 if (!request) {
3331 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3332 return;
3333 }
3334
3335 priv = hdd_request_priv(request);
3336
3337 /* copy over the stats. do so as a struct copy */
3338 priv->class_a_stats = *(tCsrGlobalClassAStatsInfo *)stats;
3339
3340 hdd_request_complete(request);
3341 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003342}
3343
3344VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3345{
3346 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3347 eHalStatus hstatus;
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303348 int ret;
3349 void *cookie;
3350 struct hdd_request *request;
3351 struct stats_class_a_ctx *priv;
3352 static const struct hdd_request_params params = {
3353 .priv_size = sizeof(*priv),
3354 .timeout_ms = WLAN_WAIT_TIME_STATS,
3355 };
3356
Jeff Johnson295189b2012-06-20 16:38:30 -07003357
3358 if (NULL == pAdapter)
3359 {
3360 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3361 return VOS_STATUS_E_FAULT;
3362 }
3363 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3364 {
3365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3366 return VOS_STATUS_SUCCESS;
3367 }
3368
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303369 request = hdd_request_alloc(&params);
3370 if (!request) {
3371 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3372 return VOS_STATUS_E_NOMEM;
3373 }
3374 cookie = hdd_request_cookie(request);
3375
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 /* query only for Class A statistics (which include link speed) */
3377 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3378 eCSR_HDD,
3379 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303380 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 0, // not periodic
3382 FALSE, //non-cached results
3383 pHddStaCtx->conn_info.staId[0],
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303384 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 if (eHAL_STATUS_SUCCESS != hstatus)
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003388 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003389 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 /* we'll returned a cached value below */
3391 }
3392 else
3393 {
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303394 /* request was sent -- wait for the response */
3395 ret = hdd_request_wait_for_response(request);
3396 if (ret)
3397 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303399 FL("SME timeout while retrieving Class A statistics"));
3400 }
3401 else
3402 {
3403 priv = hdd_request_priv(request);
3404 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
3405
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 }
3407 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003408
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303409 /*
3410 * either we never sent a request, we sent a request and received a
3411 * response or we sent a request and timed out. Regardless we are
3412 * done with the request.
3413 */
3414 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003415
3416 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 return VOS_STATUS_SUCCESS;
3418}
3419
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303420struct stats_ctx {
3421 tCsrSummaryStatsInfo summary_stats;
3422 tCsrGlobalClassAStatsInfo class_a_stats;
3423};
3424
3425static void hdd_get_station_statistics_cb(void *stats, void *context)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003426{
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303427 tCsrSummaryStatsInfo *summary_stats;
3428 tCsrGlobalClassAStatsInfo *class_a_stats;
3429 struct hdd_request *request;
3430 struct stats_ctx *priv;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003431
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003432
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303433 if (ioctl_debug) {
3434 pr_info("%s: stats [%pK] context [%pK]\n",
3435 __func__, stats, context);
3436 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003437
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303438 if (NULL == stats) {
3439 hddLog(VOS_TRACE_LEVEL_ERROR,
3440 "%s: Bad param, stats [%pK]",
3441 __func__, stats);
3442 return;
3443 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003444
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303445 request = hdd_request_get(context);
3446 if (!request) {
3447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3448 return;
3449 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003450
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303451 summary_stats = (tCsrSummaryStatsInfo *)stats;
3452 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
Jeff Johnson72a40512013-12-19 10:14:15 -08003453
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303454 priv = hdd_request_priv(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003455
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303456 /* copy over the stats. do so as a struct copy */
3457 priv->summary_stats = *summary_stats;
3458 priv->class_a_stats = *class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003459
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303460 hdd_request_complete(request);
3461 hdd_request_put(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003462}
3463
3464VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3465{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303466 hdd_station_ctx_t *pHddStaCtx;
3467 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003468 eHalStatus hstatus;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303469 tANI_U8 sta_id;
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303470 int ret;
3471 void *cookie;
3472 struct hdd_request *request;
3473 struct stats_ctx *priv;
3474 static const struct hdd_request_params params = {
3475 .priv_size = sizeof(*priv),
3476 .timeout_ms = WLAN_WAIT_TIME_STATS,
3477 };
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003478
3479 if (NULL == pAdapter)
3480 {
3481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3482 return VOS_STATUS_SUCCESS;
3483 }
3484
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303485 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3486 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3487 sta_id = sap_ctx->uBCStaId;
3488 } else {
3489 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3490 sta_id = pHddStaCtx->conn_info.staId[0];
3491 }
3492
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303493 request = hdd_request_alloc(&params);
3494 if (!request) {
3495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3496 return VOS_STATUS_E_NOMEM;
3497 }
3498 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003499
3500 /* query only for Summary & Class A statistics */
3501 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3502 eCSR_HDD,
3503 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303504 SME_GLOBAL_CLASSA_STATS |
3505 SME_PER_PKT_STATS,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303506 hdd_get_station_statistics_cb,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003507 0, // not periodic
3508 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303509 sta_id,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303510 cookie);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003511 if (eHAL_STATUS_SUCCESS != hstatus)
3512 {
3513 hddLog(VOS_TRACE_LEVEL_ERROR,
3514 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003515 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003516 /* we'll return with cached values */
3517 }
3518 else
3519 {
3520 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303521 ret = hdd_request_wait_for_response(request);
3522 if (ret)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003523 {
3524 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303525 FL("SME timeout while retrieving statistics"));
3526 }
3527 else
3528 {
3529 priv = hdd_request_priv(request);
3530 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
3531 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003532 }
3533 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003534
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303535 /*
3536 * either we never sent a request, we sent a request and received a
3537 * response or we sent a request and timed out. Regardless we are
3538 * done with the request.
3539 */
3540 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003541
3542 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003543 return VOS_STATUS_SUCCESS;
3544}
3545
Jeff Johnson295189b2012-06-20 16:38:30 -07003546/*
3547 * Support for the LINKSPEED private command
3548 * Per the WiFi framework the response must be of the form
3549 * "LinkSpeed xx"
3550 */
3551static int iw_get_linkspeed(struct net_device *dev,
3552 struct iw_request_info *info,
3553 union iwreq_data *wrqu, char *extra)
3554{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303555 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303556 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303558 int len = sizeof(v_U32_t) + 1;
3559 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303560 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303561 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303562 int rc, valid = 0;
3563
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303564 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303565 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3566 if (NULL == pAdapter)
3567 {
3568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3569 "%s: Adapter is NULL",__func__);
3570 return -EINVAL;
3571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003572
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303573 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303574 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303575 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003576 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303577 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003578 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303579 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3580 if (NULL == pHddStaCtx)
3581 {
3582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3583 "%s: STA Context is NULL",__func__);
3584 return -EINVAL;
3585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3587 {
3588 /* we are not connected so we don't have a classAstats */
3589 link_speed = 0;
3590 }
3591 else
3592 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303593 status = wlan_hdd_get_classAstats(pAdapter);
3594
3595 if (!VOS_IS_STATUS_SUCCESS(status ))
3596 {
3597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3598 return -EINVAL;
3599 }
3600
3601 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3602 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3603 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3604 &link_speed);
3605
3606 link_speed = link_speed / 10;
3607
3608 if (0 == link_speed)
3609 {
3610 /* The linkspeed returned by HAL is in units of 500kbps.
3611 * converting it to mbps.
3612 * This is required to support legacy firmware which does
3613 * not return link capacity.
3614 */
3615 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3616 }
3617
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 }
3619
3620 wrqu->data.length = len;
3621 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003622 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 if ((rc < 0) || (rc >= len))
3624 {
3625 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303626 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 return -EIO;
3628 }
3629
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303630 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003632 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003633}
3634
Arif Hussain695279c2014-03-24 14:06:07 -07003635/*
3636 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3637 *
3638 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303639static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003640 struct iw_request_info *info,
3641 union iwreq_data *wrqu, char *extra)
3642{
3643 int rc;
3644
3645 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3646
3647 if (rc < 0)
3648 return rc;
3649
3650 /* a value is being successfully returned */
3651 return 0;
3652}
Jeff Johnson295189b2012-06-20 16:38:30 -07003653
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303654static int iw_get_linkspeed_priv(struct net_device *dev,
3655 struct iw_request_info *info,
3656 union iwreq_data *wrqu, char *extra)
3657{
3658 int ret;
3659
3660 vos_ssr_protect(__func__);
3661 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3662 vos_ssr_unprotect(__func__);
3663
3664 return ret;
3665}
3666
Jeff Johnson295189b2012-06-20 16:38:30 -07003667/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303668 * Support for the RSSI & RSSI-APPROX private commands
3669 * Per the WiFi framework the response must be of the form
3670 * "<ssid> rssi <xx>"
3671 * unless we are not associated, in which case the response is
3672 * "OK"
3673 */
3674static int iw_get_rssi(struct net_device *dev,
3675 struct iw_request_info *info,
3676 union iwreq_data *wrqu, char *extra)
3677{
3678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3679 char *cmd = extra;
3680 int len = wrqu->data.length;
3681 v_S7_t s7Rssi = 0;
3682 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3683 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3684 VOS_STATUS vosStatus;
3685 int rc;
3686
3687 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3688 (0 == ssidlen) || (ssidlen >= len))
3689 {
3690 /* we are not connected or our SSID is too long
3691 so we cannot report an rssi */
3692 rc = scnprintf(cmd, len, "OK");
3693 }
3694 else
3695 {
3696 /* we are connected with a valid SSID
3697 so we can write the SSID into the return buffer
3698 (note that it is not NUL-terminated) */
3699 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3700
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303701 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303702 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3703
3704 if (VOS_STATUS_SUCCESS == vosStatus)
3705 {
3706 /* append the rssi to the ssid in the format required by
3707 the WiFI Framework */
3708 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3709 rc += ssidlen;
3710 }
3711 else
3712 {
3713 rc = -1;
3714 }
3715 }
3716
3717 /* verify that we wrote a valid response */
3718 if ((rc < 0) || (rc >= len))
3719 {
3720 // encoding or length error?
3721 hddLog(VOS_TRACE_LEVEL_ERROR,
3722 "%s: Unable to encode RSSI, got [%s]",
3723 __func__, cmd);
3724 return -EIO;
3725 }
3726
3727 /* a value is being successfully returned */
3728 return rc;
3729}
3730
3731/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 * Support for SoftAP channel range private command
3733 */
3734static int iw_softap_set_channel_range( struct net_device *dev,
3735 int startChannel,
3736 int endChannel,
3737 int band)
3738{
Jeff Johnson43971f52012-07-17 12:26:56 -07003739 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 int ret = 0;
3741 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3742 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003743 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745
3746 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3747 if (VOS_STATUS_SUCCESS != status)
3748 {
3749 ret = -EINVAL;
3750 }
Yathish9f22e662012-12-10 14:21:35 -08003751 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 return ret;
3753}
3754
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303755static uint8 chartohex(char c)
3756{
3757 uint8 val = 0;
3758 if (c >= '0' && c <= '9')
3759 val = c - '0';
3760 else if (c >= 'a' && c <= 'f')
3761 val = c - 'a' + 10;
3762 else if (c >= 'A' && c <= 'F')
3763 val = c - 'A' + 10;
3764 else
3765 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3766
3767 return val;
3768}
3769
3770uint8 getByte(char **buf)
3771{
3772 uint8 byte = 0;
3773 char *temp = *buf;
3774 byte = chartohex(*temp) * 16;
3775 temp++;
3776 byte += chartohex(*temp);
3777 temp++;
3778 *buf = temp;
3779 return byte;
3780}
3781
3782static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3783{
3784 tSir80211Header *macHeader;
3785 int i = 0, j = 0, length = 0;
3786 uint8 byte = 0;
3787 char *temp = pBuffer;
3788 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303789 char *pHeader;
3790 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303791
3792 macHeader = &pkt->macHeader;
3793
3794 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3795
3796 temp++;
3797
3798 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3799 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3800 pkt->encParams.keyParams.key[0].keyId);
3801
3802 for (i = 0; i< 16; i++) {
3803 pkt->encParams.keyParams.key[0].key[i]
3804 = getByte(&temp);
3805 }
3806
3807 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3808 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3809
3810 for (i = 0; i< 6; i++) {
3811 pkt->encParams.pn[i]
3812 = getByte(&temp);
3813 }
3814
3815 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3816 &pkt->encParams.pn[0], 6, 0);
3817
3818 for (i = 0, j= 5; i< 3; i++, j--) {
3819 byte = pkt->encParams.pn[i];
3820 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3821 pkt->encParams.pn[j] = byte;
3822 }
3823
3824 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303825 if (length > sizeof(tSir80211Header))
3826 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303827
Srinivas Dasari2382de62015-01-22 15:00:04 +05303828 pHeader = temp;
3829 vos_mem_zero(&header, sizeof(tSir80211Header));
3830 for (i = 0; i < length; i++) {
3831 *((uint8 *)&header + i) = getByte(&pHeader);
3832 }
3833
3834 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3835 (char *)&header, length, 0);
3836
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303837 byte = getByte(&temp);
3838
3839 macHeader->frameCtrl.protVer = byte & 0x3;
3840 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3841 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3842
3843 byte = getByte(&temp);
3844 macHeader->frameCtrl.toDS = (byte) & 0x1;
3845 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3846 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3847 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3848 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3849 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3850 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3851 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3852
3853 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3854 "macHeader->frameCtrl.type : %x "
3855 "macHeader->frameCtrl.subType : %x "
3856 "macHeader->frameCtrl.toDS : %x "
3857 "macHeader->frameCtrl.fromDS : %x "
3858 "macHeader->frameCtrl.moreFrag : %x "
3859 "macHeader->frameCtrl.retry : %x "
3860 "macHeader->frameCtrl.powerMgmt : %x "
3861 "macHeader->frameCtrl.MoreData : %x "
3862 "macHeader->frameCtrl.wep : %x "
3863 "macHeader->frameCtrl.order : %x "
3864 , macHeader->frameCtrl.protVer
3865 , macHeader->frameCtrl.type
3866 , macHeader->frameCtrl.subType
3867 , macHeader->frameCtrl.toDS
3868 , macHeader->frameCtrl.fromDS
3869 , macHeader->frameCtrl.moreFrag
3870 , macHeader->frameCtrl.retry
3871 , macHeader->frameCtrl.powerMgmt
3872 , macHeader->frameCtrl.moreData
3873 , macHeader->frameCtrl.wep
3874 , macHeader->frameCtrl.order);
3875
3876
3877 macHeader->usDurationId = getByte(&temp);
3878 macHeader->usDurationId += getByte(&temp) << 8;
3879
3880 macHeader->vA1[0] = getByte(&temp);
3881 macHeader->vA1[1] = getByte(&temp);
3882 macHeader->vA1[2] = getByte(&temp);
3883 macHeader->vA1[3] = getByte(&temp);
3884 macHeader->vA1[4] = getByte(&temp);
3885 macHeader->vA1[5] = getByte(&temp);
3886
3887 macHeader->vA2[0] = getByte(&temp);
3888 macHeader->vA2[1] = getByte(&temp);
3889 macHeader->vA2[2] = getByte(&temp);
3890 macHeader->vA2[3] = getByte(&temp);
3891 macHeader->vA2[4] = getByte(&temp);
3892 macHeader->vA2[5] = getByte(&temp);
3893
3894 macHeader->vA3[0] = getByte(&temp);
3895 macHeader->vA3[1] = getByte(&temp);
3896 macHeader->vA3[2] = getByte(&temp);
3897 macHeader->vA3[3] = getByte(&temp);
3898 macHeader->vA3[4] = getByte(&temp);
3899 macHeader->vA3[5] = getByte(&temp);
3900
3901 macHeader->sSeqCtrl = getByte(&temp);
3902 fragNum = macHeader->sSeqCtrl & 0xF;
3903 macHeader->sSeqCtrl >>= 4;
3904
3905 macHeader->sSeqCtrl += getByte(&temp) << 4;
3906
3907 macHeader->sSeqCtrl |= fragNum << 12;
3908
3909 if (length == 30 || length == 32) {
3910 macHeader->optvA4[0] = getByte(&temp);
3911 macHeader->optvA4[1] = getByte(&temp);
3912 macHeader->optvA4[2] = getByte(&temp);
3913 macHeader->optvA4[3] = getByte(&temp);
3914 macHeader->optvA4[4] = getByte(&temp);
3915 macHeader->optvA4[5] = getByte(&temp);
3916 }
3917
3918 if (length == 26 || length == 32) {
3919 macHeader->usQosCtrl = getByte(&temp);
3920 macHeader->usQosCtrl += getByte(&temp) << 8;
3921 }
3922
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303923 //parse payload
3924 length = getByte(&temp);
3925 length += getByte(&temp) << 8;
3926 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3927
Manjeet Singh5830f142016-11-21 18:21:17 +05303928 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
3929 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
3930
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303931 pkt->data.length = length;
3932
3933 for (i = 0; i< length; i++) {
3934 pkt->data.data[i] = getByte(&temp);
3935 }
3936
3937 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3938 &pkt->data.data[0], pkt->data.length, 0);
3939}
3940
3941/**---------------------------------------------------------------------------
3942
3943 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3944 encrypt message request
3945 This is an asynchronous callback function from SME when the encrypted data
3946 is received
3947
3948 \pEncInfoRsp -> Encrypted data info
3949
3950 \return - 0 for success non-zero for failure
3951 --------------------------------------------------------------------------*/
3952static void
3953hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3954{
3955 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3956
3957 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3958
3959 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3960 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3961 pEncryptedDataRsp->encryptedPayload.length);
3962 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3963 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3964 pEncryptedDataRsp->encryptedPayload.data,
3965 pEncryptedDataRsp->encryptedPayload.length, 0);
3966}
3967
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05303968/**
3969 * iw_power_callback_func() - Callback function registered with PMC
3970 * @context: cookie originally registered with PMC
3971 * @status: status code indicated by PMC state machine
3972 *
3973 * Return: None
3974 */
3975static void iw_power_callback_func(void *context, eHalStatus status)
3976{
3977 struct hdd_request *request = hdd_request_get(context);
3978
3979 if (!request) {
3980 hddLog(VOS_TRACE_LEVEL_ERROR,
3981 "%s: Obsolete request", __func__);
3982 return;
3983 }
3984
3985 hdd_request_complete(request);
3986 hdd_request_put(request);
3987}
3988
Jeff Johnson295189b2012-06-20 16:38:30 -07003989VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3990{
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 eHalStatus status;
3992 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303993 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303994 int ret;
3995 void *cookie;
3996 struct hdd_request *request;
3997 static const struct hdd_request_params params = {
3998 .priv_size = 0,
3999 .timeout_ms = WLAN_WAIT_TIME_STATS,
4000 };
Jeff Johnson295189b2012-06-20 16:38:30 -07004001
4002 if (NULL == pAdapter)
4003 {
4004 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4005 return VOS_STATUS_E_FAULT;
4006 }
4007
4008 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4009 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304010 if (pHddCtx->isLogpInProgress) {
4011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4012 "%s:LOGP in Progress. Ignore!!!", __func__);
4013 return VOS_STATUS_E_FAILURE;
4014 }
4015
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304016 request = hdd_request_alloc(&params);
4017 if (!request) {
4018 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
4019 return VOS_STATUS_E_NOMEM;
4020 }
4021 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07004022
Jeff Johnson295189b2012-06-20 16:38:30 -07004023
4024 if (DRIVER_POWER_MODE_ACTIVE == mode)
4025 {
4026 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4027 "Full Power", __func__);
4028 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304029 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 eSME_FULL_PWR_NEEDED_BY_HDD);
4031 // Enter Full power command received from GUI this means we are disconnected
4032 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4033 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4034 if (eHAL_STATUS_PMC_PENDING == status)
4035 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304036 ret = hdd_request_wait_for_response(request);
4037 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304039 hddLog(VOS_TRACE_LEVEL_ERROR,
4040 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 }
4042 }
4043 }
4044 else if (DRIVER_POWER_MODE_AUTO == mode)
4045 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304046 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4047 * was already in BMPS state and thus either STA or P2P-CLI is in
4048 * associated state and authenticated, so even if STA connState is
4049 * not associated it can be assumed that P2P-CLI is associated and
4050 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4051 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4052 * if all condition are satisfied for entering BMPS.
4053 */
4054 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4055 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304056 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304057 hddLog(LOGE,
4058 FL("Station is associated but, still not Authenticated ignore "
4059 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304060 return VOS_STATUS_E_AGAIN;
4061 }
4062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4064 {
4065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4066 __func__);
4067 // Enter BMPS command received from GUI this means DHCP is completed
4068 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4069 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4070 FALSE);
4071 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304072 iw_power_callback_func, cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 if (eHAL_STATUS_PMC_PENDING == status)
4074 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004075 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304076 ret = hdd_request_wait_for_response(request);
4077 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004079 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304080 FL("SME timeout while requesting bmps"));
4081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 }
4083 }
4084 else
4085 {
4086 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4087 "enabled in the cfg");
4088 }
4089 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004090
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304091 /*
4092 * either we never sent a request, we sent a request and received a
4093 * response or we sent a request and timed out. Regardless we are
4094 * done with the request.
4095 */
4096 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08004097
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 return VOS_STATUS_SUCCESS;
4099}
4100
4101VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4102 hdd_adapter_t *pAdapter)
4103{
4104 VOS_STATUS vos_Status;
4105
4106 if ((NULL == pAdapter) || (NULL == pHddCtx))
4107 {
4108 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4109 return VOS_STATUS_E_FAULT;
4110 }
4111
4112 /**Exit from Deep sleep or standby if we get the driver
4113 START cmd from android GUI
4114 */
4115 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4116 {
4117 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4118 "from Stand by",__func__);
4119 vos_Status = hdd_exit_standby(pHddCtx);
4120 }
4121 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4122 {
4123 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4124 "from deep sleep",__func__);
4125 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4126 }
4127 else
4128 {
4129 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4130 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4131 vos_Status = VOS_STATUS_SUCCESS;
4132 }
4133
4134 return vos_Status;
4135}
4136
4137VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4138{
4139 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4140
4141 if (NULL == pHddCtx)
4142 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304143 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 return VOS_STATUS_E_FAULT;
4145 }
4146
4147 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4148 {
4149 //Execute standby procedure.
4150 //Executing standby procedure will cause the STA to
4151 //disassociate first and then the chip will be put into standby.
4152 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4153 vos_Status = hdd_enter_standby(pHddCtx);
4154 }
4155 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4156 pHddCtx->cfg_ini->nEnableDriverStop)
4157 {
4158 //Execute deep sleep procedure
4159 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004160 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 //Deep sleep not supported
4162 vos_Status = hdd_enter_standby(pHddCtx);
4163 }
4164 else
4165 {
4166 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4167 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4168 vos_Status = VOS_STATUS_SUCCESS;
4169 }
4170
4171 return vos_Status;
4172}
4173
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004174
4175void* wlan_hdd_change_country_code_callback(void *pAdapter)
4176{
4177
4178 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004179 complete(&call_back_pAdapter->change_country_code);
4180
4181 return NULL;
4182}
4183
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304184static int __iw_set_priv(struct net_device *dev,
4185 struct iw_request_info *info,
4186 union iwreq_data *wrqu, char *extra)
4187{
4188 hdd_adapter_t *pAdapter;
4189 char *cmd = NULL;
4190 int cmd_len = wrqu->data.length;
4191 int rc = 0, ret = 0;
4192 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4193
4194 hdd_context_t *pHddCtx;
4195
4196 ENTER();
4197
4198 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4199 if (NULL == pAdapter)
4200 {
4201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4202 "mem_alloc_copy_from_user_helper fail");
4203 return -EINVAL;
4204 }
4205 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4206 rc = wlan_hdd_validate_context(pHddCtx);
4207 if (0 != rc)
4208 {
4209 return rc;
4210 }
4211
4212 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4213 wrqu->data.length);
4214 if (NULL == cmd)
4215 {
4216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4217 "mem_alloc_copy_from_user_helper fail");
4218 return -ENOMEM;
4219 }
4220
4221 if (ioctl_debug)
4222 {
4223 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4224 }
4225
4226 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4227 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4228
4229 if (strncmp(cmd, "CSCAN", 5) == 0 )
4230 {
4231 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4233 "%s: Error in iw_set_scan!", __func__);
4234 rc = -EINVAL;
4235 }
4236 }
4237 else if( strcasecmp(cmd, "start") == 0 ) {
4238
4239 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4240 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4241
4242 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4243 if (vos_status == VOS_STATUS_SUCCESS)
4244 {
4245 union iwreq_data wrqu;
4246 char buf[10];
4247
4248 memset(&wrqu, 0, sizeof(wrqu));
4249 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4250 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4251 }
4252 else
4253 {
4254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4255 rc = -EIO;
4256 }
4257 goto done;
4258 }
4259 else if( strcasecmp(cmd, "stop") == 0 )
4260 {
4261 union iwreq_data wrqu;
4262 char buf[10];
4263
4264 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4265
4266 wlan_hdd_enter_lowpower(pHddCtx);
4267 memset(&wrqu, 0, sizeof(wrqu));
4268 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4269 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4270 goto done;
4271 }
4272 else if (strcasecmp(cmd, "macaddr") == 0)
4273 {
4274 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4275 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4276 }
4277 else if (strcasecmp(cmd, "scan-active") == 0)
4278 {
4279 hddLog(LOG1,
4280 FL("making default scan to active"));
4281 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4282 ret = snprintf(cmd, cmd_len, "OK");
4283 }
4284 else if (strcasecmp(cmd, "scan-passive") == 0)
4285 {
4286 hddLog(LOG1,
4287 FL("making default scan to passive"));
4288 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4289 ret = snprintf(cmd, cmd_len, "OK");
4290 }
4291 else if( strcasecmp(cmd, "scan-mode") == 0 )
4292 {
4293 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4294 }
4295 else if( strcasecmp(cmd, "linkspeed") == 0 )
4296 {
4297 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4298 }
4299 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4300 {
4301 ret = iw_get_rssi(dev, info, wrqu, cmd);
4302 }
4303 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4304 int mode;
4305 char *ptr;
4306
4307 if (9 < cmd_len)
4308 {
4309 ptr = (char*)(cmd + 9);
4310
4311 }else{
4312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4313 "CMD LENGTH %d is not correct",cmd_len);
4314 kfree(cmd);
4315 return -EINVAL;
4316 }
4317
4318 if (1 != sscanf(ptr,"%d",&mode))
4319 {
4320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4321 "powermode input %s is not correct",ptr);
4322 kfree(cmd);
4323 return -EIO;
4324 }
4325
4326 wlan_hdd_enter_bmps(pAdapter, mode);
4327 /*TODO:Set the power mode*/
4328 }
4329 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4330 v_U32_t pmc_state;
4331 v_U16_t value;
4332
4333 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4334 if(pmc_state == BMPS) {
4335 value = DRIVER_POWER_MODE_AUTO;
4336 }
4337 else {
4338 value = DRIVER_POWER_MODE_ACTIVE;
4339 }
4340 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4341 }
4342 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4343 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4344 /*TODO: set the btcoexmode*/
4345 }
4346 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4347
4348 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4349 /*TODO: Return the btcoex status*/
4350 }
4351 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4352
4353 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4354
4355 /*TODO: Enable Rx data Filter*/
4356 }
4357 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4358
4359 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4360
4361 /*TODO: Disable Rx data Filter*/
4362 }
4363 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4364
4365 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4366 /*TODO: rxfilter-statistics*/
4367 }
4368 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4369
4370 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4371 /*TODO: rxfilter-add*/
4372 }
4373 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4374
4375 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4376 /*TODO: rxfilter-remove*/
4377 }
4378#ifdef FEATURE_WLAN_SCAN_PNO
4379 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4380 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4381 /*TODO: support pnosetup*/
4382 }
4383 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4384 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4385 /*TODO: support pnoforce*/
4386 }
4387 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4388
4389 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4390 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4391 kfree(cmd);
4392 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4393 }
4394 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4395 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4396 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4397 kfree(cmd);
4398 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4399 }
4400#endif /*FEATURE_WLAN_SCAN_PNO*/
4401 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4402 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4403 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4404 kfree(cmd);
4405 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4406 }
4407 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4408 tSirTxPerTrackingParam tTxPerTrackingParam;
4409 char *ptr;
4410
4411 if (18 < cmd_len)
4412 {
4413 ptr = (char*)(cmd + 18);
4414 }else{
4415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4416 "CMD LENGTH %d is not correct",cmd_len);
4417 kfree(cmd);
4418 return -EINVAL;
4419 }
4420
4421 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4422 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4423 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4424 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4425 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4426 {
4427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4428 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4429 kfree(cmd);
4430 return -EIO;
4431 }
4432
4433 // parameters checking
4434 // period has to be larger than 0
4435 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4436 {
4437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4438 kfree(cmd);
4439 return -EIO;
4440 }
4441
4442 // use default value 5 is the input is not reasonable. in unit of 10%
4443 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4444 {
4445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4446 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4447 }
4448
4449 // default is 5
4450 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4451 {
4452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4453 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4454 }
4455
4456 if (eHAL_STATUS_SUCCESS !=
4457 sme_SetTxPerTracking(pHddCtx->hHal,
4458 hdd_tx_per_hit_cb,
4459 (void*)pAdapter, &tTxPerTrackingParam)) {
4460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4461 rc = -EIO;
4462 }
4463 }
4464 else {
4465 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4466 __func__, cmd);
4467 }
4468done:
4469 /* many of the commands write information back into the command
4470 string using snprintf(). check the return value here in one
4471 place */
4472 if ((ret < 0) || (ret >= cmd_len))
4473 {
4474 /* there was an encoding error or overflow */
4475 rc = -EINVAL;
4476 }
4477 else if (ret > 0)
4478 {
4479 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4480 {
4481 hddLog(VOS_TRACE_LEVEL_ERROR,
4482 "%s: failed to copy data to user buffer", __func__);
4483 kfree(cmd);
4484 return -EFAULT;
4485 }
4486 wrqu->data.length = ret;
4487 }
4488
4489 if (ioctl_debug)
4490 {
4491 pr_info("%s: rsp [%s] len [%d] status %d\n",
4492 __func__, cmd, wrqu->data.length, rc);
4493 }
4494 kfree(cmd);
4495 EXIT();
4496 return rc;
4497}
4498
4499static int iw_set_priv(struct net_device *dev,
4500 struct iw_request_info *info,
4501 union iwreq_data *wrqu, char *extra)
4502{
4503 int ret;
4504 vos_ssr_protect(__func__);
4505 ret = __iw_set_priv(dev, info, wrqu, extra);
4506 vos_ssr_unprotect(__func__);
4507
4508 return ret;
4509}
4510
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304511static int __iw_set_nick(struct net_device *dev,
4512 struct iw_request_info *info,
4513 union iwreq_data *wrqu, char *extra)
4514{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304515 hdd_adapter_t *pAdapter;
4516 hdd_context_t *pHddCtx;
4517 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304519 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304520
4521 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4522 if (NULL == pAdapter)
4523 {
4524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4525 "%s: Adapter is NULL",__func__);
4526 return -EINVAL;
4527 }
4528
4529 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4530 ret = wlan_hdd_validate_context(pHddCtx);
4531 if (0 != ret)
4532 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304533 return ret;
4534 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304535 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304536 return 0;
4537}
4538
Jeff Johnson295189b2012-06-20 16:38:30 -07004539static int iw_set_nick(struct net_device *dev,
4540 struct iw_request_info *info,
4541 union iwreq_data *wrqu, char *extra)
4542{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304543 int ret;
4544
4545 vos_ssr_protect(__func__);
4546 ret = __iw_set_nick(dev, info, wrqu, extra);
4547 vos_ssr_unprotect(__func__);
4548
4549 return ret;
4550}
4551
4552static int __iw_get_nick(struct net_device *dev,
4553 struct iw_request_info *info,
4554 union iwreq_data *wrqu, char *extra)
4555{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304556 hdd_adapter_t *pAdapter;
4557 hdd_context_t *pHddCtx;
4558 int ret = 0;
4559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304561
4562 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4563 if (NULL == pAdapter)
4564 {
4565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4566 "%s: Adapter is NULL",__func__);
4567 return -EINVAL;
4568 }
4569
4570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4571 ret = wlan_hdd_validate_context(pHddCtx);
4572 if (0 != ret)
4573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304574 return ret;
4575 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304576 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 return 0;
4578}
4579
4580static int iw_get_nick(struct net_device *dev,
4581 struct iw_request_info *info,
4582 union iwreq_data *wrqu, char *extra)
4583{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304584 int ret;
4585
4586 vos_ssr_protect(__func__);
4587 ret = __iw_get_nick(dev, info, wrqu, extra);
4588 vos_ssr_unprotect(__func__);
4589
4590 return ret;
4591}
4592
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304593/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304594static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4595{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304596 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4597 hdd_context_t *pHddCtx;
4598 hdd_station_ctx_t *pHddStaCtx;
4599 v_S7_t snr = 0, rssi = 0;
4600 eHalStatus status = eHAL_STATUS_SUCCESS;
4601
4602 ENTER();
4603
4604 if (NULL == pAdapter)
4605 {
4606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4607 "%s: Adapter is NULL",__func__);
4608 return NULL;
4609 }
4610
4611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4612 status = wlan_hdd_validate_context(pHddCtx);
4613 if (0 != status)
4614 {
4615 return NULL;
4616 }
4617
4618 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4619 if (NULL == pHddStaCtx)
4620 {
4621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4622 "%s: STA Context is NULL",__func__);
4623 return NULL;
4624 }
4625
4626 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4627 {
4628 wlan_hdd_get_station_stats(pAdapter);
4629 wlan_hdd_get_snr(pAdapter, &snr);
4630 wlan_hdd_get_rssi(pAdapter, &rssi);
4631
4632 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4633 pAdapter->iwStats.status = 0;
4634 pAdapter->iwStats.qual.qual = snr;
4635 pAdapter->iwStats.qual.level = rssi;
4636 pAdapter->iwStats.qual.noise = rssi - snr;
4637 pAdapter->iwStats.discard.code = 0;
4638 pAdapter->iwStats.discard.retries= 0;
4639 pAdapter->iwStats.miss.beacon = 0;
4640 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4641 }
4642 else
4643 {
4644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4645 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4646 return NULL;
4647 }
4648
4649 EXIT();
4650 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004651}
4652
4653static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4654{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304655
4656 struct iw_statistics *stats;
4657
4658 vos_ssr_protect(__func__);
4659 stats = __get_wireless_stats(dev);
4660 vos_ssr_unprotect(__func__);
4661
4662 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004663}
4664
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304665static int __iw_set_encode(struct net_device *dev,
4666 struct iw_request_info *info,
4667 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004668
4669{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304670 hdd_adapter_t *pAdapter;
4671 hdd_station_ctx_t *pHddStaCtx;
4672 hdd_wext_state_t *pWextState;
4673 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 struct iw_point *encoderq = &(wrqu->encoding);
4675 v_U32_t keyId;
4676 v_U8_t key_length;
4677 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4678 v_BOOL_t fKeyPresent = 0;
4679 int i;
4680 eHalStatus status = eHAL_STATUS_SUCCESS;
4681
4682
4683 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304684 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4685 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4688 "%s: Adapter is NULL",__func__);
4689 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 }
4691
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4693 status = wlan_hdd_validate_context(pHddCtx);
4694 if (0 != status)
4695 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304696 return status;
4697 }
4698 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4699 if (NULL == pWextState)
4700 {
4701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4702 "%s: pWextState is NULL ",__func__);
4703 return -EINVAL;
4704 }
4705 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4706 if (NULL == pHddStaCtx)
4707 {
4708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4709 "%s: STA Context is NULL",__func__);
4710 return -EINVAL;
4711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004712
4713 keyId = encoderq->flags & IW_ENCODE_INDEX;
4714
4715 if(keyId)
4716 {
4717 if(keyId > MAX_WEP_KEYS)
4718 {
4719 return -EINVAL;
4720 }
4721
4722 fKeyPresent = 1;
4723 keyId--;
4724 }
4725 else
4726 {
4727 fKeyPresent = 0;
4728 }
4729
4730
4731 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4732 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 if(!fKeyPresent) {
4735
4736 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4737
4738 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4739 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4740 }
4741 }
4742 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4743 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4744 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4745 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4746
4747 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4748 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4749
4750 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4751 {
4752 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4753 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004754 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304755 {
4756 long ret;
4757 ret = wait_for_completion_interruptible_timeout(
4758 &pAdapter->disconnect_comp_var,
4759 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4760 if (ret <= 0)
4761 hddLog(VOS_TRACE_LEVEL_ERROR,
4762 FL("failed wait on disconnect_comp_var %ld"), ret);
4763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 }
4765
4766 return status;
4767
4768 }
4769
4770 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4771 {
4772 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4773
4774 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4775
4776 }
4777
4778
4779 if(wrqu->data.length > 0)
4780 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004781 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004782
4783 key_length = wrqu->data.length;
4784
4785 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4786
4787 if(5 == key_length)
4788 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004789 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004790
4791 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4792 {
4793 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4794 }
4795 else
4796 {
4797 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4798 }
4799 }
4800 else if(13 == key_length)
4801 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004802 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004803
4804 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4805 {
4806 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4807 }
4808 else
4809 {
4810 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4811 }
4812 }
4813 else
4814 {
4815 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004816 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 return -EINVAL;
4818 }
4819
4820 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4821 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4822 pWextState->roamProfile.EncryptionType.numEntries = 1;
4823 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4824 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4825 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4826
4827 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4828 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4829 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4830 {
4831
4832 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4833
4834 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4835 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4836
4837 return status;
4838 }
4839 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304840 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 return 0;
4842}
4843
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304844static int iw_set_encode(struct net_device *dev,
4845 struct iw_request_info *info,
4846 union iwreq_data *wrqu,char *extra)
4847{
4848 int ret;
4849
4850 vos_ssr_protect(__func__);
4851 ret = __iw_set_encode(dev, info, wrqu, extra);
4852 vos_ssr_unprotect(__func__);
4853
4854 return ret;
4855}
4856
4857static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 struct iw_request_info *info,
4859 struct iw_point *dwrq,
4860 char *extra)
4861{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304862 hdd_adapter_t *pAdapter;
4863 hdd_wext_state_t *pWextState;
4864 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 int keyId;
4866 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4867 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304868 int i, ret = 0;
4869 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004870
4871 ENTER();
4872
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304873 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4874 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004875 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4877 "%s: Adapter is NULL",__func__);
4878 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004879 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304880 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4881 ret = wlan_hdd_validate_context(pHddCtx);
4882 if (0 != ret)
4883 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304884 return ret;
4885 }
4886 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4887 if (NULL == pWextState)
4888 {
4889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4890 "%s: pWextState is NULL",__func__);
4891 return -EINVAL;
4892 }
4893 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004894
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 keyId = pRoamProfile->Keys.defaultIndex;
4896
4897 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4898 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004899 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 return -EINVAL;
4901 }
4902
4903 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4904 {
4905 dwrq->flags |= IW_ENCODE_ENABLED;
4906 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304907 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4908 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 }
4910 else
4911 {
4912 dwrq->flags |= IW_ENCODE_DISABLED;
4913 }
4914
4915 for(i=0; i < MAX_WEP_KEYS; i++)
4916 {
4917 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4918 {
4919 continue;
4920 }
4921 else
4922 {
4923 break;
4924 }
4925 }
4926
4927 if(MAX_WEP_KEYS == i)
4928 {
4929 dwrq->flags |= IW_ENCODE_NOKEY;
4930 }
4931 else
4932 {
4933 dwrq->flags |= IW_ENCODE_ENABLED;
4934 }
4935
4936 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4937
4938 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4939 {
4940 dwrq->flags |= IW_ENCODE_DISABLED;
4941 }
4942
4943 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4944
4945 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4946 {
4947 dwrq->flags |= IW_ENCODE_OPEN;
4948 }
4949 else
4950 {
4951 dwrq->flags |= IW_ENCODE_RESTRICTED;
4952 }
4953 EXIT();
4954 return 0;
4955
4956}
4957
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304958static int iw_get_encodeext(struct net_device *dev,
4959 struct iw_request_info *info,
4960 struct iw_point *dwrq,
4961 char *extra)
4962{
4963 int ret;
4964 vos_ssr_protect(__func__);
4965 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4966 vos_ssr_unprotect(__func__);
4967
4968 return ret;
4969}
4970
4971static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 struct iw_request_info *info,
4973 union iwreq_data *wrqu, char *extra)
4974{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304975 hdd_adapter_t *pAdapter;
4976 hdd_station_ctx_t *pHddStaCtx;
4977 hdd_wext_state_t *pWextState;
4978 hdd_context_t *pHddCtx;
4979 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004980
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304981 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 v_U32_t status = 0;
4983
4984 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4985
4986 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4987
4988 int key_index;
4989 struct iw_point *encoding = &wrqu->encoding;
4990 tCsrRoamSetKey setKey;
4991 v_U32_t roamId= 0xFF;
4992 VOS_STATUS vos_status;
4993
4994 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304995 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4996 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4999 "%s: Adapter is NULL",__func__);
5000 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305002 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5003 status = wlan_hdd_validate_context(pHddCtx);
5004 if (0 != status)
5005 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305006 return status;
5007 }
5008 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5009 if (NULL == pHddStaCtx)
5010 {
5011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5012 "%s: STA Context is NULL",__func__);
5013 return -EINVAL;
5014 }
5015 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5016 if (NULL == pWextState)
5017 {
5018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5019 "%s: pWextState is NULL",__func__);
5020 return -EINVAL;
5021 }
5022 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 key_index = encoding->flags & IW_ENCODE_INDEX;
5024
5025 if(key_index > 0) {
5026
5027 /*Convert from 1-based to 0-based keying*/
5028 key_index--;
5029 }
5030 if(!ext->key_len) {
5031
5032 /*Set the encrytion type to NONE*/
5033 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5034 return status;
5035 }
5036
5037 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5038 (IW_ENCODE_ALG_WEP == ext->alg))
5039 {
5040 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5041
Agarwal Ashish971c2882013-10-30 20:11:12 +05305042 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5043 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 return -EINVAL;
5045 }
5046 else {
5047 /*Static wep, update the roam profile with the keys */
5048 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5049 key_index < CSR_MAX_NUM_KEY) {
5050 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5051 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5052
5053 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5054 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5055
5056 }
5057 }
5058 return status;
5059 }
5060
5061 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5062
5063 setKey.keyId = key_index;
5064 setKey.keyLength = ext->key_len;
5065
5066 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5067 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5068 }
5069
5070 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5071 /*Key direction for group is RX only*/
5072 setKey.keyDirection = eSIR_RX_ONLY;
5073 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5074 }
5075 else {
5076
5077 setKey.keyDirection = eSIR_TX_RX;
5078 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5079 }
5080
5081 /*For supplicant pae role is zero*/
5082 setKey.paeRole = 0;
5083
5084 switch(ext->alg)
5085 {
5086 case IW_ENCODE_ALG_NONE:
5087 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5088 break;
5089
5090 case IW_ENCODE_ALG_WEP:
5091 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5092 break;
5093
5094 case IW_ENCODE_ALG_TKIP:
5095 {
5096 v_U8_t *pKey = &setKey.Key[0];
5097
5098 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5099
5100 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5101
5102 /*Supplicant sends the 32bytes key in this order
5103
5104 |--------------|----------|----------|
5105 | Tk1 |TX-MIC | RX Mic |
5106 |--------------|----------|----------|
5107 <---16bytes---><--8bytes--><--8bytes-->
5108
5109 */
5110 /*Sme expects the 32 bytes key to be in the below order
5111
5112 |--------------|----------|----------|
5113 | Tk1 |RX-MIC | TX Mic |
5114 |--------------|----------|----------|
5115 <---16bytes---><--8bytes--><--8bytes-->
5116 */
5117 /* Copy the Temporal Key 1 (TK1) */
5118 vos_mem_copy(pKey,ext->key,16);
5119
5120 /*Copy the rx mic first*/
5121 vos_mem_copy(&pKey[16],&ext->key[24],8);
5122
5123 /*Copy the tx mic */
5124 vos_mem_copy(&pKey[24],&ext->key[16],8);
5125
5126 }
5127 break;
5128
5129 case IW_ENCODE_ALG_CCMP:
5130 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5131 break;
5132
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005133#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005134#define IW_ENCODE_ALG_KRK 6
5135 case IW_ENCODE_ALG_KRK:
5136 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5137 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005138#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005139
5140 default:
5141 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5142 break;
5143 }
5144
5145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005146 ("%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 -07005147
5148#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305149 /* The supplicant may attempt to set the PTK once pre-authentication
5150 is done. Save the key in the UMAC and include it in the ADD
5151 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305153 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305155 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5156 "%s: Update PreAuth Key success", __func__);
5157 return 0;
5158 }
5159 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5160 {
5161 hddLog(VOS_TRACE_LEVEL_ERROR,
5162 "%s: Update PreAuth Key failed", __func__);
5163 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 }
5165#endif /* WLAN_FEATURE_VOWIFI_11R */
5166
5167 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5168
5169 vos_status = wlan_hdd_check_ula_done(pAdapter);
5170 if ( vos_status != VOS_STATUS_SUCCESS )
5171 {
5172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5173 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5174 __LINE__, vos_status );
5175
5176 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5177 }
5178
5179 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5180
5181 if ( halStatus != eHAL_STATUS_SUCCESS )
5182 {
5183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5184 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5185 __LINE__, halStatus );
5186
5187 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5188 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305189 EXIT();
5190 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005191}
5192
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305193static int iw_set_encodeext(struct net_device *dev,
5194 struct iw_request_info *info,
5195 union iwreq_data *wrqu, char *extra)
5196{
5197 int ret;
5198
5199 vos_ssr_protect(__func__);
5200 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5201 vos_ssr_unprotect(__func__);
5202
5203 return ret;
5204}
5205
5206static int __iw_set_retry(struct net_device *dev,
5207 struct iw_request_info *info,
5208 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005209{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305210 hdd_adapter_t *pAdapter;
5211 tHalHandle hHal;
5212 hdd_context_t *pHddCtx;
5213 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005214
5215 ENTER();
5216
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305217 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5218 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005219 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5221 "%s: Adapter is NULL",__func__);
5222 return -EINVAL;
5223 }
5224
5225 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5226 ret = wlan_hdd_validate_context(pHddCtx);
5227 if (0 != ret)
5228 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305229 return ret;
5230 }
5231
5232 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5233 if (NULL == hHal)
5234 {
5235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5236 "%s: Hal Context is NULL",__func__);
5237 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005238 }
5239
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5241 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5242
Arif Hussain6d2a3322013-11-17 19:50:10 -08005243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005244
5245 return -EINVAL;
5246 }
5247
5248 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5249
5250 if((wrqu->retry.flags & IW_RETRY_LONG))
5251 {
5252 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5253 {
c_hpothub8245442013-11-20 23:41:09 +05305254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5255 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 return -EIO;
5257 }
5258 }
5259 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5260 {
5261 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5262 {
c_hpothub8245442013-11-20 23:41:09 +05305263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5264 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 return -EIO;
5266 }
5267 }
5268 }
5269 else
5270 {
5271 return -EOPNOTSUPP;
5272 }
5273
Arif Hussain6d2a3322013-11-17 19:50:10 -08005274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005275
5276 EXIT();
5277
5278 return 0;
5279
5280}
5281
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305282static int iw_set_retry(struct net_device *dev,
5283 struct iw_request_info *info,
5284 union iwreq_data *wrqu, char *extra)
5285{
5286 int ret;
5287
5288 vos_ssr_protect(__func__);
5289 ret = __iw_set_retry(dev, info, wrqu, extra);
5290 vos_ssr_unprotect(__func__);
5291
5292 return ret;
5293}
5294
5295static int __iw_get_retry(struct net_device *dev,
5296 struct iw_request_info *info,
5297 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005298{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305299 hdd_adapter_t *pAdapter;
5300 hdd_context_t *pHddCtx;
5301 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305303 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005304
5305 ENTER();
5306
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305307 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5308 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005309 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5311 "%s: Adapter is NULL",__func__);
5312 return -EINVAL;
5313 }
5314
5315 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5316 ret = wlan_hdd_validate_context(pHddCtx);
5317 if (0 != ret)
5318 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305319 return ret;
5320 }
5321
5322 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5323 if (NULL == hHal)
5324 {
5325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5326 "%s: Hal Context is NULL",__func__);
5327 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005328 }
5329
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 if((wrqu->retry.flags & IW_RETRY_LONG))
5331 {
5332 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5333
5334 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5335 {
c_hpothub8245442013-11-20 23:41:09 +05305336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5337 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 return -EIO;
5339 }
5340
5341 wrqu->retry.value = retry;
5342 }
5343 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5344 {
5345 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5346
5347 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5348 {
c_hpothub8245442013-11-20 23:41:09 +05305349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5350 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 return -EIO;
5352 }
5353
5354 wrqu->retry.value = retry;
5355 }
5356 else {
5357 return -EOPNOTSUPP;
5358 }
5359
Arif Hussain6d2a3322013-11-17 19:50:10 -08005360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005361
5362 EXIT();
5363
5364 return 0;
5365}
5366
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305367static int iw_get_retry(struct net_device *dev,
5368 struct iw_request_info *info,
5369 union iwreq_data *wrqu, char *extra)
5370{
5371 int ret;
5372
5373 vos_ssr_protect(__func__);
5374 ret = __iw_get_retry(dev, info, wrqu, extra);
5375 vos_ssr_unprotect(__func__);
5376
5377 return ret;
5378}
5379
5380static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 struct iw_request_info *info,
5382 union iwreq_data *wrqu,
5383 char *extra)
5384{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305385 hdd_adapter_t *pAdapter;
5386 hdd_context_t *pHddCtx;
5387 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5389 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305390 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005391
5392 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305393 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5394 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5397 "%s:Adapter is NULL",__func__);
5398 return -EINVAL;
5399 }
5400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5401 ret = wlan_hdd_validate_context(pHddCtx);
5402 if (0 != ret)
5403 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305404 return ret;
5405 }
5406 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5407 if (NULL == pHddStaCtx)
5408 {
5409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5410 "%s:STA context is NULL",__func__);
5411 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 }
5413
5414 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5415 switch (mlme->cmd) {
5416 case IW_MLME_DISASSOC:
5417 case IW_MLME_DEAUTH:
5418
5419 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5420 {
5421 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5422
5423 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5424 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5425
5426 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5427 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5428
Jeff Johnson43971f52012-07-17 12:26:56 -07005429 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305430 {
5431 long ret;
5432 ret = wait_for_completion_interruptible_timeout(
5433 &pAdapter->disconnect_comp_var,
5434 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5435 if (ret <= 0)
5436 hddLog(VOS_TRACE_LEVEL_ERROR,
5437 FL("failed wait on disconnect_comp_var %ld"), ret);
5438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005440 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005441 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005442
5443 /* Resetting authKeyMgmt */
5444 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5445
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305446 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 netif_tx_disable(dev);
5448 netif_carrier_off(dev);
5449
5450 }
5451 else
5452 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005453 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 -07005454 }
5455 break;
5456 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005457 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 return -EINVAL;
5459 }//end of switch
5460
5461 EXIT();
5462
5463 return status;
5464
5465}
5466
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305467static int iw_set_mlme(struct net_device *dev,
5468 struct iw_request_info *info,
5469 union iwreq_data *wrqu,
5470 char *extra)
5471{
5472 int ret;
5473
5474 vos_ssr_protect(__func__);
5475 ret = __iw_set_mlme(dev, info, wrqu, extra);
5476 vos_ssr_unprotect(__func__);
5477
5478 return ret;
5479}
5480
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305481int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305482{
5483 sHwCalValues hwCalValues;
5484 uint16 hwCalTxPower;
5485 uint8 txPwr = TX_PWR_DEF;
5486
5487 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5488
5489 if (TRUE == set_value) {
5490 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5491 NULL, sizeof(sHwCalValues) )
5492 != VOS_STATUS_SUCCESS) {
5493 return -EINVAL;
5494 }
5495 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5496
5497 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5498 hwCalTxPower, hwCalValues.calData.hwParam7);
5499
5500 txPwr = (int8)(hwCalTxPower & 0x00FF);
5501 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305502 if (txPwr == 0)
5503 txPwr = TX_PWR_DEF;
5504 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305505 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305506 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305507 txPwr = TX_PWR_MAX;
5508
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305509 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305510 eHAL_STATUS_SUCCESS) {
5511 hddLog(VOS_TRACE_LEVEL_ERROR,
5512 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5513 return -EIO;
5514 }
5515
5516 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5517 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305518 if (txPwr == 0)
5519 txPwr = TX_PWR_DEF;
5520 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305521 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305522 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305523 txPwr = TX_PWR_MAX;
5524
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305525 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305526 eHAL_STATUS_SUCCESS) {
5527 hddLog(VOS_TRACE_LEVEL_ERROR,
5528 FL("setting tx power failed for 5GHz band %d"), txPwr);
5529 return -EIO;
5530 }
5531 }
5532 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305533 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305534 eHAL_STATUS_SUCCESS) {
5535 hddLog(VOS_TRACE_LEVEL_ERROR,
5536 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5537 return -EIO;
5538 }
5539
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305540 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305541 eHAL_STATUS_SUCCESS) {
5542 hddLog(VOS_TRACE_LEVEL_ERROR,
5543 FL("setting tx power failed for 5GHz band %d"), txPwr);
5544 return -EIO;
5545 }
5546 }
5547 else {
5548 return -EINVAL;
5549 }
5550
5551 return eHAL_STATUS_SUCCESS;
5552}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305553
5554static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5555{
5556 int ret = 0;
5557 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5558 tDelBaParams del_session;
5559
5560 del_session.session_id = adapter->sessionId;
5561 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5562
5563 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5564 {
5565 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5566 value,NULL, eANI_BOOLEAN_FALSE);
5567 if (ret != eHAL_STATUS_SUCCESS)
5568 {
5569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5570 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5571 return -EIO;
5572 }
5573
5574 } else {
5575 hddLog(VOS_TRACE_LEVEL_ERROR,
5576 FL("Invalid command input"));
5577 return -EINVAL;
5578 }
5579 ret = sme_del_sta_ba_session_req(hal, del_session);
5580 if (ret != VOS_STATUS_SUCCESS) {
5581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5582 return -EINVAL;
5583 }
5584
5585 EXIT();
5586 return ret;
5587}
5588
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305589static int
5590wlan_hdd_sta_mon_op(hdd_context_t *hdd_ctx, uint32_t set_value,
5591 hdd_adapter_t *mon_adapter, hdd_mon_ctx_t *mon_ctx)
5592{
5593 hdd_station_ctx_t *sta_ctx;
5594 VOS_STATUS disable_bmps_status;
5595 hdd_adapter_t *sta_adapter;
5596 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(mon_adapter))->pvosContext;
5597
5598 if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) {
5599 hddLog(LOGE, FL("Monitor Interface is not OPENED"));
5600 return -EINVAL;
5601 }
5602
5603 if (set_value == MON_MODE_STOP) {
5604 if (wlan_hdd_check_monitor_state(hdd_ctx))
5605 return 0;
5606 return -EINVAL;
5607 }
5608
5609 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
5610 if (!sta_adapter) {
5611 hddLog(LOGE, FL("No Station adapter"));
5612 return -EINVAL;
5613 }
5614
5615 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
5616 if (!sta_ctx || !hdd_connIsConnected(sta_ctx)) {
5617 hddLog(LOGE, FL("STA is not connected"));
5618 return -EINVAL;
5619 }
5620
5621 if (hdd_isConnectionInProgress(hdd_ctx, NULL, NULL)) {
5622 hddLog(LOGE, FL("Roaming or set-key is in progress"));
5623 return -EBUSY;
5624 }
5625
5626 hdd_disable_roaming(hdd_ctx);
5627
5628 hddLog(LOG1, FL("Disable BMPS"));
5629 disable_bmps_status = hdd_disable_bmps_imps(hdd_ctx,
5630 WLAN_HDD_INFRA_STATION);
5631 if (disable_bmps_status != VOS_STATUS_SUCCESS) {
5632 hddLog(LOGE, FL("Cannot start monitor mode"));
5633 hdd_restore_roaming(hdd_ctx);
5634 return -EINVAL;
5635 }
5636
5637 mon_ctx->ChannelNo = sta_ctx->conn_info.operationChannel;
5638
5639 /*
5640 * In STA + Mon mode, firmware should not consider ChannelBW
5641 */
5642 mon_ctx->ChannelBW = 0;
5643 mon_ctx->crcCheckEnabled = 0;
5644 wlan_hdd_mon_set_typesubtype(mon_ctx, 100);
5645 mon_ctx->is80211to803ConReq = 0;
5646 WLANTL_SetIsConversionReq(vos_ctx, 0);
5647 mon_adapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
5648
5649 mon_ctx->state = MON_MODE_START;
5650 return 0;
5651}
5652
5653/* set param sub-ioctls */
5654static int __iw_mon_setint_getnone(struct net_device *dev,
5655 struct iw_request_info *info,
5656 union iwreq_data *wrqu, char *extra)
5657{
5658 hdd_adapter_t *adapter;
5659 hdd_context_t *hdd_ctx;
5660 hdd_mon_ctx_t *mon_ctx;
5661 int *value = (int *)extra;
5662 int sub_cmd = value[0];
5663 int set_value = value[1];
5664 int ret = 0; /* success */
5665 tVOS_CONCURRENCY_MODE concurrency_mode;
5666
5667 ENTER();
5668 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5669 if (!adapter || adapter->device_mode != WLAN_HDD_MONITOR)
5670 return -EINVAL;
5671
5672 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5673 ret = wlan_hdd_validate_context(hdd_ctx);
5674 if (ret)
5675 return ret;
5676
5677 concurrency_mode = hdd_ctx->concurrency_mode;
5678 if (concurrency_mode != VOS_STA_MON) {
5679 hddLog(LOGE, "invalid concurrency mode %d", concurrency_mode);
5680 return -EINVAL;
5681 }
5682
5683 switch(sub_cmd) {
5684
5685 case WE_SET_MONITOR_STATE:
5686 {
5687 v_U32_t magic = 0;
5688 struct completion cmp_var;
5689 long waitRet = 0;
5690
5691 mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter);
5692 if(!mon_ctx) {
5693 hddLog(LOGE, "Monitor Context NULL");
5694 ret = -EIO;
5695 break;
5696 }
5697
5698 if (mon_ctx->state == set_value) {
5699 hddLog(LOGE, FL("already in same mode curr_mode:%d req_mode: %d"),
5700 mon_ctx->state, set_value);
5701 break;
5702 }
5703
5704 ret = wlan_hdd_sta_mon_op(hdd_ctx, set_value,
5705 adapter,mon_ctx);
5706 if (ret)
5707 break;
5708
5709 mon_ctx->state = set_value;
5710 magic = MON_MODE_MSG_MAGIC;
5711 init_completion(&cmp_var);
5712 if (wlan_hdd_mon_postMsg(&magic, &cmp_var, mon_ctx,
5713 hdd_monPostMsgCb) != VOS_STATUS_SUCCESS) {
5714 hddLog(LOGE, FL("failed to post MON MODE REQ"));
5715 mon_ctx->state =
5716 (mon_ctx->state==MON_MODE_START) ?
5717 MON_MODE_STOP : MON_MODE_START;
5718 magic = 0;
5719 ret = -EIO;
5720 break;
5721 }
5722
5723 waitRet = wait_for_completion_timeout(&cmp_var,
5724 MON_MODE_MSG_TIMEOUT);
5725 magic = 0;
5726 if (waitRet <= 0 ){
5727 hddLog(LOGE, FL("failed to wait on monitor mode completion %ld"),
5728 waitRet);
5729 } else if (mon_ctx->state == MON_MODE_STOP) {
5730 hddLog(LOG1, FL("Enable BMPS"));
5731 hdd_enable_bmps_imps(hdd_ctx);
5732 hdd_restore_roaming(hdd_ctx);
5733 }
5734 }
5735 break;
5736
5737 default:
5738 {
5739 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
5740 sub_cmd, set_value);
5741 }
5742 break;
5743 }
5744
5745 EXIT();
5746 return ret;
5747}
5748
Jeff Johnson295189b2012-06-20 16:38:30 -07005749/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305750static int __iw_setint_getnone(struct net_device *dev,
5751 struct iw_request_info *info,
5752 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005753{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305754 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305755 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305756 hdd_wext_state_t *pWextState;
5757 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305758 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 int *value = (int *)extra;
5760 int sub_cmd = value[0];
5761 int set_value = value[1];
5762 int ret = 0; /* success */
5763 int enable_pbm, enable_mp;
5764#ifdef CONFIG_HAS_EARLYSUSPEND
5765 v_U8_t nEnableSuspendOld;
5766#endif
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305767 void *cookie;
5768 struct hdd_request *request;
Jeff Johnson295189b2012-06-20 16:38:30 -07005769
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305770 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305771 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5772 if (NULL == pAdapter)
5773 {
5774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5775 "%s: Adapter is NULL",__func__);
5776 return -EINVAL;
5777 }
5778 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5779 ret = wlan_hdd_validate_context(pHddCtx);
5780 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005781 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305782 return ret;
5783 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305784
Katya Nigameae74b62015-05-28 17:19:16 +05305785 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305786 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305787 /* In monitor mode hHal is NULL */
5788 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5789 if (NULL == hHal)
5790 {
5791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5792 "%s: Hal Context is NULL",__func__);
5793 return -EINVAL;
5794 }
Katya Nigameae74b62015-05-28 17:19:16 +05305795 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5796 if (NULL == pWextState)
5797 {
5798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5799 "%s: pWextState is NULL",__func__);
5800 return -EINVAL;
5801 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005802
Katya Nigameae74b62015-05-28 17:19:16 +05305803 INIT_COMPLETION(pWextState->completion_var);
5804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 switch(sub_cmd)
5806 {
5807 case WE_SET_11D_STATE:
5808 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005809 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005810 memset(&smeConfig, 0x00, sizeof(smeConfig));
5811
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305812 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5813 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 sme_GetConfigParam(hHal,&smeConfig);
5815 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5816
Arif Hussain6d2a3322013-11-17 19:50:10 -08005817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818
5819 sme_UpdateConfig(hHal,&smeConfig);
5820 }
5821 else {
5822 return -EINVAL;
5823 }
5824 break;
5825 }
5826
5827 case WE_WOWL:
5828 {
5829 switch (set_value)
5830 {
5831 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305832 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 break;
5834 case 0x01:
5835 case 0x02:
5836 case 0x03:
5837 enable_mp = (set_value & 0x01) ? 1 : 0;
5838 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005839 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5841 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5842 break;
5843 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005844 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 ret = -EINVAL;
5846 break;
5847 }
5848
5849 break;
5850 }
5851 case WE_SET_POWER:
5852 {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305853 if (wlan_hdd_check_monitor_state(pHddCtx)) {
5854 hddLog(LOGE, FL("setPower not allowed in STA + MON"));
5855 ret = -EOPNOTSUPP;
5856 break;
5857 }
5858
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 switch (set_value)
5860 {
5861 case 0: //Full Power
5862 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305863 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305864 static const struct hdd_request_params params = {
5865 .priv_size = 0,
5866 .timeout_ms = WLAN_WAIT_TIME_POWER,
5867 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005868
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305869 if (NULL == hHal)
5870 return -EINVAL;
5871
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305872 request = hdd_request_alloc(&params);
5873 if (!request) {
5874 hddLog(VOS_TRACE_LEVEL_ERROR,
5875 FL("Request allocation failure"));
5876 return VOS_STATUS_E_NOMEM;
5877 }
5878 cookie = hdd_request_cookie(request);
5879
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305881 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305883
Jeff Johnson72a40512013-12-19 10:14:15 -08005884 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305886 ret = hdd_request_wait_for_response(request);
5887 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005888 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305889 FL("SME timeout while requesting bmps"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 }
5891 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305892
5893 /*
5894 * either we never sent a request, we sent a request and
5895 * received a response or we sent a request and timed out.
5896 * Regardless we are done with the request.
5897 */
5898 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005899
Arif Hussain6d2a3322013-11-17 19:50:10 -08005900 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 break;
5902 }
5903 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305904 if (hHal)
5905 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5906 else
5907 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 break;
5909 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305910 if (hHal)
5911 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5912 else
5913 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 break;
5915 case 3: //Request Bmps
5916 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305917 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305918 static const struct hdd_request_params params = {
5919 .priv_size = 0,
5920 .timeout_ms = WLAN_WAIT_TIME_POWER,
5921 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005922
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305923 if (NULL == hHal)
5924 return -EINVAL;
5925
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305926 request = hdd_request_alloc(&params);
5927 if (!request) {
5928 hddLog(VOS_TRACE_LEVEL_ERROR,
5929 FL("Request allocation failure"));
5930 return VOS_STATUS_E_NOMEM;
5931 }
5932 cookie = hdd_request_cookie(request);
5933
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305935 iw_power_callback_func, cookie);
Jeff Johnson72a40512013-12-19 10:14:15 -08005936 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305938 ret = hdd_request_wait_for_response(request);
5939 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005940 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305941 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 }
5943 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305944
5945 /*
5946 * either we never sent a request, we sent a request and
5947 * received a response or we sent a request and timed out.
5948 * Regardless we are done with the request.
5949 */
5950 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005951
Arif Hussain6d2a3322013-11-17 19:50:10 -08005952 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 break;
5954 }
5955 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305956 if (hHal)
5957 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5958 else
5959 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 break;
5961 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305962 if (hHal)
5963 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5964 else
5965 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 break;
5967 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305968 if (hHal)
5969 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5970 else
5971 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 break;
5973 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305974 if (hHal)
5975 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5976 else
5977 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 break;
5979 case 8: //Request Standby
5980#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005981#endif
5982 break;
5983 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305984 if (hHal)
5985 sme_StartAutoBmpsTimer(hHal);
5986 else
5987 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 break;
5989 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305990 if (hHal)
5991 sme_StopAutoBmpsTimer(hHal);
5992 else
5993 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 break;
5995#ifdef CONFIG_HAS_EARLYSUSPEND
5996 case 11://suspend to standby
5997#ifdef CONFIG_HAS_EARLYSUSPEND
5998 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5999 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
6001#endif
6002 break;
6003 case 12://suspend to deep sleep
6004#ifdef CONFIG_HAS_EARLYSUSPEND
6005 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
6006 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
6008#endif
6009 break;
6010 case 13://resume from suspend
6011#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07006012#endif
6013 break;
6014#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006016 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 ret = -EINVAL;
6018 break;
6019 }
6020 break;
6021 }
6022
6023 case WE_SET_MAX_ASSOC:
6024 {
6025 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306026 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
6027 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 {
6029 ret = -EINVAL;
6030 }
6031 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
6032 set_value, NULL, eANI_BOOLEAN_FALSE)
6033 != eHAL_STATUS_SUCCESS )
6034 {
c_hpothub8245442013-11-20 23:41:09 +05306035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6036 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 ret = -EIO;
6038 }
6039 break;
6040 }
6041
6042 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
6043 {
6044 if( 0 == set_value )
6045 {
6046 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
6047 }
6048 else if ( 1 == set_value )
6049 {
6050 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
6051 }
6052 else
6053 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006054 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 ret = -EINVAL;
6056 }
6057 break;
6058 }
6059
6060 case WE_SET_DATA_INACTIVITY_TO:
6061 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306062 if (NULL == hHal)
6063 return -EINVAL;
6064
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
6066 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
6067 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6068 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
6069 set_value,
6070 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
6071 {
6072 hddLog(LOGE,"Failure: Could not pass on "
6073 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006074 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 ret = -EINVAL;
6076 }
6077 break;
6078 }
6079 case WE_SET_MAX_TX_POWER:
6080 {
6081 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6082 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6083
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306084 if (NULL == hHal)
6085 return -EINVAL;
6086
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
6088 __func__, set_value);
6089 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
6090 eHAL_STATUS_SUCCESS )
6091 {
6092 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6093 __func__);
6094 return -EIO;
6095 }
6096
6097 break;
6098 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07006099 case WE_SET_MAX_TX_POWER_2_4:
6100 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306101 if (NULL == hHal)
6102 return -EINVAL;
6103
Arif Hussaina5ebce02013-08-09 15:09:58 -07006104 hddLog(VOS_TRACE_LEVEL_INFO,
6105 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6106 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306107 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006108 eHAL_STATUS_SUCCESS)
6109 {
6110 hddLog(VOS_TRACE_LEVEL_ERROR,
6111 "%s: Setting maximum tx power failed for 2.4 GHz band",
6112 __func__);
6113 return -EIO;
6114 }
6115
6116 break;
6117 }
6118 case WE_SET_MAX_TX_POWER_5_0:
6119 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306120 if (NULL == hHal)
6121 return -EINVAL;
6122
Arif Hussaina5ebce02013-08-09 15:09:58 -07006123 hddLog(VOS_TRACE_LEVEL_INFO,
6124 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6125 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306126 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006127 eHAL_STATUS_SUCCESS)
6128 {
6129 hddLog(VOS_TRACE_LEVEL_ERROR,
6130 "%s: Setting maximum tx power failed for 5.0 GHz band",
6131 __func__);
6132 return -EIO;
6133 }
6134
6135 break;
6136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 case WE_SET_HIGHER_DTIM_TRANSITION:
6138 {
6139 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6140 (set_value == eANI_BOOLEAN_TRUE)))
6141 {
6142 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6143 ret = -EINVAL;
6144 }
6145 else
6146 {
6147 if(pAdapter->higherDtimTransition != set_value)
6148 {
6149 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006150 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 }
6152 }
6153
6154 break;
6155 }
6156
6157 case WE_SET_TM_LEVEL:
6158 {
6159 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006160 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6162
6163 break;
6164 }
6165
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306166 case WE_ENABLE_STRICT_FCC_REG:
6167 {
6168 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6169 struct wiphy *wiphy = NULL;
6170 long lrc;
6171 int status;
6172
6173 wiphy = hddCtxt->wiphy;
6174 if(wiphy == NULL)
6175 {
6176 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6177 break;
6178 }
6179 init_completion(&hddCtxt->wiphy_channel_update_event);
6180
6181 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6182
6183 status = regulatory_hint(wiphy, "00");
6184 if(status < 0)
6185 {
6186 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6187 break;
6188 }
6189
6190 /* Wait for completion */
6191 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6192 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6193 if (lrc <= 0)
6194 {
6195 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6196 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6197 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6198 }
6199 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6200
6201 break;
6202 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006203 case WE_SET_DEBUG_LOG:
6204 {
6205 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6206 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306207 if (hHal)
6208 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6209 else
6210 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006211 break;
6212 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306213#ifdef FEATURE_WLAN_TDLS
6214 case WE_SET_TDLS_OFF_CHAN:
6215 {
6216 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6218 __func__, set_value);
6219 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6220 break;
6221 }
6222 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6223 {
6224 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6226 __func__, set_value);
6227 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6228 break;
6229 }
6230 case WE_SET_TDLS_OFF_CHAN_MODE:
6231 {
6232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6233 __func__, set_value);
6234 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6235 break;
6236 }
6237#endif
Peng Xu2446a892014-09-05 17:21:18 +05306238 case WE_SET_SCAN_BAND_PREFERENCE:
6239 {
6240 tSmeConfigParams smeConfig;
6241 memset(&smeConfig, 0x00, sizeof(smeConfig));
6242 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6243 ret = -EINVAL;
6244 break;
6245 }
6246 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6247
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306248 if ((eCSR_BAND_ALL == set_value ||
6249 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6250 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306251 sme_GetConfigParam(hHal, &smeConfig);
6252 smeConfig.csrConfig.scanBandPreference = set_value;
6253
6254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6255 "set band scan preference = %d\n",
6256 smeConfig.csrConfig.scanBandPreference);
6257
6258 sme_UpdateConfig(hHal, &smeConfig);
6259 }
6260 else {
6261 ret = -EINVAL;
6262 }
6263 break;
6264 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306265 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6266 * connection happens so that the params can take effect during
6267 * association. Also this should not be used in STA+p2p concurrency
6268 * as the param will also effect the STA mode.
6269 */
6270 case WE_SET_MIRACAST_VENDOR_CONFIG:
6271 {
6272 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306273
Abhishek Singh01c73d12015-03-12 15:13:44 +05306274 hddLog(LOG1, FL(
6275 "Set Miracast vendor tuning %d"), set_value);
6276
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306277 if (NULL == hHal)
6278 return -EINVAL;
6279
Abhishek Singh01c73d12015-03-12 15:13:44 +05306280 if (1 == set_value || 0 == set_value)
6281 {
6282 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6283 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6284 {
6285 hddLog( LOGE, FL("set vendor miracast config failed"));
6286 ret = -EIO;
6287 }
6288 }
6289 else
6290 {
6291 hddLog(LOGE,
6292 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6293 ret = -EINVAL;
6294 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306295 break;
6296 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306297
6298 case WE_GET_FRAME_LOG:
6299 {
6300 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6301 != VOS_STATUS_SUCCESS)
6302 {
6303 ret = -EINVAL;
6304 }
6305 break;
6306 }
6307
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306308 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6309 {
6310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6311 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306312 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306313 {
6314 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6315 set_value);
6316 }
6317 else
6318 ret = -EINVAL;
6319
6320 break;
6321 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306322 /* Bit mask value to enable RTS/CTS for different modes
6323 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6324 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6325 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6326 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6327 * for 5 GHz, VHT80 - 0x1000
6328 */
6329 case WE_SET_RTS_CTS_HTVHT:
6330 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306331
Abhishek Singh41988ba2015-05-25 19:42:29 +05306332 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6333
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306334 if (NULL == hHal)
6335 return -EINVAL;
6336
Abhishek Singh41988ba2015-05-25 19:42:29 +05306337 if (eHAL_STATUS_SUCCESS !=
6338 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6339 {
6340 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6341 ret = -EINVAL;
6342 }
6343 break;
6344 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306345 case WE_SET_MONITOR_STATE:
6346 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306347 v_U32_t magic = 0;
6348 struct completion cmpVar;
6349 long waitRet = 0;
6350 tVOS_CON_MODE mode = hdd_get_conparam();
6351
6352 if( VOS_MONITOR_MODE != mode)
6353 {
6354 hddLog(LOGE, "invalid mode %d", mode);
6355 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306356 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306357 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306358
6359 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6360 if( pMonCtx == NULL )
6361 {
6362 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306363 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306364 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306365 }
6366 if (pMonCtx->state == set_value)
6367 {
6368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6369 FL("already in same mode curr_mode:%d req_mode: %d"),
6370 pMonCtx->state, set_value);
6371 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306372 }
6373 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306374 magic = MON_MODE_MSG_MAGIC;
6375 init_completion(&cmpVar);
6376 if (VOS_STATUS_SUCCESS !=
6377 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6378 pMonCtx, hdd_monPostMsgCb)) {
6379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6380 FL("failed to post MON MODE REQ"));
6381 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6382 MON_MODE_STOP : MON_MODE_START;
6383 magic = 0;
6384 ret = -EIO;
6385 break;
6386 }
6387 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6388 magic = 0;
6389 if (waitRet <= 0 ){
6390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6391 FL("failed to wait on monitor mode completion %ld"),
6392 waitRet);
6393 }
6394 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306395 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306396 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6397 {
6398 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6399 tAniWifiStartLog start_log;
6400 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6401 !vos_isPktStatsEnabled())
6402 {
6403 hddLog(LOGE, FL("per pkt stats not enabled"));
6404 return -EINVAL;
6405 }
6406 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6407
6408 if (1 == set_value || 0 == set_value)
6409 {
6410 start_log.ringId = RING_ID_PER_PACKET_STATS;
6411 start_log.flag = 0;
6412 if (set_value)
6413 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6414 else
6415 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6416
6417 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6418 }
6419 else
6420 {
6421 hddLog(LOGE,
6422 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6423 set_value);
6424 ret = -EINVAL;
6425 }
6426 break;
6427 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306428 case WE_SET_PROXIMITY_ENABLE:
6429 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306430 if (NULL == hHal)
6431 return -EINVAL;
6432
6433 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306434 break;
6435 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306436 case WE_CAP_TSF:
6437 {
6438 if (NULL == hHal)
6439 return -EINVAL;
6440
6441 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6442 break;
6443 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306444 case WE_SET_MODULATED_DTIM:
6445 {
6446 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6447 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6448 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6449 set_value);
6450 return -EINVAL;
6451 } else {
6452 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6453 enableModulatedDTIM = set_value;
6454 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306455 }
6456 case WLAN_SET_DYNNAMIC_AGGREGATION:
6457 {
6458 if (NULL == hHal)
6459 return -EINVAL;
6460
6461 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306462 break;
6463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 default:
6465 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006466 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 sub_cmd, set_value);
6468 break;
6469 }
6470 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306471 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 return ret;
6473}
6474
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306475static int iw_setint_getnone(struct net_device *dev,
6476 struct iw_request_info *info,
6477 union iwreq_data *wrqu, char *extra)
6478{
6479 int ret;
6480
6481 vos_ssr_protect(__func__);
6482 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6483 vos_ssr_unprotect(__func__);
6484
6485 return 0;
6486}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306487
6488static
6489int iw_mon_setint_getnone(struct net_device *dev,
6490 struct iw_request_info *info,
6491 union iwreq_data *wrqu, char *extra)
6492{
6493 int ret;
6494
6495 vos_ssr_protect(__func__);
6496 ret = __iw_mon_setint_getnone(dev, info, wrqu, extra);
6497 vos_ssr_unprotect(__func__);
6498
6499 return 0;
6500}
6501
Jeff Johnson295189b2012-06-20 16:38:30 -07006502/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306503static int __iw_setchar_getnone(struct net_device *dev,
6504 struct iw_request_info *info,
6505 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006506{
6507 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306508 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006510 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306511 hdd_adapter_t *pAdapter;
6512 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006513#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306514 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006515#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306516 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306517 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306519 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306520
6521 if (!capable(CAP_NET_ADMIN))
6522 {
6523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6524 FL("permission check failed"));
6525 return -EPERM;
6526 }
6527
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306528 pAdapter = (netdev_priv(dev));
6529 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006530 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6532 "%s: Adapter is NULL",__func__);
6533 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006534 }
6535
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306536 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6537 ret = wlan_hdd_validate_context(pHddCtx);
6538 if (0 != ret)
6539 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306540 return ret;
6541 }
6542#ifdef WLAN_FEATURE_VOWIFI
6543 pConfig = pHddCtx->cfg_ini;
6544#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306545 /* helper function to get iwreq_data with compat handling. */
6546 if (hdd_priv_get_data(&s_priv_data, wrqu))
6547 {
6548 return -EINVAL;
6549 }
6550
6551 /* make sure all params are correctly passed to function */
6552 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6553 {
6554 return -EINVAL;
6555 }
6556
6557 sub_cmd = s_priv_data.flags;
6558
Arif Hussain0273cba2014-01-07 20:58:29 -08006559 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306560 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6561 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006562 if (NULL == pBuffer)
6563 {
6564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6565 "mem_alloc_copy_from_user_helper fail");
6566 return -ENOMEM;
6567 }
6568
6569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306570 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6572 "%s: Received data %s", __func__, pBuffer);
6573
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 switch(sub_cmd)
6575 {
6576 case WE_WOWL_ADD_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306577 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6578 hddLog(LOGE, FL("wowlAddPtrn not allowed in STA + MON"));
6579 ret = -EOPNOTSUPP;
6580 break;
6581 }
6582
Arif Hussain6d2a3322013-11-17 19:50:10 -08006583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006584 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 break;
6586 case WE_WOWL_DEL_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306587 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6588 hddLog(LOGE, FL("wowlDelPtrn not allowed in STA + MON"));
6589 ret = -EOPNOTSUPP;
6590 break;
6591 }
6592
Arif Hussain6d2a3322013-11-17 19:50:10 -08006593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006594 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 break;
6596#if defined WLAN_FEATURE_VOWIFI
6597 case WE_NEIGHBOR_REPORT_REQUEST:
6598 {
6599 tRrmNeighborReq neighborReq;
6600 tRrmNeighborRspCallbackInfo callbackInfo;
6601
6602 if (pConfig->fRrmEnable)
6603 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306605 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 if( !neighborReq.no_ssid )
6607 {
Girish Gowli552fc072014-06-14 18:26:16 +05306608 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006609 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 }
6611
6612 callbackInfo.neighborRspCallback = NULL;
6613 callbackInfo.neighborRspCallbackContext = NULL;
6614 callbackInfo.timeout = 5000; //5 seconds
6615 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6616 }
6617 else
6618 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006619 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 ret = -EINVAL;
6621 }
6622 }
6623 break;
6624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 case WE_SET_AP_WPS_IE:
6626 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306627 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006630 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 if (VOS_STATUS_SUCCESS != vstatus)
6632 {
6633 ret = -EINVAL;
6634 }
6635 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306636 case WE_SET_ENCRYPT_MSG:
6637 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6638 if (NULL == pkt)
6639 {
6640 hddLog(VOS_TRACE_LEVEL_ERROR,
6641 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306642 ret = -ENOMEM;
6643 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306644 }
6645
6646 memset(pkt, 0, sizeof(tSirpkt80211));
6647
6648 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6649 hddLog(VOS_TRACE_LEVEL_ERROR,
6650 FL("Firmware is not DISA capable"));
6651 ret = -EINVAL;
6652 vos_mem_free(pkt);
6653 break;
6654 }
6655
6656 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6657
6658 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6659 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6660 if (eHAL_STATUS_SUCCESS != ret) {
6661 hddLog(VOS_TRACE_LEVEL_ERROR,
6662 FL("SENDEncryptMSG: fail to post WDA cmd"));
6663 ret = -EINVAL;
6664 }
6665 vos_mem_free(pkt);
6666
6667 break;
6668
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 default:
6670 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006671 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 ret = -EINVAL;
6673 break;
6674 }
6675 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006676 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306677
6678 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 return ret;
6680}
6681
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306682static int iw_setchar_getnone(struct net_device *dev,
6683 struct iw_request_info *info,
6684 union iwreq_data *wrqu, char *extra)
6685{
6686 int ret;
6687
6688 vos_ssr_protect(__func__);
6689 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6690 vos_ssr_unprotect(__func__);
6691
6692 return ret;
6693}
6694
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306695struct get_antenna_idx_priv {
6696 int antenna_id;
6697};
6698
6699static void hdd_get_current_antenna_index_cb(int antenna_id, void *context)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306700{
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306701 struct hdd_request *request;
6702 struct get_antenna_idx_priv *priv;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306703
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306704 request = hdd_request_get(context);
6705 if (!request) {
6706 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
6707 return;
6708 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306709
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306710 priv = hdd_request_priv(request);
6711 priv->antenna_id = antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306712
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306713 hdd_request_complete(request);
6714 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306715
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306716}
6717
6718static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6719 int *antennaIndex)
6720{
6721 hdd_context_t *pHddCtx;
6722 eHalStatus halStatus;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306723 int ret;
6724 void *cookie;
6725 struct hdd_request *request;
6726 struct get_antenna_idx_priv *priv;
6727 static const struct hdd_request_params params = {
6728 .priv_size = sizeof(*priv),
6729 .timeout_ms = WLAN_WAIT_TIME_STATS,
6730 };
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306731
6732 ENTER();
6733 if (NULL == pAdapter)
6734 {
6735 hddLog(VOS_TRACE_LEVEL_WARN,
6736 "%s: Invalid context, pAdapter", __func__);
6737 return VOS_STATUS_E_FAULT;
6738 }
6739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6740 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6741 {
6742 return VOS_STATUS_E_FAULT;
6743 }
6744 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6745 {
6746 hddLog(VOS_TRACE_LEVEL_ERROR,
6747 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6748 __func__);
6749 return VOS_STATUS_E_NOSUPPORT;
6750 }
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306751
6752 request = hdd_request_alloc(&params);
6753 if (!request) {
6754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6755 return VOS_STATUS_E_NOMEM;
6756 }
6757 cookie = hdd_request_cookie(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306758
6759 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306760 hdd_get_current_antenna_index_cb,
6761 cookie, pAdapter->sessionId);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306762 if (eHAL_STATUS_SUCCESS != halStatus)
6763 {
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306764 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6765 __func__);
6766 /* we'll returned a cached value below */
6767 *antennaIndex = -1;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306768 }
6769 else
6770 {
6771 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306772 if (ret)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306773 {
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306774 hddLog(VOS_TRACE_LEVEL_ERROR,
6775 FL("SME timeout while retrieving Antenna Index"));
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306776 *antennaIndex = -1;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306777 }
6778 else
6779 {
6780 priv = hdd_request_priv(request);
6781 pAdapter->antennaIndex = priv->antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306782 }
6783 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306784
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306785 if (*antennaIndex != -1)
6786 *antennaIndex = pAdapter->antennaIndex;
6787
6788 /*
6789 * either we never sent a request, we sent a request and received a
6790 * response or we sent a request and timed out. Regardless we are
6791 * done with the request.
6792 */
6793 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306794
6795 EXIT();
6796 return VOS_STATUS_SUCCESS;
6797}
6798
Jeff Johnson295189b2012-06-20 16:38:30 -07006799/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306800static int __iw_setnone_getint(struct net_device *dev,
6801 struct iw_request_info *info,
6802 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006803{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306804 hdd_adapter_t *pAdapter;
6805 tHalHandle hHal;
6806 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 int *value = (int *)extra;
6808 int ret = 0; /* success */
6809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306810 ENTER();
6811
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306812 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6813 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006814 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6816 "%s: Adapter is NULL",__func__);
6817 return -EINVAL;
6818 }
6819 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6820 ret = wlan_hdd_validate_context(pHddCtx);
6821 if (0 != ret)
6822 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306823 return ret;
6824 }
6825 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6826 if (NULL == hHal)
6827 {
6828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6829 "%s: Hal Context is NULL",__func__);
6830 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006832
6833 switch (value[0])
6834 {
6835 case WE_GET_11D_STATE:
6836 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006837 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6841
Arif Hussain6d2a3322013-11-17 19:50:10 -08006842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006843
6844 break;
6845 }
6846
6847 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 break;
6850
6851 case WE_PMC_STATE:
6852 {
6853 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 break;
6856 }
6857 case WE_GET_WLAN_DBG:
6858 {
6859 vos_trace_display();
6860 *value = 0;
6861 break;
6862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 case WE_GET_MAX_ASSOC:
6864 {
6865 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6866 {
c_hpothub8245442013-11-20 23:41:09 +05306867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6868 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 ret = -EIO;
6870 }
Girish Gowli385be612014-09-18 11:17:20 +05306871#ifdef WLAN_SOFTAP_VSTA_FEATURE
6872 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6873 {
6874 if (*value > VSTA_NUM_ASSOC_STA)
6875 {
6876 *value = VSTA_NUM_ASSOC_STA;
6877 }
6878 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6879 (*value > (VSTA_NUM_ASSOC_STA -
6880 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6881 {
6882 *value = (VSTA_NUM_ASSOC_STA -
6883 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6884 }
6885 }
6886 else
6887#endif
6888 {
6889 if (*value > NUM_ASSOC_STA)
6890 {
6891 *value = NUM_ASSOC_STA;
6892 }
6893 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6894 (*value > (NUM_ASSOC_STA -
6895 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6896 {
6897 *value = (NUM_ASSOC_STA -
6898 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6899 }
6900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 break;
6902 }
6903
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 case WE_GET_WDI_DBG:
6905 {
6906 wpalTraceDisplay();
6907 *value = 0;
6908 break;
6909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006910
6911 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6912 {
6913 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6914 break;
6915 }
6916 case WE_GET_CONCURRENCY_MODE:
6917 {
6918 *value = hdd_get_concurrency_mode ( );
6919
Arif Hussain6d2a3322013-11-17 19:50:10 -08006920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 break;
6922 }
6923
Peng Xu2446a892014-09-05 17:21:18 +05306924 case WE_GET_SCAN_BAND_PREFERENCE:
6925 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306926 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306927 sme_GetConfigParam(hHal, &smeConfig);
6928 *value = smeConfig.csrConfig.scanBandPreference;
6929
6930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6931 "scanBandPreference = %d\n", *value);
6932 break;
6933 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306934 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6935 {
6936 wlan_hdd_get_current_antenna_index(pAdapter, value);
6937 break;
6938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 default:
6940 {
6941 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6942 break;
6943 }
6944 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306945 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 return ret;
6947}
6948
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306949static int iw_setnone_getint(struct net_device *dev,
6950 struct iw_request_info *info,
6951 union iwreq_data *wrqu, char *extra)
6952{
6953 int ret;
6954
6955 vos_ssr_protect(__func__);
6956 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6957 vos_ssr_unprotect(__func__);
6958
6959 return ret;
6960
6961}
Jeff Johnson295189b2012-06-20 16:38:30 -07006962/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306963int __iw_set_three_ints_getnone(struct net_device *dev,
6964 struct iw_request_info *info,
6965 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006966{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306967 hdd_adapter_t *pAdapter;
6968 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 int *value = (int *)extra;
6970 int sub_cmd = value[0];
6971 int ret = 0;
6972
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306973 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306974
6975 if (!capable(CAP_NET_ADMIN))
6976 {
6977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6978 FL("permission check failed"));
6979 return -EPERM;
6980 }
6981
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306982 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6983 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006984 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6986 "%s: Adapter is NULL",__func__);
6987 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006988 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306989 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6990 ret = wlan_hdd_validate_context(pHddCtx);
6991 if (0 != ret)
6992 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306993 return ret;
6994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 switch(sub_cmd)
6996 {
6997 case WE_SET_WLAN_DBG:
6998 {
6999 vos_trace_setValue( value[1], value[2], value[3]);
7000 break;
7001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 case WE_SET_WDI_DBG:
7003 {
7004 wpalTraceSetLevel( value[1], value[2], value[3]);
7005 break;
7006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 case WE_SET_SAP_CHANNELS:
7008 {
7009 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
7010 break;
7011 }
7012
7013 default:
7014 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007015 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 break;
7017 }
7018 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307019 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 return ret;
7021}
7022
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307023int iw_set_three_ints_getnone(struct net_device *dev,
7024 struct iw_request_info *info,
7025 union iwreq_data *wrqu, char *extra)
7026{
7027 int ret;
7028
7029 vos_ssr_protect(__func__);
7030 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7031 vos_ssr_unprotect(__func__);
7032
7033 return ret;
7034}
7035
7036static int __iw_get_char_setnone(struct net_device *dev,
7037 struct iw_request_info *info,
7038 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007039{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307040 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307042 hdd_context_t *pHddCtx;
7043 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07007044#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007045 hdd_wext_state_t *pWextState;
7046#endif
7047
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307048 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307049 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007050 if (pAdapter == NULL)
7051 {
7052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7053 "%s: pAdapter is NULL!", __func__);
7054 return -EINVAL;
7055 }
Alok Kumar69a8b752017-11-08 15:24:32 +05307056
7057 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
7058 WLAN_HDD_FTM == pAdapter->device_mode)
7059 return ret;
7060
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307061 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7062 ret = wlan_hdd_validate_context(pHddCtx);
7063 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07007064 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307065 return ret;
7066 }
7067#ifdef WLAN_FEATURE_11W
7068 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7069 if (NULL == pWextState)
7070 {
7071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7072 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07007073 return -EINVAL;
7074 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307075#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007076
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 switch(sub_cmd)
7078 {
7079 case WE_WLAN_VERSION:
7080 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007081 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 break;
7083 }
7084
7085 case WE_GET_STATS:
7086 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307087 tHalHandle hHal = NULL;
7088 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7090 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
7091 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307092 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07007093
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307094
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 snprintf(extra, WE_MAX_STR_LEN,
7096 "\nTransmit"
7097 "\ncalled %u, dropped %u, backpressured %u, queued %u"
7098 "\n dropped BK %u, BE %u, VI %u, VO %u"
7099 "\n classified BK %u, BE %u, VI %u, VO %u"
7100 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
7101 "\n queued BK %u, BE %u, VI %u, VO %u"
7102 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007103 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 "\n fetched BK %u, BE %u, VI %u, VO %u"
7105 "\n dequeued BK %u, BE %u, VI %u, VO %u"
7106 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007107 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 "\n flushed BK %u, BE %u, VI %u, VO %u"
7109 "\n\nReceive"
7110 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
7111 "\n\nResetsStats"
7112 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307113 "\n"
7114 "\n\nARP Transmit"
7115 "\nTransmit Count %u, dropped %u"
7116 "\n\nARP Receive"
7117 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 "\n",
7119 pStats->txXmitCalled,
7120 pStats->txXmitDropped,
7121 pStats->txXmitBackPressured,
7122 pStats->txXmitQueued,
7123
7124 pStats->txXmitDroppedAC[WLANTL_AC_BK],
7125 pStats->txXmitDroppedAC[WLANTL_AC_BE],
7126 pStats->txXmitDroppedAC[WLANTL_AC_VI],
7127 pStats->txXmitDroppedAC[WLANTL_AC_VO],
7128
7129 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
7130 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
7131 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
7132 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
7133
7134 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
7135 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
7136 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
7137 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
7138
7139 pStats->txXmitQueuedAC[WLANTL_AC_BK],
7140 pStats->txXmitQueuedAC[WLANTL_AC_BE],
7141 pStats->txXmitQueuedAC[WLANTL_AC_VI],
7142 pStats->txXmitQueuedAC[WLANTL_AC_VO],
7143
7144 pStats->txFetched,
7145 pStats->txFetchEmpty,
7146 pStats->txFetchLowResources,
7147 pStats->txFetchDequeueError,
7148
7149 pStats->txFetchDequeued,
7150 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07007151 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 pStats->txCompleted,
7153 pStats->txFlushed,
7154
7155 pStats->txFetchedAC[WLANTL_AC_BK],
7156 pStats->txFetchedAC[WLANTL_AC_BE],
7157 pStats->txFetchedAC[WLANTL_AC_VI],
7158 pStats->txFetchedAC[WLANTL_AC_VO],
7159
7160 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7161 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7162 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7163 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7164
7165 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7166 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7167 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7168 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7169
Ravi Joshi41914632013-10-21 23:02:21 -07007170 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7171 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7172 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7173 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7174
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 pStats->txFlushedAC[WLANTL_AC_BK],
7176 pStats->txFlushedAC[WLANTL_AC_BE],
7177 pStats->txFlushedAC[WLANTL_AC_VI],
7178 pStats->txFlushedAC[WLANTL_AC_VO],
7179
7180 pStats->rxChains,
7181 pStats->rxPackets,
7182 pStats->rxDropped,
7183 pStats->rxDelivered,
7184 pStats->rxRefused,
7185
7186 pResetStats->totalLogpResets,
7187 pResetStats->totalCMD53Failures,
7188 pResetStats->totalMutexReadFailures,
7189 pResetStats->totalMIFErrorFailures,
7190 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307191 pResetStats->totalUnknownExceptions,
7192
7193 parpStats->txCount,
7194 parpStats->txDropped,
7195
7196 parpStats->rxCount,
7197 parpStats->rxDropped,
7198 parpStats->rxDelivered,
7199 parpStats->rxRefused,
7200 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307202 wrqu->data.length = strlen(extra);
7203
7204 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7205
7206 if (hHal)
7207 pMac = PMAC_STRUCT( hHal );
7208
7209 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7210 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7211 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307212 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7213 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7214 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7215 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307216 "\n",
7217 pMac->pmm.BmpscntSleep,
7218 pMac->pmm.BmpscntAwake,
7219 pMac->pmm.BmpsSleeReqFailCnt,
7220 pMac->pmm.BmpsWakeupReqFailCnt,
7221 pMac->pmm.ImpsCntSleep,
7222 pMac->pmm.ImpsCntAwake,
7223 pMac->pmm.ImpsSleepErrCnt,
7224 pMac->pmm.ImpsWakeupErrCnt,
7225 pMac->pmm.ImpsLastErr
7226 );
7227 }
7228
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 wrqu->data.length = strlen(extra)+1;
7230 break;
7231 }
7232
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307233/* The case prints the current state of the HDD, SME, CSR, PE, TL
7234 *it can be extended for WDI Global State as well.
7235 *And currently it only checks P2P_CLIENT adapter.
7236 *P2P_DEVICE and P2P_GO have not been added as of now.
7237*/
7238 case WE_GET_STATES:
7239 {
7240 int buf = 0, len = 0;
7241 int adapter_num = 0;
7242 int count = 0, check = 1;
7243
7244 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007245 tHalHandle hHal = NULL;
7246 tpAniSirGlobal pMac = NULL;
7247 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307248
7249 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7250 hdd_adapter_t *useAdapter = NULL;
7251
7252 /* Print wlan0 or p2p0 states based on the adapter_num
7253 *by using the correct adapter
7254 */
7255 while ( adapter_num < 2 )
7256 {
7257 if ( WLAN_ADAPTER == adapter_num )
7258 {
7259 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007260 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307261 "\n\n wlan0 States:-");
7262 len += buf;
7263 }
7264 else if ( P2P_ADAPTER == adapter_num )
7265 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007266 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307267 "\n\n p2p0 States:-");
7268 len += buf;
7269
7270 if( !pHddCtx )
7271 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007272 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307273 "\n pHddCtx is NULL");
7274 len += buf;
7275 break;
7276 }
7277
7278 /*Printing p2p0 states only in the case when the device is
7279 configured as a p2p_client*/
7280 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7281 if ( !useAdapter )
7282 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007283 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307284 "\n Device not configured as P2P_CLIENT.");
7285 len += buf;
7286 break;
7287 }
7288 }
7289
7290 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007291 if (!hHal) {
7292 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7293 "\n pMac is NULL");
7294 len += buf;
7295 break;
7296 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307297 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007298 if (!pMac) {
7299 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7300 "\n pMac is NULL");
7301 len += buf;
7302 break;
7303 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307304 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7305 if( !pHddStaCtx )
7306 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007307 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307308 "\n pHddStaCtx is NULL");
7309 len += buf;
7310 break;
7311 }
7312
7313 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7314
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007315 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307316 "\n HDD Conn State - %s "
7317 "\n \n SME State:"
7318 "\n Neighbour Roam State - %s"
7319 "\n CSR State - %s"
7320 "\n CSR Substate - %s"
7321 "\n \n TL STA %d State: %s",
7322 macTraceGetHDDWlanConnState(
7323 pHddStaCtx->conn_info.connState),
7324 macTraceGetNeighbourRoamState(
7325 pMac->roam.neighborRoamInfo.neighborRoamState),
7326 macTraceGetcsrRoamState(
7327 pMac->roam.curState[useAdapter->sessionId]),
7328 macTraceGetcsrRoamSubState(
7329 pMac->roam.curSubState[useAdapter->sessionId]),
7330 pHddStaCtx->conn_info.staId[0],
7331 macTraceGetTLState(tlState)
7332 );
7333 len += buf;
7334 adapter_num++;
7335 }
7336
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007337 if (pMac) {
7338 /* Printing Lim State starting with global lim states */
7339 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7340 "\n \n LIM STATES:-"
7341 "\n Global Sme State - %s "\
7342 "\n Global mlm State - %s "\
7343 "\n",
7344 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7345 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7346 );
7347 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307348
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007349 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307350 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307351 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007352 if ( pMac->lim.gpSession[count].valid )
7353 {
7354 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7355 "\n Lim Valid Session %d:-"
7356 "\n PE Sme State - %s "
7357 "\n PE Mlm State - %s "
7358 "\n",
7359 check,
7360 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7361 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7362 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307363
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007364 len += buf;
7365 check++;
7366 }
7367 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307368 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307369 }
7370
7371 wrqu->data.length = strlen(extra)+1;
7372 break;
7373 }
7374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 case WE_GET_CFG:
7376 {
7377 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7378 wrqu->data.length = strlen(extra)+1;
7379 break;
7380 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007381#ifdef WLAN_FEATURE_11AC
7382 case WE_GET_RSSI:
7383 {
7384 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307385 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007386 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7387 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7388 wrqu->data.length = strlen(extra)+1;
7389 break;
7390 }
7391#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307392
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007393#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007394 case WE_GET_ROAM_RSSI:
7395 {
7396 v_S7_t s7Rssi = 0;
7397 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7398 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7399 wrqu->data.length = strlen(extra)+1;
7400 break;
7401 }
7402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 case WE_GET_WMM_STATUS:
7404 {
7405 snprintf(extra, WE_MAX_STR_LEN,
7406 "\nDir: 0=up, 1=down, 3=both\n"
7407 "|------------------------|\n"
7408 "|AC | ACM |Admitted| Dir |\n"
7409 "|------------------------|\n"
7410 "|VO | %d | %3s | %d |\n"
7411 "|VI | %d | %3s | %d |\n"
7412 "|BE | %d | %3s | %d |\n"
7413 "|BK | %d | %3s | %d |\n"
7414 "|------------------------|\n",
7415 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7416 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7417 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7418 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7419 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7420 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7421 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7422 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7423 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7424 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7425 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7426 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7427
Jeff Johnsone7245742012-09-05 17:12:55 -07007428
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 wrqu->data.length = strlen(extra)+1;
7430 break;
7431 }
7432 case WE_GET_CHANNEL_LIST:
7433 {
7434 VOS_STATUS status;
7435 v_U8_t i, len;
7436 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307437 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7438 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7439 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 tChannelListInfo channel_list;
7441
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007442 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007443 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007444 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007446 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 return -EINVAL;
7448 }
7449 buf = extra;
7450
7451 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007452 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7453 * needed = 5 * number of channels. Check ifsufficient
7454 * buffer is available and then proceed to fill the buffer.
7455 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7457 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007458 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007459 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007460 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 return -EINVAL;
7462 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007463 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7464 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307465 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7466 {
7467 //Printing Country code in getChannelList
7468 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7469 {
7470 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7471 "%c ", pBuf[i]);
7472 }
7473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 for(i = 0 ; i < channel_list.num_channels; i++)
7475 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007476 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 }
7479 wrqu->data.length = strlen(extra)+1;
7480
7481 break;
7482 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007483#ifdef FEATURE_WLAN_TDLS
7484 case WE_GET_TDLS_PEERS:
7485 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007486 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007487 break;
7488 }
7489#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007490#ifdef WLAN_FEATURE_11W
7491 case WE_GET_11W_INFO:
7492 {
7493 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7494
7495 snprintf(extra, WE_MAX_STR_LEN,
7496 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7497 "\n Number of Unprotected Disassocs %d"
7498 "\n Number of Unprotected Deauths %d",
7499 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7500 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7501 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7502 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7503 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7504
7505 wrqu->data.length = strlen(extra)+1;
7506 break;
7507 }
7508#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307509#ifdef WLAN_FEATURE_RMC
7510 case WE_GET_IBSS_STA_INFO:
7511 {
7512 hdd_station_ctx_t *pHddStaCtx =
7513 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7514 int idx = 0;
7515 int length = 0, buf = 0;
7516
7517 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7518 {
7519 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7520 {
7521 buf = snprintf
7522 (
7523 (extra + length), WE_MAX_STR_LEN - length,
7524 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7525 pHddStaCtx->conn_info.staId[ idx ],
7526 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7527 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7528 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7529 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7530 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7531 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7532 );
7533 length += buf;
7534 }
7535 }
7536 wrqu->data.length = strlen(extra)+1;
7537 break;
7538 }
7539#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307540 case WE_GET_SNR:
7541 {
7542 v_S7_t s7snr = 0;
7543 int status = 0;
7544 hdd_context_t *pHddCtx;
7545 hdd_station_ctx_t *pHddStaCtx;
7546
7547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7548 status = wlan_hdd_validate_context(pHddCtx);
7549 if (0 != status)
7550 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307551 return status;
7552 }
7553
7554 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7555
7556 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7557 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7558 {
7559 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7560 " ConnectionState-%d", __func__,
7561 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7562 pHddStaCtx->conn_info.connState);
7563 return -ENONET;
7564 }
7565
7566 /*update the stats in TL*/
7567 wlan_hdd_get_station_stats(pAdapter);
7568 wlan_hdd_get_snr(pAdapter, &s7snr);
7569 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7570 wrqu->data.length = strlen(extra) + 1;
7571 break;
7572 }
7573
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307574#ifdef FEATURE_OEM_DATA_SUPPORT
7575 case WE_GET_OEM_DATA_CAP:
7576 {
7577 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7578 }
7579#endif /* FEATURE_OEM_DATA_SUPPORT */
7580
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307581 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007583 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 break;
7585 }
7586 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307587 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 return 0;
7589}
7590
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307591static int iw_get_char_setnone(struct net_device *dev,
7592 struct iw_request_info *info,
7593 union iwreq_data *wrqu, char *extra)
7594{
7595 int ret;
7596
7597 vos_ssr_protect(__func__);
7598 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7599 vos_ssr_unprotect(__func__);
7600
7601 return ret;
7602}
7603
Jeff Johnson295189b2012-06-20 16:38:30 -07007604/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307605static int __iw_setnone_getnone(struct net_device *dev,
7606 struct iw_request_info *info,
7607 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007608{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307609 hdd_adapter_t *pAdapter;
7610 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307611 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007612 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307613 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007614
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307615 ENTER();
7616
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307617 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7618 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007619 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7621 "%s: Adapter is NULL",__func__);
7622 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007623 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307624 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7625 ret = wlan_hdd_validate_context(pHddCtx);
7626 if (0 != ret)
7627 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307628 return ret;
7629 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307630 /* helper function to get iwreq_data with compat handling. */
7631 if (hdd_priv_get_data(&s_priv_data, wrqu))
7632 {
7633 return -EINVAL;
7634 }
7635
7636 sub_cmd = s_priv_data.flags;
7637
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 switch (sub_cmd)
7639 {
7640 case WE_CLEAR_STATS:
7641 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7644 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7645 break;
7646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 case WE_INIT_AP:
7648 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307649 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7650
7651 /* As Soft AP mode might been changed to STA already with
7652 * killing of Hostapd, need to find the adpater by name
7653 * rather than mode */
7654 hdd_adapter_t* pAdapter_to_stop =
7655 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7656 if( pAdapter_to_stop )
7657 {
7658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7659 "Adapter with name softap.0 already "
7660 "exist, ignoring the request.\nRemove the "
7661 "adapter and try again\n");
7662 break;
7663 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05307664
7665 if (wlan_hdd_check_monitor_state(pHddCtx)) {
7666 hddLog(LOGE, FL("initAP not allowed in STA + MON"));
7667 ret = -EOPNOTSUPP;
7668 break;
7669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 pr_info("Init AP trigger\n");
7671 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7672 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7673 break;
7674 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307675#ifdef WLAN_FEATURE_RMC
7676 case WE_IBSS_GET_PEER_INFO_ALL:
7677 {
7678 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7679 break;
7680 }
7681#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 case WE_STOP_AP:
7683 {
7684 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7685 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7686 * this is a dead code and need to find the adpater by name rather than mode */
7687 hdd_adapter_t* pAdapter_to_stop =
7688 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7689 if( pAdapter_to_stop )
7690 {
7691 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7692
7693 pr_info("Stopping AP mode\n");
7694
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307695 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7696 {
7697 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7698 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7699 }
7700
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307702 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307703 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7705
7706 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7707 pAdapter_to_stop->macAddressCurrent.bytes);
7708 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7709 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307710
7711 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7712 {
7713 /* put the device back into BMPS */
7714 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 }
7717 else
7718 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007719 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 }
7721
7722 break;
7723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007724#ifdef WLAN_BTAMP_FEATURE
7725 case WE_ENABLE_AMP:
7726 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 WLANBAP_RegisterWithHCI(pAdapter);
7729 break;
7730 }
7731 case WE_DISABLE_AMP:
7732 {
7733 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7734 VOS_STATUS status;
7735
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007737
7738 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7739 status = WLANBAP_StopAmp();
7740 if(VOS_STATUS_SUCCESS != status )
7741 {
7742 pHddCtx->isAmpAllowed = VOS_TRUE;
7743 hddLog(VOS_TRACE_LEVEL_FATAL,
7744 "%s: Failed to stop AMP", __func__);
7745 }
7746 else
7747 {
7748 //a state m/c implementation in PAL is TBD to avoid this delay
7749 msleep(500);
7750 pHddCtx->isAmpAllowed = VOS_FALSE;
7751 WLANBAP_DeregisterFromHCI();
7752 }
7753
7754 break;
7755 }
7756#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007757 case WE_ENABLE_DXE_STALL_DETECT:
7758 {
schang6295e542013-03-12 15:31:23 -07007759 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7760 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007761 break;
7762 }
7763 case WE_DISPLAY_DXE_SNAP_SHOT:
7764 {
schang6295e542013-03-12 15:31:23 -07007765 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7766 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007767 break;
7768 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307769 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7770 {
7771 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7772 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307773 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307774 break;
7775 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307776
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307777 case WE_SET_REASSOC_TRIGGER:
7778 {
7779 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7780 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7781 v_U32_t roamId = 0;
7782 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307783 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7784 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307785 return 0;
7786 }
7787
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307788 case WE_STOP_OBSS_SCAN:
7789 {
7790 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7791 2.OBSS scan is stopped by Firmware during the disassociation
7792 3.OBSS stop comamnd is added for debugging purpose*/
7793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7794 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007795
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307796 if (pAdapter == NULL)
7797 {
7798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7799 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307800 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307801 }
7802 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7803 if (pMac == NULL)
7804 {
7805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7806 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307807 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307808 }
7809 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7810 }
7811 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307812 case WE_DUMP_ROAM_TIMER_LOG:
7813 {
7814 vos_dump_roam_time_log_service();
7815 break;
7816 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307817
Mukul Sharma84f27252014-07-14 18:11:42 +05307818 case WE_RESET_ROAM_TIMER_LOG:
7819 {
7820 vos_reset_roam_timer_log();
7821 break;
7822 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307823 case WE_GET_FW_LOGS:
7824 {
7825 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7826 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307827 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307828 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307829 break;
7830 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307831 case WE_GET_FW_MEMDUMP:
7832 {
7833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7834 "FW_MEM_DUMP requested ");
7835 get_fwr_memdump(dev,info,wrqu,extra);
7836 break;
7837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 default:
7839 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007840 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 break;
7842 }
7843 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307844 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 return ret;
7846}
7847
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307848static int iw_setnone_getnone(struct net_device *dev,
7849 struct iw_request_info *info,
7850 union iwreq_data *wrqu, char *extra)
7851{
7852 int ret;
7853
7854 vos_ssr_protect(__func__);
7855 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7856 vos_ssr_unprotect(__func__);
7857
7858 return ret;
7859}
7860
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307861void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7862{
7863 /*
7864 * Function to display HDD WMM information
7865 * for Tx Queues.
7866 * Prints globala as well as per client depending
7867 * whether the clients are registered or not.
7868 */
7869 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307870 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7871 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307872 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7873 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307874 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307875
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307876 for ( i=0; i< NUM_TX_QUEUES; i++)
7877 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307878 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307879 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307880 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307881 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307882
7883 for ( i=0; i< NUM_TX_QUEUES; i++) {
7884 if (tx_queue_count[i]) {
7885 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7886 i, tx_queue_count[i]);
7887 }
7888 }
7889
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307890 if(pSapCtx == NULL){
7891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7892 FL("psapCtx is NULL"));
7893 return;
7894 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307895
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307896 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307897 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7898 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307899 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307900 {
7901 hddLog(LOGE, "******STAIndex: %d*********", i);
7902 for ( j=0; j< NUM_TX_QUEUES; j++)
7903 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307904 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7905 {
7906 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307907 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7908 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307909 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7910 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307911 }
7912 }
7913 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307914 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307915
Katya Nigam1fd24402015-02-16 14:52:19 +05307916 if(pHddStaCtx == NULL){
7917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7918 FL("pHddStaCtx is NULL"));
7919 return;
7920 }
7921
7922 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7923 if(pPeerInfo == NULL){
7924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7925 FL("ppeerinfo is NULL"));
7926 return;
7927 }
7928
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307929 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7930 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7931 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7932 for (j = 0; j < NUM_TX_QUEUES; j++) {
7933 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7934 spin_lock_bh(
7935 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7936 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07007937 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307938 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7939 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7940 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7941 spin_unlock_bh(
7942 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7943 }
7944 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307945 }
7946 }
7947
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307948}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307949
Girish Gowlifb9758e2014-11-19 15:19:17 +05307950static int __iw_set_var_ints_getnone(struct net_device *dev,
7951 struct iw_request_info *info,
7952 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007953{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307954 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307955 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307956 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307957 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007958 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307959 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307960 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007961 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307962 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007963 int cmd = 0;
7964 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307965 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007966
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307967 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307968 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307969 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7971 "%s: NULL extra buffer pointer", __func__);
7972 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307973 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307974 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7975 if (NULL == pAdapter)
7976 {
7977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7978 "%s: Adapter is NULL",__func__);
7979 return -EINVAL;
7980 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307981 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307982 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7983 ret = wlan_hdd_validate_context(pHddCtx);
7984 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007985 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307986 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007987 }
Katya Nigameae74b62015-05-28 17:19:16 +05307988 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307989 {
Katya Nigameae74b62015-05-28 17:19:16 +05307990 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7991 if (NULL == hHal)
7992 {
7993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7994 "%s: Hal Context is NULL",__func__);
7995 return -EINVAL;
7996 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307997 }
7998 sub_cmd = wrqu->data.flags;
7999
8000 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
8001
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008002
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008003 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
8004 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
8005 {
8006 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
8007 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
8008 {
8009 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8010 staId = pStaCtx->conn_info.staId[0];
8011 }
8012 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
8013 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
8014 {
8015 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8016 staId = pAPCtx->uBCStaId;
8017 }
8018 else
8019 {
8020 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
8021 return 0;
8022 }
8023 }
8024
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 switch (sub_cmd)
8026 {
8027 case WE_LOG_DUMP_CMD:
8028 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05308029 if(apps_args[0] == 26) {
8030 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
8031 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
8032 return 0;
8033 }
8034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008036 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308038 if (hHal)
8039 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
8040 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008041
8042 }
8043 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05308044#ifdef WLAN_FEATURE_RMC
8045 case WE_IBSS_GET_PEER_INFO:
8046 {
8047 pr_info ( "Station ID = %d\n",apps_args[0]);
8048 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
8049 }
8050 break;
8051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008052
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 case WE_P2P_NOA_CMD:
8054 {
8055 p2p_app_setP2pPs_t p2pNoA;
8056
Rajeev Kumara4c475d2015-11-27 13:41:24 +05308057 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
8058 hddLog(LOGE,
8059 FL("Setting NoA is not allowed in Device mode:%d"),
8060 pAdapter->device_mode);
8061 return -EINVAL;
8062 }
8063
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 p2pNoA.opp_ps = apps_args[0];
8065 p2pNoA.ctWindow = apps_args[1];
8066 p2pNoA.duration = apps_args[2];
8067 p2pNoA.interval = apps_args[3];
8068 p2pNoA.count = apps_args[4];
8069 p2pNoA.single_noa_duration = apps_args[5];
8070 p2pNoA.psSelection = apps_args[6];
8071
8072 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
8073 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008074 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
8076
8077 hdd_setP2pPs(dev, &p2pNoA);
8078
8079 }
8080 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008081
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308082 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8083 {
8084 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8085 __func__, apps_args[0], apps_args[1]);
8086 vosTraceEnable(apps_args[0], apps_args[1]);
8087 }
8088 break;
8089
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008090 case WE_MTRACE_DUMP_CMD:
8091 {
8092 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
8093 "bitmask_of_module %d ",
8094 __func__, apps_args[0], apps_args[1], apps_args[2],
8095 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308096 if (hHal)
8097 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
8098 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008099
8100 }
8101 break;
8102
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008103 case WE_MCC_CONFIG_CREDENTIAL :
8104 {
8105 cmd = 287; //Command should be updated if there is any change
8106 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08008107 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008108 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308109 if (hHal)
8110 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
8111 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008112 }
8113 else
8114 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008115 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008116 return 0;
8117 }
8118 }
8119 break;
8120
8121 case WE_MCC_CONFIG_PARAMS :
8122 {
8123 cmd = 288; //command Should be updated if there is any change
8124 // in the Riva dump command
8125 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
8126 }
8127 break;
8128
Chilam NG571c65a2013-01-19 12:27:36 +05308129#ifdef FEATURE_WLAN_TDLS
8130 case WE_TDLS_CONFIG_PARAMS :
8131 {
8132 tdls_config_params_t tdlsParams;
8133
Chilam Ng01120412013-02-19 18:32:21 -08008134 tdlsParams.tdls = apps_args[0];
8135 tdlsParams.tx_period_t = apps_args[1];
8136 tdlsParams.tx_packet_n = apps_args[2];
8137 tdlsParams.discovery_period_t = apps_args[3];
8138 tdlsParams.discovery_tries_n = apps_args[4];
8139 tdlsParams.idle_timeout_t = apps_args[5];
8140 tdlsParams.idle_packet_n = apps_args[6];
8141 tdlsParams.rssi_hysteresis = apps_args[7];
8142 tdlsParams.rssi_trigger_threshold = apps_args[8];
8143 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05308144
Chilam Ng01120412013-02-19 18:32:21 -08008145 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05308146 }
8147 break;
8148#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05308149 case WE_CONFIGURE_MONITOR_MODE:
8150 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308151 v_U32_t magic = 0;
8152 struct completion cmpVar;
8153 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308154 tVOS_CON_MODE mode = hdd_get_conparam();
8155
8156 if (VOS_MONITOR_MODE != mode) {
8157 hddLog(LOGE, FL("invalid mode %d"), mode);
8158 return -EIO;
8159 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308160
Katya Nigamf0511f62015-05-05 16:40:57 +05308161 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8162 if( pMonCtx == NULL )
8163 {
8164 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308165 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308166 }
8167 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
8168 __func__, apps_args[0], apps_args[1], apps_args[2],
8169 apps_args[3], apps_args[4]);
8170 /* Input Validation part of FW */
8171 pMonCtx->ChannelNo = apps_args[0];
8172 pMonCtx->ChannelBW = apps_args[1];
8173 pMonCtx->crcCheckEnabled = apps_args[2];
8174 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8175 pMonCtx->is80211to803ConReq = apps_args[4];
8176 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8177 if( pMonCtx->is80211to803ConReq )
8178 pAdapter->dev->type = ARPHRD_ETHER;
8179 else
8180 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8181 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8182 {
8183 hddLog(LOGE, "%s: Filtering data packets as management and control"
8184 " cannot be converted to 802.3 ",__func__);
8185 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8186 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308187 if (MON_MODE_START == pMonCtx->state) {
8188 magic = MON_MODE_MSG_MAGIC;
8189 init_completion(&cmpVar);
8190 if (VOS_STATUS_SUCCESS !=
8191 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8192 pMonCtx, hdd_monPostMsgCb)) {
8193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8194 FL("failed to post MON MODE REQ"));
8195 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308196 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308197 }
8198 waitRet = wait_for_completion_timeout(&cmpVar,
8199 MON_MODE_MSG_TIMEOUT);
8200 magic = 0;
8201 if (waitRet <= 0 ) {
8202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8203 FL("failed to wait on monitor mode completion %ld"),
8204 waitRet);
8205 }
8206 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308207 }
8208 break;
8209
8210 case WE_SET_MONITOR_MODE_FILTER:
8211 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308212 v_U32_t magic = 0;
8213 struct completion cmpVar;
8214 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308215 tVOS_CON_MODE mode = hdd_get_conparam();
8216
8217 if (VOS_MONITOR_MODE != mode) {
8218 hddLog(LOGE, FL("invalid mode %d"), mode);
8219 return -EIO;
8220 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308221
Katya Nigamf0511f62015-05-05 16:40:57 +05308222 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8223 if( pMonCtx == NULL )
8224 {
8225 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308226 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308227 }
8228 /* Input Validation Part of FW */
8229 pMonCtx->numOfMacFilters=1;
8230 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8231 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8232 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8233 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8234 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8235 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8236 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8237 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8238 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8239 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8240 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8241 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308242 if (MON_MODE_START == pMonCtx->state) {
8243 magic = MON_MODE_MSG_MAGIC;
8244 init_completion(&cmpVar);
8245 if (VOS_STATUS_SUCCESS !=
8246 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8247 pMonCtx, hdd_monPostMsgCb)) {
8248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8249 FL("failed to post MON MODE REQ"));
8250 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308251 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308252 }
8253 waitRet = wait_for_completion_timeout(&cmpVar,
8254 MON_MODE_MSG_TIMEOUT);
8255 magic = 0;
8256 if (waitRet <= 0 ) {
8257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8258 FL("failed to wait on monitor mode completion %ld"),
8259 waitRet);
8260 }
8261 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308262 }
8263 break;
8264
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 default:
8266 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008267 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8268 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 }
8270 break;
8271 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308272 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 return 0;
8274}
8275
Girish Gowlifb9758e2014-11-19 15:19:17 +05308276static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8277 struct iw_request_info *info,
8278 union iwreq_data *wrqu, char *extra)
8279{
8280 int ret;
8281 union iwreq_data u_priv_wrqu;
8282 int apps_args[MAX_VAR_ARGS] = {0};
8283 int num_args;
8284
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308285 if (!capable(CAP_NET_ADMIN))
8286 {
8287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8288 FL("permission check failed"));
8289 return -EPERM;
8290 }
8291
Girish Gowlifb9758e2014-11-19 15:19:17 +05308292 /* helper function to get iwreq_data with compat handling. */
8293 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8294 {
8295 return -EINVAL;
8296 }
8297
8298 if (NULL == u_priv_wrqu.data.pointer)
8299 {
8300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8301 "%s: NULL data pointer", __func__);
8302 return -EINVAL;
8303 }
8304
8305 num_args = u_priv_wrqu.data.length;
8306 if (num_args > MAX_VAR_ARGS)
8307 {
8308 num_args = MAX_VAR_ARGS;
8309 }
8310
8311 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8312 (sizeof(int)) * num_args))
8313 {
8314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8315 "%s: failed to copy data from user buffer", __func__);
8316 return -EFAULT;
8317 }
8318
8319 vos_ssr_protect(__func__);
8320 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8321 (char *)&apps_args);
8322 vos_ssr_unprotect(__func__);
8323
8324 return ret;
8325}
8326
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308327int iw_set_var_ints_getnone(struct net_device *dev,
8328 struct iw_request_info *info,
8329 union iwreq_data *wrqu, char *extra)
8330{
8331 int ret;
8332 vos_ssr_protect(__func__);
8333 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8334 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008335
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308336 return ret;
8337}
8338
8339static int __iw_add_tspec(struct net_device *dev,
8340 struct iw_request_info *info,
8341 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008342{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308343 hdd_adapter_t *pAdapter;
8344 hdd_station_ctx_t *pHddStaCtx;
8345 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8347 int params[HDD_WLAN_WMM_PARAM_COUNT];
8348 sme_QosWmmTspecInfo tSpec;
8349 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308350 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308351 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308353 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308354 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8355 if (NULL == pAdapter)
8356 {
8357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8358 "%s: Adapter is NULL",__func__);
8359 return -EINVAL;
8360 }
8361 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8362 ret = wlan_hdd_validate_context(pHddCtx);
8363 if (0 != ret)
8364 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308365 return ret;
8366 }
8367 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8368 if (NULL == pHddStaCtx)
8369 {
8370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8371 "%s: STA Context is NULL",__func__);
8372 return -EINVAL;
8373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 // make sure the application is sufficiently priviledged
8375 // note that the kernel will do this for "set" ioctls, but since
8376 // this ioctl wants to return status to user space it must be
8377 // defined as a "get" ioctl
8378 if (!capable(CAP_NET_ADMIN))
8379 {
8380 return -EPERM;
8381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 // we must be associated in order to add a tspec
8383 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8384 {
8385 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8386 return 0;
8387 }
8388
8389 // since we are defined to be a "get" ioctl, and since the number
8390 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308391 // will pass down in the iwreq_data, we must copy the "set" params.
8392 // We must handle the compat for iwreq_data in 32U/64K environment.
8393
8394 // helper fucntion to get iwreq_data with compat handling.
8395 if (hdd_priv_get_data(&s_priv_data, wrqu))
8396 {
8397 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8398 return 0;
8399 }
8400
8401 // make sure all params are correctly passed to function
8402 if ((NULL == s_priv_data.pointer) ||
8403 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8404 {
8405 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8406 return 0;
8407 }
8408
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308410 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 {
8412 // hmmm, can't get them
8413 return -EIO;
8414 }
8415
8416 // clear the tspec
8417 memset(&tSpec, 0, sizeof(tSpec));
8418
8419 // validate the handle
8420 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8421 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8422 {
8423 // that one is reserved
8424 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8425 return 0;
8426 }
8427
8428 // validate the TID
8429 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8430 {
8431 // out of range
8432 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8433 return 0;
8434 }
8435 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8436
8437 // validate the direction
8438 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8439 {
8440 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8441 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8442 break;
8443
8444 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8445 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8446 break;
8447
8448 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8449 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8450 break;
8451
8452 default:
8453 // unknown
8454 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8455 return 0;
8456 }
8457
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308458 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8459
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 // validate the user priority
8461 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8462 {
8463 // out of range
8464 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8465 return 0;
8466 }
8467 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308468 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8469 {
8470 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8471 return 0;
8472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008473
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8475 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8476 tSpec.ts_info.psb, tSpec.ts_info.up);
8477
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8479 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8480 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8481 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8482 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8483 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8484 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8485 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8486 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8487 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8488 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8489 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8490
8491 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8492
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308493 // Save the expected UAPSD settings by application, this will be needed
8494 // when re-negotiating UAPSD settings during BT Coex cases.
8495 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8496
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 // validate the ts info ack policy
8498 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8499 {
8500 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8501 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8502 break;
8503
8504 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8505 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8506 break;
8507
8508 default:
8509 // unknown
8510 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8511 return 0;
8512 }
8513
8514 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308515
8516 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 return 0;
8518}
8519
8520
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308521static int iw_add_tspec(struct net_device *dev,
8522 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 union iwreq_data *wrqu, char *extra)
8524{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308525 int ret;
8526
8527 vos_ssr_protect(__func__);
8528 ret = __iw_add_tspec(dev, info, wrqu, extra);
8529 vos_ssr_unprotect(__func__);
8530
8531 return ret;
8532}
8533
8534static int __iw_del_tspec(struct net_device *dev,
8535 struct iw_request_info *info,
8536 union iwreq_data *wrqu, char *extra)
8537{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308538 hdd_adapter_t *pAdapter;
8539 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 int *params = (int *)extra;
8541 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8542 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308543 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008544
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308545 ENTER();
8546
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308547 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8548 if (NULL == pAdapter)
8549 {
8550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8551 "%s: Adapter is NULL",__func__);
8552 return -EINVAL;
8553 }
8554
8555 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8556 ret = wlan_hdd_validate_context(pHddCtx);
8557 if (0 != ret)
8558 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308559 return ret;
8560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008561 // make sure the application is sufficiently priviledged
8562 // note that the kernel will do this for "set" ioctls, but since
8563 // this ioctl wants to return status to user space it must be
8564 // defined as a "get" ioctl
8565 if (!capable(CAP_NET_ADMIN))
8566 {
8567 return -EPERM;
8568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 // although we are defined to be a "get" ioctl, the params we require
8570 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8571 // is no need to copy the params from user space
8572
8573 // validate the handle
8574 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8575 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8576 {
8577 // that one is reserved
8578 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8579 return 0;
8580 }
8581
8582 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308583
8584 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 return 0;
8586}
8587
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308588static int iw_del_tspec(struct net_device *dev,
8589 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 union iwreq_data *wrqu, char *extra)
8591{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308592 int ret;
8593
8594 vos_ssr_protect(__func__);
8595 ret = __iw_del_tspec(dev, info, wrqu, extra);
8596 vos_ssr_unprotect(__func__);
8597
8598 return ret;
8599}
8600
8601
8602static int __iw_get_tspec(struct net_device *dev,
8603 struct iw_request_info *info,
8604 union iwreq_data *wrqu, char *extra)
8605{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308606 hdd_adapter_t *pAdapter;
8607 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008608 int *params = (int *)extra;
8609 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8610 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308611 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008612
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308613 ENTER();
8614
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 // although we are defined to be a "get" ioctl, the params we require
8616 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8617 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308618 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8619 if (NULL == pAdapter)
8620 {
8621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8622 "%s: Adapter is NULL",__func__);
8623 return -EINVAL;
8624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008625
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8627 ret = wlan_hdd_validate_context(pHddCtx);
8628 if (0 != ret)
8629 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308630 return ret;
8631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 // validate the handle
8633 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8634 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8635 {
8636 // that one is reserved
8637 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8638 return 0;
8639 }
8640
8641 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308642 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 return 0;
8644}
8645
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308646static int iw_get_tspec(struct net_device *dev,
8647 struct iw_request_info *info,
8648 union iwreq_data *wrqu, char *extra)
8649{
8650 int ret;
8651
8652 vos_ssr_protect(__func__);
8653 ret = __iw_get_tspec(dev, info, wrqu, extra);
8654 vos_ssr_unprotect(__func__);
8655
8656 return ret;
8657}
8658
Manjeet Singh3ed79242017-01-11 19:04:32 +05308659/**
8660 * __iw_setnone_get_threeint() - return three value to up layer.
8661 *
8662 * @dev: pointer of net_device of this wireless card
8663 * @info: meta data about Request sent
8664 * @wrqu: include request info
8665 * @extra: buf used for in/Output
8666 *
8667 * Return: execute result
8668 */
8669static int __iw_setnone_get_threeint(struct net_device *dev,
8670 struct iw_request_info *info,
8671 union iwreq_data *wrqu, char *extra)
8672{
8673 int ret = 0; /* success */
8674 uint32_t *value = (int *)extra;
8675 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8676
8677 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8678
8679 switch (value[0]) {
8680 case WE_GET_TSF:
8681 ret = hdd_indicate_tsf(adapter, value, 3);
8682 break;
8683 default:
8684 hddLog(VOS_TRACE_LEVEL_ERROR,
8685 FL("Invalid IOCTL get_value command %d"),
8686 value[0]);
8687 break;
8688 }
8689 return ret;
8690}
8691
8692/**
8693 * iw_setnone_get_threeint() - return three value to up layer.
8694 *
8695 * @dev: pointer of net_device of this wireless card
8696 * @info: meta data about Request sent
8697 * @wrqu: include request info
8698 * @extra: buf used for in/Output
8699 *
8700 * Return: execute result
8701 */
8702static int iw_setnone_get_threeint(struct net_device *dev,
8703 struct iw_request_info *info,
8704 union iwreq_data *wrqu, char *extra)
8705{
8706 int ret;
8707
8708 vos_ssr_protect(__func__);
8709 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8710 vos_ssr_unprotect(__func__);
8711
8712 return ret;
8713}
8714
Jeff Johnson295189b2012-06-20 16:38:30 -07008715#ifdef WLAN_FEATURE_VOWIFI_11R
8716//
8717//
8718// Each time the supplicant has the auth_request or reassoc request
8719// IEs ready. This is pushed to the driver. The driver will inturn use
8720// it to send out the auth req and reassoc req for 11r FT Assoc.
8721//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308722static int __iw_set_fties(struct net_device *dev,
8723 struct iw_request_info *info,
8724 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008725{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308726 hdd_adapter_t *pAdapter;
8727 hdd_station_ctx_t *pHddStaCtx;
8728 hdd_context_t *pHddCtx;
8729 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 //v_CONTEXT_t pVosContext;
8731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308732 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308733 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8734 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008735 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8737 "%s: Adapter is NULL",__func__);
8738 return -EINVAL;
8739 }
8740 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8741 ret = wlan_hdd_validate_context(pHddCtx);
8742 if (0 != ret)
8743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308744 return ret;
8745 }
8746 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8747 if (NULL == pHddStaCtx)
8748 {
8749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8750 "%s: STA Context is NULL",__func__);
8751 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 if (!wrqu->data.length)
8754 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008755 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 return -EINVAL;
8757 }
8758 if (wrqu->data.pointer == NULL)
8759 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008760 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 return -EINVAL;
8762 }
8763
8764 // Added for debug on reception of Re-assoc Req.
8765 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8766 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008767 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008769 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 }
8771
8772#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008773 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008774#endif
8775
8776 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008777 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 wrqu->data.length);
8779
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308780 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 return 0;
8782}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308783
8784static int iw_set_fties(struct net_device *dev,
8785 struct iw_request_info *info,
8786 union iwreq_data *wrqu, char *extra)
8787{
8788 int ret;
8789
8790 vos_ssr_protect(__func__);
8791 ret = __iw_set_fties(dev, info, wrqu, extra);
8792 vos_ssr_unprotect(__func__);
8793
8794 return ret;
8795}
Jeff Johnson295189b2012-06-20 16:38:30 -07008796#endif
8797
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308798static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008799 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008801{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308802 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008803 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308804 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008805 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308806 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008807 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8808 int idx;
8809 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008810
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308811 ENTER();
8812
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308813 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8814 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008815 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8817 "%s: Adapter is NULL",__func__);
8818 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008819 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308820 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8821 ret_val = wlan_hdd_validate_context(pHddCtx);
8822 if (0 != ret_val)
8823 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308824 return ret_val;
8825 }
8826 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8827 if (NULL == hHal)
8828 {
8829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8830 "%s: Hal Context is NULL",__func__);
8831 return -EINVAL;
8832 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308833 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8834 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308835#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008836
Amar Singhalf3a6e762013-02-19 15:06:50 -08008837 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8838 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008839 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008840 hddLog(VOS_TRACE_LEVEL_ERROR,
8841 "%s: vos_mem_alloc failed", __func__);
8842 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008843 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008844
8845 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8846
8847 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8848 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8849
8850 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8851 mc_addr_list_ptr->ulMulticastAddrCnt);
8852
8853 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008854 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008855 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8856 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8857
8858 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8859 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008860 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008861
Amar Singhalf3a6e762013-02-19 15:06:50 -08008862 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8863 vos_mem_free(mc_addr_list_ptr);
8864 if (eHAL_STATUS_SUCCESS != ret_val)
8865 {
8866 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8867 __func__);
8868 return -EINVAL;
8869 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308870#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308871 }
8872 else
8873 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008874
Amar Singhalf3a6e762013-02-19 15:06:50 -08008875 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8876 "%s: Set MC BC Filter Config request: %d suspend %d",
8877 __func__, pRequest->mcastBcastFilterSetting,
8878 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308879 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308880 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308881 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008882
8883 if (pHddCtx->hdd_wlan_suspended)
8884 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008885 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8886 if (NULL == wlanRxpFilterParam)
8887 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308888 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008889 "%s: vos_mem_alloc failed", __func__);
8890 return -EINVAL;
8891 }
8892
Amar Singhalf3a6e762013-02-19 15:06:50 -08008893 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8894 pRequest->mcastBcastFilterSetting;
8895 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308896 /* Fwr expect offload needs to clear before set */
8897 hdd_conf_hostoffload(pAdapter, FALSE);
8898 spin_lock(&pHddCtx->filter_lock);
8899 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8900 spin_unlock(&pHddCtx->filter_lock);
8901 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8902 {
8903 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8904 pHddCtx->sus_res_mcastbcast_filter =
8905 pRequest->mcastBcastFilterSetting;
8906 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008907
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308908 hdd_conf_hostoffload(pAdapter, TRUE);
8909 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8910 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008911
8912 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8913 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308914 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008915 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8916 wlanRxpFilterParam->setMcstBcstFilter);
8917
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308918 if (eHAL_STATUS_SUCCESS !=
8919 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8920 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008921 {
8922 hddLog(VOS_TRACE_LEVEL_ERROR,
8923 "%s: Failure to execute set HW MC/BC Filter request",
8924 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008925 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008926 return -EINVAL;
8927 }
8928
mukul sharmae4abd892016-11-24 22:03:31 +05308929 /* mc add list cfg item configuration in fwr */
8930 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008931 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008933
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308934 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 return 0;
8936}
8937
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308938static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8939 struct iw_request_info *info,
8940 union iwreq_data *wrqu, char *extra)
8941{
8942 int ret;
8943
8944 vos_ssr_protect(__func__);
8945 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8946 vos_ssr_unprotect(__func__);
8947
8948 return ret;
8949}
8950
8951static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8952 struct iw_request_info *info,
8953 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008954{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308955 hdd_adapter_t *pAdapter;
8956 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308957 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308958 int ret = 0;
8959
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308960 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008961
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308962 if (!capable(CAP_NET_ADMIN))
8963 {
8964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8965 FL("permission check failed"));
8966 return -EPERM;
8967 }
8968
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308969 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8970 if (NULL == pAdapter)
8971 {
8972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8973 "%s: Adapter is NULL",__func__);
8974 return -EINVAL;
8975 }
8976
8977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8978 ret = wlan_hdd_validate_context(pHddCtx);
8979 if (0 != ret)
8980 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308981 return ret;
8982 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308983 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308984 //Reset the filter to INI value as we have to clear the dynamic filter
8985 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308986 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008987
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308988 //Configure FW with new setting
8989 if (pHddCtx->hdd_wlan_suspended)
8990 {
8991 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8992 if (NULL == wlanRxpFilterParam)
8993 {
8994 hddLog(VOS_TRACE_LEVEL_ERROR,
8995 "%s: vos_mem_alloc failed", __func__);
8996 return -EINVAL;
8997 }
8998
8999 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9000 pHddCtx->configuredMcastBcastFilter;
9001 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309002 /* Fwr expect offload needs to clear before set */
9003 hdd_conf_hostoffload(pAdapter, FALSE);
9004 spin_lock(&pHddCtx->filter_lock);
9005 pHddCtx->configuredMcastBcastFilter =
9006 pHddCtx->cfg_ini->mcastBcastFilterSetting;
9007 spin_unlock(&pHddCtx->filter_lock);
9008
9009 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
9010 {
9011 pHddCtx->sus_res_mcastbcast_filter =
9012 pHddCtx->cfg_ini->mcastBcastFilterSetting;
9013 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309014
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05309015 hdd_conf_hostoffload(pAdapter, TRUE);
9016 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9017 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309018 if (eHAL_STATUS_SUCCESS !=
9019 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
9020 wlanRxpFilterParam))
9021 {
9022 hddLog(VOS_TRACE_LEVEL_ERROR,
9023 "%s: Failure to execute set HW MC/BC Filter request",
9024 __func__);
9025 vos_mem_free(wlanRxpFilterParam);
9026 return -EINVAL;
9027 }
c_hpothud3ce76d2014-10-28 10:34:13 +05309028
mukul sharmae4abd892016-11-24 22:03:31 +05309029 /* mc add list cfg item configuration in fwr */
9030 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309031 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309032 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009033 return 0;
9034}
9035
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309036
9037static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
9038 struct iw_request_info *info,
9039 union iwreq_data *wrqu, char *extra)
9040{
9041 int ret;
9042
9043 vos_ssr_protect(__func__);
9044 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
9045 vos_ssr_unprotect(__func__);
9046
9047 return ret;
9048}
9049
9050static int __iw_set_host_offload(struct net_device *dev,
9051 struct iw_request_info *info,
9052 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009053{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309054 hdd_adapter_t *pAdapter;
9055 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009056 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309058 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009059
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309060 ENTER();
9061
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309062 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9063 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009064 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9066 "%s: Adapter is NULL",__func__);
9067 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009068 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309069 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9070 ret = wlan_hdd_validate_context(pHddCtx);
9071 if (0 != ret)
9072 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309073 return ret;
9074 }
9075
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 /* Debug display of request components. */
9077 switch (pRequest->offloadType)
9078 {
9079 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009080 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 switch (pRequest->enableOrDisable)
9082 {
9083 case WLAN_OFFLOAD_DISABLE:
9084 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
9085 break;
9086 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
9087 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
9088 case WLAN_OFFLOAD_ENABLE:
9089 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
9090 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
9091 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
9092 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
9093 }
9094 break;
9095
9096 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08009097 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009098 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009099 switch (pRequest->enableOrDisable)
9100 {
9101 case WLAN_OFFLOAD_DISABLE:
9102 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
9103 break;
9104 case WLAN_OFFLOAD_ENABLE:
9105 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
9106 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
9107 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
9108 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
9109 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
9110 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
9111 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
9112 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
9113 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
9114 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
9115 }
9116 }
9117
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05309118 vos_mem_zero(&offloadRequest, sizeof(offloadRequest));
9119 offloadRequest.offloadType = pRequest->offloadType;
9120 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
9121 vos_mem_copy(&offloadRequest.params, &pRequest->params,
9122 sizeof(pRequest->params));
9123 vos_mem_copy(&offloadRequest.bssId, &pRequest->bssId.bytes,
9124 VOS_MAC_ADDRESS_LEN);
9125
Jeff Johnsone7245742012-09-05 17:12:55 -07009126 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9127 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009129 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 __func__);
9131 return -EINVAL;
9132 }
9133
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309134 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 return 0;
9136}
9137
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309138static int iw_set_host_offload(struct net_device *dev,
9139 struct iw_request_info *info,
9140 union iwreq_data *wrqu, char *extra)
9141{
9142 int ret;
9143
9144 vos_ssr_protect(__func__);
9145 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9146 vos_ssr_unprotect(__func__);
9147
9148 return ret;
9149}
9150
9151static int __iw_set_keepalive_params(struct net_device *dev,
9152 struct iw_request_info *info,
9153 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009154{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309155 hdd_adapter_t *pAdapter;
9156 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009157 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309159 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309161 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309162 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9163 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9166 "%s: Adapter is NULL",__func__);
9167 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9170 ret = wlan_hdd_validate_context(pHddCtx);
9171 if (0 != ret)
9172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309173 return ret;
9174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009176 hddLog(VOS_TRACE_LEVEL_INFO,
9177 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9178 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009179
9180 switch (pRequest->packetType)
9181 {
9182 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009183 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 break;
9185
9186 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9187
Arif Hussain6d2a3322013-11-17 19:50:10 -08009188 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009189 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009190
9191 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9192 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9193 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9194
9195 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9196 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9197 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9198
9199 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9200 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9201 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9202 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9203 break;
9204
9205 }
9206
9207 /* Execute keep alive request. The reason that we can copy the request information
9208 from the ioctl structure to the SME structure is that they are laid out
9209 exactly the same. Otherwise, each piece of information would have to be
9210 copied individually. */
9211 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9212
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309213 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9214 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009215
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009216 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009217 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 __func__);
9221 return -EINVAL;
9222 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309223 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 return 0;
9225}
9226
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309227static int iw_set_keepalive_params(struct net_device *dev,
9228 struct iw_request_info *info,
9229 union iwreq_data *wrqu, char *extra)
9230{
9231 int ret;
9232 vos_ssr_protect(__func__);
9233 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9234 vos_ssr_unprotect(__func__);
9235
9236 return ret;
9237}
9238
Jeff Johnson295189b2012-06-20 16:38:30 -07009239#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309240/**-----------------------------------------------------------------
9241
9242 \brief hdd_pkt_filter_done - callback to be executed on completion
9243 successful/failure) for clear filter request.
9244
9245 \return - None
9246
9247 --------------------------------------------------------------------------*/
9248static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009249{
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309250 struct hdd_request *request;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309251
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309252 hddLog(VOS_TRACE_LEVEL_INFO,
9253 FL("Pkt Filter Clear Status : %d"), status);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309254
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309255 request = hdd_request_get(data);
9256 if (!request) {
9257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
9258 if (ioctl_debug)
9259 pr_info("%s: Obsolete request", __func__);
9260 return;
9261 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309262
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309263 hdd_request_complete(request);
9264 hdd_request_put(request);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309265}
9266
9267int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9268{
9269 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309270 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009271 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9272 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309273 int i=0, status;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309274 void *cookie;
9275 struct hdd_request *request;
9276 static const struct hdd_request_params params = {
9277 .priv_size = 0,
9278 .timeout_ms = PKT_FILTER_TIMEOUT,
9279 };
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309280
9281 status = wlan_hdd_validate_context(pHddCtx);
9282 if (0 != status)
9283 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284
9285 if (pHddCtx->cfg_ini->disablePacketFilter)
9286 {
9287 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009288 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 return 0;
9290 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309291 if (pHddCtx->isLogpInProgress)
9292 {
9293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9294 "%s:LOGP in Progress. Ignore!!!", __func__);
9295 return -EBUSY;
9296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 /* Debug display of request components. */
9298 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009299 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009300
9301 switch (pRequest->filterAction)
9302 {
9303 case HDD_RCV_FILTER_SET:
9304 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009305 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009306
9307 packetFilterSetReq.filterId = pRequest->filterId;
9308 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9309 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 __func__, pRequest->numParams);
9312 return -EINVAL;
9313 }
9314 packetFilterSetReq.numFieldParams = pRequest->numParams;
9315 packetFilterSetReq.coalesceTime = 0;
9316 packetFilterSetReq.filterType = 1;
9317 for (i=0; i < pRequest->numParams; i++)
9318 {
9319 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9320 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9321 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9322 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9323 packetFilterSetReq.paramsData[i].reserved = 0;
9324
Arif Hussain6d2a3322013-11-17 19:50:10 -08009325 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9327 packetFilterSetReq.filterType);
9328
Arif Hussain6d2a3322013-11-17 19:50:10 -08009329 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309331 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9332 (pRequest->paramsData[i].dataLength))
9333 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009334
9335 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9336 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9337 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9338 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9339
Arif Hussain6d2a3322013-11-17 19:50:10 -08009340 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9342 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9343 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9344
Arif Hussain6d2a3322013-11-17 19:50:10 -08009345 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9347 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9348 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9349 }
9350
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309351 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009353 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 __func__);
9355 return -EINVAL;
9356 }
9357
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309358 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9359 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 break;
9361
9362 case HDD_RCV_FILTER_CLEAR:
9363
Arif Hussain6d2a3322013-11-17 19:50:10 -08009364 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009365 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309366
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309367 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9368 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9369 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9370 pHddStaCtx->conn_info.staId[0]);
9371 }
9372
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309373 request = hdd_request_alloc(&params);
9374 if (!request) {
9375 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
9376 return VOS_STATUS_E_NOMEM;
9377 }
9378 cookie = hdd_request_cookie(request);
9379
9380 packetFilterClrReq.cbCtx = cookie;
Jeff Johnson295189b2012-06-20 16:38:30 -07009381 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309382 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309383 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(
9384 pHddCtx->hHal,
9385 &packetFilterClrReq,
9386 pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009388 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 __func__);
9390 return -EINVAL;
9391 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309392
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309393 status = hdd_request_wait_for_response(request);
9394 hdd_request_put(request);
9395 if (status)
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309396 {
9397 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9398 status);
9399 return -EINVAL;
9400 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309401
9402 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9403 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 break;
9405
9406 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009407 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009408 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 return -EINVAL;
9410 }
9411 return 0;
9412}
9413
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309414int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9415 tANI_U8 sessionId)
9416{
9417 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9418 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9419
9420 if (NULL == pHddCtx)
9421 {
9422 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9423 return -EINVAL;
9424 }
9425
9426 if (pHddCtx->isLogpInProgress)
9427 {
9428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9429 "%s:LOGP in Progress. Ignore!!!", __func__);
9430 return -EBUSY;
9431 }
9432
9433 if (pHddCtx->cfg_ini->disablePacketFilter)
9434 {
9435 hddLog(VOS_TRACE_LEVEL_ERROR,
9436 "%s: Packet Filtering Disabled. Returning ",
9437 __func__ );
9438 return -EINVAL;
9439 }
9440
9441 switch (filterType)
9442 {
9443 /* For setting IPV6 MC and UC Filter we need to configure
9444 * 2 filters, one for MC and one for UC.
9445 * The Filter ID shouldn't be swapped, which results in making
9446 * UC Filter ineffective.
9447 * We have Hardcode all the values
9448 *
9449 * Reason for a seperate UC filter is because, driver need to
9450 * specify the FW that the specific filter is for unicast
9451 * otherwise FW will not pass the unicast frames by default
9452 * through the filter. This is required to avoid any performance
9453 * hits when no unicast filter is set and only MC/BC are set.
9454 * The way driver informs host is by using the MAC protocol
9455 * layer, CMP flag set to MAX, CMP Data set to 1.
9456 */
9457
9458 case HDD_FILTER_IPV6_MC_UC:
9459 /* Setting IPV6 MC Filter below
9460 */
9461 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9462 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9463 packetFilterSetReq.numFieldParams = 2;
9464 packetFilterSetReq.paramsData[0].protocolLayer =
9465 HDD_FILTER_PROTO_TYPE_MAC;
9466 packetFilterSetReq.paramsData[0].cmpFlag =
9467 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9468 packetFilterSetReq.paramsData[0].dataOffset =
9469 WLAN_HDD_80211_FRM_DA_OFFSET;
9470 packetFilterSetReq.paramsData[0].dataLength = 1;
9471 packetFilterSetReq.paramsData[0].compareData[0] =
9472 HDD_IPV6_MC_CMP_DATA;
9473
9474 packetFilterSetReq.paramsData[1].protocolLayer =
9475 HDD_FILTER_PROTO_TYPE_ARP;
9476 packetFilterSetReq.paramsData[1].cmpFlag =
9477 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9478 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9479 packetFilterSetReq.paramsData[1].dataLength = 2;
9480 packetFilterSetReq.paramsData[1].compareData[0] =
9481 HDD_IPV6_CMP_DATA_0;
9482 packetFilterSetReq.paramsData[1].compareData[1] =
9483 HDD_IPV6_CMP_DATA_1;
9484
9485
9486 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9487 &packetFilterSetReq, sessionId))
9488 {
9489 hddLog(VOS_TRACE_LEVEL_ERROR,
9490 "%s: Failure to execute Set IPv6 Mulicast Filter",
9491 __func__);
9492 return -EINVAL;
9493 }
9494
9495 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9496
9497 /*
9498 * Setting IPV6 UC Filter below
9499 */
9500 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9501 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9502 packetFilterSetReq.numFieldParams = 2;
9503 packetFilterSetReq.paramsData[0].protocolLayer =
9504 HDD_FILTER_PROTO_TYPE_MAC;
9505 packetFilterSetReq.paramsData[0].cmpFlag =
9506 HDD_FILTER_CMP_TYPE_MAX;
9507 packetFilterSetReq.paramsData[0].dataOffset = 0;
9508 packetFilterSetReq.paramsData[0].dataLength = 1;
9509 packetFilterSetReq.paramsData[0].compareData[0] =
9510 HDD_IPV6_UC_CMP_DATA;
9511
9512 packetFilterSetReq.paramsData[1].protocolLayer =
9513 HDD_FILTER_PROTO_TYPE_ARP;
9514 packetFilterSetReq.paramsData[1].cmpFlag =
9515 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9516 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9517 packetFilterSetReq.paramsData[1].dataLength = 2;
9518 packetFilterSetReq.paramsData[1].compareData[0] =
9519 HDD_IPV6_CMP_DATA_0;
9520 packetFilterSetReq.paramsData[1].compareData[1] =
9521 HDD_IPV6_CMP_DATA_1;
9522
9523 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9524 &packetFilterSetReq, sessionId))
9525 {
9526 hddLog(VOS_TRACE_LEVEL_ERROR,
9527 "%s: Failure to execute Set IPv6 Unicast Filter",
9528 __func__);
9529 return -EINVAL;
9530 }
9531
9532 break;
9533
9534 case HDD_FILTER_IPV6_MC:
9535 /*
9536 * IPV6 UC Filter might be already set,
9537 * clear the UC Filter. As the Filter
9538 * IDs are static, we can directly clear it.
9539 */
9540 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9541 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9542 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9543 &packetFilterClrReq, sessionId))
9544 {
9545 hddLog(VOS_TRACE_LEVEL_ERROR,
9546 "%s: Failure to execute Clear IPv6 Unicast Filter",
9547 __func__);
9548 return -EINVAL;
9549 }
9550
9551 /*
9552 * Setting IPV6 MC Filter below
9553 */
9554 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9555 packetFilterSetReq.numFieldParams = 2;
9556 packetFilterSetReq.paramsData[0].protocolLayer =
9557 HDD_FILTER_PROTO_TYPE_MAC;
9558 packetFilterSetReq.paramsData[0].cmpFlag =
9559 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9560 packetFilterSetReq.paramsData[0].dataOffset =
9561 WLAN_HDD_80211_FRM_DA_OFFSET;
9562 packetFilterSetReq.paramsData[0].dataLength = 1;
9563 packetFilterSetReq.paramsData[0].compareData[0] =
9564 HDD_IPV6_MC_CMP_DATA;
9565
9566 packetFilterSetReq.paramsData[1].protocolLayer =
9567 HDD_FILTER_PROTO_TYPE_ARP;
9568 packetFilterSetReq.paramsData[1].cmpFlag =
9569 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9570 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9571 packetFilterSetReq.paramsData[1].dataLength = 2;
9572 packetFilterSetReq.paramsData[1].compareData[0] =
9573 HDD_IPV6_CMP_DATA_0;
9574 packetFilterSetReq.paramsData[1].compareData[1] =
9575 HDD_IPV6_CMP_DATA_1;
9576
9577
9578 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9579 &packetFilterSetReq, sessionId))
9580 {
9581 hddLog(VOS_TRACE_LEVEL_ERROR,
9582 "%s: Failure to execute Set IPv6 Multicast Filter",
9583 __func__);
9584 return -EINVAL;
9585 }
9586 break;
9587
9588 default :
9589 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9590 "%s: Packet Filter Request: Invalid",
9591 __func__);
9592 return -EINVAL;
9593 }
9594 return 0;
9595}
9596
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309597void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009598{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309599 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309600 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009601 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309602 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009603
Yue Ma3ede6052013-08-29 00:33:26 -07009604 if (NULL == pHddCtx)
9605 {
9606 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9607 return;
9608 }
9609
9610 hHal = pHddCtx->hHal;
9611
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309612 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9615 return;
9616 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309617
9618 /* Check if INI is enabled or not, other wise just return
9619 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309620 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309621 {
9622 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9623 if (NULL == pMulticastAddrs)
9624 {
9625 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9626 return;
9627 }
9628
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 if (set)
9630 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309631 /* Following pre-conditions should be satisfied before wei
9632 * configure the MC address list.
9633 */
9634 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9635 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9636 && pAdapter->mc_addr_list.mc_cnt
9637 && (eConnectionState_Associated ==
9638 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9639 {
9640 pMulticastAddrs->ulMulticastAddrCnt =
9641 pAdapter->mc_addr_list.mc_cnt;
9642 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9643 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009644 memcpy(pMulticastAddrs->multicastAddr[i],
9645 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309646 sizeof(pAdapter->mc_addr_list.addr[i]));
9647 hddLog(VOS_TRACE_LEVEL_INFO,
9648 "%s: %s multicast filter: addr ="
9649 MAC_ADDRESS_STR,
9650 __func__, set ? "setting" : "clearing",
9651 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9652 }
9653 /* Set multicast filter */
9654 sme_8023MulticastList(hHal, pAdapter->sessionId,
9655 pMulticastAddrs);
9656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309658 else
9659 {
9660 /* Need to clear only if it was previously configured
9661 */
9662 if (pAdapter->mc_addr_list.isFilterApplied)
9663 {
9664 pMulticastAddrs->ulMulticastAddrCnt = 0;
9665 sme_8023MulticastList(hHal, pAdapter->sessionId,
9666 pMulticastAddrs);
9667 }
9668
9669 }
9670 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009671 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309673 else
9674 {
9675 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309676 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309677 }
9678 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009679}
9680
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309681static int __iw_set_packet_filter_params(struct net_device *dev,
9682 struct iw_request_info *info,
9683 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309684{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309685 hdd_adapter_t *pAdapter;
9686 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009687 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309688 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309689 struct iw_point s_priv_data;
9690
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309691 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309692
9693 if (!capable(CAP_NET_ADMIN))
9694 {
9695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9696 FL("permission check failed"));
9697 return -EPERM;
9698 }
9699
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309700 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9701 if (NULL == pAdapter)
9702 {
9703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9704 "%s: Adapter is NULL",__func__);
9705 return -EINVAL;
9706 }
9707 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9708 ret = wlan_hdd_validate_context(pHddCtx);
9709 if (0 != ret)
9710 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309711 return ret;
9712 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309713 if (hdd_priv_get_data(&s_priv_data, wrqu))
9714 {
9715 return -EINVAL;
9716 }
9717
9718 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9719 {
9720 return -EINVAL;
9721 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009722
Arif Hussain0273cba2014-01-07 20:58:29 -08009723 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309724 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9725 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009726 if (NULL == pRequest)
9727 {
9728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9729 "mem_alloc_copy_from_user_helper fail");
9730 return -ENOMEM;
9731 }
9732
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309733 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009734 kfree(pRequest);
9735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309736 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009737 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009738}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309739
9740static int iw_set_packet_filter_params(struct net_device *dev,
9741 struct iw_request_info *info,
9742 union iwreq_data *wrqu, char *extra)
9743{
9744 int ret;
9745
9746 vos_ssr_protect(__func__);
9747 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9748 vos_ssr_unprotect(__func__);
9749
9750 return ret;
9751}
Jeff Johnson295189b2012-06-20 16:38:30 -07009752#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309753static int __iw_get_statistics(struct net_device *dev,
9754 struct iw_request_info *info,
9755 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009756{
9757
9758 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9759 eHalStatus status = eHAL_STATUS_SUCCESS;
9760 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309761 hdd_adapter_t *pAdapter;
9762 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309764 int tlen = 0, ret = 0;
9765 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009766
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309767 tCsrGlobalClassAStatsInfo *aStats;
9768 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009769
9770 ENTER();
9771
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309772 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9773 if (NULL == pAdapter)
9774 {
9775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9776 "%s: Adapter is NULL",__func__);
9777 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309779 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9780 ret = wlan_hdd_validate_context(pHddCtx);
9781 if (0 != ret)
9782 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309783 return ret;
9784 }
9785 pStats = &(pAdapter->hdd_stats.summary_stat);
9786 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9787 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9789
9790 wrqu->txpower.value = 0;
9791 }
9792 else {
9793 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9794 SME_SUMMARY_STATS |
9795 SME_GLOBAL_CLASSA_STATS |
9796 SME_GLOBAL_CLASSB_STATS |
9797 SME_GLOBAL_CLASSC_STATS |
9798 SME_GLOBAL_CLASSD_STATS |
9799 SME_PER_STA_STATS,
9800 hdd_StatisticsCB, 0, FALSE,
9801 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9802
9803 if (eHAL_STATUS_SUCCESS != status)
9804 {
9805 hddLog(VOS_TRACE_LEVEL_ERROR,
9806 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009807 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 return -EINVAL;
9809 }
9810
9811 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309812 if (NULL == pWextState)
9813 {
9814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9815 "%s: pWextState is NULL",__func__);
9816 return -EINVAL;
9817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009818
9819 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9820 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9821 {
9822 hddLog(VOS_TRACE_LEVEL_ERROR,
9823 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009824 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 /*Remove the SME statistics list by passing NULL in callback argument*/
9826 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9827 SME_SUMMARY_STATS |
9828 SME_GLOBAL_CLASSA_STATS |
9829 SME_GLOBAL_CLASSB_STATS |
9830 SME_GLOBAL_CLASSC_STATS |
9831 SME_GLOBAL_CLASSD_STATS |
9832 SME_PER_STA_STATS,
9833 NULL, 0, FALSE,
9834 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9835
9836 return -EINVAL;
9837 }
9838 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9839 (tANI_U8) sizeof (pStats->retry_cnt),
9840 (char*) &(pStats->retry_cnt[0]),
9841 tlen);
9842
9843 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9844 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9845 (char*) &(pStats->multiple_retry_cnt[0]),
9846 tlen);
9847
9848 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9849 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9850 (char*) &(pStats->tx_frm_cnt[0]),
9851 tlen);
9852
9853 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9854 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9855 (char*) &(pStats->rx_frm_cnt),
9856 tlen);
9857
9858 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9859 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9860 (char*) &(pStats->frm_dup_cnt),
9861 tlen);
9862
9863 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9864 (tANI_U8) sizeof (pStats->fail_cnt),
9865 (char*) &(pStats->fail_cnt[0]),
9866 tlen);
9867
9868 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9869 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9870 (char*) &(pStats->rts_fail_cnt),
9871 tlen);
9872
9873 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9874 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9875 (char*) &(pStats->ack_fail_cnt),
9876 tlen);
9877
9878 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9879 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9880 (char*) &(pStats->rts_succ_cnt),
9881 tlen);
9882
9883 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9884 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9885 (char*) &(pStats->rx_discard_cnt),
9886 tlen);
9887
9888 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9889 (tANI_U8) sizeof (pStats->rx_error_cnt),
9890 (char*) &(pStats->rx_error_cnt),
9891 tlen);
9892
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009893 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009894 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009895 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 tlen);
9897
9898 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9899 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9900 (char*) &(dStats->rx_byte_cnt),
9901 tlen);
9902
9903 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9904 (tANI_U8) sizeof (dStats->rx_rate),
9905 (char*) &(dStats->rx_rate),
9906 tlen);
9907
9908 /* Transmit rate, in units of 500 kbit/sec */
9909 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9910 (tANI_U8) sizeof (aStats->tx_rate),
9911 (char*) &(aStats->tx_rate),
9912 tlen);
9913
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009914 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9915 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9916 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009917 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009918 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9919 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9920 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009921 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009922 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9923 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9924 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009925 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009926 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9927 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9928 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009929 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009930 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9931 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9932 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009933 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009934 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9935 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9936 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009937 tlen);
9938
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 wrqu->data.length = tlen;
9940
9941 }
9942
9943 EXIT();
9944
9945 return 0;
9946}
9947
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309948static int iw_get_statistics(struct net_device *dev,
9949 struct iw_request_info *info,
9950 union iwreq_data *wrqu, char *extra)
9951{
9952 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009953
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309954 vos_ssr_protect(__func__);
9955 ret = __iw_get_statistics(dev, info, wrqu, extra);
9956 vos_ssr_unprotect(__func__);
9957
9958 return ret;
9959}
Jeff Johnson295189b2012-06-20 16:38:30 -07009960#ifdef FEATURE_WLAN_SCAN_PNO
9961
9962/*Max Len for PNO notification*/
9963#define MAX_PNO_NOTIFY_LEN 100
9964void found_pref_network_cb (void *callbackContext,
9965 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9966{
9967 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9968 union iwreq_data wrqu;
9969 char buf[MAX_PNO_NOTIFY_LEN+1];
9970
9971 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9972 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9973
9974 // create the event
9975 memset(&wrqu, 0, sizeof(wrqu));
9976 memset(buf, 0, sizeof(buf));
9977
9978 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9979 pPrefNetworkFoundInd->ssId.ssId,
9980 (unsigned int)pPrefNetworkFoundInd->rssi);
9981
9982 wrqu.data.pointer = buf;
9983 wrqu.data.length = strlen(buf);
9984
9985 // send the event
9986
9987 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9988
9989}
9990
9991
9992/*string based input*/
9993VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9994 union iwreq_data *wrqu, char *extra, int nOffset)
9995{
9996 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309997 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009998 /* pnoRequest is a large struct, so we make it static to avoid stack
9999 overflow. This API is only invoked via ioctl, so it is
10000 serialized by the kernel rtnl_lock and hence does not need to be
10001 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010002 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010003 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010005 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +053010006 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
10008
10009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10010 "PNO data len %d data %s",
10011 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010012 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010013
10014 if (wrqu->data.length <= nOffset )
10015 {
10016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
10017 return VOS_STATUS_E_FAILURE;
10018 }
10019
10020 pnoRequest.enable = 0;
10021 pnoRequest.ucNetworksCount = 0;
10022 /*-----------------------------------------------------------------------
10023 Input is string based and expected to be like this:
10024
10025 <enabled> <netw_count>
10026 for each network:
10027 <ssid_len> <ssid> <authentication> <encryption>
10028 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
10029 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
10030
10031 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -070010032 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 -070010033
10034 this translates into:
10035 -----------------------------
10036 enable PNO
10037 look for 2 networks:
10038 test - with authentication type 0 and encryption type 0,
10039 that can be found on 3 channels: 1 6 and 11 ,
10040 SSID bcast type is unknown (directed probe will be sent if AP not found)
10041 and must meet -40dBm RSSI
10042
10043 test2 - with auth and enrytption type 4/4
10044 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
10045 bcast type is non-bcast (directed probe will be sent)
10046 and must not meet any RSSI threshold
10047
Jeff Johnson8301aa12013-03-28 14:27:29 -070010048 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010050
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010051 /* making sure argument string ends with '\0' */
10052 len = (wrqu->data.length-nOffset) + 1;
10053 data = vos_mem_malloc(len);
10054 if (NULL == data) {
10055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10056 FL("fail to allocate memory %zu"), len);
10057 return -EINVAL;
10058 }
10059 vos_mem_zero(data, len);
10060 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010061 ptr = data;
10062
10063 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010064 {
10065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10066 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010067 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -070010068 return VOS_STATUS_E_FAILURE;
10069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010070
10071 if ( 0 == pnoRequest.enable )
10072 {
10073 /*Disable PNO*/
10074 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +053010075 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
10076 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 pAdapter->sessionId,
10078 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010079 if (eHAL_STATUS_SUCCESS != status)
10080 {
10081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10082 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010083 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010084 return VOS_STATUS_E_FAILURE;
10085 }
10086 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010087 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 return VOS_STATUS_SUCCESS;
10089 }
10090
c_hpothu37f21312014-04-09 21:49:54 +053010091 if (TRUE == pHddCtx->isPnoEnable)
10092 {
10093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10094 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010095 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010096 return -EBUSY;
10097 }
10098 pHddCtx->isPnoEnable = TRUE;
10099
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -070010101
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010102 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010103 {
10104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10105 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010106 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010108
10109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10110 "PNO enable %d networks count %d offset %d",
10111 pnoRequest.enable,
10112 pnoRequest.ucNetworksCount,
10113 nOffset);
10114
10115 /* Parameters checking:
10116 ucNetworksCount has to be larger than 0*/
10117 if (( 0 == pnoRequest.ucNetworksCount ) ||
10118 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10119 {
10120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +053010121 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 }
10123
10124 ptr += nOffset;
10125
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010126 pnoRequest.aNetworks =
10127 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10128 if (pnoRequest.aNetworks == NULL)
10129 {
10130 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10131 FL("failed to allocate memory aNetworks %u"),
10132 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10133 goto error;
10134 }
10135 vos_mem_zero(pnoRequest.aNetworks,
10136 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10137
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
10139 {
10140
10141 pnoRequest.aNetworks[i].ssId.length = 0;
10142
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010143 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010144 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
10145
10146 if (1 != ucParams)
10147 {
10148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10149 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010150 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010152
10153 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
10154 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
10155 {
10156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10157 "SSID Len %d is not correct for network %d",
10158 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +053010159 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 }
10161
10162 /*Advance to SSID*/
10163 ptr += nOffset;
10164
Jeff Johnson8301aa12013-03-28 14:27:29 -070010165 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -080010166 pnoRequest.aNetworks[i].ssId.length);
10167 ptr += pnoRequest.aNetworks[i].ssId.length;
10168
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010169 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -080010170 &(pnoRequest.aNetworks[i].authentication),
10171 &(pnoRequest.aNetworks[i].encryption),
10172 &(pnoRequest.aNetworks[i].ucChannelCount),
10173 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010174
Wilson Yang623f6592013-10-08 16:33:37 -070010175 if ( 3 != ucParams )
10176 {
10177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10178 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010179 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010180 }
10181
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010183 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010184 "auth %d encry %d channel count %d offset %d",
10185 pnoRequest.aNetworks[i].ssId.length,
10186 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10187 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10188 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10189 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10190 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10191 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10192 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10193 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10194 pnoRequest.aNetworks[i].authentication,
10195 pnoRequest.aNetworks[i].encryption,
10196 pnoRequest.aNetworks[i].ucChannelCount,
10197 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010198
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 /*Advance to channel list*/
10200 ptr += nOffset;
10201
Wilson Yang623f6592013-10-08 16:33:37 -070010202 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010203 {
10204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10205 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010206 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 }
10208
10209 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10210 {
10211 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10212 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010213 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010214 &(pnoRequest.aNetworks[i].aChannels[j]),
10215 &nOffset))
10216 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10217 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010218 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010219 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010220 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10222 FL("invalid channel: %hhu"),
10223 pnoRequest.aNetworks[i].aChannels[j]);
10224 goto error;
10225 }
10226
Wilson Yang623f6592013-10-08 16:33:37 -070010227 /*Advance to next channel number*/
10228 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 }
10230 }
10231
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010232 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010233 &(pnoRequest.aNetworks[i].bcastNetwType),
10234 &nOffset))
10235 {
10236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10237 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010238 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010239 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010240 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10242 FL("invalid bcast nw type: %u"),
10243 pnoRequest.aNetworks[i].bcastNetwType);
10244 goto error;
10245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010246
10247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10248 "PNO bcastNetwType %d offset %d",
10249 pnoRequest.aNetworks[i].bcastNetwType,
10250 nOffset );
10251
10252 /*Advance to rssi Threshold*/
10253 ptr += nOffset;
10254
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010255 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010256 &(pnoRequest.aNetworks[i].rssiThreshold),
10257 &nOffset))
10258 {
10259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10260 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010261 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010262 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010263
10264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10265 "PNO rssi %d offset %d",
10266 pnoRequest.aNetworks[i].rssiThreshold,
10267 nOffset );
10268 /*Advance to next network*/
10269 ptr += nOffset;
10270 }/*For ucNetworkCount*/
10271
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010272 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010273 &(pnoRequest.scanTimers.ucScanTimersCount),
10274 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010275
10276 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010277 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 {
10279 ptr += nOffset;
10280
Jeff Johnson8301aa12013-03-28 14:27:29 -070010281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10282 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 pnoRequest.scanTimers.ucScanTimersCount,
10284 nOffset );
10285
10286 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10287 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010290 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 }
10292
10293 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10294 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010295 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010296 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10297 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10298 &nOffset);
10299
Wilson Yang623f6592013-10-08 16:33:37 -070010300 if (2 != ucParams)
10301 {
10302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10303 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010304 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010305 }
10306
Jeff Johnson8301aa12013-03-28 14:27:29 -070010307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10308 "PNO Timer value %d Timer repeat %d offset %d",
10309 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010310 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10311 nOffset );
10312
Jeff Johnson295189b2012-06-20 16:38:30 -070010313 ptr += nOffset;
10314 }
10315
10316 }
10317 else
10318 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10320 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10322
10323 /*Scan timers defaults to 5 minutes*/
10324 pnoRequest.scanTimers.ucScanTimersCount = 1;
10325 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10326 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10327 }
10328
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010329 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010330
10331 pnoRequest.modePNO = ucMode;
10332 /*for LA we just expose suspend option*/
10333 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10334 {
10335 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10336 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010337 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10338 if (pnoRequest.p24GProbeTemplate == NULL){
10339 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10340 FL("failed to allocate memory p24GProbeTemplate %u"),
10341 SIR_PNO_MAX_PB_REQ_SIZE);
10342 goto error;
10343 }
10344
10345 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10346 if (pnoRequest.p5GProbeTemplate == NULL){
10347 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10348 FL("failed to allocate memory p5GProbeTemplate %u"),
10349 SIR_PNO_MAX_PB_REQ_SIZE);
10350 goto error;
10351 }
10352
10353 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10354 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010355
c_hpothu37f21312014-04-09 21:49:54 +053010356 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 pAdapter->sessionId,
10358 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010359 if (eHAL_STATUS_SUCCESS == status)
10360 {
10361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10362 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010363 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010364 return VOS_STATUS_SUCCESS;
10365 }
10366error:
10367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10368 "%s: Failed to enable PNO", __func__);
10369 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010370 if (pnoRequest.aNetworks)
10371 vos_mem_free(pnoRequest.aNetworks);
10372 if (pnoRequest.p24GProbeTemplate)
10373 vos_mem_free(pnoRequest.p24GProbeTemplate);
10374 if (pnoRequest.p5GProbeTemplate)
10375 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010376
10377 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010378 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010379}/*iw_set_pno*/
10380
10381VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10382 union iwreq_data *wrqu, char *extra, int nOffset)
10383{
10384 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10385 v_U8_t rssiThreshold = 0;
10386 v_U8_t nRead;
10387
Arif Hussain7adce1b2013-11-11 22:59:34 -080010388 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 &rssiThreshold);
10390
10391 if ( 1 != nRead )
10392 {
10393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10394 "Incorrect format");
10395 return VOS_STATUS_E_FAILURE;
10396 }
10397
10398 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10399 return VOS_STATUS_SUCCESS;
10400}
10401
10402
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010403static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 struct iw_request_info *info,
10405 union iwreq_data *wrqu, char *extra)
10406{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010407 hdd_adapter_t *pAdapter;
10408 hdd_context_t *pHddCtx;
10409 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010410 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010412 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010413 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10414 if (NULL == pAdapter)
10415 {
10416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10417 "%s: Adapter is NULL",__func__);
10418 return -EINVAL;
10419 }
10420
10421 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10422 ret = wlan_hdd_validate_context(pHddCtx);
10423 if (0 != ret)
10424 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010425 return ret;
10426 }
10427
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010428
10429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010431
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010432 status = iw_set_pno(dev,info,wrqu,extra,0);
10433
10434 EXIT();
10435 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010436}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010437
10438static int iw_set_pno_priv(struct net_device *dev,
10439 struct iw_request_info *info,
10440 union iwreq_data *wrqu, char *extra)
10441{
10442 int ret;
10443
10444 vos_ssr_protect(__func__);
10445 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10446 vos_ssr_unprotect(__func__);
10447
10448 return ret;
10449}
Jeff Johnson295189b2012-06-20 16:38:30 -070010450#endif /*FEATURE_WLAN_SCAN_PNO*/
10451
10452//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010453int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010454{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010455 hdd_adapter_t *pAdapter;
10456 tHalHandle hHal;
10457 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010458 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010459 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010460 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010462 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010463 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010464 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010465
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010466 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010467 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10468 if (NULL == pAdapter)
10469 {
10470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10471 "%s: Adapter is NULL",__func__);
10472 return -EINVAL;
10473 }
10474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10475 retval = wlan_hdd_validate_context(pHddCtx);
10476 if (0 != retval)
10477 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010478 return retval;
10479 }
10480 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10481 if (NULL == hHal)
10482 {
10483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10484 "%s: Hal Context is NULL",__func__);
10485 return -EINVAL;
10486 }
10487 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010488
Atul Mittal54378cb2014-04-02 16:51:50 +053010489 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 {
10491 case WLAN_HDD_UI_BAND_AUTO:
10492 band = eCSR_BAND_ALL;
10493 break;
10494 case WLAN_HDD_UI_BAND_5_GHZ:
10495 band = eCSR_BAND_5G;
10496 break;
10497 case WLAN_HDD_UI_BAND_2_4_GHZ:
10498 band = eCSR_BAND_24;
10499 break;
10500 default:
10501 band = eCSR_BAND_MAX;
10502 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010503 connectedBand =
10504 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010505
Atul Mittal54378cb2014-04-02 16:51:50 +053010506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010507 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010508
10509 if (band == eCSR_BAND_MAX)
10510 {
10511 /* Received change band request with invalid band value */
10512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010513 "%s: Invalid band value %u", __func__, ui_band);
10514 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 }
10516
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010517 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010518 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010519 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010521 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010522 band, pHddCtx->cfg_ini->nBandCapability);
10523 return -EIO;
10524 }
10525
Sushant Kaushik1165f872015-03-30 20:25:27 +053010526 if (band == eCSR_BAND_ALL)
10527 {
10528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10529 "received. Setting band same as ini value %d"),
10530 pHddCtx->cfg_ini->nBandCapability);
10531 band = pHddCtx->cfg_ini->nBandCapability;
10532 }
10533
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10535 {
10536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10537 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010538 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 return -EIO;
10540 }
10541
10542 if (currBand != band)
10543 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010544 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010545 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010546 /* Return failure if current country code is world regulatory domain*/
10547 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10548 pMac->scan.countryCodeCurrent[1] == '0') )
10549 {
10550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10551 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010552 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010553 return -EAGAIN;
10554 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010555 }
10556
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 /* Change band request received.
10558 * Abort pending scan requests, flush the existing scan results,
10559 * and change the band capability
10560 */
10561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10562 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010563 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010564
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010565 /* We need to change the band and flush the scan results here itself
10566 * as we may get timeout for disconnection in which we will return
10567 * with out doing any of these
10568 */
10569 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10570 {
10571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10572 "%s: failed to set the band value to %u ",
10573 __func__, band);
10574 return -EINVAL;
10575 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010576 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10577 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010578 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010579 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10580 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010581 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010582 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10583 * information available in NV so to get the channel information from kernel
10584 * we need to send regulatory hint for the currunt country
10585 * And to set the same country again we need to set the dummy country
10586 * first and then the actual country.
10587 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010589 if(curr_country[0] == '0' && curr_country[1] == '0')
10590 regulatory_hint_user("IN", NL80211_USER_REG_HINT_USER);
10591 else
10592 regulatory_hint_user("OO", NL80211_USER_REG_HINT_USER);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010593#else
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010594 if(curr_country[0] == '0' && curr_country[1] == '0')
10595 regulatory_hint_user("IN");
10596 else
10597 regulatory_hint_user("00");
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010598#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010599 wait_result = wait_for_completion_interruptible_timeout(
10600 &pHddCtx->linux_reg_req,
10601 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10602
10603 /* if the country information does not exist with the kernel,
10604 then the driver callback would not be called */
10605
10606 if (wait_result >= 0)
10607 {
10608 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10609 "runtime country code is found in kernel db");
10610 }
10611 else
10612 {
10613 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10614 "runtime country code is not found"
10615 " in kernel db");
10616 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010617
10618 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010619
10620 /*
10621 * Update 11dcountry and current country here as the hint
10622 * with 00 results in 11d and current country with 00
10623 */
10624 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10625 WNI_CFG_COUNTRY_CODE_LEN);
10626 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10627 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010628#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10629 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10630#else
10631 regulatory_hint_user(curr_country);
10632#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010633 wait_result = wait_for_completion_interruptible_timeout(
10634 &pHddCtx->linux_reg_req,
10635 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10636
10637 /* if the country information does not exist with the kernel,
10638 then the driver callback would not be called */
10639 if (wait_result >= 0)
10640 {
10641 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10642 "runtime country code is found in kernel db");
10643 }
10644 else
10645 {
10646 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10647 "runtime country code is not found"
10648 " in kernel db");
10649 }
10650
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010651 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010652 }
10653 else
10654 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010655#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010656 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10657 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010658#else
10659 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10660#endif
10661
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010662 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010663 pScanInfo = &pHddCtx->scan_info;
10664 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10665 {
10666 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10667 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10668 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010669 sme_FilterScanResults(hHal, pAdapter->sessionId);
10670
10671 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010672 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10673 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010675 eHalStatus status = eHAL_STATUS_SUCCESS;
10676 long lrc;
10677
10678 /* STA already connected on current band, So issue disconnect first,
10679 * then change the band*/
10680
10681 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010682 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010683 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010684
Jeff Johnson295189b2012-06-20 16:38:30 -070010685 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10686
10687 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10688 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10689
Jeff Johnson43971f52012-07-17 12:26:56 -070010690 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010691 {
10692 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010693 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010694 __func__, (int)status );
10695 return -EINVAL;
10696 }
10697
10698 lrc = wait_for_completion_interruptible_timeout(
10699 &pAdapter->disconnect_comp_var,
10700 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10701
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010702 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010703
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010704 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010705 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010706
10707 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10708 }
10709 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010711 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010712 if (TRUE == pHddCtx->isSetBandByNL)
10713 return 0;
10714 else
10715 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010716}
10717
Atul Mittal54378cb2014-04-02 16:51:50 +053010718int hdd_setBand_helper(struct net_device *dev, const char *command)
10719{
10720 u8 band;
10721
10722 /*convert the band value from ascii to integer*/
10723 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10724
10725 return hdd_setBand(dev, band);
10726
10727}
10728
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010729static int __iw_set_band_config(struct net_device *dev,
10730 struct iw_request_info *info,
10731 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010732{
Atul Mittal54378cb2014-04-02 16:51:50 +053010733 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010734
Arif Hussain0273cba2014-01-07 20:58:29 -080010735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010736
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010737 if (!capable(CAP_NET_ADMIN))
10738 {
10739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10740 FL("permission check failed"));
10741 return -EPERM;
10742 }
10743
Atul Mittal54378cb2014-04-02 16:51:50 +053010744 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010745}
10746
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010747static int iw_set_band_config(struct net_device *dev,
10748 struct iw_request_info *info,
10749 union iwreq_data *wrqu, char *extra)
10750{
10751 int ret;
10752
10753 vos_ssr_protect(__func__);
10754 ret = __iw_set_band_config(dev, info, wrqu, extra);
10755 vos_ssr_unprotect(__func__);
10756
10757 return ret;
10758}
10759
c_manjeecfd1efb2015-09-25 19:32:34 +053010760static int get_fwr_memdump(struct net_device *dev,
10761 struct iw_request_info *info,
10762 union iwreq_data *wrqu, char *extra)
10763{
10764 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10765 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10766 int ret;
10767 ENTER();
10768 // HddCtx sanity
10769 ret = wlan_hdd_validate_context(pHddCtx);
10770 if (0 != ret)
10771 {
10772 return ret;
10773 }
10774 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10775 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10776 {
10777 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10778 return -EINVAL;
10779 }
10780 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10781
10782 EXIT();
10783 return ret;
10784}
10785
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010786static int __iw_set_power_params_priv(struct net_device *dev,
10787 struct iw_request_info *info,
10788 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010789{
Arif Hussain0273cba2014-01-07 20:58:29 -080010790 int ret;
10791 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010792
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10794 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010795
10796 if (!capable(CAP_NET_ADMIN))
10797 {
10798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10799 FL("permission check failed"));
10800 return -EPERM;
10801 }
10802
Arif Hussain0273cba2014-01-07 20:58:29 -080010803 /* ODD number is used for set, copy data using copy_from_user */
10804 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10805 wrqu->data.length);
10806 if (NULL == ptr)
10807 {
10808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10809 "mem_alloc_copy_from_user_helper fail");
10810 return -ENOMEM;
10811 }
10812
10813 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10814 kfree(ptr);
10815 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010816}
10817
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010818static int iw_set_power_params_priv(struct net_device *dev,
10819 struct iw_request_info *info,
10820 union iwreq_data *wrqu, char *extra)
10821{
10822 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010823
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010824 vos_ssr_protect(__func__);
10825 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10826 vos_ssr_unprotect(__func__);
10827
10828 return ret;
10829}
Jeff Johnson295189b2012-06-20 16:38:30 -070010830
10831/*string based input*/
10832VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10833 union iwreq_data *wrqu, char *extra, int nOffset)
10834{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010835 hdd_adapter_t *pAdapter;
10836 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 tSirSetPowerParamsReq powerRequest;
10838 char *ptr;
10839 v_U8_t ucType;
10840 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010841 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010843 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010844 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10845 if (NULL == pAdapter)
10846 {
10847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10848 "%s: Adapter is NULL",__func__);
10849 return -EINVAL;
10850 }
10851
10852 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10853 ret = wlan_hdd_validate_context(pHddCtx);
10854 if (0 != ret)
10855 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010856 return ret;
10857 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10859 "Power Params data len %d data %s",
10860 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010861 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010862
10863 if (wrqu->data.length <= nOffset )
10864 {
10865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10866 return VOS_STATUS_E_FAILURE;
10867 }
10868
10869 uTotalSize = wrqu->data.length - nOffset;
10870
10871 /*-----------------------------------------------------------------------
10872 Input is string based and expected to be like this:
10873
10874 <param_type> <param_value> <param_type> <param_value> ...
10875
10876 e.g:
10877 1 2 2 3 3 0 4 1 5 1
10878
10879 e.g. setting just a few:
10880 1 2 4 1
10881
10882 parameter types:
10883 -----------------------------
10884 1 - Ignore DTIM
10885 2 - Listen Interval
10886 3 - Broadcast Multicas Filter
10887 4 - Beacon Early Termination
10888 5 - Beacon Early Termination Interval
10889 -----------------------------------------------------------------------*/
10890 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10891 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10892 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10893 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10894 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10895
Arif Hussain7adce1b2013-11-11 22:59:34 -080010896 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010897
10898 while ( uTotalSize )
10899 {
Wilson Yang6f971452013-10-08 15:00:00 -070010900 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10901 {
10902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10903 "Invalid input parameter type %s",ptr);
10904 return VOS_STATUS_E_FAILURE;
10905 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010906
10907 uTotalSize -= nOffset;
10908
10909 if (!uTotalSize)
10910 {
10911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010912 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 ucType, nOffset);
10914 return VOS_STATUS_E_FAILURE;
10915 }
10916
10917 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010918
Jeff Johnson02797792013-10-26 19:17:13 -070010919 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010920 {
10921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10922 "Invalid input parameter value %s",ptr);
10923 return VOS_STATUS_E_FAILURE;
10924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010925
10926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10927 "Power request parameter %d value %d offset %d",
10928 ucType, uValue, nOffset);
10929
10930 switch (ucType)
10931 {
10932 case eSIR_IGNORE_DTIM:
10933 powerRequest.uIgnoreDTIM = uValue;
10934 break;
10935 case eSIR_LISTEN_INTERVAL:
10936 powerRequest.uListenInterval = uValue;
10937 break;
10938 case eSIR_MCAST_BCAST_FILTER:
10939 powerRequest.uBcastMcastFilter = uValue;
10940 break;
10941 case eSIR_ENABLE_BET:
10942 powerRequest.uEnableBET = uValue;
10943 break;
10944 case eSIR_BET_INTERVAL:
10945 powerRequest.uBETInterval = uValue;
10946 break;
10947 default:
10948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010949 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010950 ucType, uValue, nOffset);
10951 return VOS_STATUS_E_FAILURE;
10952 }
10953
10954 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10956 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010957 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010958 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010959 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010960 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010961 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10962 {
10963 uTotalSize = 0;
10964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010965
10966 }/*Go for as long as we have a valid string*/
10967
10968 /* put the device into full power*/
10969 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10970
10971 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010972 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010973
10974 /* put the device back to power save*/
10975 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010977 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010978 return VOS_STATUS_SUCCESS;
10979}/*iw_set_power_params*/
10980
Atul Mittalc0f739f2014-07-31 13:47:47 +053010981// tdlsoffchan
10982#ifdef FEATURE_WLAN_TDLS
10983
Atul Mittal87ec2422014-09-24 13:12:50 +053010984int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010985{
10986 if (offchannel < 0 || offchannel > 165)
10987 {
10988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10989 __func__, offchannel);
10990 return -1;
10991
10992 }
10993
10994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10995 __func__, tdlsOffCh, offchannel);
10996
10997 tdlsOffCh = offchannel;
10998 return 0;
10999}
11000
Atul Mittal87ec2422014-09-24 13:12:50 +053011001int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011002{
11003 if (offchanoffset == 0)
11004 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011005 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11007 __func__, tdlsOffChBwOffset);
11008
11009 return 0;
11010
11011 }
11012
11013 if ( offchanoffset == 40 )
11014 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011015 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11017 __func__, tdlsOffChBwOffset);
11018
11019 return 0;
11020
11021 }
11022 if (offchanoffset == -40)
11023 {
11024 tdlsOffChBwOffset = 3;
11025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11026 __func__, tdlsOffChBwOffset);
11027
11028 return 0;
11029
11030 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053011031
11032 if ((offchanoffset == 80) &&
11033 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
11034 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
11035 {
11036 tdlsOffChBwOffset = 4;
11037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11038 "%s: change tdls secondary off channel offset to %u",
11039 __func__, tdlsOffChBwOffset);
11040
11041 return 0;
11042 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053011043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
11044 __func__, offchanoffset);
11045 return -1;
11046}
11047
Atul Mittal87ec2422014-09-24 13:12:50 +053011048int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011049{
11050 hddTdlsPeer_t *connPeer = NULL;
11051 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11052 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011053 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011054 if (offchanmode < 0 || offchanmode > 4)
11055 {
11056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11057 "%s: Invalid tdls off channel mode %d",
11058 __func__, offchanmode);
11059 return -1;
11060 }
11061
11062 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
11063 {
11064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11065 "%s: tdls off channel mode req in not associated state %d",
11066 __func__, offchanmode);
11067 return -1;
11068 }
11069
11070 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
11071 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
11072 {
11073 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011074 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011075 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011076 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011077 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11079 "%s: No TDLS Connected Peer", __func__);
11080 return -1;
11081 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011082 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011083 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011084 }
11085 else
11086 {
11087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11088 "%s: TDLS Connection not supported", __func__);
11089 return -1;
11090 }
11091
11092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11093 ("%s: TDLS Channel Switch in swmode=%d"),
11094 __func__, offchanmode);
11095
11096 switch (offchanmode)
11097 {
11098 case 1:/*Enable*/
11099 case 2:/*Disable*/
11100 {
11101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11102 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
11103 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11104 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
11105 {
11106
11107 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011108 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053011109 tdlsOffCh, tdlsOffChBwOffset,
11110 offchanmode);
11111 }
11112 else
11113 {
11114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11115 "%s: TDLS Off Channel not supported", __func__);
11116 return -1;
11117 }
11118 break;
11119 }
11120 case 3:
11121 {
11122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11123 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
11124 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11125
11126 break;
11127 }
11128 case 4:
11129 {
11130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11131 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
11132 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11133 break;
11134 }
11135 default:
11136 {
11137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11138 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
11139 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11140 break;
11141 }
11142
11143 }
11144
11145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
11146 __func__, offchanmode);
11147 return 0;
11148}
Atul Mittalc0f739f2014-07-31 13:47:47 +053011149#endif
11150
Jeff Johnson295189b2012-06-20 16:38:30 -070011151// Define the Wireless Extensions to the Linux Network Device structure
11152// A number of these routines are NULL (meaning they are not implemented.)
11153
11154static const iw_handler we_handler[] =
11155{
11156 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
11157 (iw_handler) iw_get_name, /* SIOCGIWNAME */
11158 (iw_handler) NULL, /* SIOCSIWNWID */
11159 (iw_handler) NULL, /* SIOCGIWNWID */
11160 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
11161 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
11162 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
11163 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
11164 (iw_handler) NULL, /* SIOCSIWSENS */
11165 (iw_handler) NULL, /* SIOCGIWSENS */
11166 (iw_handler) NULL, /* SIOCSIWRANGE */
11167 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053011168 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 (iw_handler) NULL, /* SIOCGIWPRIV */
11170 (iw_handler) NULL, /* SIOCSIWSTATS */
11171 (iw_handler) NULL, /* SIOCGIWSTATS */
11172 iw_handler_set_spy, /* SIOCSIWSPY */
11173 iw_handler_get_spy, /* SIOCGIWSPY */
11174 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
11175 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
11176 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11177 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11178 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11179 (iw_handler) NULL, /* SIOCGIWAPLIST */
11180 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11181 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11182 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11183 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11184 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11185 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11186 (iw_handler) NULL, /* -- hole -- */
11187 (iw_handler) NULL, /* -- hole -- */
11188 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11189 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11190 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11191 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11192 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11193 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11194 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11195 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11196 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11197 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11198 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11199 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11200 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11201 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11202 (iw_handler) NULL, /* -- hole -- */
11203 (iw_handler) NULL, /* -- hole -- */
11204 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11205 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11206 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11207 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11208 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11209 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11210 (iw_handler) NULL, /* SIOCSIWPMKSA */
11211};
11212
11213static const iw_handler we_private[] = {
11214
11215 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11216 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11217 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11218 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11219 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11220 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011221 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11223 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11224 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011225 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11226 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011227#ifdef FEATURE_OEM_DATA_SUPPORT
11228 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11229 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11230#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011231
Jeff Johnson295189b2012-06-20 16:38:30 -070011232#ifdef WLAN_FEATURE_VOWIFI_11R
11233 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11234#endif
11235 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11236 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11237 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11238#ifdef WLAN_FEATURE_PACKET_FILTERING
11239 ,
11240 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11241#endif
11242#ifdef FEATURE_WLAN_SCAN_PNO
11243 ,
11244 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11245#endif
11246 ,
11247 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11248 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11249 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11250 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011251 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011252};
11253
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011254static const iw_handler we_mon_private[] = {
11255 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] =
11256 iw_mon_setint_getnone,
11257};
11258
11259static const struct iw_priv_args we_mon_private_args[] = {
11260 {WE_SET_MONITOR_STATE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11261 0, "monitor"},
11262
11263 /* handlers for main ioctl */
11264 {WLAN_PRIV_SET_INT_GET_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11265 0, "" },
11266};
11267
Jeff Johnson295189b2012-06-20 16:38:30 -070011268/*Maximum command length can be only 15 */
11269static const struct iw_priv_args we_private_args[] = {
11270
Katya Nigamf0511f62015-05-05 16:40:57 +053011271 { WE_SET_MONITOR_STATE,
11272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11273 0, "monitor" },
11274
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 /* handlers for main ioctl */
11276 { WLAN_PRIV_SET_INT_GET_NONE,
11277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11278 0,
11279 "" },
11280
11281 /* handlers for sub-ioctl */
11282 { WE_SET_11D_STATE,
11283 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11284 0,
11285 "set11Dstate" },
11286
11287 { WE_WOWL,
11288 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11289 0,
11290 "wowl" },
11291
11292 { WE_SET_POWER,
11293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11294 0,
11295 "setPower" },
11296
11297 { WE_SET_MAX_ASSOC,
11298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11299 0,
11300 "setMaxAssoc" },
11301
11302 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11303 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11304 0,
11305 "setAutoChannel" },
11306
11307 { WE_SET_DATA_INACTIVITY_TO,
11308 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11309 0,
11310 "inactivityTO" },
11311
11312 { WE_SET_MAX_TX_POWER,
11313 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11314 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011315 "setMaxTxPower" },
11316
11317 { WE_SET_MAX_TX_POWER_2_4,
11318 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11319 0,
11320 "setTxMaxPower2G" },
11321
11322 { WE_SET_MAX_TX_POWER_5_0,
11323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11324 0,
11325 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011326
11327 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11328 * as well to keep same syntax as in SAP. Now onwards, STA
11329 * will support both */
11330 { WE_SET_MAX_TX_POWER,
11331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11332 0,
11333 "setTxMaxPower" },
11334
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11336 * 1 = enable and 0 = disable */
11337 {
11338 WE_SET_HIGHER_DTIM_TRANSITION,
11339 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11340 0,
11341 "setHDtimTransn" },
11342
11343 { WE_SET_TM_LEVEL,
11344 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011345 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011346 "setTmLevel" },
11347
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011348 { WE_ENABLE_STRICT_FCC_REG,
11349 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11350 0,
11351 "setStrictFCCreg" },
11352
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011353 { WE_SET_DEBUG_LOG,
11354 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11355 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011356#ifdef FEATURE_WLAN_TDLS
11357 {
11358 WE_SET_TDLS_OFF_CHAN,
11359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11360 0,
11361 "tdlsoffchan" },
11362 {
11363 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11365 0,
11366 "tdlsecchnoffst" },
11367 {
11368 WE_SET_TDLS_OFF_CHAN_MODE,
11369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11370 0,
11371 "tdlsoffchnmode" },
11372#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011373
Peng Xu2446a892014-09-05 17:21:18 +053011374 { WE_SET_SCAN_BAND_PREFERENCE,
11375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11376 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011377 {
11378 WE_GET_FRAME_LOG,
11379 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11380 0,
11381 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011382
Abhishek Singh01c73d12015-03-12 15:13:44 +053011383 { WE_SET_MIRACAST_VENDOR_CONFIG,
11384 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11385 0, "setMiracstConf" },
11386
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011387#ifdef FEATURE_WLAN_TDLS
11388 {
11389 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11390 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11391 0,
11392 "tdls_2040bsscox" },
11393#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011394 { WE_SET_RTS_CTS_HTVHT,
11395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11396 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011397 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11398 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11399 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011400 { WE_SET_PROXIMITY_ENABLE,
11401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11402 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011403
11404#ifdef WLAN_FEATURE_TSF
11405 { WE_CAP_TSF,
11406 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11407 0, "cap_tsf" },
11408#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011409 { WE_SET_MODULATED_DTIM,
11410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11411 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011412 {
11413 WLAN_SET_DYNNAMIC_AGGREGATION,
11414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11415 0, "setAggregation" },
11416
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 /* handlers for main ioctl */
11418 { WLAN_PRIV_SET_NONE_GET_INT,
11419 0,
11420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11421 "" },
11422
11423 /* handlers for sub-ioctl */
11424 { WE_GET_11D_STATE,
11425 0,
11426 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11427 "get11Dstate" },
11428
11429 { WE_IBSS_STATUS,
11430 0,
11431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11432 "getAdhocStatus" },
11433
11434 { WE_PMC_STATE,
11435 0,
11436 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11437 "pmcState" },
11438
11439 { WE_GET_WLAN_DBG,
11440 0,
11441 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11442 "getwlandbg" },
11443
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 { WE_GET_MAX_ASSOC,
11445 0,
11446 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11447 "getMaxAssoc" },
11448
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 { WE_GET_WDI_DBG,
11450 0,
11451 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11452 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011453
11454 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11455 0,
11456 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11457 "getAutoChannel" },
11458
11459 { WE_GET_CONCURRENCY_MODE,
11460 0,
11461 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11462 "getconcurrency" },
11463
Peng Xu2446a892014-09-05 17:21:18 +053011464 { WE_GET_SCAN_BAND_PREFERENCE,
11465 0,
11466 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11467 "get_scan_pref"},
11468
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011469 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11470 0,
11471 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11472 "getCurAnt"},
11473
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 /* handlers for main ioctl */
11475 { WLAN_PRIV_SET_CHAR_GET_NONE,
11476 IW_PRIV_TYPE_CHAR| 512,
11477 0,
11478 "" },
11479
11480 /* handlers for sub-ioctl */
11481 { WE_WOWL_ADD_PTRN,
11482 IW_PRIV_TYPE_CHAR| 512,
11483 0,
11484 "wowlAddPtrn" },
11485
11486 { WE_WOWL_DEL_PTRN,
11487 IW_PRIV_TYPE_CHAR| 512,
11488 0,
11489 "wowlDelPtrn" },
11490
11491#if defined WLAN_FEATURE_VOWIFI
11492 /* handlers for sub-ioctl */
11493 { WE_NEIGHBOR_REPORT_REQUEST,
11494 IW_PRIV_TYPE_CHAR | 512,
11495 0,
11496 "neighbor" },
11497#endif
11498 { WE_SET_AP_WPS_IE,
11499 IW_PRIV_TYPE_CHAR| 512,
11500 0,
11501 "set_ap_wps_ie" },
11502
11503 { WE_SET_CONFIG,
11504 IW_PRIV_TYPE_CHAR| 512,
11505 0,
11506 "setConfig" },
11507
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011508 { WE_SET_ENCRYPT_MSG,
11509 IW_PRIV_TYPE_CHAR| 512,
11510 0,
11511 "encryptMsg" },
11512
11513
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 /* handlers for main ioctl */
11515 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11516 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11517 0,
11518 "" },
11519
11520 /* handlers for sub-ioctl */
11521 { WE_SET_WLAN_DBG,
11522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11523 0,
11524 "setwlandbg" },
11525
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 { WE_SET_WDI_DBG,
11527 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11528 0,
11529 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011530
11531 { WE_SET_SAP_CHANNELS,
11532 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11533 0,
11534 "setsapchannels" },
11535
11536 /* handlers for main ioctl */
11537 { WLAN_PRIV_GET_CHAR_SET_NONE,
11538 0,
11539 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11540 "" },
11541
11542 /* handlers for sub-ioctl */
11543 { WE_WLAN_VERSION,
11544 0,
11545 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11546 "version" },
11547 { WE_GET_STATS,
11548 0,
11549 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11550 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011551 { WE_GET_STATES,
11552 0,
11553 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11554 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011555 { WE_GET_CFG,
11556 0,
11557 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11558 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011559#ifdef WLAN_FEATURE_11AC
11560 { WE_GET_RSSI,
11561 0,
11562 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11563 "getRSSI" },
11564#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011565#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011566 { WE_GET_ROAM_RSSI,
11567 0,
11568 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11569 "getRoamRSSI" },
11570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 { WE_GET_WMM_STATUS,
11572 0,
11573 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11574 "getWmmStatus" },
11575 {
11576 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011577 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011578 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11579 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011580#ifdef FEATURE_WLAN_TDLS
11581 {
11582 WE_GET_TDLS_PEERS,
11583 0,
11584 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11585 "getTdlsPeers" },
11586#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011587#ifdef WLAN_FEATURE_11W
11588 {
11589 WE_GET_11W_INFO,
11590 0,
11591 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11592 "getPMFInfo" },
11593#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011594#ifdef WLAN_FEATURE_RMC
11595 {
11596 WE_GET_IBSS_STA_INFO,
11597 0,
11598 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11599 "getIbssSTAs" },
11600#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011601 { WE_GET_SNR,
11602 0,
11603 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11604 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011605#ifdef FEATURE_OEM_DATA_SUPPORT
11606 {
11607 WE_GET_OEM_DATA_CAP,
11608 0,
11609 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11610 "getOemDataCap" },
11611#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 /* handlers for main ioctl */
11613 { WLAN_PRIV_SET_NONE_GET_NONE,
11614 0,
11615 0,
11616 "" },
11617
11618 /* handlers for sub-ioctl */
11619 { WE_CLEAR_STATS,
11620 0,
11621 0,
11622 "clearStats" },
11623 { WE_INIT_AP,
11624 0,
11625 0,
11626 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011627#ifdef WLAN_FEATURE_RMC
11628 {
11629 WE_IBSS_GET_PEER_INFO_ALL,
11630 0,
11631 0,
11632 "ibssPeerInfoAll" },
11633#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 { WE_STOP_AP,
11635 0,
11636 0,
11637 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011638#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 { WE_ENABLE_AMP,
11640 0,
11641 0,
11642 "enableAMP" },
11643 { WE_DISABLE_AMP,
11644 0,
11645 0,
11646 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011647#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011648 { WE_ENABLE_DXE_STALL_DETECT,
11649 0,
11650 0,
11651 "dxeStallDetect" },
11652 { WE_DISPLAY_DXE_SNAP_SHOT,
11653 0,
11654 0,
11655 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011656 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11657 0,
11658 0,
11659 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011660 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011661 WE_SET_REASSOC_TRIGGER,
11662 0,
11663 0,
11664 "reassoc" },
11665 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011666 WE_STOP_OBSS_SCAN,
11667 0,
11668 0,
11669 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011670 {
11671 WE_DUMP_ROAM_TIMER_LOG,
11672 0,
11673 0,
11674 "dumpRoamDelay" },
11675 {
11676 WE_RESET_ROAM_TIMER_LOG,
11677 0,
11678 0,
11679 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011680 {
11681 WE_GET_FW_LOGS,
11682 0,
11683 0,
11684 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011685 {
11686 WE_GET_FW_MEMDUMP,
11687 0,
11688 0,
11689 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 /* handlers for main ioctl */
11691 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11692 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11693 0,
11694 "" },
11695
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011696
11697
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 /* handlers for sub-ioctl */
11699 { WE_LOG_DUMP_CMD,
11700 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11701 0,
11702 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011703#ifdef WLAN_FEATURE_RMC
11704 { WE_IBSS_GET_PEER_INFO,
11705 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11706 0,
11707 "ibssPeerInfo" },
11708#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011709
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011710 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011711 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11712 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11713 0,
11714 "setdumplog" },
11715
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011716 { WE_MTRACE_DUMP_CMD,
11717 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11718 0,
11719 "dumplog" },
11720
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011721 /* handlers for sub ioctl */
11722 {
11723 WE_MCC_CONFIG_CREDENTIAL,
11724 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11725 0,
11726 "setMccCrdnl" },
11727
11728 /* handlers for sub ioctl */
11729 {
11730 WE_MCC_CONFIG_PARAMS,
11731 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11732 0,
11733 "setMccConfig" },
11734
Chilam NG571c65a2013-01-19 12:27:36 +053011735#ifdef FEATURE_WLAN_TDLS
11736 /* handlers for sub ioctl */
11737 {
11738 WE_TDLS_CONFIG_PARAMS,
11739 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11740 0,
11741 "setTdlsConfig" },
11742#endif
11743
Katya Nigamf0511f62015-05-05 16:40:57 +053011744 {
11745 WE_CONFIGURE_MONITOR_MODE,
11746 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11747 0,
11748 "MonitorModeConf" },
11749
11750 {
11751 WE_SET_MONITOR_MODE_FILTER,
11752 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11753 0,
11754 "MonitorFilter" },
11755
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 /* handlers for main ioctl */
11757 { WLAN_PRIV_ADD_TSPEC,
11758 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11760 "addTspec" },
11761
11762 /* handlers for main ioctl */
11763 { WLAN_PRIV_DEL_TSPEC,
11764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11766 "delTspec" },
11767
11768 /* handlers for main ioctl */
11769 { WLAN_PRIV_GET_TSPEC,
11770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11772 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011773 /* handlers for main ioctl */
11774 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11775 0,
11776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11777 "" },
11778#ifdef WLAN_FEATURE_TSF
11779 { WE_GET_TSF,
11780 0,
11781 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11782 "get_tsf" },
11783#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011784#ifdef FEATURE_OEM_DATA_SUPPORT
11785 /* handlers for main ioctl - OEM DATA */
11786 {
11787 WLAN_PRIV_SET_OEM_DATA_REQ,
11788 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11789 0,
11790 "set_oem_data_req" },
11791
11792 /* handlers for main ioctl - OEM DATA */
11793 {
11794 WLAN_PRIV_GET_OEM_DATA_RSP,
11795 0,
11796 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11797 "get_oem_data_rsp" },
11798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011799
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 /* handlers for main ioctl - host offload */
11801 {
11802 WLAN_PRIV_SET_HOST_OFFLOAD,
11803 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11804 0,
11805 "setHostOffload" },
11806
11807 {
11808 WLAN_GET_WLAN_STATISTICS,
11809 0,
11810 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11811 "getWlanStats" },
11812
11813 {
11814 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011815 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11816 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 0,
11818 "setKeepAlive" },
11819#ifdef WLAN_FEATURE_PACKET_FILTERING
11820 {
11821 WLAN_SET_PACKET_FILTER_PARAMS,
11822 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11823 0,
11824 "setPktFilter" },
11825#endif
11826#ifdef FEATURE_WLAN_SCAN_PNO
11827 {
11828 WLAN_SET_PNO,
11829 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11830 0,
11831 "setpno" },
11832#endif
11833 {
11834 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 0,
11837 "SETBAND" },
11838 /* handlers for dynamic MC BC ioctl */
11839 {
11840 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011841 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 0,
11843 "setMCBCFilter" },
11844 {
11845 WLAN_PRIV_CLEAR_MCBC_FILTER,
11846 0,
11847 0,
11848 "clearMCBCFilter" },
11849 {
11850 WLAN_SET_POWER_PARAMS,
11851 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11852 0,
11853 "setpowerparams" },
11854 {
11855 WLAN_GET_LINK_SPEED,
11856 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011857 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011858 {
11859 WLAN_PRIV_SET_FTIES,
11860 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11861 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011862};
11863
11864
11865
11866const struct iw_handler_def we_handler_def = {
11867 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11868 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11869 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11870
11871 .standard = (iw_handler *)we_handler,
11872 .private = (iw_handler *)we_private,
11873 .private_args = we_private_args,
11874 .get_wireless_stats = get_wireless_stats,
11875};
11876
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011877const struct iw_handler_def we_mon_handler_def = {
11878 .num_standard = 0,
11879 .num_private = sizeof(we_mon_private) / sizeof(we_mon_private[0]),
11880 .num_private_args =
11881 sizeof(we_mon_private_args) / sizeof(we_mon_private_args[0]),
11882 .standard = NULL,
11883 .private = (iw_handler *)we_mon_private,
11884 .private_args = we_mon_private_args,
11885 .get_wireless_stats = NULL,
11886};
11887
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011888int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11889{
11890 v_U32_t cmd = 288; //Command to RIVA
11891 hdd_context_t *pHddCtx = NULL;
11892 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11893 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11894 /*
11895 *configMccParam : specify the bit which needs to be modified
11896 *allowed to update based on wlan_qcom_cfg.ini
11897 * configuration
11898 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11899 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11900 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11901 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11902 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11903 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11904 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11905 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11906 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11907 * Bit 9 : Reserved
11908 */
11909 switch (arg1)
11910 {
11911 //Update MCC SCHEDULE_TIME_SLICE parameter
11912 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11913 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11914 {
11915 if((arg2 >= 5) && (arg2 <= 20))
11916 {
11917 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11918 }
11919 else
11920 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011921 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011922 return 0;
11923 }
11924 }
11925 break;
11926
11927 //Update MCC MAX_NULL_SEND_TIME parameter
11928 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11929 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11930 {
11931 if((arg2 >= 1) && (arg2 <= 10))
11932 {
11933 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11934 }
11935 else
11936 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011937 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011938 return 0;
11939 }
11940 }
11941 break;
11942
11943 //Update MCC TX_EARLY_STOP_TIME parameter
11944 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11945 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11946 {
11947 if((arg2 >= 1) && (arg2 <= 10))
11948 {
11949 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11950 }
11951 else
11952 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011953 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011954 return 0;
11955 }
11956 }
11957 break;
11958
11959 //Update MCC RX_DRAIN_TIME parameter
11960 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11961 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11962 {
11963 if((arg2 >= 1) && (arg2 <= 10))
11964 {
11965 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11966 }
11967 else
11968 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011969 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011970 return 0;
11971 }
11972 }
11973 break;
11974
11975 //Update MCC CHANNEL_SWITCH_TIME parameter
11976 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11977 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11978 {
11979 if((arg2 >= 1) && (arg2 <= 20))
11980 {
11981 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11982 }
11983 else
11984 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011985 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011986 return 0;
11987 }
11988 }
11989 break;
11990
11991 //Update MCC MIN_CHANNEL_TIME parameter
11992 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11993 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11994 {
11995 if((arg2 >= 5) && (arg2 <= 20))
11996 {
11997 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11998 }
11999 else
12000 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012001 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012002 return 0;
12003 }
12004 }
12005 break;
12006
12007 //Update MCC PARK_BEFORE_TBTT parameter
12008 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
12009 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
12010 {
12011 if((arg2 >= 1) && (arg2 <= 5))
12012 {
12013 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12014 }
12015 else
12016 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012017 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012018 return 0;
12019 }
12020 }
12021 break;
12022
12023 //Update MCC MIN_AFTER_DTIM parameter
12024 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
12025 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
12026 {
12027 if((arg2 >= 5) && (arg2 <= 15))
12028 {
12029 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12030 }
12031 else
12032 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012033 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012034 return 0;
12035 }
12036 }
12037 break;
12038
12039 //Update MCC TOO_CLOSE_MARGIN parameter
12040 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
12041 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
12042 {
12043 if((arg2 >= 1) && (arg2 <= 3))
12044 {
12045 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12046 }
12047 else
12048 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012049 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012050 return 0;
12051 }
12052 }
12053 break;
12054
12055 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080012056 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012057 __FUNCTION__,arg1);
12058 break;
12059 }
12060 return 0;
12061}
12062
Jeff Johnson295189b2012-06-20 16:38:30 -070012063int hdd_set_wext(hdd_adapter_t *pAdapter)
12064{
12065 hdd_wext_state_t *pwextBuf;
12066 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012067 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012068
12069 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12070
12071 // Now configure the roaming profile links. To SSID and bssid.
12072 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
12073 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
12074
12075 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
12076 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
12077
12078 /*Set the numOfChannels to zero to scan all the channels*/
12079 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
12080 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
12081
12082 /* Default is no encryption */
12083 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
12084 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
12085
12086 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
12087 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
12088
12089 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
12090
12091 /* Default is no authentication */
12092 pwextBuf->roamProfile.AuthType.numEntries = 1;
12093 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
12094
12095 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
12096 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12097
12098 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012099 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012100
12101 hdd_clearRoamProfileIe(pAdapter);
12102
12103 return VOS_STATUS_SUCCESS;
12104
12105 }
12106
12107int hdd_register_wext(struct net_device *dev)
12108 {
12109 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12110 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12111 VOS_STATUS status;
12112
12113 ENTER();
12114
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012115 if (pAdapter->device_mode == WLAN_HDD_MONITOR &&
12116 hdd_get_conparam() != VOS_MONITOR_MODE) {
12117 // Register as a wireless device
12118 dev->wireless_handlers = (struct iw_handler_def *)&we_mon_handler_def;
12119 return 0;
12120 }
12121
Jeff Johnson295189b2012-06-20 16:38:30 -070012122 // Zero the memory. This zeros the profile structure.
12123 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
12124
12125 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
12126
12127
12128 status = hdd_set_wext(pAdapter);
12129
12130 if(!VOS_IS_STATUS_SUCCESS(status)) {
12131
Arif Hussain6d2a3322013-11-17 19:50:10 -080012132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 return eHAL_STATUS_FAILURE;
12134 }
12135
12136 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
12137 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012139 return eHAL_STATUS_FAILURE;
12140 }
12141
12142 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
12143 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 return eHAL_STATUS_FAILURE;
12146 }
12147
12148 // Register as a wireless device
12149 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12150
12151 EXIT();
12152 return 0;
12153}
12154
12155int hdd_UnregisterWext(struct net_device *dev)
12156{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070012157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053012158 if (dev != NULL)
12159 {
12160 rtnl_lock();
12161 dev->wireless_handlers = NULL;
12162 rtnl_unlock();
12163 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053012164
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 return 0;
12166}
12167
12168