blob: c08dd6e8f0facbce0095c52716434ad9f5297e26 [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
1218static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1219{
1220 struct statsContext *pStatsContext;
1221 hdd_adapter_t *pAdapter;
1222 if (ioctl_debug)
1223 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001224 pr_info("%s: rssi [%d] STA [%d] pContext [%pK]\n",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001225 __func__, (int)rssi, (int)staId, pContext);
1226 }
1227
1228 if (NULL == pContext)
1229 {
1230 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001231 "%s: Bad param, pContext [%pK]",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001232 __func__, pContext);
1233 return;
1234 }
1235
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001236 pStatsContext = pContext;
1237 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001238
1239 /* there is a race condition that exists between this callback
1240 function and the caller since the caller could time out either
1241 before or while this code is executing. we use a spinlock to
1242 serialize these actions */
1243 spin_lock(&hdd_context_lock);
1244
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001245 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1246 {
1247 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001248 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001249 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001250 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001251 __func__, pAdapter, pStatsContext->magic);
1252 if (ioctl_debug)
1253 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001254 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001255 __func__, pAdapter, pStatsContext->magic);
1256 }
1257 return;
1258 }
1259
Jeff Johnson72a40512013-12-19 10:14:15 -08001260 /* context is valid so caller is still waiting */
1261
1262 /* paranoia: invalidate the magic */
1263 pStatsContext->magic = 0;
1264
Sachin Ahujaa082b672015-10-05 19:51:31 +05301265 /* copy over the rssi.FW will return RSSI as -100
1266 * if there are no samples to calculate the average
1267 * RSSI
1268 */
1269 if (rssi != -100)
1270 pAdapter->rssi = rssi;
1271
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301272 if (pAdapter->rssi > 0)
1273 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001274 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001275 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001276
1277 /* serialization is complete */
1278 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001279}
1280
1281
1282
1283VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1284{
1285 struct statsContext context;
1286 hdd_context_t *pHddCtx = NULL;
1287 hdd_station_ctx_t *pHddStaCtx = NULL;
1288 eHalStatus hstatus;
1289 long lrc;
1290
1291 if (NULL == pAdapter)
1292 {
1293 hddLog(VOS_TRACE_LEVEL_WARN,
1294 "%s: Invalid context, pAdapter", __func__);
1295 return VOS_STATUS_E_FAULT;
1296 }
1297 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1298 {
1299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1300 /* return a cached value */
1301 *rssi_value = pAdapter->rssi;
1302 return VOS_STATUS_SUCCESS;
1303 }
1304
1305 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1306 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1307
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301308 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001309 {
1310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1311 /* return a cached value */
1312 *rssi_value = 0;
1313 return VOS_STATUS_SUCCESS;
1314 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301315
1316 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1317 {
1318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1319 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1320 *rssi_value = pAdapter->rssi;
1321 return VOS_STATUS_SUCCESS;
1322 }
1323
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001324 init_completion(&context.completion);
1325 context.pAdapter = pAdapter;
1326 context.magic = RSSI_CONTEXT_MAGIC;
1327
1328 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1329 pHddStaCtx->conn_info.staId[ 0 ],
1330 pHddStaCtx->conn_info.bssId,
1331 &context, pHddCtx->pvosContext);
1332 if (eHAL_STATUS_SUCCESS != hstatus)
1333 {
1334 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1335 __func__);
1336 /* we'll returned a cached value below */
1337 }
1338 else
1339 {
1340 /* request was sent -- wait for the response */
1341 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1342 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001343 if (lrc <= 0)
1344 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001345 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001346 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001347 /* we'll now returned a cached value below */
1348 }
1349 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001350
1351 /* either we never sent a request, we sent a request and received a
1352 response or we sent a request and timed out. if we never sent a
1353 request or if we sent a request and got a response, we want to
1354 clear the magic out of paranoia. if we timed out there is a
1355 race condition such that the callback function could be
1356 executing at the same time we are. of primary concern is if the
1357 callback function had already verified the "magic" but had not
1358 yet set the completion variable when a timeout occurred. we
1359 serialize these activities by invalidating the magic while
1360 holding a shared spinlock which will cause us to block if the
1361 callback is currently executing */
1362 spin_lock(&hdd_context_lock);
1363 context.magic = 0;
1364 spin_unlock(&hdd_context_lock);
1365
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001366 *rssi_value = pAdapter->rssi;
1367
1368 return VOS_STATUS_SUCCESS;
1369}
1370#endif
1371
1372
Jeff Johnson295189b2012-06-20 16:38:30 -07001373void hdd_StatisticsCB( void *pStats, void *pContext )
1374{
1375 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1376 hdd_stats_t *pStatsCache = NULL;
1377 hdd_wext_state_t *pWextState;
1378 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1379
1380 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1381 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1382 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1383 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1384 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1385 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1386
1387 if (pAdapter!= NULL)
1388 pStatsCache = &pAdapter->hdd_stats;
1389
1390
1391 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1392 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1393 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1394 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1395 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1396 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1397
1398 if (pStatsCache!=NULL)
1399 {
1400 // and copy the stats into the cache we keep in the adapter instance structure
1401 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1402 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1403 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1404 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1405 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1406 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1407 }
1408
1409 if(pAdapter)
1410 {
1411 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1412 if(pWextState)
1413 {
1414 vos_status = vos_event_set(&pWextState->vosevent);
1415 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1416 {
1417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001418 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 return;
1420 }
1421 }
1422 }
1423}
1424
1425void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1426{
1427 v_CONTEXT_t pVosContext;
1428 hdd_context_t *pHddCtx;
1429 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1430#if 0
1431 hdd_wext_state_t *pWextState;
1432 v_U32_t roamId;
1433#endif
1434
1435 ENTER();
1436
1437 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1438
1439 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1440 if (NULL == pHddCtx)
1441 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001442 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 return;
1444 }
1445#if 0
1446 pWextState = pAdapter->pWextState;
1447#endif
1448
1449 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1450 {
1451 //TODO Verify is this is really used. If yes need to fix it.
1452 hdd_reconnect_all_adapters( pHddCtx );
1453#if 0
1454 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1455 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1456 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1457
1458 if(VOS_STATUS_SUCCESS == vosStatus)
1459 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1460 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1461
1462 sme_RoamConnect(halHandle,
1463 pAdapter->sessionId, &(pWextState->roamProfile),
1464 &roamId);
1465#endif
1466 }
1467
1468 EXIT();
1469
1470}
1471
1472void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1473{
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1475
1476 /* clear WPA/RSN/WSC IE information in the profile */
1477 pWextState->roamProfile.nWPAReqIELength = 0;
1478 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1479 pWextState->roamProfile.nRSNReqIELength = 0;
1480 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1481
Chet Lanctot186b5732013-03-18 10:26:30 -07001482#ifdef FEATURE_WLAN_WAPI
1483 pWextState->roamProfile.nWAPIReqIELength = 0;
1484 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1485#endif
1486
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001488 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301490 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1492 pWextState->roamProfile.nAddIEAssocLength = 0;
1493
1494 pWextState->roamProfile.EncryptionType.numEntries = 1;
1495 pWextState->roamProfile.EncryptionType.encryptionType[0]
1496 = eCSR_ENCRYPT_TYPE_NONE;
1497
1498 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1499 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1500 = eCSR_ENCRYPT_TYPE_NONE;
1501
1502 pWextState->roamProfile.AuthType.numEntries = 1;
1503 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1504
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301505 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001506#ifdef WLAN_FEATURE_11W
1507 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1508 pWextState->roamProfile.MFPRequired = 0;
1509 pWextState->roamProfile.MFPCapable = 0;
1510#endif
1511
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 pWextState->authKeyMgmt = 0;
1513
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301514 vos_mem_zero(&pWextState->roamProfile.Keys,
1515 sizeof(pWextState->roamProfile.Keys));
1516
Jeff Johnson295189b2012-06-20 16:38:30 -07001517#ifdef FEATURE_WLAN_WAPI
1518 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1519 pAdapter->wapi_info.nWapiMode = 0;
1520#endif
1521
1522 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1523
1524}
1525
1526void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1527{
1528 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Nirav Shahf6bd2672015-03-11 12:53:15 +05301530 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001531 {
1532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301533 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001534 }
1535 else
1536 {
1537 complete(&pAdapter->ula_complete);
1538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001539}
1540
1541VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1542{
1543 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001545 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001546
1547 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1548 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001549 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
1551 /*To avoid race condition between the set key and the last EAPOL
1552 packet, notify TL to finish upper layer authentication incase if the
1553 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001554 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001555
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001556 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 {
1558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1559 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1560 __LINE__, vos_status );
1561 return vos_status;
1562
1563 }
1564
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001565 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301567 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001568 {
1569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301570 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001571 /* we'll still fall through and return success since the
1572 * connection may still get established but is just taking
1573 * too long for us to wait */
1574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 }
1576 return VOS_STATUS_SUCCESS;
1577}
1578
1579v_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)
1580{
1581
1582 int left = ie_len;
1583 v_U8_t *ptr = ie;
1584 v_U8_t elem_id,elem_len;
1585 v_U8_t eid = 0xDD;
1586
1587 if ( NULL == ie || 0 == ie_len )
1588 return NULL;
1589
1590 while(left >= 2)
1591 {
1592 elem_id = ptr[0];
1593 elem_len = ptr[1];
1594 left -= 2;
1595 if(elem_len > left)
1596 {
1597 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001598 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 eid,elem_len,left);
1600 return NULL;
1601 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301602 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 {
1604 if(memcmp( &ptr[2], oui, oui_size)==0)
1605 return ptr;
1606 }
1607
1608 left -= elem_len;
1609 ptr += (elem_len + 2);
1610 }
1611 return NULL;
1612}
1613
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301614static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 union iwreq_data *wrqu, char *extra)
1616{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301617 hdd_adapter_t *pAdapter;
1618 hdd_context_t *pHddCtx;
1619 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301620
1621 ENTER();
1622
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301623 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1624 if (NULL == pAdapter)
1625 {
1626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1627 "%s: pAdapter is NULL\n", __func__);
1628 return -EINVAL;
1629 }
1630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1631 ret = wlan_hdd_validate_context(pHddCtx);
1632 if (0 != ret)
1633 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301634 return ret;
1635 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301636
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301638
1639 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301640 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641}
1642
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301643static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1644 union iwreq_data *wrqu, char *extra)
1645{
1646 int ret;
1647
1648 vos_ssr_protect(__func__);
1649 ret = __iw_set_commit(dev, info, wrqu, extra);
1650 vos_ssr_unprotect(__func__);
1651
1652 return ret;
1653}
1654
1655static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 struct iw_request_info *info,
1657 char *wrqu, char *extra)
1658{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301659 hdd_adapter_t *pAdapter;
1660 hdd_context_t *pHddCtx;
1661 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301662
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301664 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1665 if (NULL == pAdapter)
1666 {
1667 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1668 "%s: pAdapter is NULL\n", __func__);
1669 return -EINVAL;
1670 }
1671 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1672 ret = wlan_hdd_validate_context(pHddCtx);
1673 if (0 != ret)
1674 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301675 return ret;
1676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1678 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301679 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001680}
1681
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301682static int iw_get_name(struct net_device *dev,
1683 struct iw_request_info *info,
1684 char *wrqu, char *extra)
1685{
1686 int ret;
1687
1688 vos_ssr_protect(__func__);
1689 ret = __iw_get_name(dev, info, wrqu, extra);
1690 vos_ssr_unprotect(__func__);
1691
1692 return ret;
1693}
1694
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301695static int __iw_set_mode(struct net_device *dev,
1696 struct iw_request_info *info,
1697 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001698{
1699 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301700 hdd_adapter_t *pAdapter;
1701 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 tCsrRoamProfile *pRoamProfile;
1703 eCsrRoamBssType LastBSSType;
1704 eMib_dot11DesiredBssType connectedBssType;
1705 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301707 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001708
1709 ENTER();
1710
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301711 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 if (NULL == pAdapter)
1713 {
1714 hddLog(VOS_TRACE_LEVEL_WARN,
1715 "%s: Invalid context, pAdapter", __func__);
1716 return 0;
1717 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301718 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1719 status = wlan_hdd_validate_context(pHddCtx);
1720 if (0 != status)
1721 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301722 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 }
1724
1725 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1726 if (pWextState == NULL)
1727 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301728 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 return -EINVAL;
1730 }
1731
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 pRoamProfile = &pWextState->roamProfile;
1734 LastBSSType = pRoamProfile->BSSType;
1735
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301736 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001737
1738 switch (wrqu->mode)
1739 {
1740 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301741 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1743 // Set the phymode correctly for IBSS.
1744 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1745 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001746 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 break;
1749 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301750 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 break;
1754 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301755 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1757 break;
1758 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301759 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 return -EOPNOTSUPP;
1761 }
1762
1763 if ( LastBSSType != pRoamProfile->BSSType )
1764 {
1765 //the BSS mode changed
1766 // We need to issue disconnect if connected or in IBSS disconnect state
1767 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1768 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1769 {
1770 VOS_STATUS vosStatus;
1771 // need to issue a disconnect to CSR.
1772 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1773 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1774 pAdapter->sessionId,
1775 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1776 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301777 {
1778 long ret;
1779 ret = wait_for_completion_interruptible_timeout(
1780 &pAdapter->disconnect_comp_var,
1781 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1782 if (ret <= 0)
1783 hddLog(VOS_TRACE_LEVEL_ERROR,
1784 FL("failed wait on disconnect_comp_var %ld"), ret);
1785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 }
1787 }
1788
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 EXIT();
1790 return 0;
1791}
1792
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301793static int iw_set_mode(struct net_device *dev,
1794 struct iw_request_info *info,
1795 union iwreq_data *wrqu, char *extra)
1796{
1797 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301799 vos_ssr_protect(__func__);
1800 ret = __iw_set_mode(dev, info, wrqu, extra);
1801 vos_ssr_unprotect(__func__);
1802
1803 return ret;
1804}
1805
1806static int __iw_get_mode(struct net_device *dev,
1807 struct iw_request_info *info,
1808 union iwreq_data *wrqu,
1809 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001810{
1811
1812 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301813 hdd_adapter_t *pAdapter;
1814 hdd_context_t *pHddCtx;
1815 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001816
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301817 ENTER();
1818
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301819 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 if (NULL == pAdapter)
1821 {
1822 hddLog(VOS_TRACE_LEVEL_WARN,
1823 "%s: Invalid context, pAdapter", __func__);
1824 return 0;
1825 }
1826
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301827 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1828 ret = wlan_hdd_validate_context(pHddCtx);
1829 if (0 != ret)
1830 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301831 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1834 if (pWextState == NULL)
1835 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301836 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 return -EINVAL;
1838 }
1839
1840 switch (pWextState->roamProfile.BSSType)
1841 {
1842 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001843 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301844 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 break;
1846 case eCSR_BSS_TYPE_IBSS:
1847 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001848 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301849 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 break;
1851 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001852 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301853 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 break;
1855 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001856 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 break;
1858 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301859
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301860 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 return 0;
1862}
1863
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301864static int iw_get_mode(struct net_device *dev,
1865 struct iw_request_info *info,
1866 union iwreq_data *wrqu,
1867 char *extra)
1868{
1869 int ret;
1870
1871 vos_ssr_protect(__func__);
1872 ret = __iw_get_mode(dev, info, wrqu, extra);
1873 vos_ssr_unprotect(__func__);
1874
1875 return ret;
1876}
1877
1878static int __iw_set_freq(struct net_device *dev,
1879 struct iw_request_info *info,
1880 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001881{
1882 v_U32_t numChans = 0;
1883 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1884 v_U32_t indx = 0;
1885 v_U32_t status = 0;
1886
1887 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301888 hdd_adapter_t *pAdapter;
1889 hdd_context_t *pHddCtx;
1890 tHalHandle hHal;
1891 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301893
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 ENTER();
1895
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301896 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1897 if (NULL == pAdapter)
1898 {
1899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1900 "%s:Invalid Adapter",__func__);
1901 return -EINVAL;
1902 }
1903
1904 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1905 status = wlan_hdd_validate_context(pHddCtx);
1906 if (0 != status)
1907 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 return status;
1909 }
1910
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301911 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1912 if (NULL == hHal)
1913 {
1914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1915 "%s: Hal Context is NULL",__func__);
1916 return -EINVAL;
1917 }
1918
1919 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1920 if (NULL == pHddStaCtx)
1921 {
1922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1923 "%s:STA context is NULL",__func__);
1924 return -EINVAL;
1925 }
1926
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301928 if (NULL == pWextState)
1929 {
1930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1931 "%s: pWextState is NULL",__func__);
1932 return -EINVAL;
1933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001934
1935 pRoamProfile = &pWextState->roamProfile;
1936
Arif Hussain6d2a3322013-11-17 19:50:10 -08001937 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001938
1939 /* Link is up then return cant set channel*/
1940 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1941 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1942 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001943 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 return -EOPNOTSUPP;
1945 }
1946
1947 /* Settings by Frequency as input */
1948 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1949 (wrqu->freq.m <= (tANI_U32)5.825e8))
1950 {
1951 tANI_U32 freq = wrqu->freq.m / 100000;
1952
1953 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1954 indx++;
1955 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1956 {
1957 return -EINVAL;
1958 }
1959 wrqu->freq.e = 0;
1960 wrqu->freq.m = freq_chan_map[indx].chan;
1961
1962 }
1963
1964 if (wrqu->freq.e == 0)
1965 {
1966 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1967 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1968 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001969 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001970 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1972 return -EINVAL;
1973 }
1974
1975 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1976
1977 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1978 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1980 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 return -EIO;
1982 }
1983
1984 for (indx = 0; indx < numChans; indx++) {
1985 if (wrqu->freq.m == validChan[indx]){
1986 break;
1987 }
1988 }
1989 }
1990 else{
1991
1992 return -EINVAL;
1993 }
1994
1995 if(indx >= numChans)
1996 {
1997 return -EINVAL;
1998 }
1999
2000 /* Set the Operational Channel */
2001 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2002 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2003 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
2004
Arif Hussain6d2a3322013-11-17 19:50:10 -08002005 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07002006
2007 EXIT();
2008
2009 return status;
2010}
2011
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302012static int iw_set_freq(struct net_device *dev,
2013 struct iw_request_info *info,
2014 union iwreq_data *wrqu, char *extra)
2015{
2016 int ret;
2017
2018 vos_ssr_protect(__func__);
2019 ret = __iw_set_freq(dev, info, wrqu, extra);
2020 vos_ssr_unprotect(__func__);
2021
2022 return ret;
2023}
2024
2025static int __iw_get_freq(struct net_device *dev,
2026 struct iw_request_info *info,
2027 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002028{
Jeff Johnsone7245742012-09-05 17:12:55 -07002029 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302030 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 tHalHandle hHal;
2032 hdd_wext_state_t *pWextState;
2033 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302034 hdd_station_ctx_t *pHddStaCtx;
2035 hdd_context_t *pHddCtx;
2036 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 ENTER();
2039
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302040 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2041 if (NULL == pAdapter)
2042 {
2043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2044 "%s: Adapter is NULL", __func__);
2045 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302047 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2048 ret = wlan_hdd_validate_context(pHddCtx);
2049 if (0 != ret)
2050 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302051 return ret;
2052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302054 if (NULL == hHal)
2055 {
2056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2057 "%s: Hal Context is NULL",__func__);
2058 return -EINVAL;
2059 }
2060 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2061 if (NULL == pHddStaCtx)
2062 {
2063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2064 "%s: HddStaCtx is NULL", __func__);
2065 return -EINVAL;
2066 }
2067 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2068 if (NULL == pWextState)
2069 {
2070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2071 "%s: pWextState is NULL",__func__);
2072 return -EINVAL;
2073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 pRoamProfile = &pWextState->roamProfile;
2075
2076 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2077 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002078 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 {
c_hpothub8245442013-11-20 23:41:09 +05302080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2081 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 return -EIO;
2083 }
2084 else
2085 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002086 status = hdd_wlan_get_freq(channel, &freq);
2087 if( TRUE == status )
2088 {
2089 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2090 * iwlist & iwconfig command shows frequency into proper
2091 * format (2.412 GHz instead of 246.2 MHz)*/
2092 fwrq->m = freq;
2093 fwrq->e = MHZ;
2094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 }
2096 }
2097 else
2098 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002099 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2100 * iwlist & iwconfig command shows frequency into proper
2101 * format (2.412 GHz instead of 246.2 MHz)*/
2102 fwrq->m = 0;
2103 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302105
2106 EXIT();
2107 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002108}
2109
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302110static int iw_get_freq(struct net_device *dev,
2111 struct iw_request_info *info,
2112 struct iw_freq *fwrq, char *extra)
2113{
2114 int ret;
2115
2116 vos_ssr_protect(__func__);
2117 ret = __iw_get_freq(dev, info, fwrq, extra);
2118 vos_ssr_unprotect(__func__);
2119
2120 return ret;
2121}
2122
2123static int __iw_get_tx_power(struct net_device *dev,
2124 struct iw_request_info *info,
2125 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002126{
2127
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302128 hdd_adapter_t *pAdapter;
2129 hdd_context_t *pHddCtx;
2130 hdd_station_ctx_t *pHddStaCtx;
2131 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002132
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302133 ENTER();
2134
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302135 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2136 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2139 "%s: Adapter is NULL",__func__);
2140 return -EINVAL;
2141 }
2142 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2143 ret = wlan_hdd_validate_context(pHddCtx);
2144 if (0 != ret)
2145 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302146 return ret;
2147 }
2148
2149 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2150 if (NULL == pHddStaCtx)
2151 {
2152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2153 "%s: STA Context is NULL",__func__);
2154 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 }
2156
2157 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2158 {
2159 wrqu->txpower.value = 0;
2160 return 0;
2161 }
2162 wlan_hdd_get_classAstats(pAdapter);
2163 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2164
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302165 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 return 0;
2167}
2168
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302169static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 struct iw_request_info *info,
2171 union iwreq_data *wrqu, char *extra)
2172{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302173 int ret;
2174
2175 vos_ssr_protect(__func__);
2176 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2177 vos_ssr_unprotect(__func__);
2178
2179 return ret;
2180}
2181
2182static int __iw_set_tx_power(struct net_device *dev,
2183 struct iw_request_info *info,
2184 union iwreq_data *wrqu, char *extra)
2185{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302186 hdd_adapter_t *pAdapter;
2187 tHalHandle hHal;
2188 hdd_context_t *pHddCtx;
2189 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190
2191 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302192 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2193 if (NULL == pAdapter)
2194 {
2195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2196 "%s: Adapter is NULL",__func__);
2197 return -EINVAL;
2198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002199
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302200 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2201 ret = wlan_hdd_validate_context(pHddCtx);
2202 if (0 != ret)
2203 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302204 return ret;
2205 }
2206
2207 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2208 if (NULL == hHal)
2209 {
2210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2211 "%s: Hal Context is NULL",__func__);
2212 return -EINVAL;
2213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2215 {
c_hpothub8245442013-11-20 23:41:09 +05302216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2217 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 return -EIO;
2219 }
2220
2221 EXIT();
2222
2223 return 0;
2224}
2225
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302226static int iw_set_tx_power(struct net_device *dev,
2227 struct iw_request_info *info,
2228 union iwreq_data *wrqu, char *extra)
2229{
2230 int ret;
2231
2232 vos_ssr_protect(__func__);
2233 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2234 vos_ssr_unprotect(__func__);
2235
2236 return ret;
2237}
2238
2239static int __iw_get_bitrate(struct net_device *dev,
2240 struct iw_request_info *info,
2241 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002242{
2243 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2244 eHalStatus status = eHAL_STATUS_SUCCESS;
2245 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302246 hdd_adapter_t *pAdapter;
2247 hdd_context_t *pHddCtx;
2248 hdd_station_ctx_t *pHddStaCtx;
2249 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002250
2251 ENTER();
2252
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302253 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2254 if (NULL == pAdapter)
2255 {
2256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2257 "%s: Adapter is NULL",__func__);
2258 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 }
2260
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302261 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2262 ret = wlan_hdd_validate_context(pHddCtx);
2263 if (0 != ret)
2264 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302265 return ret;
2266 }
2267
2268 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2269 if (NULL == pHddStaCtx)
2270 {
2271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2272 "%s: STA Context is NULL",__func__);
2273 return -EINVAL;
2274 }
2275
2276 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 wrqu->bitrate.value = 0;
2278 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302279 else
2280 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2282 SME_SUMMARY_STATS |
2283 SME_GLOBAL_CLASSA_STATS |
2284 SME_GLOBAL_CLASSB_STATS |
2285 SME_GLOBAL_CLASSC_STATS |
2286 SME_GLOBAL_CLASSD_STATS |
2287 SME_PER_STA_STATS,
2288 hdd_StatisticsCB, 0, FALSE,
2289 pHddStaCtx->conn_info.staId[0], pAdapter );
2290
2291 if(eHAL_STATUS_SUCCESS != status)
2292 {
2293 hddLog(VOS_TRACE_LEVEL_ERROR,
2294 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002295 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 return status;
2297 }
2298
2299 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302300 if (NULL == pWextState)
2301 {
2302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2303 "%s: pWextState is NULL",__func__);
2304 return -EINVAL;
2305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002306
2307 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2308
2309 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2310 {
2311 hddLog(VOS_TRACE_LEVEL_ERROR,
2312 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002313 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 return VOS_STATUS_E_FAILURE;
2315 }
2316
2317 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2318 }
2319
2320 EXIT();
2321
2322 return vos_status;
2323}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302324
2325static int iw_get_bitrate(struct net_device *dev,
2326 struct iw_request_info *info,
2327 union iwreq_data *wrqu, char *extra)
2328{
2329 int ret;
2330
2331 vos_ssr_protect(__func__);
2332 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2333 vos_ssr_unprotect(__func__);
2334
2335 return ret;
2336}
2337
2338
Jeff Johnson295189b2012-06-20 16:38:30 -07002339/* ccm call back function */
2340
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302341static int __iw_set_bitrate(struct net_device *dev,
2342 struct iw_request_info *info,
2343 union iwreq_data *wrqu,
2344 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002345{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302348 hdd_station_ctx_t *pHddStaCtx;
2349 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2351 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2352 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2353 v_U32_t i, rate;
2354 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302355 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002356
2357 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302358 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2359 if (NULL == pAdapter)
2360 {
2361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2362 "%s: Adapter is NULL",__func__);
2363 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 }
2365
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302366 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2367 ret = wlan_hdd_validate_context(pHddCtx);
2368 if (0 != ret)
2369 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302370 return ret;
2371 }
2372
2373 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2374 if (NULL == pHddStaCtx)
2375 {
2376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2377 "%s: STA Context is NULL",__func__);
2378 return -EINVAL;
2379 }
2380
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302383 if (NULL == pWextState)
2384 {
2385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2386 "%s: pWextState is NULL",__func__);
2387 return -EINVAL;
2388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002389
2390 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2391 {
2392 return -ENXIO ;
2393 }
2394
2395 rate = wrqu->bitrate.value;
2396
2397 if (rate == -1)
2398 {
2399 rate = WNI_CFG_FIXED_RATE_AUTO;
2400 valid_rate = TRUE;
2401 }
2402 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2403 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2404 {
2405 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2406 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2407 {
2408 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2409 WNI_CFG_SUPPORTED_RATES_11A,
2410 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2411 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2412 WNI_CFG_SUPPORTED_RATES_11B,
2413 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2414 {
2415 for (i = 0; i < (b_len + a_len); ++i)
2416 {
2417 /* supported rates returned is double the actual rate so we divide it by 2 */
2418 if ((supp_rates[i]&0x7F)/2 == rate)
2419 {
2420 valid_rate = TRUE;
2421 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2422 break;
2423 }
2424 }
2425 }
2426 }
2427 }
2428 if (valid_rate != TRUE)
2429 {
2430 return -EINVAL;
2431 }
2432 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2433 WNI_CFG_FIXED_RATE, rate,
2434 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2435 {
c_hpothub8245442013-11-20 23:41:09 +05302436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2437 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 return -EIO;
2439 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302440
2441 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 return 0;
2443}
2444
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302445static int iw_set_bitrate(struct net_device *dev,
2446 struct iw_request_info *info,
2447 union iwreq_data *wrqu,
2448 char *extra)
2449{
2450 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302452 vos_ssr_protect(__func__);
2453 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2454 vos_ssr_unprotect(__func__);
2455
2456 return ret;
2457}
2458
2459static int __iw_set_genie(struct net_device *dev,
2460 struct iw_request_info *info,
2461 union iwreq_data *wrqu,
2462 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002463{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302464 hdd_adapter_t *pAdapter;
2465 hdd_context_t *pHddCtx;
2466 hdd_wext_state_t *pWextState;
2467 u_int8_t *genie = NULL;
2468 u_int8_t *base_genie = NULL;
2469 v_U16_t remLen;
2470 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002471
2472 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002473
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302474 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2475 if (NULL == pAdapter)
2476 {
2477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2478 "%s: Adapter is NULL",__func__);
2479 return -EINVAL;
2480 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002481
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302482 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2483 ret = wlan_hdd_validate_context(pHddCtx);
2484 if (0 != ret)
2485 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302486 return ret;
2487 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002488
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302489 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2490 if (NULL == pWextState)
2491 {
2492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2493 "%s: pWextState is NULL",__func__);
2494 return -EINVAL;
2495 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002496
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 if (!wrqu->data.length) {
2498 hdd_clearRoamProfileIe(pAdapter);
2499 EXIT();
2500 return 0;
2501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002502
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302503 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2504 wrqu->data.length);
2505 if (NULL == base_genie)
2506 {
2507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2508 "mem_alloc_copy_from_user_helper fail");
2509 return -ENOMEM;
2510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302512 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002513
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302514 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002515
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302516 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2517
2518 /* clear any previous genIE before this call */
2519 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2520
2521 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 {
2523 v_U16_t eLen = 0;
2524 v_U8_t elementId;
2525 elementId = *genie++;
2526 eLen = *genie++;
2527 remLen -= 2;
2528
Arif Hussain6d2a3322013-11-17 19:50:10 -08002529 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 __func__, elementId, eLen);
2531
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302532 if (remLen < eLen) {
2533 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2534 remLen, eLen);
2535 ret = -EINVAL;
2536 goto exit;
2537 }
2538
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 switch ( elementId )
2540 {
2541 case IE_EID_VENDOR:
2542 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002543 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302544 ret = -EINVAL;
2545 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
2548 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2549 {
2550 v_U16_t curGenIELen = pWextState->genIE.length;
2551 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2552 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2553
2554 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2555 {
2556 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002557 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302559 ret = -EINVAL;
2560 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 }
2562 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2563 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2564 pWextState->genIE.length += eLen + 2;
2565 }
2566 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2567 {
2568 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302569 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2570 {
2571 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2572 "Need bigger buffer space");
2573 ret = -EINVAL;
2574 VOS_ASSERT(0);
2575 goto exit;
2576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2578 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2579 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2580 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2581 }
2582 else /* any vendorId except WPA IE should be accumulated to genIE */
2583 {
2584 v_U16_t curGenIELen = pWextState->genIE.length;
2585 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2586 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2587
2588 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2589 {
2590 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002591 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302593 ret = -ENOMEM;
2594 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 }
2596 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2597 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2598 pWextState->genIE.length += eLen + 2;
2599 }
2600 break;
2601 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002602 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302603 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2604 {
2605 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2606 "Need bigger buffer space");
2607 ret = -EINVAL;
2608 VOS_ASSERT(0);
2609 goto exit;
2610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2612 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2613 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2614 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2615 break;
2616
2617 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002618 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302619 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302622
2623 /* Move genie only if next element is present */
2624 if (remLen >= 2)
2625 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302627
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302628exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002630 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302631 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002632}
2633
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302634static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 struct iw_request_info *info,
2636 union iwreq_data *wrqu,
2637 char *extra)
2638{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302639 int ret;
2640
2641 vos_ssr_protect(__func__);
2642 ret = __iw_set_genie(dev, info, wrqu, extra);
2643 vos_ssr_unprotect(__func__);
2644
2645 return ret;
2646}
2647
2648static int __iw_get_genie(struct net_device *dev,
2649 struct iw_request_info *info,
2650 union iwreq_data *wrqu,
2651 char *extra)
2652{
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302654 hdd_context_t *pHddCtx;
2655 hdd_adapter_t *pAdapter;
2656 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 eHalStatus status;
2658 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2659 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2660
2661 ENTER();
2662
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302663 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2664 if (NULL == pAdapter)
2665 {
2666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2667 "%s: Adapter is NULL",__func__);
2668 return -EINVAL;
2669 }
2670 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2671 status = wlan_hdd_validate_context(pHddCtx);
2672 if (0 != status)
2673 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302674 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 }
2676
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302678 if (NULL == pWextState)
2679 {
2680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2681 "%s: pWextState is NULL",__func__);
2682 return -EINVAL;
2683 }
2684
2685 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2686 if (NULL == pHddStaCtx)
2687 {
2688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2689 "%s: STA Context is NULL",__func__);
2690 return -EINVAL;
2691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002692
2693 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2694 {
2695 return -ENXIO;
2696 }
2697
2698 // Return something ONLY if we are associated with an RSN or WPA network
2699 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2700 pWextState->roamProfile.negotiatedAuthType))
2701 {
2702 return -ENXIO;
2703 }
2704
2705 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2706 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2707 pAdapter->sessionId,
2708 &length,
2709 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302710 if (eHAL_STATUS_SUCCESS != status) {
2711 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002712 return -EFAULT;
2713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002714
Manjeet Singh715d47e2016-08-02 19:08:02 +05302715 wrqu->data.length = length;
2716 if (length > DOT11F_IE_RSN_MAX_LEN) {
2717 hddLog(LOGE,
2718 FL("invalid buffer length length:%d"), length);
2719 return -E2BIG;
2720 }
2721
2722 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2723
2724 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 EXIT();
2727
2728 return 0;
2729}
2730
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302731static int iw_get_genie(struct net_device *dev,
2732 struct iw_request_info *info,
2733 union iwreq_data *wrqu,
2734 char *extra)
2735{
2736 int ret;
2737
2738 vos_ssr_protect(__func__);
2739 ret = __iw_get_genie(dev, info, wrqu, extra);
2740 vos_ssr_unprotect(__func__);
2741
2742 return ret;
2743}
2744
2745
2746static int __iw_get_encode(struct net_device *dev,
2747 struct iw_request_info *info,
2748 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002749{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302750 hdd_adapter_t *pAdapter;
2751 hdd_context_t *pHddCtx;
2752 hdd_wext_state_t *pWextState;
2753 tCsrRoamProfile *pRoamProfile;
2754 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002756
2757 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302758 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2759 if (NULL == pAdapter)
2760 {
2761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2762 "%s: Adapter is NULL",__func__);
2763 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 }
2765
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302766 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2767 ret = wlan_hdd_validate_context(pHddCtx);
2768 if (0 != ret)
2769 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302770 return ret;
2771 }
2772 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2773 if (NULL == pWextState)
2774 {
2775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2776 "%s: pWextState is NULL",__func__);
2777 return -EINVAL;
2778 }
2779
2780 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 keyId = pRoamProfile->Keys.defaultIndex;
2782
2783 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2784 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002785 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 return -EINVAL;
2787 }
2788
2789 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2790 {
2791 dwrq->flags |= IW_ENCODE_ENABLED;
2792 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2793 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2794
2795 dwrq->flags |= (keyId + 1);
2796
2797 }
2798 else
2799 {
2800 dwrq->flags |= IW_ENCODE_DISABLED;
2801 }
2802
2803 for(i=0; i < MAX_WEP_KEYS; i++)
2804 {
2805 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2806 {
2807 continue;
2808 }
2809 else
2810 {
2811 break;
2812 }
2813 }
2814
2815 if(MAX_WEP_KEYS == i)
2816 {
2817 dwrq->flags |= IW_ENCODE_NOKEY;
2818 }
2819
2820 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2821
2822 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2823 {
2824 dwrq->flags |= IW_ENCODE_OPEN;
2825 }
2826 else
2827 {
2828 dwrq->flags |= IW_ENCODE_RESTRICTED;
2829 }
2830 EXIT();
2831 return 0;
2832}
2833
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302834static int iw_get_encode(struct net_device *dev,
2835 struct iw_request_info *info,
2836 struct iw_point *dwrq, char *extra)
2837{
2838 int ret;
2839
2840 vos_ssr_protect(__func__);
2841 ret = __iw_get_encode(dev, info, dwrq, extra);
2842 vos_ssr_unprotect(__func__);
2843
2844 return ret;
2845}
2846
Jeff Johnson295189b2012-06-20 16:38:30 -07002847#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2848#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2849
2850
2851/*
2852 * This function sends a single 'key' to LIM at all time.
2853 */
2854
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302855static int __iw_get_rts_threshold(struct net_device *dev,
2856 struct iw_request_info *info,
2857 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002858{
2859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2860 v_U32_t status = 0;
2861
2862 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2863
2864 return status;
2865}
2866
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302867static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 struct iw_request_info *info,
2869 union iwreq_data *wrqu, char *extra)
2870{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302871 int ret;
2872
2873 vos_ssr_protect(__func__);
2874 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2875 vos_ssr_unprotect(__func__);
2876
2877 return ret;
2878}
2879
2880static int __iw_set_rts_threshold(struct net_device *dev,
2881 struct iw_request_info *info,
2882 union iwreq_data *wrqu, char *extra)
2883{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302884 hdd_adapter_t *pAdapter;
2885 hdd_context_t *pHddCtx;
2886 tHalHandle hHal;
2887 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002888
2889 ENTER();
2890
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302891 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2892 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002893 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2895 "%s: Adapter is NULL",__func__);
2896 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002897 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302898
2899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2900 ret = wlan_hdd_validate_context(pHddCtx);
2901 if (0 != ret)
2902 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302903 return ret;
2904 }
2905
2906 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2907 if (NULL == hHal)
2908 {
2909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2910 "%s: Hal Context is NULL",__func__);
2911 return -EINVAL;
2912 }
2913
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2915 {
2916 return -EINVAL;
2917 }
2918
2919 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2920 {
c_hpothub8245442013-11-20 23:41:09 +05302921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2922 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 return -EIO;
2924 }
2925
2926 EXIT();
2927
2928 return 0;
2929}
2930
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302931static int iw_set_rts_threshold(struct net_device *dev,
2932 struct iw_request_info *info,
2933 union iwreq_data *wrqu, char *extra)
2934{
2935 int ret;
2936
2937 vos_ssr_protect(__func__);
2938 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2939 vos_ssr_unprotect(__func__);
2940
2941 return ret;
2942}
2943
2944static int __iw_get_frag_threshold(struct net_device *dev,
2945 struct iw_request_info *info,
2946 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002947{
2948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2949 v_U32_t status = 0;
2950
2951 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2952
2953 return status;
2954}
2955
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302956static int iw_get_frag_threshold(struct net_device *dev,
2957 struct iw_request_info *info,
2958 union iwreq_data *wrqu, char *extra)
2959{
2960 int ret;
2961
2962 vos_ssr_protect(__func__);
2963 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2964 vos_ssr_unprotect(__func__);
2965
2966 return ret;
2967}
2968
2969static int __iw_set_frag_threshold(struct net_device *dev,
2970 struct iw_request_info *info,
2971 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002972{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302973 hdd_adapter_t *pAdapter;
2974 hdd_context_t *pHddCtx;
2975 tHalHandle hHal;
2976 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002977
2978 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2980 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002981 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2983 "%s: Adapter is NULL",__func__);
2984 return -EINVAL;
2985 }
2986
2987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2988 ret = wlan_hdd_validate_context(pHddCtx);
2989 if (0 != ret)
2990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302991 return ret;
2992 }
2993
2994 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2995 if (NULL == hHal)
2996 {
2997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2998 "%s: Hal Context is NULL",__func__);
2999 return -EINVAL;
3000 }
3001
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3003 {
3004 return -EINVAL;
3005 }
3006
3007 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3008 {
c_hpothub8245442013-11-20 23:41:09 +05303009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3010 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 return -EIO;
3012 }
3013
3014 EXIT();
3015
3016 return 0;
3017}
3018
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303019static int iw_set_frag_threshold(struct net_device *dev,
3020 struct iw_request_info *info,
3021 union iwreq_data *wrqu, char *extra)
3022{
3023 int ret;
3024
3025 vos_ssr_protect(__func__);
3026 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3027 vos_ssr_unprotect(__func__);
3028
3029 return ret;
3030}
3031
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303032static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 struct iw_request_info *info,
3034 union iwreq_data *wrqu, char *extra)
3035{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303036 hdd_adapter_t *pAdapter;
3037 hdd_context_t *pHddCtx;
3038 int ret = 0;
3039
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303041 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3042 if (NULL == pAdapter)
3043 {
3044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3045 "%s: Adapter is NULL",__func__);
3046 return -EINVAL;
3047 }
3048 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3049 ret = wlan_hdd_validate_context(pHddCtx);
3050 if (0 != ret)
3051 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303052 return ret;
3053 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303054
3055 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 return -EOPNOTSUPP;
3057}
3058
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303059static int iw_get_power_mode(struct net_device *dev,
3060 struct iw_request_info *info,
3061 union iwreq_data *wrqu, char *extra)
3062{
3063 int ret;
3064
3065 vos_ssr_protect(__func__);
3066 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3067 vos_ssr_unprotect(__func__);
3068
3069 return ret;
3070}
3071static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 struct iw_request_info *info,
3073 union iwreq_data *wrqu, char *extra)
3074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303075 hdd_adapter_t *pAdapter;
3076 hdd_context_t *pHddCtx;
3077 int ret = 0;
3078
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303080 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3081 if (NULL == pAdapter)
3082 {
3083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3084 "%s: Adapter is NULL",__func__);
3085 return -EINVAL;
3086 }
3087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3088 ret = wlan_hdd_validate_context(pHddCtx);
3089 if (0 != ret)
3090 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303091 return ret;
3092 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303093
3094 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 return -EOPNOTSUPP;
3096}
3097
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303098static int iw_set_power_mode(struct net_device *dev,
3099 struct iw_request_info *info,
3100 union iwreq_data *wrqu, char *extra)
3101{
3102 int ret;
3103
3104 vos_ssr_protect(__func__);
3105 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3106 vos_ssr_unprotect(__func__);
3107
3108 return ret;
3109}
3110
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303111static int __iw_get_range(struct net_device *dev,
3112 struct iw_request_info *info,
3113 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003114{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303115 hdd_adapter_t *pAdapter;
3116 tHalHandle hHal;
3117 hdd_context_t *pHddCtx;
3118 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 struct iw_range *range = (struct iw_range *) extra;
3120
3121 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3122
3123 v_U32_t num_channels = sizeof(channels);
3124 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3125 v_U32_t a_len;
3126 v_U32_t b_len;
3127 v_U32_t active_phy_mode = 0;
3128 v_U8_t index = 0, i;
3129
3130 ENTER();
3131
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303132 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3133 if (NULL == pAdapter)
3134 {
3135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3136 "%s: pAdapter is NULL", __func__);
3137 return -EINVAL;
3138 }
3139 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3140 ret = wlan_hdd_validate_context(pHddCtx);
3141 if (0 != ret)
3142 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303143 return ret;
3144 }
3145 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3146 if (NULL == hHal)
3147 {
3148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3149 "%s: pAdapter is NULL", __func__);
3150 return -EINVAL;
3151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 wrqu->data.length = sizeof(struct iw_range);
3153 memset(range, 0, sizeof(struct iw_range));
3154
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 /*Get the phy mode*/
3156 if (ccmCfgGetInt(hHal,
3157 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3158 {
3159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003160 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003161
3162 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3163 {
3164 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003165 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 if (ccmCfgGetStr(hHal,
3167 WNI_CFG_SUPPORTED_RATES_11A,
3168 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3169 {
3170 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3171 {
3172 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3173 }
3174 for (i = 0; i < a_len; i++)
3175 {
3176 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3177 }
3178 range->num_bitrates = a_len;
3179 }
3180 else
3181 {
3182 return -EIO;
3183 }
3184 }
3185 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3186 {
3187 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003188 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 if (ccmCfgGetStr(hHal,
3190 WNI_CFG_SUPPORTED_RATES_11B,
3191 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3192 {
3193 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3194 {
3195 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3196 }
3197 for (i = 0; i < b_len; i++)
3198 {
3199 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3200 }
3201 range->num_bitrates = b_len;
3202 }
3203 else
3204 {
3205 return -EIO;
3206 }
3207 }
3208 }
3209
3210 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3211 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3212 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3213
3214 range->encoding_size[0] = 5;
3215 range->encoding_size[1] = 13;
3216 range->num_encoding_sizes = 2;
3217 range->max_encoding_tokens = MAX_WEP_KEYS;
3218
3219 // we support through Wireless Extensions 22
3220 range->we_version_compiled = WIRELESS_EXT;
3221 range->we_version_source = 22;
3222
3223 /*Supported Channels and Frequencies*/
3224 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3225 {
c_hpothub8245442013-11-20 23:41:09 +05303226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3227 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 return -EIO;
3229 }
3230 if (num_channels > IW_MAX_FREQUENCIES)
3231 {
3232 num_channels = IW_MAX_FREQUENCIES;
3233 }
3234
3235 range->num_channels = num_channels;
3236 range->num_frequency = num_channels;
3237
3238 for (index=0; index < num_channels; index++)
3239 {
3240 v_U32_t frq_indx = 0;
3241
3242 range->freq[index].i = channels[index];
3243 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3244 {
3245 if(channels[index] == freq_chan_map[frq_indx].chan)
3246 {
3247 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3248 range->freq[index].e = 1;
3249 break;
3250 }
3251 frq_indx++;
3252 }
3253 }
3254
3255 /* Event capability (kernel + driver) */
3256 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3257 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3258 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3259 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3260
3261 /*Encryption capability*/
3262 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3263 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3264
3265 /* Txpower capability */
3266 range->txpower_capa = IW_TXPOW_MWATT;
3267
3268 /*Scanning capability*/
3269 #if WIRELESS_EXT >= 22
3270 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3271 #endif
3272
3273 EXIT();
3274 return 0;
3275}
3276
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303277static int iw_get_range(struct net_device *dev,
3278 struct iw_request_info *info,
3279 union iwreq_data *wrqu, char *extra)
3280{
3281 int ret;
3282
3283 vos_ssr_protect(__func__);
3284 ret = __iw_get_range(dev, info, wrqu, extra);
3285 vos_ssr_unprotect(__func__);
3286
3287 return ret;
3288}
3289
Jeff Johnson295189b2012-06-20 16:38:30 -07003290/* Callback function for tx per hit */
3291void hdd_tx_per_hit_cb (void *pCallbackContext)
3292{
3293 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3294 unsigned char tx_fail[16];
3295 union iwreq_data wrqu;
3296
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303297 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003299 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 return;
3301 }
3302 memset(&wrqu, 0, sizeof(wrqu));
3303 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3304 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3305}
3306
3307void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3308{
3309 struct statsContext *pStatsContext;
3310 tCsrGlobalClassAStatsInfo *pClassAStats;
3311 hdd_adapter_t *pAdapter;
3312
3313 if (ioctl_debug)
3314 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003315 pr_info("%s: pStats [%pK] pContext [%pK]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003316 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 }
3318
3319 if ((NULL == pStats) || (NULL == pContext))
3320 {
3321 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003322 "%s: Bad param, pStats [%pK] pContext [%pK]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003323 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 return;
3325 }
3326
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 pClassAStats = pStats;
3328 pStatsContext = pContext;
3329 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003330
3331 /* there is a race condition that exists between this callback
3332 function and the caller since the caller could time out either
3333 before or while this code is executing. we use a spinlock to
3334 serialize these actions */
3335 spin_lock(&hdd_context_lock);
3336
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3338 {
3339 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003340 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003342 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003343 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 if (ioctl_debug)
3345 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003346 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003347 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 }
3349 return;
3350 }
3351
Jeff Johnson72a40512013-12-19 10:14:15 -08003352 /* context is valid so caller is still waiting */
3353
3354 /* paranoia: invalidate the magic */
3355 pStatsContext->magic = 0;
3356
3357 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3359
Jeff Johnson72a40512013-12-19 10:14:15 -08003360 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003362
3363 /* serialization is complete */
3364 spin_unlock(&hdd_context_lock);
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303365
3366}
3367
3368struct stats_class_a_ctx {
3369 tCsrGlobalClassAStatsInfo class_a_stats;
3370};
3371
3372void hdd_get_class_a_statistics_cb(void *stats, void *context)
3373{
3374 struct hdd_request *request;
3375 struct stats_class_a_ctx *priv;
3376
3377 if (ioctl_debug) {
3378 pr_info("%s: stats [%pK] context [%pK]\n",
3379 __func__, stats, context);
3380 }
3381
3382 if (NULL == stats) {
3383 hddLog(VOS_TRACE_LEVEL_ERROR,
3384 "%s: Bad param, stats [%pK]",
3385 __func__, stats);
3386 return;
3387 }
3388
3389 request = hdd_request_get(context);
3390 if (!request) {
3391 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3392 return;
3393 }
3394
3395 priv = hdd_request_priv(request);
3396
3397 /* copy over the stats. do so as a struct copy */
3398 priv->class_a_stats = *(tCsrGlobalClassAStatsInfo *)stats;
3399
3400 hdd_request_complete(request);
3401 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003402}
3403
3404VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3405{
3406 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3407 eHalStatus hstatus;
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303408 int ret;
3409 void *cookie;
3410 struct hdd_request *request;
3411 struct stats_class_a_ctx *priv;
3412 static const struct hdd_request_params params = {
3413 .priv_size = sizeof(*priv),
3414 .timeout_ms = WLAN_WAIT_TIME_STATS,
3415 };
3416
Jeff Johnson295189b2012-06-20 16:38:30 -07003417
3418 if (NULL == pAdapter)
3419 {
3420 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3421 return VOS_STATUS_E_FAULT;
3422 }
3423 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3424 {
3425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3426 return VOS_STATUS_SUCCESS;
3427 }
3428
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303429 request = hdd_request_alloc(&params);
3430 if (!request) {
3431 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3432 return VOS_STATUS_E_NOMEM;
3433 }
3434 cookie = hdd_request_cookie(request);
3435
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 /* query only for Class A statistics (which include link speed) */
3437 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3438 eCSR_HDD,
3439 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303440 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 0, // not periodic
3442 FALSE, //non-cached results
3443 pHddStaCtx->conn_info.staId[0],
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303444 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 if (eHAL_STATUS_SUCCESS != hstatus)
3446 {
3447 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003448 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003449 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 /* we'll returned a cached value below */
3451 }
3452 else
3453 {
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303454 /* request was sent -- wait for the response */
3455 ret = hdd_request_wait_for_response(request);
3456 if (ret)
3457 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303459 FL("SME timeout while retrieving Class A statistics"));
3460 }
3461 else
3462 {
3463 priv = hdd_request_priv(request);
3464 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
3465
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 }
3467 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003468
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303469 /*
3470 * either we never sent a request, we sent a request and received a
3471 * response or we sent a request and timed out. Regardless we are
3472 * done with the request.
3473 */
3474 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003475
3476 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 return VOS_STATUS_SUCCESS;
3478}
3479
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303480struct stats_ctx {
3481 tCsrSummaryStatsInfo summary_stats;
3482 tCsrGlobalClassAStatsInfo class_a_stats;
3483};
3484
3485static void hdd_get_station_statistics_cb(void *stats, void *context)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003486{
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303487 tCsrSummaryStatsInfo *summary_stats;
3488 tCsrGlobalClassAStatsInfo *class_a_stats;
3489 struct hdd_request *request;
3490 struct stats_ctx *priv;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003491
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003492
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303493 if (ioctl_debug) {
3494 pr_info("%s: stats [%pK] context [%pK]\n",
3495 __func__, stats, context);
3496 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003497
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303498 if (NULL == stats) {
3499 hddLog(VOS_TRACE_LEVEL_ERROR,
3500 "%s: Bad param, stats [%pK]",
3501 __func__, stats);
3502 return;
3503 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003504
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303505 request = hdd_request_get(context);
3506 if (!request) {
3507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3508 return;
3509 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003510
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303511 summary_stats = (tCsrSummaryStatsInfo *)stats;
3512 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
Jeff Johnson72a40512013-12-19 10:14:15 -08003513
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303514 priv = hdd_request_priv(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003515
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303516 /* copy over the stats. do so as a struct copy */
3517 priv->summary_stats = *summary_stats;
3518 priv->class_a_stats = *class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003519
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303520 hdd_request_complete(request);
3521 hdd_request_put(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003522}
3523
3524VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3525{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303526 hdd_station_ctx_t *pHddStaCtx;
3527 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003528 eHalStatus hstatus;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303529 tANI_U8 sta_id;
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303530 int ret;
3531 void *cookie;
3532 struct hdd_request *request;
3533 struct stats_ctx *priv;
3534 static const struct hdd_request_params params = {
3535 .priv_size = sizeof(*priv),
3536 .timeout_ms = WLAN_WAIT_TIME_STATS,
3537 };
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003538
3539 if (NULL == pAdapter)
3540 {
3541 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3542 return VOS_STATUS_SUCCESS;
3543 }
3544
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303545 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3546 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3547 sta_id = sap_ctx->uBCStaId;
3548 } else {
3549 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3550 sta_id = pHddStaCtx->conn_info.staId[0];
3551 }
3552
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303553 request = hdd_request_alloc(&params);
3554 if (!request) {
3555 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3556 return VOS_STATUS_E_NOMEM;
3557 }
3558 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003559
3560 /* query only for Summary & Class A statistics */
3561 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3562 eCSR_HDD,
3563 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303564 SME_GLOBAL_CLASSA_STATS |
3565 SME_PER_PKT_STATS,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303566 hdd_get_station_statistics_cb,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003567 0, // not periodic
3568 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303569 sta_id,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303570 cookie);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003571 if (eHAL_STATUS_SUCCESS != hstatus)
3572 {
3573 hddLog(VOS_TRACE_LEVEL_ERROR,
3574 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003575 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003576 /* we'll return with cached values */
3577 }
3578 else
3579 {
3580 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303581 ret = hdd_request_wait_for_response(request);
3582 if (ret)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003583 {
3584 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303585 FL("SME timeout while retrieving statistics"));
3586 }
3587 else
3588 {
3589 priv = hdd_request_priv(request);
3590 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
3591 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003592 }
3593 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003594
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303595 /*
3596 * either we never sent a request, we sent a request and received a
3597 * response or we sent a request and timed out. Regardless we are
3598 * done with the request.
3599 */
3600 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003601
3602 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003603 return VOS_STATUS_SUCCESS;
3604}
3605
Jeff Johnson295189b2012-06-20 16:38:30 -07003606/*
3607 * Support for the LINKSPEED private command
3608 * Per the WiFi framework the response must be of the form
3609 * "LinkSpeed xx"
3610 */
3611static int iw_get_linkspeed(struct net_device *dev,
3612 struct iw_request_info *info,
3613 union iwreq_data *wrqu, char *extra)
3614{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303615 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303616 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303618 int len = sizeof(v_U32_t) + 1;
3619 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303620 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303621 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303622 int rc, valid = 0;
3623
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303624 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303625 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3626 if (NULL == pAdapter)
3627 {
3628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3629 "%s: Adapter is NULL",__func__);
3630 return -EINVAL;
3631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003632
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303634 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303635 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003636 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303637 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003638 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303639 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3640 if (NULL == pHddStaCtx)
3641 {
3642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3643 "%s: STA Context is NULL",__func__);
3644 return -EINVAL;
3645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3647 {
3648 /* we are not connected so we don't have a classAstats */
3649 link_speed = 0;
3650 }
3651 else
3652 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303653 status = wlan_hdd_get_classAstats(pAdapter);
3654
3655 if (!VOS_IS_STATUS_SUCCESS(status ))
3656 {
3657 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3658 return -EINVAL;
3659 }
3660
3661 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3662 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3663 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3664 &link_speed);
3665
3666 link_speed = link_speed / 10;
3667
3668 if (0 == link_speed)
3669 {
3670 /* The linkspeed returned by HAL is in units of 500kbps.
3671 * converting it to mbps.
3672 * This is required to support legacy firmware which does
3673 * not return link capacity.
3674 */
3675 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3676 }
3677
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 }
3679
3680 wrqu->data.length = len;
3681 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003682 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 if ((rc < 0) || (rc >= len))
3684 {
3685 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303686 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 return -EIO;
3688 }
3689
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303690 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003692 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003693}
3694
Arif Hussain695279c2014-03-24 14:06:07 -07003695/*
3696 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3697 *
3698 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303699static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003700 struct iw_request_info *info,
3701 union iwreq_data *wrqu, char *extra)
3702{
3703 int rc;
3704
3705 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3706
3707 if (rc < 0)
3708 return rc;
3709
3710 /* a value is being successfully returned */
3711 return 0;
3712}
Jeff Johnson295189b2012-06-20 16:38:30 -07003713
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303714static int iw_get_linkspeed_priv(struct net_device *dev,
3715 struct iw_request_info *info,
3716 union iwreq_data *wrqu, char *extra)
3717{
3718 int ret;
3719
3720 vos_ssr_protect(__func__);
3721 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3722 vos_ssr_unprotect(__func__);
3723
3724 return ret;
3725}
3726
Jeff Johnson295189b2012-06-20 16:38:30 -07003727/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303728 * Support for the RSSI & RSSI-APPROX private commands
3729 * Per the WiFi framework the response must be of the form
3730 * "<ssid> rssi <xx>"
3731 * unless we are not associated, in which case the response is
3732 * "OK"
3733 */
3734static int iw_get_rssi(struct net_device *dev,
3735 struct iw_request_info *info,
3736 union iwreq_data *wrqu, char *extra)
3737{
3738 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3739 char *cmd = extra;
3740 int len = wrqu->data.length;
3741 v_S7_t s7Rssi = 0;
3742 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3743 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3744 VOS_STATUS vosStatus;
3745 int rc;
3746
3747 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3748 (0 == ssidlen) || (ssidlen >= len))
3749 {
3750 /* we are not connected or our SSID is too long
3751 so we cannot report an rssi */
3752 rc = scnprintf(cmd, len, "OK");
3753 }
3754 else
3755 {
3756 /* we are connected with a valid SSID
3757 so we can write the SSID into the return buffer
3758 (note that it is not NUL-terminated) */
3759 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3760
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303761 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303762 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3763
3764 if (VOS_STATUS_SUCCESS == vosStatus)
3765 {
3766 /* append the rssi to the ssid in the format required by
3767 the WiFI Framework */
3768 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3769 rc += ssidlen;
3770 }
3771 else
3772 {
3773 rc = -1;
3774 }
3775 }
3776
3777 /* verify that we wrote a valid response */
3778 if ((rc < 0) || (rc >= len))
3779 {
3780 // encoding or length error?
3781 hddLog(VOS_TRACE_LEVEL_ERROR,
3782 "%s: Unable to encode RSSI, got [%s]",
3783 __func__, cmd);
3784 return -EIO;
3785 }
3786
3787 /* a value is being successfully returned */
3788 return rc;
3789}
3790
3791/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 * Support for SoftAP channel range private command
3793 */
3794static int iw_softap_set_channel_range( struct net_device *dev,
3795 int startChannel,
3796 int endChannel,
3797 int band)
3798{
Jeff Johnson43971f52012-07-17 12:26:56 -07003799 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 int ret = 0;
3801 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3802 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003803 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3804
Jeff Johnson295189b2012-06-20 16:38:30 -07003805
3806 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3807 if (VOS_STATUS_SUCCESS != status)
3808 {
3809 ret = -EINVAL;
3810 }
Yathish9f22e662012-12-10 14:21:35 -08003811 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 return ret;
3813}
3814
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303815static uint8 chartohex(char c)
3816{
3817 uint8 val = 0;
3818 if (c >= '0' && c <= '9')
3819 val = c - '0';
3820 else if (c >= 'a' && c <= 'f')
3821 val = c - 'a' + 10;
3822 else if (c >= 'A' && c <= 'F')
3823 val = c - 'A' + 10;
3824 else
3825 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3826
3827 return val;
3828}
3829
3830uint8 getByte(char **buf)
3831{
3832 uint8 byte = 0;
3833 char *temp = *buf;
3834 byte = chartohex(*temp) * 16;
3835 temp++;
3836 byte += chartohex(*temp);
3837 temp++;
3838 *buf = temp;
3839 return byte;
3840}
3841
3842static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3843{
3844 tSir80211Header *macHeader;
3845 int i = 0, j = 0, length = 0;
3846 uint8 byte = 0;
3847 char *temp = pBuffer;
3848 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303849 char *pHeader;
3850 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303851
3852 macHeader = &pkt->macHeader;
3853
3854 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3855
3856 temp++;
3857
3858 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3859 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3860 pkt->encParams.keyParams.key[0].keyId);
3861
3862 for (i = 0; i< 16; i++) {
3863 pkt->encParams.keyParams.key[0].key[i]
3864 = getByte(&temp);
3865 }
3866
3867 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3868 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3869
3870 for (i = 0; i< 6; i++) {
3871 pkt->encParams.pn[i]
3872 = getByte(&temp);
3873 }
3874
3875 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3876 &pkt->encParams.pn[0], 6, 0);
3877
3878 for (i = 0, j= 5; i< 3; i++, j--) {
3879 byte = pkt->encParams.pn[i];
3880 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3881 pkt->encParams.pn[j] = byte;
3882 }
3883
3884 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303885 if (length > sizeof(tSir80211Header))
3886 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303887
Srinivas Dasari2382de62015-01-22 15:00:04 +05303888 pHeader = temp;
3889 vos_mem_zero(&header, sizeof(tSir80211Header));
3890 for (i = 0; i < length; i++) {
3891 *((uint8 *)&header + i) = getByte(&pHeader);
3892 }
3893
3894 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3895 (char *)&header, length, 0);
3896
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303897 byte = getByte(&temp);
3898
3899 macHeader->frameCtrl.protVer = byte & 0x3;
3900 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3901 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3902
3903 byte = getByte(&temp);
3904 macHeader->frameCtrl.toDS = (byte) & 0x1;
3905 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3906 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3907 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3908 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3909 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3910 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3911 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3912
3913 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3914 "macHeader->frameCtrl.type : %x "
3915 "macHeader->frameCtrl.subType : %x "
3916 "macHeader->frameCtrl.toDS : %x "
3917 "macHeader->frameCtrl.fromDS : %x "
3918 "macHeader->frameCtrl.moreFrag : %x "
3919 "macHeader->frameCtrl.retry : %x "
3920 "macHeader->frameCtrl.powerMgmt : %x "
3921 "macHeader->frameCtrl.MoreData : %x "
3922 "macHeader->frameCtrl.wep : %x "
3923 "macHeader->frameCtrl.order : %x "
3924 , macHeader->frameCtrl.protVer
3925 , macHeader->frameCtrl.type
3926 , macHeader->frameCtrl.subType
3927 , macHeader->frameCtrl.toDS
3928 , macHeader->frameCtrl.fromDS
3929 , macHeader->frameCtrl.moreFrag
3930 , macHeader->frameCtrl.retry
3931 , macHeader->frameCtrl.powerMgmt
3932 , macHeader->frameCtrl.moreData
3933 , macHeader->frameCtrl.wep
3934 , macHeader->frameCtrl.order);
3935
3936
3937 macHeader->usDurationId = getByte(&temp);
3938 macHeader->usDurationId += getByte(&temp) << 8;
3939
3940 macHeader->vA1[0] = getByte(&temp);
3941 macHeader->vA1[1] = getByte(&temp);
3942 macHeader->vA1[2] = getByte(&temp);
3943 macHeader->vA1[3] = getByte(&temp);
3944 macHeader->vA1[4] = getByte(&temp);
3945 macHeader->vA1[5] = getByte(&temp);
3946
3947 macHeader->vA2[0] = getByte(&temp);
3948 macHeader->vA2[1] = getByte(&temp);
3949 macHeader->vA2[2] = getByte(&temp);
3950 macHeader->vA2[3] = getByte(&temp);
3951 macHeader->vA2[4] = getByte(&temp);
3952 macHeader->vA2[5] = getByte(&temp);
3953
3954 macHeader->vA3[0] = getByte(&temp);
3955 macHeader->vA3[1] = getByte(&temp);
3956 macHeader->vA3[2] = getByte(&temp);
3957 macHeader->vA3[3] = getByte(&temp);
3958 macHeader->vA3[4] = getByte(&temp);
3959 macHeader->vA3[5] = getByte(&temp);
3960
3961 macHeader->sSeqCtrl = getByte(&temp);
3962 fragNum = macHeader->sSeqCtrl & 0xF;
3963 macHeader->sSeqCtrl >>= 4;
3964
3965 macHeader->sSeqCtrl += getByte(&temp) << 4;
3966
3967 macHeader->sSeqCtrl |= fragNum << 12;
3968
3969 if (length == 30 || length == 32) {
3970 macHeader->optvA4[0] = getByte(&temp);
3971 macHeader->optvA4[1] = getByte(&temp);
3972 macHeader->optvA4[2] = getByte(&temp);
3973 macHeader->optvA4[3] = getByte(&temp);
3974 macHeader->optvA4[4] = getByte(&temp);
3975 macHeader->optvA4[5] = getByte(&temp);
3976 }
3977
3978 if (length == 26 || length == 32) {
3979 macHeader->usQosCtrl = getByte(&temp);
3980 macHeader->usQosCtrl += getByte(&temp) << 8;
3981 }
3982
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303983 //parse payload
3984 length = getByte(&temp);
3985 length += getByte(&temp) << 8;
3986 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3987
Manjeet Singh5830f142016-11-21 18:21:17 +05303988 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
3989 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
3990
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303991 pkt->data.length = length;
3992
3993 for (i = 0; i< length; i++) {
3994 pkt->data.data[i] = getByte(&temp);
3995 }
3996
3997 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3998 &pkt->data.data[0], pkt->data.length, 0);
3999}
4000
4001/**---------------------------------------------------------------------------
4002
4003 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4004 encrypt message request
4005 This is an asynchronous callback function from SME when the encrypted data
4006 is received
4007
4008 \pEncInfoRsp -> Encrypted data info
4009
4010 \return - 0 for success non-zero for failure
4011 --------------------------------------------------------------------------*/
4012static void
4013hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4014{
4015 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4016
4017 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4018
4019 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4020 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4021 pEncryptedDataRsp->encryptedPayload.length);
4022 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4023 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4024 pEncryptedDataRsp->encryptedPayload.data,
4025 pEncryptedDataRsp->encryptedPayload.length, 0);
4026}
4027
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05304028/**
4029 * iw_power_callback_func() - Callback function registered with PMC
4030 * @context: cookie originally registered with PMC
4031 * @status: status code indicated by PMC state machine
4032 *
4033 * Return: None
4034 */
4035static void iw_power_callback_func(void *context, eHalStatus status)
4036{
4037 struct hdd_request *request = hdd_request_get(context);
4038
4039 if (!request) {
4040 hddLog(VOS_TRACE_LEVEL_ERROR,
4041 "%s: Obsolete request", __func__);
4042 return;
4043 }
4044
4045 hdd_request_complete(request);
4046 hdd_request_put(request);
4047}
4048
Jeff Johnson295189b2012-06-20 16:38:30 -07004049VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4050{
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 eHalStatus status;
4052 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304053 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304054 int ret;
4055 void *cookie;
4056 struct hdd_request *request;
4057 static const struct hdd_request_params params = {
4058 .priv_size = 0,
4059 .timeout_ms = WLAN_WAIT_TIME_STATS,
4060 };
Jeff Johnson295189b2012-06-20 16:38:30 -07004061
4062 if (NULL == pAdapter)
4063 {
4064 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4065 return VOS_STATUS_E_FAULT;
4066 }
4067
4068 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4069 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304070 if (pHddCtx->isLogpInProgress) {
4071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4072 "%s:LOGP in Progress. Ignore!!!", __func__);
4073 return VOS_STATUS_E_FAILURE;
4074 }
4075
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304076 request = hdd_request_alloc(&params);
4077 if (!request) {
4078 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
4079 return VOS_STATUS_E_NOMEM;
4080 }
4081 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
Jeff Johnson295189b2012-06-20 16:38:30 -07004083
4084 if (DRIVER_POWER_MODE_ACTIVE == mode)
4085 {
4086 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4087 "Full Power", __func__);
4088 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304089 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 eSME_FULL_PWR_NEEDED_BY_HDD);
4091 // Enter Full power command received from GUI this means we are disconnected
4092 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4093 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4094 if (eHAL_STATUS_PMC_PENDING == status)
4095 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304096 ret = hdd_request_wait_for_response(request);
4097 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304099 hddLog(VOS_TRACE_LEVEL_ERROR,
4100 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 }
4102 }
4103 }
4104 else if (DRIVER_POWER_MODE_AUTO == mode)
4105 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304106 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4107 * was already in BMPS state and thus either STA or P2P-CLI is in
4108 * associated state and authenticated, so even if STA connState is
4109 * not associated it can be assumed that P2P-CLI is associated and
4110 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4111 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4112 * if all condition are satisfied for entering BMPS.
4113 */
4114 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4115 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304116 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304117 hddLog(LOGE,
4118 FL("Station is associated but, still not Authenticated ignore "
4119 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304120 return VOS_STATUS_E_AGAIN;
4121 }
4122
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4124 {
4125 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4126 __func__);
4127 // Enter BMPS command received from GUI this means DHCP is completed
4128 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4129 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4130 FALSE);
4131 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304132 iw_power_callback_func, cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 if (eHAL_STATUS_PMC_PENDING == status)
4134 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004135 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304136 ret = hdd_request_wait_for_response(request);
4137 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004139 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304140 FL("SME timeout while requesting bmps"));
4141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 }
4143 }
4144 else
4145 {
4146 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4147 "enabled in the cfg");
4148 }
4149 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004150
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05304151 /*
4152 * either we never sent a request, we sent a request and received a
4153 * response or we sent a request and timed out. Regardless we are
4154 * done with the request.
4155 */
4156 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08004157
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 return VOS_STATUS_SUCCESS;
4159}
4160
4161VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4162 hdd_adapter_t *pAdapter)
4163{
4164 VOS_STATUS vos_Status;
4165
4166 if ((NULL == pAdapter) || (NULL == pHddCtx))
4167 {
4168 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4169 return VOS_STATUS_E_FAULT;
4170 }
4171
4172 /**Exit from Deep sleep or standby if we get the driver
4173 START cmd from android GUI
4174 */
4175 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4176 {
4177 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4178 "from Stand by",__func__);
4179 vos_Status = hdd_exit_standby(pHddCtx);
4180 }
4181 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4182 {
4183 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4184 "from deep sleep",__func__);
4185 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4186 }
4187 else
4188 {
4189 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4190 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4191 vos_Status = VOS_STATUS_SUCCESS;
4192 }
4193
4194 return vos_Status;
4195}
4196
4197VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4198{
4199 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4200
4201 if (NULL == pHddCtx)
4202 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304203 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 return VOS_STATUS_E_FAULT;
4205 }
4206
4207 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4208 {
4209 //Execute standby procedure.
4210 //Executing standby procedure will cause the STA to
4211 //disassociate first and then the chip will be put into standby.
4212 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4213 vos_Status = hdd_enter_standby(pHddCtx);
4214 }
4215 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4216 pHddCtx->cfg_ini->nEnableDriverStop)
4217 {
4218 //Execute deep sleep procedure
4219 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004220 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 //Deep sleep not supported
4222 vos_Status = hdd_enter_standby(pHddCtx);
4223 }
4224 else
4225 {
4226 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4227 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4228 vos_Status = VOS_STATUS_SUCCESS;
4229 }
4230
4231 return vos_Status;
4232}
4233
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004234
4235void* wlan_hdd_change_country_code_callback(void *pAdapter)
4236{
4237
4238 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004239 complete(&call_back_pAdapter->change_country_code);
4240
4241 return NULL;
4242}
4243
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304244static int __iw_set_priv(struct net_device *dev,
4245 struct iw_request_info *info,
4246 union iwreq_data *wrqu, char *extra)
4247{
4248 hdd_adapter_t *pAdapter;
4249 char *cmd = NULL;
4250 int cmd_len = wrqu->data.length;
4251 int rc = 0, ret = 0;
4252 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4253
4254 hdd_context_t *pHddCtx;
4255
4256 ENTER();
4257
4258 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4259 if (NULL == pAdapter)
4260 {
4261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4262 "mem_alloc_copy_from_user_helper fail");
4263 return -EINVAL;
4264 }
4265 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4266 rc = wlan_hdd_validate_context(pHddCtx);
4267 if (0 != rc)
4268 {
4269 return rc;
4270 }
4271
4272 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4273 wrqu->data.length);
4274 if (NULL == cmd)
4275 {
4276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4277 "mem_alloc_copy_from_user_helper fail");
4278 return -ENOMEM;
4279 }
4280
4281 if (ioctl_debug)
4282 {
4283 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4284 }
4285
4286 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4287 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4288
4289 if (strncmp(cmd, "CSCAN", 5) == 0 )
4290 {
4291 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4293 "%s: Error in iw_set_scan!", __func__);
4294 rc = -EINVAL;
4295 }
4296 }
4297 else if( strcasecmp(cmd, "start") == 0 ) {
4298
4299 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4300 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4301
4302 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4303 if (vos_status == VOS_STATUS_SUCCESS)
4304 {
4305 union iwreq_data wrqu;
4306 char buf[10];
4307
4308 memset(&wrqu, 0, sizeof(wrqu));
4309 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4310 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4311 }
4312 else
4313 {
4314 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4315 rc = -EIO;
4316 }
4317 goto done;
4318 }
4319 else if( strcasecmp(cmd, "stop") == 0 )
4320 {
4321 union iwreq_data wrqu;
4322 char buf[10];
4323
4324 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4325
4326 wlan_hdd_enter_lowpower(pHddCtx);
4327 memset(&wrqu, 0, sizeof(wrqu));
4328 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4329 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4330 goto done;
4331 }
4332 else if (strcasecmp(cmd, "macaddr") == 0)
4333 {
4334 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4335 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4336 }
4337 else if (strcasecmp(cmd, "scan-active") == 0)
4338 {
4339 hddLog(LOG1,
4340 FL("making default scan to active"));
4341 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4342 ret = snprintf(cmd, cmd_len, "OK");
4343 }
4344 else if (strcasecmp(cmd, "scan-passive") == 0)
4345 {
4346 hddLog(LOG1,
4347 FL("making default scan to passive"));
4348 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4349 ret = snprintf(cmd, cmd_len, "OK");
4350 }
4351 else if( strcasecmp(cmd, "scan-mode") == 0 )
4352 {
4353 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4354 }
4355 else if( strcasecmp(cmd, "linkspeed") == 0 )
4356 {
4357 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4358 }
4359 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4360 {
4361 ret = iw_get_rssi(dev, info, wrqu, cmd);
4362 }
4363 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4364 int mode;
4365 char *ptr;
4366
4367 if (9 < cmd_len)
4368 {
4369 ptr = (char*)(cmd + 9);
4370
4371 }else{
4372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4373 "CMD LENGTH %d is not correct",cmd_len);
4374 kfree(cmd);
4375 return -EINVAL;
4376 }
4377
4378 if (1 != sscanf(ptr,"%d",&mode))
4379 {
4380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4381 "powermode input %s is not correct",ptr);
4382 kfree(cmd);
4383 return -EIO;
4384 }
4385
4386 wlan_hdd_enter_bmps(pAdapter, mode);
4387 /*TODO:Set the power mode*/
4388 }
4389 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4390 v_U32_t pmc_state;
4391 v_U16_t value;
4392
4393 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4394 if(pmc_state == BMPS) {
4395 value = DRIVER_POWER_MODE_AUTO;
4396 }
4397 else {
4398 value = DRIVER_POWER_MODE_ACTIVE;
4399 }
4400 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4401 }
4402 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4403 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4404 /*TODO: set the btcoexmode*/
4405 }
4406 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4407
4408 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4409 /*TODO: Return the btcoex status*/
4410 }
4411 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4412
4413 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4414
4415 /*TODO: Enable Rx data Filter*/
4416 }
4417 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4418
4419 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4420
4421 /*TODO: Disable Rx data Filter*/
4422 }
4423 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4424
4425 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4426 /*TODO: rxfilter-statistics*/
4427 }
4428 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4429
4430 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4431 /*TODO: rxfilter-add*/
4432 }
4433 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4434
4435 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4436 /*TODO: rxfilter-remove*/
4437 }
4438#ifdef FEATURE_WLAN_SCAN_PNO
4439 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4440 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4441 /*TODO: support pnosetup*/
4442 }
4443 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4444 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4445 /*TODO: support pnoforce*/
4446 }
4447 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4448
4449 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4450 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4451 kfree(cmd);
4452 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4453 }
4454 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4455 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4456 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4457 kfree(cmd);
4458 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4459 }
4460#endif /*FEATURE_WLAN_SCAN_PNO*/
4461 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4462 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4463 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4464 kfree(cmd);
4465 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4466 }
4467 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4468 tSirTxPerTrackingParam tTxPerTrackingParam;
4469 char *ptr;
4470
4471 if (18 < cmd_len)
4472 {
4473 ptr = (char*)(cmd + 18);
4474 }else{
4475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4476 "CMD LENGTH %d is not correct",cmd_len);
4477 kfree(cmd);
4478 return -EINVAL;
4479 }
4480
4481 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4482 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4483 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4484 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4485 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4486 {
4487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4488 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4489 kfree(cmd);
4490 return -EIO;
4491 }
4492
4493 // parameters checking
4494 // period has to be larger than 0
4495 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4496 {
4497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4498 kfree(cmd);
4499 return -EIO;
4500 }
4501
4502 // use default value 5 is the input is not reasonable. in unit of 10%
4503 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4504 {
4505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4506 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4507 }
4508
4509 // default is 5
4510 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4511 {
4512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4513 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4514 }
4515
4516 if (eHAL_STATUS_SUCCESS !=
4517 sme_SetTxPerTracking(pHddCtx->hHal,
4518 hdd_tx_per_hit_cb,
4519 (void*)pAdapter, &tTxPerTrackingParam)) {
4520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4521 rc = -EIO;
4522 }
4523 }
4524 else {
4525 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4526 __func__, cmd);
4527 }
4528done:
4529 /* many of the commands write information back into the command
4530 string using snprintf(). check the return value here in one
4531 place */
4532 if ((ret < 0) || (ret >= cmd_len))
4533 {
4534 /* there was an encoding error or overflow */
4535 rc = -EINVAL;
4536 }
4537 else if (ret > 0)
4538 {
4539 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4540 {
4541 hddLog(VOS_TRACE_LEVEL_ERROR,
4542 "%s: failed to copy data to user buffer", __func__);
4543 kfree(cmd);
4544 return -EFAULT;
4545 }
4546 wrqu->data.length = ret;
4547 }
4548
4549 if (ioctl_debug)
4550 {
4551 pr_info("%s: rsp [%s] len [%d] status %d\n",
4552 __func__, cmd, wrqu->data.length, rc);
4553 }
4554 kfree(cmd);
4555 EXIT();
4556 return rc;
4557}
4558
4559static int iw_set_priv(struct net_device *dev,
4560 struct iw_request_info *info,
4561 union iwreq_data *wrqu, char *extra)
4562{
4563 int ret;
4564 vos_ssr_protect(__func__);
4565 ret = __iw_set_priv(dev, info, wrqu, extra);
4566 vos_ssr_unprotect(__func__);
4567
4568 return ret;
4569}
4570
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304571static int __iw_set_nick(struct net_device *dev,
4572 struct iw_request_info *info,
4573 union iwreq_data *wrqu, char *extra)
4574{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304575 hdd_adapter_t *pAdapter;
4576 hdd_context_t *pHddCtx;
4577 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304578
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304579 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304580
4581 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4582 if (NULL == pAdapter)
4583 {
4584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4585 "%s: Adapter is NULL",__func__);
4586 return -EINVAL;
4587 }
4588
4589 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4590 ret = wlan_hdd_validate_context(pHddCtx);
4591 if (0 != ret)
4592 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304593 return ret;
4594 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304595 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304596 return 0;
4597}
4598
Jeff Johnson295189b2012-06-20 16:38:30 -07004599static int iw_set_nick(struct net_device *dev,
4600 struct iw_request_info *info,
4601 union iwreq_data *wrqu, char *extra)
4602{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304603 int ret;
4604
4605 vos_ssr_protect(__func__);
4606 ret = __iw_set_nick(dev, info, wrqu, extra);
4607 vos_ssr_unprotect(__func__);
4608
4609 return ret;
4610}
4611
4612static int __iw_get_nick(struct net_device *dev,
4613 struct iw_request_info *info,
4614 union iwreq_data *wrqu, char *extra)
4615{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304616 hdd_adapter_t *pAdapter;
4617 hdd_context_t *pHddCtx;
4618 int ret = 0;
4619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304621
4622 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4623 if (NULL == pAdapter)
4624 {
4625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4626 "%s: Adapter is NULL",__func__);
4627 return -EINVAL;
4628 }
4629
4630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4631 ret = wlan_hdd_validate_context(pHddCtx);
4632 if (0 != ret)
4633 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304634 return ret;
4635 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304636 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 return 0;
4638}
4639
4640static int iw_get_nick(struct net_device *dev,
4641 struct iw_request_info *info,
4642 union iwreq_data *wrqu, char *extra)
4643{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304644 int ret;
4645
4646 vos_ssr_protect(__func__);
4647 ret = __iw_get_nick(dev, info, wrqu, extra);
4648 vos_ssr_unprotect(__func__);
4649
4650 return ret;
4651}
4652
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304653/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304654static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4655{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4657 hdd_context_t *pHddCtx;
4658 hdd_station_ctx_t *pHddStaCtx;
4659 v_S7_t snr = 0, rssi = 0;
4660 eHalStatus status = eHAL_STATUS_SUCCESS;
4661
4662 ENTER();
4663
4664 if (NULL == pAdapter)
4665 {
4666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4667 "%s: Adapter is NULL",__func__);
4668 return NULL;
4669 }
4670
4671 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4672 status = wlan_hdd_validate_context(pHddCtx);
4673 if (0 != status)
4674 {
4675 return NULL;
4676 }
4677
4678 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4679 if (NULL == pHddStaCtx)
4680 {
4681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4682 "%s: STA Context is NULL",__func__);
4683 return NULL;
4684 }
4685
4686 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4687 {
4688 wlan_hdd_get_station_stats(pAdapter);
4689 wlan_hdd_get_snr(pAdapter, &snr);
4690 wlan_hdd_get_rssi(pAdapter, &rssi);
4691
4692 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4693 pAdapter->iwStats.status = 0;
4694 pAdapter->iwStats.qual.qual = snr;
4695 pAdapter->iwStats.qual.level = rssi;
4696 pAdapter->iwStats.qual.noise = rssi - snr;
4697 pAdapter->iwStats.discard.code = 0;
4698 pAdapter->iwStats.discard.retries= 0;
4699 pAdapter->iwStats.miss.beacon = 0;
4700 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4701 }
4702 else
4703 {
4704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4705 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4706 return NULL;
4707 }
4708
4709 EXIT();
4710 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004711}
4712
4713static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4714{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304715
4716 struct iw_statistics *stats;
4717
4718 vos_ssr_protect(__func__);
4719 stats = __get_wireless_stats(dev);
4720 vos_ssr_unprotect(__func__);
4721
4722 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004723}
4724
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304725static int __iw_set_encode(struct net_device *dev,
4726 struct iw_request_info *info,
4727 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004728
4729{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304730 hdd_adapter_t *pAdapter;
4731 hdd_station_ctx_t *pHddStaCtx;
4732 hdd_wext_state_t *pWextState;
4733 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 struct iw_point *encoderq = &(wrqu->encoding);
4735 v_U32_t keyId;
4736 v_U8_t key_length;
4737 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4738 v_BOOL_t fKeyPresent = 0;
4739 int i;
4740 eHalStatus status = eHAL_STATUS_SUCCESS;
4741
4742
4743 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304744 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4745 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4748 "%s: Adapter is NULL",__func__);
4749 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 }
4751
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4753 status = wlan_hdd_validate_context(pHddCtx);
4754 if (0 != status)
4755 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304756 return status;
4757 }
4758 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4759 if (NULL == pWextState)
4760 {
4761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4762 "%s: pWextState is NULL ",__func__);
4763 return -EINVAL;
4764 }
4765 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4766 if (NULL == pHddStaCtx)
4767 {
4768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4769 "%s: STA Context is NULL",__func__);
4770 return -EINVAL;
4771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004772
4773 keyId = encoderq->flags & IW_ENCODE_INDEX;
4774
4775 if(keyId)
4776 {
4777 if(keyId > MAX_WEP_KEYS)
4778 {
4779 return -EINVAL;
4780 }
4781
4782 fKeyPresent = 1;
4783 keyId--;
4784 }
4785 else
4786 {
4787 fKeyPresent = 0;
4788 }
4789
4790
4791 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4792 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 if(!fKeyPresent) {
4795
4796 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4797
4798 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4799 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4800 }
4801 }
4802 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4803 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4804 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4805 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4806
4807 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4808 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4809
4810 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4811 {
4812 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4813 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004814 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304815 {
4816 long ret;
4817 ret = wait_for_completion_interruptible_timeout(
4818 &pAdapter->disconnect_comp_var,
4819 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4820 if (ret <= 0)
4821 hddLog(VOS_TRACE_LEVEL_ERROR,
4822 FL("failed wait on disconnect_comp_var %ld"), ret);
4823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 }
4825
4826 return status;
4827
4828 }
4829
4830 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4831 {
4832 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4833
4834 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4835
4836 }
4837
4838
4839 if(wrqu->data.length > 0)
4840 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004841 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004842
4843 key_length = wrqu->data.length;
4844
4845 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4846
4847 if(5 == key_length)
4848 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004849 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004850
4851 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4852 {
4853 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4854 }
4855 else
4856 {
4857 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4858 }
4859 }
4860 else if(13 == key_length)
4861 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004862 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004863
4864 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4865 {
4866 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4867 }
4868 else
4869 {
4870 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4871 }
4872 }
4873 else
4874 {
4875 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004876 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 return -EINVAL;
4878 }
4879
4880 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4881 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4882 pWextState->roamProfile.EncryptionType.numEntries = 1;
4883 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4884 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4885 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4886
4887 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4888 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4889 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4890 {
4891
4892 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4893
4894 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4895 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4896
4897 return status;
4898 }
4899 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304900 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 return 0;
4902}
4903
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304904static int iw_set_encode(struct net_device *dev,
4905 struct iw_request_info *info,
4906 union iwreq_data *wrqu,char *extra)
4907{
4908 int ret;
4909
4910 vos_ssr_protect(__func__);
4911 ret = __iw_set_encode(dev, info, wrqu, extra);
4912 vos_ssr_unprotect(__func__);
4913
4914 return ret;
4915}
4916
4917static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 struct iw_request_info *info,
4919 struct iw_point *dwrq,
4920 char *extra)
4921{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304922 hdd_adapter_t *pAdapter;
4923 hdd_wext_state_t *pWextState;
4924 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 int keyId;
4926 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4927 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304928 int i, ret = 0;
4929 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004930
4931 ENTER();
4932
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304933 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4934 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004935 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4937 "%s: Adapter is NULL",__func__);
4938 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004939 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304940 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4941 ret = wlan_hdd_validate_context(pHddCtx);
4942 if (0 != ret)
4943 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304944 return ret;
4945 }
4946 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4947 if (NULL == pWextState)
4948 {
4949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4950 "%s: pWextState is NULL",__func__);
4951 return -EINVAL;
4952 }
4953 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004954
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 keyId = pRoamProfile->Keys.defaultIndex;
4956
4957 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4958 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004959 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 return -EINVAL;
4961 }
4962
4963 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4964 {
4965 dwrq->flags |= IW_ENCODE_ENABLED;
4966 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304967 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4968 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970 else
4971 {
4972 dwrq->flags |= IW_ENCODE_DISABLED;
4973 }
4974
4975 for(i=0; i < MAX_WEP_KEYS; i++)
4976 {
4977 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4978 {
4979 continue;
4980 }
4981 else
4982 {
4983 break;
4984 }
4985 }
4986
4987 if(MAX_WEP_KEYS == i)
4988 {
4989 dwrq->flags |= IW_ENCODE_NOKEY;
4990 }
4991 else
4992 {
4993 dwrq->flags |= IW_ENCODE_ENABLED;
4994 }
4995
4996 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4997
4998 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4999 {
5000 dwrq->flags |= IW_ENCODE_DISABLED;
5001 }
5002
5003 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5004
5005 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5006 {
5007 dwrq->flags |= IW_ENCODE_OPEN;
5008 }
5009 else
5010 {
5011 dwrq->flags |= IW_ENCODE_RESTRICTED;
5012 }
5013 EXIT();
5014 return 0;
5015
5016}
5017
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305018static int iw_get_encodeext(struct net_device *dev,
5019 struct iw_request_info *info,
5020 struct iw_point *dwrq,
5021 char *extra)
5022{
5023 int ret;
5024 vos_ssr_protect(__func__);
5025 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5026 vos_ssr_unprotect(__func__);
5027
5028 return ret;
5029}
5030
5031static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 struct iw_request_info *info,
5033 union iwreq_data *wrqu, char *extra)
5034{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305035 hdd_adapter_t *pAdapter;
5036 hdd_station_ctx_t *pHddStaCtx;
5037 hdd_wext_state_t *pWextState;
5038 hdd_context_t *pHddCtx;
5039 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005040
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305041 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 v_U32_t status = 0;
5043
5044 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5045
5046 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5047
5048 int key_index;
5049 struct iw_point *encoding = &wrqu->encoding;
5050 tCsrRoamSetKey setKey;
5051 v_U32_t roamId= 0xFF;
5052 VOS_STATUS vos_status;
5053
5054 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305055 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5056 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5059 "%s: Adapter is NULL",__func__);
5060 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305062 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5063 status = wlan_hdd_validate_context(pHddCtx);
5064 if (0 != status)
5065 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305066 return status;
5067 }
5068 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5069 if (NULL == pHddStaCtx)
5070 {
5071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5072 "%s: STA Context is NULL",__func__);
5073 return -EINVAL;
5074 }
5075 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5076 if (NULL == pWextState)
5077 {
5078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5079 "%s: pWextState is NULL",__func__);
5080 return -EINVAL;
5081 }
5082 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 key_index = encoding->flags & IW_ENCODE_INDEX;
5084
5085 if(key_index > 0) {
5086
5087 /*Convert from 1-based to 0-based keying*/
5088 key_index--;
5089 }
5090 if(!ext->key_len) {
5091
5092 /*Set the encrytion type to NONE*/
5093 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5094 return status;
5095 }
5096
5097 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5098 (IW_ENCODE_ALG_WEP == ext->alg))
5099 {
5100 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5101
Agarwal Ashish971c2882013-10-30 20:11:12 +05305102 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5103 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 return -EINVAL;
5105 }
5106 else {
5107 /*Static wep, update the roam profile with the keys */
5108 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5109 key_index < CSR_MAX_NUM_KEY) {
5110 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5111 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5112
5113 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5114 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5115
5116 }
5117 }
5118 return status;
5119 }
5120
5121 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5122
5123 setKey.keyId = key_index;
5124 setKey.keyLength = ext->key_len;
5125
5126 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5127 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5128 }
5129
5130 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5131 /*Key direction for group is RX only*/
5132 setKey.keyDirection = eSIR_RX_ONLY;
5133 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5134 }
5135 else {
5136
5137 setKey.keyDirection = eSIR_TX_RX;
5138 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5139 }
5140
5141 /*For supplicant pae role is zero*/
5142 setKey.paeRole = 0;
5143
5144 switch(ext->alg)
5145 {
5146 case IW_ENCODE_ALG_NONE:
5147 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5148 break;
5149
5150 case IW_ENCODE_ALG_WEP:
5151 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5152 break;
5153
5154 case IW_ENCODE_ALG_TKIP:
5155 {
5156 v_U8_t *pKey = &setKey.Key[0];
5157
5158 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5159
5160 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5161
5162 /*Supplicant sends the 32bytes key in this order
5163
5164 |--------------|----------|----------|
5165 | Tk1 |TX-MIC | RX Mic |
5166 |--------------|----------|----------|
5167 <---16bytes---><--8bytes--><--8bytes-->
5168
5169 */
5170 /*Sme expects the 32 bytes key to be in the below order
5171
5172 |--------------|----------|----------|
5173 | Tk1 |RX-MIC | TX Mic |
5174 |--------------|----------|----------|
5175 <---16bytes---><--8bytes--><--8bytes-->
5176 */
5177 /* Copy the Temporal Key 1 (TK1) */
5178 vos_mem_copy(pKey,ext->key,16);
5179
5180 /*Copy the rx mic first*/
5181 vos_mem_copy(&pKey[16],&ext->key[24],8);
5182
5183 /*Copy the tx mic */
5184 vos_mem_copy(&pKey[24],&ext->key[16],8);
5185
5186 }
5187 break;
5188
5189 case IW_ENCODE_ALG_CCMP:
5190 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5191 break;
5192
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005193#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005194#define IW_ENCODE_ALG_KRK 6
5195 case IW_ENCODE_ALG_KRK:
5196 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5197 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005198#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005199
5200 default:
5201 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5202 break;
5203 }
5204
5205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005206 ("%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 -07005207
5208#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305209 /* The supplicant may attempt to set the PTK once pre-authentication
5210 is done. Save the key in the UMAC and include it in the ADD
5211 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305213 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305215 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5216 "%s: Update PreAuth Key success", __func__);
5217 return 0;
5218 }
5219 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5220 {
5221 hddLog(VOS_TRACE_LEVEL_ERROR,
5222 "%s: Update PreAuth Key failed", __func__);
5223 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 }
5225#endif /* WLAN_FEATURE_VOWIFI_11R */
5226
5227 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5228
5229 vos_status = wlan_hdd_check_ula_done(pAdapter);
5230 if ( vos_status != VOS_STATUS_SUCCESS )
5231 {
5232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5233 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5234 __LINE__, vos_status );
5235
5236 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5237 }
5238
5239 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5240
5241 if ( halStatus != eHAL_STATUS_SUCCESS )
5242 {
5243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5244 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5245 __LINE__, halStatus );
5246
5247 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5248 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305249 EXIT();
5250 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005251}
5252
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305253static int iw_set_encodeext(struct net_device *dev,
5254 struct iw_request_info *info,
5255 union iwreq_data *wrqu, char *extra)
5256{
5257 int ret;
5258
5259 vos_ssr_protect(__func__);
5260 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5261 vos_ssr_unprotect(__func__);
5262
5263 return ret;
5264}
5265
5266static int __iw_set_retry(struct net_device *dev,
5267 struct iw_request_info *info,
5268 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005269{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305270 hdd_adapter_t *pAdapter;
5271 tHalHandle hHal;
5272 hdd_context_t *pHddCtx;
5273 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005274
5275 ENTER();
5276
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305277 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5278 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005279 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5281 "%s: Adapter is NULL",__func__);
5282 return -EINVAL;
5283 }
5284
5285 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5286 ret = wlan_hdd_validate_context(pHddCtx);
5287 if (0 != ret)
5288 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305289 return ret;
5290 }
5291
5292 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5293 if (NULL == hHal)
5294 {
5295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5296 "%s: Hal Context is NULL",__func__);
5297 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005298 }
5299
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5301 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5302
Arif Hussain6d2a3322013-11-17 19:50:10 -08005303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005304
5305 return -EINVAL;
5306 }
5307
5308 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5309
5310 if((wrqu->retry.flags & IW_RETRY_LONG))
5311 {
5312 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5313 {
c_hpothub8245442013-11-20 23:41:09 +05305314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5315 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 return -EIO;
5317 }
5318 }
5319 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5320 {
5321 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5322 {
c_hpothub8245442013-11-20 23:41:09 +05305323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5324 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 return -EIO;
5326 }
5327 }
5328 }
5329 else
5330 {
5331 return -EOPNOTSUPP;
5332 }
5333
Arif Hussain6d2a3322013-11-17 19:50:10 -08005334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005335
5336 EXIT();
5337
5338 return 0;
5339
5340}
5341
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305342static int iw_set_retry(struct net_device *dev,
5343 struct iw_request_info *info,
5344 union iwreq_data *wrqu, char *extra)
5345{
5346 int ret;
5347
5348 vos_ssr_protect(__func__);
5349 ret = __iw_set_retry(dev, info, wrqu, extra);
5350 vos_ssr_unprotect(__func__);
5351
5352 return ret;
5353}
5354
5355static int __iw_get_retry(struct net_device *dev,
5356 struct iw_request_info *info,
5357 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005358{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305359 hdd_adapter_t *pAdapter;
5360 hdd_context_t *pHddCtx;
5361 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305363 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005364
5365 ENTER();
5366
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305367 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5368 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005369 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5371 "%s: Adapter is NULL",__func__);
5372 return -EINVAL;
5373 }
5374
5375 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5376 ret = wlan_hdd_validate_context(pHddCtx);
5377 if (0 != ret)
5378 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305379 return ret;
5380 }
5381
5382 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5383 if (NULL == hHal)
5384 {
5385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5386 "%s: Hal Context is NULL",__func__);
5387 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005388 }
5389
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 if((wrqu->retry.flags & IW_RETRY_LONG))
5391 {
5392 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5393
5394 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5395 {
c_hpothub8245442013-11-20 23:41:09 +05305396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5397 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 return -EIO;
5399 }
5400
5401 wrqu->retry.value = retry;
5402 }
5403 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5404 {
5405 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5406
5407 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5408 {
c_hpothub8245442013-11-20 23:41:09 +05305409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5410 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 return -EIO;
5412 }
5413
5414 wrqu->retry.value = retry;
5415 }
5416 else {
5417 return -EOPNOTSUPP;
5418 }
5419
Arif Hussain6d2a3322013-11-17 19:50:10 -08005420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005421
5422 EXIT();
5423
5424 return 0;
5425}
5426
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305427static int iw_get_retry(struct net_device *dev,
5428 struct iw_request_info *info,
5429 union iwreq_data *wrqu, char *extra)
5430{
5431 int ret;
5432
5433 vos_ssr_protect(__func__);
5434 ret = __iw_get_retry(dev, info, wrqu, extra);
5435 vos_ssr_unprotect(__func__);
5436
5437 return ret;
5438}
5439
5440static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 struct iw_request_info *info,
5442 union iwreq_data *wrqu,
5443 char *extra)
5444{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305445 hdd_adapter_t *pAdapter;
5446 hdd_context_t *pHddCtx;
5447 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5449 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305450 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005451
5452 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305453 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5454 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5457 "%s:Adapter is NULL",__func__);
5458 return -EINVAL;
5459 }
5460 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5461 ret = wlan_hdd_validate_context(pHddCtx);
5462 if (0 != ret)
5463 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305464 return ret;
5465 }
5466 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5467 if (NULL == pHddStaCtx)
5468 {
5469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5470 "%s:STA context is NULL",__func__);
5471 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 }
5473
5474 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5475 switch (mlme->cmd) {
5476 case IW_MLME_DISASSOC:
5477 case IW_MLME_DEAUTH:
5478
5479 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5480 {
5481 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5482
5483 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5484 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5485
5486 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5487 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5488
Jeff Johnson43971f52012-07-17 12:26:56 -07005489 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305490 {
5491 long ret;
5492 ret = wait_for_completion_interruptible_timeout(
5493 &pAdapter->disconnect_comp_var,
5494 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5495 if (ret <= 0)
5496 hddLog(VOS_TRACE_LEVEL_ERROR,
5497 FL("failed wait on disconnect_comp_var %ld"), ret);
5498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005500 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005501 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005502
5503 /* Resetting authKeyMgmt */
5504 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5505
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305506 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 netif_tx_disable(dev);
5508 netif_carrier_off(dev);
5509
5510 }
5511 else
5512 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005513 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 -07005514 }
5515 break;
5516 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005517 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 return -EINVAL;
5519 }//end of switch
5520
5521 EXIT();
5522
5523 return status;
5524
5525}
5526
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305527static int iw_set_mlme(struct net_device *dev,
5528 struct iw_request_info *info,
5529 union iwreq_data *wrqu,
5530 char *extra)
5531{
5532 int ret;
5533
5534 vos_ssr_protect(__func__);
5535 ret = __iw_set_mlme(dev, info, wrqu, extra);
5536 vos_ssr_unprotect(__func__);
5537
5538 return ret;
5539}
5540
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305541int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305542{
5543 sHwCalValues hwCalValues;
5544 uint16 hwCalTxPower;
5545 uint8 txPwr = TX_PWR_DEF;
5546
5547 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5548
5549 if (TRUE == set_value) {
5550 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5551 NULL, sizeof(sHwCalValues) )
5552 != VOS_STATUS_SUCCESS) {
5553 return -EINVAL;
5554 }
5555 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5556
5557 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5558 hwCalTxPower, hwCalValues.calData.hwParam7);
5559
5560 txPwr = (int8)(hwCalTxPower & 0x00FF);
5561 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305562 if (txPwr == 0)
5563 txPwr = TX_PWR_DEF;
5564 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305565 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305566 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305567 txPwr = TX_PWR_MAX;
5568
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305569 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305570 eHAL_STATUS_SUCCESS) {
5571 hddLog(VOS_TRACE_LEVEL_ERROR,
5572 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5573 return -EIO;
5574 }
5575
5576 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5577 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305578 if (txPwr == 0)
5579 txPwr = TX_PWR_DEF;
5580 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305581 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305582 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305583 txPwr = TX_PWR_MAX;
5584
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305585 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305586 eHAL_STATUS_SUCCESS) {
5587 hddLog(VOS_TRACE_LEVEL_ERROR,
5588 FL("setting tx power failed for 5GHz band %d"), txPwr);
5589 return -EIO;
5590 }
5591 }
5592 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305593 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305594 eHAL_STATUS_SUCCESS) {
5595 hddLog(VOS_TRACE_LEVEL_ERROR,
5596 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5597 return -EIO;
5598 }
5599
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305600 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305601 eHAL_STATUS_SUCCESS) {
5602 hddLog(VOS_TRACE_LEVEL_ERROR,
5603 FL("setting tx power failed for 5GHz band %d"), txPwr);
5604 return -EIO;
5605 }
5606 }
5607 else {
5608 return -EINVAL;
5609 }
5610
5611 return eHAL_STATUS_SUCCESS;
5612}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305613
5614static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5615{
5616 int ret = 0;
5617 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5618 tDelBaParams del_session;
5619
5620 del_session.session_id = adapter->sessionId;
5621 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5622
5623 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5624 {
5625 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5626 value,NULL, eANI_BOOLEAN_FALSE);
5627 if (ret != eHAL_STATUS_SUCCESS)
5628 {
5629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5630 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5631 return -EIO;
5632 }
5633
5634 } else {
5635 hddLog(VOS_TRACE_LEVEL_ERROR,
5636 FL("Invalid command input"));
5637 return -EINVAL;
5638 }
5639 ret = sme_del_sta_ba_session_req(hal, del_session);
5640 if (ret != VOS_STATUS_SUCCESS) {
5641 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5642 return -EINVAL;
5643 }
5644
5645 EXIT();
5646 return ret;
5647}
5648
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305649static int
5650wlan_hdd_sta_mon_op(hdd_context_t *hdd_ctx, uint32_t set_value,
5651 hdd_adapter_t *mon_adapter, hdd_mon_ctx_t *mon_ctx)
5652{
5653 hdd_station_ctx_t *sta_ctx;
5654 VOS_STATUS disable_bmps_status;
5655 hdd_adapter_t *sta_adapter;
5656 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(mon_adapter))->pvosContext;
5657
5658 if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) {
5659 hddLog(LOGE, FL("Monitor Interface is not OPENED"));
5660 return -EINVAL;
5661 }
5662
5663 if (set_value == MON_MODE_STOP) {
5664 if (wlan_hdd_check_monitor_state(hdd_ctx))
5665 return 0;
5666 return -EINVAL;
5667 }
5668
5669 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
5670 if (!sta_adapter) {
5671 hddLog(LOGE, FL("No Station adapter"));
5672 return -EINVAL;
5673 }
5674
5675 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
5676 if (!sta_ctx || !hdd_connIsConnected(sta_ctx)) {
5677 hddLog(LOGE, FL("STA is not connected"));
5678 return -EINVAL;
5679 }
5680
5681 if (hdd_isConnectionInProgress(hdd_ctx, NULL, NULL)) {
5682 hddLog(LOGE, FL("Roaming or set-key is in progress"));
5683 return -EBUSY;
5684 }
5685
5686 hdd_disable_roaming(hdd_ctx);
5687
5688 hddLog(LOG1, FL("Disable BMPS"));
5689 disable_bmps_status = hdd_disable_bmps_imps(hdd_ctx,
5690 WLAN_HDD_INFRA_STATION);
5691 if (disable_bmps_status != VOS_STATUS_SUCCESS) {
5692 hddLog(LOGE, FL("Cannot start monitor mode"));
5693 hdd_restore_roaming(hdd_ctx);
5694 return -EINVAL;
5695 }
5696
5697 mon_ctx->ChannelNo = sta_ctx->conn_info.operationChannel;
5698
5699 /*
5700 * In STA + Mon mode, firmware should not consider ChannelBW
5701 */
5702 mon_ctx->ChannelBW = 0;
5703 mon_ctx->crcCheckEnabled = 0;
5704 wlan_hdd_mon_set_typesubtype(mon_ctx, 100);
5705 mon_ctx->is80211to803ConReq = 0;
5706 WLANTL_SetIsConversionReq(vos_ctx, 0);
5707 mon_adapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
5708
5709 mon_ctx->state = MON_MODE_START;
5710 return 0;
5711}
5712
5713/* set param sub-ioctls */
5714static int __iw_mon_setint_getnone(struct net_device *dev,
5715 struct iw_request_info *info,
5716 union iwreq_data *wrqu, char *extra)
5717{
5718 hdd_adapter_t *adapter;
5719 hdd_context_t *hdd_ctx;
5720 hdd_mon_ctx_t *mon_ctx;
5721 int *value = (int *)extra;
5722 int sub_cmd = value[0];
5723 int set_value = value[1];
5724 int ret = 0; /* success */
5725 tVOS_CONCURRENCY_MODE concurrency_mode;
5726
5727 ENTER();
5728 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5729 if (!adapter || adapter->device_mode != WLAN_HDD_MONITOR)
5730 return -EINVAL;
5731
5732 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5733 ret = wlan_hdd_validate_context(hdd_ctx);
5734 if (ret)
5735 return ret;
5736
5737 concurrency_mode = hdd_ctx->concurrency_mode;
5738 if (concurrency_mode != VOS_STA_MON) {
5739 hddLog(LOGE, "invalid concurrency mode %d", concurrency_mode);
5740 return -EINVAL;
5741 }
5742
5743 switch(sub_cmd) {
5744
5745 case WE_SET_MONITOR_STATE:
5746 {
5747 v_U32_t magic = 0;
5748 struct completion cmp_var;
5749 long waitRet = 0;
5750
5751 mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter);
5752 if(!mon_ctx) {
5753 hddLog(LOGE, "Monitor Context NULL");
5754 ret = -EIO;
5755 break;
5756 }
5757
5758 if (mon_ctx->state == set_value) {
5759 hddLog(LOGE, FL("already in same mode curr_mode:%d req_mode: %d"),
5760 mon_ctx->state, set_value);
5761 break;
5762 }
5763
5764 ret = wlan_hdd_sta_mon_op(hdd_ctx, set_value,
5765 adapter,mon_ctx);
5766 if (ret)
5767 break;
5768
5769 mon_ctx->state = set_value;
5770 magic = MON_MODE_MSG_MAGIC;
5771 init_completion(&cmp_var);
5772 if (wlan_hdd_mon_postMsg(&magic, &cmp_var, mon_ctx,
5773 hdd_monPostMsgCb) != VOS_STATUS_SUCCESS) {
5774 hddLog(LOGE, FL("failed to post MON MODE REQ"));
5775 mon_ctx->state =
5776 (mon_ctx->state==MON_MODE_START) ?
5777 MON_MODE_STOP : MON_MODE_START;
5778 magic = 0;
5779 ret = -EIO;
5780 break;
5781 }
5782
5783 waitRet = wait_for_completion_timeout(&cmp_var,
5784 MON_MODE_MSG_TIMEOUT);
5785 magic = 0;
5786 if (waitRet <= 0 ){
5787 hddLog(LOGE, FL("failed to wait on monitor mode completion %ld"),
5788 waitRet);
5789 } else if (mon_ctx->state == MON_MODE_STOP) {
5790 hddLog(LOG1, FL("Enable BMPS"));
5791 hdd_enable_bmps_imps(hdd_ctx);
5792 hdd_restore_roaming(hdd_ctx);
5793 }
5794 }
5795 break;
5796
5797 default:
5798 {
5799 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
5800 sub_cmd, set_value);
5801 }
5802 break;
5803 }
5804
5805 EXIT();
5806 return ret;
5807}
5808
Jeff Johnson295189b2012-06-20 16:38:30 -07005809/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305810static int __iw_setint_getnone(struct net_device *dev,
5811 struct iw_request_info *info,
5812 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005813{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305814 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305815 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305816 hdd_wext_state_t *pWextState;
5817 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305818 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 int *value = (int *)extra;
5820 int sub_cmd = value[0];
5821 int set_value = value[1];
5822 int ret = 0; /* success */
5823 int enable_pbm, enable_mp;
5824#ifdef CONFIG_HAS_EARLYSUSPEND
5825 v_U8_t nEnableSuspendOld;
5826#endif
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305827 void *cookie;
5828 struct hdd_request *request;
Jeff Johnson295189b2012-06-20 16:38:30 -07005829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305830 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305831 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5832 if (NULL == pAdapter)
5833 {
5834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5835 "%s: Adapter is NULL",__func__);
5836 return -EINVAL;
5837 }
5838 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5839 ret = wlan_hdd_validate_context(pHddCtx);
5840 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005841 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305842 return ret;
5843 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305844
Katya Nigameae74b62015-05-28 17:19:16 +05305845 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305846 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305847 /* In monitor mode hHal is NULL */
5848 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5849 if (NULL == hHal)
5850 {
5851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5852 "%s: Hal Context is NULL",__func__);
5853 return -EINVAL;
5854 }
Katya Nigameae74b62015-05-28 17:19:16 +05305855 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5856 if (NULL == pWextState)
5857 {
5858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5859 "%s: pWextState is NULL",__func__);
5860 return -EINVAL;
5861 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005862
Katya Nigameae74b62015-05-28 17:19:16 +05305863 INIT_COMPLETION(pWextState->completion_var);
5864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 switch(sub_cmd)
5866 {
5867 case WE_SET_11D_STATE:
5868 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005869 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005870 memset(&smeConfig, 0x00, sizeof(smeConfig));
5871
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305872 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5873 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 sme_GetConfigParam(hHal,&smeConfig);
5875 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5876
Arif Hussain6d2a3322013-11-17 19:50:10 -08005877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005878
5879 sme_UpdateConfig(hHal,&smeConfig);
5880 }
5881 else {
5882 return -EINVAL;
5883 }
5884 break;
5885 }
5886
5887 case WE_WOWL:
5888 {
5889 switch (set_value)
5890 {
5891 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305892 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 break;
5894 case 0x01:
5895 case 0x02:
5896 case 0x03:
5897 enable_mp = (set_value & 0x01) ? 1 : 0;
5898 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005899 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5901 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5902 break;
5903 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005904 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 ret = -EINVAL;
5906 break;
5907 }
5908
5909 break;
5910 }
5911 case WE_SET_POWER:
5912 {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305913 if (wlan_hdd_check_monitor_state(pHddCtx)) {
5914 hddLog(LOGE, FL("setPower not allowed in STA + MON"));
5915 ret = -EOPNOTSUPP;
5916 break;
5917 }
5918
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 switch (set_value)
5920 {
5921 case 0: //Full Power
5922 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305923 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305924 static const struct hdd_request_params params = {
5925 .priv_size = 0,
5926 .timeout_ms = WLAN_WAIT_TIME_POWER,
5927 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005928
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305929 if (NULL == hHal)
5930 return -EINVAL;
5931
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305932 request = hdd_request_alloc(&params);
5933 if (!request) {
5934 hddLog(VOS_TRACE_LEVEL_ERROR,
5935 FL("Request allocation failure"));
5936 return VOS_STATUS_E_NOMEM;
5937 }
5938 cookie = hdd_request_cookie(request);
5939
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305941 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305943
Jeff Johnson72a40512013-12-19 10:14:15 -08005944 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305946 ret = hdd_request_wait_for_response(request);
5947 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005948 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305949 FL("SME timeout while requesting bmps"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 }
5951 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305952
5953 /*
5954 * either we never sent a request, we sent a request and
5955 * received a response or we sent a request and timed out.
5956 * Regardless we are done with the request.
5957 */
5958 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005959
Arif Hussain6d2a3322013-11-17 19:50:10 -08005960 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 break;
5962 }
5963 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305964 if (hHal)
5965 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5966 else
5967 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 break;
5969 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305970 if (hHal)
5971 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5972 else
5973 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 break;
5975 case 3: //Request Bmps
5976 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305977 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305978 static const struct hdd_request_params params = {
5979 .priv_size = 0,
5980 .timeout_ms = WLAN_WAIT_TIME_POWER,
5981 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005982
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305983 if (NULL == hHal)
5984 return -EINVAL;
5985
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305986 request = hdd_request_alloc(&params);
5987 if (!request) {
5988 hddLog(VOS_TRACE_LEVEL_ERROR,
5989 FL("Request allocation failure"));
5990 return VOS_STATUS_E_NOMEM;
5991 }
5992 cookie = hdd_request_cookie(request);
5993
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305995 iw_power_callback_func, cookie);
Jeff Johnson72a40512013-12-19 10:14:15 -08005996 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305998 ret = hdd_request_wait_for_response(request);
5999 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08006000 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05306001 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 }
6003 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05306004
6005 /*
6006 * either we never sent a request, we sent a request and
6007 * received a response or we sent a request and timed out.
6008 * Regardless we are done with the request.
6009 */
6010 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08006011
Arif Hussain6d2a3322013-11-17 19:50:10 -08006012 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 break;
6014 }
6015 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306016 if (hHal)
6017 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
6018 else
6019 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 break;
6021 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306022 if (hHal)
6023 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
6024 else
6025 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 break;
6027 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306028 if (hHal)
6029 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
6030 else
6031 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 break;
6033 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306034 if (hHal)
6035 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
6036 else
6037 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 break;
6039 case 8: //Request Standby
6040#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07006041#endif
6042 break;
6043 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306044 if (hHal)
6045 sme_StartAutoBmpsTimer(hHal);
6046 else
6047 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 break;
6049 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306050 if (hHal)
6051 sme_StopAutoBmpsTimer(hHal);
6052 else
6053 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 break;
6055#ifdef CONFIG_HAS_EARLYSUSPEND
6056 case 11://suspend to standby
6057#ifdef CONFIG_HAS_EARLYSUSPEND
6058 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
6059 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
6061#endif
6062 break;
6063 case 12://suspend to deep sleep
6064#ifdef CONFIG_HAS_EARLYSUSPEND
6065 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
6066 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
6068#endif
6069 break;
6070 case 13://resume from suspend
6071#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07006072#endif
6073 break;
6074#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006076 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 ret = -EINVAL;
6078 break;
6079 }
6080 break;
6081 }
6082
6083 case WE_SET_MAX_ASSOC:
6084 {
6085 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306086 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
6087 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 {
6089 ret = -EINVAL;
6090 }
6091 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
6092 set_value, NULL, eANI_BOOLEAN_FALSE)
6093 != eHAL_STATUS_SUCCESS )
6094 {
c_hpothub8245442013-11-20 23:41:09 +05306095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6096 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 ret = -EIO;
6098 }
6099 break;
6100 }
6101
6102 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
6103 {
6104 if( 0 == set_value )
6105 {
6106 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
6107 }
6108 else if ( 1 == set_value )
6109 {
6110 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
6111 }
6112 else
6113 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006114 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 ret = -EINVAL;
6116 }
6117 break;
6118 }
6119
6120 case WE_SET_DATA_INACTIVITY_TO:
6121 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306122 if (NULL == hHal)
6123 return -EINVAL;
6124
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
6126 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
6127 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6128 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
6129 set_value,
6130 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
6131 {
6132 hddLog(LOGE,"Failure: Could not pass on "
6133 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006134 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 ret = -EINVAL;
6136 }
6137 break;
6138 }
6139 case WE_SET_MAX_TX_POWER:
6140 {
6141 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6142 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6143
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306144 if (NULL == hHal)
6145 return -EINVAL;
6146
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
6148 __func__, set_value);
6149 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
6150 eHAL_STATUS_SUCCESS )
6151 {
6152 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6153 __func__);
6154 return -EIO;
6155 }
6156
6157 break;
6158 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07006159 case WE_SET_MAX_TX_POWER_2_4:
6160 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306161 if (NULL == hHal)
6162 return -EINVAL;
6163
Arif Hussaina5ebce02013-08-09 15:09:58 -07006164 hddLog(VOS_TRACE_LEVEL_INFO,
6165 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6166 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306167 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006168 eHAL_STATUS_SUCCESS)
6169 {
6170 hddLog(VOS_TRACE_LEVEL_ERROR,
6171 "%s: Setting maximum tx power failed for 2.4 GHz band",
6172 __func__);
6173 return -EIO;
6174 }
6175
6176 break;
6177 }
6178 case WE_SET_MAX_TX_POWER_5_0:
6179 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306180 if (NULL == hHal)
6181 return -EINVAL;
6182
Arif Hussaina5ebce02013-08-09 15:09:58 -07006183 hddLog(VOS_TRACE_LEVEL_INFO,
6184 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6185 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306186 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006187 eHAL_STATUS_SUCCESS)
6188 {
6189 hddLog(VOS_TRACE_LEVEL_ERROR,
6190 "%s: Setting maximum tx power failed for 5.0 GHz band",
6191 __func__);
6192 return -EIO;
6193 }
6194
6195 break;
6196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 case WE_SET_HIGHER_DTIM_TRANSITION:
6198 {
6199 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6200 (set_value == eANI_BOOLEAN_TRUE)))
6201 {
6202 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6203 ret = -EINVAL;
6204 }
6205 else
6206 {
6207 if(pAdapter->higherDtimTransition != set_value)
6208 {
6209 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006210 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 }
6212 }
6213
6214 break;
6215 }
6216
6217 case WE_SET_TM_LEVEL:
6218 {
6219 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006220 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6222
6223 break;
6224 }
6225
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306226 case WE_ENABLE_STRICT_FCC_REG:
6227 {
6228 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6229 struct wiphy *wiphy = NULL;
6230 long lrc;
6231 int status;
6232
6233 wiphy = hddCtxt->wiphy;
6234 if(wiphy == NULL)
6235 {
6236 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6237 break;
6238 }
6239 init_completion(&hddCtxt->wiphy_channel_update_event);
6240
6241 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6242
6243 status = regulatory_hint(wiphy, "00");
6244 if(status < 0)
6245 {
6246 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6247 break;
6248 }
6249
6250 /* Wait for completion */
6251 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6252 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6253 if (lrc <= 0)
6254 {
6255 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6256 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6257 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6258 }
6259 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6260
6261 break;
6262 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006263 case WE_SET_DEBUG_LOG:
6264 {
6265 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6266 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306267 if (hHal)
6268 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6269 else
6270 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006271 break;
6272 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306273#ifdef FEATURE_WLAN_TDLS
6274 case WE_SET_TDLS_OFF_CHAN:
6275 {
6276 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6278 __func__, set_value);
6279 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6280 break;
6281 }
6282 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6283 {
6284 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6286 __func__, set_value);
6287 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6288 break;
6289 }
6290 case WE_SET_TDLS_OFF_CHAN_MODE:
6291 {
6292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6293 __func__, set_value);
6294 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6295 break;
6296 }
6297#endif
Peng Xu2446a892014-09-05 17:21:18 +05306298 case WE_SET_SCAN_BAND_PREFERENCE:
6299 {
6300 tSmeConfigParams smeConfig;
6301 memset(&smeConfig, 0x00, sizeof(smeConfig));
6302 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6303 ret = -EINVAL;
6304 break;
6305 }
6306 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6307
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306308 if ((eCSR_BAND_ALL == set_value ||
6309 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6310 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306311 sme_GetConfigParam(hHal, &smeConfig);
6312 smeConfig.csrConfig.scanBandPreference = set_value;
6313
6314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6315 "set band scan preference = %d\n",
6316 smeConfig.csrConfig.scanBandPreference);
6317
6318 sme_UpdateConfig(hHal, &smeConfig);
6319 }
6320 else {
6321 ret = -EINVAL;
6322 }
6323 break;
6324 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306325 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6326 * connection happens so that the params can take effect during
6327 * association. Also this should not be used in STA+p2p concurrency
6328 * as the param will also effect the STA mode.
6329 */
6330 case WE_SET_MIRACAST_VENDOR_CONFIG:
6331 {
6332 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306333
Abhishek Singh01c73d12015-03-12 15:13:44 +05306334 hddLog(LOG1, FL(
6335 "Set Miracast vendor tuning %d"), set_value);
6336
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306337 if (NULL == hHal)
6338 return -EINVAL;
6339
Abhishek Singh01c73d12015-03-12 15:13:44 +05306340 if (1 == set_value || 0 == set_value)
6341 {
6342 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6343 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6344 {
6345 hddLog( LOGE, FL("set vendor miracast config failed"));
6346 ret = -EIO;
6347 }
6348 }
6349 else
6350 {
6351 hddLog(LOGE,
6352 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6353 ret = -EINVAL;
6354 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306355 break;
6356 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306357
6358 case WE_GET_FRAME_LOG:
6359 {
6360 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6361 != VOS_STATUS_SUCCESS)
6362 {
6363 ret = -EINVAL;
6364 }
6365 break;
6366 }
6367
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306368 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6369 {
6370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6371 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306372 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306373 {
6374 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6375 set_value);
6376 }
6377 else
6378 ret = -EINVAL;
6379
6380 break;
6381 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306382 /* Bit mask value to enable RTS/CTS for different modes
6383 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6384 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6385 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6386 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6387 * for 5 GHz, VHT80 - 0x1000
6388 */
6389 case WE_SET_RTS_CTS_HTVHT:
6390 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306391
Abhishek Singh41988ba2015-05-25 19:42:29 +05306392 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6393
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306394 if (NULL == hHal)
6395 return -EINVAL;
6396
Abhishek Singh41988ba2015-05-25 19:42:29 +05306397 if (eHAL_STATUS_SUCCESS !=
6398 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6399 {
6400 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6401 ret = -EINVAL;
6402 }
6403 break;
6404 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306405 case WE_SET_MONITOR_STATE:
6406 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306407 v_U32_t magic = 0;
6408 struct completion cmpVar;
6409 long waitRet = 0;
6410 tVOS_CON_MODE mode = hdd_get_conparam();
6411
6412 if( VOS_MONITOR_MODE != mode)
6413 {
6414 hddLog(LOGE, "invalid mode %d", mode);
6415 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306416 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306417 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306418
6419 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6420 if( pMonCtx == NULL )
6421 {
6422 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306423 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306424 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306425 }
6426 if (pMonCtx->state == set_value)
6427 {
6428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6429 FL("already in same mode curr_mode:%d req_mode: %d"),
6430 pMonCtx->state, set_value);
6431 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306432 }
6433 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306434 magic = MON_MODE_MSG_MAGIC;
6435 init_completion(&cmpVar);
6436 if (VOS_STATUS_SUCCESS !=
6437 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6438 pMonCtx, hdd_monPostMsgCb)) {
6439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6440 FL("failed to post MON MODE REQ"));
6441 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6442 MON_MODE_STOP : MON_MODE_START;
6443 magic = 0;
6444 ret = -EIO;
6445 break;
6446 }
6447 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6448 magic = 0;
6449 if (waitRet <= 0 ){
6450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6451 FL("failed to wait on monitor mode completion %ld"),
6452 waitRet);
6453 }
6454 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306455 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306456 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6457 {
6458 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6459 tAniWifiStartLog start_log;
6460 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6461 !vos_isPktStatsEnabled())
6462 {
6463 hddLog(LOGE, FL("per pkt stats not enabled"));
6464 return -EINVAL;
6465 }
6466 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6467
6468 if (1 == set_value || 0 == set_value)
6469 {
6470 start_log.ringId = RING_ID_PER_PACKET_STATS;
6471 start_log.flag = 0;
6472 if (set_value)
6473 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6474 else
6475 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6476
6477 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6478 }
6479 else
6480 {
6481 hddLog(LOGE,
6482 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6483 set_value);
6484 ret = -EINVAL;
6485 }
6486 break;
6487 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306488 case WE_SET_PROXIMITY_ENABLE:
6489 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306490 if (NULL == hHal)
6491 return -EINVAL;
6492
6493 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306494 break;
6495 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306496 case WE_CAP_TSF:
6497 {
6498 if (NULL == hHal)
6499 return -EINVAL;
6500
6501 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6502 break;
6503 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306504 case WE_SET_MODULATED_DTIM:
6505 {
6506 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6507 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6508 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6509 set_value);
6510 return -EINVAL;
6511 } else {
6512 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6513 enableModulatedDTIM = set_value;
6514 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306515 }
6516 case WLAN_SET_DYNNAMIC_AGGREGATION:
6517 {
6518 if (NULL == hHal)
6519 return -EINVAL;
6520
6521 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306522 break;
6523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 default:
6525 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006526 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 sub_cmd, set_value);
6528 break;
6529 }
6530 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306531 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 return ret;
6533}
6534
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306535static int iw_setint_getnone(struct net_device *dev,
6536 struct iw_request_info *info,
6537 union iwreq_data *wrqu, char *extra)
6538{
6539 int ret;
6540
6541 vos_ssr_protect(__func__);
6542 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6543 vos_ssr_unprotect(__func__);
6544
6545 return 0;
6546}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306547
6548static
6549int iw_mon_setint_getnone(struct net_device *dev,
6550 struct iw_request_info *info,
6551 union iwreq_data *wrqu, char *extra)
6552{
6553 int ret;
6554
6555 vos_ssr_protect(__func__);
6556 ret = __iw_mon_setint_getnone(dev, info, wrqu, extra);
6557 vos_ssr_unprotect(__func__);
6558
6559 return 0;
6560}
6561
Jeff Johnson295189b2012-06-20 16:38:30 -07006562/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306563static int __iw_setchar_getnone(struct net_device *dev,
6564 struct iw_request_info *info,
6565 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006566{
6567 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306568 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006570 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306571 hdd_adapter_t *pAdapter;
6572 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006573#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306574 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006575#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306576 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306577 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006578
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306579 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306580
6581 if (!capable(CAP_NET_ADMIN))
6582 {
6583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6584 FL("permission check failed"));
6585 return -EPERM;
6586 }
6587
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306588 pAdapter = (netdev_priv(dev));
6589 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006590 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6592 "%s: Adapter is NULL",__func__);
6593 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006594 }
6595
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306596 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6597 ret = wlan_hdd_validate_context(pHddCtx);
6598 if (0 != ret)
6599 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306600 return ret;
6601 }
6602#ifdef WLAN_FEATURE_VOWIFI
6603 pConfig = pHddCtx->cfg_ini;
6604#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306605 /* helper function to get iwreq_data with compat handling. */
6606 if (hdd_priv_get_data(&s_priv_data, wrqu))
6607 {
6608 return -EINVAL;
6609 }
6610
6611 /* make sure all params are correctly passed to function */
6612 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6613 {
6614 return -EINVAL;
6615 }
6616
6617 sub_cmd = s_priv_data.flags;
6618
Arif Hussain0273cba2014-01-07 20:58:29 -08006619 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306620 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6621 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006622 if (NULL == pBuffer)
6623 {
6624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6625 "mem_alloc_copy_from_user_helper fail");
6626 return -ENOMEM;
6627 }
6628
6629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306630 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6632 "%s: Received data %s", __func__, pBuffer);
6633
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 switch(sub_cmd)
6635 {
6636 case WE_WOWL_ADD_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306637 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6638 hddLog(LOGE, FL("wowlAddPtrn not allowed in STA + MON"));
6639 ret = -EOPNOTSUPP;
6640 break;
6641 }
6642
Arif Hussain6d2a3322013-11-17 19:50:10 -08006643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006644 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 break;
6646 case WE_WOWL_DEL_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306647 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6648 hddLog(LOGE, FL("wowlDelPtrn not allowed in STA + MON"));
6649 ret = -EOPNOTSUPP;
6650 break;
6651 }
6652
Arif Hussain6d2a3322013-11-17 19:50:10 -08006653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006654 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 break;
6656#if defined WLAN_FEATURE_VOWIFI
6657 case WE_NEIGHBOR_REPORT_REQUEST:
6658 {
6659 tRrmNeighborReq neighborReq;
6660 tRrmNeighborRspCallbackInfo callbackInfo;
6661
6662 if (pConfig->fRrmEnable)
6663 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306665 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 if( !neighborReq.no_ssid )
6667 {
Girish Gowli552fc072014-06-14 18:26:16 +05306668 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006669 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 }
6671
6672 callbackInfo.neighborRspCallback = NULL;
6673 callbackInfo.neighborRspCallbackContext = NULL;
6674 callbackInfo.timeout = 5000; //5 seconds
6675 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6676 }
6677 else
6678 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006679 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 ret = -EINVAL;
6681 }
6682 }
6683 break;
6684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 case WE_SET_AP_WPS_IE:
6686 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306687 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006690 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 if (VOS_STATUS_SUCCESS != vstatus)
6692 {
6693 ret = -EINVAL;
6694 }
6695 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306696 case WE_SET_ENCRYPT_MSG:
6697 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6698 if (NULL == pkt)
6699 {
6700 hddLog(VOS_TRACE_LEVEL_ERROR,
6701 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306702 ret = -ENOMEM;
6703 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306704 }
6705
6706 memset(pkt, 0, sizeof(tSirpkt80211));
6707
6708 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6709 hddLog(VOS_TRACE_LEVEL_ERROR,
6710 FL("Firmware is not DISA capable"));
6711 ret = -EINVAL;
6712 vos_mem_free(pkt);
6713 break;
6714 }
6715
6716 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6717
6718 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6719 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6720 if (eHAL_STATUS_SUCCESS != ret) {
6721 hddLog(VOS_TRACE_LEVEL_ERROR,
6722 FL("SENDEncryptMSG: fail to post WDA cmd"));
6723 ret = -EINVAL;
6724 }
6725 vos_mem_free(pkt);
6726
6727 break;
6728
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 default:
6730 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006731 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 ret = -EINVAL;
6733 break;
6734 }
6735 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006736 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306737
6738 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 return ret;
6740}
6741
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306742static int iw_setchar_getnone(struct net_device *dev,
6743 struct iw_request_info *info,
6744 union iwreq_data *wrqu, char *extra)
6745{
6746 int ret;
6747
6748 vos_ssr_protect(__func__);
6749 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6750 vos_ssr_unprotect(__func__);
6751
6752 return ret;
6753}
6754
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306755static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6756{
6757 struct statsContext *context;
6758 hdd_adapter_t *pAdapter;
6759
6760 if (NULL == pContext)
6761 {
6762 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07006763 "%s: Bad param, pContext [%pK]",
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306764 __func__, pContext);
6765 return;
6766 }
6767
6768 context = pContext;
6769 pAdapter = context->pAdapter;
6770
6771 spin_lock(&hdd_context_lock);
6772
6773 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6774 {
6775 /* the caller presumably timed out so there is nothing we can do */
6776 spin_unlock(&hdd_context_lock);
6777 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07006778 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306779 __func__, pAdapter, context->magic);
6780 return;
6781 }
6782
6783 context->magic = 0;
6784 pAdapter->antennaIndex = antennaId;
6785
6786 complete(&context->completion);
6787 spin_unlock(&hdd_context_lock);
6788}
6789
6790static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6791 int *antennaIndex)
6792{
6793 hdd_context_t *pHddCtx;
6794 eHalStatus halStatus;
6795 struct statsContext context;
6796 long lrc;
6797
6798 ENTER();
6799 if (NULL == pAdapter)
6800 {
6801 hddLog(VOS_TRACE_LEVEL_WARN,
6802 "%s: Invalid context, pAdapter", __func__);
6803 return VOS_STATUS_E_FAULT;
6804 }
6805 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6806 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6807 {
6808 return VOS_STATUS_E_FAULT;
6809 }
6810 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6811 {
6812 hddLog(VOS_TRACE_LEVEL_ERROR,
6813 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6814 __func__);
6815 return VOS_STATUS_E_NOSUPPORT;
6816 }
6817 init_completion(&context.completion);
6818 context.pAdapter = pAdapter;
6819 context.magic = ANTENNA_CONTEXT_MAGIC;
6820
6821 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6822 hdd_GetCurrentAntennaIndex,
6823 &context, pAdapter->sessionId);
6824 if (eHAL_STATUS_SUCCESS != halStatus)
6825 {
6826 spin_lock(&hdd_context_lock);
6827 context.magic = 0;
6828 spin_unlock(&hdd_context_lock);
6829 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6830 __func__);
6831 /* we'll returned a cached value below */
6832 *antennaIndex = -1;
6833 return VOS_STATUS_E_FAILURE;
6834 }
6835 else
6836 {
6837 /* request was sent -- wait for the response */
6838 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6839 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6840 if (lrc <= 0)
6841 {
6842 spin_lock(&hdd_context_lock);
6843 context.magic = 0;
6844 spin_unlock(&hdd_context_lock);
6845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6846 " Index",
6847 __func__, (0 == lrc) ? "timeout" : "interrupt");
6848 *antennaIndex = -1;
6849 return VOS_STATUS_E_FAILURE;
6850 }
6851 }
6852 spin_lock(&hdd_context_lock);
6853 context.magic = 0;
6854 spin_unlock(&hdd_context_lock);
6855
6856 *antennaIndex = pAdapter->antennaIndex;
6857
6858 EXIT();
6859 return VOS_STATUS_SUCCESS;
6860}
6861
Jeff Johnson295189b2012-06-20 16:38:30 -07006862/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306863static int __iw_setnone_getint(struct net_device *dev,
6864 struct iw_request_info *info,
6865 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006866{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306867 hdd_adapter_t *pAdapter;
6868 tHalHandle hHal;
6869 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 int *value = (int *)extra;
6871 int ret = 0; /* success */
6872
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306873 ENTER();
6874
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306875 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6876 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006877 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6879 "%s: Adapter is NULL",__func__);
6880 return -EINVAL;
6881 }
6882 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6883 ret = wlan_hdd_validate_context(pHddCtx);
6884 if (0 != ret)
6885 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306886 return ret;
6887 }
6888 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6889 if (NULL == hHal)
6890 {
6891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6892 "%s: Hal Context is NULL",__func__);
6893 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006895
6896 switch (value[0])
6897 {
6898 case WE_GET_11D_STATE:
6899 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006900 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306902
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6904
Arif Hussain6d2a3322013-11-17 19:50:10 -08006905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006906
6907 break;
6908 }
6909
6910 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 break;
6913
6914 case WE_PMC_STATE:
6915 {
6916 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 break;
6919 }
6920 case WE_GET_WLAN_DBG:
6921 {
6922 vos_trace_display();
6923 *value = 0;
6924 break;
6925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 case WE_GET_MAX_ASSOC:
6927 {
6928 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6929 {
c_hpothub8245442013-11-20 23:41:09 +05306930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6931 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 ret = -EIO;
6933 }
Girish Gowli385be612014-09-18 11:17:20 +05306934#ifdef WLAN_SOFTAP_VSTA_FEATURE
6935 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6936 {
6937 if (*value > VSTA_NUM_ASSOC_STA)
6938 {
6939 *value = VSTA_NUM_ASSOC_STA;
6940 }
6941 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6942 (*value > (VSTA_NUM_ASSOC_STA -
6943 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6944 {
6945 *value = (VSTA_NUM_ASSOC_STA -
6946 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6947 }
6948 }
6949 else
6950#endif
6951 {
6952 if (*value > NUM_ASSOC_STA)
6953 {
6954 *value = NUM_ASSOC_STA;
6955 }
6956 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6957 (*value > (NUM_ASSOC_STA -
6958 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6959 {
6960 *value = (NUM_ASSOC_STA -
6961 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6962 }
6963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 break;
6965 }
6966
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 case WE_GET_WDI_DBG:
6968 {
6969 wpalTraceDisplay();
6970 *value = 0;
6971 break;
6972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006973
6974 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6975 {
6976 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6977 break;
6978 }
6979 case WE_GET_CONCURRENCY_MODE:
6980 {
6981 *value = hdd_get_concurrency_mode ( );
6982
Arif Hussain6d2a3322013-11-17 19:50:10 -08006983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 break;
6985 }
6986
Peng Xu2446a892014-09-05 17:21:18 +05306987 case WE_GET_SCAN_BAND_PREFERENCE:
6988 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306989 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306990 sme_GetConfigParam(hHal, &smeConfig);
6991 *value = smeConfig.csrConfig.scanBandPreference;
6992
6993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6994 "scanBandPreference = %d\n", *value);
6995 break;
6996 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306997 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6998 {
6999 wlan_hdd_get_current_antenna_index(pAdapter, value);
7000 break;
7001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007002 default:
7003 {
7004 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
7005 break;
7006 }
7007 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307008 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 return ret;
7010}
7011
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307012static int iw_setnone_getint(struct net_device *dev,
7013 struct iw_request_info *info,
7014 union iwreq_data *wrqu, char *extra)
7015{
7016 int ret;
7017
7018 vos_ssr_protect(__func__);
7019 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7020 vos_ssr_unprotect(__func__);
7021
7022 return ret;
7023
7024}
Jeff Johnson295189b2012-06-20 16:38:30 -07007025/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307026int __iw_set_three_ints_getnone(struct net_device *dev,
7027 struct iw_request_info *info,
7028 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007029{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307030 hdd_adapter_t *pAdapter;
7031 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 int *value = (int *)extra;
7033 int sub_cmd = value[0];
7034 int ret = 0;
7035
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307036 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05307037
7038 if (!capable(CAP_NET_ADMIN))
7039 {
7040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7041 FL("permission check failed"));
7042 return -EPERM;
7043 }
7044
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307045 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7046 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007047 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7049 "%s: Adapter is NULL",__func__);
7050 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007051 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307052 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7053 ret = wlan_hdd_validate_context(pHddCtx);
7054 if (0 != ret)
7055 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307056 return ret;
7057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 switch(sub_cmd)
7059 {
7060 case WE_SET_WLAN_DBG:
7061 {
7062 vos_trace_setValue( value[1], value[2], value[3]);
7063 break;
7064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 case WE_SET_WDI_DBG:
7066 {
7067 wpalTraceSetLevel( value[1], value[2], value[3]);
7068 break;
7069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 case WE_SET_SAP_CHANNELS:
7071 {
7072 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
7073 break;
7074 }
7075
7076 default:
7077 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007078 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 break;
7080 }
7081 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307082 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 return ret;
7084}
7085
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307086int iw_set_three_ints_getnone(struct net_device *dev,
7087 struct iw_request_info *info,
7088 union iwreq_data *wrqu, char *extra)
7089{
7090 int ret;
7091
7092 vos_ssr_protect(__func__);
7093 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7094 vos_ssr_unprotect(__func__);
7095
7096 return ret;
7097}
7098
7099static int __iw_get_char_setnone(struct net_device *dev,
7100 struct iw_request_info *info,
7101 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007102{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307103 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307105 hdd_context_t *pHddCtx;
7106 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07007107#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007108 hdd_wext_state_t *pWextState;
7109#endif
7110
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307111 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307112 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007113 if (pAdapter == NULL)
7114 {
7115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7116 "%s: pAdapter is NULL!", __func__);
7117 return -EINVAL;
7118 }
Alok Kumar69a8b752017-11-08 15:24:32 +05307119
7120 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
7121 WLAN_HDD_FTM == pAdapter->device_mode)
7122 return ret;
7123
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307124 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7125 ret = wlan_hdd_validate_context(pHddCtx);
7126 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07007127 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307128 return ret;
7129 }
7130#ifdef WLAN_FEATURE_11W
7131 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7132 if (NULL == pWextState)
7133 {
7134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7135 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07007136 return -EINVAL;
7137 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307138#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007139
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 switch(sub_cmd)
7141 {
7142 case WE_WLAN_VERSION:
7143 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007144 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007145 break;
7146 }
7147
7148 case WE_GET_STATS:
7149 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307150 tHalHandle hHal = NULL;
7151 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7153 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
7154 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307155 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07007156
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307157
Jeff Johnson295189b2012-06-20 16:38:30 -07007158 snprintf(extra, WE_MAX_STR_LEN,
7159 "\nTransmit"
7160 "\ncalled %u, dropped %u, backpressured %u, queued %u"
7161 "\n dropped BK %u, BE %u, VI %u, VO %u"
7162 "\n classified BK %u, BE %u, VI %u, VO %u"
7163 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
7164 "\n queued BK %u, BE %u, VI %u, VO %u"
7165 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007166 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 "\n fetched BK %u, BE %u, VI %u, VO %u"
7168 "\n dequeued BK %u, BE %u, VI %u, VO %u"
7169 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007170 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 "\n flushed BK %u, BE %u, VI %u, VO %u"
7172 "\n\nReceive"
7173 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
7174 "\n\nResetsStats"
7175 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307176 "\n"
7177 "\n\nARP Transmit"
7178 "\nTransmit Count %u, dropped %u"
7179 "\n\nARP Receive"
7180 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 "\n",
7182 pStats->txXmitCalled,
7183 pStats->txXmitDropped,
7184 pStats->txXmitBackPressured,
7185 pStats->txXmitQueued,
7186
7187 pStats->txXmitDroppedAC[WLANTL_AC_BK],
7188 pStats->txXmitDroppedAC[WLANTL_AC_BE],
7189 pStats->txXmitDroppedAC[WLANTL_AC_VI],
7190 pStats->txXmitDroppedAC[WLANTL_AC_VO],
7191
7192 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
7193 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
7194 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
7195 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
7196
7197 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
7198 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
7199 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
7200 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
7201
7202 pStats->txXmitQueuedAC[WLANTL_AC_BK],
7203 pStats->txXmitQueuedAC[WLANTL_AC_BE],
7204 pStats->txXmitQueuedAC[WLANTL_AC_VI],
7205 pStats->txXmitQueuedAC[WLANTL_AC_VO],
7206
7207 pStats->txFetched,
7208 pStats->txFetchEmpty,
7209 pStats->txFetchLowResources,
7210 pStats->txFetchDequeueError,
7211
7212 pStats->txFetchDequeued,
7213 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07007214 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 pStats->txCompleted,
7216 pStats->txFlushed,
7217
7218 pStats->txFetchedAC[WLANTL_AC_BK],
7219 pStats->txFetchedAC[WLANTL_AC_BE],
7220 pStats->txFetchedAC[WLANTL_AC_VI],
7221 pStats->txFetchedAC[WLANTL_AC_VO],
7222
7223 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7224 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7225 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7226 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7227
7228 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7229 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7230 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7231 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7232
Ravi Joshi41914632013-10-21 23:02:21 -07007233 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7234 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7235 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7236 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7237
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 pStats->txFlushedAC[WLANTL_AC_BK],
7239 pStats->txFlushedAC[WLANTL_AC_BE],
7240 pStats->txFlushedAC[WLANTL_AC_VI],
7241 pStats->txFlushedAC[WLANTL_AC_VO],
7242
7243 pStats->rxChains,
7244 pStats->rxPackets,
7245 pStats->rxDropped,
7246 pStats->rxDelivered,
7247 pStats->rxRefused,
7248
7249 pResetStats->totalLogpResets,
7250 pResetStats->totalCMD53Failures,
7251 pResetStats->totalMutexReadFailures,
7252 pResetStats->totalMIFErrorFailures,
7253 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307254 pResetStats->totalUnknownExceptions,
7255
7256 parpStats->txCount,
7257 parpStats->txDropped,
7258
7259 parpStats->rxCount,
7260 parpStats->rxDropped,
7261 parpStats->rxDelivered,
7262 parpStats->rxRefused,
7263 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307265 wrqu->data.length = strlen(extra);
7266
7267 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7268
7269 if (hHal)
7270 pMac = PMAC_STRUCT( hHal );
7271
7272 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7273 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7274 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307275 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7276 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7277 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7278 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307279 "\n",
7280 pMac->pmm.BmpscntSleep,
7281 pMac->pmm.BmpscntAwake,
7282 pMac->pmm.BmpsSleeReqFailCnt,
7283 pMac->pmm.BmpsWakeupReqFailCnt,
7284 pMac->pmm.ImpsCntSleep,
7285 pMac->pmm.ImpsCntAwake,
7286 pMac->pmm.ImpsSleepErrCnt,
7287 pMac->pmm.ImpsWakeupErrCnt,
7288 pMac->pmm.ImpsLastErr
7289 );
7290 }
7291
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 wrqu->data.length = strlen(extra)+1;
7293 break;
7294 }
7295
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307296/* The case prints the current state of the HDD, SME, CSR, PE, TL
7297 *it can be extended for WDI Global State as well.
7298 *And currently it only checks P2P_CLIENT adapter.
7299 *P2P_DEVICE and P2P_GO have not been added as of now.
7300*/
7301 case WE_GET_STATES:
7302 {
7303 int buf = 0, len = 0;
7304 int adapter_num = 0;
7305 int count = 0, check = 1;
7306
7307 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007308 tHalHandle hHal = NULL;
7309 tpAniSirGlobal pMac = NULL;
7310 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307311
7312 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7313 hdd_adapter_t *useAdapter = NULL;
7314
7315 /* Print wlan0 or p2p0 states based on the adapter_num
7316 *by using the correct adapter
7317 */
7318 while ( adapter_num < 2 )
7319 {
7320 if ( WLAN_ADAPTER == adapter_num )
7321 {
7322 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007323 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307324 "\n\n wlan0 States:-");
7325 len += buf;
7326 }
7327 else if ( P2P_ADAPTER == adapter_num )
7328 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007329 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307330 "\n\n p2p0 States:-");
7331 len += buf;
7332
7333 if( !pHddCtx )
7334 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007335 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307336 "\n pHddCtx is NULL");
7337 len += buf;
7338 break;
7339 }
7340
7341 /*Printing p2p0 states only in the case when the device is
7342 configured as a p2p_client*/
7343 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7344 if ( !useAdapter )
7345 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007346 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307347 "\n Device not configured as P2P_CLIENT.");
7348 len += buf;
7349 break;
7350 }
7351 }
7352
7353 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007354 if (!hHal) {
7355 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7356 "\n pMac is NULL");
7357 len += buf;
7358 break;
7359 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307360 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007361 if (!pMac) {
7362 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7363 "\n pMac is NULL");
7364 len += buf;
7365 break;
7366 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307367 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7368 if( !pHddStaCtx )
7369 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007370 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307371 "\n pHddStaCtx is NULL");
7372 len += buf;
7373 break;
7374 }
7375
7376 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7377
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007378 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307379 "\n HDD Conn State - %s "
7380 "\n \n SME State:"
7381 "\n Neighbour Roam State - %s"
7382 "\n CSR State - %s"
7383 "\n CSR Substate - %s"
7384 "\n \n TL STA %d State: %s",
7385 macTraceGetHDDWlanConnState(
7386 pHddStaCtx->conn_info.connState),
7387 macTraceGetNeighbourRoamState(
7388 pMac->roam.neighborRoamInfo.neighborRoamState),
7389 macTraceGetcsrRoamState(
7390 pMac->roam.curState[useAdapter->sessionId]),
7391 macTraceGetcsrRoamSubState(
7392 pMac->roam.curSubState[useAdapter->sessionId]),
7393 pHddStaCtx->conn_info.staId[0],
7394 macTraceGetTLState(tlState)
7395 );
7396 len += buf;
7397 adapter_num++;
7398 }
7399
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007400 if (pMac) {
7401 /* Printing Lim State starting with global lim states */
7402 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7403 "\n \n LIM STATES:-"
7404 "\n Global Sme State - %s "\
7405 "\n Global mlm State - %s "\
7406 "\n",
7407 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7408 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7409 );
7410 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307411
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007412 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307413 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307414 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007415 if ( pMac->lim.gpSession[count].valid )
7416 {
7417 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7418 "\n Lim Valid Session %d:-"
7419 "\n PE Sme State - %s "
7420 "\n PE Mlm State - %s "
7421 "\n",
7422 check,
7423 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7424 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7425 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307426
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007427 len += buf;
7428 check++;
7429 }
7430 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307431 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307432 }
7433
7434 wrqu->data.length = strlen(extra)+1;
7435 break;
7436 }
7437
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 case WE_GET_CFG:
7439 {
7440 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7441 wrqu->data.length = strlen(extra)+1;
7442 break;
7443 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007444#ifdef WLAN_FEATURE_11AC
7445 case WE_GET_RSSI:
7446 {
7447 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307448 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007449 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7450 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7451 wrqu->data.length = strlen(extra)+1;
7452 break;
7453 }
7454#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307455
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007456#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007457 case WE_GET_ROAM_RSSI:
7458 {
7459 v_S7_t s7Rssi = 0;
7460 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7461 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7462 wrqu->data.length = strlen(extra)+1;
7463 break;
7464 }
7465#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 case WE_GET_WMM_STATUS:
7467 {
7468 snprintf(extra, WE_MAX_STR_LEN,
7469 "\nDir: 0=up, 1=down, 3=both\n"
7470 "|------------------------|\n"
7471 "|AC | ACM |Admitted| Dir |\n"
7472 "|------------------------|\n"
7473 "|VO | %d | %3s | %d |\n"
7474 "|VI | %d | %3s | %d |\n"
7475 "|BE | %d | %3s | %d |\n"
7476 "|BK | %d | %3s | %d |\n"
7477 "|------------------------|\n",
7478 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7479 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7480 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7481 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7482 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7483 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7484 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7485 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7486 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7487 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7488 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7489 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7490
Jeff Johnsone7245742012-09-05 17:12:55 -07007491
Jeff Johnson295189b2012-06-20 16:38:30 -07007492 wrqu->data.length = strlen(extra)+1;
7493 break;
7494 }
7495 case WE_GET_CHANNEL_LIST:
7496 {
7497 VOS_STATUS status;
7498 v_U8_t i, len;
7499 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307500 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7501 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7502 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 tChannelListInfo channel_list;
7504
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007505 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007507 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007509 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 return -EINVAL;
7511 }
7512 buf = extra;
7513
7514 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007515 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7516 * needed = 5 * number of channels. Check ifsufficient
7517 * buffer is available and then proceed to fill the buffer.
7518 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7520 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007521 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007522 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007523 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 return -EINVAL;
7525 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007526 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7527 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307528 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7529 {
7530 //Printing Country code in getChannelList
7531 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7532 {
7533 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7534 "%c ", pBuf[i]);
7535 }
7536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 for(i = 0 ; i < channel_list.num_channels; i++)
7538 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007539 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 }
7542 wrqu->data.length = strlen(extra)+1;
7543
7544 break;
7545 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007546#ifdef FEATURE_WLAN_TDLS
7547 case WE_GET_TDLS_PEERS:
7548 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007549 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007550 break;
7551 }
7552#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007553#ifdef WLAN_FEATURE_11W
7554 case WE_GET_11W_INFO:
7555 {
7556 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7557
7558 snprintf(extra, WE_MAX_STR_LEN,
7559 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7560 "\n Number of Unprotected Disassocs %d"
7561 "\n Number of Unprotected Deauths %d",
7562 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7563 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7564 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7565 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7566 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7567
7568 wrqu->data.length = strlen(extra)+1;
7569 break;
7570 }
7571#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307572#ifdef WLAN_FEATURE_RMC
7573 case WE_GET_IBSS_STA_INFO:
7574 {
7575 hdd_station_ctx_t *pHddStaCtx =
7576 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7577 int idx = 0;
7578 int length = 0, buf = 0;
7579
7580 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7581 {
7582 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7583 {
7584 buf = snprintf
7585 (
7586 (extra + length), WE_MAX_STR_LEN - length,
7587 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7588 pHddStaCtx->conn_info.staId[ idx ],
7589 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7590 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7591 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7592 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7593 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7594 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7595 );
7596 length += buf;
7597 }
7598 }
7599 wrqu->data.length = strlen(extra)+1;
7600 break;
7601 }
7602#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307603 case WE_GET_SNR:
7604 {
7605 v_S7_t s7snr = 0;
7606 int status = 0;
7607 hdd_context_t *pHddCtx;
7608 hdd_station_ctx_t *pHddStaCtx;
7609
7610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7611 status = wlan_hdd_validate_context(pHddCtx);
7612 if (0 != status)
7613 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307614 return status;
7615 }
7616
7617 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7618
7619 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7620 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7621 {
7622 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7623 " ConnectionState-%d", __func__,
7624 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7625 pHddStaCtx->conn_info.connState);
7626 return -ENONET;
7627 }
7628
7629 /*update the stats in TL*/
7630 wlan_hdd_get_station_stats(pAdapter);
7631 wlan_hdd_get_snr(pAdapter, &s7snr);
7632 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7633 wrqu->data.length = strlen(extra) + 1;
7634 break;
7635 }
7636
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307637#ifdef FEATURE_OEM_DATA_SUPPORT
7638 case WE_GET_OEM_DATA_CAP:
7639 {
7640 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7641 }
7642#endif /* FEATURE_OEM_DATA_SUPPORT */
7643
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307644 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007646 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 break;
7648 }
7649 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307650 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 return 0;
7652}
7653
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307654static int iw_get_char_setnone(struct net_device *dev,
7655 struct iw_request_info *info,
7656 union iwreq_data *wrqu, char *extra)
7657{
7658 int ret;
7659
7660 vos_ssr_protect(__func__);
7661 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7662 vos_ssr_unprotect(__func__);
7663
7664 return ret;
7665}
7666
Jeff Johnson295189b2012-06-20 16:38:30 -07007667/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307668static int __iw_setnone_getnone(struct net_device *dev,
7669 struct iw_request_info *info,
7670 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007671{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307672 hdd_adapter_t *pAdapter;
7673 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307674 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007675 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307676 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007677
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307678 ENTER();
7679
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307680 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7681 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007682 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7684 "%s: Adapter is NULL",__func__);
7685 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007686 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7688 ret = wlan_hdd_validate_context(pHddCtx);
7689 if (0 != ret)
7690 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307691 return ret;
7692 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307693 /* helper function to get iwreq_data with compat handling. */
7694 if (hdd_priv_get_data(&s_priv_data, wrqu))
7695 {
7696 return -EINVAL;
7697 }
7698
7699 sub_cmd = s_priv_data.flags;
7700
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 switch (sub_cmd)
7702 {
7703 case WE_CLEAR_STATS:
7704 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7707 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7708 break;
7709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 case WE_INIT_AP:
7711 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307712 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7713
7714 /* As Soft AP mode might been changed to STA already with
7715 * killing of Hostapd, need to find the adpater by name
7716 * rather than mode */
7717 hdd_adapter_t* pAdapter_to_stop =
7718 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7719 if( pAdapter_to_stop )
7720 {
7721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7722 "Adapter with name softap.0 already "
7723 "exist, ignoring the request.\nRemove the "
7724 "adapter and try again\n");
7725 break;
7726 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05307727
7728 if (wlan_hdd_check_monitor_state(pHddCtx)) {
7729 hddLog(LOGE, FL("initAP not allowed in STA + MON"));
7730 ret = -EOPNOTSUPP;
7731 break;
7732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007733 pr_info("Init AP trigger\n");
7734 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7735 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7736 break;
7737 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307738#ifdef WLAN_FEATURE_RMC
7739 case WE_IBSS_GET_PEER_INFO_ALL:
7740 {
7741 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7742 break;
7743 }
7744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 case WE_STOP_AP:
7746 {
7747 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7748 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7749 * this is a dead code and need to find the adpater by name rather than mode */
7750 hdd_adapter_t* pAdapter_to_stop =
7751 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7752 if( pAdapter_to_stop )
7753 {
7754 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7755
7756 pr_info("Stopping AP mode\n");
7757
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307758 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7759 {
7760 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7761 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7762 }
7763
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307765 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307766 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7768
7769 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7770 pAdapter_to_stop->macAddressCurrent.bytes);
7771 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7772 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307773
7774 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7775 {
7776 /* put the device back into BMPS */
7777 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 }
7780 else
7781 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007782 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 }
7784
7785 break;
7786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007787#ifdef WLAN_BTAMP_FEATURE
7788 case WE_ENABLE_AMP:
7789 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 WLANBAP_RegisterWithHCI(pAdapter);
7792 break;
7793 }
7794 case WE_DISABLE_AMP:
7795 {
7796 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7797 VOS_STATUS status;
7798
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007800
7801 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7802 status = WLANBAP_StopAmp();
7803 if(VOS_STATUS_SUCCESS != status )
7804 {
7805 pHddCtx->isAmpAllowed = VOS_TRUE;
7806 hddLog(VOS_TRACE_LEVEL_FATAL,
7807 "%s: Failed to stop AMP", __func__);
7808 }
7809 else
7810 {
7811 //a state m/c implementation in PAL is TBD to avoid this delay
7812 msleep(500);
7813 pHddCtx->isAmpAllowed = VOS_FALSE;
7814 WLANBAP_DeregisterFromHCI();
7815 }
7816
7817 break;
7818 }
7819#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007820 case WE_ENABLE_DXE_STALL_DETECT:
7821 {
schang6295e542013-03-12 15:31:23 -07007822 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7823 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007824 break;
7825 }
7826 case WE_DISPLAY_DXE_SNAP_SHOT:
7827 {
schang6295e542013-03-12 15:31:23 -07007828 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7829 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007830 break;
7831 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307832 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7833 {
7834 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7835 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307836 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307837 break;
7838 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307839
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307840 case WE_SET_REASSOC_TRIGGER:
7841 {
7842 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7843 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7844 v_U32_t roamId = 0;
7845 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307846 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7847 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307848 return 0;
7849 }
7850
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307851 case WE_STOP_OBSS_SCAN:
7852 {
7853 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7854 2.OBSS scan is stopped by Firmware during the disassociation
7855 3.OBSS stop comamnd is added for debugging purpose*/
7856 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7857 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007858
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307859 if (pAdapter == NULL)
7860 {
7861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7862 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307863 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307864 }
7865 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7866 if (pMac == NULL)
7867 {
7868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7869 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307870 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307871 }
7872 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7873 }
7874 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307875 case WE_DUMP_ROAM_TIMER_LOG:
7876 {
7877 vos_dump_roam_time_log_service();
7878 break;
7879 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307880
Mukul Sharma84f27252014-07-14 18:11:42 +05307881 case WE_RESET_ROAM_TIMER_LOG:
7882 {
7883 vos_reset_roam_timer_log();
7884 break;
7885 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307886 case WE_GET_FW_LOGS:
7887 {
7888 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7889 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307890 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307891 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307892 break;
7893 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307894 case WE_GET_FW_MEMDUMP:
7895 {
7896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7897 "FW_MEM_DUMP requested ");
7898 get_fwr_memdump(dev,info,wrqu,extra);
7899 break;
7900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 default:
7902 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007903 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 break;
7905 }
7906 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307907 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 return ret;
7909}
7910
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307911static int iw_setnone_getnone(struct net_device *dev,
7912 struct iw_request_info *info,
7913 union iwreq_data *wrqu, char *extra)
7914{
7915 int ret;
7916
7917 vos_ssr_protect(__func__);
7918 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7919 vos_ssr_unprotect(__func__);
7920
7921 return ret;
7922}
7923
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307924void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7925{
7926 /*
7927 * Function to display HDD WMM information
7928 * for Tx Queues.
7929 * Prints globala as well as per client depending
7930 * whether the clients are registered or not.
7931 */
7932 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307933 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7934 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307935 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7936 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307937 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307938
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307939 for ( i=0; i< NUM_TX_QUEUES; i++)
7940 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307941 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307942 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307943 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307944 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307945
7946 for ( i=0; i< NUM_TX_QUEUES; i++) {
7947 if (tx_queue_count[i]) {
7948 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7949 i, tx_queue_count[i]);
7950 }
7951 }
7952
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307953 if(pSapCtx == NULL){
7954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7955 FL("psapCtx is NULL"));
7956 return;
7957 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307958
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307959 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307960 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7961 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307962 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307963 {
7964 hddLog(LOGE, "******STAIndex: %d*********", i);
7965 for ( j=0; j< NUM_TX_QUEUES; j++)
7966 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307967 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7968 {
7969 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307970 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7971 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307972 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7973 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307974 }
7975 }
7976 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307977 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307978
Katya Nigam1fd24402015-02-16 14:52:19 +05307979 if(pHddStaCtx == NULL){
7980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7981 FL("pHddStaCtx is NULL"));
7982 return;
7983 }
7984
7985 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7986 if(pPeerInfo == NULL){
7987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7988 FL("ppeerinfo is NULL"));
7989 return;
7990 }
7991
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307992 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7993 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7994 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7995 for (j = 0; j < NUM_TX_QUEUES; j++) {
7996 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7997 spin_lock_bh(
7998 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7999 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07008000 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05308001 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
8002 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
8003 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
8004 spin_unlock_bh(
8005 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
8006 }
8007 }
Katya Nigam1fd24402015-02-16 14:52:19 +05308008 }
8009 }
8010
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308011}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05308012
Girish Gowlifb9758e2014-11-19 15:19:17 +05308013static int __iw_set_var_ints_getnone(struct net_device *dev,
8014 struct iw_request_info *info,
8015 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008016{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308017 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308018 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05308019 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05308020 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008021 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05308022 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308023 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008024 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05308025 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008026 int cmd = 0;
8027 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308028 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008029
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308030 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05308031 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05308032 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05308033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8034 "%s: NULL extra buffer pointer", __func__);
8035 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05308036 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308037 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8038 if (NULL == pAdapter)
8039 {
8040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8041 "%s: Adapter is NULL",__func__);
8042 return -EINVAL;
8043 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308044 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308045 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8046 ret = wlan_hdd_validate_context(pHddCtx);
8047 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008048 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308049 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008050 }
Katya Nigameae74b62015-05-28 17:19:16 +05308051 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308052 {
Katya Nigameae74b62015-05-28 17:19:16 +05308053 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8054 if (NULL == hHal)
8055 {
8056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8057 "%s: Hal Context is NULL",__func__);
8058 return -EINVAL;
8059 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308060 }
8061 sub_cmd = wrqu->data.flags;
8062
8063 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
8064
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008065
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008066 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
8067 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
8068 {
8069 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
8070 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
8071 {
8072 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8073 staId = pStaCtx->conn_info.staId[0];
8074 }
8075 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
8076 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
8077 {
8078 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8079 staId = pAPCtx->uBCStaId;
8080 }
8081 else
8082 {
8083 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
8084 return 0;
8085 }
8086 }
8087
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 switch (sub_cmd)
8089 {
8090 case WE_LOG_DUMP_CMD:
8091 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05308092 if(apps_args[0] == 26) {
8093 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
8094 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
8095 return 0;
8096 }
8097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008099 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308101 if (hHal)
8102 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
8103 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104
8105 }
8106 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05308107#ifdef WLAN_FEATURE_RMC
8108 case WE_IBSS_GET_PEER_INFO:
8109 {
8110 pr_info ( "Station ID = %d\n",apps_args[0]);
8111 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
8112 }
8113 break;
8114#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008115
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 case WE_P2P_NOA_CMD:
8117 {
8118 p2p_app_setP2pPs_t p2pNoA;
8119
Rajeev Kumara4c475d2015-11-27 13:41:24 +05308120 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
8121 hddLog(LOGE,
8122 FL("Setting NoA is not allowed in Device mode:%d"),
8123 pAdapter->device_mode);
8124 return -EINVAL;
8125 }
8126
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 p2pNoA.opp_ps = apps_args[0];
8128 p2pNoA.ctWindow = apps_args[1];
8129 p2pNoA.duration = apps_args[2];
8130 p2pNoA.interval = apps_args[3];
8131 p2pNoA.count = apps_args[4];
8132 p2pNoA.single_noa_duration = apps_args[5];
8133 p2pNoA.psSelection = apps_args[6];
8134
8135 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
8136 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008137 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
8139
8140 hdd_setP2pPs(dev, &p2pNoA);
8141
8142 }
8143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008144
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308145 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8146 {
8147 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8148 __func__, apps_args[0], apps_args[1]);
8149 vosTraceEnable(apps_args[0], apps_args[1]);
8150 }
8151 break;
8152
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008153 case WE_MTRACE_DUMP_CMD:
8154 {
8155 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
8156 "bitmask_of_module %d ",
8157 __func__, apps_args[0], apps_args[1], apps_args[2],
8158 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308159 if (hHal)
8160 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
8161 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008162
8163 }
8164 break;
8165
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008166 case WE_MCC_CONFIG_CREDENTIAL :
8167 {
8168 cmd = 287; //Command should be updated if there is any change
8169 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08008170 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008171 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308172 if (hHal)
8173 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
8174 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008175 }
8176 else
8177 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008178 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008179 return 0;
8180 }
8181 }
8182 break;
8183
8184 case WE_MCC_CONFIG_PARAMS :
8185 {
8186 cmd = 288; //command Should be updated if there is any change
8187 // in the Riva dump command
8188 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
8189 }
8190 break;
8191
Chilam NG571c65a2013-01-19 12:27:36 +05308192#ifdef FEATURE_WLAN_TDLS
8193 case WE_TDLS_CONFIG_PARAMS :
8194 {
8195 tdls_config_params_t tdlsParams;
8196
Chilam Ng01120412013-02-19 18:32:21 -08008197 tdlsParams.tdls = apps_args[0];
8198 tdlsParams.tx_period_t = apps_args[1];
8199 tdlsParams.tx_packet_n = apps_args[2];
8200 tdlsParams.discovery_period_t = apps_args[3];
8201 tdlsParams.discovery_tries_n = apps_args[4];
8202 tdlsParams.idle_timeout_t = apps_args[5];
8203 tdlsParams.idle_packet_n = apps_args[6];
8204 tdlsParams.rssi_hysteresis = apps_args[7];
8205 tdlsParams.rssi_trigger_threshold = apps_args[8];
8206 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05308207
Chilam Ng01120412013-02-19 18:32:21 -08008208 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05308209 }
8210 break;
8211#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05308212 case WE_CONFIGURE_MONITOR_MODE:
8213 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308214 v_U32_t magic = 0;
8215 struct completion cmpVar;
8216 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308217 tVOS_CON_MODE mode = hdd_get_conparam();
8218
8219 if (VOS_MONITOR_MODE != mode) {
8220 hddLog(LOGE, FL("invalid mode %d"), mode);
8221 return -EIO;
8222 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308223
Katya Nigamf0511f62015-05-05 16:40:57 +05308224 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8225 if( pMonCtx == NULL )
8226 {
8227 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308228 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308229 }
8230 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
8231 __func__, apps_args[0], apps_args[1], apps_args[2],
8232 apps_args[3], apps_args[4]);
8233 /* Input Validation part of FW */
8234 pMonCtx->ChannelNo = apps_args[0];
8235 pMonCtx->ChannelBW = apps_args[1];
8236 pMonCtx->crcCheckEnabled = apps_args[2];
8237 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8238 pMonCtx->is80211to803ConReq = apps_args[4];
8239 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8240 if( pMonCtx->is80211to803ConReq )
8241 pAdapter->dev->type = ARPHRD_ETHER;
8242 else
8243 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8244 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8245 {
8246 hddLog(LOGE, "%s: Filtering data packets as management and control"
8247 " cannot be converted to 802.3 ",__func__);
8248 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8249 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308250 if (MON_MODE_START == pMonCtx->state) {
8251 magic = MON_MODE_MSG_MAGIC;
8252 init_completion(&cmpVar);
8253 if (VOS_STATUS_SUCCESS !=
8254 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8255 pMonCtx, hdd_monPostMsgCb)) {
8256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8257 FL("failed to post MON MODE REQ"));
8258 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308259 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308260 }
8261 waitRet = wait_for_completion_timeout(&cmpVar,
8262 MON_MODE_MSG_TIMEOUT);
8263 magic = 0;
8264 if (waitRet <= 0 ) {
8265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8266 FL("failed to wait on monitor mode completion %ld"),
8267 waitRet);
8268 }
8269 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308270 }
8271 break;
8272
8273 case WE_SET_MONITOR_MODE_FILTER:
8274 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308275 v_U32_t magic = 0;
8276 struct completion cmpVar;
8277 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308278 tVOS_CON_MODE mode = hdd_get_conparam();
8279
8280 if (VOS_MONITOR_MODE != mode) {
8281 hddLog(LOGE, FL("invalid mode %d"), mode);
8282 return -EIO;
8283 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308284
Katya Nigamf0511f62015-05-05 16:40:57 +05308285 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8286 if( pMonCtx == NULL )
8287 {
8288 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308289 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308290 }
8291 /* Input Validation Part of FW */
8292 pMonCtx->numOfMacFilters=1;
8293 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8294 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8295 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8296 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8297 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8298 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8299 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8300 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8301 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8302 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8303 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8304 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308305 if (MON_MODE_START == pMonCtx->state) {
8306 magic = MON_MODE_MSG_MAGIC;
8307 init_completion(&cmpVar);
8308 if (VOS_STATUS_SUCCESS !=
8309 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8310 pMonCtx, hdd_monPostMsgCb)) {
8311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8312 FL("failed to post MON MODE REQ"));
8313 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308314 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308315 }
8316 waitRet = wait_for_completion_timeout(&cmpVar,
8317 MON_MODE_MSG_TIMEOUT);
8318 magic = 0;
8319 if (waitRet <= 0 ) {
8320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8321 FL("failed to wait on monitor mode completion %ld"),
8322 waitRet);
8323 }
8324 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308325 }
8326 break;
8327
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 default:
8329 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008330 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8331 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 }
8333 break;
8334 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308335 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 return 0;
8337}
8338
Girish Gowlifb9758e2014-11-19 15:19:17 +05308339static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8340 struct iw_request_info *info,
8341 union iwreq_data *wrqu, char *extra)
8342{
8343 int ret;
8344 union iwreq_data u_priv_wrqu;
8345 int apps_args[MAX_VAR_ARGS] = {0};
8346 int num_args;
8347
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308348 if (!capable(CAP_NET_ADMIN))
8349 {
8350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8351 FL("permission check failed"));
8352 return -EPERM;
8353 }
8354
Girish Gowlifb9758e2014-11-19 15:19:17 +05308355 /* helper function to get iwreq_data with compat handling. */
8356 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8357 {
8358 return -EINVAL;
8359 }
8360
8361 if (NULL == u_priv_wrqu.data.pointer)
8362 {
8363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8364 "%s: NULL data pointer", __func__);
8365 return -EINVAL;
8366 }
8367
8368 num_args = u_priv_wrqu.data.length;
8369 if (num_args > MAX_VAR_ARGS)
8370 {
8371 num_args = MAX_VAR_ARGS;
8372 }
8373
8374 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8375 (sizeof(int)) * num_args))
8376 {
8377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8378 "%s: failed to copy data from user buffer", __func__);
8379 return -EFAULT;
8380 }
8381
8382 vos_ssr_protect(__func__);
8383 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8384 (char *)&apps_args);
8385 vos_ssr_unprotect(__func__);
8386
8387 return ret;
8388}
8389
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308390int iw_set_var_ints_getnone(struct net_device *dev,
8391 struct iw_request_info *info,
8392 union iwreq_data *wrqu, char *extra)
8393{
8394 int ret;
8395 vos_ssr_protect(__func__);
8396 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8397 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008398
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308399 return ret;
8400}
8401
8402static int __iw_add_tspec(struct net_device *dev,
8403 struct iw_request_info *info,
8404 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008405{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308406 hdd_adapter_t *pAdapter;
8407 hdd_station_ctx_t *pHddStaCtx;
8408 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8410 int params[HDD_WLAN_WMM_PARAM_COUNT];
8411 sme_QosWmmTspecInfo tSpec;
8412 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308413 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308414 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008415
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308416 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308417 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8418 if (NULL == pAdapter)
8419 {
8420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8421 "%s: Adapter is NULL",__func__);
8422 return -EINVAL;
8423 }
8424 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8425 ret = wlan_hdd_validate_context(pHddCtx);
8426 if (0 != ret)
8427 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308428 return ret;
8429 }
8430 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8431 if (NULL == pHddStaCtx)
8432 {
8433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8434 "%s: STA Context is NULL",__func__);
8435 return -EINVAL;
8436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 // make sure the application is sufficiently priviledged
8438 // note that the kernel will do this for "set" ioctls, but since
8439 // this ioctl wants to return status to user space it must be
8440 // defined as a "get" ioctl
8441 if (!capable(CAP_NET_ADMIN))
8442 {
8443 return -EPERM;
8444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 // we must be associated in order to add a tspec
8446 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8447 {
8448 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8449 return 0;
8450 }
8451
8452 // since we are defined to be a "get" ioctl, and since the number
8453 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308454 // will pass down in the iwreq_data, we must copy the "set" params.
8455 // We must handle the compat for iwreq_data in 32U/64K environment.
8456
8457 // helper fucntion to get iwreq_data with compat handling.
8458 if (hdd_priv_get_data(&s_priv_data, wrqu))
8459 {
8460 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8461 return 0;
8462 }
8463
8464 // make sure all params are correctly passed to function
8465 if ((NULL == s_priv_data.pointer) ||
8466 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8467 {
8468 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8469 return 0;
8470 }
8471
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308473 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 {
8475 // hmmm, can't get them
8476 return -EIO;
8477 }
8478
8479 // clear the tspec
8480 memset(&tSpec, 0, sizeof(tSpec));
8481
8482 // validate the handle
8483 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8484 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8485 {
8486 // that one is reserved
8487 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8488 return 0;
8489 }
8490
8491 // validate the TID
8492 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8493 {
8494 // out of range
8495 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8496 return 0;
8497 }
8498 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8499
8500 // validate the direction
8501 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8502 {
8503 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8504 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8505 break;
8506
8507 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8508 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8509 break;
8510
8511 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8512 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8513 break;
8514
8515 default:
8516 // unknown
8517 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8518 return 0;
8519 }
8520
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308521 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8522
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 // validate the user priority
8524 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8525 {
8526 // out of range
8527 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8528 return 0;
8529 }
8530 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308531 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8532 {
8533 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8534 return 0;
8535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008536
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8538 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8539 tSpec.ts_info.psb, tSpec.ts_info.up);
8540
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8542 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8543 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8544 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8545 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8546 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8547 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8548 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8549 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8550 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8551 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8552 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8553
8554 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8555
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308556 // Save the expected UAPSD settings by application, this will be needed
8557 // when re-negotiating UAPSD settings during BT Coex cases.
8558 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8559
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 // validate the ts info ack policy
8561 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8562 {
8563 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8564 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8565 break;
8566
8567 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8568 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8569 break;
8570
8571 default:
8572 // unknown
8573 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8574 return 0;
8575 }
8576
8577 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308578
8579 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 return 0;
8581}
8582
8583
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308584static int iw_add_tspec(struct net_device *dev,
8585 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 union iwreq_data *wrqu, char *extra)
8587{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308588 int ret;
8589
8590 vos_ssr_protect(__func__);
8591 ret = __iw_add_tspec(dev, info, wrqu, extra);
8592 vos_ssr_unprotect(__func__);
8593
8594 return ret;
8595}
8596
8597static int __iw_del_tspec(struct net_device *dev,
8598 struct iw_request_info *info,
8599 union iwreq_data *wrqu, char *extra)
8600{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308601 hdd_adapter_t *pAdapter;
8602 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 int *params = (int *)extra;
8604 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8605 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308606 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008607
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308608 ENTER();
8609
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308610 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8611 if (NULL == pAdapter)
8612 {
8613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8614 "%s: Adapter is NULL",__func__);
8615 return -EINVAL;
8616 }
8617
8618 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8619 ret = wlan_hdd_validate_context(pHddCtx);
8620 if (0 != ret)
8621 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308622 return ret;
8623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008624 // make sure the application is sufficiently priviledged
8625 // note that the kernel will do this for "set" ioctls, but since
8626 // this ioctl wants to return status to user space it must be
8627 // defined as a "get" ioctl
8628 if (!capable(CAP_NET_ADMIN))
8629 {
8630 return -EPERM;
8631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 // although we are defined to be a "get" ioctl, the params we require
8633 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8634 // is no need to copy the params from user space
8635
8636 // validate the handle
8637 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8638 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8639 {
8640 // that one is reserved
8641 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8642 return 0;
8643 }
8644
8645 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308646
8647 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008648 return 0;
8649}
8650
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308651static int iw_del_tspec(struct net_device *dev,
8652 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 union iwreq_data *wrqu, char *extra)
8654{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308655 int ret;
8656
8657 vos_ssr_protect(__func__);
8658 ret = __iw_del_tspec(dev, info, wrqu, extra);
8659 vos_ssr_unprotect(__func__);
8660
8661 return ret;
8662}
8663
8664
8665static int __iw_get_tspec(struct net_device *dev,
8666 struct iw_request_info *info,
8667 union iwreq_data *wrqu, char *extra)
8668{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308669 hdd_adapter_t *pAdapter;
8670 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 int *params = (int *)extra;
8672 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8673 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308674 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308676 ENTER();
8677
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 // although we are defined to be a "get" ioctl, the params we require
8679 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8680 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308681 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8682 if (NULL == pAdapter)
8683 {
8684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8685 "%s: Adapter is NULL",__func__);
8686 return -EINVAL;
8687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008688
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308689 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8690 ret = wlan_hdd_validate_context(pHddCtx);
8691 if (0 != ret)
8692 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308693 return ret;
8694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 // validate the handle
8696 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8697 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8698 {
8699 // that one is reserved
8700 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8701 return 0;
8702 }
8703
8704 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308705 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 return 0;
8707}
8708
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308709static int iw_get_tspec(struct net_device *dev,
8710 struct iw_request_info *info,
8711 union iwreq_data *wrqu, char *extra)
8712{
8713 int ret;
8714
8715 vos_ssr_protect(__func__);
8716 ret = __iw_get_tspec(dev, info, wrqu, extra);
8717 vos_ssr_unprotect(__func__);
8718
8719 return ret;
8720}
8721
Manjeet Singh3ed79242017-01-11 19:04:32 +05308722/**
8723 * __iw_setnone_get_threeint() - return three value to up layer.
8724 *
8725 * @dev: pointer of net_device of this wireless card
8726 * @info: meta data about Request sent
8727 * @wrqu: include request info
8728 * @extra: buf used for in/Output
8729 *
8730 * Return: execute result
8731 */
8732static int __iw_setnone_get_threeint(struct net_device *dev,
8733 struct iw_request_info *info,
8734 union iwreq_data *wrqu, char *extra)
8735{
8736 int ret = 0; /* success */
8737 uint32_t *value = (int *)extra;
8738 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8739
8740 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8741
8742 switch (value[0]) {
8743 case WE_GET_TSF:
8744 ret = hdd_indicate_tsf(adapter, value, 3);
8745 break;
8746 default:
8747 hddLog(VOS_TRACE_LEVEL_ERROR,
8748 FL("Invalid IOCTL get_value command %d"),
8749 value[0]);
8750 break;
8751 }
8752 return ret;
8753}
8754
8755/**
8756 * iw_setnone_get_threeint() - return three value to up layer.
8757 *
8758 * @dev: pointer of net_device of this wireless card
8759 * @info: meta data about Request sent
8760 * @wrqu: include request info
8761 * @extra: buf used for in/Output
8762 *
8763 * Return: execute result
8764 */
8765static int iw_setnone_get_threeint(struct net_device *dev,
8766 struct iw_request_info *info,
8767 union iwreq_data *wrqu, char *extra)
8768{
8769 int ret;
8770
8771 vos_ssr_protect(__func__);
8772 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8773 vos_ssr_unprotect(__func__);
8774
8775 return ret;
8776}
8777
Jeff Johnson295189b2012-06-20 16:38:30 -07008778#ifdef WLAN_FEATURE_VOWIFI_11R
8779//
8780//
8781// Each time the supplicant has the auth_request or reassoc request
8782// IEs ready. This is pushed to the driver. The driver will inturn use
8783// it to send out the auth req and reassoc req for 11r FT Assoc.
8784//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308785static int __iw_set_fties(struct net_device *dev,
8786 struct iw_request_info *info,
8787 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008788{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308789 hdd_adapter_t *pAdapter;
8790 hdd_station_ctx_t *pHddStaCtx;
8791 hdd_context_t *pHddCtx;
8792 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 //v_CONTEXT_t pVosContext;
8794
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308795 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8797 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008798 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8800 "%s: Adapter is NULL",__func__);
8801 return -EINVAL;
8802 }
8803 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8804 ret = wlan_hdd_validate_context(pHddCtx);
8805 if (0 != ret)
8806 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308807 return ret;
8808 }
8809 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8810 if (NULL == pHddStaCtx)
8811 {
8812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8813 "%s: STA Context is NULL",__func__);
8814 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 if (!wrqu->data.length)
8817 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008818 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 return -EINVAL;
8820 }
8821 if (wrqu->data.pointer == NULL)
8822 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008823 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 return -EINVAL;
8825 }
8826
8827 // Added for debug on reception of Re-assoc Req.
8828 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8829 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008830 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008832 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 }
8834
8835#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008836 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008837#endif
8838
8839 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008840 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 wrqu->data.length);
8842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308843 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008844 return 0;
8845}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308846
8847static int iw_set_fties(struct net_device *dev,
8848 struct iw_request_info *info,
8849 union iwreq_data *wrqu, char *extra)
8850{
8851 int ret;
8852
8853 vos_ssr_protect(__func__);
8854 ret = __iw_set_fties(dev, info, wrqu, extra);
8855 vos_ssr_unprotect(__func__);
8856
8857 return ret;
8858}
Jeff Johnson295189b2012-06-20 16:38:30 -07008859#endif
8860
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308861static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008862 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008864{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308865 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008866 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308867 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008868 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308869 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008870 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8871 int idx;
8872 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308874 ENTER();
8875
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308876 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8877 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008878 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8880 "%s: Adapter is NULL",__func__);
8881 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008882 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308883 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8884 ret_val = wlan_hdd_validate_context(pHddCtx);
8885 if (0 != ret_val)
8886 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308887 return ret_val;
8888 }
8889 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8890 if (NULL == hHal)
8891 {
8892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8893 "%s: Hal Context is NULL",__func__);
8894 return -EINVAL;
8895 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308896 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8897 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308898#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008899
Amar Singhalf3a6e762013-02-19 15:06:50 -08008900 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8901 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008902 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008903 hddLog(VOS_TRACE_LEVEL_ERROR,
8904 "%s: vos_mem_alloc failed", __func__);
8905 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008906 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008907
8908 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8909
8910 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8911 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8912
8913 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8914 mc_addr_list_ptr->ulMulticastAddrCnt);
8915
8916 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008917 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008918 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8919 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8920
8921 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8922 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008923 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008924
Amar Singhalf3a6e762013-02-19 15:06:50 -08008925 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8926 vos_mem_free(mc_addr_list_ptr);
8927 if (eHAL_STATUS_SUCCESS != ret_val)
8928 {
8929 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8930 __func__);
8931 return -EINVAL;
8932 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308933#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308934 }
8935 else
8936 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008937
Amar Singhalf3a6e762013-02-19 15:06:50 -08008938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8939 "%s: Set MC BC Filter Config request: %d suspend %d",
8940 __func__, pRequest->mcastBcastFilterSetting,
8941 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308942 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308943 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308944 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008945
8946 if (pHddCtx->hdd_wlan_suspended)
8947 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008948 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8949 if (NULL == wlanRxpFilterParam)
8950 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308951 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008952 "%s: vos_mem_alloc failed", __func__);
8953 return -EINVAL;
8954 }
8955
Amar Singhalf3a6e762013-02-19 15:06:50 -08008956 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8957 pRequest->mcastBcastFilterSetting;
8958 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308959 /* Fwr expect offload needs to clear before set */
8960 hdd_conf_hostoffload(pAdapter, FALSE);
8961 spin_lock(&pHddCtx->filter_lock);
8962 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8963 spin_unlock(&pHddCtx->filter_lock);
8964 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8965 {
8966 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8967 pHddCtx->sus_res_mcastbcast_filter =
8968 pRequest->mcastBcastFilterSetting;
8969 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008970
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308971 hdd_conf_hostoffload(pAdapter, TRUE);
8972 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8973 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008974
8975 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8976 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308977 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008978 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8979 wlanRxpFilterParam->setMcstBcstFilter);
8980
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308981 if (eHAL_STATUS_SUCCESS !=
8982 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8983 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008984 {
8985 hddLog(VOS_TRACE_LEVEL_ERROR,
8986 "%s: Failure to execute set HW MC/BC Filter request",
8987 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008988 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008989 return -EINVAL;
8990 }
8991
mukul sharmae4abd892016-11-24 22:03:31 +05308992 /* mc add list cfg item configuration in fwr */
8993 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008994 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008996
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308997 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 return 0;
8999}
9000
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309001static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9002 struct iw_request_info *info,
9003 union iwreq_data *wrqu, char *extra)
9004{
9005 int ret;
9006
9007 vos_ssr_protect(__func__);
9008 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
9009 vos_ssr_unprotect(__func__);
9010
9011 return ret;
9012}
9013
9014static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
9015 struct iw_request_info *info,
9016 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009017{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309018 hdd_adapter_t *pAdapter;
9019 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309020 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309021 int ret = 0;
9022
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309023 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009024
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05309025 if (!capable(CAP_NET_ADMIN))
9026 {
9027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9028 FL("permission check failed"));
9029 return -EPERM;
9030 }
9031
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309032 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9033 if (NULL == pAdapter)
9034 {
9035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9036 "%s: Adapter is NULL",__func__);
9037 return -EINVAL;
9038 }
9039
9040 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9041 ret = wlan_hdd_validate_context(pHddCtx);
9042 if (0 != ret)
9043 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309044 return ret;
9045 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309046 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309047 //Reset the filter to INI value as we have to clear the dynamic filter
9048 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309049 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07009050
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309051 //Configure FW with new setting
9052 if (pHddCtx->hdd_wlan_suspended)
9053 {
9054 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
9055 if (NULL == wlanRxpFilterParam)
9056 {
9057 hddLog(VOS_TRACE_LEVEL_ERROR,
9058 "%s: vos_mem_alloc failed", __func__);
9059 return -EINVAL;
9060 }
9061
9062 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9063 pHddCtx->configuredMcastBcastFilter;
9064 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309065 /* Fwr expect offload needs to clear before set */
9066 hdd_conf_hostoffload(pAdapter, FALSE);
9067 spin_lock(&pHddCtx->filter_lock);
9068 pHddCtx->configuredMcastBcastFilter =
9069 pHddCtx->cfg_ini->mcastBcastFilterSetting;
9070 spin_unlock(&pHddCtx->filter_lock);
9071
9072 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
9073 {
9074 pHddCtx->sus_res_mcastbcast_filter =
9075 pHddCtx->cfg_ini->mcastBcastFilterSetting;
9076 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309077
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05309078 hdd_conf_hostoffload(pAdapter, TRUE);
9079 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9080 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309081 if (eHAL_STATUS_SUCCESS !=
9082 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
9083 wlanRxpFilterParam))
9084 {
9085 hddLog(VOS_TRACE_LEVEL_ERROR,
9086 "%s: Failure to execute set HW MC/BC Filter request",
9087 __func__);
9088 vos_mem_free(wlanRxpFilterParam);
9089 return -EINVAL;
9090 }
c_hpothud3ce76d2014-10-28 10:34:13 +05309091
mukul sharmae4abd892016-11-24 22:03:31 +05309092 /* mc add list cfg item configuration in fwr */
9093 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309094 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309095 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 return 0;
9097}
9098
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309099
9100static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
9101 struct iw_request_info *info,
9102 union iwreq_data *wrqu, char *extra)
9103{
9104 int ret;
9105
9106 vos_ssr_protect(__func__);
9107 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
9108 vos_ssr_unprotect(__func__);
9109
9110 return ret;
9111}
9112
9113static int __iw_set_host_offload(struct net_device *dev,
9114 struct iw_request_info *info,
9115 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009116{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309117 hdd_adapter_t *pAdapter;
9118 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009119 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309121 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009122
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309123 ENTER();
9124
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309125 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9126 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009127 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9129 "%s: Adapter is NULL",__func__);
9130 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009131 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309132 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9133 ret = wlan_hdd_validate_context(pHddCtx);
9134 if (0 != ret)
9135 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309136 return ret;
9137 }
9138
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 /* Debug display of request components. */
9140 switch (pRequest->offloadType)
9141 {
9142 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009143 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 switch (pRequest->enableOrDisable)
9145 {
9146 case WLAN_OFFLOAD_DISABLE:
9147 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
9148 break;
9149 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
9150 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
9151 case WLAN_OFFLOAD_ENABLE:
9152 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
9153 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
9154 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
9155 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
9156 }
9157 break;
9158
9159 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08009160 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009161 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 switch (pRequest->enableOrDisable)
9163 {
9164 case WLAN_OFFLOAD_DISABLE:
9165 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
9166 break;
9167 case WLAN_OFFLOAD_ENABLE:
9168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
9169 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
9170 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
9171 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
9172 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
9173 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
9174 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
9175 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
9176 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
9177 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
9178 }
9179 }
9180
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05309181 vos_mem_zero(&offloadRequest, sizeof(offloadRequest));
9182 offloadRequest.offloadType = pRequest->offloadType;
9183 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
9184 vos_mem_copy(&offloadRequest.params, &pRequest->params,
9185 sizeof(pRequest->params));
9186 vos_mem_copy(&offloadRequest.bssId, &pRequest->bssId.bytes,
9187 VOS_MAC_ADDRESS_LEN);
9188
Jeff Johnsone7245742012-09-05 17:12:55 -07009189 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9190 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 __func__);
9194 return -EINVAL;
9195 }
9196
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309197 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 return 0;
9199}
9200
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309201static int iw_set_host_offload(struct net_device *dev,
9202 struct iw_request_info *info,
9203 union iwreq_data *wrqu, char *extra)
9204{
9205 int ret;
9206
9207 vos_ssr_protect(__func__);
9208 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9209 vos_ssr_unprotect(__func__);
9210
9211 return ret;
9212}
9213
9214static int __iw_set_keepalive_params(struct net_device *dev,
9215 struct iw_request_info *info,
9216 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009217{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309218 hdd_adapter_t *pAdapter;
9219 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009220 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309222 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009223
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309224 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309225 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9226 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9229 "%s: Adapter is NULL",__func__);
9230 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9233 ret = wlan_hdd_validate_context(pHddCtx);
9234 if (0 != ret)
9235 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309236 return ret;
9237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009238 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009239 hddLog(VOS_TRACE_LEVEL_INFO,
9240 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9241 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009242
9243 switch (pRequest->packetType)
9244 {
9245 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009246 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 break;
9248
9249 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9250
Arif Hussain6d2a3322013-11-17 19:50:10 -08009251 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009252 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009253
9254 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9255 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9256 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9257
9258 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9259 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9260 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9261
9262 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9263 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9264 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9265 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9266 break;
9267
9268 }
9269
9270 /* Execute keep alive request. The reason that we can copy the request information
9271 from the ioctl structure to the SME structure is that they are laid out
9272 exactly the same. Otherwise, each piece of information would have to be
9273 copied individually. */
9274 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9275
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309276 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9277 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009279 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009280 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009282 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 __func__);
9284 return -EINVAL;
9285 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309286 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009287 return 0;
9288}
9289
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309290static int iw_set_keepalive_params(struct net_device *dev,
9291 struct iw_request_info *info,
9292 union iwreq_data *wrqu, char *extra)
9293{
9294 int ret;
9295 vos_ssr_protect(__func__);
9296 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9297 vos_ssr_unprotect(__func__);
9298
9299 return ret;
9300}
9301
Jeff Johnson295189b2012-06-20 16:38:30 -07009302#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309303/**-----------------------------------------------------------------
9304
9305 \brief hdd_pkt_filter_done - callback to be executed on completion
9306 successful/failure) for clear filter request.
9307
9308 \return - None
9309
9310 --------------------------------------------------------------------------*/
9311static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009312{
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309313 struct hdd_request *request;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309314
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309315 hddLog(VOS_TRACE_LEVEL_INFO,
9316 FL("Pkt Filter Clear Status : %d"), status);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309317
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309318 request = hdd_request_get(data);
9319 if (!request) {
9320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
9321 if (ioctl_debug)
9322 pr_info("%s: Obsolete request", __func__);
9323 return;
9324 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309325
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309326 hdd_request_complete(request);
9327 hdd_request_put(request);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309328}
9329
9330int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9331{
9332 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309333 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009334 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9335 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309336 int i=0, status;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309337 void *cookie;
9338 struct hdd_request *request;
9339 static const struct hdd_request_params params = {
9340 .priv_size = 0,
9341 .timeout_ms = PKT_FILTER_TIMEOUT,
9342 };
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309343
9344 status = wlan_hdd_validate_context(pHddCtx);
9345 if (0 != status)
9346 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009347
9348 if (pHddCtx->cfg_ini->disablePacketFilter)
9349 {
9350 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009351 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 return 0;
9353 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309354 if (pHddCtx->isLogpInProgress)
9355 {
9356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9357 "%s:LOGP in Progress. Ignore!!!", __func__);
9358 return -EBUSY;
9359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 /* Debug display of request components. */
9361 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009362 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009363
9364 switch (pRequest->filterAction)
9365 {
9366 case HDD_RCV_FILTER_SET:
9367 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009368 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009369
9370 packetFilterSetReq.filterId = pRequest->filterId;
9371 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9372 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009373 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 __func__, pRequest->numParams);
9375 return -EINVAL;
9376 }
9377 packetFilterSetReq.numFieldParams = pRequest->numParams;
9378 packetFilterSetReq.coalesceTime = 0;
9379 packetFilterSetReq.filterType = 1;
9380 for (i=0; i < pRequest->numParams; i++)
9381 {
9382 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9383 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9384 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9385 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9386 packetFilterSetReq.paramsData[i].reserved = 0;
9387
Arif Hussain6d2a3322013-11-17 19:50:10 -08009388 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9390 packetFilterSetReq.filterType);
9391
Arif Hussain6d2a3322013-11-17 19:50:10 -08009392 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309394 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9395 (pRequest->paramsData[i].dataLength))
9396 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009397
9398 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9399 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9400 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9401 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9402
Arif Hussain6d2a3322013-11-17 19:50:10 -08009403 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9405 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9406 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9407
Arif Hussain6d2a3322013-11-17 19:50:10 -08009408 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9410 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9411 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9412 }
9413
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309414 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009416 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 __func__);
9418 return -EINVAL;
9419 }
9420
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309421 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9422 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 break;
9424
9425 case HDD_RCV_FILTER_CLEAR:
9426
Arif Hussain6d2a3322013-11-17 19:50:10 -08009427 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009428 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309429
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309430 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9431 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9432 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9433 pHddStaCtx->conn_info.staId[0]);
9434 }
9435
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309436 request = hdd_request_alloc(&params);
9437 if (!request) {
9438 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
9439 return VOS_STATUS_E_NOMEM;
9440 }
9441 cookie = hdd_request_cookie(request);
9442
9443 packetFilterClrReq.cbCtx = cookie;
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309445 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309446 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(
9447 pHddCtx->hHal,
9448 &packetFilterClrReq,
9449 pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009451 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 __func__);
9453 return -EINVAL;
9454 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309455
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309456 status = hdd_request_wait_for_response(request);
9457 hdd_request_put(request);
9458 if (status)
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309459 {
9460 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9461 status);
9462 return -EINVAL;
9463 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309464
9465 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9466 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 break;
9468
9469 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009470 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009471 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 return -EINVAL;
9473 }
9474 return 0;
9475}
9476
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309477int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9478 tANI_U8 sessionId)
9479{
9480 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9481 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9482
9483 if (NULL == pHddCtx)
9484 {
9485 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9486 return -EINVAL;
9487 }
9488
9489 if (pHddCtx->isLogpInProgress)
9490 {
9491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9492 "%s:LOGP in Progress. Ignore!!!", __func__);
9493 return -EBUSY;
9494 }
9495
9496 if (pHddCtx->cfg_ini->disablePacketFilter)
9497 {
9498 hddLog(VOS_TRACE_LEVEL_ERROR,
9499 "%s: Packet Filtering Disabled. Returning ",
9500 __func__ );
9501 return -EINVAL;
9502 }
9503
9504 switch (filterType)
9505 {
9506 /* For setting IPV6 MC and UC Filter we need to configure
9507 * 2 filters, one for MC and one for UC.
9508 * The Filter ID shouldn't be swapped, which results in making
9509 * UC Filter ineffective.
9510 * We have Hardcode all the values
9511 *
9512 * Reason for a seperate UC filter is because, driver need to
9513 * specify the FW that the specific filter is for unicast
9514 * otherwise FW will not pass the unicast frames by default
9515 * through the filter. This is required to avoid any performance
9516 * hits when no unicast filter is set and only MC/BC are set.
9517 * The way driver informs host is by using the MAC protocol
9518 * layer, CMP flag set to MAX, CMP Data set to 1.
9519 */
9520
9521 case HDD_FILTER_IPV6_MC_UC:
9522 /* Setting IPV6 MC Filter below
9523 */
9524 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9525 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9526 packetFilterSetReq.numFieldParams = 2;
9527 packetFilterSetReq.paramsData[0].protocolLayer =
9528 HDD_FILTER_PROTO_TYPE_MAC;
9529 packetFilterSetReq.paramsData[0].cmpFlag =
9530 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9531 packetFilterSetReq.paramsData[0].dataOffset =
9532 WLAN_HDD_80211_FRM_DA_OFFSET;
9533 packetFilterSetReq.paramsData[0].dataLength = 1;
9534 packetFilterSetReq.paramsData[0].compareData[0] =
9535 HDD_IPV6_MC_CMP_DATA;
9536
9537 packetFilterSetReq.paramsData[1].protocolLayer =
9538 HDD_FILTER_PROTO_TYPE_ARP;
9539 packetFilterSetReq.paramsData[1].cmpFlag =
9540 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9541 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9542 packetFilterSetReq.paramsData[1].dataLength = 2;
9543 packetFilterSetReq.paramsData[1].compareData[0] =
9544 HDD_IPV6_CMP_DATA_0;
9545 packetFilterSetReq.paramsData[1].compareData[1] =
9546 HDD_IPV6_CMP_DATA_1;
9547
9548
9549 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9550 &packetFilterSetReq, sessionId))
9551 {
9552 hddLog(VOS_TRACE_LEVEL_ERROR,
9553 "%s: Failure to execute Set IPv6 Mulicast Filter",
9554 __func__);
9555 return -EINVAL;
9556 }
9557
9558 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9559
9560 /*
9561 * Setting IPV6 UC Filter below
9562 */
9563 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9564 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9565 packetFilterSetReq.numFieldParams = 2;
9566 packetFilterSetReq.paramsData[0].protocolLayer =
9567 HDD_FILTER_PROTO_TYPE_MAC;
9568 packetFilterSetReq.paramsData[0].cmpFlag =
9569 HDD_FILTER_CMP_TYPE_MAX;
9570 packetFilterSetReq.paramsData[0].dataOffset = 0;
9571 packetFilterSetReq.paramsData[0].dataLength = 1;
9572 packetFilterSetReq.paramsData[0].compareData[0] =
9573 HDD_IPV6_UC_CMP_DATA;
9574
9575 packetFilterSetReq.paramsData[1].protocolLayer =
9576 HDD_FILTER_PROTO_TYPE_ARP;
9577 packetFilterSetReq.paramsData[1].cmpFlag =
9578 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9579 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9580 packetFilterSetReq.paramsData[1].dataLength = 2;
9581 packetFilterSetReq.paramsData[1].compareData[0] =
9582 HDD_IPV6_CMP_DATA_0;
9583 packetFilterSetReq.paramsData[1].compareData[1] =
9584 HDD_IPV6_CMP_DATA_1;
9585
9586 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9587 &packetFilterSetReq, sessionId))
9588 {
9589 hddLog(VOS_TRACE_LEVEL_ERROR,
9590 "%s: Failure to execute Set IPv6 Unicast Filter",
9591 __func__);
9592 return -EINVAL;
9593 }
9594
9595 break;
9596
9597 case HDD_FILTER_IPV6_MC:
9598 /*
9599 * IPV6 UC Filter might be already set,
9600 * clear the UC Filter. As the Filter
9601 * IDs are static, we can directly clear it.
9602 */
9603 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9604 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9605 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9606 &packetFilterClrReq, sessionId))
9607 {
9608 hddLog(VOS_TRACE_LEVEL_ERROR,
9609 "%s: Failure to execute Clear IPv6 Unicast Filter",
9610 __func__);
9611 return -EINVAL;
9612 }
9613
9614 /*
9615 * Setting IPV6 MC Filter below
9616 */
9617 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9618 packetFilterSetReq.numFieldParams = 2;
9619 packetFilterSetReq.paramsData[0].protocolLayer =
9620 HDD_FILTER_PROTO_TYPE_MAC;
9621 packetFilterSetReq.paramsData[0].cmpFlag =
9622 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9623 packetFilterSetReq.paramsData[0].dataOffset =
9624 WLAN_HDD_80211_FRM_DA_OFFSET;
9625 packetFilterSetReq.paramsData[0].dataLength = 1;
9626 packetFilterSetReq.paramsData[0].compareData[0] =
9627 HDD_IPV6_MC_CMP_DATA;
9628
9629 packetFilterSetReq.paramsData[1].protocolLayer =
9630 HDD_FILTER_PROTO_TYPE_ARP;
9631 packetFilterSetReq.paramsData[1].cmpFlag =
9632 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9633 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9634 packetFilterSetReq.paramsData[1].dataLength = 2;
9635 packetFilterSetReq.paramsData[1].compareData[0] =
9636 HDD_IPV6_CMP_DATA_0;
9637 packetFilterSetReq.paramsData[1].compareData[1] =
9638 HDD_IPV6_CMP_DATA_1;
9639
9640
9641 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9642 &packetFilterSetReq, sessionId))
9643 {
9644 hddLog(VOS_TRACE_LEVEL_ERROR,
9645 "%s: Failure to execute Set IPv6 Multicast Filter",
9646 __func__);
9647 return -EINVAL;
9648 }
9649 break;
9650
9651 default :
9652 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9653 "%s: Packet Filter Request: Invalid",
9654 __func__);
9655 return -EINVAL;
9656 }
9657 return 0;
9658}
9659
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309660void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009661{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309662 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309663 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009664 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309665 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009666
Yue Ma3ede6052013-08-29 00:33:26 -07009667 if (NULL == pHddCtx)
9668 {
9669 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9670 return;
9671 }
9672
9673 hHal = pHddCtx->hHal;
9674
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309675 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9678 return;
9679 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309680
9681 /* Check if INI is enabled or not, other wise just return
9682 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309683 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309684 {
9685 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9686 if (NULL == pMulticastAddrs)
9687 {
9688 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9689 return;
9690 }
9691
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 if (set)
9693 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309694 /* Following pre-conditions should be satisfied before wei
9695 * configure the MC address list.
9696 */
9697 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9698 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9699 && pAdapter->mc_addr_list.mc_cnt
9700 && (eConnectionState_Associated ==
9701 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9702 {
9703 pMulticastAddrs->ulMulticastAddrCnt =
9704 pAdapter->mc_addr_list.mc_cnt;
9705 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9706 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009707 memcpy(pMulticastAddrs->multicastAddr[i],
9708 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309709 sizeof(pAdapter->mc_addr_list.addr[i]));
9710 hddLog(VOS_TRACE_LEVEL_INFO,
9711 "%s: %s multicast filter: addr ="
9712 MAC_ADDRESS_STR,
9713 __func__, set ? "setting" : "clearing",
9714 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9715 }
9716 /* Set multicast filter */
9717 sme_8023MulticastList(hHal, pAdapter->sessionId,
9718 pMulticastAddrs);
9719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309721 else
9722 {
9723 /* Need to clear only if it was previously configured
9724 */
9725 if (pAdapter->mc_addr_list.isFilterApplied)
9726 {
9727 pMulticastAddrs->ulMulticastAddrCnt = 0;
9728 sme_8023MulticastList(hHal, pAdapter->sessionId,
9729 pMulticastAddrs);
9730 }
9731
9732 }
9733 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009734 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309736 else
9737 {
9738 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309739 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309740 }
9741 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009742}
9743
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309744static int __iw_set_packet_filter_params(struct net_device *dev,
9745 struct iw_request_info *info,
9746 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309747{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309748 hdd_adapter_t *pAdapter;
9749 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009750 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309751 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309752 struct iw_point s_priv_data;
9753
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309754 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309755
9756 if (!capable(CAP_NET_ADMIN))
9757 {
9758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9759 FL("permission check failed"));
9760 return -EPERM;
9761 }
9762
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309763 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9764 if (NULL == pAdapter)
9765 {
9766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9767 "%s: Adapter is NULL",__func__);
9768 return -EINVAL;
9769 }
9770 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9771 ret = wlan_hdd_validate_context(pHddCtx);
9772 if (0 != ret)
9773 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309774 return ret;
9775 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309776 if (hdd_priv_get_data(&s_priv_data, wrqu))
9777 {
9778 return -EINVAL;
9779 }
9780
9781 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9782 {
9783 return -EINVAL;
9784 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009785
Arif Hussain0273cba2014-01-07 20:58:29 -08009786 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309787 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9788 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009789 if (NULL == pRequest)
9790 {
9791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9792 "mem_alloc_copy_from_user_helper fail");
9793 return -ENOMEM;
9794 }
9795
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309796 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009797 kfree(pRequest);
9798
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309799 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009800 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009801}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309802
9803static int iw_set_packet_filter_params(struct net_device *dev,
9804 struct iw_request_info *info,
9805 union iwreq_data *wrqu, char *extra)
9806{
9807 int ret;
9808
9809 vos_ssr_protect(__func__);
9810 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9811 vos_ssr_unprotect(__func__);
9812
9813 return ret;
9814}
Jeff Johnson295189b2012-06-20 16:38:30 -07009815#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309816static int __iw_get_statistics(struct net_device *dev,
9817 struct iw_request_info *info,
9818 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009819{
9820
9821 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9822 eHalStatus status = eHAL_STATUS_SUCCESS;
9823 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309824 hdd_adapter_t *pAdapter;
9825 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309827 int tlen = 0, ret = 0;
9828 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009829
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309830 tCsrGlobalClassAStatsInfo *aStats;
9831 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009832
9833 ENTER();
9834
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309835 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9836 if (NULL == pAdapter)
9837 {
9838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9839 "%s: Adapter is NULL",__func__);
9840 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309842 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9843 ret = wlan_hdd_validate_context(pHddCtx);
9844 if (0 != ret)
9845 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309846 return ret;
9847 }
9848 pStats = &(pAdapter->hdd_stats.summary_stat);
9849 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9850 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9852
9853 wrqu->txpower.value = 0;
9854 }
9855 else {
9856 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9857 SME_SUMMARY_STATS |
9858 SME_GLOBAL_CLASSA_STATS |
9859 SME_GLOBAL_CLASSB_STATS |
9860 SME_GLOBAL_CLASSC_STATS |
9861 SME_GLOBAL_CLASSD_STATS |
9862 SME_PER_STA_STATS,
9863 hdd_StatisticsCB, 0, FALSE,
9864 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9865
9866 if (eHAL_STATUS_SUCCESS != status)
9867 {
9868 hddLog(VOS_TRACE_LEVEL_ERROR,
9869 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009870 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009871 return -EINVAL;
9872 }
9873
9874 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309875 if (NULL == pWextState)
9876 {
9877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9878 "%s: pWextState is NULL",__func__);
9879 return -EINVAL;
9880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009881
9882 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9883 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9884 {
9885 hddLog(VOS_TRACE_LEVEL_ERROR,
9886 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009887 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009888 /*Remove the SME statistics list by passing NULL in callback argument*/
9889 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9890 SME_SUMMARY_STATS |
9891 SME_GLOBAL_CLASSA_STATS |
9892 SME_GLOBAL_CLASSB_STATS |
9893 SME_GLOBAL_CLASSC_STATS |
9894 SME_GLOBAL_CLASSD_STATS |
9895 SME_PER_STA_STATS,
9896 NULL, 0, FALSE,
9897 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9898
9899 return -EINVAL;
9900 }
9901 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9902 (tANI_U8) sizeof (pStats->retry_cnt),
9903 (char*) &(pStats->retry_cnt[0]),
9904 tlen);
9905
9906 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9907 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9908 (char*) &(pStats->multiple_retry_cnt[0]),
9909 tlen);
9910
9911 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9912 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9913 (char*) &(pStats->tx_frm_cnt[0]),
9914 tlen);
9915
9916 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9917 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9918 (char*) &(pStats->rx_frm_cnt),
9919 tlen);
9920
9921 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9922 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9923 (char*) &(pStats->frm_dup_cnt),
9924 tlen);
9925
9926 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9927 (tANI_U8) sizeof (pStats->fail_cnt),
9928 (char*) &(pStats->fail_cnt[0]),
9929 tlen);
9930
9931 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9932 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9933 (char*) &(pStats->rts_fail_cnt),
9934 tlen);
9935
9936 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9937 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9938 (char*) &(pStats->ack_fail_cnt),
9939 tlen);
9940
9941 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9942 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9943 (char*) &(pStats->rts_succ_cnt),
9944 tlen);
9945
9946 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9947 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9948 (char*) &(pStats->rx_discard_cnt),
9949 tlen);
9950
9951 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9952 (tANI_U8) sizeof (pStats->rx_error_cnt),
9953 (char*) &(pStats->rx_error_cnt),
9954 tlen);
9955
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009956 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009957 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009958 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 tlen);
9960
9961 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9962 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9963 (char*) &(dStats->rx_byte_cnt),
9964 tlen);
9965
9966 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9967 (tANI_U8) sizeof (dStats->rx_rate),
9968 (char*) &(dStats->rx_rate),
9969 tlen);
9970
9971 /* Transmit rate, in units of 500 kbit/sec */
9972 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9973 (tANI_U8) sizeof (aStats->tx_rate),
9974 (char*) &(aStats->tx_rate),
9975 tlen);
9976
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009977 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9978 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9979 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009980 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009981 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9982 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9983 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009984 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009985 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9986 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9987 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009988 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009989 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9990 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9991 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009992 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009993 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9994 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9995 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009996 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009997 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9998 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9999 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -070010000 tlen);
10001
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 wrqu->data.length = tlen;
10003
10004 }
10005
10006 EXIT();
10007
10008 return 0;
10009}
10010
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010011static int iw_get_statistics(struct net_device *dev,
10012 struct iw_request_info *info,
10013 union iwreq_data *wrqu, char *extra)
10014{
10015 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010016
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010017 vos_ssr_protect(__func__);
10018 ret = __iw_get_statistics(dev, info, wrqu, extra);
10019 vos_ssr_unprotect(__func__);
10020
10021 return ret;
10022}
Jeff Johnson295189b2012-06-20 16:38:30 -070010023#ifdef FEATURE_WLAN_SCAN_PNO
10024
10025/*Max Len for PNO notification*/
10026#define MAX_PNO_NOTIFY_LEN 100
10027void found_pref_network_cb (void *callbackContext,
10028 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
10029{
10030 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
10031 union iwreq_data wrqu;
10032 char buf[MAX_PNO_NOTIFY_LEN+1];
10033
10034 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
10035 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
10036
10037 // create the event
10038 memset(&wrqu, 0, sizeof(wrqu));
10039 memset(buf, 0, sizeof(buf));
10040
10041 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
10042 pPrefNetworkFoundInd->ssId.ssId,
10043 (unsigned int)pPrefNetworkFoundInd->rssi);
10044
10045 wrqu.data.pointer = buf;
10046 wrqu.data.length = strlen(buf);
10047
10048 // send the event
10049
10050 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
10051
10052}
10053
10054
10055/*string based input*/
10056VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
10057 union iwreq_data *wrqu, char *extra, int nOffset)
10058{
10059 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +053010060 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -070010061 /* pnoRequest is a large struct, so we make it static to avoid stack
10062 overflow. This API is only invoked via ioctl, so it is
10063 serialized by the kernel rtnl_lock and hence does not need to be
10064 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010065 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010066 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010068 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +053010069 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010070 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
10071
10072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10073 "PNO data len %d data %s",
10074 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010075 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010076
10077 if (wrqu->data.length <= nOffset )
10078 {
10079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
10080 return VOS_STATUS_E_FAILURE;
10081 }
10082
10083 pnoRequest.enable = 0;
10084 pnoRequest.ucNetworksCount = 0;
10085 /*-----------------------------------------------------------------------
10086 Input is string based and expected to be like this:
10087
10088 <enabled> <netw_count>
10089 for each network:
10090 <ssid_len> <ssid> <authentication> <encryption>
10091 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
10092 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
10093
10094 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -070010095 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 -070010096
10097 this translates into:
10098 -----------------------------
10099 enable PNO
10100 look for 2 networks:
10101 test - with authentication type 0 and encryption type 0,
10102 that can be found on 3 channels: 1 6 and 11 ,
10103 SSID bcast type is unknown (directed probe will be sent if AP not found)
10104 and must meet -40dBm RSSI
10105
10106 test2 - with auth and enrytption type 4/4
10107 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
10108 bcast type is non-bcast (directed probe will be sent)
10109 and must not meet any RSSI threshold
10110
Jeff Johnson8301aa12013-03-28 14:27:29 -070010111 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010113
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010114 /* making sure argument string ends with '\0' */
10115 len = (wrqu->data.length-nOffset) + 1;
10116 data = vos_mem_malloc(len);
10117 if (NULL == data) {
10118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10119 FL("fail to allocate memory %zu"), len);
10120 return -EINVAL;
10121 }
10122 vos_mem_zero(data, len);
10123 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010124 ptr = data;
10125
10126 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010127 {
10128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10129 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010130 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -070010131 return VOS_STATUS_E_FAILURE;
10132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010133
10134 if ( 0 == pnoRequest.enable )
10135 {
10136 /*Disable PNO*/
10137 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +053010138 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
10139 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 pAdapter->sessionId,
10141 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010142 if (eHAL_STATUS_SUCCESS != status)
10143 {
10144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10145 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010146 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010147 return VOS_STATUS_E_FAILURE;
10148 }
10149 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010150 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 return VOS_STATUS_SUCCESS;
10152 }
10153
c_hpothu37f21312014-04-09 21:49:54 +053010154 if (TRUE == pHddCtx->isPnoEnable)
10155 {
10156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10157 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010158 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010159 return -EBUSY;
10160 }
10161 pHddCtx->isPnoEnable = TRUE;
10162
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -070010164
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010165 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010166 {
10167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10168 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010169 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010171
10172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10173 "PNO enable %d networks count %d offset %d",
10174 pnoRequest.enable,
10175 pnoRequest.ucNetworksCount,
10176 nOffset);
10177
10178 /* Parameters checking:
10179 ucNetworksCount has to be larger than 0*/
10180 if (( 0 == pnoRequest.ucNetworksCount ) ||
10181 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10182 {
10183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +053010184 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 }
10186
10187 ptr += nOffset;
10188
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010189 pnoRequest.aNetworks =
10190 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10191 if (pnoRequest.aNetworks == NULL)
10192 {
10193 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10194 FL("failed to allocate memory aNetworks %u"),
10195 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10196 goto error;
10197 }
10198 vos_mem_zero(pnoRequest.aNetworks,
10199 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10200
Jeff Johnson295189b2012-06-20 16:38:30 -070010201 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
10202 {
10203
10204 pnoRequest.aNetworks[i].ssId.length = 0;
10205
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010206 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010207 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
10208
10209 if (1 != ucParams)
10210 {
10211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10212 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010213 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010215
10216 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
10217 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
10218 {
10219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10220 "SSID Len %d is not correct for network %d",
10221 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +053010222 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 }
10224
10225 /*Advance to SSID*/
10226 ptr += nOffset;
10227
Jeff Johnson8301aa12013-03-28 14:27:29 -070010228 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -080010229 pnoRequest.aNetworks[i].ssId.length);
10230 ptr += pnoRequest.aNetworks[i].ssId.length;
10231
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010232 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -080010233 &(pnoRequest.aNetworks[i].authentication),
10234 &(pnoRequest.aNetworks[i].encryption),
10235 &(pnoRequest.aNetworks[i].ucChannelCount),
10236 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010237
Wilson Yang623f6592013-10-08 16:33:37 -070010238 if ( 3 != ucParams )
10239 {
10240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10241 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010242 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010243 }
10244
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010246 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010247 "auth %d encry %d channel count %d offset %d",
10248 pnoRequest.aNetworks[i].ssId.length,
10249 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10250 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10251 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10252 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10253 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10254 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10255 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10256 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10257 pnoRequest.aNetworks[i].authentication,
10258 pnoRequest.aNetworks[i].encryption,
10259 pnoRequest.aNetworks[i].ucChannelCount,
10260 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010261
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 /*Advance to channel list*/
10263 ptr += nOffset;
10264
Wilson Yang623f6592013-10-08 16:33:37 -070010265 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 {
10267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10268 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010269 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 }
10271
10272 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10273 {
10274 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10275 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010276 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010277 &(pnoRequest.aNetworks[i].aChannels[j]),
10278 &nOffset))
10279 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10280 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010281 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010282 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010283 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10285 FL("invalid channel: %hhu"),
10286 pnoRequest.aNetworks[i].aChannels[j]);
10287 goto error;
10288 }
10289
Wilson Yang623f6592013-10-08 16:33:37 -070010290 /*Advance to next channel number*/
10291 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 }
10293 }
10294
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010295 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010296 &(pnoRequest.aNetworks[i].bcastNetwType),
10297 &nOffset))
10298 {
10299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10300 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010301 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010302 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010303 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10305 FL("invalid bcast nw type: %u"),
10306 pnoRequest.aNetworks[i].bcastNetwType);
10307 goto error;
10308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010309
10310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10311 "PNO bcastNetwType %d offset %d",
10312 pnoRequest.aNetworks[i].bcastNetwType,
10313 nOffset );
10314
10315 /*Advance to rssi Threshold*/
10316 ptr += nOffset;
10317
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010318 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010319 &(pnoRequest.aNetworks[i].rssiThreshold),
10320 &nOffset))
10321 {
10322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10323 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010324 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010325 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010326
10327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10328 "PNO rssi %d offset %d",
10329 pnoRequest.aNetworks[i].rssiThreshold,
10330 nOffset );
10331 /*Advance to next network*/
10332 ptr += nOffset;
10333 }/*For ucNetworkCount*/
10334
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010335 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010336 &(pnoRequest.scanTimers.ucScanTimersCount),
10337 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010338
10339 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010340 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010341 {
10342 ptr += nOffset;
10343
Jeff Johnson8301aa12013-03-28 14:27:29 -070010344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10345 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 pnoRequest.scanTimers.ucScanTimersCount,
10347 nOffset );
10348
10349 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10350 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010353 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 }
10355
10356 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10357 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010358 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10360 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10361 &nOffset);
10362
Wilson Yang623f6592013-10-08 16:33:37 -070010363 if (2 != ucParams)
10364 {
10365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10366 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010367 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010368 }
10369
Jeff Johnson8301aa12013-03-28 14:27:29 -070010370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10371 "PNO Timer value %d Timer repeat %d offset %d",
10372 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10374 nOffset );
10375
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 ptr += nOffset;
10377 }
10378
10379 }
10380 else
10381 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10383 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10385
10386 /*Scan timers defaults to 5 minutes*/
10387 pnoRequest.scanTimers.ucScanTimersCount = 1;
10388 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10389 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10390 }
10391
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010392 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010393
10394 pnoRequest.modePNO = ucMode;
10395 /*for LA we just expose suspend option*/
10396 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10397 {
10398 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10399 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010400 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10401 if (pnoRequest.p24GProbeTemplate == NULL){
10402 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10403 FL("failed to allocate memory p24GProbeTemplate %u"),
10404 SIR_PNO_MAX_PB_REQ_SIZE);
10405 goto error;
10406 }
10407
10408 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10409 if (pnoRequest.p5GProbeTemplate == NULL){
10410 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10411 FL("failed to allocate memory p5GProbeTemplate %u"),
10412 SIR_PNO_MAX_PB_REQ_SIZE);
10413 goto error;
10414 }
10415
10416 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10417 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010418
c_hpothu37f21312014-04-09 21:49:54 +053010419 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 pAdapter->sessionId,
10421 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010422 if (eHAL_STATUS_SUCCESS == status)
10423 {
10424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10425 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010426 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010427 return VOS_STATUS_SUCCESS;
10428 }
10429error:
10430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10431 "%s: Failed to enable PNO", __func__);
10432 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010433 if (pnoRequest.aNetworks)
10434 vos_mem_free(pnoRequest.aNetworks);
10435 if (pnoRequest.p24GProbeTemplate)
10436 vos_mem_free(pnoRequest.p24GProbeTemplate);
10437 if (pnoRequest.p5GProbeTemplate)
10438 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010439
10440 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010441 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010442}/*iw_set_pno*/
10443
10444VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10445 union iwreq_data *wrqu, char *extra, int nOffset)
10446{
10447 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10448 v_U8_t rssiThreshold = 0;
10449 v_U8_t nRead;
10450
Arif Hussain7adce1b2013-11-11 22:59:34 -080010451 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 &rssiThreshold);
10453
10454 if ( 1 != nRead )
10455 {
10456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10457 "Incorrect format");
10458 return VOS_STATUS_E_FAILURE;
10459 }
10460
10461 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10462 return VOS_STATUS_SUCCESS;
10463}
10464
10465
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010466static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 struct iw_request_info *info,
10468 union iwreq_data *wrqu, char *extra)
10469{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010470 hdd_adapter_t *pAdapter;
10471 hdd_context_t *pHddCtx;
10472 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010473 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010474
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010475 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010476 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10477 if (NULL == pAdapter)
10478 {
10479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10480 "%s: Adapter is NULL",__func__);
10481 return -EINVAL;
10482 }
10483
10484 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10485 ret = wlan_hdd_validate_context(pHddCtx);
10486 if (0 != ret)
10487 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010488 return ret;
10489 }
10490
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010491
10492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010493 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010494
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010495 status = iw_set_pno(dev,info,wrqu,extra,0);
10496
10497 EXIT();
10498 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010499}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010500
10501static int iw_set_pno_priv(struct net_device *dev,
10502 struct iw_request_info *info,
10503 union iwreq_data *wrqu, char *extra)
10504{
10505 int ret;
10506
10507 vos_ssr_protect(__func__);
10508 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10509 vos_ssr_unprotect(__func__);
10510
10511 return ret;
10512}
Jeff Johnson295189b2012-06-20 16:38:30 -070010513#endif /*FEATURE_WLAN_SCAN_PNO*/
10514
10515//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010516int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010517{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010518 hdd_adapter_t *pAdapter;
10519 tHalHandle hHal;
10520 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010521 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010522 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010523 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010525 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010526 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010527 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010528
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010529 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010530 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10531 if (NULL == pAdapter)
10532 {
10533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10534 "%s: Adapter is NULL",__func__);
10535 return -EINVAL;
10536 }
10537 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10538 retval = wlan_hdd_validate_context(pHddCtx);
10539 if (0 != retval)
10540 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010541 return retval;
10542 }
10543 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10544 if (NULL == hHal)
10545 {
10546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10547 "%s: Hal Context is NULL",__func__);
10548 return -EINVAL;
10549 }
10550 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010551
Atul Mittal54378cb2014-04-02 16:51:50 +053010552 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 {
10554 case WLAN_HDD_UI_BAND_AUTO:
10555 band = eCSR_BAND_ALL;
10556 break;
10557 case WLAN_HDD_UI_BAND_5_GHZ:
10558 band = eCSR_BAND_5G;
10559 break;
10560 case WLAN_HDD_UI_BAND_2_4_GHZ:
10561 band = eCSR_BAND_24;
10562 break;
10563 default:
10564 band = eCSR_BAND_MAX;
10565 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010566 connectedBand =
10567 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010568
Atul Mittal54378cb2014-04-02 16:51:50 +053010569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010570 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010571
10572 if (band == eCSR_BAND_MAX)
10573 {
10574 /* Received change band request with invalid band value */
10575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010576 "%s: Invalid band value %u", __func__, ui_band);
10577 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 }
10579
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010580 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010581 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010582 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010584 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010585 band, pHddCtx->cfg_ini->nBandCapability);
10586 return -EIO;
10587 }
10588
Sushant Kaushik1165f872015-03-30 20:25:27 +053010589 if (band == eCSR_BAND_ALL)
10590 {
10591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10592 "received. Setting band same as ini value %d"),
10593 pHddCtx->cfg_ini->nBandCapability);
10594 band = pHddCtx->cfg_ini->nBandCapability;
10595 }
10596
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10598 {
10599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10600 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010601 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010602 return -EIO;
10603 }
10604
10605 if (currBand != band)
10606 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010607 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010608 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010609 /* Return failure if current country code is world regulatory domain*/
10610 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10611 pMac->scan.countryCodeCurrent[1] == '0') )
10612 {
10613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10614 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010615 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010616 return -EAGAIN;
10617 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010618 }
10619
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 /* Change band request received.
10621 * Abort pending scan requests, flush the existing scan results,
10622 * and change the band capability
10623 */
10624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10625 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010626 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010627
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010628 /* We need to change the band and flush the scan results here itself
10629 * as we may get timeout for disconnection in which we will return
10630 * with out doing any of these
10631 */
10632 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10633 {
10634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10635 "%s: failed to set the band value to %u ",
10636 __func__, band);
10637 return -EINVAL;
10638 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010639 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10640 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010641 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010642 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10643 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010644 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010645 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10646 * information available in NV so to get the channel information from kernel
10647 * we need to send regulatory hint for the currunt country
10648 * And to set the same country again we need to set the dummy country
10649 * first and then the actual country.
10650 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010652 if(curr_country[0] == '0' && curr_country[1] == '0')
10653 regulatory_hint_user("IN", NL80211_USER_REG_HINT_USER);
10654 else
10655 regulatory_hint_user("OO", NL80211_USER_REG_HINT_USER);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010656#else
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010657 if(curr_country[0] == '0' && curr_country[1] == '0')
10658 regulatory_hint_user("IN");
10659 else
10660 regulatory_hint_user("00");
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010661#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010662 wait_result = wait_for_completion_interruptible_timeout(
10663 &pHddCtx->linux_reg_req,
10664 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10665
10666 /* if the country information does not exist with the kernel,
10667 then the driver callback would not be called */
10668
10669 if (wait_result >= 0)
10670 {
10671 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10672 "runtime country code is found in kernel db");
10673 }
10674 else
10675 {
10676 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10677 "runtime country code is not found"
10678 " in kernel db");
10679 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010680
10681 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010682
10683 /*
10684 * Update 11dcountry and current country here as the hint
10685 * with 00 results in 11d and current country with 00
10686 */
10687 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10688 WNI_CFG_COUNTRY_CODE_LEN);
10689 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10690 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010691#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10692 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10693#else
10694 regulatory_hint_user(curr_country);
10695#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010696 wait_result = wait_for_completion_interruptible_timeout(
10697 &pHddCtx->linux_reg_req,
10698 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10699
10700 /* if the country information does not exist with the kernel,
10701 then the driver callback would not be called */
10702 if (wait_result >= 0)
10703 {
10704 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10705 "runtime country code is found in kernel db");
10706 }
10707 else
10708 {
10709 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10710 "runtime country code is not found"
10711 " in kernel db");
10712 }
10713
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010714 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010715 }
10716 else
10717 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010718#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010719 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10720 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010721#else
10722 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10723#endif
10724
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010725 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010726 pScanInfo = &pHddCtx->scan_info;
10727 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10728 {
10729 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10730 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10731 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010732 sme_FilterScanResults(hHal, pAdapter->sessionId);
10733
10734 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010735 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10736 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010737 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010738 eHalStatus status = eHAL_STATUS_SUCCESS;
10739 long lrc;
10740
10741 /* STA already connected on current band, So issue disconnect first,
10742 * then change the band*/
10743
10744 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010745 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010746 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010747
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10749
10750 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10751 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10752
Jeff Johnson43971f52012-07-17 12:26:56 -070010753 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 {
10755 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010756 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 __func__, (int)status );
10758 return -EINVAL;
10759 }
10760
10761 lrc = wait_for_completion_interruptible_timeout(
10762 &pAdapter->disconnect_comp_var,
10763 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10764
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010765 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010766
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010767 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010768 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010769
10770 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10771 }
10772 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010774 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010775 if (TRUE == pHddCtx->isSetBandByNL)
10776 return 0;
10777 else
10778 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010779}
10780
Atul Mittal54378cb2014-04-02 16:51:50 +053010781int hdd_setBand_helper(struct net_device *dev, const char *command)
10782{
10783 u8 band;
10784
10785 /*convert the band value from ascii to integer*/
10786 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10787
10788 return hdd_setBand(dev, band);
10789
10790}
10791
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010792static int __iw_set_band_config(struct net_device *dev,
10793 struct iw_request_info *info,
10794 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010795{
Atul Mittal54378cb2014-04-02 16:51:50 +053010796 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010797
Arif Hussain0273cba2014-01-07 20:58:29 -080010798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010799
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010800 if (!capable(CAP_NET_ADMIN))
10801 {
10802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10803 FL("permission check failed"));
10804 return -EPERM;
10805 }
10806
Atul Mittal54378cb2014-04-02 16:51:50 +053010807 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010808}
10809
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010810static int iw_set_band_config(struct net_device *dev,
10811 struct iw_request_info *info,
10812 union iwreq_data *wrqu, char *extra)
10813{
10814 int ret;
10815
10816 vos_ssr_protect(__func__);
10817 ret = __iw_set_band_config(dev, info, wrqu, extra);
10818 vos_ssr_unprotect(__func__);
10819
10820 return ret;
10821}
10822
c_manjeecfd1efb2015-09-25 19:32:34 +053010823static int get_fwr_memdump(struct net_device *dev,
10824 struct iw_request_info *info,
10825 union iwreq_data *wrqu, char *extra)
10826{
10827 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10828 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10829 int ret;
10830 ENTER();
10831 // HddCtx sanity
10832 ret = wlan_hdd_validate_context(pHddCtx);
10833 if (0 != ret)
10834 {
10835 return ret;
10836 }
10837 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10838 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10839 {
10840 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10841 return -EINVAL;
10842 }
10843 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10844
10845 EXIT();
10846 return ret;
10847}
10848
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010849static int __iw_set_power_params_priv(struct net_device *dev,
10850 struct iw_request_info *info,
10851 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010852{
Arif Hussain0273cba2014-01-07 20:58:29 -080010853 int ret;
10854 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010855
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10857 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010858
10859 if (!capable(CAP_NET_ADMIN))
10860 {
10861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10862 FL("permission check failed"));
10863 return -EPERM;
10864 }
10865
Arif Hussain0273cba2014-01-07 20:58:29 -080010866 /* ODD number is used for set, copy data using copy_from_user */
10867 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10868 wrqu->data.length);
10869 if (NULL == ptr)
10870 {
10871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10872 "mem_alloc_copy_from_user_helper fail");
10873 return -ENOMEM;
10874 }
10875
10876 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10877 kfree(ptr);
10878 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010879}
10880
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010881static int iw_set_power_params_priv(struct net_device *dev,
10882 struct iw_request_info *info,
10883 union iwreq_data *wrqu, char *extra)
10884{
10885 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010886
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010887 vos_ssr_protect(__func__);
10888 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10889 vos_ssr_unprotect(__func__);
10890
10891 return ret;
10892}
Jeff Johnson295189b2012-06-20 16:38:30 -070010893
10894/*string based input*/
10895VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10896 union iwreq_data *wrqu, char *extra, int nOffset)
10897{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010898 hdd_adapter_t *pAdapter;
10899 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 tSirSetPowerParamsReq powerRequest;
10901 char *ptr;
10902 v_U8_t ucType;
10903 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010904 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010905
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010906 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010907 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10908 if (NULL == pAdapter)
10909 {
10910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10911 "%s: Adapter is NULL",__func__);
10912 return -EINVAL;
10913 }
10914
10915 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10916 ret = wlan_hdd_validate_context(pHddCtx);
10917 if (0 != ret)
10918 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010919 return ret;
10920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10922 "Power Params data len %d data %s",
10923 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010924 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010925
10926 if (wrqu->data.length <= nOffset )
10927 {
10928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10929 return VOS_STATUS_E_FAILURE;
10930 }
10931
10932 uTotalSize = wrqu->data.length - nOffset;
10933
10934 /*-----------------------------------------------------------------------
10935 Input is string based and expected to be like this:
10936
10937 <param_type> <param_value> <param_type> <param_value> ...
10938
10939 e.g:
10940 1 2 2 3 3 0 4 1 5 1
10941
10942 e.g. setting just a few:
10943 1 2 4 1
10944
10945 parameter types:
10946 -----------------------------
10947 1 - Ignore DTIM
10948 2 - Listen Interval
10949 3 - Broadcast Multicas Filter
10950 4 - Beacon Early Termination
10951 5 - Beacon Early Termination Interval
10952 -----------------------------------------------------------------------*/
10953 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10954 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10955 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10956 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10957 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10958
Arif Hussain7adce1b2013-11-11 22:59:34 -080010959 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010960
10961 while ( uTotalSize )
10962 {
Wilson Yang6f971452013-10-08 15:00:00 -070010963 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10964 {
10965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10966 "Invalid input parameter type %s",ptr);
10967 return VOS_STATUS_E_FAILURE;
10968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010969
10970 uTotalSize -= nOffset;
10971
10972 if (!uTotalSize)
10973 {
10974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010975 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 ucType, nOffset);
10977 return VOS_STATUS_E_FAILURE;
10978 }
10979
10980 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010981
Jeff Johnson02797792013-10-26 19:17:13 -070010982 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010983 {
10984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10985 "Invalid input parameter value %s",ptr);
10986 return VOS_STATUS_E_FAILURE;
10987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010988
10989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10990 "Power request parameter %d value %d offset %d",
10991 ucType, uValue, nOffset);
10992
10993 switch (ucType)
10994 {
10995 case eSIR_IGNORE_DTIM:
10996 powerRequest.uIgnoreDTIM = uValue;
10997 break;
10998 case eSIR_LISTEN_INTERVAL:
10999 powerRequest.uListenInterval = uValue;
11000 break;
11001 case eSIR_MCAST_BCAST_FILTER:
11002 powerRequest.uBcastMcastFilter = uValue;
11003 break;
11004 case eSIR_ENABLE_BET:
11005 powerRequest.uEnableBET = uValue;
11006 break;
11007 case eSIR_BET_INTERVAL:
11008 powerRequest.uBETInterval = uValue;
11009 break;
11010 default:
11011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080011012 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011013 ucType, uValue, nOffset);
11014 return VOS_STATUS_E_FAILURE;
11015 }
11016
11017 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11019 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070011020 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070011022 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011023 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070011024 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
11025 {
11026 uTotalSize = 0;
11027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011028
11029 }/*Go for as long as we have a valid string*/
11030
11031 /* put the device into full power*/
11032 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
11033
11034 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080011035 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011036
11037 /* put the device back to power save*/
11038 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
11039
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011040 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 return VOS_STATUS_SUCCESS;
11042}/*iw_set_power_params*/
11043
Atul Mittalc0f739f2014-07-31 13:47:47 +053011044// tdlsoffchan
11045#ifdef FEATURE_WLAN_TDLS
11046
Atul Mittal87ec2422014-09-24 13:12:50 +053011047int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011048{
11049 if (offchannel < 0 || offchannel > 165)
11050 {
11051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
11052 __func__, offchannel);
11053 return -1;
11054
11055 }
11056
11057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
11058 __func__, tdlsOffCh, offchannel);
11059
11060 tdlsOffCh = offchannel;
11061 return 0;
11062}
11063
Atul Mittal87ec2422014-09-24 13:12:50 +053011064int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011065{
11066 if (offchanoffset == 0)
11067 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011068 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11070 __func__, tdlsOffChBwOffset);
11071
11072 return 0;
11073
11074 }
11075
11076 if ( offchanoffset == 40 )
11077 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011078 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11080 __func__, tdlsOffChBwOffset);
11081
11082 return 0;
11083
11084 }
11085 if (offchanoffset == -40)
11086 {
11087 tdlsOffChBwOffset = 3;
11088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11089 __func__, tdlsOffChBwOffset);
11090
11091 return 0;
11092
11093 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053011094
11095 if ((offchanoffset == 80) &&
11096 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
11097 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
11098 {
11099 tdlsOffChBwOffset = 4;
11100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11101 "%s: change tdls secondary off channel offset to %u",
11102 __func__, tdlsOffChBwOffset);
11103
11104 return 0;
11105 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053011106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
11107 __func__, offchanoffset);
11108 return -1;
11109}
11110
Atul Mittal87ec2422014-09-24 13:12:50 +053011111int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011112{
11113 hddTdlsPeer_t *connPeer = NULL;
11114 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11115 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011116 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011117 if (offchanmode < 0 || offchanmode > 4)
11118 {
11119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11120 "%s: Invalid tdls off channel mode %d",
11121 __func__, offchanmode);
11122 return -1;
11123 }
11124
11125 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
11126 {
11127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11128 "%s: tdls off channel mode req in not associated state %d",
11129 __func__, offchanmode);
11130 return -1;
11131 }
11132
11133 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
11134 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
11135 {
11136 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011137 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011138 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011139 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011140 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11142 "%s: No TDLS Connected Peer", __func__);
11143 return -1;
11144 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011145 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011146 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011147 }
11148 else
11149 {
11150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11151 "%s: TDLS Connection not supported", __func__);
11152 return -1;
11153 }
11154
11155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11156 ("%s: TDLS Channel Switch in swmode=%d"),
11157 __func__, offchanmode);
11158
11159 switch (offchanmode)
11160 {
11161 case 1:/*Enable*/
11162 case 2:/*Disable*/
11163 {
11164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11165 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
11166 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11167 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
11168 {
11169
11170 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011171 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053011172 tdlsOffCh, tdlsOffChBwOffset,
11173 offchanmode);
11174 }
11175 else
11176 {
11177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11178 "%s: TDLS Off Channel not supported", __func__);
11179 return -1;
11180 }
11181 break;
11182 }
11183 case 3:
11184 {
11185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11186 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
11187 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11188
11189 break;
11190 }
11191 case 4:
11192 {
11193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11194 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
11195 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11196 break;
11197 }
11198 default:
11199 {
11200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11201 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
11202 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11203 break;
11204 }
11205
11206 }
11207
11208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
11209 __func__, offchanmode);
11210 return 0;
11211}
Atul Mittalc0f739f2014-07-31 13:47:47 +053011212#endif
11213
Jeff Johnson295189b2012-06-20 16:38:30 -070011214// Define the Wireless Extensions to the Linux Network Device structure
11215// A number of these routines are NULL (meaning they are not implemented.)
11216
11217static const iw_handler we_handler[] =
11218{
11219 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
11220 (iw_handler) iw_get_name, /* SIOCGIWNAME */
11221 (iw_handler) NULL, /* SIOCSIWNWID */
11222 (iw_handler) NULL, /* SIOCGIWNWID */
11223 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
11224 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
11225 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
11226 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
11227 (iw_handler) NULL, /* SIOCSIWSENS */
11228 (iw_handler) NULL, /* SIOCGIWSENS */
11229 (iw_handler) NULL, /* SIOCSIWRANGE */
11230 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053011231 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 (iw_handler) NULL, /* SIOCGIWPRIV */
11233 (iw_handler) NULL, /* SIOCSIWSTATS */
11234 (iw_handler) NULL, /* SIOCGIWSTATS */
11235 iw_handler_set_spy, /* SIOCSIWSPY */
11236 iw_handler_get_spy, /* SIOCGIWSPY */
11237 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
11238 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
11239 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11240 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11241 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11242 (iw_handler) NULL, /* SIOCGIWAPLIST */
11243 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11244 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11245 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11246 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11247 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11248 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11249 (iw_handler) NULL, /* -- hole -- */
11250 (iw_handler) NULL, /* -- hole -- */
11251 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11252 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11253 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11254 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11255 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11256 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11257 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11258 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11259 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11260 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11261 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11262 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11263 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11264 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11265 (iw_handler) NULL, /* -- hole -- */
11266 (iw_handler) NULL, /* -- hole -- */
11267 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11268 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11269 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11270 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11271 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11272 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11273 (iw_handler) NULL, /* SIOCSIWPMKSA */
11274};
11275
11276static const iw_handler we_private[] = {
11277
11278 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11279 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11280 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11281 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11282 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11283 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011284 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011285 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11286 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11287 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011288 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11289 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011290#ifdef FEATURE_OEM_DATA_SUPPORT
11291 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11292 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11293#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011294
Jeff Johnson295189b2012-06-20 16:38:30 -070011295#ifdef WLAN_FEATURE_VOWIFI_11R
11296 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11297#endif
11298 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11299 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11300 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11301#ifdef WLAN_FEATURE_PACKET_FILTERING
11302 ,
11303 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11304#endif
11305#ifdef FEATURE_WLAN_SCAN_PNO
11306 ,
11307 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11308#endif
11309 ,
11310 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11311 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11312 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11313 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011314 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011315};
11316
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011317static const iw_handler we_mon_private[] = {
11318 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] =
11319 iw_mon_setint_getnone,
11320};
11321
11322static const struct iw_priv_args we_mon_private_args[] = {
11323 {WE_SET_MONITOR_STATE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11324 0, "monitor"},
11325
11326 /* handlers for main ioctl */
11327 {WLAN_PRIV_SET_INT_GET_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11328 0, "" },
11329};
11330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331/*Maximum command length can be only 15 */
11332static const struct iw_priv_args we_private_args[] = {
11333
Katya Nigamf0511f62015-05-05 16:40:57 +053011334 { WE_SET_MONITOR_STATE,
11335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11336 0, "monitor" },
11337
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 /* handlers for main ioctl */
11339 { WLAN_PRIV_SET_INT_GET_NONE,
11340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11341 0,
11342 "" },
11343
11344 /* handlers for sub-ioctl */
11345 { WE_SET_11D_STATE,
11346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11347 0,
11348 "set11Dstate" },
11349
11350 { WE_WOWL,
11351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11352 0,
11353 "wowl" },
11354
11355 { WE_SET_POWER,
11356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11357 0,
11358 "setPower" },
11359
11360 { WE_SET_MAX_ASSOC,
11361 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11362 0,
11363 "setMaxAssoc" },
11364
11365 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11366 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11367 0,
11368 "setAutoChannel" },
11369
11370 { WE_SET_DATA_INACTIVITY_TO,
11371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11372 0,
11373 "inactivityTO" },
11374
11375 { WE_SET_MAX_TX_POWER,
11376 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11377 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011378 "setMaxTxPower" },
11379
11380 { WE_SET_MAX_TX_POWER_2_4,
11381 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11382 0,
11383 "setTxMaxPower2G" },
11384
11385 { WE_SET_MAX_TX_POWER_5_0,
11386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11387 0,
11388 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011389
11390 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11391 * as well to keep same syntax as in SAP. Now onwards, STA
11392 * will support both */
11393 { WE_SET_MAX_TX_POWER,
11394 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11395 0,
11396 "setTxMaxPower" },
11397
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11399 * 1 = enable and 0 = disable */
11400 {
11401 WE_SET_HIGHER_DTIM_TRANSITION,
11402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11403 0,
11404 "setHDtimTransn" },
11405
11406 { WE_SET_TM_LEVEL,
11407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011408 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 "setTmLevel" },
11410
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011411 { WE_ENABLE_STRICT_FCC_REG,
11412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11413 0,
11414 "setStrictFCCreg" },
11415
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011416 { WE_SET_DEBUG_LOG,
11417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11418 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011419#ifdef FEATURE_WLAN_TDLS
11420 {
11421 WE_SET_TDLS_OFF_CHAN,
11422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11423 0,
11424 "tdlsoffchan" },
11425 {
11426 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11428 0,
11429 "tdlsecchnoffst" },
11430 {
11431 WE_SET_TDLS_OFF_CHAN_MODE,
11432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11433 0,
11434 "tdlsoffchnmode" },
11435#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011436
Peng Xu2446a892014-09-05 17:21:18 +053011437 { WE_SET_SCAN_BAND_PREFERENCE,
11438 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11439 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011440 {
11441 WE_GET_FRAME_LOG,
11442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11443 0,
11444 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011445
Abhishek Singh01c73d12015-03-12 15:13:44 +053011446 { WE_SET_MIRACAST_VENDOR_CONFIG,
11447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11448 0, "setMiracstConf" },
11449
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011450#ifdef FEATURE_WLAN_TDLS
11451 {
11452 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11453 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11454 0,
11455 "tdls_2040bsscox" },
11456#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011457 { WE_SET_RTS_CTS_HTVHT,
11458 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11459 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011460 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11461 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11462 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011463 { WE_SET_PROXIMITY_ENABLE,
11464 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11465 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011466
11467#ifdef WLAN_FEATURE_TSF
11468 { WE_CAP_TSF,
11469 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11470 0, "cap_tsf" },
11471#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011472 { WE_SET_MODULATED_DTIM,
11473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11474 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011475 {
11476 WLAN_SET_DYNNAMIC_AGGREGATION,
11477 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11478 0, "setAggregation" },
11479
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 /* handlers for main ioctl */
11481 { WLAN_PRIV_SET_NONE_GET_INT,
11482 0,
11483 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11484 "" },
11485
11486 /* handlers for sub-ioctl */
11487 { WE_GET_11D_STATE,
11488 0,
11489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11490 "get11Dstate" },
11491
11492 { WE_IBSS_STATUS,
11493 0,
11494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11495 "getAdhocStatus" },
11496
11497 { WE_PMC_STATE,
11498 0,
11499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11500 "pmcState" },
11501
11502 { WE_GET_WLAN_DBG,
11503 0,
11504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11505 "getwlandbg" },
11506
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 { WE_GET_MAX_ASSOC,
11508 0,
11509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11510 "getMaxAssoc" },
11511
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 { WE_GET_WDI_DBG,
11513 0,
11514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11515 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011516
11517 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11518 0,
11519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11520 "getAutoChannel" },
11521
11522 { WE_GET_CONCURRENCY_MODE,
11523 0,
11524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11525 "getconcurrency" },
11526
Peng Xu2446a892014-09-05 17:21:18 +053011527 { WE_GET_SCAN_BAND_PREFERENCE,
11528 0,
11529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11530 "get_scan_pref"},
11531
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011532 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11533 0,
11534 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11535 "getCurAnt"},
11536
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 /* handlers for main ioctl */
11538 { WLAN_PRIV_SET_CHAR_GET_NONE,
11539 IW_PRIV_TYPE_CHAR| 512,
11540 0,
11541 "" },
11542
11543 /* handlers for sub-ioctl */
11544 { WE_WOWL_ADD_PTRN,
11545 IW_PRIV_TYPE_CHAR| 512,
11546 0,
11547 "wowlAddPtrn" },
11548
11549 { WE_WOWL_DEL_PTRN,
11550 IW_PRIV_TYPE_CHAR| 512,
11551 0,
11552 "wowlDelPtrn" },
11553
11554#if defined WLAN_FEATURE_VOWIFI
11555 /* handlers for sub-ioctl */
11556 { WE_NEIGHBOR_REPORT_REQUEST,
11557 IW_PRIV_TYPE_CHAR | 512,
11558 0,
11559 "neighbor" },
11560#endif
11561 { WE_SET_AP_WPS_IE,
11562 IW_PRIV_TYPE_CHAR| 512,
11563 0,
11564 "set_ap_wps_ie" },
11565
11566 { WE_SET_CONFIG,
11567 IW_PRIV_TYPE_CHAR| 512,
11568 0,
11569 "setConfig" },
11570
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011571 { WE_SET_ENCRYPT_MSG,
11572 IW_PRIV_TYPE_CHAR| 512,
11573 0,
11574 "encryptMsg" },
11575
11576
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 /* handlers for main ioctl */
11578 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11580 0,
11581 "" },
11582
11583 /* handlers for sub-ioctl */
11584 { WE_SET_WLAN_DBG,
11585 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11586 0,
11587 "setwlandbg" },
11588
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 { WE_SET_WDI_DBG,
11590 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11591 0,
11592 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011593
11594 { WE_SET_SAP_CHANNELS,
11595 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11596 0,
11597 "setsapchannels" },
11598
11599 /* handlers for main ioctl */
11600 { WLAN_PRIV_GET_CHAR_SET_NONE,
11601 0,
11602 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11603 "" },
11604
11605 /* handlers for sub-ioctl */
11606 { WE_WLAN_VERSION,
11607 0,
11608 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11609 "version" },
11610 { WE_GET_STATS,
11611 0,
11612 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11613 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011614 { WE_GET_STATES,
11615 0,
11616 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11617 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 { WE_GET_CFG,
11619 0,
11620 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11621 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011622#ifdef WLAN_FEATURE_11AC
11623 { WE_GET_RSSI,
11624 0,
11625 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11626 "getRSSI" },
11627#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011628#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011629 { WE_GET_ROAM_RSSI,
11630 0,
11631 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11632 "getRoamRSSI" },
11633#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 { WE_GET_WMM_STATUS,
11635 0,
11636 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11637 "getWmmStatus" },
11638 {
11639 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011640 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11642 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011643#ifdef FEATURE_WLAN_TDLS
11644 {
11645 WE_GET_TDLS_PEERS,
11646 0,
11647 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11648 "getTdlsPeers" },
11649#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011650#ifdef WLAN_FEATURE_11W
11651 {
11652 WE_GET_11W_INFO,
11653 0,
11654 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11655 "getPMFInfo" },
11656#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011657#ifdef WLAN_FEATURE_RMC
11658 {
11659 WE_GET_IBSS_STA_INFO,
11660 0,
11661 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11662 "getIbssSTAs" },
11663#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011664 { WE_GET_SNR,
11665 0,
11666 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11667 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011668#ifdef FEATURE_OEM_DATA_SUPPORT
11669 {
11670 WE_GET_OEM_DATA_CAP,
11671 0,
11672 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11673 "getOemDataCap" },
11674#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 /* handlers for main ioctl */
11676 { WLAN_PRIV_SET_NONE_GET_NONE,
11677 0,
11678 0,
11679 "" },
11680
11681 /* handlers for sub-ioctl */
11682 { WE_CLEAR_STATS,
11683 0,
11684 0,
11685 "clearStats" },
11686 { WE_INIT_AP,
11687 0,
11688 0,
11689 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011690#ifdef WLAN_FEATURE_RMC
11691 {
11692 WE_IBSS_GET_PEER_INFO_ALL,
11693 0,
11694 0,
11695 "ibssPeerInfoAll" },
11696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 { WE_STOP_AP,
11698 0,
11699 0,
11700 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011701#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 { WE_ENABLE_AMP,
11703 0,
11704 0,
11705 "enableAMP" },
11706 { WE_DISABLE_AMP,
11707 0,
11708 0,
11709 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011710#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011711 { WE_ENABLE_DXE_STALL_DETECT,
11712 0,
11713 0,
11714 "dxeStallDetect" },
11715 { WE_DISPLAY_DXE_SNAP_SHOT,
11716 0,
11717 0,
11718 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011719 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11720 0,
11721 0,
11722 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011723 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011724 WE_SET_REASSOC_TRIGGER,
11725 0,
11726 0,
11727 "reassoc" },
11728 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011729 WE_STOP_OBSS_SCAN,
11730 0,
11731 0,
11732 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011733 {
11734 WE_DUMP_ROAM_TIMER_LOG,
11735 0,
11736 0,
11737 "dumpRoamDelay" },
11738 {
11739 WE_RESET_ROAM_TIMER_LOG,
11740 0,
11741 0,
11742 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011743 {
11744 WE_GET_FW_LOGS,
11745 0,
11746 0,
11747 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011748 {
11749 WE_GET_FW_MEMDUMP,
11750 0,
11751 0,
11752 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 /* handlers for main ioctl */
11754 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11755 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11756 0,
11757 "" },
11758
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011759
11760
Jeff Johnson295189b2012-06-20 16:38:30 -070011761 /* handlers for sub-ioctl */
11762 { WE_LOG_DUMP_CMD,
11763 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11764 0,
11765 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011766#ifdef WLAN_FEATURE_RMC
11767 { WE_IBSS_GET_PEER_INFO,
11768 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11769 0,
11770 "ibssPeerInfo" },
11771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011772
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011773 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011774 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11775 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11776 0,
11777 "setdumplog" },
11778
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011779 { WE_MTRACE_DUMP_CMD,
11780 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11781 0,
11782 "dumplog" },
11783
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011784 /* handlers for sub ioctl */
11785 {
11786 WE_MCC_CONFIG_CREDENTIAL,
11787 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11788 0,
11789 "setMccCrdnl" },
11790
11791 /* handlers for sub ioctl */
11792 {
11793 WE_MCC_CONFIG_PARAMS,
11794 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11795 0,
11796 "setMccConfig" },
11797
Chilam NG571c65a2013-01-19 12:27:36 +053011798#ifdef FEATURE_WLAN_TDLS
11799 /* handlers for sub ioctl */
11800 {
11801 WE_TDLS_CONFIG_PARAMS,
11802 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11803 0,
11804 "setTdlsConfig" },
11805#endif
11806
Katya Nigamf0511f62015-05-05 16:40:57 +053011807 {
11808 WE_CONFIGURE_MONITOR_MODE,
11809 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11810 0,
11811 "MonitorModeConf" },
11812
11813 {
11814 WE_SET_MONITOR_MODE_FILTER,
11815 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11816 0,
11817 "MonitorFilter" },
11818
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 /* handlers for main ioctl */
11820 { WLAN_PRIV_ADD_TSPEC,
11821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11822 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11823 "addTspec" },
11824
11825 /* handlers for main ioctl */
11826 { WLAN_PRIV_DEL_TSPEC,
11827 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11829 "delTspec" },
11830
11831 /* handlers for main ioctl */
11832 { WLAN_PRIV_GET_TSPEC,
11833 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11835 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011836 /* handlers for main ioctl */
11837 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11838 0,
11839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11840 "" },
11841#ifdef WLAN_FEATURE_TSF
11842 { WE_GET_TSF,
11843 0,
11844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11845 "get_tsf" },
11846#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011847#ifdef FEATURE_OEM_DATA_SUPPORT
11848 /* handlers for main ioctl - OEM DATA */
11849 {
11850 WLAN_PRIV_SET_OEM_DATA_REQ,
11851 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11852 0,
11853 "set_oem_data_req" },
11854
11855 /* handlers for main ioctl - OEM DATA */
11856 {
11857 WLAN_PRIV_GET_OEM_DATA_RSP,
11858 0,
11859 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11860 "get_oem_data_rsp" },
11861#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011862
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 /* handlers for main ioctl - host offload */
11864 {
11865 WLAN_PRIV_SET_HOST_OFFLOAD,
11866 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11867 0,
11868 "setHostOffload" },
11869
11870 {
11871 WLAN_GET_WLAN_STATISTICS,
11872 0,
11873 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11874 "getWlanStats" },
11875
11876 {
11877 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011878 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11879 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011880 0,
11881 "setKeepAlive" },
11882#ifdef WLAN_FEATURE_PACKET_FILTERING
11883 {
11884 WLAN_SET_PACKET_FILTER_PARAMS,
11885 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11886 0,
11887 "setPktFilter" },
11888#endif
11889#ifdef FEATURE_WLAN_SCAN_PNO
11890 {
11891 WLAN_SET_PNO,
11892 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11893 0,
11894 "setpno" },
11895#endif
11896 {
11897 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 0,
11900 "SETBAND" },
11901 /* handlers for dynamic MC BC ioctl */
11902 {
11903 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011904 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 0,
11906 "setMCBCFilter" },
11907 {
11908 WLAN_PRIV_CLEAR_MCBC_FILTER,
11909 0,
11910 0,
11911 "clearMCBCFilter" },
11912 {
11913 WLAN_SET_POWER_PARAMS,
11914 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11915 0,
11916 "setpowerparams" },
11917 {
11918 WLAN_GET_LINK_SPEED,
11919 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011920 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011921 {
11922 WLAN_PRIV_SET_FTIES,
11923 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11924 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011925};
11926
11927
11928
11929const struct iw_handler_def we_handler_def = {
11930 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11931 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11932 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11933
11934 .standard = (iw_handler *)we_handler,
11935 .private = (iw_handler *)we_private,
11936 .private_args = we_private_args,
11937 .get_wireless_stats = get_wireless_stats,
11938};
11939
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011940const struct iw_handler_def we_mon_handler_def = {
11941 .num_standard = 0,
11942 .num_private = sizeof(we_mon_private) / sizeof(we_mon_private[0]),
11943 .num_private_args =
11944 sizeof(we_mon_private_args) / sizeof(we_mon_private_args[0]),
11945 .standard = NULL,
11946 .private = (iw_handler *)we_mon_private,
11947 .private_args = we_mon_private_args,
11948 .get_wireless_stats = NULL,
11949};
11950
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011951int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11952{
11953 v_U32_t cmd = 288; //Command to RIVA
11954 hdd_context_t *pHddCtx = NULL;
11955 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11956 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11957 /*
11958 *configMccParam : specify the bit which needs to be modified
11959 *allowed to update based on wlan_qcom_cfg.ini
11960 * configuration
11961 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11962 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11963 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11964 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11965 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11966 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11967 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11968 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11969 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11970 * Bit 9 : Reserved
11971 */
11972 switch (arg1)
11973 {
11974 //Update MCC SCHEDULE_TIME_SLICE parameter
11975 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11976 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11977 {
11978 if((arg2 >= 5) && (arg2 <= 20))
11979 {
11980 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11981 }
11982 else
11983 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011984 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011985 return 0;
11986 }
11987 }
11988 break;
11989
11990 //Update MCC MAX_NULL_SEND_TIME parameter
11991 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11992 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11993 {
11994 if((arg2 >= 1) && (arg2 <= 10))
11995 {
11996 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11997 }
11998 else
11999 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012000 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012001 return 0;
12002 }
12003 }
12004 break;
12005
12006 //Update MCC TX_EARLY_STOP_TIME parameter
12007 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
12008 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
12009 {
12010 if((arg2 >= 1) && (arg2 <= 10))
12011 {
12012 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12013 }
12014 else
12015 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012016 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012017 return 0;
12018 }
12019 }
12020 break;
12021
12022 //Update MCC RX_DRAIN_TIME parameter
12023 case MCC_RX_DRAIN_TIME_CFG_PARAM :
12024 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
12025 {
12026 if((arg2 >= 1) && (arg2 <= 10))
12027 {
12028 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12029 }
12030 else
12031 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012032 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012033 return 0;
12034 }
12035 }
12036 break;
12037
12038 //Update MCC CHANNEL_SWITCH_TIME parameter
12039 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
12040 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
12041 {
12042 if((arg2 >= 1) && (arg2 <= 20))
12043 {
12044 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12045 }
12046 else
12047 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012048 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012049 return 0;
12050 }
12051 }
12052 break;
12053
12054 //Update MCC MIN_CHANNEL_TIME parameter
12055 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
12056 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
12057 {
12058 if((arg2 >= 5) && (arg2 <= 20))
12059 {
12060 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12061 }
12062 else
12063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012064 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012065 return 0;
12066 }
12067 }
12068 break;
12069
12070 //Update MCC PARK_BEFORE_TBTT parameter
12071 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
12072 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
12073 {
12074 if((arg2 >= 1) && (arg2 <= 5))
12075 {
12076 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12077 }
12078 else
12079 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012080 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012081 return 0;
12082 }
12083 }
12084 break;
12085
12086 //Update MCC MIN_AFTER_DTIM parameter
12087 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
12088 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
12089 {
12090 if((arg2 >= 5) && (arg2 <= 15))
12091 {
12092 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12093 }
12094 else
12095 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012096 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012097 return 0;
12098 }
12099 }
12100 break;
12101
12102 //Update MCC TOO_CLOSE_MARGIN parameter
12103 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
12104 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
12105 {
12106 if((arg2 >= 1) && (arg2 <= 3))
12107 {
12108 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12109 }
12110 else
12111 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012112 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012113 return 0;
12114 }
12115 }
12116 break;
12117
12118 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080012119 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012120 __FUNCTION__,arg1);
12121 break;
12122 }
12123 return 0;
12124}
12125
Jeff Johnson295189b2012-06-20 16:38:30 -070012126int hdd_set_wext(hdd_adapter_t *pAdapter)
12127{
12128 hdd_wext_state_t *pwextBuf;
12129 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012130 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131
12132 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12133
12134 // Now configure the roaming profile links. To SSID and bssid.
12135 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
12136 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
12137
12138 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
12139 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
12140
12141 /*Set the numOfChannels to zero to scan all the channels*/
12142 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
12143 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
12144
12145 /* Default is no encryption */
12146 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
12147 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
12148
12149 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
12150 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
12151
12152 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
12153
12154 /* Default is no authentication */
12155 pwextBuf->roamProfile.AuthType.numEntries = 1;
12156 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
12157
12158 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
12159 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12160
12161 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012162 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012163
12164 hdd_clearRoamProfileIe(pAdapter);
12165
12166 return VOS_STATUS_SUCCESS;
12167
12168 }
12169
12170int hdd_register_wext(struct net_device *dev)
12171 {
12172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12173 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12174 VOS_STATUS status;
12175
12176 ENTER();
12177
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012178 if (pAdapter->device_mode == WLAN_HDD_MONITOR &&
12179 hdd_get_conparam() != VOS_MONITOR_MODE) {
12180 // Register as a wireless device
12181 dev->wireless_handlers = (struct iw_handler_def *)&we_mon_handler_def;
12182 return 0;
12183 }
12184
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 // Zero the memory. This zeros the profile structure.
12186 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
12187
12188 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
12189
12190
12191 status = hdd_set_wext(pAdapter);
12192
12193 if(!VOS_IS_STATUS_SUCCESS(status)) {
12194
Arif Hussain6d2a3322013-11-17 19:50:10 -080012195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 return eHAL_STATUS_FAILURE;
12197 }
12198
12199 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
12200 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 return eHAL_STATUS_FAILURE;
12203 }
12204
12205 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
12206 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 return eHAL_STATUS_FAILURE;
12209 }
12210
12211 // Register as a wireless device
12212 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12213
12214 EXIT();
12215 return 0;
12216}
12217
12218int hdd_UnregisterWext(struct net_device *dev)
12219{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070012220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053012221 if (dev != NULL)
12222 {
12223 rtnl_lock();
12224 dev->wireless_handlers = NULL;
12225 rtnl_unlock();
12226 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053012227
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 return 0;
12229}
12230
12231