blob: 5d8582f924707b5decf241b799ec2f33cd51308b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntuka88566212019-04-17 15:02:33 +05302 * Copyright (c) 2011-2019 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;
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +0530842 return 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700843 }
844 }
845 }
846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800847 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700848 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700849}
850
851static v_BOOL_t
852hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
853{
854 v_BOOL_t rsnType = VOS_FALSE;
855 // is the authType supported?
856 switch (authType)
857 {
858 case eCSR_AUTH_TYPE_NONE: //never used
859 rsnType = eANI_BOOLEAN_FALSE;
860 break;
861 // MAC layer authentication types
862 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
863 rsnType = eANI_BOOLEAN_FALSE;
864 break;
865 case eCSR_AUTH_TYPE_SHARED_KEY:
866 rsnType = eANI_BOOLEAN_FALSE;
867 break;
868 case eCSR_AUTH_TYPE_AUTOSWITCH:
869 rsnType = eANI_BOOLEAN_FALSE;
870 break;
871
872 // Upper layer authentication types
873 case eCSR_AUTH_TYPE_WPA:
874 rsnType = eANI_BOOLEAN_TRUE;
875 break;
876 case eCSR_AUTH_TYPE_WPA_PSK:
877 rsnType = eANI_BOOLEAN_TRUE;
878 break;
879 case eCSR_AUTH_TYPE_WPA_NONE:
880 rsnType = eANI_BOOLEAN_TRUE;
881 break;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 case eCSR_AUTH_TYPE_FT_RSN:
884#endif
885 case eCSR_AUTH_TYPE_RSN:
886 rsnType = eANI_BOOLEAN_TRUE;
887 break;
888#ifdef WLAN_FEATURE_VOWIFI_11R
889 case eCSR_AUTH_TYPE_FT_RSN_PSK:
890#endif
891 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700892#ifdef WLAN_FEATURE_11W
893 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530894 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 rsnType = eANI_BOOLEAN_TRUE;
897 break;
898 //case eCSR_AUTH_TYPE_FAILED:
899 case eCSR_AUTH_TYPE_UNKNOWN:
900 rsnType = eANI_BOOLEAN_FALSE;
901 break;
902 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800903 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
904 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 rsnType = eANI_BOOLEAN_FALSE;
906 break;
907 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800908 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700909 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 return rsnType;
911}
912
Jeff Johnson295189b2012-06-20 16:38:30 -0700913
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530914struct snr_priv {
915 int8_t snr;
916};
917
918/**
919 * hdd_get_snr_cb() - "Get SNR" callback function
920 * @snr: Current SNR of the station
921 * @sta_id: ID of the station
922 * @context: opaque context originally passed to SME. HDD always passes
923 * a cookie for the request context
924 *
925 * Return: None
926 */
927static void hdd_get_snr_cb(tANI_S8 snr, tANI_U32 staId, void *context)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530928{
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530929 struct hdd_request *request;
930 struct snr_priv *priv;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530931
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530932 request = hdd_request_get(context);
933 if (!request) {
934 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
935 return;
936 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530937
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530938 /* propagate response back to requesting thread */
939 priv = hdd_request_priv(request);
940 priv->snr = snr;
941 hdd_request_complete(request);
942 hdd_request_put(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530943}
944
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530945struct rssi_priv {
946 v_S7_t rssi;
947};
948
949static void hdd_get_rssi_cb( v_S7_t rssi, tANI_U32 staId, void *context )
950{
951 struct hdd_request *request;
952 struct rssi_priv *priv;
953
954 if (ioctl_debug) {
955 pr_info("%s: rssi [%d] STA [%d] context [%pK]\n",
956 __func__, (int)rssi, (int)staId, context);
957 }
958
959 request = hdd_request_get(context);
960 if (!request) {
961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
962 return;
963 }
964
965 priv = hdd_request_priv(request);
966 priv->rssi = rssi;
967
968 hdd_request_complete(request);
969 hdd_request_put(request);
970}
971
Jeff Johnson295189b2012-06-20 16:38:30 -0700972VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
973{
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 hdd_context_t *pHddCtx;
975 hdd_station_ctx_t *pHddStaCtx;
976 eHalStatus hstatus;
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +0530977 int ret;
978 void *cookie;
979 struct hdd_request *request;
980 struct rssi_priv *priv;
981 static const struct hdd_request_params params = {
982 .priv_size = sizeof(*priv),
983 .timeout_ms = WLAN_WAIT_TIME_STATS,
984 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 if (NULL == pAdapter)
987 {
988 hddLog(VOS_TRACE_LEVEL_WARN,
989 "%s: Invalid context, pAdapter", __func__);
990 return VOS_STATUS_E_FAULT;
991 }
992 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
993 {
994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
995 /* return a cached value */
996 *rssi_value = pAdapter->rssi;
997 return VOS_STATUS_SUCCESS;
998 }
999
1000 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1001 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1002
mukul sharma8aec69b2015-06-10 22:28:43 +05301003 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1004 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1006 __func__, pAdapter->rssi_on_disconnect);
1007 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301008 return VOS_STATUS_SUCCESS;
1009 }
1010
1011 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1012 {
1013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1014 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1015 *rssi_value = pAdapter->rssi;
1016 return VOS_STATUS_SUCCESS;
1017 }
1018
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301019 request = hdd_request_alloc(&params);
1020 if (!request) {
1021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1022 return VOS_STATUS_E_NOMEM;
1023 }
1024 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301026 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pHddStaCtx->conn_info.staId[ 0 ],
1028 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301029 cookie, pHddCtx->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 if (eHAL_STATUS_SUCCESS != hstatus)
1031 {
1032 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001033 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /* we'll returned a cached value below */
1035 }
1036 else
1037 {
1038 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301039 ret = hdd_request_wait_for_response(request);
1040 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 {
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301042 hddLog(VOS_TRACE_LEVEL_ERROR,
1043 FL("SME timeout while retrieving RSSI"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 /* we'll now returned a cached value below */
1045 }
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301046 else
1047 {
1048 priv = hdd_request_priv(request);
1049 pAdapter->rssi = priv->rssi;
1050 /*
1051 * copy over the rssi.FW will return RSSI as -100 if
1052 * there are no samples to calculate the averag RSSI
1053 */
1054 if (priv->rssi != -100)
1055 pAdapter->rssi = priv->rssi;
Jeff Johnson72a40512013-12-19 10:14:15 -08001056
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301057 if (pAdapter->rssi > 0)
1058 pAdapter->rssi = 0;
1059 }
1060 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301063 hddLog(VOS_TRACE_LEVEL_INFO,
1064 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065
Hanumanth Reddy Pothula084e45b2018-04-05 18:02:55 +05301066 /*
1067 * either we never sent a request, we sent a request and received a
1068 * response or we sent a request and timed out. Regardless we are
1069 * done with the request.
1070 */
1071 hdd_request_put(request);
1072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 return VOS_STATUS_SUCCESS;
1074}
Siddharth Bhal64246172015-02-27 01:04:37 +05301075/**---------------------------------------------------------------------------
1076
1077 \brief wlan_hdd_get_frame_logs() -
1078
1079 This function use to get Frames log.
1080
1081 \param - pAdapter Pointer to the adapter.
1082 flag - Specify type of request. Clear and Send request are
1083 supported.
1084
1085 \return - none
1086
1087 --------------------------------------------------------------------------*/
1088VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1089{
Siddharth Bhal64246172015-02-27 01:04:37 +05301090 hdd_context_t *pHddCtx;
1091 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301092
1093 if (NULL == pAdapter)
1094 {
1095 hddLog(VOS_TRACE_LEVEL_WARN,
1096 "%s: Invalid context, pAdapter", __func__);
1097 return VOS_STATUS_E_FAULT;
1098 }
1099
1100 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1101 if (!pHddCtx->mgmt_frame_logging)
1102 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301103 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301104 return VOS_STATUS_E_AGAIN;
1105 }
1106
Siddharth Bhal4507c262015-04-29 20:20:42 +05301107 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1108 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1109 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301110 {
1111 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1112 return VOS_STATUS_E_INVAL;
1113 }
1114
Siddharth Bhal4507c262015-04-29 20:20:42 +05301115 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1116 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1119 return VOS_STATUS_E_INVAL;
1120 }
1121
Abhishek Singh611295e2015-07-09 11:11:54 +05301122 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301123 if (eHAL_STATUS_SUCCESS != hstatus)
1124 {
1125 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301126 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301127 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301128
1129 return VOS_STATUS_SUCCESS;
1130}
1131
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301132
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301133VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1134{
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301135 hdd_context_t *pHddCtx;
1136 hdd_station_ctx_t *pHddStaCtx;
1137 eHalStatus hstatus;
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301138 int ret;
1139 void *cookie;
1140 struct hdd_request *request;
1141 struct snr_priv *priv;
1142 static const struct hdd_request_params params = {
1143 .priv_size = sizeof(*priv),
1144 .timeout_ms = WLAN_WAIT_TIME_STATS,
1145 };
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301147 ENTER();
1148
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301149 if (NULL == pAdapter)
1150 {
1151 hddLog(VOS_TRACE_LEVEL_ERROR,
1152 "%s: Invalid context, pAdapter", __func__);
1153 return VOS_STATUS_E_FAULT;
1154 }
1155
1156 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1157
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301158 ret = wlan_hdd_validate_context(pHddCtx);
1159 if (0 != ret)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301160 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301161 return VOS_STATUS_E_FAULT;
1162 }
1163
1164 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1165 if (NULL == pHddStaCtx)
1166 {
1167 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1168 return VOS_STATUS_E_FAULT;
1169 }
1170
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301171 request = hdd_request_alloc(&params);
1172 if (!request) {
1173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1174 return VOS_STATUS_E_FAULT;
1175 }
1176 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301177
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301178 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_get_snr_cb,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301179 pHddStaCtx->conn_info.staId[ 0 ],
1180 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301181 cookie);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301182 if (eHAL_STATUS_SUCCESS != hstatus)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1185 __func__);
1186 /* we'll returned a cached value below */
1187 }
1188 else
1189 {
1190 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301191 ret = hdd_request_wait_for_response(request);
1192 if (ret) {
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 FL("SME timed out while retrieving SNR"));
1195 /* we'll now returned a cached value below */
1196 } else {
1197 /* update the adapter with the fresh results */
1198 priv = hdd_request_priv(request);
1199 pAdapter->snr = priv->snr;
1200 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301201 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001202
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301203 /*
1204 * either we never sent a request, we sent a request and
1205 * received a response or we sent a request and timed out.
1206 * regardless we are done with the request.
1207 */
1208 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001209
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301210 *snr = pAdapter->snr;
1211
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301212 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301213 return VOS_STATUS_SUCCESS;
1214}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301215
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001216#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001217
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1219{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001220 hdd_context_t *pHddCtx = NULL;
1221 hdd_station_ctx_t *pHddStaCtx = NULL;
1222 eHalStatus hstatus;
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301223 int ret;
1224 void *cookie;
1225 struct hdd_request *request;
1226 struct rssi_priv *priv;
1227 static const struct hdd_request_params params = {
1228 .priv_size = sizeof(*priv),
1229 .timeout_ms = WLAN_WAIT_TIME_STATS,
1230 };
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001231
1232 if (NULL == pAdapter)
1233 {
1234 hddLog(VOS_TRACE_LEVEL_WARN,
1235 "%s: Invalid context, pAdapter", __func__);
1236 return VOS_STATUS_E_FAULT;
1237 }
1238 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1239 {
1240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1241 /* return a cached value */
1242 *rssi_value = pAdapter->rssi;
1243 return VOS_STATUS_SUCCESS;
1244 }
1245
1246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1247 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1248
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301249 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001250 {
1251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1252 /* return a cached value */
1253 *rssi_value = 0;
1254 return VOS_STATUS_SUCCESS;
1255 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301256
1257 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1258 {
1259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1260 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1261 *rssi_value = pAdapter->rssi;
1262 return VOS_STATUS_SUCCESS;
1263 }
1264
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301265 request = hdd_request_alloc(&params);
1266 if (!request) {
1267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1268 return VOS_STATUS_E_NOMEM;
1269 }
1270 cookie = hdd_request_cookie(request);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001271
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301272 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_get_rssi_cb,
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001273 pHddStaCtx->conn_info.staId[ 0 ],
1274 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301275 cookie, pHddCtx->pvosContext);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001276 if (eHAL_STATUS_SUCCESS != hstatus)
1277 {
1278 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1279 __func__);
1280 /* we'll returned a cached value below */
1281 }
1282 else
1283 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301284 ret = hdd_request_wait_for_response(request);
1285 if(ret)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001286 /* request was sent -- wait for the response */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001287 {
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301288 hddLog(VOS_TRACE_LEVEL_ERROR,
1289 FL(" SME timeout while retrieving RSSI"));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001290 /* we'll now returned a cached value below */
1291 }
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301292 else
1293 {
1294 priv = hdd_request_priv(request);
1295 pAdapter->rssi = priv->rssi;
1296 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001297 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001298
Hanumanth Reddy Pothulaa88659e2018-04-09 18:45:14 +05301299 /*
1300 * either we never sent a request, we sent a request and received a
1301 * response or we sent a request and timed out. Regardless we are
1302 * done with the request.
1303 */
1304 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001305
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001306 *rssi_value = pAdapter->rssi;
1307
1308 return VOS_STATUS_SUCCESS;
1309}
1310#endif
1311
1312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313void hdd_StatisticsCB( void *pStats, void *pContext )
1314{
1315 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1316 hdd_stats_t *pStatsCache = NULL;
1317 hdd_wext_state_t *pWextState;
1318 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1319
1320 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1321 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1322 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1323 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1324 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1325 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1326
1327 if (pAdapter!= NULL)
1328 pStatsCache = &pAdapter->hdd_stats;
1329
1330
1331 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1332 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1333 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1334 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1335 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1336 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1337
1338 if (pStatsCache!=NULL)
1339 {
1340 // and copy the stats into the cache we keep in the adapter instance structure
1341 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1342 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1343 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1344 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1345 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1346 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1347 }
1348
1349 if(pAdapter)
1350 {
1351 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1352 if(pWextState)
1353 {
1354 vos_status = vos_event_set(&pWextState->vosevent);
1355 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1356 {
1357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001358 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 return;
1360 }
1361 }
1362 }
1363}
1364
1365void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1366{
1367 v_CONTEXT_t pVosContext;
1368 hdd_context_t *pHddCtx;
1369 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1370#if 0
1371 hdd_wext_state_t *pWextState;
1372 v_U32_t roamId;
1373#endif
1374
1375 ENTER();
1376
1377 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1378
1379 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1380 if (NULL == pHddCtx)
1381 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 return;
1384 }
1385#if 0
1386 pWextState = pAdapter->pWextState;
1387#endif
1388
1389 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1390 {
1391 //TODO Verify is this is really used. If yes need to fix it.
1392 hdd_reconnect_all_adapters( pHddCtx );
1393#if 0
1394 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1395 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1396 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1397
1398 if(VOS_STATUS_SUCCESS == vosStatus)
1399 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1400 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1401
1402 sme_RoamConnect(halHandle,
1403 pAdapter->sessionId, &(pWextState->roamProfile),
1404 &roamId);
1405#endif
1406 }
1407
1408 EXIT();
1409
1410}
1411
1412void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1413{
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1415
1416 /* clear WPA/RSN/WSC IE information in the profile */
1417 pWextState->roamProfile.nWPAReqIELength = 0;
1418 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1419 pWextState->roamProfile.nRSNReqIELength = 0;
1420 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1421
Chet Lanctot186b5732013-03-18 10:26:30 -07001422#ifdef FEATURE_WLAN_WAPI
1423 pWextState->roamProfile.nWAPIReqIELength = 0;
1424 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1425#endif
1426
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001428 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301430 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1432 pWextState->roamProfile.nAddIEAssocLength = 0;
1433
1434 pWextState->roamProfile.EncryptionType.numEntries = 1;
1435 pWextState->roamProfile.EncryptionType.encryptionType[0]
1436 = eCSR_ENCRYPT_TYPE_NONE;
1437
1438 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1439 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1440 = eCSR_ENCRYPT_TYPE_NONE;
1441
1442 pWextState->roamProfile.AuthType.numEntries = 1;
1443 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1444
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301445 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001446#ifdef WLAN_FEATURE_11W
1447 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1448 pWextState->roamProfile.MFPRequired = 0;
1449 pWextState->roamProfile.MFPCapable = 0;
1450#endif
1451
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 pWextState->authKeyMgmt = 0;
1453
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301454 vos_mem_zero(&pWextState->roamProfile.Keys,
1455 sizeof(pWextState->roamProfile.Keys));
1456
Jeff Johnson295189b2012-06-20 16:38:30 -07001457#ifdef FEATURE_WLAN_WAPI
1458 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1459 pAdapter->wapi_info.nWapiMode = 0;
1460#endif
1461
1462 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1463
1464}
1465
1466void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1467{
1468 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469
Nirav Shahf6bd2672015-03-11 12:53:15 +05301470 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001471 {
1472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301473 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001474 }
1475 else
1476 {
1477 complete(&pAdapter->ula_complete);
1478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001479}
1480
1481VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1482{
1483 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001485 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
1487 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1488 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001489 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
1491 /*To avoid race condition between the set key and the last EAPOL
1492 packet, notify TL to finish upper layer authentication incase if the
1493 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001494 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001496 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 {
1498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1499 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1500 __LINE__, vos_status );
1501 return vos_status;
1502
1503 }
1504
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001505 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301507 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001508 {
1509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301510 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001511 /* we'll still fall through and return success since the
1512 * connection may still get established but is just taking
1513 * too long for us to wait */
1514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 }
1516 return VOS_STATUS_SUCCESS;
1517}
1518
1519v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len)
1520{
1521
1522 int left = ie_len;
1523 v_U8_t *ptr = ie;
1524 v_U8_t elem_id,elem_len;
1525 v_U8_t eid = 0xDD;
1526
1527 if ( NULL == ie || 0 == ie_len )
1528 return NULL;
1529
1530 while(left >= 2)
1531 {
1532 elem_id = ptr[0];
1533 elem_len = ptr[1];
1534 left -= 2;
1535 if(elem_len > left)
1536 {
1537 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001538 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 eid,elem_len,left);
1540 return NULL;
1541 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301542 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 {
1544 if(memcmp( &ptr[2], oui, oui_size)==0)
1545 return ptr;
1546 }
1547
1548 left -= elem_len;
1549 ptr += (elem_len + 2);
1550 }
1551 return NULL;
1552}
1553
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301554static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 union iwreq_data *wrqu, char *extra)
1556{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301557 hdd_adapter_t *pAdapter;
1558 hdd_context_t *pHddCtx;
1559 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560
1561 ENTER();
1562
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301563 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1564 if (NULL == pAdapter)
1565 {
1566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1567 "%s: pAdapter is NULL\n", __func__);
1568 return -EINVAL;
1569 }
1570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1571 ret = wlan_hdd_validate_context(pHddCtx);
1572 if (0 != ret)
1573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301574 return ret;
1575 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301576
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301578
1579 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301580 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581}
1582
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301583static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1584 union iwreq_data *wrqu, char *extra)
1585{
1586 int ret;
1587
1588 vos_ssr_protect(__func__);
1589 ret = __iw_set_commit(dev, info, wrqu, extra);
1590 vos_ssr_unprotect(__func__);
1591
1592 return ret;
1593}
1594
1595static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 struct iw_request_info *info,
1597 char *wrqu, char *extra)
1598{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301599 hdd_adapter_t *pAdapter;
1600 hdd_context_t *pHddCtx;
1601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301602
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1605 if (NULL == pAdapter)
1606 {
1607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1608 "%s: pAdapter is NULL\n", __func__);
1609 return -EINVAL;
1610 }
1611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1612 ret = wlan_hdd_validate_context(pHddCtx);
1613 if (0 != ret)
1614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301615 return ret;
1616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1618 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301619 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001620}
1621
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301622static int iw_get_name(struct net_device *dev,
1623 struct iw_request_info *info,
1624 char *wrqu, char *extra)
1625{
1626 int ret;
1627
1628 vos_ssr_protect(__func__);
1629 ret = __iw_get_name(dev, info, wrqu, extra);
1630 vos_ssr_unprotect(__func__);
1631
1632 return ret;
1633}
1634
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301635static int __iw_set_freq(struct net_device *dev,
1636 struct iw_request_info *info,
1637 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001638{
1639 v_U32_t numChans = 0;
1640 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1641 v_U32_t indx = 0;
1642 v_U32_t status = 0;
1643
1644 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301645 hdd_adapter_t *pAdapter;
1646 hdd_context_t *pHddCtx;
1647 tHalHandle hHal;
1648 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301650
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 ENTER();
1652
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301653 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1654 if (NULL == pAdapter)
1655 {
1656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1657 "%s:Invalid Adapter",__func__);
1658 return -EINVAL;
1659 }
1660
1661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1662 status = wlan_hdd_validate_context(pHddCtx);
1663 if (0 != status)
1664 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 return status;
1666 }
1667
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301668 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1669 if (NULL == hHal)
1670 {
1671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1672 "%s: Hal Context is NULL",__func__);
1673 return -EINVAL;
1674 }
1675
1676 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1677 if (NULL == pHddStaCtx)
1678 {
1679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1680 "%s:STA context is NULL",__func__);
1681 return -EINVAL;
1682 }
1683
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301685 if (NULL == pWextState)
1686 {
1687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1688 "%s: pWextState is NULL",__func__);
1689 return -EINVAL;
1690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001691
1692 pRoamProfile = &pWextState->roamProfile;
1693
Arif Hussain6d2a3322013-11-17 19:50:10 -08001694 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001695
1696 /* Link is up then return cant set channel*/
1697 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1698 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1699 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001700 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 return -EOPNOTSUPP;
1702 }
1703
1704 /* Settings by Frequency as input */
1705 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1706 (wrqu->freq.m <= (tANI_U32)5.825e8))
1707 {
1708 tANI_U32 freq = wrqu->freq.m / 100000;
1709
1710 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1711 indx++;
1712 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1713 {
1714 return -EINVAL;
1715 }
1716 wrqu->freq.e = 0;
1717 wrqu->freq.m = freq_chan_map[indx].chan;
1718
1719 }
1720
1721 if (wrqu->freq.e == 0)
1722 {
1723 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1724 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1725 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001726 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001727 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1729 return -EINVAL;
1730 }
1731
1732 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1733
1734 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1735 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1737 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 return -EIO;
1739 }
1740
1741 for (indx = 0; indx < numChans; indx++) {
1742 if (wrqu->freq.m == validChan[indx]){
1743 break;
1744 }
1745 }
1746 }
1747 else{
1748
1749 return -EINVAL;
1750 }
1751
1752 if(indx >= numChans)
1753 {
1754 return -EINVAL;
1755 }
1756
1757 /* Set the Operational Channel */
1758 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1759 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1760 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1761
Arif Hussain6d2a3322013-11-17 19:50:10 -08001762 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763
1764 EXIT();
1765
1766 return status;
1767}
1768
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301769static int iw_set_freq(struct net_device *dev,
1770 struct iw_request_info *info,
1771 union iwreq_data *wrqu, char *extra)
1772{
1773 int ret;
1774
1775 vos_ssr_protect(__func__);
1776 ret = __iw_set_freq(dev, info, wrqu, extra);
1777 vos_ssr_unprotect(__func__);
1778
1779 return ret;
1780}
1781
1782static int __iw_get_freq(struct net_device *dev,
1783 struct iw_request_info *info,
1784 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001785{
Jeff Johnsone7245742012-09-05 17:12:55 -07001786 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301787 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 tHalHandle hHal;
1789 hdd_wext_state_t *pWextState;
1790 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301791 hdd_station_ctx_t *pHddStaCtx;
1792 hdd_context_t *pHddCtx;
1793 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 ENTER();
1796
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301797 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1798 if (NULL == pAdapter)
1799 {
1800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1801 "%s: Adapter is NULL", __func__);
1802 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301804 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1805 ret = wlan_hdd_validate_context(pHddCtx);
1806 if (0 != ret)
1807 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301808 return ret;
1809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301811 if (NULL == hHal)
1812 {
1813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1814 "%s: Hal Context is NULL",__func__);
1815 return -EINVAL;
1816 }
1817 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1818 if (NULL == pHddStaCtx)
1819 {
1820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1821 "%s: HddStaCtx is NULL", __func__);
1822 return -EINVAL;
1823 }
1824 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1825 if (NULL == pWextState)
1826 {
1827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1828 "%s: pWextState is NULL",__func__);
1829 return -EINVAL;
1830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 pRoamProfile = &pWextState->roamProfile;
1832
1833 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1834 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001835 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 {
c_hpothub8245442013-11-20 23:41:09 +05301837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1838 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 return -EIO;
1840 }
1841 else
1842 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001843 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05301844 if( 0 == status )
Jeff Johnsone7245742012-09-05 17:12:55 -07001845 {
1846 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1847 * iwlist & iwconfig command shows frequency into proper
1848 * format (2.412 GHz instead of 246.2 MHz)*/
1849 fwrq->m = freq;
1850 fwrq->e = MHZ;
1851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 }
1853 }
1854 else
1855 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001856 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1857 * iwlist & iwconfig command shows frequency into proper
1858 * format (2.412 GHz instead of 246.2 MHz)*/
1859 fwrq->m = 0;
1860 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301862
1863 EXIT();
1864 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001865}
1866
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301867static int iw_get_freq(struct net_device *dev,
1868 struct iw_request_info *info,
1869 struct iw_freq *fwrq, char *extra)
1870{
1871 int ret;
1872
1873 vos_ssr_protect(__func__);
1874 ret = __iw_get_freq(dev, info, fwrq, extra);
1875 vos_ssr_unprotect(__func__);
1876
1877 return ret;
1878}
1879
1880static int __iw_get_tx_power(struct net_device *dev,
1881 struct iw_request_info *info,
1882 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001883{
1884
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301885 hdd_adapter_t *pAdapter;
1886 hdd_context_t *pHddCtx;
1887 hdd_station_ctx_t *pHddStaCtx;
1888 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301890 ENTER();
1891
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301892 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1893 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1896 "%s: Adapter is NULL",__func__);
1897 return -EINVAL;
1898 }
1899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1900 ret = wlan_hdd_validate_context(pHddCtx);
1901 if (0 != ret)
1902 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301903 return ret;
1904 }
1905
1906 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1907 if (NULL == pHddStaCtx)
1908 {
1909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1910 "%s: STA Context is NULL",__func__);
1911 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 }
1913
1914 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1915 {
1916 wrqu->txpower.value = 0;
1917 return 0;
1918 }
1919 wlan_hdd_get_classAstats(pAdapter);
1920 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301922 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 return 0;
1924}
1925
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301926static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 struct iw_request_info *info,
1928 union iwreq_data *wrqu, char *extra)
1929{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301930 int ret;
1931
1932 vos_ssr_protect(__func__);
1933 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1934 vos_ssr_unprotect(__func__);
1935
1936 return ret;
1937}
1938
1939static int __iw_set_tx_power(struct net_device *dev,
1940 struct iw_request_info *info,
1941 union iwreq_data *wrqu, char *extra)
1942{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301943 hdd_adapter_t *pAdapter;
1944 tHalHandle hHal;
1945 hdd_context_t *pHddCtx;
1946 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001947
1948 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301949 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1950 if (NULL == pAdapter)
1951 {
1952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1953 "%s: Adapter is NULL",__func__);
1954 return -EINVAL;
1955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001956
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1958 ret = wlan_hdd_validate_context(pHddCtx);
1959 if (0 != ret)
1960 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301961 return ret;
1962 }
1963
1964 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1965 if (NULL == hHal)
1966 {
1967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1968 "%s: Hal Context is NULL",__func__);
1969 return -EINVAL;
1970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1972 {
c_hpothub8245442013-11-20 23:41:09 +05301973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1974 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 return -EIO;
1976 }
1977
1978 EXIT();
1979
1980 return 0;
1981}
1982
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301983static int iw_set_tx_power(struct net_device *dev,
1984 struct iw_request_info *info,
1985 union iwreq_data *wrqu, char *extra)
1986{
1987 int ret;
1988
1989 vos_ssr_protect(__func__);
1990 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1991 vos_ssr_unprotect(__func__);
1992
1993 return ret;
1994}
1995
1996static int __iw_get_bitrate(struct net_device *dev,
1997 struct iw_request_info *info,
1998 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001999{
2000 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2001 eHalStatus status = eHAL_STATUS_SUCCESS;
2002 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302003 hdd_adapter_t *pAdapter;
2004 hdd_context_t *pHddCtx;
2005 hdd_station_ctx_t *pHddStaCtx;
2006 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002007
2008 ENTER();
2009
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302010 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2011 if (NULL == pAdapter)
2012 {
2013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2014 "%s: Adapter is NULL",__func__);
2015 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 }
2017
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302018 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2019 ret = wlan_hdd_validate_context(pHddCtx);
2020 if (0 != ret)
2021 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302022 return ret;
2023 }
2024
2025 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2026 if (NULL == pHddStaCtx)
2027 {
2028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2029 "%s: STA Context is NULL",__func__);
2030 return -EINVAL;
2031 }
2032
2033 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 wrqu->bitrate.value = 0;
2035 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302036 else
2037 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2039 SME_SUMMARY_STATS |
2040 SME_GLOBAL_CLASSA_STATS |
2041 SME_GLOBAL_CLASSB_STATS |
2042 SME_GLOBAL_CLASSC_STATS |
2043 SME_GLOBAL_CLASSD_STATS |
2044 SME_PER_STA_STATS,
2045 hdd_StatisticsCB, 0, FALSE,
2046 pHddStaCtx->conn_info.staId[0], pAdapter );
2047
2048 if(eHAL_STATUS_SUCCESS != status)
2049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR,
2051 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002052 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 return status;
2054 }
2055
2056 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302057 if (NULL == pWextState)
2058 {
2059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2060 "%s: pWextState is NULL",__func__);
2061 return -EINVAL;
2062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2065
2066 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2067 {
2068 hddLog(VOS_TRACE_LEVEL_ERROR,
2069 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002070 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 return VOS_STATUS_E_FAILURE;
2072 }
2073
2074 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2075 }
2076
2077 EXIT();
2078
2079 return vos_status;
2080}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302081
2082static int iw_get_bitrate(struct net_device *dev,
2083 struct iw_request_info *info,
2084 union iwreq_data *wrqu, char *extra)
2085{
2086 int ret;
2087
2088 vos_ssr_protect(__func__);
2089 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2090 vos_ssr_unprotect(__func__);
2091
2092 return ret;
2093}
2094
2095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096/* ccm call back function */
2097
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302098static int __iw_set_bitrate(struct net_device *dev,
2099 struct iw_request_info *info,
2100 union iwreq_data *wrqu,
2101 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002102{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302103 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302105 hdd_station_ctx_t *pHddStaCtx;
2106 hdd_context_t *pHddCtx;
Ashish Kumar Dhanotiyaaa9e38c2018-05-23 20:23:24 +05302107 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN +
2108 WNI_CFG_SUPPORTED_RATES_11B_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2110 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2111 v_U32_t i, rate;
2112 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302113 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114
2115 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302116 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2117 if (NULL == pAdapter)
2118 {
2119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2120 "%s: Adapter is NULL",__func__);
2121 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
2123
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302124 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2125 ret = wlan_hdd_validate_context(pHddCtx);
2126 if (0 != ret)
2127 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302128 return ret;
2129 }
2130
2131 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2132 if (NULL == pHddStaCtx)
2133 {
2134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2135 "%s: STA Context is NULL",__func__);
2136 return -EINVAL;
2137 }
2138
2139
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302141 if (NULL == pWextState)
2142 {
2143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2144 "%s: pWextState is NULL",__func__);
2145 return -EINVAL;
2146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2149 {
2150 return -ENXIO ;
2151 }
2152
2153 rate = wrqu->bitrate.value;
2154
2155 if (rate == -1)
2156 {
2157 rate = WNI_CFG_FIXED_RATE_AUTO;
2158 valid_rate = TRUE;
2159 }
2160 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2161 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2162 {
2163 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2164 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2165 {
2166 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2167 WNI_CFG_SUPPORTED_RATES_11A,
2168 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2169 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2170 WNI_CFG_SUPPORTED_RATES_11B,
Ashish Kumar Dhanotiyaaa9e38c2018-05-23 20:23:24 +05302171 supp_rates + a_len, &b_len) == eHAL_STATUS_SUCCESS))
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 {
2173 for (i = 0; i < (b_len + a_len); ++i)
2174 {
2175 /* supported rates returned is double the actual rate so we divide it by 2 */
2176 if ((supp_rates[i]&0x7F)/2 == rate)
2177 {
2178 valid_rate = TRUE;
2179 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2180 break;
2181 }
2182 }
2183 }
2184 }
2185 }
2186 if (valid_rate != TRUE)
2187 {
2188 return -EINVAL;
2189 }
2190 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2191 WNI_CFG_FIXED_RATE, rate,
2192 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2193 {
c_hpothub8245442013-11-20 23:41:09 +05302194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2195 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 return -EIO;
2197 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302198
2199 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 return 0;
2201}
2202
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302203static int iw_set_bitrate(struct net_device *dev,
2204 struct iw_request_info *info,
2205 union iwreq_data *wrqu,
2206 char *extra)
2207{
2208 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002209
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302210 vos_ssr_protect(__func__);
2211 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2212 vos_ssr_unprotect(__func__);
2213
2214 return ret;
2215}
2216
2217static int __iw_set_genie(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu,
2220 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302222 hdd_adapter_t *pAdapter;
2223 hdd_context_t *pHddCtx;
2224 hdd_wext_state_t *pWextState;
2225 u_int8_t *genie = NULL;
2226 u_int8_t *base_genie = NULL;
2227 v_U16_t remLen;
2228 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
2230 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002231
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302232 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2233 if (NULL == pAdapter)
2234 {
2235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2236 "%s: Adapter is NULL",__func__);
2237 return -EINVAL;
2238 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002239
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302240 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2241 ret = wlan_hdd_validate_context(pHddCtx);
2242 if (0 != ret)
2243 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302244 return ret;
2245 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002246
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302247 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2248 if (NULL == pWextState)
2249 {
2250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2251 "%s: pWextState is NULL",__func__);
2252 return -EINVAL;
2253 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002254
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302255 if (!wrqu->data.length) {
2256 hdd_clearRoamProfileIe(pAdapter);
2257 EXIT();
2258 return 0;
2259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302261 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2262 wrqu->data.length);
2263 if (NULL == base_genie)
2264 {
2265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2266 "mem_alloc_copy_from_user_helper fail");
2267 return -ENOMEM;
2268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302270 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302272 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302274 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2275
2276 /* clear any previous genIE before this call */
2277 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2278
2279 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 {
2281 v_U16_t eLen = 0;
2282 v_U8_t elementId;
2283 elementId = *genie++;
2284 eLen = *genie++;
2285 remLen -= 2;
2286
Arif Hussain6d2a3322013-11-17 19:50:10 -08002287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 __func__, elementId, eLen);
2289
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302290 if (remLen < eLen) {
2291 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2292 remLen, eLen);
2293 ret = -EINVAL;
2294 goto exit;
2295 }
2296
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 switch ( elementId )
2298 {
2299 case IE_EID_VENDOR:
2300 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002301 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302302 ret = -EINVAL;
2303 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002305
2306 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2307 {
2308 v_U16_t curGenIELen = pWextState->genIE.length;
2309 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2310 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2311
2312 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2313 {
2314 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002315 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302317 ret = -EINVAL;
2318 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 }
2320 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2321 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2322 pWextState->genIE.length += eLen + 2;
2323 }
2324 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2325 {
2326 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302327 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2328 {
2329 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2330 "Need bigger buffer space");
2331 ret = -EINVAL;
2332 VOS_ASSERT(0);
2333 goto exit;
2334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2336 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2337 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2338 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2339 }
2340 else /* any vendorId except WPA IE should be accumulated to genIE */
2341 {
2342 v_U16_t curGenIELen = pWextState->genIE.length;
2343 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2344 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2345
2346 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2347 {
2348 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002349 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302351 ret = -ENOMEM;
2352 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 }
2354 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2355 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2356 pWextState->genIE.length += eLen + 2;
2357 }
2358 break;
2359 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002360 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302361 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2362 {
2363 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2364 "Need bigger buffer space");
2365 ret = -EINVAL;
2366 VOS_ASSERT(0);
2367 goto exit;
2368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2370 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2371 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2372 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2373 break;
2374
2375 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002376 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302377 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302380
2381 /* Move genie only if next element is present */
2382 if (remLen >= 2)
2383 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302385
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302386exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002388 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302389 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002390}
2391
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302392static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 struct iw_request_info *info,
2394 union iwreq_data *wrqu,
2395 char *extra)
2396{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302397 int ret;
2398
2399 vos_ssr_protect(__func__);
2400 ret = __iw_set_genie(dev, info, wrqu, extra);
2401 vos_ssr_unprotect(__func__);
2402
2403 return ret;
2404}
2405
2406static int __iw_get_genie(struct net_device *dev,
2407 struct iw_request_info *info,
2408 union iwreq_data *wrqu,
2409 char *extra)
2410{
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302412 hdd_context_t *pHddCtx;
2413 hdd_adapter_t *pAdapter;
2414 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 eHalStatus status;
2416 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2417 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2418
2419 ENTER();
2420
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302421 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2422 if (NULL == pAdapter)
2423 {
2424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2425 "%s: Adapter is NULL",__func__);
2426 return -EINVAL;
2427 }
2428 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2429 status = wlan_hdd_validate_context(pHddCtx);
2430 if (0 != status)
2431 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302432 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 }
2434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302436 if (NULL == pWextState)
2437 {
2438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2439 "%s: pWextState is NULL",__func__);
2440 return -EINVAL;
2441 }
2442
2443 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2444 if (NULL == pHddStaCtx)
2445 {
2446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2447 "%s: STA Context is NULL",__func__);
2448 return -EINVAL;
2449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
2451 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2452 {
2453 return -ENXIO;
2454 }
2455
2456 // Return something ONLY if we are associated with an RSN or WPA network
2457 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2458 pWextState->roamProfile.negotiatedAuthType))
2459 {
2460 return -ENXIO;
2461 }
2462
2463 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2464 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2465 pAdapter->sessionId,
2466 &length,
2467 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302468 if (eHAL_STATUS_SUCCESS != status) {
2469 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002470 return -EFAULT;
2471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002472
Manjeet Singh715d47e2016-08-02 19:08:02 +05302473 wrqu->data.length = length;
2474 if (length > DOT11F_IE_RSN_MAX_LEN) {
2475 hddLog(LOGE,
2476 FL("invalid buffer length length:%d"), length);
2477 return -E2BIG;
2478 }
2479
2480 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2481
2482 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002483
2484 EXIT();
2485
2486 return 0;
2487}
2488
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302489static int iw_get_genie(struct net_device *dev,
2490 struct iw_request_info *info,
2491 union iwreq_data *wrqu,
2492 char *extra)
2493{
2494 int ret;
2495
2496 vos_ssr_protect(__func__);
2497 ret = __iw_get_genie(dev, info, wrqu, extra);
2498 vos_ssr_unprotect(__func__);
2499
2500 return ret;
2501}
2502
2503
2504static int __iw_get_encode(struct net_device *dev,
2505 struct iw_request_info *info,
2506 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002507{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302508 hdd_adapter_t *pAdapter;
2509 hdd_context_t *pHddCtx;
2510 hdd_wext_state_t *pWextState;
2511 tCsrRoamProfile *pRoamProfile;
2512 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002514
2515 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302516 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2517 if (NULL == pAdapter)
2518 {
2519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2520 "%s: Adapter is NULL",__func__);
2521 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 }
2523
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2525 ret = wlan_hdd_validate_context(pHddCtx);
2526 if (0 != ret)
2527 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302528 return ret;
2529 }
2530 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2531 if (NULL == pWextState)
2532 {
2533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2534 "%s: pWextState is NULL",__func__);
2535 return -EINVAL;
2536 }
2537
2538 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 keyId = pRoamProfile->Keys.defaultIndex;
2540
2541 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2542 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002543 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 return -EINVAL;
2545 }
2546
2547 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2548 {
2549 dwrq->flags |= IW_ENCODE_ENABLED;
2550 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2551 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2552
2553 dwrq->flags |= (keyId + 1);
2554
2555 }
2556 else
2557 {
2558 dwrq->flags |= IW_ENCODE_DISABLED;
2559 }
2560
2561 for(i=0; i < MAX_WEP_KEYS; i++)
2562 {
2563 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2564 {
2565 continue;
2566 }
2567 else
2568 {
2569 break;
2570 }
2571 }
2572
2573 if(MAX_WEP_KEYS == i)
2574 {
2575 dwrq->flags |= IW_ENCODE_NOKEY;
2576 }
2577
2578 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2579
2580 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2581 {
2582 dwrq->flags |= IW_ENCODE_OPEN;
2583 }
2584 else
2585 {
2586 dwrq->flags |= IW_ENCODE_RESTRICTED;
2587 }
2588 EXIT();
2589 return 0;
2590}
2591
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302592static int iw_get_encode(struct net_device *dev,
2593 struct iw_request_info *info,
2594 struct iw_point *dwrq, char *extra)
2595{
2596 int ret;
2597
2598 vos_ssr_protect(__func__);
2599 ret = __iw_get_encode(dev, info, dwrq, extra);
2600 vos_ssr_unprotect(__func__);
2601
2602 return ret;
2603}
2604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2606#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2607
2608
2609/*
2610 * This function sends a single 'key' to LIM at all time.
2611 */
2612
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302613static int __iw_get_rts_threshold(struct net_device *dev,
2614 struct iw_request_info *info,
2615 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002616{
2617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2618 v_U32_t status = 0;
2619
2620 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2621
2622 return status;
2623}
2624
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302625static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 struct iw_request_info *info,
2627 union iwreq_data *wrqu, char *extra)
2628{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302629 int ret;
2630
2631 vos_ssr_protect(__func__);
2632 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2633 vos_ssr_unprotect(__func__);
2634
2635 return ret;
2636}
2637
2638static int __iw_set_rts_threshold(struct net_device *dev,
2639 struct iw_request_info *info,
2640 union iwreq_data *wrqu, char *extra)
2641{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302642 hdd_adapter_t *pAdapter;
2643 hdd_context_t *pHddCtx;
2644 tHalHandle hHal;
2645 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002646
2647 ENTER();
2648
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302649 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2650 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002651 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2653 "%s: Adapter is NULL",__func__);
2654 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002655 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302656
2657 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2658 ret = wlan_hdd_validate_context(pHddCtx);
2659 if (0 != ret)
2660 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302661 return ret;
2662 }
2663
2664 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2665 if (NULL == hHal)
2666 {
2667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2668 "%s: Hal Context is NULL",__func__);
2669 return -EINVAL;
2670 }
2671
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2673 {
2674 return -EINVAL;
2675 }
2676
2677 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2678 {
c_hpothub8245442013-11-20 23:41:09 +05302679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2680 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 return -EIO;
2682 }
2683
2684 EXIT();
2685
2686 return 0;
2687}
2688
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302689static int iw_set_rts_threshold(struct net_device *dev,
2690 struct iw_request_info *info,
2691 union iwreq_data *wrqu, char *extra)
2692{
2693 int ret;
2694
2695 vos_ssr_protect(__func__);
2696 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2697 vos_ssr_unprotect(__func__);
2698
2699 return ret;
2700}
2701
2702static int __iw_get_frag_threshold(struct net_device *dev,
2703 struct iw_request_info *info,
2704 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002705{
2706 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2707 v_U32_t status = 0;
2708
2709 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2710
2711 return status;
2712}
2713
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302714static int iw_get_frag_threshold(struct net_device *dev,
2715 struct iw_request_info *info,
2716 union iwreq_data *wrqu, char *extra)
2717{
2718 int ret;
2719
2720 vos_ssr_protect(__func__);
2721 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2722 vos_ssr_unprotect(__func__);
2723
2724 return ret;
2725}
2726
2727static int __iw_set_frag_threshold(struct net_device *dev,
2728 struct iw_request_info *info,
2729 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002730{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302731 hdd_adapter_t *pAdapter;
2732 hdd_context_t *pHddCtx;
2733 tHalHandle hHal;
2734 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002735
2736 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302737 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2738 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002739 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2741 "%s: Adapter is NULL",__func__);
2742 return -EINVAL;
2743 }
2744
2745 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2746 ret = wlan_hdd_validate_context(pHddCtx);
2747 if (0 != ret)
2748 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302749 return ret;
2750 }
2751
2752 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2753 if (NULL == hHal)
2754 {
2755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2756 "%s: Hal Context is NULL",__func__);
2757 return -EINVAL;
2758 }
2759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2761 {
2762 return -EINVAL;
2763 }
2764
2765 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2766 {
c_hpothub8245442013-11-20 23:41:09 +05302767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2768 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 return -EIO;
2770 }
2771
2772 EXIT();
2773
2774 return 0;
2775}
2776
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302777static int iw_set_frag_threshold(struct net_device *dev,
2778 struct iw_request_info *info,
2779 union iwreq_data *wrqu, char *extra)
2780{
2781 int ret;
2782
2783 vos_ssr_protect(__func__);
2784 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2785 vos_ssr_unprotect(__func__);
2786
2787 return ret;
2788}
2789
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302790static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 struct iw_request_info *info,
2792 union iwreq_data *wrqu, char *extra)
2793{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302794 hdd_adapter_t *pAdapter;
2795 hdd_context_t *pHddCtx;
2796 int ret = 0;
2797
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302799 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2800 if (NULL == pAdapter)
2801 {
2802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2803 "%s: Adapter is NULL",__func__);
2804 return -EINVAL;
2805 }
2806 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2807 ret = wlan_hdd_validate_context(pHddCtx);
2808 if (0 != ret)
2809 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302810 return ret;
2811 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302812
2813 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 return -EOPNOTSUPP;
2815}
2816
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302817static int iw_get_power_mode(struct net_device *dev,
2818 struct iw_request_info *info,
2819 union iwreq_data *wrqu, char *extra)
2820{
2821 int ret;
2822
2823 vos_ssr_protect(__func__);
2824 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2825 vos_ssr_unprotect(__func__);
2826
2827 return ret;
2828}
2829static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 struct iw_request_info *info,
2831 union iwreq_data *wrqu, char *extra)
2832{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302833 hdd_adapter_t *pAdapter;
2834 hdd_context_t *pHddCtx;
2835 int ret = 0;
2836
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302838 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2839 if (NULL == pAdapter)
2840 {
2841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2842 "%s: Adapter is NULL",__func__);
2843 return -EINVAL;
2844 }
2845 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2846 ret = wlan_hdd_validate_context(pHddCtx);
2847 if (0 != ret)
2848 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302849 return ret;
2850 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302851
2852 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 return -EOPNOTSUPP;
2854}
2855
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302856static int iw_set_power_mode(struct net_device *dev,
2857 struct iw_request_info *info,
2858 union iwreq_data *wrqu, char *extra)
2859{
2860 int ret;
2861
2862 vos_ssr_protect(__func__);
2863 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2864 vos_ssr_unprotect(__func__);
2865
2866 return ret;
2867}
2868
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302869static int __iw_get_range(struct net_device *dev,
2870 struct iw_request_info *info,
2871 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002872{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302873 hdd_adapter_t *pAdapter;
2874 tHalHandle hHal;
2875 hdd_context_t *pHddCtx;
2876 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 struct iw_range *range = (struct iw_range *) extra;
2878
2879 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2880
2881 v_U32_t num_channels = sizeof(channels);
2882 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2883 v_U32_t a_len;
2884 v_U32_t b_len;
2885 v_U32_t active_phy_mode = 0;
2886 v_U8_t index = 0, i;
2887
2888 ENTER();
2889
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2891 if (NULL == pAdapter)
2892 {
2893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2894 "%s: pAdapter is NULL", __func__);
2895 return -EINVAL;
2896 }
2897 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2898 ret = wlan_hdd_validate_context(pHddCtx);
2899 if (0 != ret)
2900 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302901 return ret;
2902 }
2903 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2904 if (NULL == hHal)
2905 {
2906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2907 "%s: pAdapter is NULL", __func__);
2908 return -EINVAL;
2909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 wrqu->data.length = sizeof(struct iw_range);
2911 memset(range, 0, sizeof(struct iw_range));
2912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 /*Get the phy mode*/
2914 if (ccmCfgGetInt(hHal,
2915 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2916 {
2917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002918 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002919
2920 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2921 {
2922 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002923 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 if (ccmCfgGetStr(hHal,
2925 WNI_CFG_SUPPORTED_RATES_11A,
2926 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2927 {
2928 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2929 {
2930 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2931 }
2932 for (i = 0; i < a_len; i++)
2933 {
2934 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2935 }
2936 range->num_bitrates = a_len;
2937 }
2938 else
2939 {
2940 return -EIO;
2941 }
2942 }
2943 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2944 {
2945 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002946 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 if (ccmCfgGetStr(hHal,
2948 WNI_CFG_SUPPORTED_RATES_11B,
2949 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2950 {
2951 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2952 {
2953 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2954 }
2955 for (i = 0; i < b_len; i++)
2956 {
2957 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2958 }
2959 range->num_bitrates = b_len;
2960 }
2961 else
2962 {
2963 return -EIO;
2964 }
2965 }
2966 }
2967
2968 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2969 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2970 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2971
2972 range->encoding_size[0] = 5;
2973 range->encoding_size[1] = 13;
2974 range->num_encoding_sizes = 2;
2975 range->max_encoding_tokens = MAX_WEP_KEYS;
2976
2977 // we support through Wireless Extensions 22
2978 range->we_version_compiled = WIRELESS_EXT;
2979 range->we_version_source = 22;
2980
2981 /*Supported Channels and Frequencies*/
2982 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2983 {
c_hpothub8245442013-11-20 23:41:09 +05302984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2985 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 return -EIO;
2987 }
2988 if (num_channels > IW_MAX_FREQUENCIES)
2989 {
2990 num_channels = IW_MAX_FREQUENCIES;
2991 }
2992
2993 range->num_channels = num_channels;
2994 range->num_frequency = num_channels;
2995
2996 for (index=0; index < num_channels; index++)
2997 {
2998 v_U32_t frq_indx = 0;
2999
3000 range->freq[index].i = channels[index];
3001 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3002 {
3003 if(channels[index] == freq_chan_map[frq_indx].chan)
3004 {
3005 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3006 range->freq[index].e = 1;
3007 break;
3008 }
3009 frq_indx++;
3010 }
3011 }
3012
3013 /* Event capability (kernel + driver) */
3014 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3015 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3016 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3017 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3018
3019 /*Encryption capability*/
3020 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3021 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3022
3023 /* Txpower capability */
3024 range->txpower_capa = IW_TXPOW_MWATT;
3025
3026 /*Scanning capability*/
3027 #if WIRELESS_EXT >= 22
3028 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3029 #endif
3030
3031 EXIT();
3032 return 0;
3033}
3034
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303035static int iw_get_range(struct net_device *dev,
3036 struct iw_request_info *info,
3037 union iwreq_data *wrqu, char *extra)
3038{
3039 int ret;
3040
3041 vos_ssr_protect(__func__);
3042 ret = __iw_get_range(dev, info, wrqu, extra);
3043 vos_ssr_unprotect(__func__);
3044
3045 return ret;
3046}
3047
Jeff Johnson295189b2012-06-20 16:38:30 -07003048/* Callback function for tx per hit */
3049void hdd_tx_per_hit_cb (void *pCallbackContext)
3050{
3051 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3052 unsigned char tx_fail[16];
3053 union iwreq_data wrqu;
3054
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303055 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003057 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 return;
3059 }
3060 memset(&wrqu, 0, sizeof(wrqu));
3061 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3062 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3063}
3064
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303065void hdd_get_class_a_statistics_cb(void *stats, void *context)
3066{
3067 struct hdd_request *request;
3068 struct stats_class_a_ctx *priv;
3069
3070 if (ioctl_debug) {
3071 pr_info("%s: stats [%pK] context [%pK]\n",
3072 __func__, stats, context);
3073 }
3074
3075 if (NULL == stats) {
3076 hddLog(VOS_TRACE_LEVEL_ERROR,
3077 "%s: Bad param, stats [%pK]",
3078 __func__, stats);
3079 return;
3080 }
3081
3082 request = hdd_request_get(context);
3083 if (!request) {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3085 return;
3086 }
3087
3088 priv = hdd_request_priv(request);
3089
3090 /* copy over the stats. do so as a struct copy */
3091 priv->class_a_stats = *(tCsrGlobalClassAStatsInfo *)stats;
3092
3093 hdd_request_complete(request);
3094 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003095}
3096
3097VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3098{
3099 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3100 eHalStatus hstatus;
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303101 int ret;
3102 void *cookie;
3103 struct hdd_request *request;
3104 struct stats_class_a_ctx *priv;
3105 static const struct hdd_request_params params = {
3106 .priv_size = sizeof(*priv),
3107 .timeout_ms = WLAN_WAIT_TIME_STATS,
3108 };
3109
Jeff Johnson295189b2012-06-20 16:38:30 -07003110
3111 if (NULL == pAdapter)
3112 {
3113 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3114 return VOS_STATUS_E_FAULT;
3115 }
3116 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3117 {
3118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3119 return VOS_STATUS_SUCCESS;
3120 }
3121
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303122 request = hdd_request_alloc(&params);
3123 if (!request) {
3124 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3125 return VOS_STATUS_E_NOMEM;
3126 }
3127 cookie = hdd_request_cookie(request);
3128
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 /* query only for Class A statistics (which include link speed) */
3130 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3131 eCSR_HDD,
3132 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303133 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 0, // not periodic
3135 FALSE, //non-cached results
3136 pHddStaCtx->conn_info.staId[0],
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303137 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 if (eHAL_STATUS_SUCCESS != hstatus)
3139 {
3140 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003141 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003142 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 /* we'll returned a cached value below */
3144 }
3145 else
3146 {
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303147 /* request was sent -- wait for the response */
3148 ret = hdd_request_wait_for_response(request);
3149 if (ret)
3150 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303152 FL("SME timeout while retrieving Class A statistics"));
3153 }
3154 else
3155 {
3156 priv = hdd_request_priv(request);
3157 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
3158
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 }
3160 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003161
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303162 /*
3163 * either we never sent a request, we sent a request and received a
3164 * response or we sent a request and timed out. Regardless we are
3165 * done with the request.
3166 */
3167 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003168
3169 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 return VOS_STATUS_SUCCESS;
3171}
3172
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303173struct stats_ctx {
3174 tCsrSummaryStatsInfo summary_stats;
3175 tCsrGlobalClassAStatsInfo class_a_stats;
3176};
3177
3178static void hdd_get_station_statistics_cb(void *stats, void *context)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003179{
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303180 tCsrSummaryStatsInfo *summary_stats;
3181 tCsrGlobalClassAStatsInfo *class_a_stats;
3182 struct hdd_request *request;
3183 struct stats_ctx *priv;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003184
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003185
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303186 if (ioctl_debug) {
3187 pr_info("%s: stats [%pK] context [%pK]\n",
3188 __func__, stats, context);
3189 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003190
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303191 if (NULL == stats) {
3192 hddLog(VOS_TRACE_LEVEL_ERROR,
3193 "%s: Bad param, stats [%pK]",
3194 __func__, stats);
3195 return;
3196 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003197
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303198 request = hdd_request_get(context);
3199 if (!request) {
3200 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3201 return;
3202 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003203
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303204 summary_stats = (tCsrSummaryStatsInfo *)stats;
3205 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
Jeff Johnson72a40512013-12-19 10:14:15 -08003206
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303207 priv = hdd_request_priv(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003208
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303209 /* copy over the stats. do so as a struct copy */
3210 priv->summary_stats = *summary_stats;
3211 priv->class_a_stats = *class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003212
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303213 hdd_request_complete(request);
3214 hdd_request_put(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003215}
3216
3217VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3218{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303219 hdd_station_ctx_t *pHddStaCtx;
3220 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003221 eHalStatus hstatus;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303222 tANI_U8 sta_id;
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303223 int ret;
3224 void *cookie;
3225 struct hdd_request *request;
3226 struct stats_ctx *priv;
3227 static const struct hdd_request_params params = {
3228 .priv_size = sizeof(*priv),
3229 .timeout_ms = WLAN_WAIT_TIME_STATS,
3230 };
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003231
3232 if (NULL == pAdapter)
3233 {
3234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3235 return VOS_STATUS_SUCCESS;
3236 }
3237
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303238 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3239 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3240 sta_id = sap_ctx->uBCStaId;
3241 } else {
3242 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3243 sta_id = pHddStaCtx->conn_info.staId[0];
3244 }
3245
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303246 request = hdd_request_alloc(&params);
3247 if (!request) {
3248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3249 return VOS_STATUS_E_NOMEM;
3250 }
3251 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003252
3253 /* query only for Summary & Class A statistics */
3254 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3255 eCSR_HDD,
3256 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303257 SME_GLOBAL_CLASSA_STATS |
3258 SME_PER_PKT_STATS,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303259 hdd_get_station_statistics_cb,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003260 0, // not periodic
3261 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303262 sta_id,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303263 cookie);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003264 if (eHAL_STATUS_SUCCESS != hstatus)
3265 {
3266 hddLog(VOS_TRACE_LEVEL_ERROR,
3267 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003268 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003269 /* we'll return with cached values */
3270 }
3271 else
3272 {
3273 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303274 ret = hdd_request_wait_for_response(request);
3275 if (ret)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003276 {
3277 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303278 FL("SME timeout while retrieving statistics"));
3279 }
3280 else
3281 {
3282 priv = hdd_request_priv(request);
3283 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
3284 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003285 }
3286 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003287
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303288 /*
3289 * either we never sent a request, we sent a request and received a
3290 * response or we sent a request and timed out. Regardless we are
3291 * done with the request.
3292 */
3293 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003294
3295 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003296 return VOS_STATUS_SUCCESS;
3297}
3298
Jeff Johnson295189b2012-06-20 16:38:30 -07003299/*
3300 * Support for the LINKSPEED private command
3301 * Per the WiFi framework the response must be of the form
3302 * "LinkSpeed xx"
3303 */
3304static int iw_get_linkspeed(struct net_device *dev,
3305 struct iw_request_info *info,
3306 union iwreq_data *wrqu, char *extra)
3307{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303308 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303309 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303311 int len = sizeof(v_U32_t) + 1;
3312 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303313 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303314 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303315 int rc, valid = 0;
3316
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303317 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303318 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3319 if (NULL == pAdapter)
3320 {
3321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3322 "%s: Adapter is NULL",__func__);
3323 return -EINVAL;
3324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003325
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303327 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303328 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003329 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303330 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003331 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303332 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3333 if (NULL == pHddStaCtx)
3334 {
3335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3336 "%s: STA Context is NULL",__func__);
3337 return -EINVAL;
3338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3340 {
3341 /* we are not connected so we don't have a classAstats */
3342 link_speed = 0;
3343 }
3344 else
3345 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303346 status = wlan_hdd_get_classAstats(pAdapter);
3347
3348 if (!VOS_IS_STATUS_SUCCESS(status ))
3349 {
3350 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3351 return -EINVAL;
3352 }
3353
3354 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3355 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3356 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3357 &link_speed);
3358
3359 link_speed = link_speed / 10;
3360
3361 if (0 == link_speed)
3362 {
3363 /* The linkspeed returned by HAL is in units of 500kbps.
3364 * converting it to mbps.
3365 * This is required to support legacy firmware which does
3366 * not return link capacity.
3367 */
3368 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3369 }
3370
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 }
3372
3373 wrqu->data.length = len;
3374 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003375 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 if ((rc < 0) || (rc >= len))
3377 {
3378 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303379 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 return -EIO;
3381 }
3382
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303383 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003385 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003386}
3387
Arif Hussain695279c2014-03-24 14:06:07 -07003388/*
3389 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3390 *
3391 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303392static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003393 struct iw_request_info *info,
3394 union iwreq_data *wrqu, char *extra)
3395{
3396 int rc;
3397
3398 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3399
3400 if (rc < 0)
3401 return rc;
3402
3403 /* a value is being successfully returned */
3404 return 0;
3405}
Jeff Johnson295189b2012-06-20 16:38:30 -07003406
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303407static int iw_get_linkspeed_priv(struct net_device *dev,
3408 struct iw_request_info *info,
3409 union iwreq_data *wrqu, char *extra)
3410{
3411 int ret;
3412
3413 vos_ssr_protect(__func__);
3414 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3415 vos_ssr_unprotect(__func__);
3416
3417 return ret;
3418}
3419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303421 * Support for the RSSI & RSSI-APPROX private commands
3422 * Per the WiFi framework the response must be of the form
3423 * "<ssid> rssi <xx>"
3424 * unless we are not associated, in which case the response is
3425 * "OK"
3426 */
3427static int iw_get_rssi(struct net_device *dev,
3428 struct iw_request_info *info,
3429 union iwreq_data *wrqu, char *extra)
3430{
3431 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3432 char *cmd = extra;
3433 int len = wrqu->data.length;
3434 v_S7_t s7Rssi = 0;
3435 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3436 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3437 VOS_STATUS vosStatus;
3438 int rc;
3439
3440 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3441 (0 == ssidlen) || (ssidlen >= len))
3442 {
3443 /* we are not connected or our SSID is too long
3444 so we cannot report an rssi */
3445 rc = scnprintf(cmd, len, "OK");
3446 }
3447 else
3448 {
3449 /* we are connected with a valid SSID
3450 so we can write the SSID into the return buffer
3451 (note that it is not NUL-terminated) */
3452 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3453
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303454 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303455 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3456
3457 if (VOS_STATUS_SUCCESS == vosStatus)
3458 {
3459 /* append the rssi to the ssid in the format required by
3460 the WiFI Framework */
3461 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3462 rc += ssidlen;
3463 }
3464 else
3465 {
3466 rc = -1;
3467 }
3468 }
3469
3470 /* verify that we wrote a valid response */
3471 if ((rc < 0) || (rc >= len))
3472 {
3473 // encoding or length error?
3474 hddLog(VOS_TRACE_LEVEL_ERROR,
3475 "%s: Unable to encode RSSI, got [%s]",
3476 __func__, cmd);
3477 return -EIO;
3478 }
3479
3480 /* a value is being successfully returned */
3481 return rc;
3482}
3483
3484/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 * Support for SoftAP channel range private command
3486 */
3487static int iw_softap_set_channel_range( struct net_device *dev,
3488 int startChannel,
3489 int endChannel,
3490 int band)
3491{
Jeff Johnson43971f52012-07-17 12:26:56 -07003492 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 int ret = 0;
3494 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3495 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003496 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3497
Jeff Johnson295189b2012-06-20 16:38:30 -07003498
3499 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3500 if (VOS_STATUS_SUCCESS != status)
3501 {
3502 ret = -EINVAL;
3503 }
Yathish9f22e662012-12-10 14:21:35 -08003504 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 return ret;
3506}
3507
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303508static uint8 chartohex(char c)
3509{
3510 uint8 val = 0;
3511 if (c >= '0' && c <= '9')
3512 val = c - '0';
3513 else if (c >= 'a' && c <= 'f')
3514 val = c - 'a' + 10;
3515 else if (c >= 'A' && c <= 'F')
3516 val = c - 'A' + 10;
3517 else
3518 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3519
3520 return val;
3521}
3522
3523uint8 getByte(char **buf)
3524{
3525 uint8 byte = 0;
3526 char *temp = *buf;
3527 byte = chartohex(*temp) * 16;
3528 temp++;
3529 byte += chartohex(*temp);
3530 temp++;
3531 *buf = temp;
3532 return byte;
3533}
3534
3535static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3536{
3537 tSir80211Header *macHeader;
3538 int i = 0, j = 0, length = 0;
3539 uint8 byte = 0;
3540 char *temp = pBuffer;
3541 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303542 char *pHeader;
3543 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303544
3545 macHeader = &pkt->macHeader;
3546
3547 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3548
3549 temp++;
3550
3551 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3552 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3553 pkt->encParams.keyParams.key[0].keyId);
3554
3555 for (i = 0; i< 16; i++) {
3556 pkt->encParams.keyParams.key[0].key[i]
3557 = getByte(&temp);
3558 }
3559
3560 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3561 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3562
3563 for (i = 0; i< 6; i++) {
3564 pkt->encParams.pn[i]
3565 = getByte(&temp);
3566 }
3567
3568 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3569 &pkt->encParams.pn[0], 6, 0);
3570
3571 for (i = 0, j= 5; i< 3; i++, j--) {
3572 byte = pkt->encParams.pn[i];
3573 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3574 pkt->encParams.pn[j] = byte;
3575 }
3576
3577 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303578 if (length > sizeof(tSir80211Header))
3579 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303580
Srinivas Dasari2382de62015-01-22 15:00:04 +05303581 pHeader = temp;
3582 vos_mem_zero(&header, sizeof(tSir80211Header));
3583 for (i = 0; i < length; i++) {
3584 *((uint8 *)&header + i) = getByte(&pHeader);
3585 }
3586
3587 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3588 (char *)&header, length, 0);
3589
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303590 byte = getByte(&temp);
3591
3592 macHeader->frameCtrl.protVer = byte & 0x3;
3593 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3594 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3595
3596 byte = getByte(&temp);
3597 macHeader->frameCtrl.toDS = (byte) & 0x1;
3598 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3599 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3600 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3601 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3602 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3603 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3604 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3605
3606 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3607 "macHeader->frameCtrl.type : %x "
3608 "macHeader->frameCtrl.subType : %x "
3609 "macHeader->frameCtrl.toDS : %x "
3610 "macHeader->frameCtrl.fromDS : %x "
3611 "macHeader->frameCtrl.moreFrag : %x "
3612 "macHeader->frameCtrl.retry : %x "
3613 "macHeader->frameCtrl.powerMgmt : %x "
3614 "macHeader->frameCtrl.MoreData : %x "
3615 "macHeader->frameCtrl.wep : %x "
3616 "macHeader->frameCtrl.order : %x "
3617 , macHeader->frameCtrl.protVer
3618 , macHeader->frameCtrl.type
3619 , macHeader->frameCtrl.subType
3620 , macHeader->frameCtrl.toDS
3621 , macHeader->frameCtrl.fromDS
3622 , macHeader->frameCtrl.moreFrag
3623 , macHeader->frameCtrl.retry
3624 , macHeader->frameCtrl.powerMgmt
3625 , macHeader->frameCtrl.moreData
3626 , macHeader->frameCtrl.wep
3627 , macHeader->frameCtrl.order);
3628
3629
3630 macHeader->usDurationId = getByte(&temp);
3631 macHeader->usDurationId += getByte(&temp) << 8;
3632
3633 macHeader->vA1[0] = getByte(&temp);
3634 macHeader->vA1[1] = getByte(&temp);
3635 macHeader->vA1[2] = getByte(&temp);
3636 macHeader->vA1[3] = getByte(&temp);
3637 macHeader->vA1[4] = getByte(&temp);
3638 macHeader->vA1[5] = getByte(&temp);
3639
3640 macHeader->vA2[0] = getByte(&temp);
3641 macHeader->vA2[1] = getByte(&temp);
3642 macHeader->vA2[2] = getByte(&temp);
3643 macHeader->vA2[3] = getByte(&temp);
3644 macHeader->vA2[4] = getByte(&temp);
3645 macHeader->vA2[5] = getByte(&temp);
3646
3647 macHeader->vA3[0] = getByte(&temp);
3648 macHeader->vA3[1] = getByte(&temp);
3649 macHeader->vA3[2] = getByte(&temp);
3650 macHeader->vA3[3] = getByte(&temp);
3651 macHeader->vA3[4] = getByte(&temp);
3652 macHeader->vA3[5] = getByte(&temp);
3653
3654 macHeader->sSeqCtrl = getByte(&temp);
3655 fragNum = macHeader->sSeqCtrl & 0xF;
3656 macHeader->sSeqCtrl >>= 4;
3657
3658 macHeader->sSeqCtrl += getByte(&temp) << 4;
3659
3660 macHeader->sSeqCtrl |= fragNum << 12;
3661
3662 if (length == 30 || length == 32) {
3663 macHeader->optvA4[0] = getByte(&temp);
3664 macHeader->optvA4[1] = getByte(&temp);
3665 macHeader->optvA4[2] = getByte(&temp);
3666 macHeader->optvA4[3] = getByte(&temp);
3667 macHeader->optvA4[4] = getByte(&temp);
3668 macHeader->optvA4[5] = getByte(&temp);
3669 }
3670
3671 if (length == 26 || length == 32) {
3672 macHeader->usQosCtrl = getByte(&temp);
3673 macHeader->usQosCtrl += getByte(&temp) << 8;
3674 }
3675
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303676 //parse payload
3677 length = getByte(&temp);
3678 length += getByte(&temp) << 8;
3679 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3680
Manjeet Singh5830f142016-11-21 18:21:17 +05303681 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
3682 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
3683
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303684 pkt->data.length = length;
3685
3686 for (i = 0; i< length; i++) {
3687 pkt->data.data[i] = getByte(&temp);
3688 }
3689
3690 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3691 &pkt->data.data[0], pkt->data.length, 0);
3692}
3693
3694/**---------------------------------------------------------------------------
3695
3696 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3697 encrypt message request
3698 This is an asynchronous callback function from SME when the encrypted data
3699 is received
3700
3701 \pEncInfoRsp -> Encrypted data info
3702
3703 \return - 0 for success non-zero for failure
3704 --------------------------------------------------------------------------*/
3705static void
3706hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3707{
3708 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3709
3710 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3711
3712 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3713 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3714 pEncryptedDataRsp->encryptedPayload.length);
3715 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3716 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3717 pEncryptedDataRsp->encryptedPayload.data,
3718 pEncryptedDataRsp->encryptedPayload.length, 0);
3719}
3720
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05303721/**
3722 * iw_power_callback_func() - Callback function registered with PMC
3723 * @context: cookie originally registered with PMC
3724 * @status: status code indicated by PMC state machine
3725 *
3726 * Return: None
3727 */
3728static void iw_power_callback_func(void *context, eHalStatus status)
3729{
3730 struct hdd_request *request = hdd_request_get(context);
3731
3732 if (!request) {
3733 hddLog(VOS_TRACE_LEVEL_ERROR,
3734 "%s: Obsolete request", __func__);
3735 return;
3736 }
3737
3738 hdd_request_complete(request);
3739 hdd_request_put(request);
3740}
3741
Jeff Johnson295189b2012-06-20 16:38:30 -07003742VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3743{
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 eHalStatus status;
3745 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303746 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303747 int ret;
3748 void *cookie;
3749 struct hdd_request *request;
3750 static const struct hdd_request_params params = {
3751 .priv_size = 0,
3752 .timeout_ms = WLAN_WAIT_TIME_STATS,
3753 };
Jeff Johnson295189b2012-06-20 16:38:30 -07003754
3755 if (NULL == pAdapter)
3756 {
3757 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3758 return VOS_STATUS_E_FAULT;
3759 }
3760
3761 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3762 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303763 if (pHddCtx->isLogpInProgress) {
3764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3765 "%s:LOGP in Progress. Ignore!!!", __func__);
3766 return VOS_STATUS_E_FAILURE;
3767 }
3768
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303769 request = hdd_request_alloc(&params);
3770 if (!request) {
3771 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3772 return VOS_STATUS_E_NOMEM;
3773 }
3774 cookie = hdd_request_cookie(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003775
Jeff Johnson295189b2012-06-20 16:38:30 -07003776
3777 if (DRIVER_POWER_MODE_ACTIVE == mode)
3778 {
3779 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3780 "Full Power", __func__);
3781 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303782 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 eSME_FULL_PWR_NEEDED_BY_HDD);
3784 // Enter Full power command received from GUI this means we are disconnected
3785 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3786 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3787 if (eHAL_STATUS_PMC_PENDING == status)
3788 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303789 ret = hdd_request_wait_for_response(request);
3790 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 {
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303792 hddLog(VOS_TRACE_LEVEL_ERROR,
3793 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 }
3795 }
3796 }
3797 else if (DRIVER_POWER_MODE_AUTO == mode)
3798 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303799 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3800 * was already in BMPS state and thus either STA or P2P-CLI is in
3801 * associated state and authenticated, so even if STA connState is
3802 * not associated it can be assumed that P2P-CLI is associated and
3803 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3804 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3805 * if all condition are satisfied for entering BMPS.
3806 */
3807 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3808 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303809 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303810 hddLog(LOGE,
3811 FL("Station is associated but, still not Authenticated ignore "
3812 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303813 return VOS_STATUS_E_AGAIN;
3814 }
3815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3817 {
3818 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3819 __func__);
3820 // Enter BMPS command received from GUI this means DHCP is completed
3821 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3822 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3823 FALSE);
3824 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303825 iw_power_callback_func, cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 if (eHAL_STATUS_PMC_PENDING == status)
3827 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003828 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303829 ret = hdd_request_wait_for_response(request);
3830 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003832 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303833 FL("SME timeout while requesting bmps"));
3834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 }
3836 }
3837 else
3838 {
3839 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3840 "enabled in the cfg");
3841 }
3842 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003843
Hanumanth Reddy Pothula731ebf72018-04-06 14:34:49 +05303844 /*
3845 * either we never sent a request, we sent a request and received a
3846 * response or we sent a request and timed out. Regardless we are
3847 * done with the request.
3848 */
3849 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003850
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 return VOS_STATUS_SUCCESS;
3852}
3853
3854VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3855 hdd_adapter_t *pAdapter)
3856{
3857 VOS_STATUS vos_Status;
3858
3859 if ((NULL == pAdapter) || (NULL == pHddCtx))
3860 {
3861 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3862 return VOS_STATUS_E_FAULT;
3863 }
3864
3865 /**Exit from Deep sleep or standby if we get the driver
3866 START cmd from android GUI
3867 */
3868 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3869 {
3870 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3871 "from Stand by",__func__);
3872 vos_Status = hdd_exit_standby(pHddCtx);
3873 }
3874 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3875 {
3876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3877 "from deep sleep",__func__);
3878 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3879 }
3880 else
3881 {
3882 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3883 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3884 vos_Status = VOS_STATUS_SUCCESS;
3885 }
3886
3887 return vos_Status;
3888}
3889
3890VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3891{
3892 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3893
3894 if (NULL == pHddCtx)
3895 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303896 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 return VOS_STATUS_E_FAULT;
3898 }
3899
3900 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3901 {
3902 //Execute standby procedure.
3903 //Executing standby procedure will cause the STA to
3904 //disassociate first and then the chip will be put into standby.
3905 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3906 vos_Status = hdd_enter_standby(pHddCtx);
3907 }
3908 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3909 pHddCtx->cfg_ini->nEnableDriverStop)
3910 {
3911 //Execute deep sleep procedure
3912 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 //Deep sleep not supported
3915 vos_Status = hdd_enter_standby(pHddCtx);
3916 }
3917 else
3918 {
3919 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3920 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3921 vos_Status = VOS_STATUS_SUCCESS;
3922 }
3923
3924 return vos_Status;
3925}
3926
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003927
3928void* wlan_hdd_change_country_code_callback(void *pAdapter)
3929{
3930
3931 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003932 complete(&call_back_pAdapter->change_country_code);
3933
3934 return NULL;
3935}
3936
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303937static int __iw_set_priv(struct net_device *dev,
3938 struct iw_request_info *info,
3939 union iwreq_data *wrqu, char *extra)
3940{
3941 hdd_adapter_t *pAdapter;
3942 char *cmd = NULL;
3943 int cmd_len = wrqu->data.length;
3944 int rc = 0, ret = 0;
3945 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3946
3947 hdd_context_t *pHddCtx;
3948
3949 ENTER();
3950
3951 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3952 if (NULL == pAdapter)
3953 {
3954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3955 "mem_alloc_copy_from_user_helper fail");
3956 return -EINVAL;
3957 }
3958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3959 rc = wlan_hdd_validate_context(pHddCtx);
3960 if (0 != rc)
3961 {
3962 return rc;
3963 }
3964
3965 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3966 wrqu->data.length);
3967 if (NULL == cmd)
3968 {
3969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3970 "mem_alloc_copy_from_user_helper fail");
3971 return -ENOMEM;
3972 }
3973
3974 if (ioctl_debug)
3975 {
3976 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
3977 }
3978
3979 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3980 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
3981
3982 if (strncmp(cmd, "CSCAN", 5) == 0 )
3983 {
3984 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3986 "%s: Error in iw_set_scan!", __func__);
3987 rc = -EINVAL;
3988 }
3989 }
3990 else if( strcasecmp(cmd, "start") == 0 ) {
3991
3992 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
3993 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
3994
3995 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3996 if (vos_status == VOS_STATUS_SUCCESS)
3997 {
3998 union iwreq_data wrqu;
3999 char buf[10];
4000
4001 memset(&wrqu, 0, sizeof(wrqu));
4002 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4003 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4004 }
4005 else
4006 {
4007 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4008 rc = -EIO;
4009 }
4010 goto done;
4011 }
4012 else if( strcasecmp(cmd, "stop") == 0 )
4013 {
4014 union iwreq_data wrqu;
4015 char buf[10];
4016
4017 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4018
4019 wlan_hdd_enter_lowpower(pHddCtx);
4020 memset(&wrqu, 0, sizeof(wrqu));
4021 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4022 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4023 goto done;
4024 }
4025 else if (strcasecmp(cmd, "macaddr") == 0)
4026 {
4027 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4028 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4029 }
4030 else if (strcasecmp(cmd, "scan-active") == 0)
4031 {
4032 hddLog(LOG1,
4033 FL("making default scan to active"));
4034 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4035 ret = snprintf(cmd, cmd_len, "OK");
4036 }
4037 else if (strcasecmp(cmd, "scan-passive") == 0)
4038 {
4039 hddLog(LOG1,
4040 FL("making default scan to passive"));
4041 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4042 ret = snprintf(cmd, cmd_len, "OK");
4043 }
4044 else if( strcasecmp(cmd, "scan-mode") == 0 )
4045 {
4046 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4047 }
4048 else if( strcasecmp(cmd, "linkspeed") == 0 )
4049 {
4050 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4051 }
4052 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4053 {
4054 ret = iw_get_rssi(dev, info, wrqu, cmd);
4055 }
4056 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4057 int mode;
4058 char *ptr;
4059
4060 if (9 < cmd_len)
4061 {
4062 ptr = (char*)(cmd + 9);
4063
4064 }else{
4065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4066 "CMD LENGTH %d is not correct",cmd_len);
4067 kfree(cmd);
4068 return -EINVAL;
4069 }
4070
4071 if (1 != sscanf(ptr,"%d",&mode))
4072 {
4073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4074 "powermode input %s is not correct",ptr);
4075 kfree(cmd);
4076 return -EIO;
4077 }
4078
4079 wlan_hdd_enter_bmps(pAdapter, mode);
4080 /*TODO:Set the power mode*/
4081 }
4082 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4083 v_U32_t pmc_state;
4084 v_U16_t value;
4085
4086 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4087 if(pmc_state == BMPS) {
4088 value = DRIVER_POWER_MODE_AUTO;
4089 }
4090 else {
4091 value = DRIVER_POWER_MODE_ACTIVE;
4092 }
4093 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4094 }
4095 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4096 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4097 /*TODO: set the btcoexmode*/
4098 }
4099 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4100
4101 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4102 /*TODO: Return the btcoex status*/
4103 }
4104 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4105
4106 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4107
4108 /*TODO: Enable Rx data Filter*/
4109 }
4110 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4111
4112 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4113
4114 /*TODO: Disable Rx data Filter*/
4115 }
4116 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4117
4118 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4119 /*TODO: rxfilter-statistics*/
4120 }
4121 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4122
4123 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4124 /*TODO: rxfilter-add*/
4125 }
4126 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4127
4128 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4129 /*TODO: rxfilter-remove*/
4130 }
4131#ifdef FEATURE_WLAN_SCAN_PNO
4132 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4133 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4134 /*TODO: support pnosetup*/
4135 }
4136 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4137 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4138 /*TODO: support pnoforce*/
4139 }
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304140 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4141 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4142 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4143 kfree(cmd);
4144 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4145 }
4146#endif /*FEATURE_WLAN_SCAN_PNO*/
4147 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4148 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4149 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4150 kfree(cmd);
4151 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4152 }
4153 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4154 tSirTxPerTrackingParam tTxPerTrackingParam;
4155 char *ptr;
4156
4157 if (18 < cmd_len)
4158 {
4159 ptr = (char*)(cmd + 18);
4160 }else{
4161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4162 "CMD LENGTH %d is not correct",cmd_len);
4163 kfree(cmd);
4164 return -EINVAL;
4165 }
4166
4167 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4168 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4169 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4170 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4171 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4172 {
4173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4174 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4175 kfree(cmd);
4176 return -EIO;
4177 }
4178
4179 // parameters checking
4180 // period has to be larger than 0
4181 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4182 {
4183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4184 kfree(cmd);
4185 return -EIO;
4186 }
4187
4188 // use default value 5 is the input is not reasonable. in unit of 10%
4189 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4190 {
4191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4192 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4193 }
4194
4195 // default is 5
4196 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4197 {
4198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4199 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4200 }
4201
4202 if (eHAL_STATUS_SUCCESS !=
4203 sme_SetTxPerTracking(pHddCtx->hHal,
4204 hdd_tx_per_hit_cb,
4205 (void*)pAdapter, &tTxPerTrackingParam)) {
4206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4207 rc = -EIO;
4208 }
4209 }
4210 else {
4211 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4212 __func__, cmd);
4213 }
4214done:
4215 /* many of the commands write information back into the command
4216 string using snprintf(). check the return value here in one
4217 place */
4218 if ((ret < 0) || (ret >= cmd_len))
4219 {
4220 /* there was an encoding error or overflow */
4221 rc = -EINVAL;
4222 }
4223 else if (ret > 0)
4224 {
4225 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4226 {
4227 hddLog(VOS_TRACE_LEVEL_ERROR,
4228 "%s: failed to copy data to user buffer", __func__);
4229 kfree(cmd);
4230 return -EFAULT;
4231 }
4232 wrqu->data.length = ret;
4233 }
4234
4235 if (ioctl_debug)
4236 {
4237 pr_info("%s: rsp [%s] len [%d] status %d\n",
4238 __func__, cmd, wrqu->data.length, rc);
4239 }
4240 kfree(cmd);
4241 EXIT();
4242 return rc;
4243}
4244
4245static int iw_set_priv(struct net_device *dev,
4246 struct iw_request_info *info,
4247 union iwreq_data *wrqu, char *extra)
4248{
4249 int ret;
4250 vos_ssr_protect(__func__);
4251 ret = __iw_set_priv(dev, info, wrqu, extra);
4252 vos_ssr_unprotect(__func__);
4253
4254 return ret;
4255}
4256
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304257static int __iw_set_nick(struct net_device *dev,
4258 struct iw_request_info *info,
4259 union iwreq_data *wrqu, char *extra)
4260{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304261 hdd_adapter_t *pAdapter;
4262 hdd_context_t *pHddCtx;
4263 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304264
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304265 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304266
4267 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4268 if (NULL == pAdapter)
4269 {
4270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4271 "%s: Adapter is NULL",__func__);
4272 return -EINVAL;
4273 }
4274
4275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4276 ret = wlan_hdd_validate_context(pHddCtx);
4277 if (0 != ret)
4278 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304279 return ret;
4280 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304281 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304282 return 0;
4283}
4284
Jeff Johnson295189b2012-06-20 16:38:30 -07004285static int iw_set_nick(struct net_device *dev,
4286 struct iw_request_info *info,
4287 union iwreq_data *wrqu, char *extra)
4288{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304289 int ret;
4290
4291 vos_ssr_protect(__func__);
4292 ret = __iw_set_nick(dev, info, wrqu, extra);
4293 vos_ssr_unprotect(__func__);
4294
4295 return ret;
4296}
4297
4298static int __iw_get_nick(struct net_device *dev,
4299 struct iw_request_info *info,
4300 union iwreq_data *wrqu, char *extra)
4301{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304302 hdd_adapter_t *pAdapter;
4303 hdd_context_t *pHddCtx;
4304 int ret = 0;
4305
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304307
4308 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4309 if (NULL == pAdapter)
4310 {
4311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4312 "%s: Adapter is NULL",__func__);
4313 return -EINVAL;
4314 }
4315
4316 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4317 ret = wlan_hdd_validate_context(pHddCtx);
4318 if (0 != ret)
4319 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304320 return ret;
4321 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304322 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 return 0;
4324}
4325
4326static int iw_get_nick(struct net_device *dev,
4327 struct iw_request_info *info,
4328 union iwreq_data *wrqu, char *extra)
4329{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304330 int ret;
4331
4332 vos_ssr_protect(__func__);
4333 ret = __iw_get_nick(dev, info, wrqu, extra);
4334 vos_ssr_unprotect(__func__);
4335
4336 return ret;
4337}
4338
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304339/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304340static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4341{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304342 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4343 hdd_context_t *pHddCtx;
4344 hdd_station_ctx_t *pHddStaCtx;
4345 v_S7_t snr = 0, rssi = 0;
4346 eHalStatus status = eHAL_STATUS_SUCCESS;
4347
4348 ENTER();
4349
4350 if (NULL == pAdapter)
4351 {
4352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4353 "%s: Adapter is NULL",__func__);
4354 return NULL;
4355 }
4356
4357 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4358 status = wlan_hdd_validate_context(pHddCtx);
4359 if (0 != status)
4360 {
4361 return NULL;
4362 }
4363
4364 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4365 if (NULL == pHddStaCtx)
4366 {
4367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4368 "%s: STA Context is NULL",__func__);
4369 return NULL;
4370 }
4371
4372 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4373 {
4374 wlan_hdd_get_station_stats(pAdapter);
4375 wlan_hdd_get_snr(pAdapter, &snr);
4376 wlan_hdd_get_rssi(pAdapter, &rssi);
4377
4378 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4379 pAdapter->iwStats.status = 0;
4380 pAdapter->iwStats.qual.qual = snr;
4381 pAdapter->iwStats.qual.level = rssi;
4382 pAdapter->iwStats.qual.noise = rssi - snr;
4383 pAdapter->iwStats.discard.code = 0;
4384 pAdapter->iwStats.discard.retries= 0;
4385 pAdapter->iwStats.miss.beacon = 0;
4386 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4387 }
4388 else
4389 {
4390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4391 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4392 return NULL;
4393 }
4394
4395 EXIT();
4396 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004397}
4398
4399static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4400{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304401
4402 struct iw_statistics *stats;
4403
4404 vos_ssr_protect(__func__);
4405 stats = __get_wireless_stats(dev);
4406 vos_ssr_unprotect(__func__);
4407
4408 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004409}
4410
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304411static int __iw_set_encode(struct net_device *dev,
4412 struct iw_request_info *info,
4413 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004414
4415{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304416 hdd_adapter_t *pAdapter;
4417 hdd_station_ctx_t *pHddStaCtx;
4418 hdd_wext_state_t *pWextState;
4419 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 struct iw_point *encoderq = &(wrqu->encoding);
4421 v_U32_t keyId;
4422 v_U8_t key_length;
4423 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4424 v_BOOL_t fKeyPresent = 0;
4425 int i;
4426 eHalStatus status = eHAL_STATUS_SUCCESS;
4427
4428
4429 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304430 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4431 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4434 "%s: Adapter is NULL",__func__);
4435 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 }
4437
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304438 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4439 status = wlan_hdd_validate_context(pHddCtx);
4440 if (0 != status)
4441 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304442 return status;
4443 }
4444 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4445 if (NULL == pWextState)
4446 {
4447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4448 "%s: pWextState is NULL ",__func__);
4449 return -EINVAL;
4450 }
4451 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4452 if (NULL == pHddStaCtx)
4453 {
4454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4455 "%s: STA Context is NULL",__func__);
4456 return -EINVAL;
4457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004458
4459 keyId = encoderq->flags & IW_ENCODE_INDEX;
4460
4461 if(keyId)
4462 {
4463 if(keyId > MAX_WEP_KEYS)
4464 {
4465 return -EINVAL;
4466 }
4467
4468 fKeyPresent = 1;
4469 keyId--;
4470 }
4471 else
4472 {
4473 fKeyPresent = 0;
4474 }
4475
4476
4477 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4478 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 if(!fKeyPresent) {
4481
4482 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4483
4484 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4485 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4486 }
4487 }
4488 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4489 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4490 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4491 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4492
4493 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4494 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4495
4496 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4497 {
4498 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4499 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004500 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304501 {
4502 long ret;
4503 ret = wait_for_completion_interruptible_timeout(
4504 &pAdapter->disconnect_comp_var,
4505 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4506 if (ret <= 0)
4507 hddLog(VOS_TRACE_LEVEL_ERROR,
4508 FL("failed wait on disconnect_comp_var %ld"), ret);
4509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 }
4511
4512 return status;
4513
4514 }
4515
4516 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4517 {
4518 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4519
4520 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4521
4522 }
4523
4524
4525 if(wrqu->data.length > 0)
4526 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004527 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004528
4529 key_length = wrqu->data.length;
4530
4531 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4532
4533 if(5 == key_length)
4534 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004535 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004536
4537 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4538 {
4539 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4540 }
4541 else
4542 {
4543 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4544 }
4545 }
4546 else if(13 == key_length)
4547 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004548 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004549
4550 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4551 {
4552 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4553 }
4554 else
4555 {
4556 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4557 }
4558 }
4559 else
4560 {
4561 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004562 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 return -EINVAL;
4564 }
4565
4566 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4567 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4568 pWextState->roamProfile.EncryptionType.numEntries = 1;
4569 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4570 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4571 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4572
4573 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4574 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4575 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4576 {
4577
4578 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4579
4580 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4581 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4582
4583 return status;
4584 }
4585 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304586 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 return 0;
4588}
4589
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304590static int iw_set_encode(struct net_device *dev,
4591 struct iw_request_info *info,
4592 union iwreq_data *wrqu,char *extra)
4593{
4594 int ret;
4595
4596 vos_ssr_protect(__func__);
4597 ret = __iw_set_encode(dev, info, wrqu, extra);
4598 vos_ssr_unprotect(__func__);
4599
4600 return ret;
4601}
4602
4603static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 struct iw_request_info *info,
4605 struct iw_point *dwrq,
4606 char *extra)
4607{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304608 hdd_adapter_t *pAdapter;
4609 hdd_wext_state_t *pWextState;
4610 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 int keyId;
4612 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4613 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304614 int i, ret = 0;
4615 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004616
4617 ENTER();
4618
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304619 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4620 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004621 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4623 "%s: Adapter is NULL",__func__);
4624 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004625 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4627 ret = wlan_hdd_validate_context(pHddCtx);
4628 if (0 != ret)
4629 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304630 return ret;
4631 }
4632 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4633 if (NULL == pWextState)
4634 {
4635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4636 "%s: pWextState is NULL",__func__);
4637 return -EINVAL;
4638 }
4639 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004640
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 keyId = pRoamProfile->Keys.defaultIndex;
4642
4643 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4644 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004645 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 return -EINVAL;
4647 }
4648
4649 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4650 {
4651 dwrq->flags |= IW_ENCODE_ENABLED;
4652 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304653 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4654 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 }
4656 else
4657 {
4658 dwrq->flags |= IW_ENCODE_DISABLED;
4659 }
4660
4661 for(i=0; i < MAX_WEP_KEYS; i++)
4662 {
4663 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4664 {
4665 continue;
4666 }
4667 else
4668 {
4669 break;
4670 }
4671 }
4672
4673 if(MAX_WEP_KEYS == i)
4674 {
4675 dwrq->flags |= IW_ENCODE_NOKEY;
4676 }
4677 else
4678 {
4679 dwrq->flags |= IW_ENCODE_ENABLED;
4680 }
4681
4682 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4683
4684 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4685 {
4686 dwrq->flags |= IW_ENCODE_DISABLED;
4687 }
4688
4689 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4690
4691 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4692 {
4693 dwrq->flags |= IW_ENCODE_OPEN;
4694 }
4695 else
4696 {
4697 dwrq->flags |= IW_ENCODE_RESTRICTED;
4698 }
4699 EXIT();
4700 return 0;
4701
4702}
4703
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304704static int iw_get_encodeext(struct net_device *dev,
4705 struct iw_request_info *info,
4706 struct iw_point *dwrq,
4707 char *extra)
4708{
4709 int ret;
4710 vos_ssr_protect(__func__);
4711 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4712 vos_ssr_unprotect(__func__);
4713
4714 return ret;
4715}
4716
4717static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 struct iw_request_info *info,
4719 union iwreq_data *wrqu, char *extra)
4720{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304721 hdd_adapter_t *pAdapter;
4722 hdd_station_ctx_t *pHddStaCtx;
4723 hdd_wext_state_t *pWextState;
4724 hdd_context_t *pHddCtx;
4725 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004726
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304727 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 v_U32_t status = 0;
4729
4730 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4731
4732 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4733
4734 int key_index;
4735 struct iw_point *encoding = &wrqu->encoding;
4736 tCsrRoamSetKey setKey;
4737 v_U32_t roamId= 0xFF;
4738 VOS_STATUS vos_status;
4739
4740 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4742 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4745 "%s: Adapter is NULL",__func__);
4746 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4749 status = wlan_hdd_validate_context(pHddCtx);
4750 if (0 != status)
4751 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304752 return status;
4753 }
4754 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4755 if (NULL == pHddStaCtx)
4756 {
4757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4758 "%s: STA Context is NULL",__func__);
4759 return -EINVAL;
4760 }
4761 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4762 if (NULL == pWextState)
4763 {
4764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4765 "%s: pWextState is NULL",__func__);
4766 return -EINVAL;
4767 }
4768 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 key_index = encoding->flags & IW_ENCODE_INDEX;
4770
4771 if(key_index > 0) {
4772
4773 /*Convert from 1-based to 0-based keying*/
4774 key_index--;
4775 }
4776 if(!ext->key_len) {
4777
4778 /*Set the encrytion type to NONE*/
4779 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4780 return status;
4781 }
4782
4783 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4784 (IW_ENCODE_ALG_WEP == ext->alg))
4785 {
4786 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4787
Agarwal Ashish971c2882013-10-30 20:11:12 +05304788 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4789 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 return -EINVAL;
4791 }
4792 else {
4793 /*Static wep, update the roam profile with the keys */
4794 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4795 key_index < CSR_MAX_NUM_KEY) {
4796 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4797 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4798
4799 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4800 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4801
4802 }
4803 }
4804 return status;
4805 }
4806
4807 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4808
4809 setKey.keyId = key_index;
4810 setKey.keyLength = ext->key_len;
4811
4812 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4813 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4814 }
4815
4816 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4817 /*Key direction for group is RX only*/
4818 setKey.keyDirection = eSIR_RX_ONLY;
4819 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4820 }
4821 else {
4822
4823 setKey.keyDirection = eSIR_TX_RX;
4824 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4825 }
4826
4827 /*For supplicant pae role is zero*/
4828 setKey.paeRole = 0;
4829
4830 switch(ext->alg)
4831 {
4832 case IW_ENCODE_ALG_NONE:
4833 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4834 break;
4835
4836 case IW_ENCODE_ALG_WEP:
4837 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4838 break;
4839
4840 case IW_ENCODE_ALG_TKIP:
4841 {
4842 v_U8_t *pKey = &setKey.Key[0];
4843
4844 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4845
4846 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4847
4848 /*Supplicant sends the 32bytes key in this order
4849
4850 |--------------|----------|----------|
4851 | Tk1 |TX-MIC | RX Mic |
4852 |--------------|----------|----------|
4853 <---16bytes---><--8bytes--><--8bytes-->
4854
4855 */
4856 /*Sme expects the 32 bytes key to be in the below order
4857
4858 |--------------|----------|----------|
4859 | Tk1 |RX-MIC | TX Mic |
4860 |--------------|----------|----------|
4861 <---16bytes---><--8bytes--><--8bytes-->
4862 */
4863 /* Copy the Temporal Key 1 (TK1) */
4864 vos_mem_copy(pKey,ext->key,16);
4865
4866 /*Copy the rx mic first*/
4867 vos_mem_copy(&pKey[16],&ext->key[24],8);
4868
4869 /*Copy the tx mic */
4870 vos_mem_copy(&pKey[24],&ext->key[16],8);
4871
4872 }
4873 break;
4874
4875 case IW_ENCODE_ALG_CCMP:
4876 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4877 break;
4878
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004879#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004880#define IW_ENCODE_ALG_KRK 6
4881 case IW_ENCODE_ALG_KRK:
4882 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4883 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004884#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004885
4886 default:
4887 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4888 break;
4889 }
4890
4891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004892 ("%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 -07004893
4894#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304895 /* The supplicant may attempt to set the PTK once pre-authentication
4896 is done. Save the key in the UMAC and include it in the ADD
4897 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304899 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304901 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4902 "%s: Update PreAuth Key success", __func__);
4903 return 0;
4904 }
4905 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4906 {
4907 hddLog(VOS_TRACE_LEVEL_ERROR,
4908 "%s: Update PreAuth Key failed", __func__);
4909 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 }
4911#endif /* WLAN_FEATURE_VOWIFI_11R */
4912
4913 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4914
4915 vos_status = wlan_hdd_check_ula_done(pAdapter);
4916 if ( vos_status != VOS_STATUS_SUCCESS )
4917 {
4918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4919 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4920 __LINE__, vos_status );
4921
4922 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4923 }
4924
4925 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4926
4927 if ( halStatus != eHAL_STATUS_SUCCESS )
4928 {
4929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4930 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4931 __LINE__, halStatus );
4932
4933 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4934 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304935 EXIT();
4936 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004937}
4938
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304939static int iw_set_encodeext(struct net_device *dev,
4940 struct iw_request_info *info,
4941 union iwreq_data *wrqu, char *extra)
4942{
4943 int ret;
4944
4945 vos_ssr_protect(__func__);
4946 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4947 vos_ssr_unprotect(__func__);
4948
4949 return ret;
4950}
4951
4952static int __iw_set_retry(struct net_device *dev,
4953 struct iw_request_info *info,
4954 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004955{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304956 hdd_adapter_t *pAdapter;
4957 tHalHandle hHal;
4958 hdd_context_t *pHddCtx;
4959 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004960
4961 ENTER();
4962
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304963 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4964 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004965 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4967 "%s: Adapter is NULL",__func__);
4968 return -EINVAL;
4969 }
4970
4971 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4972 ret = wlan_hdd_validate_context(pHddCtx);
4973 if (0 != ret)
4974 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304975 return ret;
4976 }
4977
4978 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4979 if (NULL == hHal)
4980 {
4981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4982 "%s: Hal Context is NULL",__func__);
4983 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004984 }
4985
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4987 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4988
Arif Hussain6d2a3322013-11-17 19:50:10 -08004989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004990
4991 return -EINVAL;
4992 }
4993
4994 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4995
4996 if((wrqu->retry.flags & IW_RETRY_LONG))
4997 {
4998 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4999 {
c_hpothub8245442013-11-20 23:41:09 +05305000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5001 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 return -EIO;
5003 }
5004 }
5005 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5006 {
5007 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5008 {
c_hpothub8245442013-11-20 23:41:09 +05305009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5010 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 return -EIO;
5012 }
5013 }
5014 }
5015 else
5016 {
5017 return -EOPNOTSUPP;
5018 }
5019
Arif Hussain6d2a3322013-11-17 19:50:10 -08005020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005021
5022 EXIT();
5023
5024 return 0;
5025
5026}
5027
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305028static int iw_set_retry(struct net_device *dev,
5029 struct iw_request_info *info,
5030 union iwreq_data *wrqu, char *extra)
5031{
5032 int ret;
5033
5034 vos_ssr_protect(__func__);
5035 ret = __iw_set_retry(dev, info, wrqu, extra);
5036 vos_ssr_unprotect(__func__);
5037
5038 return ret;
5039}
5040
5041static int __iw_get_retry(struct net_device *dev,
5042 struct iw_request_info *info,
5043 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005044{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305045 hdd_adapter_t *pAdapter;
5046 hdd_context_t *pHddCtx;
5047 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305049 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005050
5051 ENTER();
5052
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305053 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5054 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005055 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5057 "%s: Adapter is NULL",__func__);
5058 return -EINVAL;
5059 }
5060
5061 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5062 ret = wlan_hdd_validate_context(pHddCtx);
5063 if (0 != ret)
5064 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305065 return ret;
5066 }
5067
5068 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5069 if (NULL == hHal)
5070 {
5071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5072 "%s: Hal Context is NULL",__func__);
5073 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005074 }
5075
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 if((wrqu->retry.flags & IW_RETRY_LONG))
5077 {
5078 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5079
5080 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5081 {
c_hpothub8245442013-11-20 23:41:09 +05305082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5083 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 return -EIO;
5085 }
5086
5087 wrqu->retry.value = retry;
5088 }
5089 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5090 {
5091 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5092
5093 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5094 {
c_hpothub8245442013-11-20 23:41:09 +05305095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5096 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 return -EIO;
5098 }
5099
5100 wrqu->retry.value = retry;
5101 }
5102 else {
5103 return -EOPNOTSUPP;
5104 }
5105
Arif Hussain6d2a3322013-11-17 19:50:10 -08005106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005107
5108 EXIT();
5109
5110 return 0;
5111}
5112
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305113static int iw_get_retry(struct net_device *dev,
5114 struct iw_request_info *info,
5115 union iwreq_data *wrqu, char *extra)
5116{
5117 int ret;
5118
5119 vos_ssr_protect(__func__);
5120 ret = __iw_get_retry(dev, info, wrqu, extra);
5121 vos_ssr_unprotect(__func__);
5122
5123 return ret;
5124}
5125
5126static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 struct iw_request_info *info,
5128 union iwreq_data *wrqu,
5129 char *extra)
5130{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305131 hdd_adapter_t *pAdapter;
5132 hdd_context_t *pHddCtx;
5133 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5135 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305136 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005137
5138 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305139 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5140 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5143 "%s:Adapter is NULL",__func__);
5144 return -EINVAL;
5145 }
5146 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5147 ret = wlan_hdd_validate_context(pHddCtx);
5148 if (0 != ret)
5149 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305150 return ret;
5151 }
5152 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5153 if (NULL == pHddStaCtx)
5154 {
5155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5156 "%s:STA context is NULL",__func__);
5157 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 }
5159
5160 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5161 switch (mlme->cmd) {
5162 case IW_MLME_DISASSOC:
5163 case IW_MLME_DEAUTH:
5164
5165 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5166 {
5167 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5168
5169 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5170 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5171
5172 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5173 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5174
Jeff Johnson43971f52012-07-17 12:26:56 -07005175 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305176 {
5177 long ret;
5178 ret = wait_for_completion_interruptible_timeout(
5179 &pAdapter->disconnect_comp_var,
5180 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5181 if (ret <= 0)
5182 hddLog(VOS_TRACE_LEVEL_ERROR,
5183 FL("failed wait on disconnect_comp_var %ld"), ret);
5184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005186 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005187 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005188
5189 /* Resetting authKeyMgmt */
5190 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5191
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 netif_tx_disable(dev);
5194 netif_carrier_off(dev);
5195
5196 }
5197 else
5198 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005199 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 -07005200 }
5201 break;
5202 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005203 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 return -EINVAL;
5205 }//end of switch
5206
5207 EXIT();
5208
5209 return status;
5210
5211}
5212
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305213static int iw_set_mlme(struct net_device *dev,
5214 struct iw_request_info *info,
5215 union iwreq_data *wrqu,
5216 char *extra)
5217{
5218 int ret;
5219
5220 vos_ssr_protect(__func__);
5221 ret = __iw_set_mlme(dev, info, wrqu, extra);
5222 vos_ssr_unprotect(__func__);
5223
5224 return ret;
5225}
5226
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305227int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305228{
5229 sHwCalValues hwCalValues;
5230 uint16 hwCalTxPower;
5231 uint8 txPwr = TX_PWR_DEF;
5232
5233 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5234
5235 if (TRUE == set_value) {
5236 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5237 NULL, sizeof(sHwCalValues) )
5238 != VOS_STATUS_SUCCESS) {
5239 return -EINVAL;
5240 }
5241 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5242
5243 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5244 hwCalTxPower, hwCalValues.calData.hwParam7);
5245
5246 txPwr = (int8)(hwCalTxPower & 0x00FF);
5247 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305248 if (txPwr == 0)
5249 txPwr = TX_PWR_DEF;
5250 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305251 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305252 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305253 txPwr = TX_PWR_MAX;
5254
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305255 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305256 eHAL_STATUS_SUCCESS) {
5257 hddLog(VOS_TRACE_LEVEL_ERROR,
5258 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5259 return -EIO;
5260 }
5261
5262 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5263 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305264 if (txPwr == 0)
5265 txPwr = TX_PWR_DEF;
5266 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305267 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305268 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305269 txPwr = TX_PWR_MAX;
5270
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305271 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305272 eHAL_STATUS_SUCCESS) {
5273 hddLog(VOS_TRACE_LEVEL_ERROR,
5274 FL("setting tx power failed for 5GHz band %d"), txPwr);
5275 return -EIO;
5276 }
5277 }
5278 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305279 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305280 eHAL_STATUS_SUCCESS) {
5281 hddLog(VOS_TRACE_LEVEL_ERROR,
5282 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5283 return -EIO;
5284 }
5285
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305286 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305287 eHAL_STATUS_SUCCESS) {
5288 hddLog(VOS_TRACE_LEVEL_ERROR,
5289 FL("setting tx power failed for 5GHz band %d"), txPwr);
5290 return -EIO;
5291 }
5292 }
5293 else {
5294 return -EINVAL;
5295 }
5296
5297 return eHAL_STATUS_SUCCESS;
5298}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305299
5300static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5301{
5302 int ret = 0;
5303 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5304 tDelBaParams del_session;
5305
5306 del_session.session_id = adapter->sessionId;
5307 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5308
5309 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5310 {
5311 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5312 value,NULL, eANI_BOOLEAN_FALSE);
5313 if (ret != eHAL_STATUS_SUCCESS)
5314 {
5315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5316 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5317 return -EIO;
5318 }
5319
5320 } else {
5321 hddLog(VOS_TRACE_LEVEL_ERROR,
5322 FL("Invalid command input"));
5323 return -EINVAL;
5324 }
5325 ret = sme_del_sta_ba_session_req(hal, del_session);
5326 if (ret != VOS_STATUS_SUCCESS) {
5327 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5328 return -EINVAL;
5329 }
5330
5331 EXIT();
5332 return ret;
5333}
5334
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305335static int
5336wlan_hdd_sta_mon_op(hdd_context_t *hdd_ctx, uint32_t set_value,
5337 hdd_adapter_t *mon_adapter, hdd_mon_ctx_t *mon_ctx)
5338{
5339 hdd_station_ctx_t *sta_ctx;
5340 VOS_STATUS disable_bmps_status;
5341 hdd_adapter_t *sta_adapter;
5342 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(mon_adapter))->pvosContext;
5343
5344 if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) {
5345 hddLog(LOGE, FL("Monitor Interface is not OPENED"));
5346 return -EINVAL;
5347 }
5348
5349 if (set_value == MON_MODE_STOP) {
5350 if (wlan_hdd_check_monitor_state(hdd_ctx))
5351 return 0;
5352 return -EINVAL;
5353 }
5354
5355 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
5356 if (!sta_adapter) {
5357 hddLog(LOGE, FL("No Station adapter"));
5358 return -EINVAL;
5359 }
5360
5361 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
5362 if (!sta_ctx || !hdd_connIsConnected(sta_ctx)) {
5363 hddLog(LOGE, FL("STA is not connected"));
5364 return -EINVAL;
5365 }
5366
5367 if (hdd_isConnectionInProgress(hdd_ctx, NULL, NULL)) {
5368 hddLog(LOGE, FL("Roaming or set-key is in progress"));
5369 return -EBUSY;
5370 }
5371
5372 hdd_disable_roaming(hdd_ctx);
5373
5374 hddLog(LOG1, FL("Disable BMPS"));
5375 disable_bmps_status = hdd_disable_bmps_imps(hdd_ctx,
5376 WLAN_HDD_INFRA_STATION);
5377 if (disable_bmps_status != VOS_STATUS_SUCCESS) {
5378 hddLog(LOGE, FL("Cannot start monitor mode"));
5379 hdd_restore_roaming(hdd_ctx);
5380 return -EINVAL;
5381 }
5382
5383 mon_ctx->ChannelNo = sta_ctx->conn_info.operationChannel;
5384
5385 /*
5386 * In STA + Mon mode, firmware should not consider ChannelBW
5387 */
5388 mon_ctx->ChannelBW = 0;
5389 mon_ctx->crcCheckEnabled = 0;
5390 wlan_hdd_mon_set_typesubtype(mon_ctx, 100);
5391 mon_ctx->is80211to803ConReq = 0;
5392 WLANTL_SetIsConversionReq(vos_ctx, 0);
5393 mon_adapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
5394
5395 mon_ctx->state = MON_MODE_START;
5396 return 0;
5397}
5398
5399/* set param sub-ioctls */
5400static int __iw_mon_setint_getnone(struct net_device *dev,
5401 struct iw_request_info *info,
5402 union iwreq_data *wrqu, char *extra)
5403{
5404 hdd_adapter_t *adapter;
5405 hdd_context_t *hdd_ctx;
5406 hdd_mon_ctx_t *mon_ctx;
5407 int *value = (int *)extra;
5408 int sub_cmd = value[0];
5409 int set_value = value[1];
5410 int ret = 0; /* success */
5411 tVOS_CONCURRENCY_MODE concurrency_mode;
5412
5413 ENTER();
5414 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5415 if (!adapter || adapter->device_mode != WLAN_HDD_MONITOR)
5416 return -EINVAL;
5417
5418 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5419 ret = wlan_hdd_validate_context(hdd_ctx);
5420 if (ret)
5421 return ret;
5422
5423 concurrency_mode = hdd_ctx->concurrency_mode;
5424 if (concurrency_mode != VOS_STA_MON) {
5425 hddLog(LOGE, "invalid concurrency mode %d", concurrency_mode);
5426 return -EINVAL;
5427 }
5428
5429 switch(sub_cmd) {
5430
5431 case WE_SET_MONITOR_STATE:
5432 {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305433 void *cookie;
5434 struct hdd_request *request;
5435 static const struct hdd_request_params params = {
5436 .priv_size = 0,
5437 .timeout_ms = MON_MODE_MSG_TIMEOUT,
5438 };
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305439
5440 mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter);
5441 if(!mon_ctx) {
5442 hddLog(LOGE, "Monitor Context NULL");
5443 ret = -EIO;
5444 break;
5445 }
5446
5447 if (mon_ctx->state == set_value) {
5448 hddLog(LOGE, FL("already in same mode curr_mode:%d req_mode: %d"),
5449 mon_ctx->state, set_value);
5450 break;
5451 }
5452
5453 ret = wlan_hdd_sta_mon_op(hdd_ctx, set_value,
5454 adapter,mon_ctx);
5455 if (ret)
5456 break;
5457
5458 mon_ctx->state = set_value;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305459 request = hdd_request_alloc(&params);
5460 if (!request) {
5461 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
5462 ret = -ENOMEM;
5463 break;
5464 }
5465 cookie = hdd_request_cookie(request);
5466 if (wlan_hdd_mon_postMsg(cookie, mon_ctx,
5467 hdd_mon_post_msg_cb)
5468 != VOS_STATUS_SUCCESS) {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305469 hddLog(LOGE, FL("failed to post MON MODE REQ"));
5470 mon_ctx->state =
5471 (mon_ctx->state==MON_MODE_START) ?
5472 MON_MODE_STOP : MON_MODE_START;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305473 ret = -EIO;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305474 } else {
5475 ret = hdd_request_wait_for_response(request);
5476 if (ret){
5477 hddLog(LOGE, FL("failed to wait on monitor mode completion %d"),
5478 ret);
5479 } else if (mon_ctx->state == MON_MODE_STOP) {
5480 hddLog(LOG1, FL("Enable BMPS"));
5481 hdd_enable_bmps_imps(hdd_ctx);
5482 hdd_restore_roaming(hdd_ctx);
5483 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305484 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05305485 hdd_request_put(request);
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305486 }
5487 break;
5488
5489 default:
5490 {
5491 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
5492 sub_cmd, set_value);
5493 }
5494 break;
5495 }
5496
5497 EXIT();
5498 return ret;
5499}
5500
Jeff Johnson295189b2012-06-20 16:38:30 -07005501/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305502static int __iw_setint_getnone(struct net_device *dev,
5503 struct iw_request_info *info,
5504 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005505{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305506 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305507 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305508 hdd_wext_state_t *pWextState;
5509 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305510 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 int *value = (int *)extra;
5512 int sub_cmd = value[0];
5513 int set_value = value[1];
5514 int ret = 0; /* success */
5515 int enable_pbm, enable_mp;
5516#ifdef CONFIG_HAS_EARLYSUSPEND
5517 v_U8_t nEnableSuspendOld;
5518#endif
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305519 void *cookie;
5520 struct hdd_request *request;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305522 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305523 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5524 if (NULL == pAdapter)
5525 {
5526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5527 "%s: Adapter is NULL",__func__);
5528 return -EINVAL;
5529 }
5530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5531 ret = wlan_hdd_validate_context(pHddCtx);
5532 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005533 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305534 return ret;
5535 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305536
Katya Nigameae74b62015-05-28 17:19:16 +05305537 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305538 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305539 /* In monitor mode hHal is NULL */
5540 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5541 if (NULL == hHal)
5542 {
5543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5544 "%s: Hal Context is NULL",__func__);
5545 return -EINVAL;
5546 }
Katya Nigameae74b62015-05-28 17:19:16 +05305547 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5548 if (NULL == pWextState)
5549 {
5550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5551 "%s: pWextState is NULL",__func__);
5552 return -EINVAL;
5553 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005554
Katya Nigameae74b62015-05-28 17:19:16 +05305555 INIT_COMPLETION(pWextState->completion_var);
5556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 switch(sub_cmd)
5558 {
5559 case WE_SET_11D_STATE:
5560 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005561 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005562 memset(&smeConfig, 0x00, sizeof(smeConfig));
5563
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305564 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5565 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 sme_GetConfigParam(hHal,&smeConfig);
5567 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5568
Arif Hussain6d2a3322013-11-17 19:50:10 -08005569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005570
5571 sme_UpdateConfig(hHal,&smeConfig);
5572 }
5573 else {
5574 return -EINVAL;
5575 }
5576 break;
5577 }
5578
5579 case WE_WOWL:
5580 {
5581 switch (set_value)
5582 {
5583 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305584 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 break;
5586 case 0x01:
5587 case 0x02:
5588 case 0x03:
5589 enable_mp = (set_value & 0x01) ? 1 : 0;
5590 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005591 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5593 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5594 break;
5595 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005596 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 ret = -EINVAL;
5598 break;
5599 }
5600
5601 break;
5602 }
5603 case WE_SET_POWER:
5604 {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305605 if (wlan_hdd_check_monitor_state(pHddCtx)) {
5606 hddLog(LOGE, FL("setPower not allowed in STA + MON"));
5607 ret = -EOPNOTSUPP;
5608 break;
5609 }
5610
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 switch (set_value)
5612 {
5613 case 0: //Full Power
5614 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305615 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305616 static const struct hdd_request_params params = {
5617 .priv_size = 0,
5618 .timeout_ms = WLAN_WAIT_TIME_POWER,
5619 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005620
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305621 if (NULL == hHal)
5622 return -EINVAL;
5623
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305624 request = hdd_request_alloc(&params);
5625 if (!request) {
5626 hddLog(VOS_TRACE_LEVEL_ERROR,
5627 FL("Request allocation failure"));
5628 return VOS_STATUS_E_NOMEM;
5629 }
5630 cookie = hdd_request_cookie(request);
5631
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305633 iw_power_callback_func, cookie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305635
Jeff Johnson72a40512013-12-19 10:14:15 -08005636 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305638 ret = hdd_request_wait_for_response(request);
5639 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005640 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305641 FL("SME timeout while requesting bmps"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 }
5643 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305644
5645 /*
5646 * either we never sent a request, we sent a request and
5647 * received a response or we sent a request and timed out.
5648 * Regardless we are done with the request.
5649 */
5650 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005651
Arif Hussain6d2a3322013-11-17 19:50:10 -08005652 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 break;
5654 }
5655 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305656 if (hHal)
5657 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5658 else
5659 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 break;
5661 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305662 if (hHal)
5663 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5664 else
5665 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 break;
5667 case 3: //Request Bmps
5668 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305669 eHalStatus status = eHAL_STATUS_FAILURE;
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305670 static const struct hdd_request_params params = {
5671 .priv_size = 0,
5672 .timeout_ms = WLAN_WAIT_TIME_POWER,
5673 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005674
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305675 if (NULL == hHal)
5676 return -EINVAL;
5677
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305678 request = hdd_request_alloc(&params);
5679 if (!request) {
5680 hddLog(VOS_TRACE_LEVEL_ERROR,
5681 FL("Request allocation failure"));
5682 return VOS_STATUS_E_NOMEM;
5683 }
5684 cookie = hdd_request_cookie(request);
5685
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305687 iw_power_callback_func, cookie);
Jeff Johnson72a40512013-12-19 10:14:15 -08005688 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 {
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305690 ret = hdd_request_wait_for_response(request);
5691 if (ret) {
Jeff Johnson72a40512013-12-19 10:14:15 -08005692 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305693 FL("SME timeout while requesting fullpower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 }
5695 }
Hanumanth Reddy Pothula00022c12018-04-05 18:54:35 +05305696
5697 /*
5698 * either we never sent a request, we sent a request and
5699 * received a response or we sent a request and timed out.
5700 * Regardless we are done with the request.
5701 */
5702 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005703
Arif Hussain6d2a3322013-11-17 19:50:10 -08005704 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 break;
5706 }
5707 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305708 if (hHal)
5709 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5710 else
5711 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 break;
5713 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305714 if (hHal)
5715 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5716 else
5717 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 break;
5719 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305720 if (hHal)
5721 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5722 else
5723 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 break;
5725 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305726 if (hHal)
5727 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5728 else
5729 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 break;
5731 case 8: //Request Standby
5732#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005733#endif
5734 break;
5735 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305736 if (hHal)
5737 sme_StartAutoBmpsTimer(hHal);
5738 else
5739 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 break;
5741 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305742 if (hHal)
5743 sme_StopAutoBmpsTimer(hHal);
5744 else
5745 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 break;
5747#ifdef CONFIG_HAS_EARLYSUSPEND
5748 case 11://suspend to standby
5749#ifdef CONFIG_HAS_EARLYSUSPEND
5750 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5751 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5753#endif
5754 break;
5755 case 12://suspend to deep sleep
5756#ifdef CONFIG_HAS_EARLYSUSPEND
5757 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5758 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5760#endif
5761 break;
5762 case 13://resume from suspend
5763#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005764#endif
5765 break;
5766#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005768 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 ret = -EINVAL;
5770 break;
5771 }
5772 break;
5773 }
5774
5775 case WE_SET_MAX_ASSOC:
5776 {
5777 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305778 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5779 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 {
5781 ret = -EINVAL;
5782 }
5783 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5784 set_value, NULL, eANI_BOOLEAN_FALSE)
5785 != eHAL_STATUS_SUCCESS )
5786 {
c_hpothub8245442013-11-20 23:41:09 +05305787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5788 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 ret = -EIO;
5790 }
5791 break;
5792 }
5793
5794 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5795 {
5796 if( 0 == set_value )
5797 {
5798 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5799 }
5800 else if ( 1 == set_value )
5801 {
5802 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5803 }
5804 else
5805 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005806 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 ret = -EINVAL;
5808 }
5809 break;
5810 }
5811
5812 case WE_SET_DATA_INACTIVITY_TO:
5813 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305814 if (NULL == hHal)
5815 return -EINVAL;
5816
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5818 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5819 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5820 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5821 set_value,
5822 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5823 {
5824 hddLog(LOGE,"Failure: Could not pass on "
5825 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005826 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 ret = -EINVAL;
5828 }
5829 break;
5830 }
5831 case WE_SET_MAX_TX_POWER:
5832 {
5833 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5834 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5835
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305836 if (NULL == hHal)
5837 return -EINVAL;
5838
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5840 __func__, set_value);
5841 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5842 eHAL_STATUS_SUCCESS )
5843 {
5844 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5845 __func__);
5846 return -EIO;
5847 }
5848
5849 break;
5850 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005851 case WE_SET_MAX_TX_POWER_2_4:
5852 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305853 if (NULL == hHal)
5854 return -EINVAL;
5855
Arif Hussaina5ebce02013-08-09 15:09:58 -07005856 hddLog(VOS_TRACE_LEVEL_INFO,
5857 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5858 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305859 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005860 eHAL_STATUS_SUCCESS)
5861 {
5862 hddLog(VOS_TRACE_LEVEL_ERROR,
5863 "%s: Setting maximum tx power failed for 2.4 GHz band",
5864 __func__);
5865 return -EIO;
5866 }
5867
5868 break;
5869 }
5870 case WE_SET_MAX_TX_POWER_5_0:
5871 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305872 if (NULL == hHal)
5873 return -EINVAL;
5874
Arif Hussaina5ebce02013-08-09 15:09:58 -07005875 hddLog(VOS_TRACE_LEVEL_INFO,
5876 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5877 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305878 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005879 eHAL_STATUS_SUCCESS)
5880 {
5881 hddLog(VOS_TRACE_LEVEL_ERROR,
5882 "%s: Setting maximum tx power failed for 5.0 GHz band",
5883 __func__);
5884 return -EIO;
5885 }
5886
5887 break;
5888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 case WE_SET_HIGHER_DTIM_TRANSITION:
5890 {
5891 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5892 (set_value == eANI_BOOLEAN_TRUE)))
5893 {
5894 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5895 ret = -EINVAL;
5896 }
5897 else
5898 {
5899 if(pAdapter->higherDtimTransition != set_value)
5900 {
5901 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005902 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 }
5904 }
5905
5906 break;
5907 }
5908
5909 case WE_SET_TM_LEVEL:
5910 {
5911 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005912 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5914
5915 break;
5916 }
5917
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305918 case WE_ENABLE_STRICT_FCC_REG:
5919 {
5920 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5921 struct wiphy *wiphy = NULL;
5922 long lrc;
5923 int status;
5924
5925 wiphy = hddCtxt->wiphy;
5926 if(wiphy == NULL)
5927 {
5928 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5929 break;
5930 }
5931 init_completion(&hddCtxt->wiphy_channel_update_event);
5932
5933 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5934
5935 status = regulatory_hint(wiphy, "00");
5936 if(status < 0)
5937 {
5938 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5939 break;
5940 }
5941
5942 /* Wait for completion */
5943 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5944 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5945 if (lrc <= 0)
5946 {
5947 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5948 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5949 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5950 }
5951 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5952
5953 break;
5954 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005955 case WE_SET_DEBUG_LOG:
5956 {
5957 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5958 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305959 if (hHal)
5960 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5961 else
5962 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005963 break;
5964 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305965#ifdef FEATURE_WLAN_TDLS
5966 case WE_SET_TDLS_OFF_CHAN:
5967 {
5968 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5970 __func__, set_value);
5971 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5972 break;
5973 }
5974 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5975 {
5976 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5978 __func__, set_value);
5979 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5980 break;
5981 }
5982 case WE_SET_TDLS_OFF_CHAN_MODE:
5983 {
5984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5985 __func__, set_value);
5986 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5987 break;
5988 }
5989#endif
Peng Xu2446a892014-09-05 17:21:18 +05305990 case WE_SET_SCAN_BAND_PREFERENCE:
5991 {
5992 tSmeConfigParams smeConfig;
5993 memset(&smeConfig, 0x00, sizeof(smeConfig));
5994 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5995 ret = -EINVAL;
5996 break;
5997 }
5998 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5999
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306000 if ((eCSR_BAND_ALL == set_value ||
6001 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6002 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306003 sme_GetConfigParam(hHal, &smeConfig);
6004 smeConfig.csrConfig.scanBandPreference = set_value;
6005
6006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6007 "set band scan preference = %d\n",
6008 smeConfig.csrConfig.scanBandPreference);
6009
6010 sme_UpdateConfig(hHal, &smeConfig);
6011 }
6012 else {
6013 ret = -EINVAL;
6014 }
6015 break;
6016 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306017 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6018 * connection happens so that the params can take effect during
6019 * association. Also this should not be used in STA+p2p concurrency
6020 * as the param will also effect the STA mode.
6021 */
6022 case WE_SET_MIRACAST_VENDOR_CONFIG:
6023 {
6024 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306025
Abhishek Singh01c73d12015-03-12 15:13:44 +05306026 hddLog(LOG1, FL(
6027 "Set Miracast vendor tuning %d"), set_value);
6028
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306029 if (NULL == hHal)
6030 return -EINVAL;
6031
Abhishek Singh01c73d12015-03-12 15:13:44 +05306032 if (1 == set_value || 0 == set_value)
6033 {
6034 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6035 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6036 {
6037 hddLog( LOGE, FL("set vendor miracast config failed"));
6038 ret = -EIO;
6039 }
6040 }
6041 else
6042 {
6043 hddLog(LOGE,
6044 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6045 ret = -EINVAL;
6046 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306047 break;
6048 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306049
6050 case WE_GET_FRAME_LOG:
6051 {
6052 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6053 != VOS_STATUS_SUCCESS)
6054 {
6055 ret = -EINVAL;
6056 }
6057 break;
6058 }
6059
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306060 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6061 {
6062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6063 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306064 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306065 {
6066 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6067 set_value);
6068 }
6069 else
6070 ret = -EINVAL;
6071
6072 break;
6073 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306074 /* Bit mask value to enable RTS/CTS for different modes
6075 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6076 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6077 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6078 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6079 * for 5 GHz, VHT80 - 0x1000
6080 */
6081 case WE_SET_RTS_CTS_HTVHT:
6082 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306083
Abhishek Singh41988ba2015-05-25 19:42:29 +05306084 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6085
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306086 if (NULL == hHal)
6087 return -EINVAL;
6088
Abhishek Singh41988ba2015-05-25 19:42:29 +05306089 if (eHAL_STATUS_SUCCESS !=
6090 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6091 {
6092 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6093 ret = -EINVAL;
6094 }
6095 break;
6096 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306097 case WE_SET_MONITOR_STATE:
6098 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306099 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306100 int ret;
6101 void *cookie;
6102 struct hdd_request *request;
6103 static const struct hdd_request_params params = {
6104 .priv_size = 0,
6105 .timeout_ms = MON_MODE_MSG_TIMEOUT,
6106 };
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306107
6108 if( VOS_MONITOR_MODE != mode)
6109 {
6110 hddLog(LOGE, "invalid mode %d", mode);
6111 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306112 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306113 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306114
6115 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6116 if( pMonCtx == NULL )
6117 {
6118 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306119 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306120 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306121 }
6122 if (pMonCtx->state == set_value)
6123 {
6124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6125 FL("already in same mode curr_mode:%d req_mode: %d"),
6126 pMonCtx->state, set_value);
6127 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306128 }
6129 pMonCtx->state = set_value;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306130 request = hdd_request_alloc(&params);
6131 if (!request) {
6132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6133 ret = -ENOMEM;
6134 break;
6135 }
6136 cookie = hdd_request_cookie(request);
6137
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306138 if (VOS_STATUS_SUCCESS !=
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306139 wlan_hdd_mon_postMsg(cookie, pMonCtx,
6140 hdd_mon_post_msg_cb)) {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6142 FL("failed to post MON MODE REQ"));
6143 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6144 MON_MODE_STOP : MON_MODE_START;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306145 ret = -EIO;
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306146 } else {
6147 ret = hdd_request_wait_for_response(request);
6148 if (ret) {
6149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6150 FL("failed to wait on monitor mode completion %d"),
6151 ret);
6152 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306153 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05306154 hdd_request_put(request);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306155 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306156 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306157 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6158 {
6159 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6160 tAniWifiStartLog start_log;
6161 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6162 !vos_isPktStatsEnabled())
6163 {
6164 hddLog(LOGE, FL("per pkt stats not enabled"));
6165 return -EINVAL;
6166 }
6167 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6168
6169 if (1 == set_value || 0 == set_value)
6170 {
6171 start_log.ringId = RING_ID_PER_PACKET_STATS;
6172 start_log.flag = 0;
6173 if (set_value)
6174 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6175 else
6176 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6177
6178 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6179 }
6180 else
6181 {
6182 hddLog(LOGE,
6183 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6184 set_value);
6185 ret = -EINVAL;
6186 }
6187 break;
6188 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306189 case WE_SET_PROXIMITY_ENABLE:
6190 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306191 if (NULL == hHal)
6192 return -EINVAL;
6193
6194 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306195 break;
6196 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306197 case WE_CAP_TSF:
6198 {
6199 if (NULL == hHal)
6200 return -EINVAL;
6201
6202 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6203 break;
6204 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306205 case WE_SET_MODULATED_DTIM:
6206 {
6207 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6208 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6209 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6210 set_value);
6211 return -EINVAL;
6212 } else {
6213 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6214 enableModulatedDTIM = set_value;
6215 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306216 }
6217 case WLAN_SET_DYNNAMIC_AGGREGATION:
6218 {
6219 if (NULL == hHal)
6220 return -EINVAL;
6221
6222 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306223 break;
6224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 default:
6226 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006227 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 sub_cmd, set_value);
6229 break;
6230 }
6231 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306232 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 return ret;
6234}
6235
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306236static int iw_setint_getnone(struct net_device *dev,
6237 struct iw_request_info *info,
6238 union iwreq_data *wrqu, char *extra)
6239{
6240 int ret;
6241
6242 vos_ssr_protect(__func__);
6243 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6244 vos_ssr_unprotect(__func__);
6245
6246 return 0;
6247}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306248
6249static
6250int iw_mon_setint_getnone(struct net_device *dev,
6251 struct iw_request_info *info,
6252 union iwreq_data *wrqu, char *extra)
6253{
6254 int ret;
6255
6256 vos_ssr_protect(__func__);
6257 ret = __iw_mon_setint_getnone(dev, info, wrqu, extra);
6258 vos_ssr_unprotect(__func__);
6259
6260 return 0;
6261}
6262
Jeff Johnson295189b2012-06-20 16:38:30 -07006263/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306264static int __iw_setchar_getnone(struct net_device *dev,
6265 struct iw_request_info *info,
6266 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006267{
6268 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306269 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006271 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306272 hdd_adapter_t *pAdapter;
6273 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006274#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306275 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006276#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306277 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306278 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006279
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306280 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306281
6282 if (!capable(CAP_NET_ADMIN))
6283 {
6284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6285 FL("permission check failed"));
6286 return -EPERM;
6287 }
6288
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306289 pAdapter = (netdev_priv(dev));
6290 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006291 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6293 "%s: Adapter is NULL",__func__);
6294 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006295 }
6296
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306297 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6298 ret = wlan_hdd_validate_context(pHddCtx);
6299 if (0 != ret)
6300 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306301 return ret;
6302 }
6303#ifdef WLAN_FEATURE_VOWIFI
6304 pConfig = pHddCtx->cfg_ini;
6305#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306306 /* helper function to get iwreq_data with compat handling. */
6307 if (hdd_priv_get_data(&s_priv_data, wrqu))
6308 {
6309 return -EINVAL;
6310 }
6311
6312 /* make sure all params are correctly passed to function */
6313 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6314 {
6315 return -EINVAL;
6316 }
6317
6318 sub_cmd = s_priv_data.flags;
6319
Arif Hussain0273cba2014-01-07 20:58:29 -08006320 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306321 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6322 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006323 if (NULL == pBuffer)
6324 {
6325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6326 "mem_alloc_copy_from_user_helper fail");
6327 return -ENOMEM;
6328 }
6329
6330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306331 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6333 "%s: Received data %s", __func__, pBuffer);
6334
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 switch(sub_cmd)
6336 {
6337 case WE_WOWL_ADD_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306338 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6339 hddLog(LOGE, FL("wowlAddPtrn not allowed in STA + MON"));
6340 ret = -EOPNOTSUPP;
6341 break;
6342 }
6343
Arif Hussain6d2a3322013-11-17 19:50:10 -08006344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006345 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 break;
6347 case WE_WOWL_DEL_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306348 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6349 hddLog(LOGE, FL("wowlDelPtrn not allowed in STA + MON"));
6350 ret = -EOPNOTSUPP;
6351 break;
6352 }
6353
Arif Hussain6d2a3322013-11-17 19:50:10 -08006354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006355 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 break;
6357#if defined WLAN_FEATURE_VOWIFI
6358 case WE_NEIGHBOR_REPORT_REQUEST:
6359 {
6360 tRrmNeighborReq neighborReq;
6361 tRrmNeighborRspCallbackInfo callbackInfo;
6362
6363 if (pConfig->fRrmEnable)
6364 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306366 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 if( !neighborReq.no_ssid )
6368 {
Girish Gowli552fc072014-06-14 18:26:16 +05306369 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006370 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 }
6372
6373 callbackInfo.neighborRspCallback = NULL;
6374 callbackInfo.neighborRspCallbackContext = NULL;
6375 callbackInfo.timeout = 5000; //5 seconds
6376 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6377 }
6378 else
6379 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006380 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 ret = -EINVAL;
6382 }
6383 }
6384 break;
6385#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 case WE_SET_AP_WPS_IE:
6387 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306388 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006391 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 if (VOS_STATUS_SUCCESS != vstatus)
6393 {
6394 ret = -EINVAL;
6395 }
6396 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306397 case WE_SET_ENCRYPT_MSG:
6398 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6399 if (NULL == pkt)
6400 {
6401 hddLog(VOS_TRACE_LEVEL_ERROR,
6402 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306403 ret = -ENOMEM;
6404 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306405 }
6406
6407 memset(pkt, 0, sizeof(tSirpkt80211));
6408
6409 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6410 hddLog(VOS_TRACE_LEVEL_ERROR,
6411 FL("Firmware is not DISA capable"));
6412 ret = -EINVAL;
6413 vos_mem_free(pkt);
6414 break;
6415 }
6416
6417 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6418
6419 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6420 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6421 if (eHAL_STATUS_SUCCESS != ret) {
6422 hddLog(VOS_TRACE_LEVEL_ERROR,
6423 FL("SENDEncryptMSG: fail to post WDA cmd"));
6424 ret = -EINVAL;
6425 }
6426 vos_mem_free(pkt);
6427
6428 break;
6429
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 default:
6431 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006432 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 ret = -EINVAL;
6434 break;
6435 }
6436 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006437 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306438
6439 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 return ret;
6441}
6442
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306443static int iw_setchar_getnone(struct net_device *dev,
6444 struct iw_request_info *info,
6445 union iwreq_data *wrqu, char *extra)
6446{
6447 int ret;
6448
6449 vos_ssr_protect(__func__);
6450 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6451 vos_ssr_unprotect(__func__);
6452
6453 return ret;
6454}
6455
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306456struct get_antenna_idx_priv {
6457 int antenna_id;
6458};
6459
6460static void hdd_get_current_antenna_index_cb(int antenna_id, void *context)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306461{
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306462 struct hdd_request *request;
6463 struct get_antenna_idx_priv *priv;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306464
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306465 request = hdd_request_get(context);
6466 if (!request) {
6467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
6468 return;
6469 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306470
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306471 priv = hdd_request_priv(request);
6472 priv->antenna_id = antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306473
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306474 hdd_request_complete(request);
6475 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306476
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306477}
6478
6479static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6480 int *antennaIndex)
6481{
6482 hdd_context_t *pHddCtx;
6483 eHalStatus halStatus;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306484 int ret;
6485 void *cookie;
6486 struct hdd_request *request;
6487 struct get_antenna_idx_priv *priv;
6488 static const struct hdd_request_params params = {
6489 .priv_size = sizeof(*priv),
6490 .timeout_ms = WLAN_WAIT_TIME_STATS,
6491 };
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306492
6493 ENTER();
6494 if (NULL == pAdapter)
6495 {
6496 hddLog(VOS_TRACE_LEVEL_WARN,
6497 "%s: Invalid context, pAdapter", __func__);
6498 return VOS_STATUS_E_FAULT;
6499 }
6500 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6501 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6502 {
6503 return VOS_STATUS_E_FAULT;
6504 }
6505 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6506 {
6507 hddLog(VOS_TRACE_LEVEL_ERROR,
6508 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6509 __func__);
6510 return VOS_STATUS_E_NOSUPPORT;
6511 }
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306512
6513 request = hdd_request_alloc(&params);
6514 if (!request) {
6515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
6516 return VOS_STATUS_E_NOMEM;
6517 }
6518 cookie = hdd_request_cookie(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306519
6520 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306521 hdd_get_current_antenna_index_cb,
6522 cookie, pAdapter->sessionId);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306523 if (eHAL_STATUS_SUCCESS != halStatus)
6524 {
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306525 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6526 __func__);
6527 /* we'll returned a cached value below */
6528 *antennaIndex = -1;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306529 }
6530 else
6531 {
6532 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula543559a2018-05-02 13:06:40 +05306533 ret = hdd_request_wait_for_response(request);
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306534 if (ret)
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306535 {
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306536 hddLog(VOS_TRACE_LEVEL_ERROR,
6537 FL("SME timeout while retrieving Antenna Index"));
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306538 *antennaIndex = -1;
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306539 }
6540 else
6541 {
6542 priv = hdd_request_priv(request);
6543 pAdapter->antennaIndex = priv->antenna_id;
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306544 }
6545 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306546
Hanumanth Reddy Pothula308d99d2018-04-09 19:14:26 +05306547 if (*antennaIndex != -1)
6548 *antennaIndex = pAdapter->antennaIndex;
6549
6550 /*
6551 * either we never sent a request, we sent a request and received a
6552 * response or we sent a request and timed out. Regardless we are
6553 * done with the request.
6554 */
6555 hdd_request_put(request);
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306556
6557 EXIT();
6558 return VOS_STATUS_SUCCESS;
6559}
6560
Jeff Johnson295189b2012-06-20 16:38:30 -07006561/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306562static int __iw_setnone_getint(struct net_device *dev,
6563 struct iw_request_info *info,
6564 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006565{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306566 hdd_adapter_t *pAdapter;
6567 tHalHandle hHal;
6568 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 int *value = (int *)extra;
6570 int ret = 0; /* success */
6571
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306572 ENTER();
6573
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306574 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6575 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006576 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6578 "%s: Adapter is NULL",__func__);
6579 return -EINVAL;
6580 }
6581 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6582 ret = wlan_hdd_validate_context(pHddCtx);
6583 if (0 != ret)
6584 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306585 return ret;
6586 }
6587 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6588 if (NULL == hHal)
6589 {
6590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6591 "%s: Hal Context is NULL",__func__);
6592 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006594
6595 switch (value[0])
6596 {
6597 case WE_GET_11D_STATE:
6598 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006599 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306601
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6603
Arif Hussain6d2a3322013-11-17 19:50:10 -08006604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006605
6606 break;
6607 }
6608
6609 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 break;
6612
6613 case WE_PMC_STATE:
6614 {
6615 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 break;
6618 }
6619 case WE_GET_WLAN_DBG:
6620 {
6621 vos_trace_display();
6622 *value = 0;
6623 break;
6624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 case WE_GET_MAX_ASSOC:
6626 {
6627 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6628 {
c_hpothub8245442013-11-20 23:41:09 +05306629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6630 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 ret = -EIO;
6632 }
Girish Gowli385be612014-09-18 11:17:20 +05306633#ifdef WLAN_SOFTAP_VSTA_FEATURE
6634 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6635 {
6636 if (*value > VSTA_NUM_ASSOC_STA)
6637 {
6638 *value = VSTA_NUM_ASSOC_STA;
6639 }
6640 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6641 (*value > (VSTA_NUM_ASSOC_STA -
6642 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6643 {
6644 *value = (VSTA_NUM_ASSOC_STA -
6645 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6646 }
6647 }
6648 else
6649#endif
6650 {
6651 if (*value > NUM_ASSOC_STA)
6652 {
6653 *value = NUM_ASSOC_STA;
6654 }
6655 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6656 (*value > (NUM_ASSOC_STA -
6657 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6658 {
6659 *value = (NUM_ASSOC_STA -
6660 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6661 }
6662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 break;
6664 }
6665
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 case WE_GET_WDI_DBG:
6667 {
6668 wpalTraceDisplay();
6669 *value = 0;
6670 break;
6671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006672
6673 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6674 {
6675 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6676 break;
6677 }
6678 case WE_GET_CONCURRENCY_MODE:
6679 {
6680 *value = hdd_get_concurrency_mode ( );
6681
Arif Hussain6d2a3322013-11-17 19:50:10 -08006682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 break;
6684 }
6685
Peng Xu2446a892014-09-05 17:21:18 +05306686 case WE_GET_SCAN_BAND_PREFERENCE:
6687 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306688 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306689 sme_GetConfigParam(hHal, &smeConfig);
6690 *value = smeConfig.csrConfig.scanBandPreference;
6691
6692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6693 "scanBandPreference = %d\n", *value);
6694 break;
6695 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306696 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6697 {
6698 wlan_hdd_get_current_antenna_index(pAdapter, value);
6699 break;
6700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 default:
6702 {
6703 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6704 break;
6705 }
6706 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306707 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 return ret;
6709}
6710
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306711static int iw_setnone_getint(struct net_device *dev,
6712 struct iw_request_info *info,
6713 union iwreq_data *wrqu, char *extra)
6714{
6715 int ret;
6716
6717 vos_ssr_protect(__func__);
6718 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6719 vos_ssr_unprotect(__func__);
6720
6721 return ret;
6722
6723}
Jeff Johnson295189b2012-06-20 16:38:30 -07006724/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306725int __iw_set_three_ints_getnone(struct net_device *dev,
6726 struct iw_request_info *info,
6727 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006728{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306729 hdd_adapter_t *pAdapter;
6730 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 int *value = (int *)extra;
6732 int sub_cmd = value[0];
6733 int ret = 0;
6734
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306735 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306736
6737 if (!capable(CAP_NET_ADMIN))
6738 {
6739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6740 FL("permission check failed"));
6741 return -EPERM;
6742 }
6743
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306744 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6745 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6748 "%s: Adapter is NULL",__func__);
6749 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006750 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306751 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6752 ret = wlan_hdd_validate_context(pHddCtx);
6753 if (0 != ret)
6754 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306755 return ret;
6756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 switch(sub_cmd)
6758 {
6759 case WE_SET_WLAN_DBG:
6760 {
6761 vos_trace_setValue( value[1], value[2], value[3]);
6762 break;
6763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 case WE_SET_WDI_DBG:
6765 {
6766 wpalTraceSetLevel( value[1], value[2], value[3]);
6767 break;
6768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 case WE_SET_SAP_CHANNELS:
6770 {
6771 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6772 break;
6773 }
6774
6775 default:
6776 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006777 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 break;
6779 }
6780 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306781 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 return ret;
6783}
6784
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306785int iw_set_three_ints_getnone(struct net_device *dev,
6786 struct iw_request_info *info,
6787 union iwreq_data *wrqu, char *extra)
6788{
6789 int ret;
6790
6791 vos_ssr_protect(__func__);
6792 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6793 vos_ssr_unprotect(__func__);
6794
6795 return ret;
6796}
6797
6798static int __iw_get_char_setnone(struct net_device *dev,
6799 struct iw_request_info *info,
6800 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006801{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306802 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306804 hdd_context_t *pHddCtx;
6805 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006806#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006807 hdd_wext_state_t *pWextState;
6808#endif
6809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306810 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306811 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006812 if (pAdapter == NULL)
6813 {
6814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6815 "%s: pAdapter is NULL!", __func__);
6816 return -EINVAL;
6817 }
Alok Kumar69a8b752017-11-08 15:24:32 +05306818
6819 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
6820 WLAN_HDD_FTM == pAdapter->device_mode)
6821 return ret;
6822
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306823 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6824 ret = wlan_hdd_validate_context(pHddCtx);
6825 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006826 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306827 return ret;
6828 }
6829#ifdef WLAN_FEATURE_11W
6830 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6831 if (NULL == pWextState)
6832 {
6833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6834 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006835 return -EINVAL;
6836 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306837#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006838
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 switch(sub_cmd)
6840 {
6841 case WE_WLAN_VERSION:
6842 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006843 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006844 break;
6845 }
6846
6847 case WE_GET_STATS:
6848 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306849 tHalHandle hHal = NULL;
6850 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6852 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6853 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306854 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07006855
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306856
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 snprintf(extra, WE_MAX_STR_LEN,
6858 "\nTransmit"
6859 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6860 "\n dropped BK %u, BE %u, VI %u, VO %u"
6861 "\n classified BK %u, BE %u, VI %u, VO %u"
6862 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6863 "\n queued BK %u, BE %u, VI %u, VO %u"
6864 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006865 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 "\n fetched BK %u, BE %u, VI %u, VO %u"
6867 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6868 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006869 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 "\n flushed BK %u, BE %u, VI %u, VO %u"
6871 "\n\nReceive"
6872 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6873 "\n\nResetsStats"
6874 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306875 "\n"
6876 "\n\nARP Transmit"
6877 "\nTransmit Count %u, dropped %u"
6878 "\n\nARP Receive"
6879 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 "\n",
6881 pStats->txXmitCalled,
6882 pStats->txXmitDropped,
6883 pStats->txXmitBackPressured,
6884 pStats->txXmitQueued,
6885
6886 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6887 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6888 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6889 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6890
6891 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6892 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6893 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6894 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6895
6896 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6897 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6898 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6899 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6900
6901 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6902 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6903 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6904 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6905
6906 pStats->txFetched,
6907 pStats->txFetchEmpty,
6908 pStats->txFetchLowResources,
6909 pStats->txFetchDequeueError,
6910
6911 pStats->txFetchDequeued,
6912 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006913 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 pStats->txCompleted,
6915 pStats->txFlushed,
6916
6917 pStats->txFetchedAC[WLANTL_AC_BK],
6918 pStats->txFetchedAC[WLANTL_AC_BE],
6919 pStats->txFetchedAC[WLANTL_AC_VI],
6920 pStats->txFetchedAC[WLANTL_AC_VO],
6921
6922 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6923 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6924 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6925 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6926
6927 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6928 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6929 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6930 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6931
Ravi Joshi41914632013-10-21 23:02:21 -07006932 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6933 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6934 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6935 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6936
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 pStats->txFlushedAC[WLANTL_AC_BK],
6938 pStats->txFlushedAC[WLANTL_AC_BE],
6939 pStats->txFlushedAC[WLANTL_AC_VI],
6940 pStats->txFlushedAC[WLANTL_AC_VO],
6941
6942 pStats->rxChains,
6943 pStats->rxPackets,
6944 pStats->rxDropped,
6945 pStats->rxDelivered,
6946 pStats->rxRefused,
6947
6948 pResetStats->totalLogpResets,
6949 pResetStats->totalCMD53Failures,
6950 pResetStats->totalMutexReadFailures,
6951 pResetStats->totalMIFErrorFailures,
6952 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05306953 pResetStats->totalUnknownExceptions,
6954
6955 parpStats->txCount,
6956 parpStats->txDropped,
6957
6958 parpStats->rxCount,
6959 parpStats->rxDropped,
6960 parpStats->rxDelivered,
6961 parpStats->rxRefused,
6962 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306964 wrqu->data.length = strlen(extra);
6965
6966 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6967
6968 if (hHal)
6969 pMac = PMAC_STRUCT( hHal );
6970
6971 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6972 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6973 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306974 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6975 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6976 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6977 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306978 "\n",
6979 pMac->pmm.BmpscntSleep,
6980 pMac->pmm.BmpscntAwake,
6981 pMac->pmm.BmpsSleeReqFailCnt,
6982 pMac->pmm.BmpsWakeupReqFailCnt,
6983 pMac->pmm.ImpsCntSleep,
6984 pMac->pmm.ImpsCntAwake,
6985 pMac->pmm.ImpsSleepErrCnt,
6986 pMac->pmm.ImpsWakeupErrCnt,
6987 pMac->pmm.ImpsLastErr
6988 );
6989 }
6990
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 wrqu->data.length = strlen(extra)+1;
6992 break;
6993 }
6994
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306995/* The case prints the current state of the HDD, SME, CSR, PE, TL
6996 *it can be extended for WDI Global State as well.
6997 *And currently it only checks P2P_CLIENT adapter.
6998 *P2P_DEVICE and P2P_GO have not been added as of now.
6999*/
7000 case WE_GET_STATES:
7001 {
7002 int buf = 0, len = 0;
7003 int adapter_num = 0;
7004 int count = 0, check = 1;
7005
7006 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007007 tHalHandle hHal = NULL;
7008 tpAniSirGlobal pMac = NULL;
7009 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307010
7011 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7012 hdd_adapter_t *useAdapter = NULL;
7013
7014 /* Print wlan0 or p2p0 states based on the adapter_num
7015 *by using the correct adapter
7016 */
7017 while ( adapter_num < 2 )
7018 {
7019 if ( WLAN_ADAPTER == adapter_num )
7020 {
7021 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007022 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307023 "\n\n wlan0 States:-");
7024 len += buf;
7025 }
7026 else if ( P2P_ADAPTER == adapter_num )
7027 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007028 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307029 "\n\n p2p0 States:-");
7030 len += buf;
7031
7032 if( !pHddCtx )
7033 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007034 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307035 "\n pHddCtx is NULL");
7036 len += buf;
7037 break;
7038 }
7039
7040 /*Printing p2p0 states only in the case when the device is
7041 configured as a p2p_client*/
7042 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7043 if ( !useAdapter )
7044 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007045 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307046 "\n Device not configured as P2P_CLIENT.");
7047 len += buf;
7048 break;
7049 }
7050 }
7051
7052 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007053 if (!hHal) {
7054 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7055 "\n pMac is NULL");
7056 len += buf;
7057 break;
7058 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307059 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007060 if (!pMac) {
7061 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7062 "\n pMac is NULL");
7063 len += buf;
7064 break;
7065 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307066 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7067 if( !pHddStaCtx )
7068 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007069 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307070 "\n pHddStaCtx is NULL");
7071 len += buf;
7072 break;
7073 }
7074
7075 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7076
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007077 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307078 "\n HDD Conn State - %s "
7079 "\n \n SME State:"
7080 "\n Neighbour Roam State - %s"
7081 "\n CSR State - %s"
7082 "\n CSR Substate - %s"
7083 "\n \n TL STA %d State: %s",
7084 macTraceGetHDDWlanConnState(
7085 pHddStaCtx->conn_info.connState),
7086 macTraceGetNeighbourRoamState(
7087 pMac->roam.neighborRoamInfo.neighborRoamState),
7088 macTraceGetcsrRoamState(
7089 pMac->roam.curState[useAdapter->sessionId]),
7090 macTraceGetcsrRoamSubState(
7091 pMac->roam.curSubState[useAdapter->sessionId]),
7092 pHddStaCtx->conn_info.staId[0],
7093 macTraceGetTLState(tlState)
7094 );
7095 len += buf;
7096 adapter_num++;
7097 }
7098
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007099 if (pMac) {
7100 /* Printing Lim State starting with global lim states */
7101 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7102 "\n \n LIM STATES:-"
7103 "\n Global Sme State - %s "\
7104 "\n Global mlm State - %s "\
7105 "\n",
7106 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7107 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7108 );
7109 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307110
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007111 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307112 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307113 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007114 if ( pMac->lim.gpSession[count].valid )
7115 {
7116 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7117 "\n Lim Valid Session %d:-"
7118 "\n PE Sme State - %s "
7119 "\n PE Mlm State - %s "
7120 "\n",
7121 check,
7122 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7123 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7124 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307125
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007126 len += buf;
7127 check++;
7128 }
7129 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307130 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307131 }
7132
7133 wrqu->data.length = strlen(extra)+1;
7134 break;
7135 }
7136
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 case WE_GET_CFG:
7138 {
7139 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7140 wrqu->data.length = strlen(extra)+1;
7141 break;
7142 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007143#ifdef WLAN_FEATURE_11AC
7144 case WE_GET_RSSI:
7145 {
7146 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307147 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007148 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7149 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7150 wrqu->data.length = strlen(extra)+1;
7151 break;
7152 }
7153#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307154
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007155#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007156 case WE_GET_ROAM_RSSI:
7157 {
7158 v_S7_t s7Rssi = 0;
7159 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7160 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7161 wrqu->data.length = strlen(extra)+1;
7162 break;
7163 }
7164#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 case WE_GET_WMM_STATUS:
7166 {
7167 snprintf(extra, WE_MAX_STR_LEN,
7168 "\nDir: 0=up, 1=down, 3=both\n"
7169 "|------------------------|\n"
7170 "|AC | ACM |Admitted| Dir |\n"
7171 "|------------------------|\n"
7172 "|VO | %d | %3s | %d |\n"
7173 "|VI | %d | %3s | %d |\n"
7174 "|BE | %d | %3s | %d |\n"
7175 "|BK | %d | %3s | %d |\n"
7176 "|------------------------|\n",
7177 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7178 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7179 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7180 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7181 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7182 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7183 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7184 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7185 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7186 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7187 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7188 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7189
Jeff Johnsone7245742012-09-05 17:12:55 -07007190
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 wrqu->data.length = strlen(extra)+1;
7192 break;
7193 }
7194 case WE_GET_CHANNEL_LIST:
7195 {
7196 VOS_STATUS status;
7197 v_U8_t i, len;
7198 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307199 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7200 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7201 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 tChannelListInfo channel_list;
7203
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007204 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007206 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007208 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 return -EINVAL;
7210 }
7211 buf = extra;
7212
7213 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007214 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7215 * needed = 5 * number of channels. Check ifsufficient
7216 * buffer is available and then proceed to fill the buffer.
7217 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7219 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007220 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007221 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007222 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 return -EINVAL;
7224 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007225 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7226 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307227 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7228 {
7229 //Printing Country code in getChannelList
7230 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7231 {
7232 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7233 "%c ", pBuf[i]);
7234 }
7235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 for(i = 0 ; i < channel_list.num_channels; i++)
7237 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007238 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 }
7241 wrqu->data.length = strlen(extra)+1;
7242
7243 break;
7244 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007245#ifdef FEATURE_WLAN_TDLS
7246 case WE_GET_TDLS_PEERS:
7247 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007248 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007249 break;
7250 }
7251#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007252#ifdef WLAN_FEATURE_11W
7253 case WE_GET_11W_INFO:
7254 {
7255 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7256
7257 snprintf(extra, WE_MAX_STR_LEN,
7258 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7259 "\n Number of Unprotected Disassocs %d"
7260 "\n Number of Unprotected Deauths %d",
7261 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7262 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7263 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7264 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7265 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7266
7267 wrqu->data.length = strlen(extra)+1;
7268 break;
7269 }
7270#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307271#ifdef WLAN_FEATURE_RMC
7272 case WE_GET_IBSS_STA_INFO:
7273 {
7274 hdd_station_ctx_t *pHddStaCtx =
7275 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7276 int idx = 0;
7277 int length = 0, buf = 0;
7278
7279 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7280 {
7281 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7282 {
7283 buf = snprintf
7284 (
7285 (extra + length), WE_MAX_STR_LEN - length,
7286 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7287 pHddStaCtx->conn_info.staId[ idx ],
7288 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7289 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7290 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7291 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7292 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7293 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7294 );
7295 length += buf;
7296 }
7297 }
7298 wrqu->data.length = strlen(extra)+1;
7299 break;
7300 }
7301#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307302 case WE_GET_SNR:
7303 {
7304 v_S7_t s7snr = 0;
7305 int status = 0;
7306 hdd_context_t *pHddCtx;
7307 hdd_station_ctx_t *pHddStaCtx;
7308
7309 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7310 status = wlan_hdd_validate_context(pHddCtx);
7311 if (0 != status)
7312 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307313 return status;
7314 }
7315
7316 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7317
7318 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7319 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7320 {
7321 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7322 " ConnectionState-%d", __func__,
7323 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7324 pHddStaCtx->conn_info.connState);
7325 return -ENONET;
7326 }
7327
7328 /*update the stats in TL*/
7329 wlan_hdd_get_station_stats(pAdapter);
7330 wlan_hdd_get_snr(pAdapter, &s7snr);
7331 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7332 wrqu->data.length = strlen(extra) + 1;
7333 break;
7334 }
7335
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307336#ifdef FEATURE_OEM_DATA_SUPPORT
7337 case WE_GET_OEM_DATA_CAP:
7338 {
7339 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7340 }
7341#endif /* FEATURE_OEM_DATA_SUPPORT */
7342
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307343 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007345 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 break;
7347 }
7348 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307349 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 return 0;
7351}
7352
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307353static int iw_get_char_setnone(struct net_device *dev,
7354 struct iw_request_info *info,
7355 union iwreq_data *wrqu, char *extra)
7356{
7357 int ret;
7358
7359 vos_ssr_protect(__func__);
7360 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7361 vos_ssr_unprotect(__func__);
7362
7363 return ret;
7364}
7365
Jeff Johnson295189b2012-06-20 16:38:30 -07007366/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307367static int __iw_setnone_getnone(struct net_device *dev,
7368 struct iw_request_info *info,
7369 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007370{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307371 hdd_adapter_t *pAdapter;
7372 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307373 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007374 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307375 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007376
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307377 ENTER();
7378
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307379 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7380 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007381 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7383 "%s: Adapter is NULL",__func__);
7384 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007385 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307386 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7387 ret = wlan_hdd_validate_context(pHddCtx);
7388 if (0 != ret)
7389 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307390 return ret;
7391 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307392 /* helper function to get iwreq_data with compat handling. */
7393 if (hdd_priv_get_data(&s_priv_data, wrqu))
7394 {
7395 return -EINVAL;
7396 }
7397
7398 sub_cmd = s_priv_data.flags;
7399
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 switch (sub_cmd)
7401 {
7402 case WE_CLEAR_STATS:
7403 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7406 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7407 break;
7408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 case WE_INIT_AP:
7410 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307411 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7412
7413 /* As Soft AP mode might been changed to STA already with
7414 * killing of Hostapd, need to find the adpater by name
7415 * rather than mode */
7416 hdd_adapter_t* pAdapter_to_stop =
7417 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7418 if( pAdapter_to_stop )
7419 {
7420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7421 "Adapter with name softap.0 already "
7422 "exist, ignoring the request.\nRemove the "
7423 "adapter and try again\n");
7424 break;
7425 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05307426
7427 if (wlan_hdd_check_monitor_state(pHddCtx)) {
7428 hddLog(LOGE, FL("initAP not allowed in STA + MON"));
7429 ret = -EOPNOTSUPP;
7430 break;
7431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 pr_info("Init AP trigger\n");
7433 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7434 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7435 break;
7436 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307437#ifdef WLAN_FEATURE_RMC
7438 case WE_IBSS_GET_PEER_INFO_ALL:
7439 {
7440 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7441 break;
7442 }
7443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 case WE_STOP_AP:
7445 {
7446 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7447 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7448 * this is a dead code and need to find the adpater by name rather than mode */
7449 hdd_adapter_t* pAdapter_to_stop =
7450 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7451 if( pAdapter_to_stop )
7452 {
7453 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7454
7455 pr_info("Stopping AP mode\n");
7456
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307457 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7458 {
7459 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7460 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7461 }
7462
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307464 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307465 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7467
7468 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7469 pAdapter_to_stop->macAddressCurrent.bytes);
7470 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7471 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307472
7473 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7474 {
7475 /* put the device back into BMPS */
7476 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 }
7479 else
7480 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007481 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 }
7483
7484 break;
7485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007486#ifdef WLAN_BTAMP_FEATURE
7487 case WE_ENABLE_AMP:
7488 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 WLANBAP_RegisterWithHCI(pAdapter);
7491 break;
7492 }
7493 case WE_DISABLE_AMP:
7494 {
7495 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7496 VOS_STATUS status;
7497
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007499
7500 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7501 status = WLANBAP_StopAmp();
7502 if(VOS_STATUS_SUCCESS != status )
7503 {
7504 pHddCtx->isAmpAllowed = VOS_TRUE;
7505 hddLog(VOS_TRACE_LEVEL_FATAL,
7506 "%s: Failed to stop AMP", __func__);
7507 }
7508 else
7509 {
7510 //a state m/c implementation in PAL is TBD to avoid this delay
7511 msleep(500);
7512 pHddCtx->isAmpAllowed = VOS_FALSE;
7513 WLANBAP_DeregisterFromHCI();
7514 }
7515
7516 break;
7517 }
7518#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007519 case WE_ENABLE_DXE_STALL_DETECT:
7520 {
schang6295e542013-03-12 15:31:23 -07007521 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7522 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007523 break;
7524 }
7525 case WE_DISPLAY_DXE_SNAP_SHOT:
7526 {
schang6295e542013-03-12 15:31:23 -07007527 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7528 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007529 break;
7530 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307531 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7532 {
7533 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7534 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307535 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307536 break;
7537 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307538
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307539 case WE_SET_REASSOC_TRIGGER:
7540 {
7541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7542 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7543 v_U32_t roamId = 0;
7544 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307545 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7546 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307547 return 0;
7548 }
7549
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307550 case WE_STOP_OBSS_SCAN:
7551 {
7552 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7553 2.OBSS scan is stopped by Firmware during the disassociation
7554 3.OBSS stop comamnd is added for debugging purpose*/
7555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7556 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007557
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307558 if (pAdapter == NULL)
7559 {
7560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7561 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307562 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307563 }
7564 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7565 if (pMac == NULL)
7566 {
7567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7568 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307569 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307570 }
7571 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7572 }
7573 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307574 case WE_DUMP_ROAM_TIMER_LOG:
7575 {
7576 vos_dump_roam_time_log_service();
7577 break;
7578 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307579
Mukul Sharma84f27252014-07-14 18:11:42 +05307580 case WE_RESET_ROAM_TIMER_LOG:
7581 {
7582 vos_reset_roam_timer_log();
7583 break;
7584 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307585 case WE_GET_FW_LOGS:
7586 {
7587 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7588 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307589 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307590 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307591 break;
7592 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307593 case WE_GET_FW_MEMDUMP:
7594 {
7595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7596 "FW_MEM_DUMP requested ");
7597 get_fwr_memdump(dev,info,wrqu,extra);
7598 break;
7599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 default:
7601 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007602 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 break;
7604 }
7605 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307606 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 return ret;
7608}
7609
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307610static int iw_setnone_getnone(struct net_device *dev,
7611 struct iw_request_info *info,
7612 union iwreq_data *wrqu, char *extra)
7613{
7614 int ret;
7615
7616 vos_ssr_protect(__func__);
7617 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7618 vos_ssr_unprotect(__func__);
7619
7620 return ret;
7621}
7622
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307623void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7624{
7625 /*
7626 * Function to display HDD WMM information
7627 * for Tx Queues.
7628 * Prints globala as well as per client depending
7629 * whether the clients are registered or not.
7630 */
7631 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307632 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7633 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307634 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7635 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307636 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307637
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307638 for ( i=0; i< NUM_TX_QUEUES; i++)
7639 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307640 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307641 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307642 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307643 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307644
7645 for ( i=0; i< NUM_TX_QUEUES; i++) {
7646 if (tx_queue_count[i]) {
7647 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7648 i, tx_queue_count[i]);
7649 }
7650 }
7651
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307652 if(pSapCtx == NULL){
7653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7654 FL("psapCtx is NULL"));
7655 return;
7656 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307657
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307658 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307659 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7660 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307661 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307662 {
7663 hddLog(LOGE, "******STAIndex: %d*********", i);
7664 for ( j=0; j< NUM_TX_QUEUES; j++)
7665 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307666 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7667 {
7668 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307669 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7670 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307671 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7672 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307673 }
7674 }
7675 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307676 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307677
Katya Nigam1fd24402015-02-16 14:52:19 +05307678 if(pHddStaCtx == NULL){
7679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7680 FL("pHddStaCtx is NULL"));
7681 return;
7682 }
7683
7684 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7685 if(pPeerInfo == NULL){
7686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7687 FL("ppeerinfo is NULL"));
7688 return;
7689 }
7690
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307691 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7692 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7693 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7694 for (j = 0; j < NUM_TX_QUEUES; j++) {
7695 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7696 spin_lock_bh(
7697 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7698 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07007699 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307700 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7701 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7702 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7703 spin_unlock_bh(
7704 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7705 }
7706 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307707 }
7708 }
7709
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307710}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307711
Girish Gowlifb9758e2014-11-19 15:19:17 +05307712static int __iw_set_var_ints_getnone(struct net_device *dev,
7713 struct iw_request_info *info,
7714 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007715{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307716 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307717 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307718 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307719 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007720 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307721 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307722 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007723 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307724 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007725 int cmd = 0;
7726 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307727 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007728
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307729 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307730 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307731 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7733 "%s: NULL extra buffer pointer", __func__);
7734 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307735 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307736 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7737 if (NULL == pAdapter)
7738 {
7739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7740 "%s: Adapter is NULL",__func__);
7741 return -EINVAL;
7742 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307743 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307744 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7745 ret = wlan_hdd_validate_context(pHddCtx);
7746 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007747 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307748 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007749 }
Katya Nigameae74b62015-05-28 17:19:16 +05307750 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307751 {
Katya Nigameae74b62015-05-28 17:19:16 +05307752 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7753 if (NULL == hHal)
7754 {
7755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7756 "%s: Hal Context is NULL",__func__);
7757 return -EINVAL;
7758 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307759 }
7760 sub_cmd = wrqu->data.flags;
7761
7762 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7763
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007764
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007765 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7766 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7767 {
7768 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7769 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7770 {
7771 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7772 staId = pStaCtx->conn_info.staId[0];
7773 }
7774 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7775 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7776 {
7777 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7778 staId = pAPCtx->uBCStaId;
7779 }
7780 else
7781 {
7782 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7783 return 0;
7784 }
7785 }
7786
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 switch (sub_cmd)
7788 {
7789 case WE_LOG_DUMP_CMD:
7790 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307791 if(apps_args[0] == 26) {
7792 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7793 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7794 return 0;
7795 }
7796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007798 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307800 if (hHal)
7801 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7802 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007803
7804 }
7805 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307806#ifdef WLAN_FEATURE_RMC
7807 case WE_IBSS_GET_PEER_INFO:
7808 {
7809 pr_info ( "Station ID = %d\n",apps_args[0]);
7810 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7811 }
7812 break;
7813#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007814
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 case WE_P2P_NOA_CMD:
7816 {
7817 p2p_app_setP2pPs_t p2pNoA;
7818
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307819 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7820 hddLog(LOGE,
7821 FL("Setting NoA is not allowed in Device mode:%d"),
7822 pAdapter->device_mode);
7823 return -EINVAL;
7824 }
7825
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 p2pNoA.opp_ps = apps_args[0];
7827 p2pNoA.ctWindow = apps_args[1];
7828 p2pNoA.duration = apps_args[2];
7829 p2pNoA.interval = apps_args[3];
7830 p2pNoA.count = apps_args[4];
7831 p2pNoA.single_noa_duration = apps_args[5];
7832 p2pNoA.psSelection = apps_args[6];
7833
7834 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7835 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007836 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7838
7839 hdd_setP2pPs(dev, &p2pNoA);
7840
7841 }
7842 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007843
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307844 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7845 {
7846 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7847 __func__, apps_args[0], apps_args[1]);
7848 vosTraceEnable(apps_args[0], apps_args[1]);
7849 }
7850 break;
7851
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007852 case WE_MTRACE_DUMP_CMD:
7853 {
7854 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7855 "bitmask_of_module %d ",
7856 __func__, apps_args[0], apps_args[1], apps_args[2],
7857 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307858 if (hHal)
7859 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7860 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007861
7862 }
7863 break;
7864
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007865 case WE_MCC_CONFIG_CREDENTIAL :
7866 {
7867 cmd = 287; //Command should be updated if there is any change
7868 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007869 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007870 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307871 if (hHal)
7872 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7873 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007874 }
7875 else
7876 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007877 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007878 return 0;
7879 }
7880 }
7881 break;
7882
7883 case WE_MCC_CONFIG_PARAMS :
7884 {
7885 cmd = 288; //command Should be updated if there is any change
7886 // in the Riva dump command
7887 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7888 }
7889 break;
7890
Chilam NG571c65a2013-01-19 12:27:36 +05307891#ifdef FEATURE_WLAN_TDLS
7892 case WE_TDLS_CONFIG_PARAMS :
7893 {
7894 tdls_config_params_t tdlsParams;
7895
Chilam Ng01120412013-02-19 18:32:21 -08007896 tdlsParams.tdls = apps_args[0];
7897 tdlsParams.tx_period_t = apps_args[1];
7898 tdlsParams.tx_packet_n = apps_args[2];
7899 tdlsParams.discovery_period_t = apps_args[3];
7900 tdlsParams.discovery_tries_n = apps_args[4];
7901 tdlsParams.idle_timeout_t = apps_args[5];
7902 tdlsParams.idle_packet_n = apps_args[6];
7903 tdlsParams.rssi_hysteresis = apps_args[7];
7904 tdlsParams.rssi_trigger_threshold = apps_args[8];
7905 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307906
Chilam Ng01120412013-02-19 18:32:21 -08007907 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307908 }
7909 break;
7910#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307911 case WE_CONFIGURE_MONITOR_MODE:
7912 {
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307913 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307914 int ret;
7915 void *cookie;
7916 struct hdd_request *request;
7917 static const struct hdd_request_params params = {
7918 .priv_size = 0,
7919 .timeout_ms = MON_MODE_MSG_TIMEOUT,
7920 };
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307921
7922 if (VOS_MONITOR_MODE != mode) {
7923 hddLog(LOGE, FL("invalid mode %d"), mode);
7924 return -EIO;
7925 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307926
Katya Nigamf0511f62015-05-05 16:40:57 +05307927 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7928 if( pMonCtx == NULL )
7929 {
7930 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307931 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307932 }
7933 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7934 __func__, apps_args[0], apps_args[1], apps_args[2],
7935 apps_args[3], apps_args[4]);
7936 /* Input Validation part of FW */
7937 pMonCtx->ChannelNo = apps_args[0];
7938 pMonCtx->ChannelBW = apps_args[1];
7939 pMonCtx->crcCheckEnabled = apps_args[2];
7940 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7941 pMonCtx->is80211to803ConReq = apps_args[4];
7942 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7943 if( pMonCtx->is80211to803ConReq )
7944 pAdapter->dev->type = ARPHRD_ETHER;
7945 else
7946 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7947 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7948 {
7949 hddLog(LOGE, "%s: Filtering data packets as management and control"
7950 " cannot be converted to 802.3 ",__func__);
7951 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7952 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307953 if (MON_MODE_START == pMonCtx->state) {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307954 request = hdd_request_alloc(&params);
7955 if (!request) {
7956 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
7957 return -ENOMEM;
7958 }
7959 cookie = hdd_request_cookie(request);
7960
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307961 if (VOS_STATUS_SUCCESS !=
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307962 wlan_hdd_mon_postMsg(cookie, pMonCtx,
7963 hdd_mon_post_msg_cb)) {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7965 FL("failed to post MON MODE REQ"));
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307966 ret = -EIO;
7967 } else {
7968 ret = hdd_request_wait_for_response(request);
7969 if (ret)
7970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7971 FL("failed to wait on monitor mode completion %d"),
7972 ret);
7973 }
7974 hdd_request_put(request);
7975 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307976 }
7977 break;
7978
7979 case WE_SET_MONITOR_MODE_FILTER:
7980 {
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307981 tVOS_CON_MODE mode = hdd_get_conparam();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05307982 int ret;
7983 void *cookie;
7984 struct hdd_request *request;
7985 static const struct hdd_request_params params = {
7986 .priv_size = 0,
7987 .timeout_ms = MON_MODE_MSG_TIMEOUT,
7988 };
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307989
7990 if (VOS_MONITOR_MODE != mode) {
7991 hddLog(LOGE, FL("invalid mode %d"), mode);
7992 return -EIO;
7993 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307994
Katya Nigamf0511f62015-05-05 16:40:57 +05307995 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7996 if( pMonCtx == NULL )
7997 {
7998 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307999 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308000 }
8001 /* Input Validation Part of FW */
8002 pMonCtx->numOfMacFilters=1;
8003 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8004 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8005 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8006 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8007 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8008 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8009 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8010 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8011 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8012 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8013 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8014 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308015 if (MON_MODE_START == pMonCtx->state) {
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308016 request = hdd_request_alloc(&params);
8017 if (!request) {
8018 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
8019 return -ENOMEM;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308020 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308021 cookie = hdd_request_cookie(request);
8022
8023 if (VOS_STATUS_SUCCESS ==
8024 wlan_hdd_mon_postMsg(cookie, pMonCtx,
8025 hdd_mon_post_msg_cb)) {
8026 ret = hdd_request_wait_for_response(request);
8027 if (ret)
8028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8029 FL("failed to wait on monitor mode completion %d"),
8030 ret);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308031 }
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308032 hdd_request_put(request);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308033 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308034 }
8035 break;
8036
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 default:
8038 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008039 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8040 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 break;
8043 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308044 EXIT();
Hanumanth Reddy Pothulab8be9ab2018-04-12 20:03:05 +05308045 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008046}
8047
Girish Gowlifb9758e2014-11-19 15:19:17 +05308048static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8049 struct iw_request_info *info,
8050 union iwreq_data *wrqu, char *extra)
8051{
8052 int ret;
8053 union iwreq_data u_priv_wrqu;
8054 int apps_args[MAX_VAR_ARGS] = {0};
8055 int num_args;
8056
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308057 if (!capable(CAP_NET_ADMIN))
8058 {
8059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8060 FL("permission check failed"));
8061 return -EPERM;
8062 }
8063
Girish Gowlifb9758e2014-11-19 15:19:17 +05308064 /* helper function to get iwreq_data with compat handling. */
8065 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8066 {
8067 return -EINVAL;
8068 }
8069
8070 if (NULL == u_priv_wrqu.data.pointer)
8071 {
8072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8073 "%s: NULL data pointer", __func__);
8074 return -EINVAL;
8075 }
8076
8077 num_args = u_priv_wrqu.data.length;
8078 if (num_args > MAX_VAR_ARGS)
8079 {
8080 num_args = MAX_VAR_ARGS;
8081 }
8082
8083 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8084 (sizeof(int)) * num_args))
8085 {
8086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8087 "%s: failed to copy data from user buffer", __func__);
8088 return -EFAULT;
8089 }
8090
8091 vos_ssr_protect(__func__);
8092 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8093 (char *)&apps_args);
8094 vos_ssr_unprotect(__func__);
8095
8096 return ret;
8097}
8098
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308099int iw_set_var_ints_getnone(struct net_device *dev,
8100 struct iw_request_info *info,
8101 union iwreq_data *wrqu, char *extra)
8102{
8103 int ret;
8104 vos_ssr_protect(__func__);
8105 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8106 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008107
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308108 return ret;
8109}
8110
8111static int __iw_add_tspec(struct net_device *dev,
8112 struct iw_request_info *info,
8113 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008114{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308115 hdd_adapter_t *pAdapter;
8116 hdd_station_ctx_t *pHddStaCtx;
8117 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8119 int params[HDD_WLAN_WMM_PARAM_COUNT];
8120 sme_QosWmmTspecInfo tSpec;
8121 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308122 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308123 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008124
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308125 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308126 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8127 if (NULL == pAdapter)
8128 {
8129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8130 "%s: Adapter is NULL",__func__);
8131 return -EINVAL;
8132 }
8133 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8134 ret = wlan_hdd_validate_context(pHddCtx);
8135 if (0 != ret)
8136 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308137 return ret;
8138 }
8139 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8140 if (NULL == pHddStaCtx)
8141 {
8142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8143 "%s: STA Context is NULL",__func__);
8144 return -EINVAL;
8145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 // make sure the application is sufficiently priviledged
8147 // note that the kernel will do this for "set" ioctls, but since
8148 // this ioctl wants to return status to user space it must be
8149 // defined as a "get" ioctl
8150 if (!capable(CAP_NET_ADMIN))
8151 {
8152 return -EPERM;
8153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 // we must be associated in order to add a tspec
8155 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8156 {
8157 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8158 return 0;
8159 }
8160
8161 // since we are defined to be a "get" ioctl, and since the number
8162 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308163 // will pass down in the iwreq_data, we must copy the "set" params.
8164 // We must handle the compat for iwreq_data in 32U/64K environment.
8165
8166 // helper fucntion to get iwreq_data with compat handling.
8167 if (hdd_priv_get_data(&s_priv_data, wrqu))
8168 {
8169 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8170 return 0;
8171 }
8172
8173 // make sure all params are correctly passed to function
8174 if ((NULL == s_priv_data.pointer) ||
8175 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8176 {
8177 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8178 return 0;
8179 }
8180
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308182 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 {
8184 // hmmm, can't get them
8185 return -EIO;
8186 }
8187
8188 // clear the tspec
8189 memset(&tSpec, 0, sizeof(tSpec));
8190
8191 // validate the handle
8192 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8193 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8194 {
8195 // that one is reserved
8196 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8197 return 0;
8198 }
8199
8200 // validate the TID
8201 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8202 {
8203 // out of range
8204 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8205 return 0;
8206 }
8207 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8208
8209 // validate the direction
8210 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8211 {
8212 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8213 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8214 break;
8215
8216 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8217 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8218 break;
8219
8220 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8221 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8222 break;
8223
8224 default:
8225 // unknown
8226 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8227 return 0;
8228 }
8229
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308230 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8231
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 // validate the user priority
8233 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8234 {
8235 // out of range
8236 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8237 return 0;
8238 }
8239 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308240 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8241 {
8242 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8243 return 0;
8244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008245
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8247 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8248 tSpec.ts_info.psb, tSpec.ts_info.up);
8249
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8251 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8252 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8253 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8254 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8255 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8256 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8257 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8258 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8259 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8260 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8261 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8262
8263 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8264
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308265 // Save the expected UAPSD settings by application, this will be needed
8266 // when re-negotiating UAPSD settings during BT Coex cases.
8267 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8268
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 // validate the ts info ack policy
8270 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8271 {
8272 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8273 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8274 break;
8275
8276 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8277 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8278 break;
8279
8280 default:
8281 // unknown
8282 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8283 return 0;
8284 }
8285
8286 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308287
8288 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 return 0;
8290}
8291
8292
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308293static int iw_add_tspec(struct net_device *dev,
8294 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 union iwreq_data *wrqu, char *extra)
8296{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308297 int ret;
8298
8299 vos_ssr_protect(__func__);
8300 ret = __iw_add_tspec(dev, info, wrqu, extra);
8301 vos_ssr_unprotect(__func__);
8302
8303 return ret;
8304}
8305
8306static int __iw_del_tspec(struct net_device *dev,
8307 struct iw_request_info *info,
8308 union iwreq_data *wrqu, char *extra)
8309{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308310 hdd_adapter_t *pAdapter;
8311 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 int *params = (int *)extra;
8313 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8314 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308315 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008316
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308317 ENTER();
8318
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308319 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8320 if (NULL == pAdapter)
8321 {
8322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8323 "%s: Adapter is NULL",__func__);
8324 return -EINVAL;
8325 }
8326
8327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8328 ret = wlan_hdd_validate_context(pHddCtx);
8329 if (0 != ret)
8330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308331 return ret;
8332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 // make sure the application is sufficiently priviledged
8334 // note that the kernel will do this for "set" ioctls, but since
8335 // this ioctl wants to return status to user space it must be
8336 // defined as a "get" ioctl
8337 if (!capable(CAP_NET_ADMIN))
8338 {
8339 return -EPERM;
8340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 // although we are defined to be a "get" ioctl, the params we require
8342 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8343 // is no need to copy the params from user space
8344
8345 // validate the handle
8346 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8347 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8348 {
8349 // that one is reserved
8350 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8351 return 0;
8352 }
8353
8354 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308355
8356 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 return 0;
8358}
8359
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308360static int iw_del_tspec(struct net_device *dev,
8361 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 union iwreq_data *wrqu, char *extra)
8363{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308364 int ret;
8365
8366 vos_ssr_protect(__func__);
8367 ret = __iw_del_tspec(dev, info, wrqu, extra);
8368 vos_ssr_unprotect(__func__);
8369
8370 return ret;
8371}
8372
8373
8374static int __iw_get_tspec(struct net_device *dev,
8375 struct iw_request_info *info,
8376 union iwreq_data *wrqu, char *extra)
8377{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308378 hdd_adapter_t *pAdapter;
8379 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 int *params = (int *)extra;
8381 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8382 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308383 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008384
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308385 ENTER();
8386
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 // although we are defined to be a "get" ioctl, the params we require
8388 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8389 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308390 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8391 if (NULL == pAdapter)
8392 {
8393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8394 "%s: Adapter is NULL",__func__);
8395 return -EINVAL;
8396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008397
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308398 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8399 ret = wlan_hdd_validate_context(pHddCtx);
8400 if (0 != ret)
8401 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308402 return ret;
8403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 // validate the handle
8405 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8406 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8407 {
8408 // that one is reserved
8409 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8410 return 0;
8411 }
8412
8413 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308414 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 return 0;
8416}
8417
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308418static int iw_get_tspec(struct net_device *dev,
8419 struct iw_request_info *info,
8420 union iwreq_data *wrqu, char *extra)
8421{
8422 int ret;
8423
8424 vos_ssr_protect(__func__);
8425 ret = __iw_get_tspec(dev, info, wrqu, extra);
8426 vos_ssr_unprotect(__func__);
8427
8428 return ret;
8429}
8430
Manjeet Singh3ed79242017-01-11 19:04:32 +05308431/**
8432 * __iw_setnone_get_threeint() - return three value to up layer.
8433 *
8434 * @dev: pointer of net_device of this wireless card
8435 * @info: meta data about Request sent
8436 * @wrqu: include request info
8437 * @extra: buf used for in/Output
8438 *
8439 * Return: execute result
8440 */
8441static int __iw_setnone_get_threeint(struct net_device *dev,
8442 struct iw_request_info *info,
8443 union iwreq_data *wrqu, char *extra)
8444{
8445 int ret = 0; /* success */
8446 uint32_t *value = (int *)extra;
8447 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8448
8449 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8450
8451 switch (value[0]) {
8452 case WE_GET_TSF:
8453 ret = hdd_indicate_tsf(adapter, value, 3);
8454 break;
8455 default:
8456 hddLog(VOS_TRACE_LEVEL_ERROR,
8457 FL("Invalid IOCTL get_value command %d"),
8458 value[0]);
8459 break;
8460 }
8461 return ret;
8462}
8463
8464/**
8465 * iw_setnone_get_threeint() - return three value to up layer.
8466 *
8467 * @dev: pointer of net_device of this wireless card
8468 * @info: meta data about Request sent
8469 * @wrqu: include request info
8470 * @extra: buf used for in/Output
8471 *
8472 * Return: execute result
8473 */
8474static int iw_setnone_get_threeint(struct net_device *dev,
8475 struct iw_request_info *info,
8476 union iwreq_data *wrqu, char *extra)
8477{
8478 int ret;
8479
8480 vos_ssr_protect(__func__);
8481 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8482 vos_ssr_unprotect(__func__);
8483
8484 return ret;
8485}
8486
Jeff Johnson295189b2012-06-20 16:38:30 -07008487#ifdef WLAN_FEATURE_VOWIFI_11R
8488//
8489//
8490// Each time the supplicant has the auth_request or reassoc request
8491// IEs ready. This is pushed to the driver. The driver will inturn use
8492// it to send out the auth req and reassoc req for 11r FT Assoc.
8493//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308494static int __iw_set_fties(struct net_device *dev,
8495 struct iw_request_info *info,
8496 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008497{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308498 hdd_adapter_t *pAdapter;
8499 hdd_station_ctx_t *pHddStaCtx;
8500 hdd_context_t *pHddCtx;
8501 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008502 //v_CONTEXT_t pVosContext;
8503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308504 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308505 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8506 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008507 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8509 "%s: Adapter is NULL",__func__);
8510 return -EINVAL;
8511 }
8512 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8513 ret = wlan_hdd_validate_context(pHddCtx);
8514 if (0 != ret)
8515 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308516 return ret;
8517 }
8518 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8519 if (NULL == pHddStaCtx)
8520 {
8521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8522 "%s: STA Context is NULL",__func__);
8523 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 if (!wrqu->data.length)
8526 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008527 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 return -EINVAL;
8529 }
8530 if (wrqu->data.pointer == NULL)
8531 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008532 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 return -EINVAL;
8534 }
8535
8536 // Added for debug on reception of Re-assoc Req.
8537 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8538 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008539 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008541 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 }
8543
8544#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008545 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008546#endif
8547
8548 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008549 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 wrqu->data.length);
8551
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308552 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 return 0;
8554}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308555
8556static int iw_set_fties(struct net_device *dev,
8557 struct iw_request_info *info,
8558 union iwreq_data *wrqu, char *extra)
8559{
8560 int ret;
8561
8562 vos_ssr_protect(__func__);
8563 ret = __iw_set_fties(dev, info, wrqu, extra);
8564 vos_ssr_unprotect(__func__);
8565
8566 return ret;
8567}
Jeff Johnson295189b2012-06-20 16:38:30 -07008568#endif
8569
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308570static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008571 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008573{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308574 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008575 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308576 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008577 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308578 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008579 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8580 int idx;
8581 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008582
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308583 ENTER();
8584
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308585 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8586 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008587 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8589 "%s: Adapter is NULL",__func__);
8590 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008591 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308592 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8593 ret_val = wlan_hdd_validate_context(pHddCtx);
8594 if (0 != ret_val)
8595 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308596 return ret_val;
8597 }
8598 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8599 if (NULL == hHal)
8600 {
8601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8602 "%s: Hal Context is NULL",__func__);
8603 return -EINVAL;
8604 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308605 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8606 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308607#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008608
Amar Singhalf3a6e762013-02-19 15:06:50 -08008609 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8610 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008611 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008612 hddLog(VOS_TRACE_LEVEL_ERROR,
8613 "%s: vos_mem_alloc failed", __func__);
8614 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008615 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008616
8617 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8618
8619 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8620 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8621
8622 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8623 mc_addr_list_ptr->ulMulticastAddrCnt);
8624
8625 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008626 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008627 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8628 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8629
8630 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8631 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008632 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008633
Amar Singhalf3a6e762013-02-19 15:06:50 -08008634 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8635 vos_mem_free(mc_addr_list_ptr);
8636 if (eHAL_STATUS_SUCCESS != ret_val)
8637 {
8638 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8639 __func__);
8640 return -EINVAL;
8641 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308642#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308643 }
8644 else
8645 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008646
Amar Singhalf3a6e762013-02-19 15:06:50 -08008647 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8648 "%s: Set MC BC Filter Config request: %d suspend %d",
8649 __func__, pRequest->mcastBcastFilterSetting,
8650 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308651 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308652 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308653 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008654
8655 if (pHddCtx->hdd_wlan_suspended)
8656 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008657 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8658 if (NULL == wlanRxpFilterParam)
8659 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308660 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008661 "%s: vos_mem_alloc failed", __func__);
8662 return -EINVAL;
8663 }
8664
Amar Singhalf3a6e762013-02-19 15:06:50 -08008665 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8666 pRequest->mcastBcastFilterSetting;
8667 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308668 /* Fwr expect offload needs to clear before set */
8669 hdd_conf_hostoffload(pAdapter, FALSE);
8670 spin_lock(&pHddCtx->filter_lock);
8671 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8672 spin_unlock(&pHddCtx->filter_lock);
8673 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8674 {
8675 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8676 pHddCtx->sus_res_mcastbcast_filter =
8677 pRequest->mcastBcastFilterSetting;
8678 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008679
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308680 hdd_conf_hostoffload(pAdapter, TRUE);
8681 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8682 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008683
8684 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8685 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308686 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008687 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8688 wlanRxpFilterParam->setMcstBcstFilter);
8689
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308690 if (eHAL_STATUS_SUCCESS !=
8691 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8692 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008693 {
8694 hddLog(VOS_TRACE_LEVEL_ERROR,
8695 "%s: Failure to execute set HW MC/BC Filter request",
8696 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008697 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008698 return -EINVAL;
8699 }
8700
mukul sharmae4abd892016-11-24 22:03:31 +05308701 /* mc add list cfg item configuration in fwr */
8702 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008703 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008705
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308706 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 return 0;
8708}
8709
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308710static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8711 struct iw_request_info *info,
8712 union iwreq_data *wrqu, char *extra)
8713{
8714 int ret;
8715
8716 vos_ssr_protect(__func__);
8717 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8718 vos_ssr_unprotect(__func__);
8719
8720 return ret;
8721}
8722
8723static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8724 struct iw_request_info *info,
8725 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008726{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308727 hdd_adapter_t *pAdapter;
8728 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308729 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308730 int ret = 0;
8731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308732 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008733
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308734 if (!capable(CAP_NET_ADMIN))
8735 {
8736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8737 FL("permission check failed"));
8738 return -EPERM;
8739 }
8740
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8742 if (NULL == pAdapter)
8743 {
8744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8745 "%s: Adapter is NULL",__func__);
8746 return -EINVAL;
8747 }
8748
8749 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8750 ret = wlan_hdd_validate_context(pHddCtx);
8751 if (0 != ret)
8752 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308753 return ret;
8754 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308755 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308756 //Reset the filter to INI value as we have to clear the dynamic filter
8757 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308758 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008759
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308760 //Configure FW with new setting
8761 if (pHddCtx->hdd_wlan_suspended)
8762 {
8763 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8764 if (NULL == wlanRxpFilterParam)
8765 {
8766 hddLog(VOS_TRACE_LEVEL_ERROR,
8767 "%s: vos_mem_alloc failed", __func__);
8768 return -EINVAL;
8769 }
8770
8771 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8772 pHddCtx->configuredMcastBcastFilter;
8773 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308774 /* Fwr expect offload needs to clear before set */
8775 hdd_conf_hostoffload(pAdapter, FALSE);
8776 spin_lock(&pHddCtx->filter_lock);
8777 pHddCtx->configuredMcastBcastFilter =
8778 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8779 spin_unlock(&pHddCtx->filter_lock);
8780
8781 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8782 {
8783 pHddCtx->sus_res_mcastbcast_filter =
8784 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8785 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308786
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308787 hdd_conf_hostoffload(pAdapter, TRUE);
8788 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8789 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308790 if (eHAL_STATUS_SUCCESS !=
8791 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8792 wlanRxpFilterParam))
8793 {
8794 hddLog(VOS_TRACE_LEVEL_ERROR,
8795 "%s: Failure to execute set HW MC/BC Filter request",
8796 __func__);
8797 vos_mem_free(wlanRxpFilterParam);
8798 return -EINVAL;
8799 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308800
mukul sharmae4abd892016-11-24 22:03:31 +05308801 /* mc add list cfg item configuration in fwr */
8802 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308803 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308804 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 return 0;
8806}
8807
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308808
8809static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8810 struct iw_request_info *info,
8811 union iwreq_data *wrqu, char *extra)
8812{
8813 int ret;
8814
8815 vos_ssr_protect(__func__);
8816 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8817 vos_ssr_unprotect(__func__);
8818
8819 return ret;
8820}
8821
8822static int __iw_set_host_offload(struct net_device *dev,
8823 struct iw_request_info *info,
8824 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008825{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308826 hdd_adapter_t *pAdapter;
8827 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008828 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308830 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008831
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308832 ENTER();
8833
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308834 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8835 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008836 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8838 "%s: Adapter is NULL",__func__);
8839 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008840 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8842 ret = wlan_hdd_validate_context(pHddCtx);
8843 if (0 != ret)
8844 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308845 return ret;
8846 }
8847
Jeff Johnson295189b2012-06-20 16:38:30 -07008848 /* Debug display of request components. */
8849 switch (pRequest->offloadType)
8850 {
8851 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008852 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 switch (pRequest->enableOrDisable)
8854 {
8855 case WLAN_OFFLOAD_DISABLE:
8856 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8857 break;
8858 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8859 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8860 case WLAN_OFFLOAD_ENABLE:
8861 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8862 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8863 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8864 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8865 }
8866 break;
8867
8868 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008869 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008870 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 switch (pRequest->enableOrDisable)
8872 {
8873 case WLAN_OFFLOAD_DISABLE:
8874 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8875 break;
8876 case WLAN_OFFLOAD_ENABLE:
8877 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8878 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8879 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8880 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8881 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8882 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8883 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8884 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8885 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8886 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8887 }
8888 }
8889
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05308890 vos_mem_zero(&offloadRequest, sizeof(offloadRequest));
8891 offloadRequest.offloadType = pRequest->offloadType;
8892 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
8893 vos_mem_copy(&offloadRequest.params, &pRequest->params,
8894 sizeof(pRequest->params));
8895 vos_mem_copy(&offloadRequest.bssId, &pRequest->bssId.bytes,
8896 VOS_MAC_ADDRESS_LEN);
8897
Jeff Johnsone7245742012-09-05 17:12:55 -07008898 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8899 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 __func__);
8903 return -EINVAL;
8904 }
8905
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308906 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 return 0;
8908}
8909
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308910static int iw_set_host_offload(struct net_device *dev,
8911 struct iw_request_info *info,
8912 union iwreq_data *wrqu, char *extra)
8913{
8914 int ret;
8915
8916 vos_ssr_protect(__func__);
8917 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8918 vos_ssr_unprotect(__func__);
8919
8920 return ret;
8921}
8922
8923static int __iw_set_keepalive_params(struct net_device *dev,
8924 struct iw_request_info *info,
8925 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008926{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308927 hdd_adapter_t *pAdapter;
8928 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008929 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308931 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008932
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308933 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308934 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8935 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8938 "%s: Adapter is NULL",__func__);
8939 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8942 ret = wlan_hdd_validate_context(pHddCtx);
8943 if (0 != ret)
8944 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308945 return ret;
8946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008948 hddLog(VOS_TRACE_LEVEL_INFO,
8949 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8950 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008951
8952 switch (pRequest->packetType)
8953 {
8954 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008955 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 break;
8957
8958 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8959
Arif Hussain6d2a3322013-11-17 19:50:10 -08008960 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008961 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008962
8963 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8964 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8965 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8966
8967 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8968 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8969 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8970
8971 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8972 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8973 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8974 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8975 break;
8976
8977 }
8978
8979 /* Execute keep alive request. The reason that we can copy the request information
8980 from the ioctl structure to the SME structure is that they are laid out
8981 exactly the same. Otherwise, each piece of information would have to be
8982 copied individually. */
8983 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8984
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308985 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8986 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008987
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008988 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008989 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008991 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 __func__);
8993 return -EINVAL;
8994 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308995 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 return 0;
8997}
8998
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308999static int iw_set_keepalive_params(struct net_device *dev,
9000 struct iw_request_info *info,
9001 union iwreq_data *wrqu, char *extra)
9002{
9003 int ret;
9004 vos_ssr_protect(__func__);
9005 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9006 vos_ssr_unprotect(__func__);
9007
9008 return ret;
9009}
9010
Jeff Johnson295189b2012-06-20 16:38:30 -07009011#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309012/**-----------------------------------------------------------------
9013
9014 \brief hdd_pkt_filter_done - callback to be executed on completion
9015 successful/failure) for clear filter request.
9016
9017 \return - None
9018
9019 --------------------------------------------------------------------------*/
9020static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009021{
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309022 struct hdd_request *request;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309023
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309024 hddLog(VOS_TRACE_LEVEL_INFO,
9025 FL("Pkt Filter Clear Status : %d"), status);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309026
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309027 request = hdd_request_get(data);
9028 if (!request) {
9029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
9030 if (ioctl_debug)
9031 pr_info("%s: Obsolete request", __func__);
9032 return;
9033 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309034
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309035 hdd_request_complete(request);
9036 hdd_request_put(request);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309037}
9038
9039int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9040{
9041 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309042 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009043 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9044 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309045 int i=0, status;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309046 void *cookie;
9047 struct hdd_request *request;
9048 static const struct hdd_request_params params = {
9049 .priv_size = 0,
9050 .timeout_ms = PKT_FILTER_TIMEOUT,
9051 };
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309052
9053 status = wlan_hdd_validate_context(pHddCtx);
9054 if (0 != status)
9055 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009056
9057 if (pHddCtx->cfg_ini->disablePacketFilter)
9058 {
9059 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009060 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 return 0;
9062 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309063 if (pHddCtx->isLogpInProgress)
9064 {
9065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9066 "%s:LOGP in Progress. Ignore!!!", __func__);
9067 return -EBUSY;
9068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 /* Debug display of request components. */
9070 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009071 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009072
9073 switch (pRequest->filterAction)
9074 {
9075 case HDD_RCV_FILTER_SET:
9076 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009077 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009078
9079 packetFilterSetReq.filterId = pRequest->filterId;
9080 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9081 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009082 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 __func__, pRequest->numParams);
9084 return -EINVAL;
9085 }
9086 packetFilterSetReq.numFieldParams = pRequest->numParams;
9087 packetFilterSetReq.coalesceTime = 0;
9088 packetFilterSetReq.filterType = 1;
9089 for (i=0; i < pRequest->numParams; i++)
9090 {
9091 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9092 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9093 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9094 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9095 packetFilterSetReq.paramsData[i].reserved = 0;
9096
Arif Hussain6d2a3322013-11-17 19:50:10 -08009097 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9099 packetFilterSetReq.filterType);
9100
Arif Hussain6d2a3322013-11-17 19:50:10 -08009101 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309103 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9104 (pRequest->paramsData[i].dataLength))
9105 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009106
9107 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9108 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9109 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9110 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9111
Arif Hussain6d2a3322013-11-17 19:50:10 -08009112 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9114 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9115 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9116
Arif Hussain6d2a3322013-11-17 19:50:10 -08009117 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9119 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9120 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9121 }
9122
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309123 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009125 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009126 __func__);
9127 return -EINVAL;
9128 }
9129
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309130 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9131 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 break;
9133
9134 case HDD_RCV_FILTER_CLEAR:
9135
Arif Hussain6d2a3322013-11-17 19:50:10 -08009136 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009137 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309138
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309139 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9140 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9141 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9142 pHddStaCtx->conn_info.staId[0]);
9143 }
9144
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309145 request = hdd_request_alloc(&params);
9146 if (!request) {
9147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
9148 return VOS_STATUS_E_NOMEM;
9149 }
9150 cookie = hdd_request_cookie(request);
9151
9152 packetFilterClrReq.cbCtx = cookie;
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309154 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309155 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(
9156 pHddCtx->hHal,
9157 &packetFilterClrReq,
9158 pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009160 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 __func__);
Hanumanth Reddy Pothula249a2b02018-05-30 17:04:25 +05309162 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 return -EINVAL;
9164 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309165
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309166 status = hdd_request_wait_for_response(request);
9167 hdd_request_put(request);
9168 if (status)
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309169 {
9170 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9171 status);
9172 return -EINVAL;
9173 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309174
9175 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9176 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 break;
9178
9179 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009180 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009181 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 return -EINVAL;
9183 }
9184 return 0;
9185}
9186
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309187int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9188 tANI_U8 sessionId)
9189{
9190 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9191 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9192
9193 if (NULL == pHddCtx)
9194 {
9195 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9196 return -EINVAL;
9197 }
9198
9199 if (pHddCtx->isLogpInProgress)
9200 {
9201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9202 "%s:LOGP in Progress. Ignore!!!", __func__);
9203 return -EBUSY;
9204 }
9205
9206 if (pHddCtx->cfg_ini->disablePacketFilter)
9207 {
9208 hddLog(VOS_TRACE_LEVEL_ERROR,
9209 "%s: Packet Filtering Disabled. Returning ",
9210 __func__ );
9211 return -EINVAL;
9212 }
9213
9214 switch (filterType)
9215 {
9216 /* For setting IPV6 MC and UC Filter we need to configure
9217 * 2 filters, one for MC and one for UC.
9218 * The Filter ID shouldn't be swapped, which results in making
9219 * UC Filter ineffective.
9220 * We have Hardcode all the values
9221 *
9222 * Reason for a seperate UC filter is because, driver need to
9223 * specify the FW that the specific filter is for unicast
9224 * otherwise FW will not pass the unicast frames by default
9225 * through the filter. This is required to avoid any performance
9226 * hits when no unicast filter is set and only MC/BC are set.
9227 * The way driver informs host is by using the MAC protocol
9228 * layer, CMP flag set to MAX, CMP Data set to 1.
9229 */
9230
9231 case HDD_FILTER_IPV6_MC_UC:
9232 /* Setting IPV6 MC Filter below
9233 */
9234 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9235 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9236 packetFilterSetReq.numFieldParams = 2;
9237 packetFilterSetReq.paramsData[0].protocolLayer =
9238 HDD_FILTER_PROTO_TYPE_MAC;
9239 packetFilterSetReq.paramsData[0].cmpFlag =
9240 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9241 packetFilterSetReq.paramsData[0].dataOffset =
9242 WLAN_HDD_80211_FRM_DA_OFFSET;
9243 packetFilterSetReq.paramsData[0].dataLength = 1;
9244 packetFilterSetReq.paramsData[0].compareData[0] =
9245 HDD_IPV6_MC_CMP_DATA;
9246
9247 packetFilterSetReq.paramsData[1].protocolLayer =
9248 HDD_FILTER_PROTO_TYPE_ARP;
9249 packetFilterSetReq.paramsData[1].cmpFlag =
9250 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9251 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9252 packetFilterSetReq.paramsData[1].dataLength = 2;
9253 packetFilterSetReq.paramsData[1].compareData[0] =
9254 HDD_IPV6_CMP_DATA_0;
9255 packetFilterSetReq.paramsData[1].compareData[1] =
9256 HDD_IPV6_CMP_DATA_1;
9257
9258
9259 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9260 &packetFilterSetReq, sessionId))
9261 {
9262 hddLog(VOS_TRACE_LEVEL_ERROR,
9263 "%s: Failure to execute Set IPv6 Mulicast Filter",
9264 __func__);
9265 return -EINVAL;
9266 }
9267
9268 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9269
9270 /*
9271 * Setting IPV6 UC Filter below
9272 */
9273 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9274 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9275 packetFilterSetReq.numFieldParams = 2;
9276 packetFilterSetReq.paramsData[0].protocolLayer =
9277 HDD_FILTER_PROTO_TYPE_MAC;
9278 packetFilterSetReq.paramsData[0].cmpFlag =
9279 HDD_FILTER_CMP_TYPE_MAX;
9280 packetFilterSetReq.paramsData[0].dataOffset = 0;
9281 packetFilterSetReq.paramsData[0].dataLength = 1;
9282 packetFilterSetReq.paramsData[0].compareData[0] =
9283 HDD_IPV6_UC_CMP_DATA;
9284
9285 packetFilterSetReq.paramsData[1].protocolLayer =
9286 HDD_FILTER_PROTO_TYPE_ARP;
9287 packetFilterSetReq.paramsData[1].cmpFlag =
9288 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9289 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9290 packetFilterSetReq.paramsData[1].dataLength = 2;
9291 packetFilterSetReq.paramsData[1].compareData[0] =
9292 HDD_IPV6_CMP_DATA_0;
9293 packetFilterSetReq.paramsData[1].compareData[1] =
9294 HDD_IPV6_CMP_DATA_1;
9295
9296 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9297 &packetFilterSetReq, sessionId))
9298 {
9299 hddLog(VOS_TRACE_LEVEL_ERROR,
9300 "%s: Failure to execute Set IPv6 Unicast Filter",
9301 __func__);
9302 return -EINVAL;
9303 }
9304
9305 break;
9306
9307 case HDD_FILTER_IPV6_MC:
9308 /*
9309 * IPV6 UC Filter might be already set,
9310 * clear the UC Filter. As the Filter
9311 * IDs are static, we can directly clear it.
9312 */
9313 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9314 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9315 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9316 &packetFilterClrReq, sessionId))
9317 {
9318 hddLog(VOS_TRACE_LEVEL_ERROR,
9319 "%s: Failure to execute Clear IPv6 Unicast Filter",
9320 __func__);
9321 return -EINVAL;
9322 }
9323
9324 /*
9325 * Setting IPV6 MC Filter below
9326 */
9327 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9328 packetFilterSetReq.numFieldParams = 2;
9329 packetFilterSetReq.paramsData[0].protocolLayer =
9330 HDD_FILTER_PROTO_TYPE_MAC;
9331 packetFilterSetReq.paramsData[0].cmpFlag =
9332 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9333 packetFilterSetReq.paramsData[0].dataOffset =
9334 WLAN_HDD_80211_FRM_DA_OFFSET;
9335 packetFilterSetReq.paramsData[0].dataLength = 1;
9336 packetFilterSetReq.paramsData[0].compareData[0] =
9337 HDD_IPV6_MC_CMP_DATA;
9338
9339 packetFilterSetReq.paramsData[1].protocolLayer =
9340 HDD_FILTER_PROTO_TYPE_ARP;
9341 packetFilterSetReq.paramsData[1].cmpFlag =
9342 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9343 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9344 packetFilterSetReq.paramsData[1].dataLength = 2;
9345 packetFilterSetReq.paramsData[1].compareData[0] =
9346 HDD_IPV6_CMP_DATA_0;
9347 packetFilterSetReq.paramsData[1].compareData[1] =
9348 HDD_IPV6_CMP_DATA_1;
9349
9350
9351 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9352 &packetFilterSetReq, sessionId))
9353 {
9354 hddLog(VOS_TRACE_LEVEL_ERROR,
9355 "%s: Failure to execute Set IPv6 Multicast Filter",
9356 __func__);
9357 return -EINVAL;
9358 }
9359 break;
9360
9361 default :
9362 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9363 "%s: Packet Filter Request: Invalid",
9364 __func__);
9365 return -EINVAL;
9366 }
9367 return 0;
9368}
9369
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309370void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009371{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309372 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309373 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009374 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309375 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009376
Yue Ma3ede6052013-08-29 00:33:26 -07009377 if (NULL == pHddCtx)
9378 {
9379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9380 return;
9381 }
9382
9383 hHal = pHddCtx->hHal;
9384
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309385 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9388 return;
9389 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309390
9391 /* Check if INI is enabled or not, other wise just return
9392 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309393 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309394 {
9395 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9396 if (NULL == pMulticastAddrs)
9397 {
9398 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9399 return;
9400 }
9401
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 if (set)
9403 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309404 /* Following pre-conditions should be satisfied before wei
9405 * configure the MC address list.
9406 */
9407 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9408 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9409 && pAdapter->mc_addr_list.mc_cnt
9410 && (eConnectionState_Associated ==
9411 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9412 {
9413 pMulticastAddrs->ulMulticastAddrCnt =
9414 pAdapter->mc_addr_list.mc_cnt;
9415 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9416 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009417 memcpy(pMulticastAddrs->multicastAddr[i],
9418 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309419 sizeof(pAdapter->mc_addr_list.addr[i]));
9420 hddLog(VOS_TRACE_LEVEL_INFO,
9421 "%s: %s multicast filter: addr ="
9422 MAC_ADDRESS_STR,
9423 __func__, set ? "setting" : "clearing",
9424 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9425 }
9426 /* Set multicast filter */
9427 sme_8023MulticastList(hHal, pAdapter->sessionId,
9428 pMulticastAddrs);
9429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309431 else
9432 {
9433 /* Need to clear only if it was previously configured
9434 */
9435 if (pAdapter->mc_addr_list.isFilterApplied)
9436 {
9437 pMulticastAddrs->ulMulticastAddrCnt = 0;
9438 sme_8023MulticastList(hHal, pAdapter->sessionId,
9439 pMulticastAddrs);
9440 }
9441
9442 }
9443 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009444 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309446 else
9447 {
9448 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309449 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309450 }
9451 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009452}
9453
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309454static int __iw_set_packet_filter_params(struct net_device *dev,
9455 struct iw_request_info *info,
9456 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309457{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309458 hdd_adapter_t *pAdapter;
9459 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009460 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309461 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309462 struct iw_point s_priv_data;
9463
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309464 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309465
9466 if (!capable(CAP_NET_ADMIN))
9467 {
9468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9469 FL("permission check failed"));
9470 return -EPERM;
9471 }
9472
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309473 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9474 if (NULL == pAdapter)
9475 {
9476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9477 "%s: Adapter is NULL",__func__);
9478 return -EINVAL;
9479 }
9480 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9481 ret = wlan_hdd_validate_context(pHddCtx);
9482 if (0 != ret)
9483 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309484 return ret;
9485 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309486 if (hdd_priv_get_data(&s_priv_data, wrqu))
9487 {
9488 return -EINVAL;
9489 }
9490
9491 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9492 {
9493 return -EINVAL;
9494 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009495
Arif Hussain0273cba2014-01-07 20:58:29 -08009496 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309497 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9498 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009499 if (NULL == pRequest)
9500 {
9501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9502 "mem_alloc_copy_from_user_helper fail");
9503 return -ENOMEM;
9504 }
9505
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309506 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009507 kfree(pRequest);
9508
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309509 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009510 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009511}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309512
9513static int iw_set_packet_filter_params(struct net_device *dev,
9514 struct iw_request_info *info,
9515 union iwreq_data *wrqu, char *extra)
9516{
9517 int ret;
9518
9519 vos_ssr_protect(__func__);
9520 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9521 vos_ssr_unprotect(__func__);
9522
9523 return ret;
9524}
Jeff Johnson295189b2012-06-20 16:38:30 -07009525#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309526static int __iw_get_statistics(struct net_device *dev,
9527 struct iw_request_info *info,
9528 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009529{
9530
9531 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9532 eHalStatus status = eHAL_STATUS_SUCCESS;
9533 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309534 hdd_adapter_t *pAdapter;
9535 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309537 int tlen = 0, ret = 0;
9538 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009539
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309540 tCsrGlobalClassAStatsInfo *aStats;
9541 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009542
9543 ENTER();
9544
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309545 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9546 if (NULL == pAdapter)
9547 {
9548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9549 "%s: Adapter is NULL",__func__);
9550 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309552 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9553 ret = wlan_hdd_validate_context(pHddCtx);
9554 if (0 != ret)
9555 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309556 return ret;
9557 }
9558 pStats = &(pAdapter->hdd_stats.summary_stat);
9559 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9560 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9562
9563 wrqu->txpower.value = 0;
9564 }
9565 else {
9566 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9567 SME_SUMMARY_STATS |
9568 SME_GLOBAL_CLASSA_STATS |
9569 SME_GLOBAL_CLASSB_STATS |
9570 SME_GLOBAL_CLASSC_STATS |
9571 SME_GLOBAL_CLASSD_STATS |
9572 SME_PER_STA_STATS,
9573 hdd_StatisticsCB, 0, FALSE,
9574 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9575
9576 if (eHAL_STATUS_SUCCESS != status)
9577 {
9578 hddLog(VOS_TRACE_LEVEL_ERROR,
9579 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009580 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 return -EINVAL;
9582 }
9583
9584 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309585 if (NULL == pWextState)
9586 {
9587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9588 "%s: pWextState is NULL",__func__);
9589 return -EINVAL;
9590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009591
9592 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9593 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9594 {
9595 hddLog(VOS_TRACE_LEVEL_ERROR,
9596 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009597 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 /*Remove the SME statistics list by passing NULL in callback argument*/
9599 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9600 SME_SUMMARY_STATS |
9601 SME_GLOBAL_CLASSA_STATS |
9602 SME_GLOBAL_CLASSB_STATS |
9603 SME_GLOBAL_CLASSC_STATS |
9604 SME_GLOBAL_CLASSD_STATS |
9605 SME_PER_STA_STATS,
9606 NULL, 0, FALSE,
9607 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9608
9609 return -EINVAL;
9610 }
9611 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9612 (tANI_U8) sizeof (pStats->retry_cnt),
9613 (char*) &(pStats->retry_cnt[0]),
9614 tlen);
9615
9616 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9617 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9618 (char*) &(pStats->multiple_retry_cnt[0]),
9619 tlen);
9620
9621 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9622 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9623 (char*) &(pStats->tx_frm_cnt[0]),
9624 tlen);
9625
9626 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9627 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9628 (char*) &(pStats->rx_frm_cnt),
9629 tlen);
9630
9631 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9632 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9633 (char*) &(pStats->frm_dup_cnt),
9634 tlen);
9635
9636 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9637 (tANI_U8) sizeof (pStats->fail_cnt),
9638 (char*) &(pStats->fail_cnt[0]),
9639 tlen);
9640
9641 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9642 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9643 (char*) &(pStats->rts_fail_cnt),
9644 tlen);
9645
9646 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9647 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9648 (char*) &(pStats->ack_fail_cnt),
9649 tlen);
9650
9651 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9652 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9653 (char*) &(pStats->rts_succ_cnt),
9654 tlen);
9655
9656 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9657 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9658 (char*) &(pStats->rx_discard_cnt),
9659 tlen);
9660
9661 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9662 (tANI_U8) sizeof (pStats->rx_error_cnt),
9663 (char*) &(pStats->rx_error_cnt),
9664 tlen);
9665
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009666 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009667 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009668 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 tlen);
9670
9671 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9672 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9673 (char*) &(dStats->rx_byte_cnt),
9674 tlen);
9675
9676 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9677 (tANI_U8) sizeof (dStats->rx_rate),
9678 (char*) &(dStats->rx_rate),
9679 tlen);
9680
9681 /* Transmit rate, in units of 500 kbit/sec */
9682 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9683 (tANI_U8) sizeof (aStats->tx_rate),
9684 (char*) &(aStats->tx_rate),
9685 tlen);
9686
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009687 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9688 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9689 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009690 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009691 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9692 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9693 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009694 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009695 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9696 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9697 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009698 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009699 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9700 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9701 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009702 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009703 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9704 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9705 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009706 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009707 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9708 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9709 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009710 tlen);
9711
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 wrqu->data.length = tlen;
9713
9714 }
9715
9716 EXIT();
9717
9718 return 0;
9719}
9720
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309721static int iw_get_statistics(struct net_device *dev,
9722 struct iw_request_info *info,
9723 union iwreq_data *wrqu, char *extra)
9724{
9725 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009726
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309727 vos_ssr_protect(__func__);
9728 ret = __iw_get_statistics(dev, info, wrqu, extra);
9729 vos_ssr_unprotect(__func__);
9730
9731 return ret;
9732}
Jeff Johnson295189b2012-06-20 16:38:30 -07009733#ifdef FEATURE_WLAN_SCAN_PNO
Jeff Johnson295189b2012-06-20 16:38:30 -07009734VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9735 union iwreq_data *wrqu, char *extra, int nOffset)
9736{
9737 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9738 v_U8_t rssiThreshold = 0;
9739 v_U8_t nRead;
9740
Arif Hussain7adce1b2013-11-11 22:59:34 -08009741 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 &rssiThreshold);
9743
9744 if ( 1 != nRead )
9745 {
9746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9747 "Incorrect format");
9748 return VOS_STATUS_E_FAILURE;
9749 }
9750
9751 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9752 return VOS_STATUS_SUCCESS;
9753}
Jeff Johnson295189b2012-06-20 16:38:30 -07009754#endif /*FEATURE_WLAN_SCAN_PNO*/
9755
9756//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309757int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009758{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309759 hdd_adapter_t *pAdapter;
9760 tHalHandle hHal;
9761 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309762 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309763 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309764 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309766 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309767 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309768 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309769
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309770 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309771 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9772 if (NULL == pAdapter)
9773 {
9774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9775 "%s: Adapter is NULL",__func__);
9776 return -EINVAL;
9777 }
9778 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9779 retval = wlan_hdd_validate_context(pHddCtx);
9780 if (0 != retval)
9781 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309782 return retval;
9783 }
9784 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9785 if (NULL == hHal)
9786 {
9787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9788 "%s: Hal Context is NULL",__func__);
9789 return -EINVAL;
9790 }
9791 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009792
Atul Mittal54378cb2014-04-02 16:51:50 +05309793 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 {
9795 case WLAN_HDD_UI_BAND_AUTO:
9796 band = eCSR_BAND_ALL;
9797 break;
9798 case WLAN_HDD_UI_BAND_5_GHZ:
9799 band = eCSR_BAND_5G;
9800 break;
9801 case WLAN_HDD_UI_BAND_2_4_GHZ:
9802 band = eCSR_BAND_24;
9803 break;
9804 default:
9805 band = eCSR_BAND_MAX;
9806 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309807 connectedBand =
9808 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009809
Atul Mittal54378cb2014-04-02 16:51:50 +05309810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009811 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009812
9813 if (band == eCSR_BAND_MAX)
9814 {
9815 /* Received change band request with invalid band value */
9816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309817 "%s: Invalid band value %u", __func__, ui_band);
9818 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 }
9820
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309821 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309822 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309823 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009825 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009826 band, pHddCtx->cfg_ini->nBandCapability);
9827 return -EIO;
9828 }
9829
Sushant Kaushik1165f872015-03-30 20:25:27 +05309830 if (band == eCSR_BAND_ALL)
9831 {
9832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9833 "received. Setting band same as ini value %d"),
9834 pHddCtx->cfg_ini->nBandCapability);
9835 band = pHddCtx->cfg_ini->nBandCapability;
9836 }
9837
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9839 {
9840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9841 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009842 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 return -EIO;
9844 }
9845
9846 if (currBand != band)
9847 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309848 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309849 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309850 /* Return failure if current country code is world regulatory domain*/
9851 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9852 pMac->scan.countryCodeCurrent[1] == '0') )
9853 {
9854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9855 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309856 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309857 return -EAGAIN;
9858 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309859 }
9860
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 /* Change band request received.
9862 * Abort pending scan requests, flush the existing scan results,
9863 * and change the band capability
9864 */
9865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9866 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009867 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009868
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309869 /* We need to change the band and flush the scan results here itself
9870 * as we may get timeout for disconnection in which we will return
9871 * with out doing any of these
9872 */
9873 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9874 {
9875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9876 "%s: failed to set the band value to %u ",
9877 __func__, band);
9878 return -EINVAL;
9879 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309880 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9881 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309882 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309883 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9884 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309885 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309886 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9887 * information available in NV so to get the channel information from kernel
9888 * we need to send regulatory hint for the currunt country
9889 * And to set the same country again we need to set the dummy country
9890 * first and then the actual country.
9891 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309892#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +05309893 if(curr_country[0] == '0' && curr_country[1] == '0')
9894 regulatory_hint_user("IN", NL80211_USER_REG_HINT_USER);
9895 else
Yeshwanth Sriram Guntuka88566212019-04-17 15:02:33 +05309896 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309897#else
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +05309898 if(curr_country[0] == '0' && curr_country[1] == '0')
9899 regulatory_hint_user("IN");
9900 else
9901 regulatory_hint_user("00");
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309902#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309903 wait_result = wait_for_completion_interruptible_timeout(
9904 &pHddCtx->linux_reg_req,
9905 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9906
9907 /* if the country information does not exist with the kernel,
9908 then the driver callback would not be called */
9909
9910 if (wait_result >= 0)
9911 {
9912 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9913 "runtime country code is found in kernel db");
9914 }
9915 else
9916 {
9917 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9918 "runtime country code is not found"
9919 " in kernel db");
9920 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309921
9922 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309923
9924 /*
9925 * Update 11dcountry and current country here as the hint
9926 * with 00 results in 11d and current country with 00
9927 */
9928 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9929 WNI_CFG_COUNTRY_CODE_LEN);
9930 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9931 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309932#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9933 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9934#else
9935 regulatory_hint_user(curr_country);
9936#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309937 wait_result = wait_for_completion_interruptible_timeout(
9938 &pHddCtx->linux_reg_req,
9939 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9940
9941 /* if the country information does not exist with the kernel,
9942 then the driver callback would not be called */
9943 if (wait_result >= 0)
9944 {
9945 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9946 "runtime country code is found in kernel db");
9947 }
9948 else
9949 {
9950 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9951 "runtime country code is not found"
9952 " in kernel db");
9953 }
9954
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309955 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309956 }
9957 else
9958 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309959#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309960 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9961 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309962#else
9963 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9964#endif
9965
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309966 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309967 pScanInfo = &pHddCtx->scan_info;
9968 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9969 {
9970 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9971 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9972 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309973 sme_FilterScanResults(hHal, pAdapter->sessionId);
9974
9975 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309976 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9977 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 eHalStatus status = eHAL_STATUS_SUCCESS;
9980 long lrc;
9981
9982 /* STA already connected on current band, So issue disconnect first,
9983 * then change the band*/
9984
9985 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309986 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309987 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009988
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9990
9991 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9992 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9993
Jeff Johnson43971f52012-07-17 12:26:56 -07009994 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 {
9996 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009997 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 __func__, (int)status );
9999 return -EINVAL;
10000 }
10001
10002 lrc = wait_for_completion_interruptible_timeout(
10003 &pAdapter->disconnect_comp_var,
10004 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10005
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010006 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010007
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010008 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010009 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010010
10011 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10012 }
10013 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010015 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010016 if (TRUE == pHddCtx->isSetBandByNL)
10017 return 0;
10018 else
10019 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010020}
10021
Atul Mittal54378cb2014-04-02 16:51:50 +053010022int hdd_setBand_helper(struct net_device *dev, const char *command)
10023{
10024 u8 band;
10025
10026 /*convert the band value from ascii to integer*/
10027 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10028
10029 return hdd_setBand(dev, band);
10030
10031}
10032
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010033static int __iw_set_band_config(struct net_device *dev,
10034 struct iw_request_info *info,
10035 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010036{
Atul Mittal54378cb2014-04-02 16:51:50 +053010037 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010038
Arif Hussain0273cba2014-01-07 20:58:29 -080010039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010040
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010041 if (!capable(CAP_NET_ADMIN))
10042 {
10043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10044 FL("permission check failed"));
10045 return -EPERM;
10046 }
10047
Atul Mittal54378cb2014-04-02 16:51:50 +053010048 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010049}
10050
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010051static int iw_set_band_config(struct net_device *dev,
10052 struct iw_request_info *info,
10053 union iwreq_data *wrqu, char *extra)
10054{
10055 int ret;
10056
10057 vos_ssr_protect(__func__);
10058 ret = __iw_set_band_config(dev, info, wrqu, extra);
10059 vos_ssr_unprotect(__func__);
10060
10061 return ret;
10062}
10063
c_manjeecfd1efb2015-09-25 19:32:34 +053010064static int get_fwr_memdump(struct net_device *dev,
10065 struct iw_request_info *info,
10066 union iwreq_data *wrqu, char *extra)
10067{
10068 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10069 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10070 int ret;
10071 ENTER();
10072 // HddCtx sanity
10073 ret = wlan_hdd_validate_context(pHddCtx);
10074 if (0 != ret)
10075 {
10076 return ret;
10077 }
10078 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10079 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10080 {
10081 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10082 return -EINVAL;
10083 }
10084 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10085
10086 EXIT();
10087 return ret;
10088}
10089
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010090static int __iw_set_power_params_priv(struct net_device *dev,
10091 struct iw_request_info *info,
10092 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010093{
Arif Hussain0273cba2014-01-07 20:58:29 -080010094 int ret;
10095 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010096
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10098 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010099
10100 if (!capable(CAP_NET_ADMIN))
10101 {
10102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10103 FL("permission check failed"));
10104 return -EPERM;
10105 }
10106
Arif Hussain0273cba2014-01-07 20:58:29 -080010107 /* ODD number is used for set, copy data using copy_from_user */
10108 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10109 wrqu->data.length);
10110 if (NULL == ptr)
10111 {
10112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10113 "mem_alloc_copy_from_user_helper fail");
10114 return -ENOMEM;
10115 }
10116
10117 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10118 kfree(ptr);
10119 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010120}
10121
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010122static int iw_set_power_params_priv(struct net_device *dev,
10123 struct iw_request_info *info,
10124 union iwreq_data *wrqu, char *extra)
10125{
10126 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010127
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010128 vos_ssr_protect(__func__);
10129 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10130 vos_ssr_unprotect(__func__);
10131
10132 return ret;
10133}
Jeff Johnson295189b2012-06-20 16:38:30 -070010134
10135/*string based input*/
10136VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10137 union iwreq_data *wrqu, char *extra, int nOffset)
10138{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010139 hdd_adapter_t *pAdapter;
10140 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 tSirSetPowerParamsReq powerRequest;
10142 char *ptr;
10143 v_U8_t ucType;
10144 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010145 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010147 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010148 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10149 if (NULL == pAdapter)
10150 {
10151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10152 "%s: Adapter is NULL",__func__);
10153 return -EINVAL;
10154 }
10155
10156 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10157 ret = wlan_hdd_validate_context(pHddCtx);
10158 if (0 != ret)
10159 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010160 return ret;
10161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10163 "Power Params data len %d data %s",
10164 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010165 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010166
10167 if (wrqu->data.length <= nOffset )
10168 {
10169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10170 return VOS_STATUS_E_FAILURE;
10171 }
10172
10173 uTotalSize = wrqu->data.length - nOffset;
10174
10175 /*-----------------------------------------------------------------------
10176 Input is string based and expected to be like this:
10177
10178 <param_type> <param_value> <param_type> <param_value> ...
10179
10180 e.g:
10181 1 2 2 3 3 0 4 1 5 1
10182
10183 e.g. setting just a few:
10184 1 2 4 1
10185
10186 parameter types:
10187 -----------------------------
10188 1 - Ignore DTIM
10189 2 - Listen Interval
10190 3 - Broadcast Multicas Filter
10191 4 - Beacon Early Termination
10192 5 - Beacon Early Termination Interval
10193 -----------------------------------------------------------------------*/
10194 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10195 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10196 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10197 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10198 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10199
Arif Hussain7adce1b2013-11-11 22:59:34 -080010200 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010201
10202 while ( uTotalSize )
10203 {
Wilson Yang6f971452013-10-08 15:00:00 -070010204 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10205 {
10206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10207 "Invalid input parameter type %s",ptr);
10208 return VOS_STATUS_E_FAILURE;
10209 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010210
10211 uTotalSize -= nOffset;
10212
10213 if (!uTotalSize)
10214 {
10215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010216 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 ucType, nOffset);
10218 return VOS_STATUS_E_FAILURE;
10219 }
10220
10221 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010222
Jeff Johnson02797792013-10-26 19:17:13 -070010223 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010224 {
10225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10226 "Invalid input parameter value %s",ptr);
10227 return VOS_STATUS_E_FAILURE;
10228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010229
10230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10231 "Power request parameter %d value %d offset %d",
10232 ucType, uValue, nOffset);
10233
10234 switch (ucType)
10235 {
10236 case eSIR_IGNORE_DTIM:
10237 powerRequest.uIgnoreDTIM = uValue;
10238 break;
10239 case eSIR_LISTEN_INTERVAL:
10240 powerRequest.uListenInterval = uValue;
10241 break;
10242 case eSIR_MCAST_BCAST_FILTER:
10243 powerRequest.uBcastMcastFilter = uValue;
10244 break;
10245 case eSIR_ENABLE_BET:
10246 powerRequest.uEnableBET = uValue;
10247 break;
10248 case eSIR_BET_INTERVAL:
10249 powerRequest.uBETInterval = uValue;
10250 break;
10251 default:
10252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010253 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 ucType, uValue, nOffset);
10255 return VOS_STATUS_E_FAILURE;
10256 }
10257
10258 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10260 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010261 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010263 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010264 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010265 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10266 {
10267 uTotalSize = 0;
10268 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010269
10270 }/*Go for as long as we have a valid string*/
10271
10272 /* put the device into full power*/
10273 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10274
10275 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010276 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010277
10278 /* put the device back to power save*/
10279 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10280
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010281 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 return VOS_STATUS_SUCCESS;
10283}/*iw_set_power_params*/
10284
Atul Mittalc0f739f2014-07-31 13:47:47 +053010285// tdlsoffchan
10286#ifdef FEATURE_WLAN_TDLS
10287
Atul Mittal87ec2422014-09-24 13:12:50 +053010288int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010289{
10290 if (offchannel < 0 || offchannel > 165)
10291 {
10292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10293 __func__, offchannel);
10294 return -1;
10295
10296 }
10297
10298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10299 __func__, tdlsOffCh, offchannel);
10300
10301 tdlsOffCh = offchannel;
10302 return 0;
10303}
10304
Atul Mittal87ec2422014-09-24 13:12:50 +053010305int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010306{
10307 if (offchanoffset == 0)
10308 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010309 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10311 __func__, tdlsOffChBwOffset);
10312
10313 return 0;
10314
10315 }
10316
10317 if ( offchanoffset == 40 )
10318 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010319 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10321 __func__, tdlsOffChBwOffset);
10322
10323 return 0;
10324
10325 }
10326 if (offchanoffset == -40)
10327 {
10328 tdlsOffChBwOffset = 3;
10329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10330 __func__, tdlsOffChBwOffset);
10331
10332 return 0;
10333
10334 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010335
10336 if ((offchanoffset == 80) &&
10337 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10338 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10339 {
10340 tdlsOffChBwOffset = 4;
10341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10342 "%s: change tdls secondary off channel offset to %u",
10343 __func__, tdlsOffChBwOffset);
10344
10345 return 0;
10346 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10348 __func__, offchanoffset);
10349 return -1;
10350}
10351
Atul Mittal87ec2422014-09-24 13:12:50 +053010352int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010353{
10354 hddTdlsPeer_t *connPeer = NULL;
10355 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10356 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010357 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010358 if (offchanmode < 0 || offchanmode > 4)
10359 {
10360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10361 "%s: Invalid tdls off channel mode %d",
10362 __func__, offchanmode);
10363 return -1;
10364 }
10365
10366 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10367 {
10368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10369 "%s: tdls off channel mode req in not associated state %d",
10370 __func__, offchanmode);
10371 return -1;
10372 }
10373
10374 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10375 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10376 {
10377 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010378 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010379 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010380 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010381 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10383 "%s: No TDLS Connected Peer", __func__);
10384 return -1;
10385 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010386 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010387 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010388 }
10389 else
10390 {
10391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10392 "%s: TDLS Connection not supported", __func__);
10393 return -1;
10394 }
10395
10396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10397 ("%s: TDLS Channel Switch in swmode=%d"),
10398 __func__, offchanmode);
10399
10400 switch (offchanmode)
10401 {
10402 case 1:/*Enable*/
10403 case 2:/*Disable*/
10404 {
10405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10406 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10407 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10408 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10409 {
10410
10411 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010412 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010413 tdlsOffCh, tdlsOffChBwOffset,
10414 offchanmode);
10415 }
10416 else
10417 {
10418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10419 "%s: TDLS Off Channel not supported", __func__);
10420 return -1;
10421 }
10422 break;
10423 }
10424 case 3:
10425 {
10426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10427 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10428 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10429
10430 break;
10431 }
10432 case 4:
10433 {
10434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10435 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10436 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10437 break;
10438 }
10439 default:
10440 {
10441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10442 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10443 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10444 break;
10445 }
10446
10447 }
10448
10449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10450 __func__, offchanmode);
10451 return 0;
10452}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010453#endif
10454
Jeff Johnson295189b2012-06-20 16:38:30 -070010455// Define the Wireless Extensions to the Linux Network Device structure
10456// A number of these routines are NULL (meaning they are not implemented.)
10457
10458static const iw_handler we_handler[] =
10459{
10460 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10461 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10462 (iw_handler) NULL, /* SIOCSIWNWID */
10463 (iw_handler) NULL, /* SIOCGIWNWID */
10464 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10465 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +053010466 (iw_handler) NULL, /* SIOCSIWMODE */
10467 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 (iw_handler) NULL, /* SIOCSIWSENS */
10469 (iw_handler) NULL, /* SIOCGIWSENS */
10470 (iw_handler) NULL, /* SIOCSIWRANGE */
10471 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010472 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 (iw_handler) NULL, /* SIOCGIWPRIV */
10474 (iw_handler) NULL, /* SIOCSIWSTATS */
10475 (iw_handler) NULL, /* SIOCGIWSTATS */
10476 iw_handler_set_spy, /* SIOCSIWSPY */
10477 iw_handler_get_spy, /* SIOCGIWSPY */
10478 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10479 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10480 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10481 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10482 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10483 (iw_handler) NULL, /* SIOCGIWAPLIST */
10484 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10485 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10486 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10487 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10488 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10489 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10490 (iw_handler) NULL, /* -- hole -- */
10491 (iw_handler) NULL, /* -- hole -- */
10492 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10493 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10494 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10495 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10496 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10497 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10498 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10499 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10500 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10501 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10502 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10503 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10504 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10505 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10506 (iw_handler) NULL, /* -- hole -- */
10507 (iw_handler) NULL, /* -- hole -- */
10508 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10509 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10510 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10511 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10512 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10513 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10514 (iw_handler) NULL, /* SIOCSIWPMKSA */
10515};
10516
10517static const iw_handler we_private[] = {
10518
10519 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10520 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10521 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10522 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10523 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10524 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010525 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10527 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10528 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053010529 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10530 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070010531#ifdef FEATURE_OEM_DATA_SUPPORT
10532 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10533 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10534#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010535
Jeff Johnson295189b2012-06-20 16:38:30 -070010536#ifdef WLAN_FEATURE_VOWIFI_11R
10537 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10538#endif
10539 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10540 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10541 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10542#ifdef WLAN_FEATURE_PACKET_FILTERING
10543 ,
10544 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10545#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 ,
10547 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10548 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10549 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10550 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010551 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010552};
10553
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053010554static const iw_handler we_mon_private[] = {
10555 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10556 iw_mon_setint_getnone,
10557};
10558
10559static const struct iw_priv_args we_mon_private_args[] = {
10560 {WE_SET_MONITOR_STATE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10561 0, "monitor"},
10562
10563 /* handlers for main ioctl */
10564 {WLAN_PRIV_SET_INT_GET_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10565 0, "" },
10566};
10567
Jeff Johnson295189b2012-06-20 16:38:30 -070010568/*Maximum command length can be only 15 */
10569static const struct iw_priv_args we_private_args[] = {
10570
Katya Nigamf0511f62015-05-05 16:40:57 +053010571 { WE_SET_MONITOR_STATE,
10572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10573 0, "monitor" },
10574
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 /* handlers for main ioctl */
10576 { WLAN_PRIV_SET_INT_GET_NONE,
10577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10578 0,
10579 "" },
10580
10581 /* handlers for sub-ioctl */
10582 { WE_SET_11D_STATE,
10583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10584 0,
10585 "set11Dstate" },
10586
10587 { WE_WOWL,
10588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10589 0,
10590 "wowl" },
10591
10592 { WE_SET_POWER,
10593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10594 0,
10595 "setPower" },
10596
10597 { WE_SET_MAX_ASSOC,
10598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10599 0,
10600 "setMaxAssoc" },
10601
10602 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10604 0,
10605 "setAutoChannel" },
10606
10607 { WE_SET_DATA_INACTIVITY_TO,
10608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10609 0,
10610 "inactivityTO" },
10611
10612 { WE_SET_MAX_TX_POWER,
10613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10614 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010615 "setMaxTxPower" },
10616
10617 { WE_SET_MAX_TX_POWER_2_4,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10619 0,
10620 "setTxMaxPower2G" },
10621
10622 { WE_SET_MAX_TX_POWER_5_0,
10623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10624 0,
10625 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010626
10627 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10628 * as well to keep same syntax as in SAP. Now onwards, STA
10629 * will support both */
10630 { WE_SET_MAX_TX_POWER,
10631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10632 0,
10633 "setTxMaxPower" },
10634
Jeff Johnson295189b2012-06-20 16:38:30 -070010635 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10636 * 1 = enable and 0 = disable */
10637 {
10638 WE_SET_HIGHER_DTIM_TRANSITION,
10639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10640 0,
10641 "setHDtimTransn" },
10642
10643 { WE_SET_TM_LEVEL,
10644 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010645 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010646 "setTmLevel" },
10647
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010648 { WE_ENABLE_STRICT_FCC_REG,
10649 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10650 0,
10651 "setStrictFCCreg" },
10652
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010653 { WE_SET_DEBUG_LOG,
10654 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10655 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010656#ifdef FEATURE_WLAN_TDLS
10657 {
10658 WE_SET_TDLS_OFF_CHAN,
10659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10660 0,
10661 "tdlsoffchan" },
10662 {
10663 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10665 0,
10666 "tdlsecchnoffst" },
10667 {
10668 WE_SET_TDLS_OFF_CHAN_MODE,
10669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10670 0,
10671 "tdlsoffchnmode" },
10672#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010673
Peng Xu2446a892014-09-05 17:21:18 +053010674 { WE_SET_SCAN_BAND_PREFERENCE,
10675 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10676 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010677 {
10678 WE_GET_FRAME_LOG,
10679 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10680 0,
10681 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010682
Abhishek Singh01c73d12015-03-12 15:13:44 +053010683 { WE_SET_MIRACAST_VENDOR_CONFIG,
10684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10685 0, "setMiracstConf" },
10686
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010687#ifdef FEATURE_WLAN_TDLS
10688 {
10689 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10691 0,
10692 "tdls_2040bsscox" },
10693#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010694 { WE_SET_RTS_CTS_HTVHT,
10695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10696 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010697 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10698 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10699 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053010700 { WE_SET_PROXIMITY_ENABLE,
10701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10702 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053010703
10704#ifdef WLAN_FEATURE_TSF
10705 { WE_CAP_TSF,
10706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10707 0, "cap_tsf" },
10708#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053010709 { WE_SET_MODULATED_DTIM,
10710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10711 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053010712 {
10713 WLAN_SET_DYNNAMIC_AGGREGATION,
10714 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10715 0, "setAggregation" },
10716
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 /* handlers for main ioctl */
10718 { WLAN_PRIV_SET_NONE_GET_INT,
10719 0,
10720 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10721 "" },
10722
10723 /* handlers for sub-ioctl */
10724 { WE_GET_11D_STATE,
10725 0,
10726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10727 "get11Dstate" },
10728
10729 { WE_IBSS_STATUS,
10730 0,
10731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10732 "getAdhocStatus" },
10733
10734 { WE_PMC_STATE,
10735 0,
10736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10737 "pmcState" },
10738
10739 { WE_GET_WLAN_DBG,
10740 0,
10741 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10742 "getwlandbg" },
10743
Jeff Johnson295189b2012-06-20 16:38:30 -070010744 { WE_GET_MAX_ASSOC,
10745 0,
10746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10747 "getMaxAssoc" },
10748
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 { WE_GET_WDI_DBG,
10750 0,
10751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10752 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010753
10754 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10755 0,
10756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10757 "getAutoChannel" },
10758
10759 { WE_GET_CONCURRENCY_MODE,
10760 0,
10761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10762 "getconcurrency" },
10763
Peng Xu2446a892014-09-05 17:21:18 +053010764 { WE_GET_SCAN_BAND_PREFERENCE,
10765 0,
10766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10767 "get_scan_pref"},
10768
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053010769 { WE_GET_ANTENA_DIVERSITY_SELECTION,
10770 0,
10771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10772 "getCurAnt"},
10773
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 /* handlers for main ioctl */
10775 { WLAN_PRIV_SET_CHAR_GET_NONE,
10776 IW_PRIV_TYPE_CHAR| 512,
10777 0,
10778 "" },
10779
10780 /* handlers for sub-ioctl */
10781 { WE_WOWL_ADD_PTRN,
10782 IW_PRIV_TYPE_CHAR| 512,
10783 0,
10784 "wowlAddPtrn" },
10785
10786 { WE_WOWL_DEL_PTRN,
10787 IW_PRIV_TYPE_CHAR| 512,
10788 0,
10789 "wowlDelPtrn" },
10790
10791#if defined WLAN_FEATURE_VOWIFI
10792 /* handlers for sub-ioctl */
10793 { WE_NEIGHBOR_REPORT_REQUEST,
10794 IW_PRIV_TYPE_CHAR | 512,
10795 0,
10796 "neighbor" },
10797#endif
10798 { WE_SET_AP_WPS_IE,
10799 IW_PRIV_TYPE_CHAR| 512,
10800 0,
10801 "set_ap_wps_ie" },
10802
10803 { WE_SET_CONFIG,
10804 IW_PRIV_TYPE_CHAR| 512,
10805 0,
10806 "setConfig" },
10807
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010808 { WE_SET_ENCRYPT_MSG,
10809 IW_PRIV_TYPE_CHAR| 512,
10810 0,
10811 "encryptMsg" },
10812
10813
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 /* handlers for main ioctl */
10815 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10816 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10817 0,
10818 "" },
10819
10820 /* handlers for sub-ioctl */
10821 { WE_SET_WLAN_DBG,
10822 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10823 0,
10824 "setwlandbg" },
10825
Jeff Johnson295189b2012-06-20 16:38:30 -070010826 { WE_SET_WDI_DBG,
10827 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10828 0,
10829 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010830
10831 { WE_SET_SAP_CHANNELS,
10832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10833 0,
10834 "setsapchannels" },
10835
10836 /* handlers for main ioctl */
10837 { WLAN_PRIV_GET_CHAR_SET_NONE,
10838 0,
10839 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10840 "" },
10841
10842 /* handlers for sub-ioctl */
10843 { WE_WLAN_VERSION,
10844 0,
10845 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10846 "version" },
10847 { WE_GET_STATS,
10848 0,
10849 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10850 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010851 { WE_GET_STATES,
10852 0,
10853 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10854 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 { WE_GET_CFG,
10856 0,
10857 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10858 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010859#ifdef WLAN_FEATURE_11AC
10860 { WE_GET_RSSI,
10861 0,
10862 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10863 "getRSSI" },
10864#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010865#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010866 { WE_GET_ROAM_RSSI,
10867 0,
10868 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10869 "getRoamRSSI" },
10870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 { WE_GET_WMM_STATUS,
10872 0,
10873 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10874 "getWmmStatus" },
10875 {
10876 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010877 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10879 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010880#ifdef FEATURE_WLAN_TDLS
10881 {
10882 WE_GET_TDLS_PEERS,
10883 0,
10884 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10885 "getTdlsPeers" },
10886#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010887#ifdef WLAN_FEATURE_11W
10888 {
10889 WE_GET_11W_INFO,
10890 0,
10891 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10892 "getPMFInfo" },
10893#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053010894#ifdef WLAN_FEATURE_RMC
10895 {
10896 WE_GET_IBSS_STA_INFO,
10897 0,
10898 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10899 "getIbssSTAs" },
10900#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010901 { WE_GET_SNR,
10902 0,
10903 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10904 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053010905#ifdef FEATURE_OEM_DATA_SUPPORT
10906 {
10907 WE_GET_OEM_DATA_CAP,
10908 0,
10909 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10910 "getOemDataCap" },
10911#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 /* handlers for main ioctl */
10913 { WLAN_PRIV_SET_NONE_GET_NONE,
10914 0,
10915 0,
10916 "" },
10917
10918 /* handlers for sub-ioctl */
10919 { WE_CLEAR_STATS,
10920 0,
10921 0,
10922 "clearStats" },
10923 { WE_INIT_AP,
10924 0,
10925 0,
10926 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053010927#ifdef WLAN_FEATURE_RMC
10928 {
10929 WE_IBSS_GET_PEER_INFO_ALL,
10930 0,
10931 0,
10932 "ibssPeerInfoAll" },
10933#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 { WE_STOP_AP,
10935 0,
10936 0,
10937 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010938#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 { WE_ENABLE_AMP,
10940 0,
10941 0,
10942 "enableAMP" },
10943 { WE_DISABLE_AMP,
10944 0,
10945 0,
10946 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010947#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010948 { WE_ENABLE_DXE_STALL_DETECT,
10949 0,
10950 0,
10951 "dxeStallDetect" },
10952 { WE_DISPLAY_DXE_SNAP_SHOT,
10953 0,
10954 0,
10955 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010956 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10957 0,
10958 0,
10959 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010960 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010961 WE_SET_REASSOC_TRIGGER,
10962 0,
10963 0,
10964 "reassoc" },
10965 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010966 WE_STOP_OBSS_SCAN,
10967 0,
10968 0,
10969 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010970 {
10971 WE_DUMP_ROAM_TIMER_LOG,
10972 0,
10973 0,
10974 "dumpRoamDelay" },
10975 {
10976 WE_RESET_ROAM_TIMER_LOG,
10977 0,
10978 0,
10979 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010980 {
10981 WE_GET_FW_LOGS,
10982 0,
10983 0,
10984 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010985 {
10986 WE_GET_FW_MEMDUMP,
10987 0,
10988 0,
10989 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010990 /* handlers for main ioctl */
10991 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10992 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10993 0,
10994 "" },
10995
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010996
10997
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 /* handlers for sub-ioctl */
10999 { WE_LOG_DUMP_CMD,
11000 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11001 0,
11002 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011003#ifdef WLAN_FEATURE_RMC
11004 { WE_IBSS_GET_PEER_INFO,
11005 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11006 0,
11007 "ibssPeerInfo" },
11008#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011009
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011010 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011011 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11012 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11013 0,
11014 "setdumplog" },
11015
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011016 { WE_MTRACE_DUMP_CMD,
11017 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11018 0,
11019 "dumplog" },
11020
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011021 /* handlers for sub ioctl */
11022 {
11023 WE_MCC_CONFIG_CREDENTIAL,
11024 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11025 0,
11026 "setMccCrdnl" },
11027
11028 /* handlers for sub ioctl */
11029 {
11030 WE_MCC_CONFIG_PARAMS,
11031 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11032 0,
11033 "setMccConfig" },
11034
Chilam NG571c65a2013-01-19 12:27:36 +053011035#ifdef FEATURE_WLAN_TDLS
11036 /* handlers for sub ioctl */
11037 {
11038 WE_TDLS_CONFIG_PARAMS,
11039 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11040 0,
11041 "setTdlsConfig" },
11042#endif
11043
Katya Nigamf0511f62015-05-05 16:40:57 +053011044 {
11045 WE_CONFIGURE_MONITOR_MODE,
11046 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11047 0,
11048 "MonitorModeConf" },
11049
11050 {
11051 WE_SET_MONITOR_MODE_FILTER,
11052 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11053 0,
11054 "MonitorFilter" },
11055
Jeff Johnson295189b2012-06-20 16:38:30 -070011056 /* handlers for main ioctl */
11057 { WLAN_PRIV_ADD_TSPEC,
11058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11060 "addTspec" },
11061
11062 /* handlers for main ioctl */
11063 { WLAN_PRIV_DEL_TSPEC,
11064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11065 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11066 "delTspec" },
11067
11068 /* handlers for main ioctl */
11069 { WLAN_PRIV_GET_TSPEC,
11070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11071 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11072 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011073 /* handlers for main ioctl */
11074 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11075 0,
11076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11077 "" },
11078#ifdef WLAN_FEATURE_TSF
11079 { WE_GET_TSF,
11080 0,
11081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11082 "get_tsf" },
11083#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011084#ifdef FEATURE_OEM_DATA_SUPPORT
11085 /* handlers for main ioctl - OEM DATA */
11086 {
11087 WLAN_PRIV_SET_OEM_DATA_REQ,
11088 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11089 0,
11090 "set_oem_data_req" },
11091
11092 /* handlers for main ioctl - OEM DATA */
11093 {
11094 WLAN_PRIV_GET_OEM_DATA_RSP,
11095 0,
11096 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11097 "get_oem_data_rsp" },
11098#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011099
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 /* handlers for main ioctl - host offload */
11101 {
11102 WLAN_PRIV_SET_HOST_OFFLOAD,
11103 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11104 0,
11105 "setHostOffload" },
11106
11107 {
11108 WLAN_GET_WLAN_STATISTICS,
11109 0,
11110 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11111 "getWlanStats" },
11112
11113 {
11114 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011115 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11116 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 0,
11118 "setKeepAlive" },
11119#ifdef WLAN_FEATURE_PACKET_FILTERING
11120 {
11121 WLAN_SET_PACKET_FILTER_PARAMS,
11122 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11123 0,
11124 "setPktFilter" },
11125#endif
11126#ifdef FEATURE_WLAN_SCAN_PNO
11127 {
11128 WLAN_SET_PNO,
11129 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11130 0,
11131 "setpno" },
11132#endif
11133 {
11134 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011136 0,
11137 "SETBAND" },
11138 /* handlers for dynamic MC BC ioctl */
11139 {
11140 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011141 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011142 0,
11143 "setMCBCFilter" },
11144 {
11145 WLAN_PRIV_CLEAR_MCBC_FILTER,
11146 0,
11147 0,
11148 "clearMCBCFilter" },
11149 {
11150 WLAN_SET_POWER_PARAMS,
11151 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11152 0,
11153 "setpowerparams" },
11154 {
11155 WLAN_GET_LINK_SPEED,
11156 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011157 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011158 {
11159 WLAN_PRIV_SET_FTIES,
11160 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11161 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011162};
11163
11164
11165
11166const struct iw_handler_def we_handler_def = {
11167 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11168 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11169 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11170
11171 .standard = (iw_handler *)we_handler,
11172 .private = (iw_handler *)we_private,
11173 .private_args = we_private_args,
11174 .get_wireless_stats = get_wireless_stats,
11175};
11176
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011177const struct iw_handler_def we_mon_handler_def = {
11178 .num_standard = 0,
11179 .num_private = sizeof(we_mon_private) / sizeof(we_mon_private[0]),
11180 .num_private_args =
11181 sizeof(we_mon_private_args) / sizeof(we_mon_private_args[0]),
11182 .standard = NULL,
11183 .private = (iw_handler *)we_mon_private,
11184 .private_args = we_mon_private_args,
11185 .get_wireless_stats = NULL,
11186};
11187
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011188int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11189{
11190 v_U32_t cmd = 288; //Command to RIVA
11191 hdd_context_t *pHddCtx = NULL;
11192 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11193 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11194 /*
11195 *configMccParam : specify the bit which needs to be modified
11196 *allowed to update based on wlan_qcom_cfg.ini
11197 * configuration
11198 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11199 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11200 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11201 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11202 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11203 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11204 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11205 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11206 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11207 * Bit 9 : Reserved
11208 */
11209 switch (arg1)
11210 {
11211 //Update MCC SCHEDULE_TIME_SLICE parameter
11212 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11213 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11214 {
11215 if((arg2 >= 5) && (arg2 <= 20))
11216 {
11217 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11218 }
11219 else
11220 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011221 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011222 return 0;
11223 }
11224 }
11225 break;
11226
11227 //Update MCC MAX_NULL_SEND_TIME parameter
11228 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11229 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11230 {
11231 if((arg2 >= 1) && (arg2 <= 10))
11232 {
11233 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11234 }
11235 else
11236 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011237 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011238 return 0;
11239 }
11240 }
11241 break;
11242
11243 //Update MCC TX_EARLY_STOP_TIME parameter
11244 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11245 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11246 {
11247 if((arg2 >= 1) && (arg2 <= 10))
11248 {
11249 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11250 }
11251 else
11252 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011253 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011254 return 0;
11255 }
11256 }
11257 break;
11258
11259 //Update MCC RX_DRAIN_TIME parameter
11260 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11261 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11262 {
11263 if((arg2 >= 1) && (arg2 <= 10))
11264 {
11265 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11266 }
11267 else
11268 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011269 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011270 return 0;
11271 }
11272 }
11273 break;
11274
11275 //Update MCC CHANNEL_SWITCH_TIME parameter
11276 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11277 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11278 {
11279 if((arg2 >= 1) && (arg2 <= 20))
11280 {
11281 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11282 }
11283 else
11284 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011285 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011286 return 0;
11287 }
11288 }
11289 break;
11290
11291 //Update MCC MIN_CHANNEL_TIME parameter
11292 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11293 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11294 {
11295 if((arg2 >= 5) && (arg2 <= 20))
11296 {
11297 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11298 }
11299 else
11300 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011301 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011302 return 0;
11303 }
11304 }
11305 break;
11306
11307 //Update MCC PARK_BEFORE_TBTT parameter
11308 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11309 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11310 {
11311 if((arg2 >= 1) && (arg2 <= 5))
11312 {
11313 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11314 }
11315 else
11316 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011317 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011318 return 0;
11319 }
11320 }
11321 break;
11322
11323 //Update MCC MIN_AFTER_DTIM parameter
11324 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11325 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11326 {
11327 if((arg2 >= 5) && (arg2 <= 15))
11328 {
11329 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11330 }
11331 else
11332 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011333 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011334 return 0;
11335 }
11336 }
11337 break;
11338
11339 //Update MCC TOO_CLOSE_MARGIN parameter
11340 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11341 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11342 {
11343 if((arg2 >= 1) && (arg2 <= 3))
11344 {
11345 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11346 }
11347 else
11348 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011349 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011350 return 0;
11351 }
11352 }
11353 break;
11354
11355 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011356 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011357 __FUNCTION__,arg1);
11358 break;
11359 }
11360 return 0;
11361}
11362
Jeff Johnson295189b2012-06-20 16:38:30 -070011363int hdd_set_wext(hdd_adapter_t *pAdapter)
11364{
11365 hdd_wext_state_t *pwextBuf;
11366 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011367 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011368
11369 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11370
11371 // Now configure the roaming profile links. To SSID and bssid.
11372 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11373 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11374
11375 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11376 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11377
11378 /*Set the numOfChannels to zero to scan all the channels*/
11379 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11380 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11381
11382 /* Default is no encryption */
11383 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11384 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11385
11386 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11387 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11388
11389 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11390
11391 /* Default is no authentication */
11392 pwextBuf->roamProfile.AuthType.numEntries = 1;
11393 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11394
11395 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11396 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11397
11398 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011399 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011400
11401 hdd_clearRoamProfileIe(pAdapter);
11402
11403 return VOS_STATUS_SUCCESS;
11404
11405 }
11406
11407int hdd_register_wext(struct net_device *dev)
11408 {
11409 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11410 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11411 VOS_STATUS status;
11412
11413 ENTER();
11414
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011415 if (pAdapter->device_mode == WLAN_HDD_MONITOR &&
11416 hdd_get_conparam() != VOS_MONITOR_MODE) {
11417 // Register as a wireless device
11418 dev->wireless_handlers = (struct iw_handler_def *)&we_mon_handler_def;
11419 return 0;
11420 }
11421
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 // Zero the memory. This zeros the profile structure.
11423 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11424
11425 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11426
11427
11428 status = hdd_set_wext(pAdapter);
11429
11430 if(!VOS_IS_STATUS_SUCCESS(status)) {
11431
Arif Hussain6d2a3322013-11-17 19:50:10 -080011432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 return eHAL_STATUS_FAILURE;
11434 }
11435
11436 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11437 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 return eHAL_STATUS_FAILURE;
11440 }
11441
11442 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11443 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 return eHAL_STATUS_FAILURE;
11446 }
11447
11448 // Register as a wireless device
11449 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11450
11451 EXIT();
11452 return 0;
11453}
11454
11455int hdd_UnregisterWext(struct net_device *dev)
11456{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070011457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053011458 if (dev != NULL)
11459 {
11460 rtnl_lock();
11461 dev->wireless_handlers = NULL;
11462 rtnl_unlock();
11463 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011464
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 return 0;
11466}
11467
11468