blob: 1a855aa63295a914e2ed64effcd90150a9152a72 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530108#include "wlan_hdd_request_manager.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#ifdef CONFIG_HAS_EARLYSUSPEND
111extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
112extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
113#endif
114
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800116#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530120#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123// tdlsoffchan
124#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530125static int tdlsOffCh = 1;
126static int tdlsOffChBwOffset = 0;
127#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530128
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700129static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132/* To Validate Channel against the Frequency and Vice-Versa */
133static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
134 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
135 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
136 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
137 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
138 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
139 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
140 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800141 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
142 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800144#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146/* Private ioctls and their sub-ioctls */
147#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
148#define WE_SET_11D_STATE 1
149#define WE_WOWL 2
150#define WE_SET_POWER 3
151#define WE_SET_MAX_ASSOC 4
152#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
153#define WE_SET_DATA_INACTIVITY_TO 6
154#define WE_SET_MAX_TX_POWER 7
155#define WE_SET_HIGHER_DTIM_TRANSITION 8
156#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530157#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700158#define WE_SET_MAX_TX_POWER_2_4 11
159#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800160/* Private IOCTL for debug connection issues */
161#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530162// tdlsoffchan
163#ifdef FEATURE_WLAN_TDLS
164#define WE_SET_TDLS_OFF_CHAN 14
165#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
166#define WE_SET_TDLS_OFF_CHAN_MODE 16
167#endif
Peng Xu2446a892014-09-05 17:21:18 +0530168#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530169#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530170#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530171#ifdef FEATURE_WLAN_TDLS
172#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
173#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530174#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530175#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530176#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530177#define WE_SET_PROXIMITY_ENABLE 24
Manjeet Singh3ed79242017-01-11 19:04:32 +0530178#define WE_CAP_TSF 25
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +0530179#define WE_SET_MODULATED_DTIM 26
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530180#define WLAN_SET_DYNNAMIC_AGGREGATION 27
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
184#define WE_GET_11D_STATE 1
185#define WE_IBSS_STATUS 2
186#define WE_PMC_STATE 3
187#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700188#define WE_GET_MAX_ASSOC 6
189#define WE_GET_WDI_DBG 7
190#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
191#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530192#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530193#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700194/* Private ioctls and their sub-ioctls */
195#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
196
197/* Private ioctls and their sub-ioctls */
198#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
199#define WE_WOWL_ADD_PTRN 1
200#define WE_WOWL_DEL_PTRN 2
201#if defined WLAN_FEATURE_VOWIFI
202#define WE_NEIGHBOR_REPORT_REQUEST 3
203#endif
204#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
205#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530206#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208/* Private ioctls and their sub-ioctls */
209#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
210#define WE_SET_WLAN_DBG 1
211#define WE_SET_WDI_DBG 2
212#define WE_SET_SAP_CHANNELS 3
213
214/* Private ioctls and their sub-ioctls */
215#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
216#define WE_WLAN_VERSION 1
217#define WE_GET_STATS 2
218#define WE_GET_CFG 3
219#define WE_GET_WMM_STATUS 4
220#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700221#ifdef WLAN_FEATURE_11AC
222#define WE_GET_RSSI 6
223#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800224#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800225#ifdef FEATURE_WLAN_TDLS
226#define WE_GET_TDLS_PEERS 8
227#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700228#ifdef WLAN_FEATURE_11W
229#define WE_GET_11W_INFO 9
230#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530231#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530232#ifdef WLAN_FEATURE_RMC
233#define WE_GET_IBSS_STA_INFO 11
234#endif
235#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700236
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530237#ifdef FEATURE_OEM_DATA_SUPPORT
238#define WE_GET_OEM_DATA_CAP 13
239#endif
240
Jeff Johnson295189b2012-06-20 16:38:30 -0700241/* Private ioctls and their sub-ioctls */
242#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
243#define WE_CLEAR_STATS 1
244#define WE_INIT_AP 2
245#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530246#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700247#define WE_ENABLE_AMP 4
248#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530249#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700250#define WE_ENABLE_DXE_STALL_DETECT 6
251#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700252#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530253#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530254#ifdef WLAN_FEATURE_RMC
255#define WE_IBSS_GET_PEER_INFO_ALL 10
256#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530257#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530258#define WE_DUMP_ROAM_TIMER_LOG 12
259#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530260#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530261#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263/* Private ioctls and their sub-ioctls */
264#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
265#define WE_LOG_DUMP_CMD 1
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800268//IOCTL to configure MCC params
269#define WE_MCC_CONFIG_CREDENTIAL 3
270#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
Chilam NG571c65a2013-01-19 12:27:36 +0530272#ifdef FEATURE_WLAN_TDLS
273#define WE_TDLS_CONFIG_PARAMS 5
274#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530275#ifdef WLAN_FEATURE_RMC
276#define WE_IBSS_GET_PEER_INFO 6
277#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530278
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700279#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530280#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530281#define WE_CONFIGURE_MONITOR_MODE 10
282#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700283
Chilam Ng01120412013-02-19 18:32:21 -0800284#ifdef FEATURE_WLAN_TDLS
285#undef MAX_VAR_ARGS
286#define MAX_VAR_ARGS 10
287#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700288#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800289#endif
290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291/* Private ioctls (with no sub-ioctls) */
292/* note that they must be odd so that they have "get" semantics */
293#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
294#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
295#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
296
Girish Gowli464c9c82014-06-09 19:47:53 +0530297/* (SIOCIWFIRSTPRIV + 8) is currently unused */
298/* (SIOCIWFIRSTPRIV + 16) is currently unused */
299/* (SIOCIWFIRSTPRIV + 10) is currently unused */
300/* (SIOCIWFIRSTPRIV + 12) is currently unused */
301/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manjeet Singh3ed79242017-01-11 19:04:32 +0530302#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
303#define WE_GET_TSF 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700304
Jeff Johnsone7245742012-09-05 17:12:55 -0700305#ifdef FEATURE_OEM_DATA_SUPPORT
306/* Private ioctls for setting the measurement configuration */
307#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
308#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700310
311#ifdef WLAN_FEATURE_VOWIFI_11R
312#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
313#endif
314
315/* Private ioctl for setting the host offload feature */
316#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
317
318/* Private ioctl to get the statistics */
319#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
320
321/* Private ioctl to set the Keep Alive Params */
322#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
323#ifdef WLAN_FEATURE_PACKET_FILTERING
324/* Private ioctl to set the Packet Filtering Params */
325#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
326#endif
327
328#ifdef FEATURE_WLAN_SCAN_PNO
329/* Private ioctl to get the statistics */
330#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
331#endif
332
333#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
334
335#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
336#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700337/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700338
Jeff Johnson295189b2012-06-20 16:38:30 -0700339#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
340#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
341
342#define WLAN_STATS_INVALID 0
343#define WLAN_STATS_RETRY_CNT 1
344#define WLAN_STATS_MUL_RETRY_CNT 2
345#define WLAN_STATS_TX_FRM_CNT 3
346#define WLAN_STATS_RX_FRM_CNT 4
347#define WLAN_STATS_FRM_DUP_CNT 5
348#define WLAN_STATS_FAIL_CNT 6
349#define WLAN_STATS_RTS_FAIL_CNT 7
350#define WLAN_STATS_ACK_FAIL_CNT 8
351#define WLAN_STATS_RTS_SUC_CNT 9
352#define WLAN_STATS_RX_DISCARD_CNT 10
353#define WLAN_STATS_RX_ERROR_CNT 11
354#define WLAN_STATS_TX_BYTE_CNT 12
355
356#define WLAN_STATS_RX_BYTE_CNT 13
357#define WLAN_STATS_RX_RATE 14
358#define WLAN_STATS_TX_RATE 15
359
Jeff Johnsone7245742012-09-05 17:12:55 -0700360#define WLAN_STATS_RX_UC_BYTE_CNT 16
361#define WLAN_STATS_RX_MC_BYTE_CNT 17
362#define WLAN_STATS_RX_BC_BYTE_CNT 18
363#define WLAN_STATS_TX_UC_BYTE_CNT 19
364#define WLAN_STATS_TX_MC_BYTE_CNT 20
365#define WLAN_STATS_TX_BC_BYTE_CNT 21
366
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800367#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
368 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
369 { \
370 *__p++ = __type; \
371 *__p++ = __size; \
372 memcpy(__p, __val, __size); \
373 __p += __size; \
374 __tlen += __size + 2; \
375 } \
376 else \
377 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800378 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800379 } \
380 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382#define VERSION_VALUE_MAX_LEN 32
383
384#define TX_PER_TRACKING_DEFAULT_RATIO 5
385#define TX_PER_TRACKING_MAX_RATIO 10
386#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
387
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530388#define WLAN_ADAPTER 0
389#define P2P_ADAPTER 1
390
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530391#define TX_PWR_MIN 6
392#define TX_PWR_MAX 22
393#define TX_PWR_DEF 50
394
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530395/* Dynamic Aggregation */
396#define DISABLE_AGGREGATION 0
397#define ENABLE_AGGREGATION 1
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530398/*
399 * When supplicant sends SETBAND ioctl it queries for channels from
400 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
401 * This is not required if the return type from ioctl is
402 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
403 * event as part of regulatory_hint.
404 */
405enum {
406 SEND_CHANNEL_CHANGE_EVENT = 0,
407 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
408};
409
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800410/*MCC Configuration parameters */
411enum {
412 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
413 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
414 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
415 MCC_RX_DRAIN_TIME_CFG_PARAM,
416 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
417 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
418 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
419 MCC_MIN_AFTER_DTIM_CFG_PARAM,
420 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
421};
422
423int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
424 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
425
Jeff Johnson295189b2012-06-20 16:38:30 -0700426#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530427int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700428#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530429static int get_fwr_memdump(struct net_device *,
430 struct iw_request_info *,
431 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700432/**---------------------------------------------------------------------------
433
Arif Hussain0273cba2014-01-07 20:58:29 -0800434 \brief mem_alloc_copy_from_user_helper -
435
436 Helper function to allocate buffer and copy user data.
437
438 \param - wrqu - Pointer to IOCTL Data.
439 len - size
440
441 \return - On Success pointer to buffer, On failure NULL
442
443 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530444void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800445{
446 u8 *ptr = NULL;
447
448 /* in order to protect the code, an extra byte is post appended to the buffer
449 * and the null termination is added. However, when allocating (len+1) byte
450 * of memory, we need to make sure that there is no uint overflow when doing
451 * addition. In theory check len < UINT_MAX protects the uint overflow. For
452 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
453 * guess, now, it is assumed that the private command buffer size is no
454 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
455 */
456 if (len > MAX_USER_COMMAND_SIZE)
457 {
458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
459 "Invalid length");
460 return NULL;
461 }
462
463 ptr = kmalloc(len + 1, GFP_KERNEL);
464 if (NULL == ptr)
465 {
466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
467 "unable to allocate memory");
468 return NULL;
469 }
470
471 if (copy_from_user(ptr, wrqu_data, len))
472 {
473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
474 "%s: failed to copy data to user buffer", __func__);
475 kfree(ptr);
476 return NULL;
477 }
478 ptr[len] = '\0';
479 return ptr;
480}
481
Girish Gowli488ef492014-06-12 18:44:33 +0530482// Function to handle and get compatible struct iw_point passed to ioctl.
483int hdd_priv_get_data(struct iw_point *p_priv_data,
484 union iwreq_data *wrqu)
485{
486 if ((NULL == p_priv_data) || (NULL == wrqu))
487 {
488 return -EINVAL;
489 }
490
491#ifdef CONFIG_COMPAT
492 if (is_compat_task())
493 {
494 struct compat_iw_point *p_compat_priv_data;
495
496 // Compat task: typecast to campat structure and copy the members.
497 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
498
499 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
500 p_priv_data->length = p_compat_priv_data->length;
501 p_priv_data->flags = p_compat_priv_data->flags;
502 }//if(is_compat_task())
503 else
504 {
505#endif //#ifdef CONFIG_COMPAT
506
507 // Non compat task: directly copy the structure.
508 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
509
510#ifdef CONFIG_COMPAT
511 }//else of - if(is_compat_task())
512#endif //#ifdef CONFIG_COMPAT
513
514 return 0;
515}
516
Arif Hussain0273cba2014-01-07 20:58:29 -0800517/**---------------------------------------------------------------------------
518
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 \brief hdd_wlan_get_version() -
520
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800521 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523 \param - pAdapter Pointer to the adapter.
524 wrqu - Pointer to IOCTL REQUEST Data.
525 extra - Pointer to char
526
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800530void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
531 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700532{
533 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800534 tSirVersionString wcnss_SW_version;
535 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530536 tSirVersionString iris_name;
537 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800538 char *pSWversion;
539 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800542 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
543 sizeof(wcnss_SW_version));
544 if (VOS_IS_STATUS_SUCCESS(status))
545 {
546 pSWversion = wcnss_SW_version;
547 }
548 else
549 {
550 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 }
552
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800553 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
554 sizeof(wcnss_HW_version));
555 if (VOS_IS_STATUS_SUCCESS(status))
556 {
557 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800559 else
560 {
561 pHWversion = "Unknown";
562 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530564 status = wcnss_get_iris_name(iris_name);
565
566 if (!status) {
567 pIRISversion = iris_name;
568 } else {
569 pIRISversion = "Unknown";
570 }
571
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700572 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530573 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800574 QWLAN_VERSIONSTR,
575 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530576 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800577
578 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579}
580
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530581#ifdef WLAN_FEATURE_RMC
582void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
583{
584 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
585 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
586 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
587 v_U8_t i;
588
589 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
590 {
591 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
592 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
593 for (i = 0; i < pPeerInfo->numPeers; i++)
594 {
595 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
596 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
597 }
598 }
599 else
600 {
601 hddLog(LOGE,
602 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
603 }
604
605 complete(&pAdapter->ibss_peer_info_comp);
606}
607
608v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
609{
610 v_U8_t idx;
611 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
612
613 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
614 {
615 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
616 staIdx == pHddStaCtx->conn_info.staId[ idx ])
617 {
618 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
619 }
620 }
621 return NULL;
622}
623
624eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
625{
626 eHalStatus status = eHAL_STATUS_FAILURE;
627 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
628 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
629 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
630
631 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
632 VOS_FALSE, staIdx);
633
634 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
635
636 if (eHAL_STATUS_SUCCESS == status)
637 {
638 long ret;
639 ret = wait_for_completion_interruptible_timeout
640 (&pAdapter->ibss_peer_info_comp,
641 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
642 if (ret <= 0)
643 {
644 hddLog(VOS_TRACE_LEVEL_ERROR,
645 FL("failed wait on ibss_peer_info_comp %ld"), ret);
646 return eHAL_STATUS_FAILURE;
647 }
648
649 /** Print the peer info */
650 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
651 pr_info("============================================================");
652 {
653 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
654 staIdx);
655 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
656
657 if (NULL != macAddr)
658 {
659 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
660 MAC_ADDR_ARRAY(macAddr->bytes),
661 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
662 }
663 else
664 {
665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
666 " ERROR: PEER MAC ADDRESS NOT FOUND ");
667 }
668 }
669 }
670 else
671 {
672 hddLog(VOS_TRACE_LEVEL_WARN,
673 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
674 }
675
676 return status;
677}
678
679eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
680{
681 eHalStatus status = eHAL_STATUS_FAILURE;
682 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
683 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
684 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
685 int i;
686
687 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
688 VOS_TRUE, 0xFF);
689 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
690
691 if (eHAL_STATUS_SUCCESS == status)
692 {
693 long ret;
694 ret = wait_for_completion_interruptible_timeout
695 (&pAdapter->ibss_peer_info_comp,
696 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
697 if (ret <= 0)
698 {
699 hddLog(VOS_TRACE_LEVEL_ERROR,
700 FL("failed wait on ibss_peer_info_comp %ld"), ret);
701 return eHAL_STATUS_FAILURE;
702 }
703
704 /** Print the peer info */
705 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
706 pr_info("============================================================");
707 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
708 {
709 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
710 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
711 staIdx);
712 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
713
714 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
715 if (NULL != macAddr)
716 {
717 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
718 MAC_ADDR_ARRAY(macAddr->bytes),
719 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
720 }
721 else
722 {
723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
724 " ERROR: PEER MAC ADDRESS NOT FOUND ");
725 }
726 }
727 }
728 else
729 {
730 hddLog(VOS_TRACE_LEVEL_WARN,
731 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
732 }
733
734 return status;
735}
736#endif /* WLAN_FEATURE_RMC */
737
Jeff Johnson295189b2012-06-20 16:38:30 -0700738int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
739{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530740 tHalHandle hHal;
741 hdd_context_t *pHddCtx;
742 v_U32_t threshold = 0;
743 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700744
745 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530746 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530747 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
749 "%s: Adapter is NULL",__func__);
750 return -EINVAL;
751 }
752
753 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
754 ret = wlan_hdd_validate_context(pHddCtx);
755 if (0 != ret)
756 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530757 return ret;
758 }
759
760 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
761 if (NULL == hHal)
762 {
763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
764 "%s: Hal Context is NULL",__func__);
765 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 }
767
768 if ( eHAL_STATUS_SUCCESS !=
769 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
770 {
c_hpothub8245442013-11-20 23:41:09 +0530771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
772 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 return -EIO;
774 }
775 wrqu->rts.value = threshold;
776
777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800778 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779
780 EXIT();
781
782 return 0;
783}
784
785int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
786{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530787 tHalHandle hHal;
788 hdd_context_t *pHddCtx;
789 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790
791 ENTER();
792
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530793 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
796 "%s: Adapter is NULL",__func__);
797 return -EINVAL;
798 }
799
800 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
801 status = wlan_hdd_validate_context(pHddCtx);
802 if (0 != status)
803 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530804 return status;
805 }
806
807 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
808 if (NULL == hHal)
809 {
810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
811 "%s: Hal Context is NULL",__func__);
812 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 }
814
815 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
816 != eHAL_STATUS_SUCCESS )
817 {
c_hpothub8245442013-11-20 23:41:09 +0530818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
819 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 return -EIO;
821 }
822 wrqu->frag.value = threshold;
823
824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800825 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 EXIT();
828
829 return 0;
830}
831
832int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
833{
Jeff Johnsone7245742012-09-05 17:12:55 -0700834 int i;
835 if (channel > 0)
836 {
837 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
838 {
839 if (channel == freq_chan_map[i].chan)
840 {
841 *pfreq = freq_chan_map[i].freq;
842 return 1;
843 }
844 }
845 }
846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800847 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700848 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700849}
850
851static v_BOOL_t
852hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
853{
854 v_BOOL_t rsnType = VOS_FALSE;
855 // is the authType supported?
856 switch (authType)
857 {
858 case eCSR_AUTH_TYPE_NONE: //never used
859 rsnType = eANI_BOOLEAN_FALSE;
860 break;
861 // MAC layer authentication types
862 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
863 rsnType = eANI_BOOLEAN_FALSE;
864 break;
865 case eCSR_AUTH_TYPE_SHARED_KEY:
866 rsnType = eANI_BOOLEAN_FALSE;
867 break;
868 case eCSR_AUTH_TYPE_AUTOSWITCH:
869 rsnType = eANI_BOOLEAN_FALSE;
870 break;
871
872 // Upper layer authentication types
873 case eCSR_AUTH_TYPE_WPA:
874 rsnType = eANI_BOOLEAN_TRUE;
875 break;
876 case eCSR_AUTH_TYPE_WPA_PSK:
877 rsnType = eANI_BOOLEAN_TRUE;
878 break;
879 case eCSR_AUTH_TYPE_WPA_NONE:
880 rsnType = eANI_BOOLEAN_TRUE;
881 break;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 case eCSR_AUTH_TYPE_FT_RSN:
884#endif
885 case eCSR_AUTH_TYPE_RSN:
886 rsnType = eANI_BOOLEAN_TRUE;
887 break;
888#ifdef WLAN_FEATURE_VOWIFI_11R
889 case eCSR_AUTH_TYPE_FT_RSN_PSK:
890#endif
891 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700892#ifdef WLAN_FEATURE_11W
893 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530894 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 rsnType = eANI_BOOLEAN_TRUE;
897 break;
898 //case eCSR_AUTH_TYPE_FAILED:
899 case eCSR_AUTH_TYPE_UNKNOWN:
900 rsnType = eANI_BOOLEAN_FALSE;
901 break;
902 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800903 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
904 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 rsnType = eANI_BOOLEAN_FALSE;
906 break;
907 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800908 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700909 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 return rsnType;
911}
912
913static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
914{
915 struct statsContext *pStatsContext;
916 hdd_adapter_t *pAdapter;
917
918 if (ioctl_debug)
919 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700920 pr_info("%s: rssi [%d] STA [%d] pContext [%pK]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700921 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 }
923
924 if (NULL == pContext)
925 {
926 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700927 "%s: Bad param, pContext [%pK]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700928 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 return;
930 }
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 pStatsContext = pContext;
933 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800934
935 /* there is a race condition that exists between this callback
936 function and the caller since the caller could time out either
937 before or while this code is executing. we use a spinlock to
938 serialize these actions */
939 spin_lock(&hdd_context_lock);
940
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
942 {
943 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800944 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700946 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700947 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 if (ioctl_debug)
949 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700950 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700951 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 }
953 return;
954 }
955
Jeff Johnson72a40512013-12-19 10:14:15 -0800956 /* context is valid so caller is still waiting */
957
958 /* paranoia: invalidate the magic */
959 pStatsContext->magic = 0;
960
Sachin Ahujaa082b672015-10-05 19:51:31 +0530961 /* copy over the rssi.FW will return RSSI as -100
962 * if there are no samples to calculate the average
963 * RSSI
964 */
965 if (rssi != -100)
966 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530967 if (pAdapter->rssi > 0)
968 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800969 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800971
972 /* serialization is complete */
973 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700974}
975
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530976struct snr_priv {
977 int8_t snr;
978};
979
980/**
981 * hdd_get_snr_cb() - "Get SNR" callback function
982 * @snr: Current SNR of the station
983 * @sta_id: ID of the station
984 * @context: opaque context originally passed to SME. HDD always passes
985 * a cookie for the request context
986 *
987 * Return: None
988 */
989static void hdd_get_snr_cb(tANI_S8 snr, tANI_U32 staId, void *context)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530990{
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530991 struct hdd_request *request;
992 struct snr_priv *priv;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530993
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +0530994 request = hdd_request_get(context);
995 if (!request) {
996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
997 return;
998 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530999
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301000 /* propagate response back to requesting thread */
1001 priv = hdd_request_priv(request);
1002 priv->snr = snr;
1003 hdd_request_complete(request);
1004 hdd_request_put(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301005}
1006
Jeff Johnson295189b2012-06-20 16:38:30 -07001007VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1008{
1009 struct statsContext context;
1010 hdd_context_t *pHddCtx;
1011 hdd_station_ctx_t *pHddStaCtx;
1012 eHalStatus hstatus;
1013 long lrc;
1014
1015 if (NULL == pAdapter)
1016 {
1017 hddLog(VOS_TRACE_LEVEL_WARN,
1018 "%s: Invalid context, pAdapter", __func__);
1019 return VOS_STATUS_E_FAULT;
1020 }
1021 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1022 {
1023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1024 /* return a cached value */
1025 *rssi_value = pAdapter->rssi;
1026 return VOS_STATUS_SUCCESS;
1027 }
1028
1029 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1030 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1031
mukul sharma8aec69b2015-06-10 22:28:43 +05301032 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1033 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1035 __func__, pAdapter->rssi_on_disconnect);
1036 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301037 return VOS_STATUS_SUCCESS;
1038 }
1039
1040 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1041 {
1042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1043 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1044 *rssi_value = pAdapter->rssi;
1045 return VOS_STATUS_SUCCESS;
1046 }
1047
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 init_completion(&context.completion);
1049 context.pAdapter = pAdapter;
1050 context.magic = RSSI_CONTEXT_MAGIC;
1051
1052 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
1053 pHddStaCtx->conn_info.staId[ 0 ],
1054 pHddStaCtx->conn_info.bssId,
1055 &context, pHddCtx->pvosContext);
1056 if (eHAL_STATUS_SUCCESS != hstatus)
1057 {
1058 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001059 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 /* we'll returned a cached value below */
1061 }
1062 else
1063 {
1064 /* request was sent -- wait for the response */
1065 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1066 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 if (lrc <= 0)
1068 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001069 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001070 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 /* we'll now returned a cached value below */
1072 }
1073 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001074
1075 /* either we never sent a request, we sent a request and received a
1076 response or we sent a request and timed out. if we never sent a
1077 request or if we sent a request and got a response, we want to
1078 clear the magic out of paranoia. if we timed out there is a
1079 race condition such that the callback function could be
1080 executing at the same time we are. of primary concern is if the
1081 callback function had already verified the "magic" but had not
1082 yet set the completion variable when a timeout occurred. we
1083 serialize these activities by invalidating the magic while
1084 holding a shared spinlock which will cause us to block if the
1085 callback is currently executing */
1086 spin_lock(&hdd_context_lock);
1087 context.magic = 0;
1088 spin_unlock(&hdd_context_lock);
1089
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301091 hddLog(VOS_TRACE_LEVEL_INFO,
1092 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 return VOS_STATUS_SUCCESS;
1095}
Siddharth Bhal64246172015-02-27 01:04:37 +05301096/**---------------------------------------------------------------------------
1097
1098 \brief wlan_hdd_get_frame_logs() -
1099
1100 This function use to get Frames log.
1101
1102 \param - pAdapter Pointer to the adapter.
1103 flag - Specify type of request. Clear and Send request are
1104 supported.
1105
1106 \return - none
1107
1108 --------------------------------------------------------------------------*/
1109VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1110{
Siddharth Bhal64246172015-02-27 01:04:37 +05301111 hdd_context_t *pHddCtx;
1112 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301113
1114 if (NULL == pAdapter)
1115 {
1116 hddLog(VOS_TRACE_LEVEL_WARN,
1117 "%s: Invalid context, pAdapter", __func__);
1118 return VOS_STATUS_E_FAULT;
1119 }
1120
1121 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1122 if (!pHddCtx->mgmt_frame_logging)
1123 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301124 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301125 return VOS_STATUS_E_AGAIN;
1126 }
1127
Siddharth Bhal4507c262015-04-29 20:20:42 +05301128 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1129 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1130 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301131 {
1132 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1133 return VOS_STATUS_E_INVAL;
1134 }
1135
Siddharth Bhal4507c262015-04-29 20:20:42 +05301136 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1137 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1138 {
1139 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1140 return VOS_STATUS_E_INVAL;
1141 }
1142
Abhishek Singh611295e2015-07-09 11:11:54 +05301143 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301144 if (eHAL_STATUS_SUCCESS != hstatus)
1145 {
1146 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301147 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301148 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301149
1150 return VOS_STATUS_SUCCESS;
1151}
1152
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301153
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301154VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1155{
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301156 hdd_context_t *pHddCtx;
1157 hdd_station_ctx_t *pHddStaCtx;
1158 eHalStatus hstatus;
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301159 int ret;
1160 void *cookie;
1161 struct hdd_request *request;
1162 struct snr_priv *priv;
1163 static const struct hdd_request_params params = {
1164 .priv_size = sizeof(*priv),
1165 .timeout_ms = WLAN_WAIT_TIME_STATS,
1166 };
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301167
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301168 ENTER();
1169
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301170 if (NULL == pAdapter)
1171 {
1172 hddLog(VOS_TRACE_LEVEL_ERROR,
1173 "%s: Invalid context, pAdapter", __func__);
1174 return VOS_STATUS_E_FAULT;
1175 }
1176
1177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1178
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301179 ret = wlan_hdd_validate_context(pHddCtx);
1180 if (0 != ret)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301181 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301182 return VOS_STATUS_E_FAULT;
1183 }
1184
1185 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1186 if (NULL == pHddStaCtx)
1187 {
1188 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1189 return VOS_STATUS_E_FAULT;
1190 }
1191
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301192 request = hdd_request_alloc(&params);
1193 if (!request) {
1194 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
1195 return VOS_STATUS_E_FAULT;
1196 }
1197 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301198
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301199 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_get_snr_cb,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301200 pHddStaCtx->conn_info.staId[ 0 ],
1201 pHddStaCtx->conn_info.bssId,
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301202 cookie);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301203 if (eHAL_STATUS_SUCCESS != hstatus)
1204 {
1205 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1206 __func__);
1207 /* we'll returned a cached value below */
1208 }
1209 else
1210 {
1211 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301212 ret = hdd_request_wait_for_response(request);
1213 if (ret) {
1214 hddLog(VOS_TRACE_LEVEL_ERROR,
1215 FL("SME timed out while retrieving SNR"));
1216 /* we'll now returned a cached value below */
1217 } else {
1218 /* update the adapter with the fresh results */
1219 priv = hdd_request_priv(request);
1220 pAdapter->snr = priv->snr;
1221 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301222 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001223
Hanumanth Reddy Pothula81b43262018-03-15 16:57:36 +05301224 /*
1225 * either we never sent a request, we sent a request and
1226 * received a response or we sent a request and timed out.
1227 * regardless we are done with the request.
1228 */
1229 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08001230
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301231 *snr = pAdapter->snr;
1232
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301233 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301234 return VOS_STATUS_SUCCESS;
1235}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301236
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001237#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001238
1239static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1240{
1241 struct statsContext *pStatsContext;
1242 hdd_adapter_t *pAdapter;
1243 if (ioctl_debug)
1244 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001245 pr_info("%s: rssi [%d] STA [%d] pContext [%pK]\n",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001246 __func__, (int)rssi, (int)staId, pContext);
1247 }
1248
1249 if (NULL == pContext)
1250 {
1251 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001252 "%s: Bad param, pContext [%pK]",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001253 __func__, pContext);
1254 return;
1255 }
1256
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001257 pStatsContext = pContext;
1258 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001259
1260 /* there is a race condition that exists between this callback
1261 function and the caller since the caller could time out either
1262 before or while this code is executing. we use a spinlock to
1263 serialize these actions */
1264 spin_lock(&hdd_context_lock);
1265
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001266 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1267 {
1268 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001269 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001270 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001271 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001272 __func__, pAdapter, pStatsContext->magic);
1273 if (ioctl_debug)
1274 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001275 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001276 __func__, pAdapter, pStatsContext->magic);
1277 }
1278 return;
1279 }
1280
Jeff Johnson72a40512013-12-19 10:14:15 -08001281 /* context is valid so caller is still waiting */
1282
1283 /* paranoia: invalidate the magic */
1284 pStatsContext->magic = 0;
1285
Sachin Ahujaa082b672015-10-05 19:51:31 +05301286 /* copy over the rssi.FW will return RSSI as -100
1287 * if there are no samples to calculate the average
1288 * RSSI
1289 */
1290 if (rssi != -100)
1291 pAdapter->rssi = rssi;
1292
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301293 if (pAdapter->rssi > 0)
1294 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001295 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001296 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001297
1298 /* serialization is complete */
1299 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001300}
1301
1302
1303
1304VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1305{
1306 struct statsContext context;
1307 hdd_context_t *pHddCtx = NULL;
1308 hdd_station_ctx_t *pHddStaCtx = NULL;
1309 eHalStatus hstatus;
1310 long lrc;
1311
1312 if (NULL == pAdapter)
1313 {
1314 hddLog(VOS_TRACE_LEVEL_WARN,
1315 "%s: Invalid context, pAdapter", __func__);
1316 return VOS_STATUS_E_FAULT;
1317 }
1318 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1319 {
1320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1321 /* return a cached value */
1322 *rssi_value = pAdapter->rssi;
1323 return VOS_STATUS_SUCCESS;
1324 }
1325
1326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1327 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1328
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301329 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001330 {
1331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1332 /* return a cached value */
1333 *rssi_value = 0;
1334 return VOS_STATUS_SUCCESS;
1335 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301336
1337 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1338 {
1339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1340 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1341 *rssi_value = pAdapter->rssi;
1342 return VOS_STATUS_SUCCESS;
1343 }
1344
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001345 init_completion(&context.completion);
1346 context.pAdapter = pAdapter;
1347 context.magic = RSSI_CONTEXT_MAGIC;
1348
1349 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1350 pHddStaCtx->conn_info.staId[ 0 ],
1351 pHddStaCtx->conn_info.bssId,
1352 &context, pHddCtx->pvosContext);
1353 if (eHAL_STATUS_SUCCESS != hstatus)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1356 __func__);
1357 /* we'll returned a cached value below */
1358 }
1359 else
1360 {
1361 /* request was sent -- wait for the response */
1362 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1363 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001364 if (lrc <= 0)
1365 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001366 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001367 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001368 /* we'll now returned a cached value below */
1369 }
1370 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001371
1372 /* either we never sent a request, we sent a request and received a
1373 response or we sent a request and timed out. if we never sent a
1374 request or if we sent a request and got a response, we want to
1375 clear the magic out of paranoia. if we timed out there is a
1376 race condition such that the callback function could be
1377 executing at the same time we are. of primary concern is if the
1378 callback function had already verified the "magic" but had not
1379 yet set the completion variable when a timeout occurred. we
1380 serialize these activities by invalidating the magic while
1381 holding a shared spinlock which will cause us to block if the
1382 callback is currently executing */
1383 spin_lock(&hdd_context_lock);
1384 context.magic = 0;
1385 spin_unlock(&hdd_context_lock);
1386
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001387 *rssi_value = pAdapter->rssi;
1388
1389 return VOS_STATUS_SUCCESS;
1390}
1391#endif
1392
1393
Jeff Johnson295189b2012-06-20 16:38:30 -07001394void hdd_StatisticsCB( void *pStats, void *pContext )
1395{
1396 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1397 hdd_stats_t *pStatsCache = NULL;
1398 hdd_wext_state_t *pWextState;
1399 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1400
1401 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1402 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1403 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1404 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1405 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1406 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1407
1408 if (pAdapter!= NULL)
1409 pStatsCache = &pAdapter->hdd_stats;
1410
1411
1412 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1413 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1414 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1415 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1416 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1417 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1418
1419 if (pStatsCache!=NULL)
1420 {
1421 // and copy the stats into the cache we keep in the adapter instance structure
1422 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1423 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1424 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1425 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1426 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1427 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1428 }
1429
1430 if(pAdapter)
1431 {
1432 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1433 if(pWextState)
1434 {
1435 vos_status = vos_event_set(&pWextState->vosevent);
1436 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1437 {
1438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001439 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 return;
1441 }
1442 }
1443 }
1444}
1445
1446void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1447{
1448 v_CONTEXT_t pVosContext;
1449 hdd_context_t *pHddCtx;
1450 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1451#if 0
1452 hdd_wext_state_t *pWextState;
1453 v_U32_t roamId;
1454#endif
1455
1456 ENTER();
1457
1458 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1459
1460 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1461 if (NULL == pHddCtx)
1462 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001463 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 return;
1465 }
1466#if 0
1467 pWextState = pAdapter->pWextState;
1468#endif
1469
1470 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1471 {
1472 //TODO Verify is this is really used. If yes need to fix it.
1473 hdd_reconnect_all_adapters( pHddCtx );
1474#if 0
1475 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1476 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1477 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1478
1479 if(VOS_STATUS_SUCCESS == vosStatus)
1480 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1481 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1482
1483 sme_RoamConnect(halHandle,
1484 pAdapter->sessionId, &(pWextState->roamProfile),
1485 &roamId);
1486#endif
1487 }
1488
1489 EXIT();
1490
1491}
1492
1493void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1494{
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1496
1497 /* clear WPA/RSN/WSC IE information in the profile */
1498 pWextState->roamProfile.nWPAReqIELength = 0;
1499 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1500 pWextState->roamProfile.nRSNReqIELength = 0;
1501 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1502
Chet Lanctot186b5732013-03-18 10:26:30 -07001503#ifdef FEATURE_WLAN_WAPI
1504 pWextState->roamProfile.nWAPIReqIELength = 0;
1505 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1506#endif
1507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001509 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301511 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1513 pWextState->roamProfile.nAddIEAssocLength = 0;
1514
1515 pWextState->roamProfile.EncryptionType.numEntries = 1;
1516 pWextState->roamProfile.EncryptionType.encryptionType[0]
1517 = eCSR_ENCRYPT_TYPE_NONE;
1518
1519 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1520 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1521 = eCSR_ENCRYPT_TYPE_NONE;
1522
1523 pWextState->roamProfile.AuthType.numEntries = 1;
1524 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1525
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301526 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001527#ifdef WLAN_FEATURE_11W
1528 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1529 pWextState->roamProfile.MFPRequired = 0;
1530 pWextState->roamProfile.MFPCapable = 0;
1531#endif
1532
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 pWextState->authKeyMgmt = 0;
1534
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301535 vos_mem_zero(&pWextState->roamProfile.Keys,
1536 sizeof(pWextState->roamProfile.Keys));
1537
Jeff Johnson295189b2012-06-20 16:38:30 -07001538#ifdef FEATURE_WLAN_WAPI
1539 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1540 pAdapter->wapi_info.nWapiMode = 0;
1541#endif
1542
1543 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1544
1545}
1546
1547void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1548{
1549 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
Nirav Shahf6bd2672015-03-11 12:53:15 +05301551 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001552 {
1553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301554 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001555 }
1556 else
1557 {
1558 complete(&pAdapter->ula_complete);
1559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001560}
1561
1562VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1563{
1564 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001566 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001567
1568 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1569 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001570 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001571
1572 /*To avoid race condition between the set key and the last EAPOL
1573 packet, notify TL to finish upper layer authentication incase if the
1574 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001575 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001576
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001577 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 {
1579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1580 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1581 __LINE__, vos_status );
1582 return vos_status;
1583
1584 }
1585
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001586 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301588 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001589 {
1590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301591 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001592 /* we'll still fall through and return success since the
1593 * connection may still get established but is just taking
1594 * too long for us to wait */
1595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 }
1597 return VOS_STATUS_SUCCESS;
1598}
1599
1600v_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)
1601{
1602
1603 int left = ie_len;
1604 v_U8_t *ptr = ie;
1605 v_U8_t elem_id,elem_len;
1606 v_U8_t eid = 0xDD;
1607
1608 if ( NULL == ie || 0 == ie_len )
1609 return NULL;
1610
1611 while(left >= 2)
1612 {
1613 elem_id = ptr[0];
1614 elem_len = ptr[1];
1615 left -= 2;
1616 if(elem_len > left)
1617 {
1618 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001619 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 eid,elem_len,left);
1621 return NULL;
1622 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301623 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 {
1625 if(memcmp( &ptr[2], oui, oui_size)==0)
1626 return ptr;
1627 }
1628
1629 left -= elem_len;
1630 ptr += (elem_len + 2);
1631 }
1632 return NULL;
1633}
1634
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301635static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 union iwreq_data *wrqu, char *extra)
1637{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301638 hdd_adapter_t *pAdapter;
1639 hdd_context_t *pHddCtx;
1640 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301641
1642 ENTER();
1643
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301644 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1645 if (NULL == pAdapter)
1646 {
1647 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1648 "%s: pAdapter is NULL\n", __func__);
1649 return -EINVAL;
1650 }
1651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1652 ret = wlan_hdd_validate_context(pHddCtx);
1653 if (0 != ret)
1654 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301655 return ret;
1656 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301657
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301659
1660 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301661 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001662}
1663
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301664static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1665 union iwreq_data *wrqu, char *extra)
1666{
1667 int ret;
1668
1669 vos_ssr_protect(__func__);
1670 ret = __iw_set_commit(dev, info, wrqu, extra);
1671 vos_ssr_unprotect(__func__);
1672
1673 return ret;
1674}
1675
1676static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 struct iw_request_info *info,
1678 char *wrqu, char *extra)
1679{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301680 hdd_adapter_t *pAdapter;
1681 hdd_context_t *pHddCtx;
1682 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301683
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301685 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1686 if (NULL == pAdapter)
1687 {
1688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1689 "%s: pAdapter is NULL\n", __func__);
1690 return -EINVAL;
1691 }
1692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1693 ret = wlan_hdd_validate_context(pHddCtx);
1694 if (0 != ret)
1695 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301696 return ret;
1697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1699 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301700 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001701}
1702
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301703static int iw_get_name(struct net_device *dev,
1704 struct iw_request_info *info,
1705 char *wrqu, char *extra)
1706{
1707 int ret;
1708
1709 vos_ssr_protect(__func__);
1710 ret = __iw_get_name(dev, info, wrqu, extra);
1711 vos_ssr_unprotect(__func__);
1712
1713 return ret;
1714}
1715
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301716static int __iw_set_mode(struct net_device *dev,
1717 struct iw_request_info *info,
1718 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001719{
1720 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301721 hdd_adapter_t *pAdapter;
1722 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 tCsrRoamProfile *pRoamProfile;
1724 eCsrRoamBssType LastBSSType;
1725 eMib_dot11DesiredBssType connectedBssType;
1726 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301728 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001729
1730 ENTER();
1731
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301732 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 if (NULL == pAdapter)
1734 {
1735 hddLog(VOS_TRACE_LEVEL_WARN,
1736 "%s: Invalid context, pAdapter", __func__);
1737 return 0;
1738 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1740 status = wlan_hdd_validate_context(pHddCtx);
1741 if (0 != status)
1742 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301743 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 }
1745
1746 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1747 if (pWextState == NULL)
1748 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301749 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 return -EINVAL;
1751 }
1752
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 pRoamProfile = &pWextState->roamProfile;
1755 LastBSSType = pRoamProfile->BSSType;
1756
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301757 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001758
1759 switch (wrqu->mode)
1760 {
1761 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301762 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1764 // Set the phymode correctly for IBSS.
1765 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1766 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001767 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 break;
1770 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301771 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 break;
1775 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301776 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1778 break;
1779 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301780 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 return -EOPNOTSUPP;
1782 }
1783
1784 if ( LastBSSType != pRoamProfile->BSSType )
1785 {
1786 //the BSS mode changed
1787 // We need to issue disconnect if connected or in IBSS disconnect state
1788 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1789 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1790 {
1791 VOS_STATUS vosStatus;
1792 // need to issue a disconnect to CSR.
1793 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1794 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1795 pAdapter->sessionId,
1796 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1797 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301798 {
1799 long ret;
1800 ret = wait_for_completion_interruptible_timeout(
1801 &pAdapter->disconnect_comp_var,
1802 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1803 if (ret <= 0)
1804 hddLog(VOS_TRACE_LEVEL_ERROR,
1805 FL("failed wait on disconnect_comp_var %ld"), ret);
1806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 }
1808 }
1809
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 EXIT();
1811 return 0;
1812}
1813
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301814static int iw_set_mode(struct net_device *dev,
1815 struct iw_request_info *info,
1816 union iwreq_data *wrqu, char *extra)
1817{
1818 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001819
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301820 vos_ssr_protect(__func__);
1821 ret = __iw_set_mode(dev, info, wrqu, extra);
1822 vos_ssr_unprotect(__func__);
1823
1824 return ret;
1825}
1826
1827static int __iw_get_mode(struct net_device *dev,
1828 struct iw_request_info *info,
1829 union iwreq_data *wrqu,
1830 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001831{
1832
1833 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301834 hdd_adapter_t *pAdapter;
1835 hdd_context_t *pHddCtx;
1836 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001837
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301838 ENTER();
1839
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301840 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 if (NULL == pAdapter)
1842 {
1843 hddLog(VOS_TRACE_LEVEL_WARN,
1844 "%s: Invalid context, pAdapter", __func__);
1845 return 0;
1846 }
1847
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1849 ret = wlan_hdd_validate_context(pHddCtx);
1850 if (0 != ret)
1851 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301852 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1855 if (pWextState == NULL)
1856 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301857 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 return -EINVAL;
1859 }
1860
1861 switch (pWextState->roamProfile.BSSType)
1862 {
1863 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001864 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301865 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 break;
1867 case eCSR_BSS_TYPE_IBSS:
1868 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001869 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301870 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 break;
1872 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001873 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301874 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 break;
1876 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001877 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 break;
1879 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301880
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301881 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 return 0;
1883}
1884
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301885static int iw_get_mode(struct net_device *dev,
1886 struct iw_request_info *info,
1887 union iwreq_data *wrqu,
1888 char *extra)
1889{
1890 int ret;
1891
1892 vos_ssr_protect(__func__);
1893 ret = __iw_get_mode(dev, info, wrqu, extra);
1894 vos_ssr_unprotect(__func__);
1895
1896 return ret;
1897}
1898
1899static int __iw_set_freq(struct net_device *dev,
1900 struct iw_request_info *info,
1901 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001902{
1903 v_U32_t numChans = 0;
1904 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1905 v_U32_t indx = 0;
1906 v_U32_t status = 0;
1907
1908 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301909 hdd_adapter_t *pAdapter;
1910 hdd_context_t *pHddCtx;
1911 tHalHandle hHal;
1912 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301914
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 ENTER();
1916
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301917 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1918 if (NULL == pAdapter)
1919 {
1920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1921 "%s:Invalid Adapter",__func__);
1922 return -EINVAL;
1923 }
1924
1925 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1926 status = wlan_hdd_validate_context(pHddCtx);
1927 if (0 != status)
1928 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 return status;
1930 }
1931
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301932 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1933 if (NULL == hHal)
1934 {
1935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1936 "%s: Hal Context is NULL",__func__);
1937 return -EINVAL;
1938 }
1939
1940 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1941 if (NULL == pHddStaCtx)
1942 {
1943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1944 "%s:STA context is NULL",__func__);
1945 return -EINVAL;
1946 }
1947
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301949 if (NULL == pWextState)
1950 {
1951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1952 "%s: pWextState is NULL",__func__);
1953 return -EINVAL;
1954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001955
1956 pRoamProfile = &pWextState->roamProfile;
1957
Arif Hussain6d2a3322013-11-17 19:50:10 -08001958 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001959
1960 /* Link is up then return cant set channel*/
1961 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1962 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1963 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001964 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 return -EOPNOTSUPP;
1966 }
1967
1968 /* Settings by Frequency as input */
1969 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1970 (wrqu->freq.m <= (tANI_U32)5.825e8))
1971 {
1972 tANI_U32 freq = wrqu->freq.m / 100000;
1973
1974 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1975 indx++;
1976 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1977 {
1978 return -EINVAL;
1979 }
1980 wrqu->freq.e = 0;
1981 wrqu->freq.m = freq_chan_map[indx].chan;
1982
1983 }
1984
1985 if (wrqu->freq.e == 0)
1986 {
1987 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1988 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1989 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001990 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001991 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1993 return -EINVAL;
1994 }
1995
1996 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1997
1998 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1999 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05302000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2001 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 return -EIO;
2003 }
2004
2005 for (indx = 0; indx < numChans; indx++) {
2006 if (wrqu->freq.m == validChan[indx]){
2007 break;
2008 }
2009 }
2010 }
2011 else{
2012
2013 return -EINVAL;
2014 }
2015
2016 if(indx >= numChans)
2017 {
2018 return -EINVAL;
2019 }
2020
2021 /* Set the Operational Channel */
2022 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2023 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2024 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
2025
Arif Hussain6d2a3322013-11-17 19:50:10 -08002026 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 EXIT();
2029
2030 return status;
2031}
2032
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302033static int iw_set_freq(struct net_device *dev,
2034 struct iw_request_info *info,
2035 union iwreq_data *wrqu, char *extra)
2036{
2037 int ret;
2038
2039 vos_ssr_protect(__func__);
2040 ret = __iw_set_freq(dev, info, wrqu, extra);
2041 vos_ssr_unprotect(__func__);
2042
2043 return ret;
2044}
2045
2046static int __iw_get_freq(struct net_device *dev,
2047 struct iw_request_info *info,
2048 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002049{
Jeff Johnsone7245742012-09-05 17:12:55 -07002050 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302051 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 tHalHandle hHal;
2053 hdd_wext_state_t *pWextState;
2054 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302055 hdd_station_ctx_t *pHddStaCtx;
2056 hdd_context_t *pHddCtx;
2057 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002058
2059 ENTER();
2060
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302061 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2062 if (NULL == pAdapter)
2063 {
2064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2065 "%s: Adapter is NULL", __func__);
2066 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2069 ret = wlan_hdd_validate_context(pHddCtx);
2070 if (0 != ret)
2071 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302072 return ret;
2073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302075 if (NULL == hHal)
2076 {
2077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2078 "%s: Hal Context is NULL",__func__);
2079 return -EINVAL;
2080 }
2081 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2082 if (NULL == pHddStaCtx)
2083 {
2084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2085 "%s: HddStaCtx is NULL", __func__);
2086 return -EINVAL;
2087 }
2088 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2089 if (NULL == pWextState)
2090 {
2091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2092 "%s: pWextState is NULL",__func__);
2093 return -EINVAL;
2094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 pRoamProfile = &pWextState->roamProfile;
2096
2097 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2098 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002099 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 {
c_hpothub8245442013-11-20 23:41:09 +05302101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2102 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 return -EIO;
2104 }
2105 else
2106 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002107 status = hdd_wlan_get_freq(channel, &freq);
2108 if( TRUE == status )
2109 {
2110 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2111 * iwlist & iwconfig command shows frequency into proper
2112 * format (2.412 GHz instead of 246.2 MHz)*/
2113 fwrq->m = freq;
2114 fwrq->e = MHZ;
2115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }
2117 }
2118 else
2119 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002120 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2121 * iwlist & iwconfig command shows frequency into proper
2122 * format (2.412 GHz instead of 246.2 MHz)*/
2123 fwrq->m = 0;
2124 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302126
2127 EXIT();
2128 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002129}
2130
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302131static int iw_get_freq(struct net_device *dev,
2132 struct iw_request_info *info,
2133 struct iw_freq *fwrq, char *extra)
2134{
2135 int ret;
2136
2137 vos_ssr_protect(__func__);
2138 ret = __iw_get_freq(dev, info, fwrq, extra);
2139 vos_ssr_unprotect(__func__);
2140
2141 return ret;
2142}
2143
2144static int __iw_get_tx_power(struct net_device *dev,
2145 struct iw_request_info *info,
2146 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002147{
2148
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302149 hdd_adapter_t *pAdapter;
2150 hdd_context_t *pHddCtx;
2151 hdd_station_ctx_t *pHddStaCtx;
2152 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002153
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302154 ENTER();
2155
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302156 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2157 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2160 "%s: Adapter is NULL",__func__);
2161 return -EINVAL;
2162 }
2163 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2164 ret = wlan_hdd_validate_context(pHddCtx);
2165 if (0 != ret)
2166 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302167 return ret;
2168 }
2169
2170 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2171 if (NULL == pHddStaCtx)
2172 {
2173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2174 "%s: STA Context is NULL",__func__);
2175 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177
2178 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2179 {
2180 wrqu->txpower.value = 0;
2181 return 0;
2182 }
2183 wlan_hdd_get_classAstats(pAdapter);
2184 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2185
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302186 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 return 0;
2188}
2189
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302190static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 struct iw_request_info *info,
2192 union iwreq_data *wrqu, char *extra)
2193{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302194 int ret;
2195
2196 vos_ssr_protect(__func__);
2197 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2198 vos_ssr_unprotect(__func__);
2199
2200 return ret;
2201}
2202
2203static int __iw_set_tx_power(struct net_device *dev,
2204 struct iw_request_info *info,
2205 union iwreq_data *wrqu, char *extra)
2206{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302207 hdd_adapter_t *pAdapter;
2208 tHalHandle hHal;
2209 hdd_context_t *pHddCtx;
2210 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002211
2212 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302213 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2214 if (NULL == pAdapter)
2215 {
2216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2217 "%s: Adapter is NULL",__func__);
2218 return -EINVAL;
2219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302221 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2222 ret = wlan_hdd_validate_context(pHddCtx);
2223 if (0 != ret)
2224 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302225 return ret;
2226 }
2227
2228 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2229 if (NULL == hHal)
2230 {
2231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2232 "%s: Hal Context is NULL",__func__);
2233 return -EINVAL;
2234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2236 {
c_hpothub8245442013-11-20 23:41:09 +05302237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2238 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 return -EIO;
2240 }
2241
2242 EXIT();
2243
2244 return 0;
2245}
2246
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302247static int iw_set_tx_power(struct net_device *dev,
2248 struct iw_request_info *info,
2249 union iwreq_data *wrqu, char *extra)
2250{
2251 int ret;
2252
2253 vos_ssr_protect(__func__);
2254 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2255 vos_ssr_unprotect(__func__);
2256
2257 return ret;
2258}
2259
2260static int __iw_get_bitrate(struct net_device *dev,
2261 struct iw_request_info *info,
2262 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002263{
2264 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2265 eHalStatus status = eHAL_STATUS_SUCCESS;
2266 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302267 hdd_adapter_t *pAdapter;
2268 hdd_context_t *pHddCtx;
2269 hdd_station_ctx_t *pHddStaCtx;
2270 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
2272 ENTER();
2273
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302274 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2275 if (NULL == pAdapter)
2276 {
2277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2278 "%s: Adapter is NULL",__func__);
2279 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 }
2281
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302282 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2283 ret = wlan_hdd_validate_context(pHddCtx);
2284 if (0 != ret)
2285 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302286 return ret;
2287 }
2288
2289 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2290 if (NULL == pHddStaCtx)
2291 {
2292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2293 "%s: STA Context is NULL",__func__);
2294 return -EINVAL;
2295 }
2296
2297 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 wrqu->bitrate.value = 0;
2299 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302300 else
2301 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2303 SME_SUMMARY_STATS |
2304 SME_GLOBAL_CLASSA_STATS |
2305 SME_GLOBAL_CLASSB_STATS |
2306 SME_GLOBAL_CLASSC_STATS |
2307 SME_GLOBAL_CLASSD_STATS |
2308 SME_PER_STA_STATS,
2309 hdd_StatisticsCB, 0, FALSE,
2310 pHddStaCtx->conn_info.staId[0], pAdapter );
2311
2312 if(eHAL_STATUS_SUCCESS != status)
2313 {
2314 hddLog(VOS_TRACE_LEVEL_ERROR,
2315 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002316 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 return status;
2318 }
2319
2320 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302321 if (NULL == pWextState)
2322 {
2323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2324 "%s: pWextState is NULL",__func__);
2325 return -EINVAL;
2326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002327
2328 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2329
2330 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2331 {
2332 hddLog(VOS_TRACE_LEVEL_ERROR,
2333 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002334 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 return VOS_STATUS_E_FAILURE;
2336 }
2337
2338 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2339 }
2340
2341 EXIT();
2342
2343 return vos_status;
2344}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302345
2346static int iw_get_bitrate(struct net_device *dev,
2347 struct iw_request_info *info,
2348 union iwreq_data *wrqu, char *extra)
2349{
2350 int ret;
2351
2352 vos_ssr_protect(__func__);
2353 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2354 vos_ssr_unprotect(__func__);
2355
2356 return ret;
2357}
2358
2359
Jeff Johnson295189b2012-06-20 16:38:30 -07002360/* ccm call back function */
2361
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302362static int __iw_set_bitrate(struct net_device *dev,
2363 struct iw_request_info *info,
2364 union iwreq_data *wrqu,
2365 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002366{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302367 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302369 hdd_station_ctx_t *pHddStaCtx;
2370 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2372 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2373 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2374 v_U32_t i, rate;
2375 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302376 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002377
2378 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302379 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2380 if (NULL == pAdapter)
2381 {
2382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2383 "%s: Adapter is NULL",__func__);
2384 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 }
2386
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302387 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2388 ret = wlan_hdd_validate_context(pHddCtx);
2389 if (0 != ret)
2390 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302391 return ret;
2392 }
2393
2394 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2395 if (NULL == pHddStaCtx)
2396 {
2397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2398 "%s: STA Context is NULL",__func__);
2399 return -EINVAL;
2400 }
2401
2402
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302404 if (NULL == pWextState)
2405 {
2406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2407 "%s: pWextState is NULL",__func__);
2408 return -EINVAL;
2409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002410
2411 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2412 {
2413 return -ENXIO ;
2414 }
2415
2416 rate = wrqu->bitrate.value;
2417
2418 if (rate == -1)
2419 {
2420 rate = WNI_CFG_FIXED_RATE_AUTO;
2421 valid_rate = TRUE;
2422 }
2423 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2424 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2425 {
2426 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2427 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2428 {
2429 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2430 WNI_CFG_SUPPORTED_RATES_11A,
2431 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2432 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2433 WNI_CFG_SUPPORTED_RATES_11B,
2434 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2435 {
2436 for (i = 0; i < (b_len + a_len); ++i)
2437 {
2438 /* supported rates returned is double the actual rate so we divide it by 2 */
2439 if ((supp_rates[i]&0x7F)/2 == rate)
2440 {
2441 valid_rate = TRUE;
2442 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2443 break;
2444 }
2445 }
2446 }
2447 }
2448 }
2449 if (valid_rate != TRUE)
2450 {
2451 return -EINVAL;
2452 }
2453 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2454 WNI_CFG_FIXED_RATE, rate,
2455 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2456 {
c_hpothub8245442013-11-20 23:41:09 +05302457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2458 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 return -EIO;
2460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302461
2462 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 return 0;
2464}
2465
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302466static int iw_set_bitrate(struct net_device *dev,
2467 struct iw_request_info *info,
2468 union iwreq_data *wrqu,
2469 char *extra)
2470{
2471 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002472
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302473 vos_ssr_protect(__func__);
2474 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2475 vos_ssr_unprotect(__func__);
2476
2477 return ret;
2478}
2479
2480static int __iw_set_genie(struct net_device *dev,
2481 struct iw_request_info *info,
2482 union iwreq_data *wrqu,
2483 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002484{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302485 hdd_adapter_t *pAdapter;
2486 hdd_context_t *pHddCtx;
2487 hdd_wext_state_t *pWextState;
2488 u_int8_t *genie = NULL;
2489 u_int8_t *base_genie = NULL;
2490 v_U16_t remLen;
2491 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002492
2493 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002494
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302495 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2496 if (NULL == pAdapter)
2497 {
2498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2499 "%s: Adapter is NULL",__func__);
2500 return -EINVAL;
2501 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002502
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302503 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2504 ret = wlan_hdd_validate_context(pHddCtx);
2505 if (0 != ret)
2506 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302507 return ret;
2508 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002509
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302510 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2511 if (NULL == pWextState)
2512 {
2513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2514 "%s: pWextState is NULL",__func__);
2515 return -EINVAL;
2516 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002517
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302518 if (!wrqu->data.length) {
2519 hdd_clearRoamProfileIe(pAdapter);
2520 EXIT();
2521 return 0;
2522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002523
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2525 wrqu->data.length);
2526 if (NULL == base_genie)
2527 {
2528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2529 "mem_alloc_copy_from_user_helper fail");
2530 return -ENOMEM;
2531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002532
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302533 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002534
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302535 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002536
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302537 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2538
2539 /* clear any previous genIE before this call */
2540 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2541
2542 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 {
2544 v_U16_t eLen = 0;
2545 v_U8_t elementId;
2546 elementId = *genie++;
2547 eLen = *genie++;
2548 remLen -= 2;
2549
Arif Hussain6d2a3322013-11-17 19:50:10 -08002550 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 __func__, elementId, eLen);
2552
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302553 if (remLen < eLen) {
2554 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2555 remLen, eLen);
2556 ret = -EINVAL;
2557 goto exit;
2558 }
2559
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 switch ( elementId )
2561 {
2562 case IE_EID_VENDOR:
2563 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002564 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302565 ret = -EINVAL;
2566 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002568
2569 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2570 {
2571 v_U16_t curGenIELen = pWextState->genIE.length;
2572 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2573 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2574
2575 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2576 {
2577 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002578 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302580 ret = -EINVAL;
2581 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 }
2583 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2584 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2585 pWextState->genIE.length += eLen + 2;
2586 }
2587 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2588 {
2589 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302590 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2591 {
2592 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2593 "Need bigger buffer space");
2594 ret = -EINVAL;
2595 VOS_ASSERT(0);
2596 goto exit;
2597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2599 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2600 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2601 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2602 }
2603 else /* any vendorId except WPA IE should be accumulated to genIE */
2604 {
2605 v_U16_t curGenIELen = pWextState->genIE.length;
2606 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2607 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2608
2609 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2610 {
2611 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002612 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302614 ret = -ENOMEM;
2615 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 }
2617 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2618 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2619 pWextState->genIE.length += eLen + 2;
2620 }
2621 break;
2622 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002623 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302624 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2625 {
2626 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2627 "Need bigger buffer space");
2628 ret = -EINVAL;
2629 VOS_ASSERT(0);
2630 goto exit;
2631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2633 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2634 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2635 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2636 break;
2637
2638 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002639 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302640 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302643
2644 /* Move genie only if next element is present */
2645 if (remLen >= 2)
2646 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302648
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302649exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002651 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302652 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002653}
2654
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302655static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 struct iw_request_info *info,
2657 union iwreq_data *wrqu,
2658 char *extra)
2659{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302660 int ret;
2661
2662 vos_ssr_protect(__func__);
2663 ret = __iw_set_genie(dev, info, wrqu, extra);
2664 vos_ssr_unprotect(__func__);
2665
2666 return ret;
2667}
2668
2669static int __iw_get_genie(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu,
2672 char *extra)
2673{
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302675 hdd_context_t *pHddCtx;
2676 hdd_adapter_t *pAdapter;
2677 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 eHalStatus status;
2679 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2680 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2681
2682 ENTER();
2683
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302684 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2685 if (NULL == pAdapter)
2686 {
2687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2688 "%s: Adapter is NULL",__func__);
2689 return -EINVAL;
2690 }
2691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2692 status = wlan_hdd_validate_context(pHddCtx);
2693 if (0 != status)
2694 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302695 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 }
2697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302699 if (NULL == pWextState)
2700 {
2701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2702 "%s: pWextState is NULL",__func__);
2703 return -EINVAL;
2704 }
2705
2706 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2707 if (NULL == pHddStaCtx)
2708 {
2709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2710 "%s: STA Context is NULL",__func__);
2711 return -EINVAL;
2712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002713
2714 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2715 {
2716 return -ENXIO;
2717 }
2718
2719 // Return something ONLY if we are associated with an RSN or WPA network
2720 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2721 pWextState->roamProfile.negotiatedAuthType))
2722 {
2723 return -ENXIO;
2724 }
2725
2726 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2727 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2728 pAdapter->sessionId,
2729 &length,
2730 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302731 if (eHAL_STATUS_SUCCESS != status) {
2732 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002733 return -EFAULT;
2734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002735
Manjeet Singh715d47e2016-08-02 19:08:02 +05302736 wrqu->data.length = length;
2737 if (length > DOT11F_IE_RSN_MAX_LEN) {
2738 hddLog(LOGE,
2739 FL("invalid buffer length length:%d"), length);
2740 return -E2BIG;
2741 }
2742
2743 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2744
2745 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002746
2747 EXIT();
2748
2749 return 0;
2750}
2751
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302752static int iw_get_genie(struct net_device *dev,
2753 struct iw_request_info *info,
2754 union iwreq_data *wrqu,
2755 char *extra)
2756{
2757 int ret;
2758
2759 vos_ssr_protect(__func__);
2760 ret = __iw_get_genie(dev, info, wrqu, extra);
2761 vos_ssr_unprotect(__func__);
2762
2763 return ret;
2764}
2765
2766
2767static int __iw_get_encode(struct net_device *dev,
2768 struct iw_request_info *info,
2769 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002770{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302771 hdd_adapter_t *pAdapter;
2772 hdd_context_t *pHddCtx;
2773 hdd_wext_state_t *pWextState;
2774 tCsrRoamProfile *pRoamProfile;
2775 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002777
2778 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302779 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2780 if (NULL == pAdapter)
2781 {
2782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2783 "%s: Adapter is NULL",__func__);
2784 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 }
2786
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302787 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2788 ret = wlan_hdd_validate_context(pHddCtx);
2789 if (0 != ret)
2790 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302791 return ret;
2792 }
2793 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2794 if (NULL == pWextState)
2795 {
2796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2797 "%s: pWextState is NULL",__func__);
2798 return -EINVAL;
2799 }
2800
2801 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 keyId = pRoamProfile->Keys.defaultIndex;
2803
2804 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2805 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002806 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 return -EINVAL;
2808 }
2809
2810 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2811 {
2812 dwrq->flags |= IW_ENCODE_ENABLED;
2813 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2814 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2815
2816 dwrq->flags |= (keyId + 1);
2817
2818 }
2819 else
2820 {
2821 dwrq->flags |= IW_ENCODE_DISABLED;
2822 }
2823
2824 for(i=0; i < MAX_WEP_KEYS; i++)
2825 {
2826 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2827 {
2828 continue;
2829 }
2830 else
2831 {
2832 break;
2833 }
2834 }
2835
2836 if(MAX_WEP_KEYS == i)
2837 {
2838 dwrq->flags |= IW_ENCODE_NOKEY;
2839 }
2840
2841 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2842
2843 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2844 {
2845 dwrq->flags |= IW_ENCODE_OPEN;
2846 }
2847 else
2848 {
2849 dwrq->flags |= IW_ENCODE_RESTRICTED;
2850 }
2851 EXIT();
2852 return 0;
2853}
2854
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302855static int iw_get_encode(struct net_device *dev,
2856 struct iw_request_info *info,
2857 struct iw_point *dwrq, char *extra)
2858{
2859 int ret;
2860
2861 vos_ssr_protect(__func__);
2862 ret = __iw_get_encode(dev, info, dwrq, extra);
2863 vos_ssr_unprotect(__func__);
2864
2865 return ret;
2866}
2867
Jeff Johnson295189b2012-06-20 16:38:30 -07002868#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2869#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2870
2871
2872/*
2873 * This function sends a single 'key' to LIM at all time.
2874 */
2875
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302876static int __iw_get_rts_threshold(struct net_device *dev,
2877 struct iw_request_info *info,
2878 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002879{
2880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2881 v_U32_t status = 0;
2882
2883 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2884
2885 return status;
2886}
2887
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302888static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 struct iw_request_info *info,
2890 union iwreq_data *wrqu, char *extra)
2891{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302892 int ret;
2893
2894 vos_ssr_protect(__func__);
2895 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2896 vos_ssr_unprotect(__func__);
2897
2898 return ret;
2899}
2900
2901static int __iw_set_rts_threshold(struct net_device *dev,
2902 struct iw_request_info *info,
2903 union iwreq_data *wrqu, char *extra)
2904{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302905 hdd_adapter_t *pAdapter;
2906 hdd_context_t *pHddCtx;
2907 tHalHandle hHal;
2908 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002909
2910 ENTER();
2911
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302912 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2913 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002914 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2916 "%s: Adapter is NULL",__func__);
2917 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002918 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302919
2920 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2921 ret = wlan_hdd_validate_context(pHddCtx);
2922 if (0 != ret)
2923 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302924 return ret;
2925 }
2926
2927 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2928 if (NULL == hHal)
2929 {
2930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2931 "%s: Hal Context is NULL",__func__);
2932 return -EINVAL;
2933 }
2934
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2936 {
2937 return -EINVAL;
2938 }
2939
2940 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2941 {
c_hpothub8245442013-11-20 23:41:09 +05302942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2943 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 return -EIO;
2945 }
2946
2947 EXIT();
2948
2949 return 0;
2950}
2951
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302952static int iw_set_rts_threshold(struct net_device *dev,
2953 struct iw_request_info *info,
2954 union iwreq_data *wrqu, char *extra)
2955{
2956 int ret;
2957
2958 vos_ssr_protect(__func__);
2959 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2960 vos_ssr_unprotect(__func__);
2961
2962 return ret;
2963}
2964
2965static int __iw_get_frag_threshold(struct net_device *dev,
2966 struct iw_request_info *info,
2967 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002968{
2969 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2970 v_U32_t status = 0;
2971
2972 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2973
2974 return status;
2975}
2976
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302977static int iw_get_frag_threshold(struct net_device *dev,
2978 struct iw_request_info *info,
2979 union iwreq_data *wrqu, char *extra)
2980{
2981 int ret;
2982
2983 vos_ssr_protect(__func__);
2984 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2985 vos_ssr_unprotect(__func__);
2986
2987 return ret;
2988}
2989
2990static int __iw_set_frag_threshold(struct net_device *dev,
2991 struct iw_request_info *info,
2992 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002993{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302994 hdd_adapter_t *pAdapter;
2995 hdd_context_t *pHddCtx;
2996 tHalHandle hHal;
2997 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002998
2999 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303000 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3001 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003002 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3004 "%s: Adapter is NULL",__func__);
3005 return -EINVAL;
3006 }
3007
3008 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3009 ret = wlan_hdd_validate_context(pHddCtx);
3010 if (0 != ret)
3011 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303012 return ret;
3013 }
3014
3015 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3016 if (NULL == hHal)
3017 {
3018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3019 "%s: Hal Context is NULL",__func__);
3020 return -EINVAL;
3021 }
3022
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3024 {
3025 return -EINVAL;
3026 }
3027
3028 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3029 {
c_hpothub8245442013-11-20 23:41:09 +05303030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3031 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 return -EIO;
3033 }
3034
3035 EXIT();
3036
3037 return 0;
3038}
3039
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303040static int iw_set_frag_threshold(struct net_device *dev,
3041 struct iw_request_info *info,
3042 union iwreq_data *wrqu, char *extra)
3043{
3044 int ret;
3045
3046 vos_ssr_protect(__func__);
3047 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3048 vos_ssr_unprotect(__func__);
3049
3050 return ret;
3051}
3052
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303053static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 struct iw_request_info *info,
3055 union iwreq_data *wrqu, char *extra)
3056{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303057 hdd_adapter_t *pAdapter;
3058 hdd_context_t *pHddCtx;
3059 int ret = 0;
3060
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303062 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3063 if (NULL == pAdapter)
3064 {
3065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: Adapter is NULL",__func__);
3067 return -EINVAL;
3068 }
3069 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3070 ret = wlan_hdd_validate_context(pHddCtx);
3071 if (0 != ret)
3072 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303073 return ret;
3074 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303075
3076 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 return -EOPNOTSUPP;
3078}
3079
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303080static int iw_get_power_mode(struct net_device *dev,
3081 struct iw_request_info *info,
3082 union iwreq_data *wrqu, char *extra)
3083{
3084 int ret;
3085
3086 vos_ssr_protect(__func__);
3087 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3088 vos_ssr_unprotect(__func__);
3089
3090 return ret;
3091}
3092static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 struct iw_request_info *info,
3094 union iwreq_data *wrqu, char *extra)
3095{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303096 hdd_adapter_t *pAdapter;
3097 hdd_context_t *pHddCtx;
3098 int ret = 0;
3099
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303101 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3102 if (NULL == pAdapter)
3103 {
3104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3105 "%s: Adapter is NULL",__func__);
3106 return -EINVAL;
3107 }
3108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3109 ret = wlan_hdd_validate_context(pHddCtx);
3110 if (0 != ret)
3111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303112 return ret;
3113 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303114
3115 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 return -EOPNOTSUPP;
3117}
3118
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303119static int iw_set_power_mode(struct net_device *dev,
3120 struct iw_request_info *info,
3121 union iwreq_data *wrqu, char *extra)
3122{
3123 int ret;
3124
3125 vos_ssr_protect(__func__);
3126 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3127 vos_ssr_unprotect(__func__);
3128
3129 return ret;
3130}
3131
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303132static int __iw_get_range(struct net_device *dev,
3133 struct iw_request_info *info,
3134 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003135{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303136 hdd_adapter_t *pAdapter;
3137 tHalHandle hHal;
3138 hdd_context_t *pHddCtx;
3139 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 struct iw_range *range = (struct iw_range *) extra;
3141
3142 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3143
3144 v_U32_t num_channels = sizeof(channels);
3145 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3146 v_U32_t a_len;
3147 v_U32_t b_len;
3148 v_U32_t active_phy_mode = 0;
3149 v_U8_t index = 0, i;
3150
3151 ENTER();
3152
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303153 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3154 if (NULL == pAdapter)
3155 {
3156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3157 "%s: pAdapter is NULL", __func__);
3158 return -EINVAL;
3159 }
3160 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3161 ret = wlan_hdd_validate_context(pHddCtx);
3162 if (0 != ret)
3163 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303164 return ret;
3165 }
3166 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3167 if (NULL == hHal)
3168 {
3169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3170 "%s: pAdapter is NULL", __func__);
3171 return -EINVAL;
3172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 wrqu->data.length = sizeof(struct iw_range);
3174 memset(range, 0, sizeof(struct iw_range));
3175
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 /*Get the phy mode*/
3177 if (ccmCfgGetInt(hHal,
3178 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3179 {
3180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003181 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182
3183 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3184 {
3185 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003186 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 if (ccmCfgGetStr(hHal,
3188 WNI_CFG_SUPPORTED_RATES_11A,
3189 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3190 {
3191 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3192 {
3193 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3194 }
3195 for (i = 0; i < a_len; i++)
3196 {
3197 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3198 }
3199 range->num_bitrates = a_len;
3200 }
3201 else
3202 {
3203 return -EIO;
3204 }
3205 }
3206 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3207 {
3208 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003209 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 if (ccmCfgGetStr(hHal,
3211 WNI_CFG_SUPPORTED_RATES_11B,
3212 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3213 {
3214 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3215 {
3216 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3217 }
3218 for (i = 0; i < b_len; i++)
3219 {
3220 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3221 }
3222 range->num_bitrates = b_len;
3223 }
3224 else
3225 {
3226 return -EIO;
3227 }
3228 }
3229 }
3230
3231 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3232 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3233 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3234
3235 range->encoding_size[0] = 5;
3236 range->encoding_size[1] = 13;
3237 range->num_encoding_sizes = 2;
3238 range->max_encoding_tokens = MAX_WEP_KEYS;
3239
3240 // we support through Wireless Extensions 22
3241 range->we_version_compiled = WIRELESS_EXT;
3242 range->we_version_source = 22;
3243
3244 /*Supported Channels and Frequencies*/
3245 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3246 {
c_hpothub8245442013-11-20 23:41:09 +05303247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3248 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 return -EIO;
3250 }
3251 if (num_channels > IW_MAX_FREQUENCIES)
3252 {
3253 num_channels = IW_MAX_FREQUENCIES;
3254 }
3255
3256 range->num_channels = num_channels;
3257 range->num_frequency = num_channels;
3258
3259 for (index=0; index < num_channels; index++)
3260 {
3261 v_U32_t frq_indx = 0;
3262
3263 range->freq[index].i = channels[index];
3264 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3265 {
3266 if(channels[index] == freq_chan_map[frq_indx].chan)
3267 {
3268 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3269 range->freq[index].e = 1;
3270 break;
3271 }
3272 frq_indx++;
3273 }
3274 }
3275
3276 /* Event capability (kernel + driver) */
3277 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3278 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3279 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3280 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3281
3282 /*Encryption capability*/
3283 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3284 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3285
3286 /* Txpower capability */
3287 range->txpower_capa = IW_TXPOW_MWATT;
3288
3289 /*Scanning capability*/
3290 #if WIRELESS_EXT >= 22
3291 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3292 #endif
3293
3294 EXIT();
3295 return 0;
3296}
3297
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303298static int iw_get_range(struct net_device *dev,
3299 struct iw_request_info *info,
3300 union iwreq_data *wrqu, char *extra)
3301{
3302 int ret;
3303
3304 vos_ssr_protect(__func__);
3305 ret = __iw_get_range(dev, info, wrqu, extra);
3306 vos_ssr_unprotect(__func__);
3307
3308 return ret;
3309}
3310
Jeff Johnson295189b2012-06-20 16:38:30 -07003311/* Callback function registered with PMC to know status of PMC request */
3312static void iw_power_callback_fn (void *pContext, eHalStatus status)
3313{
3314 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
3316 if (NULL == pContext)
3317 {
3318 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003319 "%s: Bad param, pContext [%pK]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003320 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 return;
3322 }
3323
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003325
Jeff Johnson72a40512013-12-19 10:14:15 -08003326 /* there is a race condition that exists between this callback
3327 function and the caller since the caller could time out either
3328 before or while this code is executing. we use a spinlock to
3329 serialize these actions */
3330 spin_lock(&hdd_context_lock);
3331
3332 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 {
3334 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003335 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003337 "%s: Invalid context, magic [%08x]",
3338 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003339
3340 if (ioctl_debug)
3341 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003342 pr_info("%s: Invalid context, magic [%08x]\n",
3343 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 }
3345 return;
3346 }
3347
Jeff Johnson72a40512013-12-19 10:14:15 -08003348 /* context is valid so caller is still waiting */
3349
3350 /* paranoia: invalidate the magic */
3351 pStatsContext->magic = 0;
3352
3353 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003355
3356 /* serialization is complete */
3357 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003358}
3359
3360/* Callback function for tx per hit */
3361void hdd_tx_per_hit_cb (void *pCallbackContext)
3362{
3363 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3364 unsigned char tx_fail[16];
3365 union iwreq_data wrqu;
3366
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303367 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003369 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 return;
3371 }
3372 memset(&wrqu, 0, sizeof(wrqu));
3373 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3374 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3375}
3376
3377void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3378{
3379 struct statsContext *pStatsContext;
3380 tCsrGlobalClassAStatsInfo *pClassAStats;
3381 hdd_adapter_t *pAdapter;
3382
3383 if (ioctl_debug)
3384 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003385 pr_info("%s: pStats [%pK] pContext [%pK]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003386 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 }
3388
3389 if ((NULL == pStats) || (NULL == pContext))
3390 {
3391 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003392 "%s: Bad param, pStats [%pK] pContext [%pK]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003393 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 return;
3395 }
3396
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 pClassAStats = pStats;
3398 pStatsContext = pContext;
3399 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003400
3401 /* there is a race condition that exists between this callback
3402 function and the caller since the caller could time out either
3403 before or while this code is executing. we use a spinlock to
3404 serialize these actions */
3405 spin_lock(&hdd_context_lock);
3406
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3408 {
3409 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003410 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003412 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003413 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 if (ioctl_debug)
3415 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003416 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003417 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 }
3419 return;
3420 }
3421
Jeff Johnson72a40512013-12-19 10:14:15 -08003422 /* context is valid so caller is still waiting */
3423
3424 /* paranoia: invalidate the magic */
3425 pStatsContext->magic = 0;
3426
3427 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3429
Jeff Johnson72a40512013-12-19 10:14:15 -08003430 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003432
3433 /* serialization is complete */
3434 spin_unlock(&hdd_context_lock);
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303435
3436}
3437
3438struct stats_class_a_ctx {
3439 tCsrGlobalClassAStatsInfo class_a_stats;
3440};
3441
3442void hdd_get_class_a_statistics_cb(void *stats, void *context)
3443{
3444 struct hdd_request *request;
3445 struct stats_class_a_ctx *priv;
3446
3447 if (ioctl_debug) {
3448 pr_info("%s: stats [%pK] context [%pK]\n",
3449 __func__, stats, context);
3450 }
3451
3452 if (NULL == stats) {
3453 hddLog(VOS_TRACE_LEVEL_ERROR,
3454 "%s: Bad param, stats [%pK]",
3455 __func__, stats);
3456 return;
3457 }
3458
3459 request = hdd_request_get(context);
3460 if (!request) {
3461 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3462 return;
3463 }
3464
3465 priv = hdd_request_priv(request);
3466
3467 /* copy over the stats. do so as a struct copy */
3468 priv->class_a_stats = *(tCsrGlobalClassAStatsInfo *)stats;
3469
3470 hdd_request_complete(request);
3471 hdd_request_put(request);
Jeff Johnson295189b2012-06-20 16:38:30 -07003472}
3473
3474VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3475{
3476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3477 eHalStatus hstatus;
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303478 int ret;
3479 void *cookie;
3480 struct hdd_request *request;
3481 struct stats_class_a_ctx *priv;
3482 static const struct hdd_request_params params = {
3483 .priv_size = sizeof(*priv),
3484 .timeout_ms = WLAN_WAIT_TIME_STATS,
3485 };
3486
Jeff Johnson295189b2012-06-20 16:38:30 -07003487
3488 if (NULL == pAdapter)
3489 {
3490 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3491 return VOS_STATUS_E_FAULT;
3492 }
3493 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3494 {
3495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3496 return VOS_STATUS_SUCCESS;
3497 }
3498
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303499 request = hdd_request_alloc(&params);
3500 if (!request) {
3501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3502 return VOS_STATUS_E_NOMEM;
3503 }
3504 cookie = hdd_request_cookie(request);
3505
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 /* query only for Class A statistics (which include link speed) */
3507 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3508 eCSR_HDD,
3509 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303510 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 0, // not periodic
3512 FALSE, //non-cached results
3513 pHddStaCtx->conn_info.staId[0],
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303514 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 if (eHAL_STATUS_SUCCESS != hstatus)
3516 {
3517 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003518 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003519 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 /* we'll returned a cached value below */
3521 }
3522 else
3523 {
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303524 /* request was sent -- wait for the response */
3525 ret = hdd_request_wait_for_response(request);
3526 if (ret)
3527 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303529 FL("SME timeout while retrieving Class A statistics"));
3530 }
3531 else
3532 {
3533 priv = hdd_request_priv(request);
3534 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
3535
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 }
3537 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003538
Hanumanth Reddy Pothula42981db2018-04-05 17:27:39 +05303539 /*
3540 * either we never sent a request, we sent a request and received a
3541 * response or we sent a request and timed out. Regardless we are
3542 * done with the request.
3543 */
3544 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003545
3546 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 return VOS_STATUS_SUCCESS;
3548}
3549
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303550struct stats_ctx {
3551 tCsrSummaryStatsInfo summary_stats;
3552 tCsrGlobalClassAStatsInfo class_a_stats;
3553};
3554
3555static void hdd_get_station_statistics_cb(void *stats, void *context)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003556{
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303557 tCsrSummaryStatsInfo *summary_stats;
3558 tCsrGlobalClassAStatsInfo *class_a_stats;
3559 struct hdd_request *request;
3560 struct stats_ctx *priv;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003561
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003562
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303563 if (ioctl_debug) {
3564 pr_info("%s: stats [%pK] context [%pK]\n",
3565 __func__, stats, context);
3566 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003567
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303568 if (NULL == stats) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR,
3570 "%s: Bad param, stats [%pK]",
3571 __func__, stats);
3572 return;
3573 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003574
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303575 request = hdd_request_get(context);
3576 if (!request) {
3577 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
3578 return;
3579 }
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003580
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303581 summary_stats = (tCsrSummaryStatsInfo *)stats;
3582 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
Jeff Johnson72a40512013-12-19 10:14:15 -08003583
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303584 priv = hdd_request_priv(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003585
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303586 /* copy over the stats. do so as a struct copy */
3587 priv->summary_stats = *summary_stats;
3588 priv->class_a_stats = *class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003589
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303590 hdd_request_complete(request);
3591 hdd_request_put(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003592}
3593
3594VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3595{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303596 hdd_station_ctx_t *pHddStaCtx;
3597 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003598 eHalStatus hstatus;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303599 tANI_U8 sta_id;
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303600 int ret;
3601 void *cookie;
3602 struct hdd_request *request;
3603 struct stats_ctx *priv;
3604 static const struct hdd_request_params params = {
3605 .priv_size = sizeof(*priv),
3606 .timeout_ms = WLAN_WAIT_TIME_STATS,
3607 };
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003608
3609 if (NULL == pAdapter)
3610 {
3611 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3612 return VOS_STATUS_SUCCESS;
3613 }
3614
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303615 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3616 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3617 sta_id = sap_ctx->uBCStaId;
3618 } else {
3619 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3620 sta_id = pHddStaCtx->conn_info.staId[0];
3621 }
3622
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303623 request = hdd_request_alloc(&params);
3624 if (!request) {
3625 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
3626 return VOS_STATUS_E_NOMEM;
3627 }
3628 cookie = hdd_request_cookie(request);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003629
3630 /* query only for Summary & Class A statistics */
3631 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3632 eCSR_HDD,
3633 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303634 SME_GLOBAL_CLASSA_STATS |
3635 SME_PER_PKT_STATS,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303636 hdd_get_station_statistics_cb,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003637 0, // not periodic
3638 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303639 sta_id,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303640 cookie);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003641 if (eHAL_STATUS_SUCCESS != hstatus)
3642 {
3643 hddLog(VOS_TRACE_LEVEL_ERROR,
3644 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003645 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003646 /* we'll return with cached values */
3647 }
3648 else
3649 {
3650 /* request was sent -- wait for the response */
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303651 ret = hdd_request_wait_for_response(request);
3652 if (ret)
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003653 {
3654 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303655 FL("SME timeout while retrieving statistics"));
3656 }
3657 else
3658 {
3659 priv = hdd_request_priv(request);
3660 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
3661 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003662 }
3663 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003664
Hanumanth Reddy Pothula10455232018-04-05 16:06:04 +05303665 /*
3666 * either we never sent a request, we sent a request and received a
3667 * response or we sent a request and timed out. Regardless we are
3668 * done with the request.
3669 */
3670 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08003671
3672 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003673 return VOS_STATUS_SUCCESS;
3674}
3675
Jeff Johnson295189b2012-06-20 16:38:30 -07003676/*
3677 * Support for the LINKSPEED private command
3678 * Per the WiFi framework the response must be of the form
3679 * "LinkSpeed xx"
3680 */
3681static int iw_get_linkspeed(struct net_device *dev,
3682 struct iw_request_info *info,
3683 union iwreq_data *wrqu, char *extra)
3684{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303685 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303686 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303688 int len = sizeof(v_U32_t) + 1;
3689 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303690 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303691 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303692 int rc, valid = 0;
3693
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303694 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303695 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3696 if (NULL == pAdapter)
3697 {
3698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3699 "%s: Adapter is NULL",__func__);
3700 return -EINVAL;
3701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003702
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303703 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303704 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303705 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003706 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303707 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003708 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303709 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3710 if (NULL == pHddStaCtx)
3711 {
3712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3713 "%s: STA Context is NULL",__func__);
3714 return -EINVAL;
3715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3717 {
3718 /* we are not connected so we don't have a classAstats */
3719 link_speed = 0;
3720 }
3721 else
3722 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303723 status = wlan_hdd_get_classAstats(pAdapter);
3724
3725 if (!VOS_IS_STATUS_SUCCESS(status ))
3726 {
3727 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3728 return -EINVAL;
3729 }
3730
3731 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3732 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3733 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3734 &link_speed);
3735
3736 link_speed = link_speed / 10;
3737
3738 if (0 == link_speed)
3739 {
3740 /* The linkspeed returned by HAL is in units of 500kbps.
3741 * converting it to mbps.
3742 * This is required to support legacy firmware which does
3743 * not return link capacity.
3744 */
3745 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3746 }
3747
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 }
3749
3750 wrqu->data.length = len;
3751 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003752 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 if ((rc < 0) || (rc >= len))
3754 {
3755 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303756 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 return -EIO;
3758 }
3759
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303760 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003762 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003763}
3764
Arif Hussain695279c2014-03-24 14:06:07 -07003765/*
3766 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3767 *
3768 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303769static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003770 struct iw_request_info *info,
3771 union iwreq_data *wrqu, char *extra)
3772{
3773 int rc;
3774
3775 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3776
3777 if (rc < 0)
3778 return rc;
3779
3780 /* a value is being successfully returned */
3781 return 0;
3782}
Jeff Johnson295189b2012-06-20 16:38:30 -07003783
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303784static int iw_get_linkspeed_priv(struct net_device *dev,
3785 struct iw_request_info *info,
3786 union iwreq_data *wrqu, char *extra)
3787{
3788 int ret;
3789
3790 vos_ssr_protect(__func__);
3791 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3792 vos_ssr_unprotect(__func__);
3793
3794 return ret;
3795}
3796
Jeff Johnson295189b2012-06-20 16:38:30 -07003797/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303798 * Support for the RSSI & RSSI-APPROX private commands
3799 * Per the WiFi framework the response must be of the form
3800 * "<ssid> rssi <xx>"
3801 * unless we are not associated, in which case the response is
3802 * "OK"
3803 */
3804static int iw_get_rssi(struct net_device *dev,
3805 struct iw_request_info *info,
3806 union iwreq_data *wrqu, char *extra)
3807{
3808 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3809 char *cmd = extra;
3810 int len = wrqu->data.length;
3811 v_S7_t s7Rssi = 0;
3812 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3813 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3814 VOS_STATUS vosStatus;
3815 int rc;
3816
3817 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3818 (0 == ssidlen) || (ssidlen >= len))
3819 {
3820 /* we are not connected or our SSID is too long
3821 so we cannot report an rssi */
3822 rc = scnprintf(cmd, len, "OK");
3823 }
3824 else
3825 {
3826 /* we are connected with a valid SSID
3827 so we can write the SSID into the return buffer
3828 (note that it is not NUL-terminated) */
3829 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3830
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303831 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303832 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3833
3834 if (VOS_STATUS_SUCCESS == vosStatus)
3835 {
3836 /* append the rssi to the ssid in the format required by
3837 the WiFI Framework */
3838 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3839 rc += ssidlen;
3840 }
3841 else
3842 {
3843 rc = -1;
3844 }
3845 }
3846
3847 /* verify that we wrote a valid response */
3848 if ((rc < 0) || (rc >= len))
3849 {
3850 // encoding or length error?
3851 hddLog(VOS_TRACE_LEVEL_ERROR,
3852 "%s: Unable to encode RSSI, got [%s]",
3853 __func__, cmd);
3854 return -EIO;
3855 }
3856
3857 /* a value is being successfully returned */
3858 return rc;
3859}
3860
3861/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 * Support for SoftAP channel range private command
3863 */
3864static int iw_softap_set_channel_range( struct net_device *dev,
3865 int startChannel,
3866 int endChannel,
3867 int band)
3868{
Jeff Johnson43971f52012-07-17 12:26:56 -07003869 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 int ret = 0;
3871 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3872 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003873 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3874
Jeff Johnson295189b2012-06-20 16:38:30 -07003875
3876 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3877 if (VOS_STATUS_SUCCESS != status)
3878 {
3879 ret = -EINVAL;
3880 }
Yathish9f22e662012-12-10 14:21:35 -08003881 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 return ret;
3883}
3884
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303885static uint8 chartohex(char c)
3886{
3887 uint8 val = 0;
3888 if (c >= '0' && c <= '9')
3889 val = c - '0';
3890 else if (c >= 'a' && c <= 'f')
3891 val = c - 'a' + 10;
3892 else if (c >= 'A' && c <= 'F')
3893 val = c - 'A' + 10;
3894 else
3895 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3896
3897 return val;
3898}
3899
3900uint8 getByte(char **buf)
3901{
3902 uint8 byte = 0;
3903 char *temp = *buf;
3904 byte = chartohex(*temp) * 16;
3905 temp++;
3906 byte += chartohex(*temp);
3907 temp++;
3908 *buf = temp;
3909 return byte;
3910}
3911
3912static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3913{
3914 tSir80211Header *macHeader;
3915 int i = 0, j = 0, length = 0;
3916 uint8 byte = 0;
3917 char *temp = pBuffer;
3918 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303919 char *pHeader;
3920 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303921
3922 macHeader = &pkt->macHeader;
3923
3924 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3925
3926 temp++;
3927
3928 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3929 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3930 pkt->encParams.keyParams.key[0].keyId);
3931
3932 for (i = 0; i< 16; i++) {
3933 pkt->encParams.keyParams.key[0].key[i]
3934 = getByte(&temp);
3935 }
3936
3937 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3938 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3939
3940 for (i = 0; i< 6; i++) {
3941 pkt->encParams.pn[i]
3942 = getByte(&temp);
3943 }
3944
3945 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3946 &pkt->encParams.pn[0], 6, 0);
3947
3948 for (i = 0, j= 5; i< 3; i++, j--) {
3949 byte = pkt->encParams.pn[i];
3950 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3951 pkt->encParams.pn[j] = byte;
3952 }
3953
3954 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303955 if (length > sizeof(tSir80211Header))
3956 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303957
Srinivas Dasari2382de62015-01-22 15:00:04 +05303958 pHeader = temp;
3959 vos_mem_zero(&header, sizeof(tSir80211Header));
3960 for (i = 0; i < length; i++) {
3961 *((uint8 *)&header + i) = getByte(&pHeader);
3962 }
3963
3964 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3965 (char *)&header, length, 0);
3966
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303967 byte = getByte(&temp);
3968
3969 macHeader->frameCtrl.protVer = byte & 0x3;
3970 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3971 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3972
3973 byte = getByte(&temp);
3974 macHeader->frameCtrl.toDS = (byte) & 0x1;
3975 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3976 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3977 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3978 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3979 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3980 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3981 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3982
3983 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3984 "macHeader->frameCtrl.type : %x "
3985 "macHeader->frameCtrl.subType : %x "
3986 "macHeader->frameCtrl.toDS : %x "
3987 "macHeader->frameCtrl.fromDS : %x "
3988 "macHeader->frameCtrl.moreFrag : %x "
3989 "macHeader->frameCtrl.retry : %x "
3990 "macHeader->frameCtrl.powerMgmt : %x "
3991 "macHeader->frameCtrl.MoreData : %x "
3992 "macHeader->frameCtrl.wep : %x "
3993 "macHeader->frameCtrl.order : %x "
3994 , macHeader->frameCtrl.protVer
3995 , macHeader->frameCtrl.type
3996 , macHeader->frameCtrl.subType
3997 , macHeader->frameCtrl.toDS
3998 , macHeader->frameCtrl.fromDS
3999 , macHeader->frameCtrl.moreFrag
4000 , macHeader->frameCtrl.retry
4001 , macHeader->frameCtrl.powerMgmt
4002 , macHeader->frameCtrl.moreData
4003 , macHeader->frameCtrl.wep
4004 , macHeader->frameCtrl.order);
4005
4006
4007 macHeader->usDurationId = getByte(&temp);
4008 macHeader->usDurationId += getByte(&temp) << 8;
4009
4010 macHeader->vA1[0] = getByte(&temp);
4011 macHeader->vA1[1] = getByte(&temp);
4012 macHeader->vA1[2] = getByte(&temp);
4013 macHeader->vA1[3] = getByte(&temp);
4014 macHeader->vA1[4] = getByte(&temp);
4015 macHeader->vA1[5] = getByte(&temp);
4016
4017 macHeader->vA2[0] = getByte(&temp);
4018 macHeader->vA2[1] = getByte(&temp);
4019 macHeader->vA2[2] = getByte(&temp);
4020 macHeader->vA2[3] = getByte(&temp);
4021 macHeader->vA2[4] = getByte(&temp);
4022 macHeader->vA2[5] = getByte(&temp);
4023
4024 macHeader->vA3[0] = getByte(&temp);
4025 macHeader->vA3[1] = getByte(&temp);
4026 macHeader->vA3[2] = getByte(&temp);
4027 macHeader->vA3[3] = getByte(&temp);
4028 macHeader->vA3[4] = getByte(&temp);
4029 macHeader->vA3[5] = getByte(&temp);
4030
4031 macHeader->sSeqCtrl = getByte(&temp);
4032 fragNum = macHeader->sSeqCtrl & 0xF;
4033 macHeader->sSeqCtrl >>= 4;
4034
4035 macHeader->sSeqCtrl += getByte(&temp) << 4;
4036
4037 macHeader->sSeqCtrl |= fragNum << 12;
4038
4039 if (length == 30 || length == 32) {
4040 macHeader->optvA4[0] = getByte(&temp);
4041 macHeader->optvA4[1] = getByte(&temp);
4042 macHeader->optvA4[2] = getByte(&temp);
4043 macHeader->optvA4[3] = getByte(&temp);
4044 macHeader->optvA4[4] = getByte(&temp);
4045 macHeader->optvA4[5] = getByte(&temp);
4046 }
4047
4048 if (length == 26 || length == 32) {
4049 macHeader->usQosCtrl = getByte(&temp);
4050 macHeader->usQosCtrl += getByte(&temp) << 8;
4051 }
4052
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304053 //parse payload
4054 length = getByte(&temp);
4055 length += getByte(&temp) << 8;
4056 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4057
Manjeet Singh5830f142016-11-21 18:21:17 +05304058 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
4059 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
4060
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304061 pkt->data.length = length;
4062
4063 for (i = 0; i< length; i++) {
4064 pkt->data.data[i] = getByte(&temp);
4065 }
4066
4067 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4068 &pkt->data.data[0], pkt->data.length, 0);
4069}
4070
4071/**---------------------------------------------------------------------------
4072
4073 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4074 encrypt message request
4075 This is an asynchronous callback function from SME when the encrypted data
4076 is received
4077
4078 \pEncInfoRsp -> Encrypted data info
4079
4080 \return - 0 for success non-zero for failure
4081 --------------------------------------------------------------------------*/
4082static void
4083hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4084{
4085 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4086
4087 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4088
4089 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4090 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4091 pEncryptedDataRsp->encryptedPayload.length);
4092 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4093 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4094 pEncryptedDataRsp->encryptedPayload.data,
4095 pEncryptedDataRsp->encryptedPayload.length, 0);
4096}
4097
Jeff Johnson295189b2012-06-20 16:38:30 -07004098VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4099{
4100 struct statsContext context;
4101 eHalStatus status;
4102 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304103 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 if (NULL == pAdapter)
4106 {
4107 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4108 return VOS_STATUS_E_FAULT;
4109 }
4110
4111 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4112 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304113 if (pHddCtx->isLogpInProgress) {
4114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4115 "%s:LOGP in Progress. Ignore!!!", __func__);
4116 return VOS_STATUS_E_FAILURE;
4117 }
4118
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 init_completion(&context.completion);
4120
4121 context.pAdapter = pAdapter;
4122 context.magic = POWER_CONTEXT_MAGIC;
4123
4124 if (DRIVER_POWER_MODE_ACTIVE == mode)
4125 {
4126 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4127 "Full Power", __func__);
4128 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4129 iw_power_callback_fn, &context,
4130 eSME_FULL_PWR_NEEDED_BY_HDD);
4131 // Enter Full power command received from GUI this means we are disconnected
4132 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4133 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4134 if (eHAL_STATUS_PMC_PENDING == status)
4135 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004136 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 int lrc = wait_for_completion_interruptible_timeout(
4138 &context.completion,
4139 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004140
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 if (lrc <= 0)
4142 {
4143 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004144 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 }
4146 }
4147 }
4148 else if (DRIVER_POWER_MODE_AUTO == mode)
4149 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304150 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4151 * was already in BMPS state and thus either STA or P2P-CLI is in
4152 * associated state and authenticated, so even if STA connState is
4153 * not associated it can be assumed that P2P-CLI is associated and
4154 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4155 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4156 * if all condition are satisfied for entering BMPS.
4157 */
4158 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4159 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304160 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304161 hddLog(LOGE,
4162 FL("Station is associated but, still not Authenticated ignore "
4163 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304164 return VOS_STATUS_E_AGAIN;
4165 }
4166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4168 {
4169 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4170 __func__);
4171 // Enter BMPS command received from GUI this means DHCP is completed
4172 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4173 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4174 FALSE);
4175 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4176 iw_power_callback_fn, &context);
4177 if (eHAL_STATUS_PMC_PENDING == status)
4178 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004179 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 int lrc = wait_for_completion_interruptible_timeout(
4181 &context.completion,
4182 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 if (lrc <= 0)
4184 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004185 hddLog(VOS_TRACE_LEVEL_ERROR,
4186 "%s: SME %s while requesting BMPS",
4187 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 }
4189 }
4190 }
4191 else
4192 {
4193 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4194 "enabled in the cfg");
4195 }
4196 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004197
4198 /* either we never sent a request, we sent a request and received a
4199 response or we sent a request and timed out. if we never sent a
4200 request or if we sent a request and got a response, we want to
4201 clear the magic out of paranoia. if we timed out there is a
4202 race condition such that the callback function could be
4203 executing at the same time we are. of primary concern is if the
4204 callback function had already verified the "magic" but had not
4205 yet set the completion variable when a timeout occurred. we
4206 serialize these activities by invalidating the magic while
4207 holding a shared spinlock which will cause us to block if the
4208 callback is currently executing */
4209 spin_lock(&hdd_context_lock);
4210 context.magic = 0;
4211 spin_unlock(&hdd_context_lock);
4212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 return VOS_STATUS_SUCCESS;
4214}
4215
4216VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4217 hdd_adapter_t *pAdapter)
4218{
4219 VOS_STATUS vos_Status;
4220
4221 if ((NULL == pAdapter) || (NULL == pHddCtx))
4222 {
4223 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4224 return VOS_STATUS_E_FAULT;
4225 }
4226
4227 /**Exit from Deep sleep or standby if we get the driver
4228 START cmd from android GUI
4229 */
4230 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4231 {
4232 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4233 "from Stand by",__func__);
4234 vos_Status = hdd_exit_standby(pHddCtx);
4235 }
4236 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4237 {
4238 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4239 "from deep sleep",__func__);
4240 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4241 }
4242 else
4243 {
4244 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4245 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4246 vos_Status = VOS_STATUS_SUCCESS;
4247 }
4248
4249 return vos_Status;
4250}
4251
4252VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4253{
4254 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4255
4256 if (NULL == pHddCtx)
4257 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304258 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 return VOS_STATUS_E_FAULT;
4260 }
4261
4262 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4263 {
4264 //Execute standby procedure.
4265 //Executing standby procedure will cause the STA to
4266 //disassociate first and then the chip will be put into standby.
4267 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4268 vos_Status = hdd_enter_standby(pHddCtx);
4269 }
4270 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4271 pHddCtx->cfg_ini->nEnableDriverStop)
4272 {
4273 //Execute deep sleep procedure
4274 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004275 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 //Deep sleep not supported
4277 vos_Status = hdd_enter_standby(pHddCtx);
4278 }
4279 else
4280 {
4281 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4282 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4283 vos_Status = VOS_STATUS_SUCCESS;
4284 }
4285
4286 return vos_Status;
4287}
4288
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004289
4290void* wlan_hdd_change_country_code_callback(void *pAdapter)
4291{
4292
4293 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004294 complete(&call_back_pAdapter->change_country_code);
4295
4296 return NULL;
4297}
4298
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304299static int __iw_set_priv(struct net_device *dev,
4300 struct iw_request_info *info,
4301 union iwreq_data *wrqu, char *extra)
4302{
4303 hdd_adapter_t *pAdapter;
4304 char *cmd = NULL;
4305 int cmd_len = wrqu->data.length;
4306 int rc = 0, ret = 0;
4307 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4308
4309 hdd_context_t *pHddCtx;
4310
4311 ENTER();
4312
4313 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4314 if (NULL == pAdapter)
4315 {
4316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4317 "mem_alloc_copy_from_user_helper fail");
4318 return -EINVAL;
4319 }
4320 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4321 rc = wlan_hdd_validate_context(pHddCtx);
4322 if (0 != rc)
4323 {
4324 return rc;
4325 }
4326
4327 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4328 wrqu->data.length);
4329 if (NULL == cmd)
4330 {
4331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4332 "mem_alloc_copy_from_user_helper fail");
4333 return -ENOMEM;
4334 }
4335
4336 if (ioctl_debug)
4337 {
4338 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4339 }
4340
4341 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4342 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4343
4344 if (strncmp(cmd, "CSCAN", 5) == 0 )
4345 {
4346 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4348 "%s: Error in iw_set_scan!", __func__);
4349 rc = -EINVAL;
4350 }
4351 }
4352 else if( strcasecmp(cmd, "start") == 0 ) {
4353
4354 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4355 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4356
4357 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4358 if (vos_status == VOS_STATUS_SUCCESS)
4359 {
4360 union iwreq_data wrqu;
4361 char buf[10];
4362
4363 memset(&wrqu, 0, sizeof(wrqu));
4364 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4365 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4366 }
4367 else
4368 {
4369 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4370 rc = -EIO;
4371 }
4372 goto done;
4373 }
4374 else if( strcasecmp(cmd, "stop") == 0 )
4375 {
4376 union iwreq_data wrqu;
4377 char buf[10];
4378
4379 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4380
4381 wlan_hdd_enter_lowpower(pHddCtx);
4382 memset(&wrqu, 0, sizeof(wrqu));
4383 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4384 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4385 goto done;
4386 }
4387 else if (strcasecmp(cmd, "macaddr") == 0)
4388 {
4389 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4390 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4391 }
4392 else if (strcasecmp(cmd, "scan-active") == 0)
4393 {
4394 hddLog(LOG1,
4395 FL("making default scan to active"));
4396 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4397 ret = snprintf(cmd, cmd_len, "OK");
4398 }
4399 else if (strcasecmp(cmd, "scan-passive") == 0)
4400 {
4401 hddLog(LOG1,
4402 FL("making default scan to passive"));
4403 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4404 ret = snprintf(cmd, cmd_len, "OK");
4405 }
4406 else if( strcasecmp(cmd, "scan-mode") == 0 )
4407 {
4408 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4409 }
4410 else if( strcasecmp(cmd, "linkspeed") == 0 )
4411 {
4412 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4413 }
4414 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4415 {
4416 ret = iw_get_rssi(dev, info, wrqu, cmd);
4417 }
4418 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4419 int mode;
4420 char *ptr;
4421
4422 if (9 < cmd_len)
4423 {
4424 ptr = (char*)(cmd + 9);
4425
4426 }else{
4427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4428 "CMD LENGTH %d is not correct",cmd_len);
4429 kfree(cmd);
4430 return -EINVAL;
4431 }
4432
4433 if (1 != sscanf(ptr,"%d",&mode))
4434 {
4435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4436 "powermode input %s is not correct",ptr);
4437 kfree(cmd);
4438 return -EIO;
4439 }
4440
4441 wlan_hdd_enter_bmps(pAdapter, mode);
4442 /*TODO:Set the power mode*/
4443 }
4444 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4445 v_U32_t pmc_state;
4446 v_U16_t value;
4447
4448 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4449 if(pmc_state == BMPS) {
4450 value = DRIVER_POWER_MODE_AUTO;
4451 }
4452 else {
4453 value = DRIVER_POWER_MODE_ACTIVE;
4454 }
4455 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4456 }
4457 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4458 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4459 /*TODO: set the btcoexmode*/
4460 }
4461 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4462
4463 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4464 /*TODO: Return the btcoex status*/
4465 }
4466 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4467
4468 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4469
4470 /*TODO: Enable Rx data Filter*/
4471 }
4472 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4473
4474 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4475
4476 /*TODO: Disable Rx data Filter*/
4477 }
4478 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4479
4480 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4481 /*TODO: rxfilter-statistics*/
4482 }
4483 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4484
4485 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4486 /*TODO: rxfilter-add*/
4487 }
4488 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4489
4490 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4491 /*TODO: rxfilter-remove*/
4492 }
4493#ifdef FEATURE_WLAN_SCAN_PNO
4494 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4495 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4496 /*TODO: support pnosetup*/
4497 }
4498 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4499 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4500 /*TODO: support pnoforce*/
4501 }
4502 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4503
4504 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4505 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4506 kfree(cmd);
4507 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4508 }
4509 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4510 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4511 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4512 kfree(cmd);
4513 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4514 }
4515#endif /*FEATURE_WLAN_SCAN_PNO*/
4516 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4517 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4518 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4519 kfree(cmd);
4520 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4521 }
4522 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4523 tSirTxPerTrackingParam tTxPerTrackingParam;
4524 char *ptr;
4525
4526 if (18 < cmd_len)
4527 {
4528 ptr = (char*)(cmd + 18);
4529 }else{
4530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4531 "CMD LENGTH %d is not correct",cmd_len);
4532 kfree(cmd);
4533 return -EINVAL;
4534 }
4535
4536 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4537 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4538 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4539 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4540 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4541 {
4542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4543 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4544 kfree(cmd);
4545 return -EIO;
4546 }
4547
4548 // parameters checking
4549 // period has to be larger than 0
4550 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4551 {
4552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4553 kfree(cmd);
4554 return -EIO;
4555 }
4556
4557 // use default value 5 is the input is not reasonable. in unit of 10%
4558 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4559 {
4560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4561 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4562 }
4563
4564 // default is 5
4565 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4566 {
4567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4568 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4569 }
4570
4571 if (eHAL_STATUS_SUCCESS !=
4572 sme_SetTxPerTracking(pHddCtx->hHal,
4573 hdd_tx_per_hit_cb,
4574 (void*)pAdapter, &tTxPerTrackingParam)) {
4575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4576 rc = -EIO;
4577 }
4578 }
4579 else {
4580 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4581 __func__, cmd);
4582 }
4583done:
4584 /* many of the commands write information back into the command
4585 string using snprintf(). check the return value here in one
4586 place */
4587 if ((ret < 0) || (ret >= cmd_len))
4588 {
4589 /* there was an encoding error or overflow */
4590 rc = -EINVAL;
4591 }
4592 else if (ret > 0)
4593 {
4594 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4595 {
4596 hddLog(VOS_TRACE_LEVEL_ERROR,
4597 "%s: failed to copy data to user buffer", __func__);
4598 kfree(cmd);
4599 return -EFAULT;
4600 }
4601 wrqu->data.length = ret;
4602 }
4603
4604 if (ioctl_debug)
4605 {
4606 pr_info("%s: rsp [%s] len [%d] status %d\n",
4607 __func__, cmd, wrqu->data.length, rc);
4608 }
4609 kfree(cmd);
4610 EXIT();
4611 return rc;
4612}
4613
4614static int iw_set_priv(struct net_device *dev,
4615 struct iw_request_info *info,
4616 union iwreq_data *wrqu, char *extra)
4617{
4618 int ret;
4619 vos_ssr_protect(__func__);
4620 ret = __iw_set_priv(dev, info, wrqu, extra);
4621 vos_ssr_unprotect(__func__);
4622
4623 return ret;
4624}
4625
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304626static int __iw_set_nick(struct net_device *dev,
4627 struct iw_request_info *info,
4628 union iwreq_data *wrqu, char *extra)
4629{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304630 hdd_adapter_t *pAdapter;
4631 hdd_context_t *pHddCtx;
4632 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304633
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304634 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304635
4636 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4637 if (NULL == pAdapter)
4638 {
4639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4640 "%s: Adapter is NULL",__func__);
4641 return -EINVAL;
4642 }
4643
4644 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4645 ret = wlan_hdd_validate_context(pHddCtx);
4646 if (0 != ret)
4647 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304648 return ret;
4649 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304650 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304651 return 0;
4652}
4653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654static int iw_set_nick(struct net_device *dev,
4655 struct iw_request_info *info,
4656 union iwreq_data *wrqu, char *extra)
4657{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304658 int ret;
4659
4660 vos_ssr_protect(__func__);
4661 ret = __iw_set_nick(dev, info, wrqu, extra);
4662 vos_ssr_unprotect(__func__);
4663
4664 return ret;
4665}
4666
4667static int __iw_get_nick(struct net_device *dev,
4668 struct iw_request_info *info,
4669 union iwreq_data *wrqu, char *extra)
4670{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304671 hdd_adapter_t *pAdapter;
4672 hdd_context_t *pHddCtx;
4673 int ret = 0;
4674
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304676
4677 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4678 if (NULL == pAdapter)
4679 {
4680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4681 "%s: Adapter is NULL",__func__);
4682 return -EINVAL;
4683 }
4684
4685 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4686 ret = wlan_hdd_validate_context(pHddCtx);
4687 if (0 != ret)
4688 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304689 return ret;
4690 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304691 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 return 0;
4693}
4694
4695static int iw_get_nick(struct net_device *dev,
4696 struct iw_request_info *info,
4697 union iwreq_data *wrqu, char *extra)
4698{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304699 int ret;
4700
4701 vos_ssr_protect(__func__);
4702 ret = __iw_get_nick(dev, info, wrqu, extra);
4703 vos_ssr_unprotect(__func__);
4704
4705 return ret;
4706}
4707
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304708/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304709static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4710{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304711 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4712 hdd_context_t *pHddCtx;
4713 hdd_station_ctx_t *pHddStaCtx;
4714 v_S7_t snr = 0, rssi = 0;
4715 eHalStatus status = eHAL_STATUS_SUCCESS;
4716
4717 ENTER();
4718
4719 if (NULL == pAdapter)
4720 {
4721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4722 "%s: Adapter is NULL",__func__);
4723 return NULL;
4724 }
4725
4726 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4727 status = wlan_hdd_validate_context(pHddCtx);
4728 if (0 != status)
4729 {
4730 return NULL;
4731 }
4732
4733 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4734 if (NULL == pHddStaCtx)
4735 {
4736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4737 "%s: STA Context is NULL",__func__);
4738 return NULL;
4739 }
4740
4741 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4742 {
4743 wlan_hdd_get_station_stats(pAdapter);
4744 wlan_hdd_get_snr(pAdapter, &snr);
4745 wlan_hdd_get_rssi(pAdapter, &rssi);
4746
4747 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4748 pAdapter->iwStats.status = 0;
4749 pAdapter->iwStats.qual.qual = snr;
4750 pAdapter->iwStats.qual.level = rssi;
4751 pAdapter->iwStats.qual.noise = rssi - snr;
4752 pAdapter->iwStats.discard.code = 0;
4753 pAdapter->iwStats.discard.retries= 0;
4754 pAdapter->iwStats.miss.beacon = 0;
4755 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4756 }
4757 else
4758 {
4759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4760 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4761 return NULL;
4762 }
4763
4764 EXIT();
4765 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004766}
4767
4768static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4769{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304770
4771 struct iw_statistics *stats;
4772
4773 vos_ssr_protect(__func__);
4774 stats = __get_wireless_stats(dev);
4775 vos_ssr_unprotect(__func__);
4776
4777 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004778}
4779
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304780static int __iw_set_encode(struct net_device *dev,
4781 struct iw_request_info *info,
4782 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004783
4784{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304785 hdd_adapter_t *pAdapter;
4786 hdd_station_ctx_t *pHddStaCtx;
4787 hdd_wext_state_t *pWextState;
4788 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 struct iw_point *encoderq = &(wrqu->encoding);
4790 v_U32_t keyId;
4791 v_U8_t key_length;
4792 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4793 v_BOOL_t fKeyPresent = 0;
4794 int i;
4795 eHalStatus status = eHAL_STATUS_SUCCESS;
4796
4797
4798 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304799 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4800 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4803 "%s: Adapter is NULL",__func__);
4804 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 }
4806
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304807 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4808 status = wlan_hdd_validate_context(pHddCtx);
4809 if (0 != status)
4810 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304811 return status;
4812 }
4813 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4814 if (NULL == pWextState)
4815 {
4816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4817 "%s: pWextState is NULL ",__func__);
4818 return -EINVAL;
4819 }
4820 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4821 if (NULL == pHddStaCtx)
4822 {
4823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4824 "%s: STA Context is NULL",__func__);
4825 return -EINVAL;
4826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004827
4828 keyId = encoderq->flags & IW_ENCODE_INDEX;
4829
4830 if(keyId)
4831 {
4832 if(keyId > MAX_WEP_KEYS)
4833 {
4834 return -EINVAL;
4835 }
4836
4837 fKeyPresent = 1;
4838 keyId--;
4839 }
4840 else
4841 {
4842 fKeyPresent = 0;
4843 }
4844
4845
4846 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4847 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 if(!fKeyPresent) {
4850
4851 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4852
4853 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4854 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4855 }
4856 }
4857 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4858 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4859 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4860 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4861
4862 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4863 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4864
4865 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4866 {
4867 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4868 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004869 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304870 {
4871 long ret;
4872 ret = wait_for_completion_interruptible_timeout(
4873 &pAdapter->disconnect_comp_var,
4874 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4875 if (ret <= 0)
4876 hddLog(VOS_TRACE_LEVEL_ERROR,
4877 FL("failed wait on disconnect_comp_var %ld"), ret);
4878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 }
4880
4881 return status;
4882
4883 }
4884
4885 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4886 {
4887 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4888
4889 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4890
4891 }
4892
4893
4894 if(wrqu->data.length > 0)
4895 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004896 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004897
4898 key_length = wrqu->data.length;
4899
4900 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4901
4902 if(5 == key_length)
4903 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004904 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004905
4906 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4907 {
4908 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4909 }
4910 else
4911 {
4912 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4913 }
4914 }
4915 else if(13 == key_length)
4916 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004917 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004918
4919 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4920 {
4921 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4922 }
4923 else
4924 {
4925 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4926 }
4927 }
4928 else
4929 {
4930 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004931 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 return -EINVAL;
4933 }
4934
4935 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4936 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4937 pWextState->roamProfile.EncryptionType.numEntries = 1;
4938 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4939 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4940 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4941
4942 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4943 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4944 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4945 {
4946
4947 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4948
4949 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4950 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4951
4952 return status;
4953 }
4954 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304955 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 return 0;
4957}
4958
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304959static int iw_set_encode(struct net_device *dev,
4960 struct iw_request_info *info,
4961 union iwreq_data *wrqu,char *extra)
4962{
4963 int ret;
4964
4965 vos_ssr_protect(__func__);
4966 ret = __iw_set_encode(dev, info, wrqu, extra);
4967 vos_ssr_unprotect(__func__);
4968
4969 return ret;
4970}
4971
4972static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 struct iw_request_info *info,
4974 struct iw_point *dwrq,
4975 char *extra)
4976{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304977 hdd_adapter_t *pAdapter;
4978 hdd_wext_state_t *pWextState;
4979 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 int keyId;
4981 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4982 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304983 int i, ret = 0;
4984 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004985
4986 ENTER();
4987
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304988 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4989 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4992 "%s: Adapter is NULL",__func__);
4993 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004994 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304995 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4996 ret = wlan_hdd_validate_context(pHddCtx);
4997 if (0 != ret)
4998 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304999 return ret;
5000 }
5001 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5002 if (NULL == pWextState)
5003 {
5004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5005 "%s: pWextState is NULL",__func__);
5006 return -EINVAL;
5007 }
5008 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005009
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 keyId = pRoamProfile->Keys.defaultIndex;
5011
5012 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
5013 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005014 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 return -EINVAL;
5016 }
5017
5018 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
5019 {
5020 dwrq->flags |= IW_ENCODE_ENABLED;
5021 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05305022 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
5023 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 }
5025 else
5026 {
5027 dwrq->flags |= IW_ENCODE_DISABLED;
5028 }
5029
5030 for(i=0; i < MAX_WEP_KEYS; i++)
5031 {
5032 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5033 {
5034 continue;
5035 }
5036 else
5037 {
5038 break;
5039 }
5040 }
5041
5042 if(MAX_WEP_KEYS == i)
5043 {
5044 dwrq->flags |= IW_ENCODE_NOKEY;
5045 }
5046 else
5047 {
5048 dwrq->flags |= IW_ENCODE_ENABLED;
5049 }
5050
5051 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5052
5053 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5054 {
5055 dwrq->flags |= IW_ENCODE_DISABLED;
5056 }
5057
5058 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5059
5060 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5061 {
5062 dwrq->flags |= IW_ENCODE_OPEN;
5063 }
5064 else
5065 {
5066 dwrq->flags |= IW_ENCODE_RESTRICTED;
5067 }
5068 EXIT();
5069 return 0;
5070
5071}
5072
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305073static int iw_get_encodeext(struct net_device *dev,
5074 struct iw_request_info *info,
5075 struct iw_point *dwrq,
5076 char *extra)
5077{
5078 int ret;
5079 vos_ssr_protect(__func__);
5080 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5081 vos_ssr_unprotect(__func__);
5082
5083 return ret;
5084}
5085
5086static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 struct iw_request_info *info,
5088 union iwreq_data *wrqu, char *extra)
5089{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305090 hdd_adapter_t *pAdapter;
5091 hdd_station_ctx_t *pHddStaCtx;
5092 hdd_wext_state_t *pWextState;
5093 hdd_context_t *pHddCtx;
5094 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005095
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305096 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 v_U32_t status = 0;
5098
5099 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5100
5101 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5102
5103 int key_index;
5104 struct iw_point *encoding = &wrqu->encoding;
5105 tCsrRoamSetKey setKey;
5106 v_U32_t roamId= 0xFF;
5107 VOS_STATUS vos_status;
5108
5109 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305110 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5111 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5114 "%s: Adapter is NULL",__func__);
5115 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305117 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5118 status = wlan_hdd_validate_context(pHddCtx);
5119 if (0 != status)
5120 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305121 return status;
5122 }
5123 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5124 if (NULL == pHddStaCtx)
5125 {
5126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5127 "%s: STA Context is NULL",__func__);
5128 return -EINVAL;
5129 }
5130 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5131 if (NULL == pWextState)
5132 {
5133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5134 "%s: pWextState is NULL",__func__);
5135 return -EINVAL;
5136 }
5137 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 key_index = encoding->flags & IW_ENCODE_INDEX;
5139
5140 if(key_index > 0) {
5141
5142 /*Convert from 1-based to 0-based keying*/
5143 key_index--;
5144 }
5145 if(!ext->key_len) {
5146
5147 /*Set the encrytion type to NONE*/
5148 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5149 return status;
5150 }
5151
5152 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5153 (IW_ENCODE_ALG_WEP == ext->alg))
5154 {
5155 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5156
Agarwal Ashish971c2882013-10-30 20:11:12 +05305157 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5158 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 return -EINVAL;
5160 }
5161 else {
5162 /*Static wep, update the roam profile with the keys */
5163 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5164 key_index < CSR_MAX_NUM_KEY) {
5165 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5166 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5167
5168 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5169 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5170
5171 }
5172 }
5173 return status;
5174 }
5175
5176 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5177
5178 setKey.keyId = key_index;
5179 setKey.keyLength = ext->key_len;
5180
5181 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5182 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5183 }
5184
5185 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5186 /*Key direction for group is RX only*/
5187 setKey.keyDirection = eSIR_RX_ONLY;
5188 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5189 }
5190 else {
5191
5192 setKey.keyDirection = eSIR_TX_RX;
5193 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5194 }
5195
5196 /*For supplicant pae role is zero*/
5197 setKey.paeRole = 0;
5198
5199 switch(ext->alg)
5200 {
5201 case IW_ENCODE_ALG_NONE:
5202 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5203 break;
5204
5205 case IW_ENCODE_ALG_WEP:
5206 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5207 break;
5208
5209 case IW_ENCODE_ALG_TKIP:
5210 {
5211 v_U8_t *pKey = &setKey.Key[0];
5212
5213 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5214
5215 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5216
5217 /*Supplicant sends the 32bytes key in this order
5218
5219 |--------------|----------|----------|
5220 | Tk1 |TX-MIC | RX Mic |
5221 |--------------|----------|----------|
5222 <---16bytes---><--8bytes--><--8bytes-->
5223
5224 */
5225 /*Sme expects the 32 bytes key to be in the below order
5226
5227 |--------------|----------|----------|
5228 | Tk1 |RX-MIC | TX Mic |
5229 |--------------|----------|----------|
5230 <---16bytes---><--8bytes--><--8bytes-->
5231 */
5232 /* Copy the Temporal Key 1 (TK1) */
5233 vos_mem_copy(pKey,ext->key,16);
5234
5235 /*Copy the rx mic first*/
5236 vos_mem_copy(&pKey[16],&ext->key[24],8);
5237
5238 /*Copy the tx mic */
5239 vos_mem_copy(&pKey[24],&ext->key[16],8);
5240
5241 }
5242 break;
5243
5244 case IW_ENCODE_ALG_CCMP:
5245 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5246 break;
5247
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005248#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005249#define IW_ENCODE_ALG_KRK 6
5250 case IW_ENCODE_ALG_KRK:
5251 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5252 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005253#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005254
5255 default:
5256 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5257 break;
5258 }
5259
5260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005261 ("%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 -07005262
5263#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305264 /* The supplicant may attempt to set the PTK once pre-authentication
5265 is done. Save the key in the UMAC and include it in the ADD
5266 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305268 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305270 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5271 "%s: Update PreAuth Key success", __func__);
5272 return 0;
5273 }
5274 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5275 {
5276 hddLog(VOS_TRACE_LEVEL_ERROR,
5277 "%s: Update PreAuth Key failed", __func__);
5278 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 }
5280#endif /* WLAN_FEATURE_VOWIFI_11R */
5281
5282 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5283
5284 vos_status = wlan_hdd_check_ula_done(pAdapter);
5285 if ( vos_status != VOS_STATUS_SUCCESS )
5286 {
5287 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5288 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5289 __LINE__, vos_status );
5290
5291 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5292 }
5293
5294 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5295
5296 if ( halStatus != eHAL_STATUS_SUCCESS )
5297 {
5298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5299 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5300 __LINE__, halStatus );
5301
5302 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5303 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305304 EXIT();
5305 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005306}
5307
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305308static int iw_set_encodeext(struct net_device *dev,
5309 struct iw_request_info *info,
5310 union iwreq_data *wrqu, char *extra)
5311{
5312 int ret;
5313
5314 vos_ssr_protect(__func__);
5315 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5316 vos_ssr_unprotect(__func__);
5317
5318 return ret;
5319}
5320
5321static int __iw_set_retry(struct net_device *dev,
5322 struct iw_request_info *info,
5323 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005324{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305325 hdd_adapter_t *pAdapter;
5326 tHalHandle hHal;
5327 hdd_context_t *pHddCtx;
5328 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005329
5330 ENTER();
5331
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305332 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5333 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005334 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5336 "%s: Adapter is NULL",__func__);
5337 return -EINVAL;
5338 }
5339
5340 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5341 ret = wlan_hdd_validate_context(pHddCtx);
5342 if (0 != ret)
5343 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305344 return ret;
5345 }
5346
5347 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5348 if (NULL == hHal)
5349 {
5350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5351 "%s: Hal Context is NULL",__func__);
5352 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005353 }
5354
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5356 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5357
Arif Hussain6d2a3322013-11-17 19:50:10 -08005358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005359
5360 return -EINVAL;
5361 }
5362
5363 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5364
5365 if((wrqu->retry.flags & IW_RETRY_LONG))
5366 {
5367 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5368 {
c_hpothub8245442013-11-20 23:41:09 +05305369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5370 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 return -EIO;
5372 }
5373 }
5374 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5375 {
5376 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5377 {
c_hpothub8245442013-11-20 23:41:09 +05305378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5379 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 return -EIO;
5381 }
5382 }
5383 }
5384 else
5385 {
5386 return -EOPNOTSUPP;
5387 }
5388
Arif Hussain6d2a3322013-11-17 19:50:10 -08005389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005390
5391 EXIT();
5392
5393 return 0;
5394
5395}
5396
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305397static int iw_set_retry(struct net_device *dev,
5398 struct iw_request_info *info,
5399 union iwreq_data *wrqu, char *extra)
5400{
5401 int ret;
5402
5403 vos_ssr_protect(__func__);
5404 ret = __iw_set_retry(dev, info, wrqu, extra);
5405 vos_ssr_unprotect(__func__);
5406
5407 return ret;
5408}
5409
5410static int __iw_get_retry(struct net_device *dev,
5411 struct iw_request_info *info,
5412 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005413{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305414 hdd_adapter_t *pAdapter;
5415 hdd_context_t *pHddCtx;
5416 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305418 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005419
5420 ENTER();
5421
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305422 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5423 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005424 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5426 "%s: Adapter is NULL",__func__);
5427 return -EINVAL;
5428 }
5429
5430 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5431 ret = wlan_hdd_validate_context(pHddCtx);
5432 if (0 != ret)
5433 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305434 return ret;
5435 }
5436
5437 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5438 if (NULL == hHal)
5439 {
5440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5441 "%s: Hal Context is NULL",__func__);
5442 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005443 }
5444
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 if((wrqu->retry.flags & IW_RETRY_LONG))
5446 {
5447 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5448
5449 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5450 {
c_hpothub8245442013-11-20 23:41:09 +05305451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5452 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 return -EIO;
5454 }
5455
5456 wrqu->retry.value = retry;
5457 }
5458 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5459 {
5460 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5461
5462 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5463 {
c_hpothub8245442013-11-20 23:41:09 +05305464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5465 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 return -EIO;
5467 }
5468
5469 wrqu->retry.value = retry;
5470 }
5471 else {
5472 return -EOPNOTSUPP;
5473 }
5474
Arif Hussain6d2a3322013-11-17 19:50:10 -08005475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005476
5477 EXIT();
5478
5479 return 0;
5480}
5481
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305482static int iw_get_retry(struct net_device *dev,
5483 struct iw_request_info *info,
5484 union iwreq_data *wrqu, char *extra)
5485{
5486 int ret;
5487
5488 vos_ssr_protect(__func__);
5489 ret = __iw_get_retry(dev, info, wrqu, extra);
5490 vos_ssr_unprotect(__func__);
5491
5492 return ret;
5493}
5494
5495static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 struct iw_request_info *info,
5497 union iwreq_data *wrqu,
5498 char *extra)
5499{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305500 hdd_adapter_t *pAdapter;
5501 hdd_context_t *pHddCtx;
5502 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5504 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305505 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005506
5507 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305508 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5509 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5512 "%s:Adapter is NULL",__func__);
5513 return -EINVAL;
5514 }
5515 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5516 ret = wlan_hdd_validate_context(pHddCtx);
5517 if (0 != ret)
5518 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305519 return ret;
5520 }
5521 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5522 if (NULL == pHddStaCtx)
5523 {
5524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5525 "%s:STA context is NULL",__func__);
5526 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 }
5528
5529 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5530 switch (mlme->cmd) {
5531 case IW_MLME_DISASSOC:
5532 case IW_MLME_DEAUTH:
5533
5534 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5535 {
5536 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5537
5538 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5539 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5540
5541 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5542 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5543
Jeff Johnson43971f52012-07-17 12:26:56 -07005544 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305545 {
5546 long ret;
5547 ret = wait_for_completion_interruptible_timeout(
5548 &pAdapter->disconnect_comp_var,
5549 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5550 if (ret <= 0)
5551 hddLog(VOS_TRACE_LEVEL_ERROR,
5552 FL("failed wait on disconnect_comp_var %ld"), ret);
5553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005555 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005556 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005557
5558 /* Resetting authKeyMgmt */
5559 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5560
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305561 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 netif_tx_disable(dev);
5563 netif_carrier_off(dev);
5564
5565 }
5566 else
5567 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005568 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 -07005569 }
5570 break;
5571 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005572 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 return -EINVAL;
5574 }//end of switch
5575
5576 EXIT();
5577
5578 return status;
5579
5580}
5581
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305582static int iw_set_mlme(struct net_device *dev,
5583 struct iw_request_info *info,
5584 union iwreq_data *wrqu,
5585 char *extra)
5586{
5587 int ret;
5588
5589 vos_ssr_protect(__func__);
5590 ret = __iw_set_mlme(dev, info, wrqu, extra);
5591 vos_ssr_unprotect(__func__);
5592
5593 return ret;
5594}
5595
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305596int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305597{
5598 sHwCalValues hwCalValues;
5599 uint16 hwCalTxPower;
5600 uint8 txPwr = TX_PWR_DEF;
5601
5602 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5603
5604 if (TRUE == set_value) {
5605 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5606 NULL, sizeof(sHwCalValues) )
5607 != VOS_STATUS_SUCCESS) {
5608 return -EINVAL;
5609 }
5610 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5611
5612 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5613 hwCalTxPower, hwCalValues.calData.hwParam7);
5614
5615 txPwr = (int8)(hwCalTxPower & 0x00FF);
5616 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305617 if (txPwr == 0)
5618 txPwr = TX_PWR_DEF;
5619 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305620 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305621 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305622 txPwr = TX_PWR_MAX;
5623
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305624 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305625 eHAL_STATUS_SUCCESS) {
5626 hddLog(VOS_TRACE_LEVEL_ERROR,
5627 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5628 return -EIO;
5629 }
5630
5631 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5632 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305633 if (txPwr == 0)
5634 txPwr = TX_PWR_DEF;
5635 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305636 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305637 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305638 txPwr = TX_PWR_MAX;
5639
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305640 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305641 eHAL_STATUS_SUCCESS) {
5642 hddLog(VOS_TRACE_LEVEL_ERROR,
5643 FL("setting tx power failed for 5GHz band %d"), txPwr);
5644 return -EIO;
5645 }
5646 }
5647 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305648 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305649 eHAL_STATUS_SUCCESS) {
5650 hddLog(VOS_TRACE_LEVEL_ERROR,
5651 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5652 return -EIO;
5653 }
5654
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305655 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305656 eHAL_STATUS_SUCCESS) {
5657 hddLog(VOS_TRACE_LEVEL_ERROR,
5658 FL("setting tx power failed for 5GHz band %d"), txPwr);
5659 return -EIO;
5660 }
5661 }
5662 else {
5663 return -EINVAL;
5664 }
5665
5666 return eHAL_STATUS_SUCCESS;
5667}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305668
5669static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5670{
5671 int ret = 0;
5672 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5673 tDelBaParams del_session;
5674
5675 del_session.session_id = adapter->sessionId;
5676 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5677
5678 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5679 {
5680 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5681 value,NULL, eANI_BOOLEAN_FALSE);
5682 if (ret != eHAL_STATUS_SUCCESS)
5683 {
5684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5685 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5686 return -EIO;
5687 }
5688
5689 } else {
5690 hddLog(VOS_TRACE_LEVEL_ERROR,
5691 FL("Invalid command input"));
5692 return -EINVAL;
5693 }
5694 ret = sme_del_sta_ba_session_req(hal, del_session);
5695 if (ret != VOS_STATUS_SUCCESS) {
5696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5697 return -EINVAL;
5698 }
5699
5700 EXIT();
5701 return ret;
5702}
5703
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305704static int
5705wlan_hdd_sta_mon_op(hdd_context_t *hdd_ctx, uint32_t set_value,
5706 hdd_adapter_t *mon_adapter, hdd_mon_ctx_t *mon_ctx)
5707{
5708 hdd_station_ctx_t *sta_ctx;
5709 VOS_STATUS disable_bmps_status;
5710 hdd_adapter_t *sta_adapter;
5711 v_CONTEXT_t vos_ctx = (WLAN_HDD_GET_CTX(mon_adapter))->pvosContext;
5712
5713 if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) {
5714 hddLog(LOGE, FL("Monitor Interface is not OPENED"));
5715 return -EINVAL;
5716 }
5717
5718 if (set_value == MON_MODE_STOP) {
5719 if (wlan_hdd_check_monitor_state(hdd_ctx))
5720 return 0;
5721 return -EINVAL;
5722 }
5723
5724 sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION);
5725 if (!sta_adapter) {
5726 hddLog(LOGE, FL("No Station adapter"));
5727 return -EINVAL;
5728 }
5729
5730 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
5731 if (!sta_ctx || !hdd_connIsConnected(sta_ctx)) {
5732 hddLog(LOGE, FL("STA is not connected"));
5733 return -EINVAL;
5734 }
5735
5736 if (hdd_isConnectionInProgress(hdd_ctx, NULL, NULL)) {
5737 hddLog(LOGE, FL("Roaming or set-key is in progress"));
5738 return -EBUSY;
5739 }
5740
5741 hdd_disable_roaming(hdd_ctx);
5742
5743 hddLog(LOG1, FL("Disable BMPS"));
5744 disable_bmps_status = hdd_disable_bmps_imps(hdd_ctx,
5745 WLAN_HDD_INFRA_STATION);
5746 if (disable_bmps_status != VOS_STATUS_SUCCESS) {
5747 hddLog(LOGE, FL("Cannot start monitor mode"));
5748 hdd_restore_roaming(hdd_ctx);
5749 return -EINVAL;
5750 }
5751
5752 mon_ctx->ChannelNo = sta_ctx->conn_info.operationChannel;
5753
5754 /*
5755 * In STA + Mon mode, firmware should not consider ChannelBW
5756 */
5757 mon_ctx->ChannelBW = 0;
5758 mon_ctx->crcCheckEnabled = 0;
5759 wlan_hdd_mon_set_typesubtype(mon_ctx, 100);
5760 mon_ctx->is80211to803ConReq = 0;
5761 WLANTL_SetIsConversionReq(vos_ctx, 0);
5762 mon_adapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
5763
5764 mon_ctx->state = MON_MODE_START;
5765 return 0;
5766}
5767
5768/* set param sub-ioctls */
5769static int __iw_mon_setint_getnone(struct net_device *dev,
5770 struct iw_request_info *info,
5771 union iwreq_data *wrqu, char *extra)
5772{
5773 hdd_adapter_t *adapter;
5774 hdd_context_t *hdd_ctx;
5775 hdd_mon_ctx_t *mon_ctx;
5776 int *value = (int *)extra;
5777 int sub_cmd = value[0];
5778 int set_value = value[1];
5779 int ret = 0; /* success */
5780 tVOS_CONCURRENCY_MODE concurrency_mode;
5781
5782 ENTER();
5783 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5784 if (!adapter || adapter->device_mode != WLAN_HDD_MONITOR)
5785 return -EINVAL;
5786
5787 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5788 ret = wlan_hdd_validate_context(hdd_ctx);
5789 if (ret)
5790 return ret;
5791
5792 concurrency_mode = hdd_ctx->concurrency_mode;
5793 if (concurrency_mode != VOS_STA_MON) {
5794 hddLog(LOGE, "invalid concurrency mode %d", concurrency_mode);
5795 return -EINVAL;
5796 }
5797
5798 switch(sub_cmd) {
5799
5800 case WE_SET_MONITOR_STATE:
5801 {
5802 v_U32_t magic = 0;
5803 struct completion cmp_var;
5804 long waitRet = 0;
5805
5806 mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter);
5807 if(!mon_ctx) {
5808 hddLog(LOGE, "Monitor Context NULL");
5809 ret = -EIO;
5810 break;
5811 }
5812
5813 if (mon_ctx->state == set_value) {
5814 hddLog(LOGE, FL("already in same mode curr_mode:%d req_mode: %d"),
5815 mon_ctx->state, set_value);
5816 break;
5817 }
5818
5819 ret = wlan_hdd_sta_mon_op(hdd_ctx, set_value,
5820 adapter,mon_ctx);
5821 if (ret)
5822 break;
5823
5824 mon_ctx->state = set_value;
5825 magic = MON_MODE_MSG_MAGIC;
5826 init_completion(&cmp_var);
5827 if (wlan_hdd_mon_postMsg(&magic, &cmp_var, mon_ctx,
5828 hdd_monPostMsgCb) != VOS_STATUS_SUCCESS) {
5829 hddLog(LOGE, FL("failed to post MON MODE REQ"));
5830 mon_ctx->state =
5831 (mon_ctx->state==MON_MODE_START) ?
5832 MON_MODE_STOP : MON_MODE_START;
5833 magic = 0;
5834 ret = -EIO;
5835 break;
5836 }
5837
5838 waitRet = wait_for_completion_timeout(&cmp_var,
5839 MON_MODE_MSG_TIMEOUT);
5840 magic = 0;
5841 if (waitRet <= 0 ){
5842 hddLog(LOGE, FL("failed to wait on monitor mode completion %ld"),
5843 waitRet);
5844 } else if (mon_ctx->state == MON_MODE_STOP) {
5845 hddLog(LOG1, FL("Enable BMPS"));
5846 hdd_enable_bmps_imps(hdd_ctx);
5847 hdd_restore_roaming(hdd_ctx);
5848 }
5849 }
5850 break;
5851
5852 default:
5853 {
5854 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
5855 sub_cmd, set_value);
5856 }
5857 break;
5858 }
5859
5860 EXIT();
5861 return ret;
5862}
5863
Jeff Johnson295189b2012-06-20 16:38:30 -07005864/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305865static int __iw_setint_getnone(struct net_device *dev,
5866 struct iw_request_info *info,
5867 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005868{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305869 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305870 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305871 hdd_wext_state_t *pWextState;
5872 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305873 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 int *value = (int *)extra;
5875 int sub_cmd = value[0];
5876 int set_value = value[1];
5877 int ret = 0; /* success */
5878 int enable_pbm, enable_mp;
5879#ifdef CONFIG_HAS_EARLYSUSPEND
5880 v_U8_t nEnableSuspendOld;
5881#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005882
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305883 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305884 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5885 if (NULL == pAdapter)
5886 {
5887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5888 "%s: Adapter is NULL",__func__);
5889 return -EINVAL;
5890 }
5891 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5892 ret = wlan_hdd_validate_context(pHddCtx);
5893 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005894 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305895 return ret;
5896 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305897
Katya Nigameae74b62015-05-28 17:19:16 +05305898 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305899 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305900 /* In monitor mode hHal is NULL */
5901 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5902 if (NULL == hHal)
5903 {
5904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5905 "%s: Hal Context is NULL",__func__);
5906 return -EINVAL;
5907 }
Katya Nigameae74b62015-05-28 17:19:16 +05305908 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5909 if (NULL == pWextState)
5910 {
5911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5912 "%s: pWextState is NULL",__func__);
5913 return -EINVAL;
5914 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005915
Katya Nigameae74b62015-05-28 17:19:16 +05305916 INIT_COMPLETION(pWextState->completion_var);
5917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 switch(sub_cmd)
5919 {
5920 case WE_SET_11D_STATE:
5921 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005922 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005923 memset(&smeConfig, 0x00, sizeof(smeConfig));
5924
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305925 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5926 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 sme_GetConfigParam(hHal,&smeConfig);
5928 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5929
Arif Hussain6d2a3322013-11-17 19:50:10 -08005930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005931
5932 sme_UpdateConfig(hHal,&smeConfig);
5933 }
5934 else {
5935 return -EINVAL;
5936 }
5937 break;
5938 }
5939
5940 case WE_WOWL:
5941 {
5942 switch (set_value)
5943 {
5944 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305945 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 break;
5947 case 0x01:
5948 case 0x02:
5949 case 0x03:
5950 enable_mp = (set_value & 0x01) ? 1 : 0;
5951 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005952 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5954 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5955 break;
5956 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005957 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 ret = -EINVAL;
5959 break;
5960 }
5961
5962 break;
5963 }
5964 case WE_SET_POWER:
5965 {
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305966 if (wlan_hdd_check_monitor_state(pHddCtx)) {
5967 hddLog(LOGE, FL("setPower not allowed in STA + MON"));
5968 ret = -EOPNOTSUPP;
5969 break;
5970 }
5971
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 switch (set_value)
5973 {
5974 case 0: //Full Power
5975 {
5976 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305977 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005978
5979 init_completion(&context.completion);
5980
5981 context.pAdapter = pAdapter;
5982 context.magic = POWER_CONTEXT_MAGIC;
5983
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305984 if (NULL == hHal)
5985 return -EINVAL;
5986
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5988 iw_power_callback_fn, &context,
5989 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305990
Jeff Johnson72a40512013-12-19 10:14:15 -08005991 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 {
5993 int lrc = wait_for_completion_interruptible_timeout(
5994 &context.completion,
5995 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005996
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 if (lrc <= 0)
5998 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005999 hddLog(VOS_TRACE_LEVEL_ERROR,
6000 "%s: SME %s while requesting fullpower",
6001 __func__, (0 == lrc) ?
6002 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 }
6004 }
Jeff Johnson72a40512013-12-19 10:14:15 -08006005 /* either we have a response or we timed out. if we timed
6006 out there is a race condition such that the callback
6007 function could be executing at the same time we are. of
6008 primary concern is if the callback function had already
6009 verified the "magic" but had not yet set the completion
6010 variable when a timeout occurred. we serialize these
6011 activities by invalidating the magic while holding a
6012 shared spinlock which will cause us to block if the
6013 callback is currently executing */
6014 spin_lock(&hdd_context_lock);
6015 context.magic = 0;
6016 spin_unlock(&hdd_context_lock);
6017
Arif Hussain6d2a3322013-11-17 19:50:10 -08006018 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 break;
6020 }
6021 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306022 if (hHal)
6023 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
6024 else
6025 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 break;
6027 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306028 if (hHal)
6029 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
6030 else
6031 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 break;
6033 case 3: //Request Bmps
6034 {
6035 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306036 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037
6038 init_completion(&context.completion);
6039
6040 context.pAdapter = pAdapter;
6041 context.magic = POWER_CONTEXT_MAGIC;
6042
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306043 if (NULL == hHal)
6044 return -EINVAL;
6045
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306047 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08006048 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 {
6050 int lrc = wait_for_completion_interruptible_timeout(
6051 &context.completion,
6052 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 if (lrc <= 0)
6054 {
Jeff Johnson72a40512013-12-19 10:14:15 -08006055 hddLog(VOS_TRACE_LEVEL_ERROR,
6056 "%s: SME %s while requesting BMPS",
6057 __func__, (0 == lrc) ? "timeout" :
6058 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 }
6060 }
Jeff Johnson72a40512013-12-19 10:14:15 -08006061 /* either we have a response or we timed out. if we
6062 timed out there is a race condition such that the
6063 callback function could be executing at the same
6064 time we are. of primary concern is if the callback
6065 function had already verified the "magic" but had
6066 not yet set the completion variable when a timeout
6067 occurred. we serialize these activities by
6068 invalidating the magic while holding a shared
6069 spinlock which will cause us to block if the
6070 callback is currently executing */
6071 spin_lock(&hdd_context_lock);
6072 context.magic = 0;
6073 spin_unlock(&hdd_context_lock);
6074
Arif Hussain6d2a3322013-11-17 19:50:10 -08006075 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 break;
6077 }
6078 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306079 if (hHal)
6080 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
6081 else
6082 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 break;
6084 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306085 if (hHal)
6086 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
6087 else
6088 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 break;
6090 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306091 if (hHal)
6092 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
6093 else
6094 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 break;
6096 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306097 if (hHal)
6098 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
6099 else
6100 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 break;
6102 case 8: //Request Standby
6103#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07006104#endif
6105 break;
6106 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306107 if (hHal)
6108 sme_StartAutoBmpsTimer(hHal);
6109 else
6110 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 break;
6112 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306113 if (hHal)
6114 sme_StopAutoBmpsTimer(hHal);
6115 else
6116 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 break;
6118#ifdef CONFIG_HAS_EARLYSUSPEND
6119 case 11://suspend to standby
6120#ifdef CONFIG_HAS_EARLYSUSPEND
6121 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
6122 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
6124#endif
6125 break;
6126 case 12://suspend to deep sleep
6127#ifdef CONFIG_HAS_EARLYSUSPEND
6128 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
6129 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
6131#endif
6132 break;
6133 case 13://resume from suspend
6134#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07006135#endif
6136 break;
6137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006139 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 ret = -EINVAL;
6141 break;
6142 }
6143 break;
6144 }
6145
6146 case WE_SET_MAX_ASSOC:
6147 {
6148 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306149 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
6150 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 {
6152 ret = -EINVAL;
6153 }
6154 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
6155 set_value, NULL, eANI_BOOLEAN_FALSE)
6156 != eHAL_STATUS_SUCCESS )
6157 {
c_hpothub8245442013-11-20 23:41:09 +05306158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6159 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 ret = -EIO;
6161 }
6162 break;
6163 }
6164
6165 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
6166 {
6167 if( 0 == set_value )
6168 {
6169 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
6170 }
6171 else if ( 1 == set_value )
6172 {
6173 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
6174 }
6175 else
6176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006177 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 ret = -EINVAL;
6179 }
6180 break;
6181 }
6182
6183 case WE_SET_DATA_INACTIVITY_TO:
6184 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306185 if (NULL == hHal)
6186 return -EINVAL;
6187
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
6189 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
6190 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6191 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
6192 set_value,
6193 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
6194 {
6195 hddLog(LOGE,"Failure: Could not pass on "
6196 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006197 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 ret = -EINVAL;
6199 }
6200 break;
6201 }
6202 case WE_SET_MAX_TX_POWER:
6203 {
6204 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6205 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6206
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306207 if (NULL == hHal)
6208 return -EINVAL;
6209
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
6211 __func__, set_value);
6212 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
6213 eHAL_STATUS_SUCCESS )
6214 {
6215 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6216 __func__);
6217 return -EIO;
6218 }
6219
6220 break;
6221 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07006222 case WE_SET_MAX_TX_POWER_2_4:
6223 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306224 if (NULL == hHal)
6225 return -EINVAL;
6226
Arif Hussaina5ebce02013-08-09 15:09:58 -07006227 hddLog(VOS_TRACE_LEVEL_INFO,
6228 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6229 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306230 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006231 eHAL_STATUS_SUCCESS)
6232 {
6233 hddLog(VOS_TRACE_LEVEL_ERROR,
6234 "%s: Setting maximum tx power failed for 2.4 GHz band",
6235 __func__);
6236 return -EIO;
6237 }
6238
6239 break;
6240 }
6241 case WE_SET_MAX_TX_POWER_5_0:
6242 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306243 if (NULL == hHal)
6244 return -EINVAL;
6245
Arif Hussaina5ebce02013-08-09 15:09:58 -07006246 hddLog(VOS_TRACE_LEVEL_INFO,
6247 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6248 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306249 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006250 eHAL_STATUS_SUCCESS)
6251 {
6252 hddLog(VOS_TRACE_LEVEL_ERROR,
6253 "%s: Setting maximum tx power failed for 5.0 GHz band",
6254 __func__);
6255 return -EIO;
6256 }
6257
6258 break;
6259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 case WE_SET_HIGHER_DTIM_TRANSITION:
6261 {
6262 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6263 (set_value == eANI_BOOLEAN_TRUE)))
6264 {
6265 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6266 ret = -EINVAL;
6267 }
6268 else
6269 {
6270 if(pAdapter->higherDtimTransition != set_value)
6271 {
6272 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006273 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 }
6275 }
6276
6277 break;
6278 }
6279
6280 case WE_SET_TM_LEVEL:
6281 {
6282 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006283 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6285
6286 break;
6287 }
6288
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306289 case WE_ENABLE_STRICT_FCC_REG:
6290 {
6291 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6292 struct wiphy *wiphy = NULL;
6293 long lrc;
6294 int status;
6295
6296 wiphy = hddCtxt->wiphy;
6297 if(wiphy == NULL)
6298 {
6299 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6300 break;
6301 }
6302 init_completion(&hddCtxt->wiphy_channel_update_event);
6303
6304 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6305
6306 status = regulatory_hint(wiphy, "00");
6307 if(status < 0)
6308 {
6309 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6310 break;
6311 }
6312
6313 /* Wait for completion */
6314 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6315 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6316 if (lrc <= 0)
6317 {
6318 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6319 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6320 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6321 }
6322 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6323
6324 break;
6325 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006326 case WE_SET_DEBUG_LOG:
6327 {
6328 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6329 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306330 if (hHal)
6331 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6332 else
6333 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006334 break;
6335 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306336#ifdef FEATURE_WLAN_TDLS
6337 case WE_SET_TDLS_OFF_CHAN:
6338 {
6339 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6341 __func__, set_value);
6342 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6343 break;
6344 }
6345 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6346 {
6347 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6349 __func__, set_value);
6350 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6351 break;
6352 }
6353 case WE_SET_TDLS_OFF_CHAN_MODE:
6354 {
6355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6356 __func__, set_value);
6357 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6358 break;
6359 }
6360#endif
Peng Xu2446a892014-09-05 17:21:18 +05306361 case WE_SET_SCAN_BAND_PREFERENCE:
6362 {
6363 tSmeConfigParams smeConfig;
6364 memset(&smeConfig, 0x00, sizeof(smeConfig));
6365 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6366 ret = -EINVAL;
6367 break;
6368 }
6369 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6370
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306371 if ((eCSR_BAND_ALL == set_value ||
6372 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6373 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306374 sme_GetConfigParam(hHal, &smeConfig);
6375 smeConfig.csrConfig.scanBandPreference = set_value;
6376
6377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6378 "set band scan preference = %d\n",
6379 smeConfig.csrConfig.scanBandPreference);
6380
6381 sme_UpdateConfig(hHal, &smeConfig);
6382 }
6383 else {
6384 ret = -EINVAL;
6385 }
6386 break;
6387 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306388 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6389 * connection happens so that the params can take effect during
6390 * association. Also this should not be used in STA+p2p concurrency
6391 * as the param will also effect the STA mode.
6392 */
6393 case WE_SET_MIRACAST_VENDOR_CONFIG:
6394 {
6395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306396
Abhishek Singh01c73d12015-03-12 15:13:44 +05306397 hddLog(LOG1, FL(
6398 "Set Miracast vendor tuning %d"), set_value);
6399
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306400 if (NULL == hHal)
6401 return -EINVAL;
6402
Abhishek Singh01c73d12015-03-12 15:13:44 +05306403 if (1 == set_value || 0 == set_value)
6404 {
6405 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6406 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6407 {
6408 hddLog( LOGE, FL("set vendor miracast config failed"));
6409 ret = -EIO;
6410 }
6411 }
6412 else
6413 {
6414 hddLog(LOGE,
6415 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6416 ret = -EINVAL;
6417 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306418 break;
6419 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306420
6421 case WE_GET_FRAME_LOG:
6422 {
6423 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6424 != VOS_STATUS_SUCCESS)
6425 {
6426 ret = -EINVAL;
6427 }
6428 break;
6429 }
6430
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306431 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6432 {
6433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6434 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306435 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306436 {
6437 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6438 set_value);
6439 }
6440 else
6441 ret = -EINVAL;
6442
6443 break;
6444 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306445 /* Bit mask value to enable RTS/CTS for different modes
6446 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6447 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6448 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6449 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6450 * for 5 GHz, VHT80 - 0x1000
6451 */
6452 case WE_SET_RTS_CTS_HTVHT:
6453 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306454
Abhishek Singh41988ba2015-05-25 19:42:29 +05306455 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6456
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306457 if (NULL == hHal)
6458 return -EINVAL;
6459
Abhishek Singh41988ba2015-05-25 19:42:29 +05306460 if (eHAL_STATUS_SUCCESS !=
6461 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6462 {
6463 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6464 ret = -EINVAL;
6465 }
6466 break;
6467 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306468 case WE_SET_MONITOR_STATE:
6469 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306470 v_U32_t magic = 0;
6471 struct completion cmpVar;
6472 long waitRet = 0;
6473 tVOS_CON_MODE mode = hdd_get_conparam();
6474
6475 if( VOS_MONITOR_MODE != mode)
6476 {
6477 hddLog(LOGE, "invalid mode %d", mode);
6478 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306479 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306480 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306481
6482 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6483 if( pMonCtx == NULL )
6484 {
6485 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306486 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306487 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306488 }
6489 if (pMonCtx->state == set_value)
6490 {
6491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6492 FL("already in same mode curr_mode:%d req_mode: %d"),
6493 pMonCtx->state, set_value);
6494 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306495 }
6496 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306497 magic = MON_MODE_MSG_MAGIC;
6498 init_completion(&cmpVar);
6499 if (VOS_STATUS_SUCCESS !=
6500 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6501 pMonCtx, hdd_monPostMsgCb)) {
6502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6503 FL("failed to post MON MODE REQ"));
6504 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6505 MON_MODE_STOP : MON_MODE_START;
6506 magic = 0;
6507 ret = -EIO;
6508 break;
6509 }
6510 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6511 magic = 0;
6512 if (waitRet <= 0 ){
6513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6514 FL("failed to wait on monitor mode completion %ld"),
6515 waitRet);
6516 }
6517 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306518 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306519 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6520 {
6521 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6522 tAniWifiStartLog start_log;
6523 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6524 !vos_isPktStatsEnabled())
6525 {
6526 hddLog(LOGE, FL("per pkt stats not enabled"));
6527 return -EINVAL;
6528 }
6529 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6530
6531 if (1 == set_value || 0 == set_value)
6532 {
6533 start_log.ringId = RING_ID_PER_PACKET_STATS;
6534 start_log.flag = 0;
6535 if (set_value)
6536 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6537 else
6538 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6539
6540 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6541 }
6542 else
6543 {
6544 hddLog(LOGE,
6545 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6546 set_value);
6547 ret = -EINVAL;
6548 }
6549 break;
6550 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306551 case WE_SET_PROXIMITY_ENABLE:
6552 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306553 if (NULL == hHal)
6554 return -EINVAL;
6555
6556 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306557 break;
6558 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306559 case WE_CAP_TSF:
6560 {
6561 if (NULL == hHal)
6562 return -EINVAL;
6563
6564 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6565 break;
6566 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306567 case WE_SET_MODULATED_DTIM:
6568 {
6569 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6570 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6571 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6572 set_value);
6573 return -EINVAL;
6574 } else {
6575 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6576 enableModulatedDTIM = set_value;
6577 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306578 }
6579 case WLAN_SET_DYNNAMIC_AGGREGATION:
6580 {
6581 if (NULL == hHal)
6582 return -EINVAL;
6583
6584 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306585 break;
6586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 default:
6588 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006589 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 sub_cmd, set_value);
6591 break;
6592 }
6593 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306594 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 return ret;
6596}
6597
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306598static int iw_setint_getnone(struct net_device *dev,
6599 struct iw_request_info *info,
6600 union iwreq_data *wrqu, char *extra)
6601{
6602 int ret;
6603
6604 vos_ssr_protect(__func__);
6605 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6606 vos_ssr_unprotect(__func__);
6607
6608 return 0;
6609}
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306610
6611static
6612int iw_mon_setint_getnone(struct net_device *dev,
6613 struct iw_request_info *info,
6614 union iwreq_data *wrqu, char *extra)
6615{
6616 int ret;
6617
6618 vos_ssr_protect(__func__);
6619 ret = __iw_mon_setint_getnone(dev, info, wrqu, extra);
6620 vos_ssr_unprotect(__func__);
6621
6622 return 0;
6623}
6624
Jeff Johnson295189b2012-06-20 16:38:30 -07006625/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306626static int __iw_setchar_getnone(struct net_device *dev,
6627 struct iw_request_info *info,
6628 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006629{
6630 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306631 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006633 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306634 hdd_adapter_t *pAdapter;
6635 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006636#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306637 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006638#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306639 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306640 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006641
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306642 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306643
6644 if (!capable(CAP_NET_ADMIN))
6645 {
6646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6647 FL("permission check failed"));
6648 return -EPERM;
6649 }
6650
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306651 pAdapter = (netdev_priv(dev));
6652 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006653 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6655 "%s: Adapter is NULL",__func__);
6656 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006657 }
6658
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306659 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6660 ret = wlan_hdd_validate_context(pHddCtx);
6661 if (0 != ret)
6662 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306663 return ret;
6664 }
6665#ifdef WLAN_FEATURE_VOWIFI
6666 pConfig = pHddCtx->cfg_ini;
6667#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306668 /* helper function to get iwreq_data with compat handling. */
6669 if (hdd_priv_get_data(&s_priv_data, wrqu))
6670 {
6671 return -EINVAL;
6672 }
6673
6674 /* make sure all params are correctly passed to function */
6675 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6676 {
6677 return -EINVAL;
6678 }
6679
6680 sub_cmd = s_priv_data.flags;
6681
Arif Hussain0273cba2014-01-07 20:58:29 -08006682 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306683 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6684 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006685 if (NULL == pBuffer)
6686 {
6687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6688 "mem_alloc_copy_from_user_helper fail");
6689 return -ENOMEM;
6690 }
6691
6692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306693 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6695 "%s: Received data %s", __func__, pBuffer);
6696
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 switch(sub_cmd)
6698 {
6699 case WE_WOWL_ADD_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306700 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6701 hddLog(LOGE, FL("wowlAddPtrn not allowed in STA + MON"));
6702 ret = -EOPNOTSUPP;
6703 break;
6704 }
6705
Arif Hussain6d2a3322013-11-17 19:50:10 -08006706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006707 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 break;
6709 case WE_WOWL_DEL_PTRN:
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05306710 if (wlan_hdd_check_monitor_state(pHddCtx)) {
6711 hddLog(LOGE, FL("wowlDelPtrn not allowed in STA + MON"));
6712 ret = -EOPNOTSUPP;
6713 break;
6714 }
6715
Arif Hussain6d2a3322013-11-17 19:50:10 -08006716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006717 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 break;
6719#if defined WLAN_FEATURE_VOWIFI
6720 case WE_NEIGHBOR_REPORT_REQUEST:
6721 {
6722 tRrmNeighborReq neighborReq;
6723 tRrmNeighborRspCallbackInfo callbackInfo;
6724
6725 if (pConfig->fRrmEnable)
6726 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306728 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 if( !neighborReq.no_ssid )
6730 {
Girish Gowli552fc072014-06-14 18:26:16 +05306731 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006732 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 }
6734
6735 callbackInfo.neighborRspCallback = NULL;
6736 callbackInfo.neighborRspCallbackContext = NULL;
6737 callbackInfo.timeout = 5000; //5 seconds
6738 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6739 }
6740 else
6741 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006742 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 ret = -EINVAL;
6744 }
6745 }
6746 break;
6747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 case WE_SET_AP_WPS_IE:
6749 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306750 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006753 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 if (VOS_STATUS_SUCCESS != vstatus)
6755 {
6756 ret = -EINVAL;
6757 }
6758 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306759 case WE_SET_ENCRYPT_MSG:
6760 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6761 if (NULL == pkt)
6762 {
6763 hddLog(VOS_TRACE_LEVEL_ERROR,
6764 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306765 ret = -ENOMEM;
6766 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306767 }
6768
6769 memset(pkt, 0, sizeof(tSirpkt80211));
6770
6771 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6772 hddLog(VOS_TRACE_LEVEL_ERROR,
6773 FL("Firmware is not DISA capable"));
6774 ret = -EINVAL;
6775 vos_mem_free(pkt);
6776 break;
6777 }
6778
6779 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6780
6781 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6782 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6783 if (eHAL_STATUS_SUCCESS != ret) {
6784 hddLog(VOS_TRACE_LEVEL_ERROR,
6785 FL("SENDEncryptMSG: fail to post WDA cmd"));
6786 ret = -EINVAL;
6787 }
6788 vos_mem_free(pkt);
6789
6790 break;
6791
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 default:
6793 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006794 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006795 ret = -EINVAL;
6796 break;
6797 }
6798 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006799 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306800
6801 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 return ret;
6803}
6804
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306805static int iw_setchar_getnone(struct net_device *dev,
6806 struct iw_request_info *info,
6807 union iwreq_data *wrqu, char *extra)
6808{
6809 int ret;
6810
6811 vos_ssr_protect(__func__);
6812 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6813 vos_ssr_unprotect(__func__);
6814
6815 return ret;
6816}
6817
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306818static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6819{
6820 struct statsContext *context;
6821 hdd_adapter_t *pAdapter;
6822
6823 if (NULL == pContext)
6824 {
6825 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07006826 "%s: Bad param, pContext [%pK]",
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306827 __func__, pContext);
6828 return;
6829 }
6830
6831 context = pContext;
6832 pAdapter = context->pAdapter;
6833
6834 spin_lock(&hdd_context_lock);
6835
6836 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6837 {
6838 /* the caller presumably timed out so there is nothing we can do */
6839 spin_unlock(&hdd_context_lock);
6840 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07006841 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306842 __func__, pAdapter, context->magic);
6843 return;
6844 }
6845
6846 context->magic = 0;
6847 pAdapter->antennaIndex = antennaId;
6848
6849 complete(&context->completion);
6850 spin_unlock(&hdd_context_lock);
6851}
6852
6853static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6854 int *antennaIndex)
6855{
6856 hdd_context_t *pHddCtx;
6857 eHalStatus halStatus;
6858 struct statsContext context;
6859 long lrc;
6860
6861 ENTER();
6862 if (NULL == pAdapter)
6863 {
6864 hddLog(VOS_TRACE_LEVEL_WARN,
6865 "%s: Invalid context, pAdapter", __func__);
6866 return VOS_STATUS_E_FAULT;
6867 }
6868 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6869 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6870 {
6871 return VOS_STATUS_E_FAULT;
6872 }
6873 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6874 {
6875 hddLog(VOS_TRACE_LEVEL_ERROR,
6876 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6877 __func__);
6878 return VOS_STATUS_E_NOSUPPORT;
6879 }
6880 init_completion(&context.completion);
6881 context.pAdapter = pAdapter;
6882 context.magic = ANTENNA_CONTEXT_MAGIC;
6883
6884 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6885 hdd_GetCurrentAntennaIndex,
6886 &context, pAdapter->sessionId);
6887 if (eHAL_STATUS_SUCCESS != halStatus)
6888 {
6889 spin_lock(&hdd_context_lock);
6890 context.magic = 0;
6891 spin_unlock(&hdd_context_lock);
6892 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6893 __func__);
6894 /* we'll returned a cached value below */
6895 *antennaIndex = -1;
6896 return VOS_STATUS_E_FAILURE;
6897 }
6898 else
6899 {
6900 /* request was sent -- wait for the response */
6901 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6902 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6903 if (lrc <= 0)
6904 {
6905 spin_lock(&hdd_context_lock);
6906 context.magic = 0;
6907 spin_unlock(&hdd_context_lock);
6908 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6909 " Index",
6910 __func__, (0 == lrc) ? "timeout" : "interrupt");
6911 *antennaIndex = -1;
6912 return VOS_STATUS_E_FAILURE;
6913 }
6914 }
6915 spin_lock(&hdd_context_lock);
6916 context.magic = 0;
6917 spin_unlock(&hdd_context_lock);
6918
6919 *antennaIndex = pAdapter->antennaIndex;
6920
6921 EXIT();
6922 return VOS_STATUS_SUCCESS;
6923}
6924
Jeff Johnson295189b2012-06-20 16:38:30 -07006925/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306926static int __iw_setnone_getint(struct net_device *dev,
6927 struct iw_request_info *info,
6928 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006929{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306930 hdd_adapter_t *pAdapter;
6931 tHalHandle hHal;
6932 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 int *value = (int *)extra;
6934 int ret = 0; /* success */
6935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306936 ENTER();
6937
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306938 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6939 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006940 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6942 "%s: Adapter is NULL",__func__);
6943 return -EINVAL;
6944 }
6945 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6946 ret = wlan_hdd_validate_context(pHddCtx);
6947 if (0 != ret)
6948 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306949 return ret;
6950 }
6951 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6952 if (NULL == hHal)
6953 {
6954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6955 "%s: Hal Context is NULL",__func__);
6956 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006958
6959 switch (value[0])
6960 {
6961 case WE_GET_11D_STATE:
6962 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006963 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306965
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6967
Arif Hussain6d2a3322013-11-17 19:50:10 -08006968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006969
6970 break;
6971 }
6972
6973 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 break;
6976
6977 case WE_PMC_STATE:
6978 {
6979 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 break;
6982 }
6983 case WE_GET_WLAN_DBG:
6984 {
6985 vos_trace_display();
6986 *value = 0;
6987 break;
6988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 case WE_GET_MAX_ASSOC:
6990 {
6991 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6992 {
c_hpothub8245442013-11-20 23:41:09 +05306993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6994 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 ret = -EIO;
6996 }
Girish Gowli385be612014-09-18 11:17:20 +05306997#ifdef WLAN_SOFTAP_VSTA_FEATURE
6998 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6999 {
7000 if (*value > VSTA_NUM_ASSOC_STA)
7001 {
7002 *value = VSTA_NUM_ASSOC_STA;
7003 }
7004 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
7005 (*value > (VSTA_NUM_ASSOC_STA -
7006 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
7007 {
7008 *value = (VSTA_NUM_ASSOC_STA -
7009 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
7010 }
7011 }
7012 else
7013#endif
7014 {
7015 if (*value > NUM_ASSOC_STA)
7016 {
7017 *value = NUM_ASSOC_STA;
7018 }
7019 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
7020 (*value > (NUM_ASSOC_STA -
7021 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
7022 {
7023 *value = (NUM_ASSOC_STA -
7024 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
7025 }
7026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 break;
7028 }
7029
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 case WE_GET_WDI_DBG:
7031 {
7032 wpalTraceDisplay();
7033 *value = 0;
7034 break;
7035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007036
7037 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7038 {
7039 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
7040 break;
7041 }
7042 case WE_GET_CONCURRENCY_MODE:
7043 {
7044 *value = hdd_get_concurrency_mode ( );
7045
Arif Hussain6d2a3322013-11-17 19:50:10 -08007046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 break;
7048 }
7049
Peng Xu2446a892014-09-05 17:21:18 +05307050 case WE_GET_SCAN_BAND_PREFERENCE:
7051 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307052 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05307053 sme_GetConfigParam(hHal, &smeConfig);
7054 *value = smeConfig.csrConfig.scanBandPreference;
7055
7056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7057 "scanBandPreference = %d\n", *value);
7058 break;
7059 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05307060 case WE_GET_ANTENA_DIVERSITY_SELECTION:
7061 {
7062 wlan_hdd_get_current_antenna_index(pAdapter, value);
7063 break;
7064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 default:
7066 {
7067 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
7068 break;
7069 }
7070 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307071 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 return ret;
7073}
7074
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307075static int iw_setnone_getint(struct net_device *dev,
7076 struct iw_request_info *info,
7077 union iwreq_data *wrqu, char *extra)
7078{
7079 int ret;
7080
7081 vos_ssr_protect(__func__);
7082 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7083 vos_ssr_unprotect(__func__);
7084
7085 return ret;
7086
7087}
Jeff Johnson295189b2012-06-20 16:38:30 -07007088/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307089int __iw_set_three_ints_getnone(struct net_device *dev,
7090 struct iw_request_info *info,
7091 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007092{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307093 hdd_adapter_t *pAdapter;
7094 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 int *value = (int *)extra;
7096 int sub_cmd = value[0];
7097 int ret = 0;
7098
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307099 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05307100
7101 if (!capable(CAP_NET_ADMIN))
7102 {
7103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7104 FL("permission check failed"));
7105 return -EPERM;
7106 }
7107
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307108 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7109 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007110 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7112 "%s: Adapter is NULL",__func__);
7113 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007114 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307115 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7116 ret = wlan_hdd_validate_context(pHddCtx);
7117 if (0 != ret)
7118 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307119 return ret;
7120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 switch(sub_cmd)
7122 {
7123 case WE_SET_WLAN_DBG:
7124 {
7125 vos_trace_setValue( value[1], value[2], value[3]);
7126 break;
7127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 case WE_SET_WDI_DBG:
7129 {
7130 wpalTraceSetLevel( value[1], value[2], value[3]);
7131 break;
7132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 case WE_SET_SAP_CHANNELS:
7134 {
7135 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
7136 break;
7137 }
7138
7139 default:
7140 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007141 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 break;
7143 }
7144 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307145 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 return ret;
7147}
7148
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307149int iw_set_three_ints_getnone(struct net_device *dev,
7150 struct iw_request_info *info,
7151 union iwreq_data *wrqu, char *extra)
7152{
7153 int ret;
7154
7155 vos_ssr_protect(__func__);
7156 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7157 vos_ssr_unprotect(__func__);
7158
7159 return ret;
7160}
7161
7162static int __iw_get_char_setnone(struct net_device *dev,
7163 struct iw_request_info *info,
7164 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007165{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307166 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307168 hdd_context_t *pHddCtx;
7169 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07007170#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007171 hdd_wext_state_t *pWextState;
7172#endif
7173
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307174 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307175 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007176 if (pAdapter == NULL)
7177 {
7178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7179 "%s: pAdapter is NULL!", __func__);
7180 return -EINVAL;
7181 }
Alok Kumar69a8b752017-11-08 15:24:32 +05307182
7183 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
7184 WLAN_HDD_FTM == pAdapter->device_mode)
7185 return ret;
7186
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307187 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7188 ret = wlan_hdd_validate_context(pHddCtx);
7189 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07007190 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307191 return ret;
7192 }
7193#ifdef WLAN_FEATURE_11W
7194 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7195 if (NULL == pWextState)
7196 {
7197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7198 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07007199 return -EINVAL;
7200 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307201#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007202
Jeff Johnson295189b2012-06-20 16:38:30 -07007203 switch(sub_cmd)
7204 {
7205 case WE_WLAN_VERSION:
7206 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007207 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 break;
7209 }
7210
7211 case WE_GET_STATS:
7212 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307213 tHalHandle hHal = NULL;
7214 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7216 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
7217 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307218 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07007219
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307220
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 snprintf(extra, WE_MAX_STR_LEN,
7222 "\nTransmit"
7223 "\ncalled %u, dropped %u, backpressured %u, queued %u"
7224 "\n dropped BK %u, BE %u, VI %u, VO %u"
7225 "\n classified BK %u, BE %u, VI %u, VO %u"
7226 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
7227 "\n queued BK %u, BE %u, VI %u, VO %u"
7228 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007229 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 "\n fetched BK %u, BE %u, VI %u, VO %u"
7231 "\n dequeued BK %u, BE %u, VI %u, VO %u"
7232 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007233 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 "\n flushed BK %u, BE %u, VI %u, VO %u"
7235 "\n\nReceive"
7236 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
7237 "\n\nResetsStats"
7238 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307239 "\n"
7240 "\n\nARP Transmit"
7241 "\nTransmit Count %u, dropped %u"
7242 "\n\nARP Receive"
7243 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 "\n",
7245 pStats->txXmitCalled,
7246 pStats->txXmitDropped,
7247 pStats->txXmitBackPressured,
7248 pStats->txXmitQueued,
7249
7250 pStats->txXmitDroppedAC[WLANTL_AC_BK],
7251 pStats->txXmitDroppedAC[WLANTL_AC_BE],
7252 pStats->txXmitDroppedAC[WLANTL_AC_VI],
7253 pStats->txXmitDroppedAC[WLANTL_AC_VO],
7254
7255 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
7256 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
7257 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
7258 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
7259
7260 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
7261 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
7262 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
7263 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
7264
7265 pStats->txXmitQueuedAC[WLANTL_AC_BK],
7266 pStats->txXmitQueuedAC[WLANTL_AC_BE],
7267 pStats->txXmitQueuedAC[WLANTL_AC_VI],
7268 pStats->txXmitQueuedAC[WLANTL_AC_VO],
7269
7270 pStats->txFetched,
7271 pStats->txFetchEmpty,
7272 pStats->txFetchLowResources,
7273 pStats->txFetchDequeueError,
7274
7275 pStats->txFetchDequeued,
7276 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07007277 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 pStats->txCompleted,
7279 pStats->txFlushed,
7280
7281 pStats->txFetchedAC[WLANTL_AC_BK],
7282 pStats->txFetchedAC[WLANTL_AC_BE],
7283 pStats->txFetchedAC[WLANTL_AC_VI],
7284 pStats->txFetchedAC[WLANTL_AC_VO],
7285
7286 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7287 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7288 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7289 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7290
7291 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7292 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7293 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7294 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7295
Ravi Joshi41914632013-10-21 23:02:21 -07007296 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7297 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7298 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7299 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7300
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 pStats->txFlushedAC[WLANTL_AC_BK],
7302 pStats->txFlushedAC[WLANTL_AC_BE],
7303 pStats->txFlushedAC[WLANTL_AC_VI],
7304 pStats->txFlushedAC[WLANTL_AC_VO],
7305
7306 pStats->rxChains,
7307 pStats->rxPackets,
7308 pStats->rxDropped,
7309 pStats->rxDelivered,
7310 pStats->rxRefused,
7311
7312 pResetStats->totalLogpResets,
7313 pResetStats->totalCMD53Failures,
7314 pResetStats->totalMutexReadFailures,
7315 pResetStats->totalMIFErrorFailures,
7316 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307317 pResetStats->totalUnknownExceptions,
7318
7319 parpStats->txCount,
7320 parpStats->txDropped,
7321
7322 parpStats->rxCount,
7323 parpStats->rxDropped,
7324 parpStats->rxDelivered,
7325 parpStats->rxRefused,
7326 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307328 wrqu->data.length = strlen(extra);
7329
7330 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7331
7332 if (hHal)
7333 pMac = PMAC_STRUCT( hHal );
7334
7335 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7336 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7337 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307338 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7339 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7340 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7341 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307342 "\n",
7343 pMac->pmm.BmpscntSleep,
7344 pMac->pmm.BmpscntAwake,
7345 pMac->pmm.BmpsSleeReqFailCnt,
7346 pMac->pmm.BmpsWakeupReqFailCnt,
7347 pMac->pmm.ImpsCntSleep,
7348 pMac->pmm.ImpsCntAwake,
7349 pMac->pmm.ImpsSleepErrCnt,
7350 pMac->pmm.ImpsWakeupErrCnt,
7351 pMac->pmm.ImpsLastErr
7352 );
7353 }
7354
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 wrqu->data.length = strlen(extra)+1;
7356 break;
7357 }
7358
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307359/* The case prints the current state of the HDD, SME, CSR, PE, TL
7360 *it can be extended for WDI Global State as well.
7361 *And currently it only checks P2P_CLIENT adapter.
7362 *P2P_DEVICE and P2P_GO have not been added as of now.
7363*/
7364 case WE_GET_STATES:
7365 {
7366 int buf = 0, len = 0;
7367 int adapter_num = 0;
7368 int count = 0, check = 1;
7369
7370 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007371 tHalHandle hHal = NULL;
7372 tpAniSirGlobal pMac = NULL;
7373 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307374
7375 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7376 hdd_adapter_t *useAdapter = NULL;
7377
7378 /* Print wlan0 or p2p0 states based on the adapter_num
7379 *by using the correct adapter
7380 */
7381 while ( adapter_num < 2 )
7382 {
7383 if ( WLAN_ADAPTER == adapter_num )
7384 {
7385 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007386 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307387 "\n\n wlan0 States:-");
7388 len += buf;
7389 }
7390 else if ( P2P_ADAPTER == adapter_num )
7391 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007392 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307393 "\n\n p2p0 States:-");
7394 len += buf;
7395
7396 if( !pHddCtx )
7397 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007398 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307399 "\n pHddCtx is NULL");
7400 len += buf;
7401 break;
7402 }
7403
7404 /*Printing p2p0 states only in the case when the device is
7405 configured as a p2p_client*/
7406 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7407 if ( !useAdapter )
7408 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007409 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307410 "\n Device not configured as P2P_CLIENT.");
7411 len += buf;
7412 break;
7413 }
7414 }
7415
7416 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007417 if (!hHal) {
7418 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7419 "\n pMac is NULL");
7420 len += buf;
7421 break;
7422 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307423 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007424 if (!pMac) {
7425 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7426 "\n pMac is NULL");
7427 len += buf;
7428 break;
7429 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307430 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7431 if( !pHddStaCtx )
7432 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007433 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307434 "\n pHddStaCtx is NULL");
7435 len += buf;
7436 break;
7437 }
7438
7439 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7440
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007441 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307442 "\n HDD Conn State - %s "
7443 "\n \n SME State:"
7444 "\n Neighbour Roam State - %s"
7445 "\n CSR State - %s"
7446 "\n CSR Substate - %s"
7447 "\n \n TL STA %d State: %s",
7448 macTraceGetHDDWlanConnState(
7449 pHddStaCtx->conn_info.connState),
7450 macTraceGetNeighbourRoamState(
7451 pMac->roam.neighborRoamInfo.neighborRoamState),
7452 macTraceGetcsrRoamState(
7453 pMac->roam.curState[useAdapter->sessionId]),
7454 macTraceGetcsrRoamSubState(
7455 pMac->roam.curSubState[useAdapter->sessionId]),
7456 pHddStaCtx->conn_info.staId[0],
7457 macTraceGetTLState(tlState)
7458 );
7459 len += buf;
7460 adapter_num++;
7461 }
7462
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007463 if (pMac) {
7464 /* Printing Lim State starting with global lim states */
7465 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7466 "\n \n LIM STATES:-"
7467 "\n Global Sme State - %s "\
7468 "\n Global mlm State - %s "\
7469 "\n",
7470 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7471 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7472 );
7473 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307474
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007475 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307476 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307477 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007478 if ( pMac->lim.gpSession[count].valid )
7479 {
7480 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7481 "\n Lim Valid Session %d:-"
7482 "\n PE Sme State - %s "
7483 "\n PE Mlm State - %s "
7484 "\n",
7485 check,
7486 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7487 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7488 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307489
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007490 len += buf;
7491 check++;
7492 }
7493 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307494 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307495 }
7496
7497 wrqu->data.length = strlen(extra)+1;
7498 break;
7499 }
7500
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 case WE_GET_CFG:
7502 {
7503 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7504 wrqu->data.length = strlen(extra)+1;
7505 break;
7506 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007507#ifdef WLAN_FEATURE_11AC
7508 case WE_GET_RSSI:
7509 {
7510 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307511 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007512 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7513 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7514 wrqu->data.length = strlen(extra)+1;
7515 break;
7516 }
7517#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307518
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007519#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007520 case WE_GET_ROAM_RSSI:
7521 {
7522 v_S7_t s7Rssi = 0;
7523 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7524 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7525 wrqu->data.length = strlen(extra)+1;
7526 break;
7527 }
7528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 case WE_GET_WMM_STATUS:
7530 {
7531 snprintf(extra, WE_MAX_STR_LEN,
7532 "\nDir: 0=up, 1=down, 3=both\n"
7533 "|------------------------|\n"
7534 "|AC | ACM |Admitted| Dir |\n"
7535 "|------------------------|\n"
7536 "|VO | %d | %3s | %d |\n"
7537 "|VI | %d | %3s | %d |\n"
7538 "|BE | %d | %3s | %d |\n"
7539 "|BK | %d | %3s | %d |\n"
7540 "|------------------------|\n",
7541 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7542 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7543 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7544 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7545 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7546 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7547 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7548 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7549 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7550 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7551 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7552 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7553
Jeff Johnsone7245742012-09-05 17:12:55 -07007554
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 wrqu->data.length = strlen(extra)+1;
7556 break;
7557 }
7558 case WE_GET_CHANNEL_LIST:
7559 {
7560 VOS_STATUS status;
7561 v_U8_t i, len;
7562 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307563 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7564 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7565 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 tChannelListInfo channel_list;
7567
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007568 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007570 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 return -EINVAL;
7574 }
7575 buf = extra;
7576
7577 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007578 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7579 * needed = 5 * number of channels. Check ifsufficient
7580 * buffer is available and then proceed to fill the buffer.
7581 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7583 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007584 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007585 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007586 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 return -EINVAL;
7588 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007589 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7590 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307591 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7592 {
7593 //Printing Country code in getChannelList
7594 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7595 {
7596 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7597 "%c ", pBuf[i]);
7598 }
7599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 for(i = 0 ; i < channel_list.num_channels; i++)
7601 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007602 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007604 }
7605 wrqu->data.length = strlen(extra)+1;
7606
7607 break;
7608 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007609#ifdef FEATURE_WLAN_TDLS
7610 case WE_GET_TDLS_PEERS:
7611 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007612 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007613 break;
7614 }
7615#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007616#ifdef WLAN_FEATURE_11W
7617 case WE_GET_11W_INFO:
7618 {
7619 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7620
7621 snprintf(extra, WE_MAX_STR_LEN,
7622 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7623 "\n Number of Unprotected Disassocs %d"
7624 "\n Number of Unprotected Deauths %d",
7625 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7626 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7627 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7628 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7629 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7630
7631 wrqu->data.length = strlen(extra)+1;
7632 break;
7633 }
7634#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307635#ifdef WLAN_FEATURE_RMC
7636 case WE_GET_IBSS_STA_INFO:
7637 {
7638 hdd_station_ctx_t *pHddStaCtx =
7639 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7640 int idx = 0;
7641 int length = 0, buf = 0;
7642
7643 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7644 {
7645 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7646 {
7647 buf = snprintf
7648 (
7649 (extra + length), WE_MAX_STR_LEN - length,
7650 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7651 pHddStaCtx->conn_info.staId[ idx ],
7652 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7653 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7654 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7655 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7656 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7657 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7658 );
7659 length += buf;
7660 }
7661 }
7662 wrqu->data.length = strlen(extra)+1;
7663 break;
7664 }
7665#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307666 case WE_GET_SNR:
7667 {
7668 v_S7_t s7snr = 0;
7669 int status = 0;
7670 hdd_context_t *pHddCtx;
7671 hdd_station_ctx_t *pHddStaCtx;
7672
7673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7674 status = wlan_hdd_validate_context(pHddCtx);
7675 if (0 != status)
7676 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307677 return status;
7678 }
7679
7680 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7681
7682 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7683 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7684 {
7685 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7686 " ConnectionState-%d", __func__,
7687 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7688 pHddStaCtx->conn_info.connState);
7689 return -ENONET;
7690 }
7691
7692 /*update the stats in TL*/
7693 wlan_hdd_get_station_stats(pAdapter);
7694 wlan_hdd_get_snr(pAdapter, &s7snr);
7695 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7696 wrqu->data.length = strlen(extra) + 1;
7697 break;
7698 }
7699
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307700#ifdef FEATURE_OEM_DATA_SUPPORT
7701 case WE_GET_OEM_DATA_CAP:
7702 {
7703 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7704 }
7705#endif /* FEATURE_OEM_DATA_SUPPORT */
7706
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307707 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007709 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 break;
7711 }
7712 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307713 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 return 0;
7715}
7716
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307717static int iw_get_char_setnone(struct net_device *dev,
7718 struct iw_request_info *info,
7719 union iwreq_data *wrqu, char *extra)
7720{
7721 int ret;
7722
7723 vos_ssr_protect(__func__);
7724 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7725 vos_ssr_unprotect(__func__);
7726
7727 return ret;
7728}
7729
Jeff Johnson295189b2012-06-20 16:38:30 -07007730/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307731static int __iw_setnone_getnone(struct net_device *dev,
7732 struct iw_request_info *info,
7733 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007734{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307735 hdd_adapter_t *pAdapter;
7736 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307737 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007738 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307739 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007740
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307741 ENTER();
7742
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307743 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7744 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007745 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7747 "%s: Adapter is NULL",__func__);
7748 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007749 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7751 ret = wlan_hdd_validate_context(pHddCtx);
7752 if (0 != ret)
7753 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307754 return ret;
7755 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307756 /* helper function to get iwreq_data with compat handling. */
7757 if (hdd_priv_get_data(&s_priv_data, wrqu))
7758 {
7759 return -EINVAL;
7760 }
7761
7762 sub_cmd = s_priv_data.flags;
7763
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 switch (sub_cmd)
7765 {
7766 case WE_CLEAR_STATS:
7767 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007769 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7770 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7771 break;
7772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 case WE_INIT_AP:
7774 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307775 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7776
7777 /* As Soft AP mode might been changed to STA already with
7778 * killing of Hostapd, need to find the adpater by name
7779 * rather than mode */
7780 hdd_adapter_t* pAdapter_to_stop =
7781 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7782 if( pAdapter_to_stop )
7783 {
7784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7785 "Adapter with name softap.0 already "
7786 "exist, ignoring the request.\nRemove the "
7787 "adapter and try again\n");
7788 break;
7789 }
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05307790
7791 if (wlan_hdd_check_monitor_state(pHddCtx)) {
7792 hddLog(LOGE, FL("initAP not allowed in STA + MON"));
7793 ret = -EOPNOTSUPP;
7794 break;
7795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 pr_info("Init AP trigger\n");
7797 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7798 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7799 break;
7800 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307801#ifdef WLAN_FEATURE_RMC
7802 case WE_IBSS_GET_PEER_INFO_ALL:
7803 {
7804 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7805 break;
7806 }
7807#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 case WE_STOP_AP:
7809 {
7810 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7811 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7812 * this is a dead code and need to find the adpater by name rather than mode */
7813 hdd_adapter_t* pAdapter_to_stop =
7814 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7815 if( pAdapter_to_stop )
7816 {
7817 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7818
7819 pr_info("Stopping AP mode\n");
7820
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307821 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7822 {
7823 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7824 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7825 }
7826
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307828 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307829 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7831
7832 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7833 pAdapter_to_stop->macAddressCurrent.bytes);
7834 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7835 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307836
7837 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7838 {
7839 /* put the device back into BMPS */
7840 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 }
7843 else
7844 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007845 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 }
7847
7848 break;
7849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007850#ifdef WLAN_BTAMP_FEATURE
7851 case WE_ENABLE_AMP:
7852 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 WLANBAP_RegisterWithHCI(pAdapter);
7855 break;
7856 }
7857 case WE_DISABLE_AMP:
7858 {
7859 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7860 VOS_STATUS status;
7861
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007863
7864 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7865 status = WLANBAP_StopAmp();
7866 if(VOS_STATUS_SUCCESS != status )
7867 {
7868 pHddCtx->isAmpAllowed = VOS_TRUE;
7869 hddLog(VOS_TRACE_LEVEL_FATAL,
7870 "%s: Failed to stop AMP", __func__);
7871 }
7872 else
7873 {
7874 //a state m/c implementation in PAL is TBD to avoid this delay
7875 msleep(500);
7876 pHddCtx->isAmpAllowed = VOS_FALSE;
7877 WLANBAP_DeregisterFromHCI();
7878 }
7879
7880 break;
7881 }
7882#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007883 case WE_ENABLE_DXE_STALL_DETECT:
7884 {
schang6295e542013-03-12 15:31:23 -07007885 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7886 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007887 break;
7888 }
7889 case WE_DISPLAY_DXE_SNAP_SHOT:
7890 {
schang6295e542013-03-12 15:31:23 -07007891 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7892 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007893 break;
7894 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307895 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7896 {
7897 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7898 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307899 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307900 break;
7901 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307902
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307903 case WE_SET_REASSOC_TRIGGER:
7904 {
7905 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7906 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7907 v_U32_t roamId = 0;
7908 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307909 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7910 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307911 return 0;
7912 }
7913
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307914 case WE_STOP_OBSS_SCAN:
7915 {
7916 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7917 2.OBSS scan is stopped by Firmware during the disassociation
7918 3.OBSS stop comamnd is added for debugging purpose*/
7919 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7920 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007921
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307922 if (pAdapter == NULL)
7923 {
7924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7925 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307926 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307927 }
7928 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7929 if (pMac == NULL)
7930 {
7931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7932 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307933 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307934 }
7935 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7936 }
7937 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307938 case WE_DUMP_ROAM_TIMER_LOG:
7939 {
7940 vos_dump_roam_time_log_service();
7941 break;
7942 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307943
Mukul Sharma84f27252014-07-14 18:11:42 +05307944 case WE_RESET_ROAM_TIMER_LOG:
7945 {
7946 vos_reset_roam_timer_log();
7947 break;
7948 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307949 case WE_GET_FW_LOGS:
7950 {
7951 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7952 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307953 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307954 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307955 break;
7956 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307957 case WE_GET_FW_MEMDUMP:
7958 {
7959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7960 "FW_MEM_DUMP requested ");
7961 get_fwr_memdump(dev,info,wrqu,extra);
7962 break;
7963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 default:
7965 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007966 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 break;
7968 }
7969 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307970 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 return ret;
7972}
7973
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307974static int iw_setnone_getnone(struct net_device *dev,
7975 struct iw_request_info *info,
7976 union iwreq_data *wrqu, char *extra)
7977{
7978 int ret;
7979
7980 vos_ssr_protect(__func__);
7981 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7982 vos_ssr_unprotect(__func__);
7983
7984 return ret;
7985}
7986
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307987void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7988{
7989 /*
7990 * Function to display HDD WMM information
7991 * for Tx Queues.
7992 * Prints globala as well as per client depending
7993 * whether the clients are registered or not.
7994 */
7995 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307996 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7997 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307998 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7999 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05308000 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05308001
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308002 for ( i=0; i< NUM_TX_QUEUES; i++)
8003 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05308004 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05308005 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05308006 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308007 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05308008
8009 for ( i=0; i< NUM_TX_QUEUES; i++) {
8010 if (tx_queue_count[i]) {
8011 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
8012 i, tx_queue_count[i]);
8013 }
8014 }
8015
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05308016 if(pSapCtx == NULL){
8017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8018 FL("psapCtx is NULL"));
8019 return;
8020 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308021
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05308022 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308023 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
8024 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05308025 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308026 {
8027 hddLog(LOGE, "******STAIndex: %d*********", i);
8028 for ( j=0; j< NUM_TX_QUEUES; j++)
8029 {
Katya Nigamd5c24212015-06-19 15:40:58 +05308030 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
8031 {
8032 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05308033 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
8034 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05308035 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
8036 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308037 }
8038 }
8039 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05308040 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308041
Katya Nigam1fd24402015-02-16 14:52:19 +05308042 if(pHddStaCtx == NULL){
8043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8044 FL("pHddStaCtx is NULL"));
8045 return;
8046 }
8047
8048 pPeerInfo = &pHddStaCtx->ibss_peer_info;
8049 if(pPeerInfo == NULL){
8050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8051 FL("ppeerinfo is NULL"));
8052 return;
8053 }
8054
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05308055 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
8056 if (pPeerInfo->ibssStaInfo[i].isUsed) {
8057 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
8058 for (j = 0; j < NUM_TX_QUEUES; j++) {
8059 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
8060 spin_lock_bh(
8061 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
8062 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07008063 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05308064 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
8065 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
8066 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
8067 spin_unlock_bh(
8068 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
8069 }
8070 }
Katya Nigam1fd24402015-02-16 14:52:19 +05308071 }
8072 }
8073
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308074}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05308075
Girish Gowlifb9758e2014-11-19 15:19:17 +05308076static int __iw_set_var_ints_getnone(struct net_device *dev,
8077 struct iw_request_info *info,
8078 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008079{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308080 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308081 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05308082 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05308083 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008084 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05308085 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308086 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008087 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05308088 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008089 int cmd = 0;
8090 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308091 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008092
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308093 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05308094 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05308095 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05308096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8097 "%s: NULL extra buffer pointer", __func__);
8098 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05308099 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308100 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8101 if (NULL == pAdapter)
8102 {
8103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8104 "%s: Adapter is NULL",__func__);
8105 return -EINVAL;
8106 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308107 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8109 ret = wlan_hdd_validate_context(pHddCtx);
8110 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008111 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05308112 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008113 }
Katya Nigameae74b62015-05-28 17:19:16 +05308114 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308115 {
Katya Nigameae74b62015-05-28 17:19:16 +05308116 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8117 if (NULL == hHal)
8118 {
8119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8120 "%s: Hal Context is NULL",__func__);
8121 return -EINVAL;
8122 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308123 }
8124 sub_cmd = wrqu->data.flags;
8125
8126 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
8127
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008128
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008129 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
8130 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
8131 {
8132 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
8133 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
8134 {
8135 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8136 staId = pStaCtx->conn_info.staId[0];
8137 }
8138 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
8139 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
8140 {
8141 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
8142 staId = pAPCtx->uBCStaId;
8143 }
8144 else
8145 {
8146 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
8147 return 0;
8148 }
8149 }
8150
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 switch (sub_cmd)
8152 {
8153 case WE_LOG_DUMP_CMD:
8154 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05308155 if(apps_args[0] == 26) {
8156 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
8157 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
8158 return 0;
8159 }
8160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008162 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308164 if (hHal)
8165 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
8166 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008167
8168 }
8169 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05308170#ifdef WLAN_FEATURE_RMC
8171 case WE_IBSS_GET_PEER_INFO:
8172 {
8173 pr_info ( "Station ID = %d\n",apps_args[0]);
8174 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
8175 }
8176 break;
8177#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008178
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 case WE_P2P_NOA_CMD:
8180 {
8181 p2p_app_setP2pPs_t p2pNoA;
8182
Rajeev Kumara4c475d2015-11-27 13:41:24 +05308183 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
8184 hddLog(LOGE,
8185 FL("Setting NoA is not allowed in Device mode:%d"),
8186 pAdapter->device_mode);
8187 return -EINVAL;
8188 }
8189
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 p2pNoA.opp_ps = apps_args[0];
8191 p2pNoA.ctWindow = apps_args[1];
8192 p2pNoA.duration = apps_args[2];
8193 p2pNoA.interval = apps_args[3];
8194 p2pNoA.count = apps_args[4];
8195 p2pNoA.single_noa_duration = apps_args[5];
8196 p2pNoA.psSelection = apps_args[6];
8197
8198 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
8199 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008200 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
8202
8203 hdd_setP2pPs(dev, &p2pNoA);
8204
8205 }
8206 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008207
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308208 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8209 {
8210 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8211 __func__, apps_args[0], apps_args[1]);
8212 vosTraceEnable(apps_args[0], apps_args[1]);
8213 }
8214 break;
8215
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008216 case WE_MTRACE_DUMP_CMD:
8217 {
8218 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
8219 "bitmask_of_module %d ",
8220 __func__, apps_args[0], apps_args[1], apps_args[2],
8221 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308222 if (hHal)
8223 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
8224 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008225
8226 }
8227 break;
8228
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008229 case WE_MCC_CONFIG_CREDENTIAL :
8230 {
8231 cmd = 287; //Command should be updated if there is any change
8232 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08008233 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008234 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308235 if (hHal)
8236 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
8237 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008238 }
8239 else
8240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008241 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008242 return 0;
8243 }
8244 }
8245 break;
8246
8247 case WE_MCC_CONFIG_PARAMS :
8248 {
8249 cmd = 288; //command Should be updated if there is any change
8250 // in the Riva dump command
8251 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
8252 }
8253 break;
8254
Chilam NG571c65a2013-01-19 12:27:36 +05308255#ifdef FEATURE_WLAN_TDLS
8256 case WE_TDLS_CONFIG_PARAMS :
8257 {
8258 tdls_config_params_t tdlsParams;
8259
Chilam Ng01120412013-02-19 18:32:21 -08008260 tdlsParams.tdls = apps_args[0];
8261 tdlsParams.tx_period_t = apps_args[1];
8262 tdlsParams.tx_packet_n = apps_args[2];
8263 tdlsParams.discovery_period_t = apps_args[3];
8264 tdlsParams.discovery_tries_n = apps_args[4];
8265 tdlsParams.idle_timeout_t = apps_args[5];
8266 tdlsParams.idle_packet_n = apps_args[6];
8267 tdlsParams.rssi_hysteresis = apps_args[7];
8268 tdlsParams.rssi_trigger_threshold = apps_args[8];
8269 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05308270
Chilam Ng01120412013-02-19 18:32:21 -08008271 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05308272 }
8273 break;
8274#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05308275 case WE_CONFIGURE_MONITOR_MODE:
8276 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308277 v_U32_t magic = 0;
8278 struct completion cmpVar;
8279 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308280 tVOS_CON_MODE mode = hdd_get_conparam();
8281
8282 if (VOS_MONITOR_MODE != mode) {
8283 hddLog(LOGE, FL("invalid mode %d"), mode);
8284 return -EIO;
8285 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308286
Katya Nigamf0511f62015-05-05 16:40:57 +05308287 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8288 if( pMonCtx == NULL )
8289 {
8290 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308291 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308292 }
8293 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
8294 __func__, apps_args[0], apps_args[1], apps_args[2],
8295 apps_args[3], apps_args[4]);
8296 /* Input Validation part of FW */
8297 pMonCtx->ChannelNo = apps_args[0];
8298 pMonCtx->ChannelBW = apps_args[1];
8299 pMonCtx->crcCheckEnabled = apps_args[2];
8300 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8301 pMonCtx->is80211to803ConReq = apps_args[4];
8302 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8303 if( pMonCtx->is80211to803ConReq )
8304 pAdapter->dev->type = ARPHRD_ETHER;
8305 else
8306 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8307 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8308 {
8309 hddLog(LOGE, "%s: Filtering data packets as management and control"
8310 " cannot be converted to 802.3 ",__func__);
8311 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8312 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308313 if (MON_MODE_START == pMonCtx->state) {
8314 magic = MON_MODE_MSG_MAGIC;
8315 init_completion(&cmpVar);
8316 if (VOS_STATUS_SUCCESS !=
8317 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8318 pMonCtx, hdd_monPostMsgCb)) {
8319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8320 FL("failed to post MON MODE REQ"));
8321 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308322 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308323 }
8324 waitRet = wait_for_completion_timeout(&cmpVar,
8325 MON_MODE_MSG_TIMEOUT);
8326 magic = 0;
8327 if (waitRet <= 0 ) {
8328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8329 FL("failed to wait on monitor mode completion %ld"),
8330 waitRet);
8331 }
8332 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308333 }
8334 break;
8335
8336 case WE_SET_MONITOR_MODE_FILTER:
8337 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308338 v_U32_t magic = 0;
8339 struct completion cmpVar;
8340 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308341 tVOS_CON_MODE mode = hdd_get_conparam();
8342
8343 if (VOS_MONITOR_MODE != mode) {
8344 hddLog(LOGE, FL("invalid mode %d"), mode);
8345 return -EIO;
8346 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308347
Katya Nigamf0511f62015-05-05 16:40:57 +05308348 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8349 if( pMonCtx == NULL )
8350 {
8351 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308352 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308353 }
8354 /* Input Validation Part of FW */
8355 pMonCtx->numOfMacFilters=1;
8356 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8357 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8358 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8359 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8360 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8361 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8362 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8363 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8364 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8365 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8366 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8367 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308368 if (MON_MODE_START == pMonCtx->state) {
8369 magic = MON_MODE_MSG_MAGIC;
8370 init_completion(&cmpVar);
8371 if (VOS_STATUS_SUCCESS !=
8372 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8373 pMonCtx, hdd_monPostMsgCb)) {
8374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8375 FL("failed to post MON MODE REQ"));
8376 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308377 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308378 }
8379 waitRet = wait_for_completion_timeout(&cmpVar,
8380 MON_MODE_MSG_TIMEOUT);
8381 magic = 0;
8382 if (waitRet <= 0 ) {
8383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8384 FL("failed to wait on monitor mode completion %ld"),
8385 waitRet);
8386 }
8387 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308388 }
8389 break;
8390
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 default:
8392 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008393 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8394 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 }
8396 break;
8397 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308398 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 return 0;
8400}
8401
Girish Gowlifb9758e2014-11-19 15:19:17 +05308402static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8403 struct iw_request_info *info,
8404 union iwreq_data *wrqu, char *extra)
8405{
8406 int ret;
8407 union iwreq_data u_priv_wrqu;
8408 int apps_args[MAX_VAR_ARGS] = {0};
8409 int num_args;
8410
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308411 if (!capable(CAP_NET_ADMIN))
8412 {
8413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8414 FL("permission check failed"));
8415 return -EPERM;
8416 }
8417
Girish Gowlifb9758e2014-11-19 15:19:17 +05308418 /* helper function to get iwreq_data with compat handling. */
8419 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8420 {
8421 return -EINVAL;
8422 }
8423
8424 if (NULL == u_priv_wrqu.data.pointer)
8425 {
8426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8427 "%s: NULL data pointer", __func__);
8428 return -EINVAL;
8429 }
8430
8431 num_args = u_priv_wrqu.data.length;
8432 if (num_args > MAX_VAR_ARGS)
8433 {
8434 num_args = MAX_VAR_ARGS;
8435 }
8436
8437 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8438 (sizeof(int)) * num_args))
8439 {
8440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8441 "%s: failed to copy data from user buffer", __func__);
8442 return -EFAULT;
8443 }
8444
8445 vos_ssr_protect(__func__);
8446 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8447 (char *)&apps_args);
8448 vos_ssr_unprotect(__func__);
8449
8450 return ret;
8451}
8452
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308453int iw_set_var_ints_getnone(struct net_device *dev,
8454 struct iw_request_info *info,
8455 union iwreq_data *wrqu, char *extra)
8456{
8457 int ret;
8458 vos_ssr_protect(__func__);
8459 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8460 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008461
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308462 return ret;
8463}
8464
8465static int __iw_add_tspec(struct net_device *dev,
8466 struct iw_request_info *info,
8467 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008468{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308469 hdd_adapter_t *pAdapter;
8470 hdd_station_ctx_t *pHddStaCtx;
8471 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8473 int params[HDD_WLAN_WMM_PARAM_COUNT];
8474 sme_QosWmmTspecInfo tSpec;
8475 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308476 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308477 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008478
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308479 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308480 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8481 if (NULL == pAdapter)
8482 {
8483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8484 "%s: Adapter is NULL",__func__);
8485 return -EINVAL;
8486 }
8487 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8488 ret = wlan_hdd_validate_context(pHddCtx);
8489 if (0 != ret)
8490 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308491 return ret;
8492 }
8493 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8494 if (NULL == pHddStaCtx)
8495 {
8496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8497 "%s: STA Context is NULL",__func__);
8498 return -EINVAL;
8499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 // make sure the application is sufficiently priviledged
8501 // note that the kernel will do this for "set" ioctls, but since
8502 // this ioctl wants to return status to user space it must be
8503 // defined as a "get" ioctl
8504 if (!capable(CAP_NET_ADMIN))
8505 {
8506 return -EPERM;
8507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 // we must be associated in order to add a tspec
8509 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8510 {
8511 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8512 return 0;
8513 }
8514
8515 // since we are defined to be a "get" ioctl, and since the number
8516 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308517 // will pass down in the iwreq_data, we must copy the "set" params.
8518 // We must handle the compat for iwreq_data in 32U/64K environment.
8519
8520 // helper fucntion to get iwreq_data with compat handling.
8521 if (hdd_priv_get_data(&s_priv_data, wrqu))
8522 {
8523 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8524 return 0;
8525 }
8526
8527 // make sure all params are correctly passed to function
8528 if ((NULL == s_priv_data.pointer) ||
8529 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8530 {
8531 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8532 return 0;
8533 }
8534
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308536 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 {
8538 // hmmm, can't get them
8539 return -EIO;
8540 }
8541
8542 // clear the tspec
8543 memset(&tSpec, 0, sizeof(tSpec));
8544
8545 // validate the handle
8546 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8547 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8548 {
8549 // that one is reserved
8550 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8551 return 0;
8552 }
8553
8554 // validate the TID
8555 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8556 {
8557 // out of range
8558 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8559 return 0;
8560 }
8561 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8562
8563 // validate the direction
8564 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8565 {
8566 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8567 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8568 break;
8569
8570 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8571 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8572 break;
8573
8574 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8575 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8576 break;
8577
8578 default:
8579 // unknown
8580 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8581 return 0;
8582 }
8583
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308584 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8585
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 // validate the user priority
8587 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8588 {
8589 // out of range
8590 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8591 return 0;
8592 }
8593 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308594 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8595 {
8596 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8597 return 0;
8598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008599
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8601 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8602 tSpec.ts_info.psb, tSpec.ts_info.up);
8603
Jeff Johnson295189b2012-06-20 16:38:30 -07008604 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8605 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8606 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8607 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8608 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8609 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8610 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8611 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8612 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8613 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8614 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8615 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8616
8617 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8618
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308619 // Save the expected UAPSD settings by application, this will be needed
8620 // when re-negotiating UAPSD settings during BT Coex cases.
8621 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8622
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 // validate the ts info ack policy
8624 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8625 {
8626 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8627 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8628 break;
8629
8630 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8631 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8632 break;
8633
8634 default:
8635 // unknown
8636 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8637 return 0;
8638 }
8639
8640 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308641
8642 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 return 0;
8644}
8645
8646
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308647static int iw_add_tspec(struct net_device *dev,
8648 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 union iwreq_data *wrqu, char *extra)
8650{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308651 int ret;
8652
8653 vos_ssr_protect(__func__);
8654 ret = __iw_add_tspec(dev, info, wrqu, extra);
8655 vos_ssr_unprotect(__func__);
8656
8657 return ret;
8658}
8659
8660static int __iw_del_tspec(struct net_device *dev,
8661 struct iw_request_info *info,
8662 union iwreq_data *wrqu, char *extra)
8663{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308664 hdd_adapter_t *pAdapter;
8665 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 int *params = (int *)extra;
8667 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8668 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308669 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008670
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308671 ENTER();
8672
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308673 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8674 if (NULL == pAdapter)
8675 {
8676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8677 "%s: Adapter is NULL",__func__);
8678 return -EINVAL;
8679 }
8680
8681 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8682 ret = wlan_hdd_validate_context(pHddCtx);
8683 if (0 != ret)
8684 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308685 return ret;
8686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 // make sure the application is sufficiently priviledged
8688 // note that the kernel will do this for "set" ioctls, but since
8689 // this ioctl wants to return status to user space it must be
8690 // defined as a "get" ioctl
8691 if (!capable(CAP_NET_ADMIN))
8692 {
8693 return -EPERM;
8694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 // although we are defined to be a "get" ioctl, the params we require
8696 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8697 // is no need to copy the params from user space
8698
8699 // validate the handle
8700 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8701 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8702 {
8703 // that one is reserved
8704 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8705 return 0;
8706 }
8707
8708 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308709
8710 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 return 0;
8712}
8713
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308714static int iw_del_tspec(struct net_device *dev,
8715 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 union iwreq_data *wrqu, char *extra)
8717{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308718 int ret;
8719
8720 vos_ssr_protect(__func__);
8721 ret = __iw_del_tspec(dev, info, wrqu, extra);
8722 vos_ssr_unprotect(__func__);
8723
8724 return ret;
8725}
8726
8727
8728static int __iw_get_tspec(struct net_device *dev,
8729 struct iw_request_info *info,
8730 union iwreq_data *wrqu, char *extra)
8731{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308732 hdd_adapter_t *pAdapter;
8733 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 int *params = (int *)extra;
8735 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8736 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308737 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008738
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308739 ENTER();
8740
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 // although we are defined to be a "get" ioctl, the params we require
8742 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8743 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308744 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8745 if (NULL == pAdapter)
8746 {
8747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8748 "%s: Adapter is NULL",__func__);
8749 return -EINVAL;
8750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008751
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8753 ret = wlan_hdd_validate_context(pHddCtx);
8754 if (0 != ret)
8755 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308756 return ret;
8757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 // validate the handle
8759 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8760 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8761 {
8762 // that one is reserved
8763 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8764 return 0;
8765 }
8766
8767 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308768 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 return 0;
8770}
8771
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308772static int iw_get_tspec(struct net_device *dev,
8773 struct iw_request_info *info,
8774 union iwreq_data *wrqu, char *extra)
8775{
8776 int ret;
8777
8778 vos_ssr_protect(__func__);
8779 ret = __iw_get_tspec(dev, info, wrqu, extra);
8780 vos_ssr_unprotect(__func__);
8781
8782 return ret;
8783}
8784
Manjeet Singh3ed79242017-01-11 19:04:32 +05308785/**
8786 * __iw_setnone_get_threeint() - return three value to up layer.
8787 *
8788 * @dev: pointer of net_device of this wireless card
8789 * @info: meta data about Request sent
8790 * @wrqu: include request info
8791 * @extra: buf used for in/Output
8792 *
8793 * Return: execute result
8794 */
8795static int __iw_setnone_get_threeint(struct net_device *dev,
8796 struct iw_request_info *info,
8797 union iwreq_data *wrqu, char *extra)
8798{
8799 int ret = 0; /* success */
8800 uint32_t *value = (int *)extra;
8801 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8802
8803 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8804
8805 switch (value[0]) {
8806 case WE_GET_TSF:
8807 ret = hdd_indicate_tsf(adapter, value, 3);
8808 break;
8809 default:
8810 hddLog(VOS_TRACE_LEVEL_ERROR,
8811 FL("Invalid IOCTL get_value command %d"),
8812 value[0]);
8813 break;
8814 }
8815 return ret;
8816}
8817
8818/**
8819 * iw_setnone_get_threeint() - return three value to up layer.
8820 *
8821 * @dev: pointer of net_device of this wireless card
8822 * @info: meta data about Request sent
8823 * @wrqu: include request info
8824 * @extra: buf used for in/Output
8825 *
8826 * Return: execute result
8827 */
8828static int iw_setnone_get_threeint(struct net_device *dev,
8829 struct iw_request_info *info,
8830 union iwreq_data *wrqu, char *extra)
8831{
8832 int ret;
8833
8834 vos_ssr_protect(__func__);
8835 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8836 vos_ssr_unprotect(__func__);
8837
8838 return ret;
8839}
8840
Jeff Johnson295189b2012-06-20 16:38:30 -07008841#ifdef WLAN_FEATURE_VOWIFI_11R
8842//
8843//
8844// Each time the supplicant has the auth_request or reassoc request
8845// IEs ready. This is pushed to the driver. The driver will inturn use
8846// it to send out the auth req and reassoc req for 11r FT Assoc.
8847//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308848static int __iw_set_fties(struct net_device *dev,
8849 struct iw_request_info *info,
8850 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008851{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308852 hdd_adapter_t *pAdapter;
8853 hdd_station_ctx_t *pHddStaCtx;
8854 hdd_context_t *pHddCtx;
8855 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 //v_CONTEXT_t pVosContext;
8857
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308858 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308859 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8860 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008861 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8863 "%s: Adapter is NULL",__func__);
8864 return -EINVAL;
8865 }
8866 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8867 ret = wlan_hdd_validate_context(pHddCtx);
8868 if (0 != ret)
8869 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308870 return ret;
8871 }
8872 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8873 if (NULL == pHddStaCtx)
8874 {
8875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8876 "%s: STA Context is NULL",__func__);
8877 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 if (!wrqu->data.length)
8880 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008881 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 return -EINVAL;
8883 }
8884 if (wrqu->data.pointer == NULL)
8885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008886 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 return -EINVAL;
8888 }
8889
8890 // Added for debug on reception of Re-assoc Req.
8891 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8892 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008893 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008895 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 }
8897
8898#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008899 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008900#endif
8901
8902 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008903 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 wrqu->data.length);
8905
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308906 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 return 0;
8908}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308909
8910static int iw_set_fties(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_fties(dev, info, wrqu, extra);
8918 vos_ssr_unprotect(__func__);
8919
8920 return ret;
8921}
Jeff Johnson295189b2012-06-20 16:38:30 -07008922#endif
8923
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308924static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008925 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008927{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308928 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008929 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308930 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008931 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308932 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008933 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8934 int idx;
8935 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008936
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308937 ENTER();
8938
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308939 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8940 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008941 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8943 "%s: Adapter is NULL",__func__);
8944 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008945 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308946 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8947 ret_val = wlan_hdd_validate_context(pHddCtx);
8948 if (0 != ret_val)
8949 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308950 return ret_val;
8951 }
8952 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8953 if (NULL == hHal)
8954 {
8955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8956 "%s: Hal Context is NULL",__func__);
8957 return -EINVAL;
8958 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308959 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8960 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308961#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008962
Amar Singhalf3a6e762013-02-19 15:06:50 -08008963 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8964 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008965 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008966 hddLog(VOS_TRACE_LEVEL_ERROR,
8967 "%s: vos_mem_alloc failed", __func__);
8968 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008969 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008970
8971 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8972
8973 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8974 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8975
8976 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8977 mc_addr_list_ptr->ulMulticastAddrCnt);
8978
8979 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008980 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008981 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8982 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8983
8984 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8985 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008986 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008987
Amar Singhalf3a6e762013-02-19 15:06:50 -08008988 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8989 vos_mem_free(mc_addr_list_ptr);
8990 if (eHAL_STATUS_SUCCESS != ret_val)
8991 {
8992 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8993 __func__);
8994 return -EINVAL;
8995 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308996#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308997 }
8998 else
8999 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07009000
Amar Singhalf3a6e762013-02-19 15:06:50 -08009001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9002 "%s: Set MC BC Filter Config request: %d suspend %d",
9003 __func__, pRequest->mcastBcastFilterSetting,
9004 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309005 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309006 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309007 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08009008
9009 if (pHddCtx->hdd_wlan_suspended)
9010 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07009011 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
9012 if (NULL == wlanRxpFilterParam)
9013 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309014 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07009015 "%s: vos_mem_alloc failed", __func__);
9016 return -EINVAL;
9017 }
9018
Amar Singhalf3a6e762013-02-19 15:06:50 -08009019 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9020 pRequest->mcastBcastFilterSetting;
9021 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309022 /* Fwr expect offload needs to clear before set */
9023 hdd_conf_hostoffload(pAdapter, FALSE);
9024 spin_lock(&pHddCtx->filter_lock);
9025 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
9026 spin_unlock(&pHddCtx->filter_lock);
9027 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
9028 {
9029 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
9030 pHddCtx->sus_res_mcastbcast_filter =
9031 pRequest->mcastBcastFilterSetting;
9032 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08009033
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05309034 hdd_conf_hostoffload(pAdapter, TRUE);
9035 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9036 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08009037
9038 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
9039 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309040 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08009041 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
9042 wlanRxpFilterParam->setMcstBcstFilter);
9043
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309044 if (eHAL_STATUS_SUCCESS !=
9045 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
9046 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08009047 {
9048 hddLog(VOS_TRACE_LEVEL_ERROR,
9049 "%s: Failure to execute set HW MC/BC Filter request",
9050 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009051 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08009052 return -EINVAL;
9053 }
9054
mukul sharmae4abd892016-11-24 22:03:31 +05309055 /* mc add list cfg item configuration in fwr */
9056 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08009057 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07009058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009059
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309060 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 return 0;
9062}
9063
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309064static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9065 struct iw_request_info *info,
9066 union iwreq_data *wrqu, char *extra)
9067{
9068 int ret;
9069
9070 vos_ssr_protect(__func__);
9071 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
9072 vos_ssr_unprotect(__func__);
9073
9074 return ret;
9075}
9076
9077static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
9078 struct iw_request_info *info,
9079 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009080{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309081 hdd_adapter_t *pAdapter;
9082 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309083 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309084 int ret = 0;
9085
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309086 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009087
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05309088 if (!capable(CAP_NET_ADMIN))
9089 {
9090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9091 FL("permission check failed"));
9092 return -EPERM;
9093 }
9094
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309095 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9096 if (NULL == pAdapter)
9097 {
9098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9099 "%s: Adapter is NULL",__func__);
9100 return -EINVAL;
9101 }
9102
9103 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9104 ret = wlan_hdd_validate_context(pHddCtx);
9105 if (0 != ret)
9106 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309107 return ret;
9108 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309109 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309110 //Reset the filter to INI value as we have to clear the dynamic filter
9111 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309112 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07009113
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309114 //Configure FW with new setting
9115 if (pHddCtx->hdd_wlan_suspended)
9116 {
9117 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
9118 if (NULL == wlanRxpFilterParam)
9119 {
9120 hddLog(VOS_TRACE_LEVEL_ERROR,
9121 "%s: vos_mem_alloc failed", __func__);
9122 return -EINVAL;
9123 }
9124
9125 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9126 pHddCtx->configuredMcastBcastFilter;
9127 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05309128 /* Fwr expect offload needs to clear before set */
9129 hdd_conf_hostoffload(pAdapter, FALSE);
9130 spin_lock(&pHddCtx->filter_lock);
9131 pHddCtx->configuredMcastBcastFilter =
9132 pHddCtx->cfg_ini->mcastBcastFilterSetting;
9133 spin_unlock(&pHddCtx->filter_lock);
9134
9135 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
9136 {
9137 pHddCtx->sus_res_mcastbcast_filter =
9138 pHddCtx->cfg_ini->mcastBcastFilterSetting;
9139 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309140
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05309141 hdd_conf_hostoffload(pAdapter, TRUE);
9142 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
9143 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309144 if (eHAL_STATUS_SUCCESS !=
9145 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
9146 wlanRxpFilterParam))
9147 {
9148 hddLog(VOS_TRACE_LEVEL_ERROR,
9149 "%s: Failure to execute set HW MC/BC Filter request",
9150 __func__);
9151 vos_mem_free(wlanRxpFilterParam);
9152 return -EINVAL;
9153 }
c_hpothud3ce76d2014-10-28 10:34:13 +05309154
mukul sharmae4abd892016-11-24 22:03:31 +05309155 /* mc add list cfg item configuration in fwr */
9156 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309157 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309158 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 return 0;
9160}
9161
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309162
9163static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
9164 struct iw_request_info *info,
9165 union iwreq_data *wrqu, char *extra)
9166{
9167 int ret;
9168
9169 vos_ssr_protect(__func__);
9170 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
9171 vos_ssr_unprotect(__func__);
9172
9173 return ret;
9174}
9175
9176static int __iw_set_host_offload(struct net_device *dev,
9177 struct iw_request_info *info,
9178 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009179{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309180 hdd_adapter_t *pAdapter;
9181 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009182 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309184 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009185
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309186 ENTER();
9187
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309188 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9189 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009190 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9192 "%s: Adapter is NULL",__func__);
9193 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009194 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309195 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9196 ret = wlan_hdd_validate_context(pHddCtx);
9197 if (0 != ret)
9198 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309199 return ret;
9200 }
9201
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 /* Debug display of request components. */
9203 switch (pRequest->offloadType)
9204 {
9205 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009206 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 switch (pRequest->enableOrDisable)
9208 {
9209 case WLAN_OFFLOAD_DISABLE:
9210 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
9211 break;
9212 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
9213 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
9214 case WLAN_OFFLOAD_ENABLE:
9215 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
9216 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
9217 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
9218 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
9219 }
9220 break;
9221
9222 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08009223 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009224 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 switch (pRequest->enableOrDisable)
9226 {
9227 case WLAN_OFFLOAD_DISABLE:
9228 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
9229 break;
9230 case WLAN_OFFLOAD_ENABLE:
9231 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
9232 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
9233 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
9234 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
9235 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
9236 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
9237 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
9238 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
9239 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
9240 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
9241 }
9242 }
9243
Hanumanth Reddy Pothula94bd51a2017-12-01 13:34:48 +05309244 vos_mem_zero(&offloadRequest, sizeof(offloadRequest));
9245 offloadRequest.offloadType = pRequest->offloadType;
9246 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
9247 vos_mem_copy(&offloadRequest.params, &pRequest->params,
9248 sizeof(pRequest->params));
9249 vos_mem_copy(&offloadRequest.bssId, &pRequest->bssId.bytes,
9250 VOS_MAC_ADDRESS_LEN);
9251
Jeff Johnsone7245742012-09-05 17:12:55 -07009252 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9253 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009255 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 __func__);
9257 return -EINVAL;
9258 }
9259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309260 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009261 return 0;
9262}
9263
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309264static int iw_set_host_offload(struct net_device *dev,
9265 struct iw_request_info *info,
9266 union iwreq_data *wrqu, char *extra)
9267{
9268 int ret;
9269
9270 vos_ssr_protect(__func__);
9271 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9272 vos_ssr_unprotect(__func__);
9273
9274 return ret;
9275}
9276
9277static int __iw_set_keepalive_params(struct net_device *dev,
9278 struct iw_request_info *info,
9279 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009280{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309281 hdd_adapter_t *pAdapter;
9282 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009283 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309285 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009286
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309287 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309288 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9289 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9292 "%s: Adapter is NULL",__func__);
9293 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009294 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309295 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9296 ret = wlan_hdd_validate_context(pHddCtx);
9297 if (0 != ret)
9298 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309299 return ret;
9300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009302 hddLog(VOS_TRACE_LEVEL_INFO,
9303 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9304 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009305
9306 switch (pRequest->packetType)
9307 {
9308 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009309 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 break;
9311
9312 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9313
Arif Hussain6d2a3322013-11-17 19:50:10 -08009314 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009315 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009316
9317 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9318 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9319 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9320
9321 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9322 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9323 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9324
9325 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9326 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9327 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9328 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9329 break;
9330
9331 }
9332
9333 /* Execute keep alive request. The reason that we can copy the request information
9334 from the ioctl structure to the SME structure is that they are laid out
9335 exactly the same. Otherwise, each piece of information would have to be
9336 copied individually. */
9337 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9338
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309339 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9340 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009341
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009342 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009343 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009345 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 __func__);
9347 return -EINVAL;
9348 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309349 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 return 0;
9351}
9352
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309353static int iw_set_keepalive_params(struct net_device *dev,
9354 struct iw_request_info *info,
9355 union iwreq_data *wrqu, char *extra)
9356{
9357 int ret;
9358 vos_ssr_protect(__func__);
9359 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9360 vos_ssr_unprotect(__func__);
9361
9362 return ret;
9363}
9364
Jeff Johnson295189b2012-06-20 16:38:30 -07009365#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309366/**-----------------------------------------------------------------
9367
9368 \brief hdd_pkt_filter_done - callback to be executed on completion
9369 successful/failure) for clear filter request.
9370
9371 \return - None
9372
9373 --------------------------------------------------------------------------*/
9374static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009375{
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309376 struct hdd_request *request;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309377
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309378 hddLog(VOS_TRACE_LEVEL_INFO,
9379 FL("Pkt Filter Clear Status : %d"), status);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309380
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309381 request = hdd_request_get(data);
9382 if (!request) {
9383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
9384 if (ioctl_debug)
9385 pr_info("%s: Obsolete request", __func__);
9386 return;
9387 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309388
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309389 hdd_request_complete(request);
9390 hdd_request_put(request);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309391}
9392
9393int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9394{
9395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309396 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009397 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9398 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309399 int i=0, status;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309400 void *cookie;
9401 struct hdd_request *request;
9402 static const struct hdd_request_params params = {
9403 .priv_size = 0,
9404 .timeout_ms = PKT_FILTER_TIMEOUT,
9405 };
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309406
9407 status = wlan_hdd_validate_context(pHddCtx);
9408 if (0 != status)
9409 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009410
9411 if (pHddCtx->cfg_ini->disablePacketFilter)
9412 {
9413 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009414 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 return 0;
9416 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309417 if (pHddCtx->isLogpInProgress)
9418 {
9419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9420 "%s:LOGP in Progress. Ignore!!!", __func__);
9421 return -EBUSY;
9422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 /* Debug display of request components. */
9424 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009425 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009426
9427 switch (pRequest->filterAction)
9428 {
9429 case HDD_RCV_FILTER_SET:
9430 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009431 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009432
9433 packetFilterSetReq.filterId = pRequest->filterId;
9434 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9435 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009436 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 __func__, pRequest->numParams);
9438 return -EINVAL;
9439 }
9440 packetFilterSetReq.numFieldParams = pRequest->numParams;
9441 packetFilterSetReq.coalesceTime = 0;
9442 packetFilterSetReq.filterType = 1;
9443 for (i=0; i < pRequest->numParams; i++)
9444 {
9445 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9446 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9447 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9448 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9449 packetFilterSetReq.paramsData[i].reserved = 0;
9450
Arif Hussain6d2a3322013-11-17 19:50:10 -08009451 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9453 packetFilterSetReq.filterType);
9454
Arif Hussain6d2a3322013-11-17 19:50:10 -08009455 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309457 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9458 (pRequest->paramsData[i].dataLength))
9459 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009460
9461 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9462 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9463 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9464 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9465
Arif Hussain6d2a3322013-11-17 19:50:10 -08009466 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9468 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9469 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9470
Arif Hussain6d2a3322013-11-17 19:50:10 -08009471 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9473 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9474 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9475 }
9476
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309477 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009479 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 __func__);
9481 return -EINVAL;
9482 }
9483
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309484 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9485 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 break;
9487
9488 case HDD_RCV_FILTER_CLEAR:
9489
Arif Hussain6d2a3322013-11-17 19:50:10 -08009490 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009491 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309492
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309493 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9494 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9495 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9496 pHddStaCtx->conn_info.staId[0]);
9497 }
9498
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309499 request = hdd_request_alloc(&params);
9500 if (!request) {
9501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
9502 return VOS_STATUS_E_NOMEM;
9503 }
9504 cookie = hdd_request_cookie(request);
9505
9506 packetFilterClrReq.cbCtx = cookie;
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309508 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309509 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(
9510 pHddCtx->hHal,
9511 &packetFilterClrReq,
9512 pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009514 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 __func__);
9516 return -EINVAL;
9517 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309518
Hanumanth Reddy Pothula73a2ca82018-04-11 12:54:39 +05309519 status = hdd_request_wait_for_response(request);
9520 hdd_request_put(request);
9521 if (status)
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309522 {
9523 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9524 status);
9525 return -EINVAL;
9526 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309527
9528 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9529 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 break;
9531
9532 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009533 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009534 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 return -EINVAL;
9536 }
9537 return 0;
9538}
9539
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309540int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9541 tANI_U8 sessionId)
9542{
9543 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9544 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9545
9546 if (NULL == pHddCtx)
9547 {
9548 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9549 return -EINVAL;
9550 }
9551
9552 if (pHddCtx->isLogpInProgress)
9553 {
9554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9555 "%s:LOGP in Progress. Ignore!!!", __func__);
9556 return -EBUSY;
9557 }
9558
9559 if (pHddCtx->cfg_ini->disablePacketFilter)
9560 {
9561 hddLog(VOS_TRACE_LEVEL_ERROR,
9562 "%s: Packet Filtering Disabled. Returning ",
9563 __func__ );
9564 return -EINVAL;
9565 }
9566
9567 switch (filterType)
9568 {
9569 /* For setting IPV6 MC and UC Filter we need to configure
9570 * 2 filters, one for MC and one for UC.
9571 * The Filter ID shouldn't be swapped, which results in making
9572 * UC Filter ineffective.
9573 * We have Hardcode all the values
9574 *
9575 * Reason for a seperate UC filter is because, driver need to
9576 * specify the FW that the specific filter is for unicast
9577 * otherwise FW will not pass the unicast frames by default
9578 * through the filter. This is required to avoid any performance
9579 * hits when no unicast filter is set and only MC/BC are set.
9580 * The way driver informs host is by using the MAC protocol
9581 * layer, CMP flag set to MAX, CMP Data set to 1.
9582 */
9583
9584 case HDD_FILTER_IPV6_MC_UC:
9585 /* Setting IPV6 MC Filter below
9586 */
9587 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9588 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9589 packetFilterSetReq.numFieldParams = 2;
9590 packetFilterSetReq.paramsData[0].protocolLayer =
9591 HDD_FILTER_PROTO_TYPE_MAC;
9592 packetFilterSetReq.paramsData[0].cmpFlag =
9593 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9594 packetFilterSetReq.paramsData[0].dataOffset =
9595 WLAN_HDD_80211_FRM_DA_OFFSET;
9596 packetFilterSetReq.paramsData[0].dataLength = 1;
9597 packetFilterSetReq.paramsData[0].compareData[0] =
9598 HDD_IPV6_MC_CMP_DATA;
9599
9600 packetFilterSetReq.paramsData[1].protocolLayer =
9601 HDD_FILTER_PROTO_TYPE_ARP;
9602 packetFilterSetReq.paramsData[1].cmpFlag =
9603 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9604 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9605 packetFilterSetReq.paramsData[1].dataLength = 2;
9606 packetFilterSetReq.paramsData[1].compareData[0] =
9607 HDD_IPV6_CMP_DATA_0;
9608 packetFilterSetReq.paramsData[1].compareData[1] =
9609 HDD_IPV6_CMP_DATA_1;
9610
9611
9612 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9613 &packetFilterSetReq, sessionId))
9614 {
9615 hddLog(VOS_TRACE_LEVEL_ERROR,
9616 "%s: Failure to execute Set IPv6 Mulicast Filter",
9617 __func__);
9618 return -EINVAL;
9619 }
9620
9621 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9622
9623 /*
9624 * Setting IPV6 UC Filter below
9625 */
9626 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9627 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9628 packetFilterSetReq.numFieldParams = 2;
9629 packetFilterSetReq.paramsData[0].protocolLayer =
9630 HDD_FILTER_PROTO_TYPE_MAC;
9631 packetFilterSetReq.paramsData[0].cmpFlag =
9632 HDD_FILTER_CMP_TYPE_MAX;
9633 packetFilterSetReq.paramsData[0].dataOffset = 0;
9634 packetFilterSetReq.paramsData[0].dataLength = 1;
9635 packetFilterSetReq.paramsData[0].compareData[0] =
9636 HDD_IPV6_UC_CMP_DATA;
9637
9638 packetFilterSetReq.paramsData[1].protocolLayer =
9639 HDD_FILTER_PROTO_TYPE_ARP;
9640 packetFilterSetReq.paramsData[1].cmpFlag =
9641 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9642 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9643 packetFilterSetReq.paramsData[1].dataLength = 2;
9644 packetFilterSetReq.paramsData[1].compareData[0] =
9645 HDD_IPV6_CMP_DATA_0;
9646 packetFilterSetReq.paramsData[1].compareData[1] =
9647 HDD_IPV6_CMP_DATA_1;
9648
9649 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9650 &packetFilterSetReq, sessionId))
9651 {
9652 hddLog(VOS_TRACE_LEVEL_ERROR,
9653 "%s: Failure to execute Set IPv6 Unicast Filter",
9654 __func__);
9655 return -EINVAL;
9656 }
9657
9658 break;
9659
9660 case HDD_FILTER_IPV6_MC:
9661 /*
9662 * IPV6 UC Filter might be already set,
9663 * clear the UC Filter. As the Filter
9664 * IDs are static, we can directly clear it.
9665 */
9666 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9667 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9668 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9669 &packetFilterClrReq, sessionId))
9670 {
9671 hddLog(VOS_TRACE_LEVEL_ERROR,
9672 "%s: Failure to execute Clear IPv6 Unicast Filter",
9673 __func__);
9674 return -EINVAL;
9675 }
9676
9677 /*
9678 * Setting IPV6 MC Filter below
9679 */
9680 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9681 packetFilterSetReq.numFieldParams = 2;
9682 packetFilterSetReq.paramsData[0].protocolLayer =
9683 HDD_FILTER_PROTO_TYPE_MAC;
9684 packetFilterSetReq.paramsData[0].cmpFlag =
9685 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9686 packetFilterSetReq.paramsData[0].dataOffset =
9687 WLAN_HDD_80211_FRM_DA_OFFSET;
9688 packetFilterSetReq.paramsData[0].dataLength = 1;
9689 packetFilterSetReq.paramsData[0].compareData[0] =
9690 HDD_IPV6_MC_CMP_DATA;
9691
9692 packetFilterSetReq.paramsData[1].protocolLayer =
9693 HDD_FILTER_PROTO_TYPE_ARP;
9694 packetFilterSetReq.paramsData[1].cmpFlag =
9695 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9696 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9697 packetFilterSetReq.paramsData[1].dataLength = 2;
9698 packetFilterSetReq.paramsData[1].compareData[0] =
9699 HDD_IPV6_CMP_DATA_0;
9700 packetFilterSetReq.paramsData[1].compareData[1] =
9701 HDD_IPV6_CMP_DATA_1;
9702
9703
9704 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9705 &packetFilterSetReq, sessionId))
9706 {
9707 hddLog(VOS_TRACE_LEVEL_ERROR,
9708 "%s: Failure to execute Set IPv6 Multicast Filter",
9709 __func__);
9710 return -EINVAL;
9711 }
9712 break;
9713
9714 default :
9715 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9716 "%s: Packet Filter Request: Invalid",
9717 __func__);
9718 return -EINVAL;
9719 }
9720 return 0;
9721}
9722
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309723void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009724{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309725 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309726 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009727 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309728 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009729
Yue Ma3ede6052013-08-29 00:33:26 -07009730 if (NULL == pHddCtx)
9731 {
9732 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9733 return;
9734 }
9735
9736 hHal = pHddCtx->hHal;
9737
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309738 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9741 return;
9742 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309743
9744 /* Check if INI is enabled or not, other wise just return
9745 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309746 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309747 {
9748 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9749 if (NULL == pMulticastAddrs)
9750 {
9751 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9752 return;
9753 }
9754
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 if (set)
9756 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309757 /* Following pre-conditions should be satisfied before wei
9758 * configure the MC address list.
9759 */
9760 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9761 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9762 && pAdapter->mc_addr_list.mc_cnt
9763 && (eConnectionState_Associated ==
9764 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9765 {
9766 pMulticastAddrs->ulMulticastAddrCnt =
9767 pAdapter->mc_addr_list.mc_cnt;
9768 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9769 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009770 memcpy(pMulticastAddrs->multicastAddr[i],
9771 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309772 sizeof(pAdapter->mc_addr_list.addr[i]));
9773 hddLog(VOS_TRACE_LEVEL_INFO,
9774 "%s: %s multicast filter: addr ="
9775 MAC_ADDRESS_STR,
9776 __func__, set ? "setting" : "clearing",
9777 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9778 }
9779 /* Set multicast filter */
9780 sme_8023MulticastList(hHal, pAdapter->sessionId,
9781 pMulticastAddrs);
9782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309784 else
9785 {
9786 /* Need to clear only if it was previously configured
9787 */
9788 if (pAdapter->mc_addr_list.isFilterApplied)
9789 {
9790 pMulticastAddrs->ulMulticastAddrCnt = 0;
9791 sme_8023MulticastList(hHal, pAdapter->sessionId,
9792 pMulticastAddrs);
9793 }
9794
9795 }
9796 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009797 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309799 else
9800 {
9801 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309802 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309803 }
9804 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009805}
9806
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309807static int __iw_set_packet_filter_params(struct net_device *dev,
9808 struct iw_request_info *info,
9809 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309810{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309811 hdd_adapter_t *pAdapter;
9812 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009813 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309814 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309815 struct iw_point s_priv_data;
9816
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309817 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309818
9819 if (!capable(CAP_NET_ADMIN))
9820 {
9821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9822 FL("permission check failed"));
9823 return -EPERM;
9824 }
9825
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309826 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9827 if (NULL == pAdapter)
9828 {
9829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9830 "%s: Adapter is NULL",__func__);
9831 return -EINVAL;
9832 }
9833 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9834 ret = wlan_hdd_validate_context(pHddCtx);
9835 if (0 != ret)
9836 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309837 return ret;
9838 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309839 if (hdd_priv_get_data(&s_priv_data, wrqu))
9840 {
9841 return -EINVAL;
9842 }
9843
9844 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9845 {
9846 return -EINVAL;
9847 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009848
Arif Hussain0273cba2014-01-07 20:58:29 -08009849 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309850 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9851 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009852 if (NULL == pRequest)
9853 {
9854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9855 "mem_alloc_copy_from_user_helper fail");
9856 return -ENOMEM;
9857 }
9858
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309859 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009860 kfree(pRequest);
9861
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309862 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009863 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009864}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309865
9866static int iw_set_packet_filter_params(struct net_device *dev,
9867 struct iw_request_info *info,
9868 union iwreq_data *wrqu, char *extra)
9869{
9870 int ret;
9871
9872 vos_ssr_protect(__func__);
9873 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9874 vos_ssr_unprotect(__func__);
9875
9876 return ret;
9877}
Jeff Johnson295189b2012-06-20 16:38:30 -07009878#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309879static int __iw_get_statistics(struct net_device *dev,
9880 struct iw_request_info *info,
9881 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009882{
9883
9884 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9885 eHalStatus status = eHAL_STATUS_SUCCESS;
9886 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309887 hdd_adapter_t *pAdapter;
9888 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309890 int tlen = 0, ret = 0;
9891 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009892
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309893 tCsrGlobalClassAStatsInfo *aStats;
9894 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009895
9896 ENTER();
9897
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309898 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9899 if (NULL == pAdapter)
9900 {
9901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9902 "%s: Adapter is NULL",__func__);
9903 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309905 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9906 ret = wlan_hdd_validate_context(pHddCtx);
9907 if (0 != ret)
9908 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309909 return ret;
9910 }
9911 pStats = &(pAdapter->hdd_stats.summary_stat);
9912 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9913 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9915
9916 wrqu->txpower.value = 0;
9917 }
9918 else {
9919 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9920 SME_SUMMARY_STATS |
9921 SME_GLOBAL_CLASSA_STATS |
9922 SME_GLOBAL_CLASSB_STATS |
9923 SME_GLOBAL_CLASSC_STATS |
9924 SME_GLOBAL_CLASSD_STATS |
9925 SME_PER_STA_STATS,
9926 hdd_StatisticsCB, 0, FALSE,
9927 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9928
9929 if (eHAL_STATUS_SUCCESS != status)
9930 {
9931 hddLog(VOS_TRACE_LEVEL_ERROR,
9932 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009933 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 return -EINVAL;
9935 }
9936
9937 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309938 if (NULL == pWextState)
9939 {
9940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9941 "%s: pWextState is NULL",__func__);
9942 return -EINVAL;
9943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009944
9945 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9946 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9947 {
9948 hddLog(VOS_TRACE_LEVEL_ERROR,
9949 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009950 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 /*Remove the SME statistics list by passing NULL in callback argument*/
9952 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9953 SME_SUMMARY_STATS |
9954 SME_GLOBAL_CLASSA_STATS |
9955 SME_GLOBAL_CLASSB_STATS |
9956 SME_GLOBAL_CLASSC_STATS |
9957 SME_GLOBAL_CLASSD_STATS |
9958 SME_PER_STA_STATS,
9959 NULL, 0, FALSE,
9960 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9961
9962 return -EINVAL;
9963 }
9964 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9965 (tANI_U8) sizeof (pStats->retry_cnt),
9966 (char*) &(pStats->retry_cnt[0]),
9967 tlen);
9968
9969 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9970 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9971 (char*) &(pStats->multiple_retry_cnt[0]),
9972 tlen);
9973
9974 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9975 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9976 (char*) &(pStats->tx_frm_cnt[0]),
9977 tlen);
9978
9979 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9980 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9981 (char*) &(pStats->rx_frm_cnt),
9982 tlen);
9983
9984 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9985 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9986 (char*) &(pStats->frm_dup_cnt),
9987 tlen);
9988
9989 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9990 (tANI_U8) sizeof (pStats->fail_cnt),
9991 (char*) &(pStats->fail_cnt[0]),
9992 tlen);
9993
9994 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9995 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9996 (char*) &(pStats->rts_fail_cnt),
9997 tlen);
9998
9999 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
10000 (tANI_U8) sizeof (pStats->ack_fail_cnt),
10001 (char*) &(pStats->ack_fail_cnt),
10002 tlen);
10003
10004 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
10005 (tANI_U8) sizeof (pStats->rts_succ_cnt),
10006 (char*) &(pStats->rts_succ_cnt),
10007 tlen);
10008
10009 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
10010 (tANI_U8) sizeof (pStats->rx_discard_cnt),
10011 (char*) &(pStats->rx_discard_cnt),
10012 tlen);
10013
10014 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
10015 (tANI_U8) sizeof (pStats->rx_error_cnt),
10016 (char*) &(pStats->rx_error_cnt),
10017 tlen);
10018
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010019 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -070010020 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010021 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 tlen);
10023
10024 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
10025 (tANI_U8) sizeof (dStats->rx_byte_cnt),
10026 (char*) &(dStats->rx_byte_cnt),
10027 tlen);
10028
10029 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
10030 (tANI_U8) sizeof (dStats->rx_rate),
10031 (char*) &(dStats->rx_rate),
10032 tlen);
10033
10034 /* Transmit rate, in units of 500 kbit/sec */
10035 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
10036 (tANI_U8) sizeof (aStats->tx_rate),
10037 (char*) &(aStats->tx_rate),
10038 tlen);
10039
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010040 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
10041 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
10042 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -070010043 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010044 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
10045 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
10046 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -070010047 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010048 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
10049 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
10050 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -070010051 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010052 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
10053 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
10054 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -070010055 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010056 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
10057 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
10058 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -070010059 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010060 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
10061 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
10062 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -070010063 tlen);
10064
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 wrqu->data.length = tlen;
10066
10067 }
10068
10069 EXIT();
10070
10071 return 0;
10072}
10073
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010074static int iw_get_statistics(struct net_device *dev,
10075 struct iw_request_info *info,
10076 union iwreq_data *wrqu, char *extra)
10077{
10078 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010079
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010080 vos_ssr_protect(__func__);
10081 ret = __iw_get_statistics(dev, info, wrqu, extra);
10082 vos_ssr_unprotect(__func__);
10083
10084 return ret;
10085}
Jeff Johnson295189b2012-06-20 16:38:30 -070010086#ifdef FEATURE_WLAN_SCAN_PNO
10087
10088/*Max Len for PNO notification*/
10089#define MAX_PNO_NOTIFY_LEN 100
10090void found_pref_network_cb (void *callbackContext,
10091 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
10092{
10093 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
10094 union iwreq_data wrqu;
10095 char buf[MAX_PNO_NOTIFY_LEN+1];
10096
10097 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
10098 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
10099
10100 // create the event
10101 memset(&wrqu, 0, sizeof(wrqu));
10102 memset(buf, 0, sizeof(buf));
10103
10104 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
10105 pPrefNetworkFoundInd->ssId.ssId,
10106 (unsigned int)pPrefNetworkFoundInd->rssi);
10107
10108 wrqu.data.pointer = buf;
10109 wrqu.data.length = strlen(buf);
10110
10111 // send the event
10112
10113 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
10114
10115}
10116
10117
10118/*string based input*/
10119VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
10120 union iwreq_data *wrqu, char *extra, int nOffset)
10121{
10122 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +053010123 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -070010124 /* pnoRequest is a large struct, so we make it static to avoid stack
10125 overflow. This API is only invoked via ioctl, so it is
10126 serialized by the kernel rtnl_lock and hence does not need to be
10127 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010128 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010129 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010131 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +053010132 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
10134
10135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10136 "PNO data len %d data %s",
10137 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010138 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010139
10140 if (wrqu->data.length <= nOffset )
10141 {
10142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
10143 return VOS_STATUS_E_FAILURE;
10144 }
10145
10146 pnoRequest.enable = 0;
10147 pnoRequest.ucNetworksCount = 0;
10148 /*-----------------------------------------------------------------------
10149 Input is string based and expected to be like this:
10150
10151 <enabled> <netw_count>
10152 for each network:
10153 <ssid_len> <ssid> <authentication> <encryption>
10154 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
10155 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
10156
10157 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -070010158 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 2 5 2 300 0
Jeff Johnson295189b2012-06-20 16:38:30 -070010159
10160 this translates into:
10161 -----------------------------
10162 enable PNO
10163 look for 2 networks:
10164 test - with authentication type 0 and encryption type 0,
10165 that can be found on 3 channels: 1 6 and 11 ,
10166 SSID bcast type is unknown (directed probe will be sent if AP not found)
10167 and must meet -40dBm RSSI
10168
10169 test2 - with auth and enrytption type 4/4
10170 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
10171 bcast type is non-bcast (directed probe will be sent)
10172 and must not meet any RSSI threshold
10173
Jeff Johnson8301aa12013-03-28 14:27:29 -070010174 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010176
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010177 /* making sure argument string ends with '\0' */
10178 len = (wrqu->data.length-nOffset) + 1;
10179 data = vos_mem_malloc(len);
10180 if (NULL == data) {
10181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10182 FL("fail to allocate memory %zu"), len);
10183 return -EINVAL;
10184 }
10185 vos_mem_zero(data, len);
10186 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010187 ptr = data;
10188
10189 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010190 {
10191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10192 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010193 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -070010194 return VOS_STATUS_E_FAILURE;
10195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010196
10197 if ( 0 == pnoRequest.enable )
10198 {
10199 /*Disable PNO*/
10200 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +053010201 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
10202 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010203 pAdapter->sessionId,
10204 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010205 if (eHAL_STATUS_SUCCESS != status)
10206 {
10207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10208 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010209 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010210 return VOS_STATUS_E_FAILURE;
10211 }
10212 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010213 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 return VOS_STATUS_SUCCESS;
10215 }
10216
c_hpothu37f21312014-04-09 21:49:54 +053010217 if (TRUE == pHddCtx->isPnoEnable)
10218 {
10219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10220 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010221 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010222 return -EBUSY;
10223 }
10224 pHddCtx->isPnoEnable = TRUE;
10225
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -070010227
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010228 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010229 {
10230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10231 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010232 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010234
10235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10236 "PNO enable %d networks count %d offset %d",
10237 pnoRequest.enable,
10238 pnoRequest.ucNetworksCount,
10239 nOffset);
10240
10241 /* Parameters checking:
10242 ucNetworksCount has to be larger than 0*/
10243 if (( 0 == pnoRequest.ucNetworksCount ) ||
10244 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10245 {
10246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +053010247 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 }
10249
10250 ptr += nOffset;
10251
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010252 pnoRequest.aNetworks =
10253 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10254 if (pnoRequest.aNetworks == NULL)
10255 {
10256 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10257 FL("failed to allocate memory aNetworks %u"),
10258 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10259 goto error;
10260 }
10261 vos_mem_zero(pnoRequest.aNetworks,
10262 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10263
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
10265 {
10266
10267 pnoRequest.aNetworks[i].ssId.length = 0;
10268
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010269 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010270 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
10271
10272 if (1 != ucParams)
10273 {
10274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10275 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010276 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010278
10279 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
10280 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
10281 {
10282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10283 "SSID Len %d is not correct for network %d",
10284 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +053010285 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 }
10287
10288 /*Advance to SSID*/
10289 ptr += nOffset;
10290
Jeff Johnson8301aa12013-03-28 14:27:29 -070010291 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -080010292 pnoRequest.aNetworks[i].ssId.length);
10293 ptr += pnoRequest.aNetworks[i].ssId.length;
10294
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010295 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -080010296 &(pnoRequest.aNetworks[i].authentication),
10297 &(pnoRequest.aNetworks[i].encryption),
10298 &(pnoRequest.aNetworks[i].ucChannelCount),
10299 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010300
Wilson Yang623f6592013-10-08 16:33:37 -070010301 if ( 3 != ucParams )
10302 {
10303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10304 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010305 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010306 }
10307
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010309 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010310 "auth %d encry %d channel count %d offset %d",
10311 pnoRequest.aNetworks[i].ssId.length,
10312 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10313 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10314 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10315 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10316 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10317 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10318 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10319 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10320 pnoRequest.aNetworks[i].authentication,
10321 pnoRequest.aNetworks[i].encryption,
10322 pnoRequest.aNetworks[i].ucChannelCount,
10323 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010324
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 /*Advance to channel list*/
10326 ptr += nOffset;
10327
Wilson Yang623f6592013-10-08 16:33:37 -070010328 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010329 {
10330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10331 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010332 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 }
10334
10335 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10336 {
10337 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10338 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010339 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010340 &(pnoRequest.aNetworks[i].aChannels[j]),
10341 &nOffset))
10342 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10343 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010344 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010345 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010346 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10348 FL("invalid channel: %hhu"),
10349 pnoRequest.aNetworks[i].aChannels[j]);
10350 goto error;
10351 }
10352
Wilson Yang623f6592013-10-08 16:33:37 -070010353 /*Advance to next channel number*/
10354 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 }
10356 }
10357
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010358 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010359 &(pnoRequest.aNetworks[i].bcastNetwType),
10360 &nOffset))
10361 {
10362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10363 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010364 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010365 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010366 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10368 FL("invalid bcast nw type: %u"),
10369 pnoRequest.aNetworks[i].bcastNetwType);
10370 goto error;
10371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010372
10373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10374 "PNO bcastNetwType %d offset %d",
10375 pnoRequest.aNetworks[i].bcastNetwType,
10376 nOffset );
10377
10378 /*Advance to rssi Threshold*/
10379 ptr += nOffset;
10380
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010381 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010382 &(pnoRequest.aNetworks[i].rssiThreshold),
10383 &nOffset))
10384 {
10385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10386 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010387 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010389
10390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10391 "PNO rssi %d offset %d",
10392 pnoRequest.aNetworks[i].rssiThreshold,
10393 nOffset );
10394 /*Advance to next network*/
10395 ptr += nOffset;
10396 }/*For ucNetworkCount*/
10397
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010398 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010399 &(pnoRequest.scanTimers.ucScanTimersCount),
10400 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010401
10402 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010403 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 {
10405 ptr += nOffset;
10406
Jeff Johnson8301aa12013-03-28 14:27:29 -070010407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10408 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 pnoRequest.scanTimers.ucScanTimersCount,
10410 nOffset );
10411
10412 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10413 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010416 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 }
10418
10419 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10420 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010421 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010422 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10423 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10424 &nOffset);
10425
Wilson Yang623f6592013-10-08 16:33:37 -070010426 if (2 != ucParams)
10427 {
10428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10429 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010430 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010431 }
10432
Jeff Johnson8301aa12013-03-28 14:27:29 -070010433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10434 "PNO Timer value %d Timer repeat %d offset %d",
10435 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10437 nOffset );
10438
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 ptr += nOffset;
10440 }
10441
10442 }
10443 else
10444 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10446 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010447 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10448
10449 /*Scan timers defaults to 5 minutes*/
10450 pnoRequest.scanTimers.ucScanTimersCount = 1;
10451 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10452 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10453 }
10454
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010455 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010456
10457 pnoRequest.modePNO = ucMode;
10458 /*for LA we just expose suspend option*/
10459 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10460 {
10461 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10462 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010463 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10464 if (pnoRequest.p24GProbeTemplate == NULL){
10465 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10466 FL("failed to allocate memory p24GProbeTemplate %u"),
10467 SIR_PNO_MAX_PB_REQ_SIZE);
10468 goto error;
10469 }
10470
10471 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10472 if (pnoRequest.p5GProbeTemplate == NULL){
10473 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10474 FL("failed to allocate memory p5GProbeTemplate %u"),
10475 SIR_PNO_MAX_PB_REQ_SIZE);
10476 goto error;
10477 }
10478
10479 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10480 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010481
c_hpothu37f21312014-04-09 21:49:54 +053010482 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 pAdapter->sessionId,
10484 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010485 if (eHAL_STATUS_SUCCESS == status)
10486 {
10487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10488 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010489 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010490 return VOS_STATUS_SUCCESS;
10491 }
10492error:
10493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10494 "%s: Failed to enable PNO", __func__);
10495 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010496 if (pnoRequest.aNetworks)
10497 vos_mem_free(pnoRequest.aNetworks);
10498 if (pnoRequest.p24GProbeTemplate)
10499 vos_mem_free(pnoRequest.p24GProbeTemplate);
10500 if (pnoRequest.p5GProbeTemplate)
10501 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010502
10503 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010504 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010505}/*iw_set_pno*/
10506
10507VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10508 union iwreq_data *wrqu, char *extra, int nOffset)
10509{
10510 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10511 v_U8_t rssiThreshold = 0;
10512 v_U8_t nRead;
10513
Arif Hussain7adce1b2013-11-11 22:59:34 -080010514 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 &rssiThreshold);
10516
10517 if ( 1 != nRead )
10518 {
10519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10520 "Incorrect format");
10521 return VOS_STATUS_E_FAILURE;
10522 }
10523
10524 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10525 return VOS_STATUS_SUCCESS;
10526}
10527
10528
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010529static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010530 struct iw_request_info *info,
10531 union iwreq_data *wrqu, char *extra)
10532{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010533 hdd_adapter_t *pAdapter;
10534 hdd_context_t *pHddCtx;
10535 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010536 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010538 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010539 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10540 if (NULL == pAdapter)
10541 {
10542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10543 "%s: Adapter is NULL",__func__);
10544 return -EINVAL;
10545 }
10546
10547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10548 ret = wlan_hdd_validate_context(pHddCtx);
10549 if (0 != ret)
10550 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010551 return ret;
10552 }
10553
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010554
10555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010558 status = iw_set_pno(dev,info,wrqu,extra,0);
10559
10560 EXIT();
10561 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010562}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010563
10564static int iw_set_pno_priv(struct net_device *dev,
10565 struct iw_request_info *info,
10566 union iwreq_data *wrqu, char *extra)
10567{
10568 int ret;
10569
10570 vos_ssr_protect(__func__);
10571 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10572 vos_ssr_unprotect(__func__);
10573
10574 return ret;
10575}
Jeff Johnson295189b2012-06-20 16:38:30 -070010576#endif /*FEATURE_WLAN_SCAN_PNO*/
10577
10578//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010579int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010580{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010581 hdd_adapter_t *pAdapter;
10582 tHalHandle hHal;
10583 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010584 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010585 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010586 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010587 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010588 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010589 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010590 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010591
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010592 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010593 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10594 if (NULL == pAdapter)
10595 {
10596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10597 "%s: Adapter is NULL",__func__);
10598 return -EINVAL;
10599 }
10600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10601 retval = wlan_hdd_validate_context(pHddCtx);
10602 if (0 != retval)
10603 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010604 return retval;
10605 }
10606 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10607 if (NULL == hHal)
10608 {
10609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10610 "%s: Hal Context is NULL",__func__);
10611 return -EINVAL;
10612 }
10613 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010614
Atul Mittal54378cb2014-04-02 16:51:50 +053010615 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 {
10617 case WLAN_HDD_UI_BAND_AUTO:
10618 band = eCSR_BAND_ALL;
10619 break;
10620 case WLAN_HDD_UI_BAND_5_GHZ:
10621 band = eCSR_BAND_5G;
10622 break;
10623 case WLAN_HDD_UI_BAND_2_4_GHZ:
10624 band = eCSR_BAND_24;
10625 break;
10626 default:
10627 band = eCSR_BAND_MAX;
10628 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010629 connectedBand =
10630 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010631
Atul Mittal54378cb2014-04-02 16:51:50 +053010632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010633 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010634
10635 if (band == eCSR_BAND_MAX)
10636 {
10637 /* Received change band request with invalid band value */
10638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010639 "%s: Invalid band value %u", __func__, ui_band);
10640 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 }
10642
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010643 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010644 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010645 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010647 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010648 band, pHddCtx->cfg_ini->nBandCapability);
10649 return -EIO;
10650 }
10651
Sushant Kaushik1165f872015-03-30 20:25:27 +053010652 if (band == eCSR_BAND_ALL)
10653 {
10654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10655 "received. Setting band same as ini value %d"),
10656 pHddCtx->cfg_ini->nBandCapability);
10657 band = pHddCtx->cfg_ini->nBandCapability;
10658 }
10659
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10661 {
10662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10663 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010664 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 return -EIO;
10666 }
10667
10668 if (currBand != band)
10669 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010670 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010671 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010672 /* Return failure if current country code is world regulatory domain*/
10673 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10674 pMac->scan.countryCodeCurrent[1] == '0') )
10675 {
10676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10677 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010678 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010679 return -EAGAIN;
10680 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010681 }
10682
Jeff Johnson295189b2012-06-20 16:38:30 -070010683 /* Change band request received.
10684 * Abort pending scan requests, flush the existing scan results,
10685 * and change the band capability
10686 */
10687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10688 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010689 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010690
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010691 /* We need to change the band and flush the scan results here itself
10692 * as we may get timeout for disconnection in which we will return
10693 * with out doing any of these
10694 */
10695 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10696 {
10697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10698 "%s: failed to set the band value to %u ",
10699 __func__, band);
10700 return -EINVAL;
10701 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010702 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10703 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010704 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010705 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10706 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010707 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010708 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10709 * information available in NV so to get the channel information from kernel
10710 * we need to send regulatory hint for the currunt country
10711 * And to set the same country again we need to set the dummy country
10712 * first and then the actual country.
10713 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010714#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010715 if(curr_country[0] == '0' && curr_country[1] == '0')
10716 regulatory_hint_user("IN", NL80211_USER_REG_HINT_USER);
10717 else
10718 regulatory_hint_user("OO", NL80211_USER_REG_HINT_USER);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010719#else
Ashish Kumar Dhanotiyaaebbe052017-11-16 14:41:09 +053010720 if(curr_country[0] == '0' && curr_country[1] == '0')
10721 regulatory_hint_user("IN");
10722 else
10723 regulatory_hint_user("00");
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010724#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010725 wait_result = wait_for_completion_interruptible_timeout(
10726 &pHddCtx->linux_reg_req,
10727 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10728
10729 /* if the country information does not exist with the kernel,
10730 then the driver callback would not be called */
10731
10732 if (wait_result >= 0)
10733 {
10734 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10735 "runtime country code is found in kernel db");
10736 }
10737 else
10738 {
10739 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10740 "runtime country code is not found"
10741 " in kernel db");
10742 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010743
10744 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010745
10746 /*
10747 * Update 11dcountry and current country here as the hint
10748 * with 00 results in 11d and current country with 00
10749 */
10750 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10751 WNI_CFG_COUNTRY_CODE_LEN);
10752 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10753 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010754#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10755 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10756#else
10757 regulatory_hint_user(curr_country);
10758#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010759 wait_result = wait_for_completion_interruptible_timeout(
10760 &pHddCtx->linux_reg_req,
10761 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10762
10763 /* if the country information does not exist with the kernel,
10764 then the driver callback would not be called */
10765 if (wait_result >= 0)
10766 {
10767 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10768 "runtime country code is found in kernel db");
10769 }
10770 else
10771 {
10772 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10773 "runtime country code is not found"
10774 " in kernel db");
10775 }
10776
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010777 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010778 }
10779 else
10780 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010781#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010782 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10783 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010784#else
10785 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10786#endif
10787
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010788 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010789 pScanInfo = &pHddCtx->scan_info;
10790 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10791 {
10792 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10793 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10794 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010795 sme_FilterScanResults(hHal, pAdapter->sessionId);
10796
10797 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010798 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10799 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 eHalStatus status = eHAL_STATUS_SUCCESS;
10802 long lrc;
10803
10804 /* STA already connected on current band, So issue disconnect first,
10805 * then change the band*/
10806
10807 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010808 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010809 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010810
Jeff Johnson295189b2012-06-20 16:38:30 -070010811 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10812
10813 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10814 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10815
Jeff Johnson43971f52012-07-17 12:26:56 -070010816 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 {
10818 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010819 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010820 __func__, (int)status );
10821 return -EINVAL;
10822 }
10823
10824 lrc = wait_for_completion_interruptible_timeout(
10825 &pAdapter->disconnect_comp_var,
10826 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10827
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010828 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010829
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010830 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010831 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010832
10833 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10834 }
10835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010837 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010838 if (TRUE == pHddCtx->isSetBandByNL)
10839 return 0;
10840 else
10841 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010842}
10843
Atul Mittal54378cb2014-04-02 16:51:50 +053010844int hdd_setBand_helper(struct net_device *dev, const char *command)
10845{
10846 u8 band;
10847
10848 /*convert the band value from ascii to integer*/
10849 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10850
10851 return hdd_setBand(dev, band);
10852
10853}
10854
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010855static int __iw_set_band_config(struct net_device *dev,
10856 struct iw_request_info *info,
10857 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010858{
Atul Mittal54378cb2014-04-02 16:51:50 +053010859 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010860
Arif Hussain0273cba2014-01-07 20:58:29 -080010861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010862
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010863 if (!capable(CAP_NET_ADMIN))
10864 {
10865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10866 FL("permission check failed"));
10867 return -EPERM;
10868 }
10869
Atul Mittal54378cb2014-04-02 16:51:50 +053010870 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010871}
10872
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010873static int iw_set_band_config(struct net_device *dev,
10874 struct iw_request_info *info,
10875 union iwreq_data *wrqu, char *extra)
10876{
10877 int ret;
10878
10879 vos_ssr_protect(__func__);
10880 ret = __iw_set_band_config(dev, info, wrqu, extra);
10881 vos_ssr_unprotect(__func__);
10882
10883 return ret;
10884}
10885
c_manjeecfd1efb2015-09-25 19:32:34 +053010886static int get_fwr_memdump(struct net_device *dev,
10887 struct iw_request_info *info,
10888 union iwreq_data *wrqu, char *extra)
10889{
10890 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10891 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10892 int ret;
10893 ENTER();
10894 // HddCtx sanity
10895 ret = wlan_hdd_validate_context(pHddCtx);
10896 if (0 != ret)
10897 {
10898 return ret;
10899 }
10900 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10901 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10902 {
10903 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10904 return -EINVAL;
10905 }
10906 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10907
10908 EXIT();
10909 return ret;
10910}
10911
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010912static int __iw_set_power_params_priv(struct net_device *dev,
10913 struct iw_request_info *info,
10914 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010915{
Arif Hussain0273cba2014-01-07 20:58:29 -080010916 int ret;
10917 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010918
Jeff Johnson295189b2012-06-20 16:38:30 -070010919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10920 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010921
10922 if (!capable(CAP_NET_ADMIN))
10923 {
10924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10925 FL("permission check failed"));
10926 return -EPERM;
10927 }
10928
Arif Hussain0273cba2014-01-07 20:58:29 -080010929 /* ODD number is used for set, copy data using copy_from_user */
10930 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10931 wrqu->data.length);
10932 if (NULL == ptr)
10933 {
10934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10935 "mem_alloc_copy_from_user_helper fail");
10936 return -ENOMEM;
10937 }
10938
10939 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10940 kfree(ptr);
10941 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010942}
10943
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010944static int iw_set_power_params_priv(struct net_device *dev,
10945 struct iw_request_info *info,
10946 union iwreq_data *wrqu, char *extra)
10947{
10948 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010949
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010950 vos_ssr_protect(__func__);
10951 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10952 vos_ssr_unprotect(__func__);
10953
10954 return ret;
10955}
Jeff Johnson295189b2012-06-20 16:38:30 -070010956
10957/*string based input*/
10958VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10959 union iwreq_data *wrqu, char *extra, int nOffset)
10960{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010961 hdd_adapter_t *pAdapter;
10962 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010963 tSirSetPowerParamsReq powerRequest;
10964 char *ptr;
10965 v_U8_t ucType;
10966 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010967 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010968
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010969 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010970 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10971 if (NULL == pAdapter)
10972 {
10973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10974 "%s: Adapter is NULL",__func__);
10975 return -EINVAL;
10976 }
10977
10978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10979 ret = wlan_hdd_validate_context(pHddCtx);
10980 if (0 != ret)
10981 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010982 return ret;
10983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10985 "Power Params data len %d data %s",
10986 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010987 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010988
10989 if (wrqu->data.length <= nOffset )
10990 {
10991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10992 return VOS_STATUS_E_FAILURE;
10993 }
10994
10995 uTotalSize = wrqu->data.length - nOffset;
10996
10997 /*-----------------------------------------------------------------------
10998 Input is string based and expected to be like this:
10999
11000 <param_type> <param_value> <param_type> <param_value> ...
11001
11002 e.g:
11003 1 2 2 3 3 0 4 1 5 1
11004
11005 e.g. setting just a few:
11006 1 2 4 1
11007
11008 parameter types:
11009 -----------------------------
11010 1 - Ignore DTIM
11011 2 - Listen Interval
11012 3 - Broadcast Multicas Filter
11013 4 - Beacon Early Termination
11014 5 - Beacon Early Termination Interval
11015 -----------------------------------------------------------------------*/
11016 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
11017 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
11018 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
11019 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
11020 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
11021
Arif Hussain7adce1b2013-11-11 22:59:34 -080011022 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011023
11024 while ( uTotalSize )
11025 {
Wilson Yang6f971452013-10-08 15:00:00 -070011026 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
11027 {
11028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11029 "Invalid input parameter type %s",ptr);
11030 return VOS_STATUS_E_FAILURE;
11031 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011032
11033 uTotalSize -= nOffset;
11034
11035 if (!uTotalSize)
11036 {
11037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080011038 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 ucType, nOffset);
11040 return VOS_STATUS_E_FAILURE;
11041 }
11042
11043 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070011044
Jeff Johnson02797792013-10-26 19:17:13 -070011045 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070011046 {
11047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11048 "Invalid input parameter value %s",ptr);
11049 return VOS_STATUS_E_FAILURE;
11050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011051
11052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11053 "Power request parameter %d value %d offset %d",
11054 ucType, uValue, nOffset);
11055
11056 switch (ucType)
11057 {
11058 case eSIR_IGNORE_DTIM:
11059 powerRequest.uIgnoreDTIM = uValue;
11060 break;
11061 case eSIR_LISTEN_INTERVAL:
11062 powerRequest.uListenInterval = uValue;
11063 break;
11064 case eSIR_MCAST_BCAST_FILTER:
11065 powerRequest.uBcastMcastFilter = uValue;
11066 break;
11067 case eSIR_ENABLE_BET:
11068 powerRequest.uEnableBET = uValue;
11069 break;
11070 case eSIR_BET_INTERVAL:
11071 powerRequest.uBETInterval = uValue;
11072 break;
11073 default:
11074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080011075 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 ucType, uValue, nOffset);
11077 return VOS_STATUS_E_FAILURE;
11078 }
11079
11080 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11082 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070011083 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070011085 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011086 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070011087 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
11088 {
11089 uTotalSize = 0;
11090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011091
11092 }/*Go for as long as we have a valid string*/
11093
11094 /* put the device into full power*/
11095 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
11096
11097 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080011098 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011099
11100 /* put the device back to power save*/
11101 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
11102
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053011103 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011104 return VOS_STATUS_SUCCESS;
11105}/*iw_set_power_params*/
11106
Atul Mittalc0f739f2014-07-31 13:47:47 +053011107// tdlsoffchan
11108#ifdef FEATURE_WLAN_TDLS
11109
Atul Mittal87ec2422014-09-24 13:12:50 +053011110int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011111{
11112 if (offchannel < 0 || offchannel > 165)
11113 {
11114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
11115 __func__, offchannel);
11116 return -1;
11117
11118 }
11119
11120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
11121 __func__, tdlsOffCh, offchannel);
11122
11123 tdlsOffCh = offchannel;
11124 return 0;
11125}
11126
Atul Mittal87ec2422014-09-24 13:12:50 +053011127int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011128{
11129 if (offchanoffset == 0)
11130 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011131 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11133 __func__, tdlsOffChBwOffset);
11134
11135 return 0;
11136
11137 }
11138
11139 if ( offchanoffset == 40 )
11140 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011141 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11143 __func__, tdlsOffChBwOffset);
11144
11145 return 0;
11146
11147 }
11148 if (offchanoffset == -40)
11149 {
11150 tdlsOffChBwOffset = 3;
11151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
11152 __func__, tdlsOffChBwOffset);
11153
11154 return 0;
11155
11156 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053011157
11158 if ((offchanoffset == 80) &&
11159 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
11160 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
11161 {
11162 tdlsOffChBwOffset = 4;
11163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11164 "%s: change tdls secondary off channel offset to %u",
11165 __func__, tdlsOffChBwOffset);
11166
11167 return 0;
11168 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053011169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
11170 __func__, offchanoffset);
11171 return -1;
11172}
11173
Atul Mittal87ec2422014-09-24 13:12:50 +053011174int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053011175{
11176 hddTdlsPeer_t *connPeer = NULL;
11177 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11178 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011179 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053011180 if (offchanmode < 0 || offchanmode > 4)
11181 {
11182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11183 "%s: Invalid tdls off channel mode %d",
11184 __func__, offchanmode);
11185 return -1;
11186 }
11187
11188 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
11189 {
11190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11191 "%s: tdls off channel mode req in not associated state %d",
11192 __func__, offchanmode);
11193 return -1;
11194 }
11195
11196 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
11197 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
11198 {
11199 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011200 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053011201 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011202 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011203 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11205 "%s: No TDLS Connected Peer", __func__);
11206 return -1;
11207 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011208 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011209 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011210 }
11211 else
11212 {
11213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11214 "%s: TDLS Connection not supported", __func__);
11215 return -1;
11216 }
11217
11218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11219 ("%s: TDLS Channel Switch in swmode=%d"),
11220 __func__, offchanmode);
11221
11222 switch (offchanmode)
11223 {
11224 case 1:/*Enable*/
11225 case 2:/*Disable*/
11226 {
11227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11228 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
11229 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11230 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
11231 {
11232
11233 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011234 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053011235 tdlsOffCh, tdlsOffChBwOffset,
11236 offchanmode);
11237 }
11238 else
11239 {
11240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11241 "%s: TDLS Off Channel not supported", __func__);
11242 return -1;
11243 }
11244 break;
11245 }
11246 case 3:
11247 {
11248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11249 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
11250 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11251
11252 break;
11253 }
11254 case 4:
11255 {
11256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11257 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
11258 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11259 break;
11260 }
11261 default:
11262 {
11263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11264 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
11265 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11266 break;
11267 }
11268
11269 }
11270
11271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
11272 __func__, offchanmode);
11273 return 0;
11274}
Atul Mittalc0f739f2014-07-31 13:47:47 +053011275#endif
11276
Jeff Johnson295189b2012-06-20 16:38:30 -070011277// Define the Wireless Extensions to the Linux Network Device structure
11278// A number of these routines are NULL (meaning they are not implemented.)
11279
11280static const iw_handler we_handler[] =
11281{
11282 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
11283 (iw_handler) iw_get_name, /* SIOCGIWNAME */
11284 (iw_handler) NULL, /* SIOCSIWNWID */
11285 (iw_handler) NULL, /* SIOCGIWNWID */
11286 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
11287 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
11288 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
11289 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
11290 (iw_handler) NULL, /* SIOCSIWSENS */
11291 (iw_handler) NULL, /* SIOCGIWSENS */
11292 (iw_handler) NULL, /* SIOCSIWRANGE */
11293 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053011294 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 (iw_handler) NULL, /* SIOCGIWPRIV */
11296 (iw_handler) NULL, /* SIOCSIWSTATS */
11297 (iw_handler) NULL, /* SIOCGIWSTATS */
11298 iw_handler_set_spy, /* SIOCSIWSPY */
11299 iw_handler_get_spy, /* SIOCGIWSPY */
11300 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
11301 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
11302 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11303 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11304 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11305 (iw_handler) NULL, /* SIOCGIWAPLIST */
11306 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11307 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11308 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11309 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11310 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11311 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11312 (iw_handler) NULL, /* -- hole -- */
11313 (iw_handler) NULL, /* -- hole -- */
11314 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11315 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11316 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11317 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11318 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11319 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11320 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11321 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11322 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11323 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11324 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11325 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11326 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11327 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11328 (iw_handler) NULL, /* -- hole -- */
11329 (iw_handler) NULL, /* -- hole -- */
11330 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11331 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11332 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11333 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11334 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11335 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11336 (iw_handler) NULL, /* SIOCSIWPMKSA */
11337};
11338
11339static const iw_handler we_private[] = {
11340
11341 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11342 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11343 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11344 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11345 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11346 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011347 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11349 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11350 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011351 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11352 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011353#ifdef FEATURE_OEM_DATA_SUPPORT
11354 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11355 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011357
Jeff Johnson295189b2012-06-20 16:38:30 -070011358#ifdef WLAN_FEATURE_VOWIFI_11R
11359 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11360#endif
11361 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11362 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11363 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11364#ifdef WLAN_FEATURE_PACKET_FILTERING
11365 ,
11366 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11367#endif
11368#ifdef FEATURE_WLAN_SCAN_PNO
11369 ,
11370 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11371#endif
11372 ,
11373 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11374 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11375 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11376 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011377 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011378};
11379
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053011380static const iw_handler we_mon_private[] = {
11381 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] =
11382 iw_mon_setint_getnone,
11383};
11384
11385static const struct iw_priv_args we_mon_private_args[] = {
11386 {WE_SET_MONITOR_STATE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11387 0, "monitor"},
11388
11389 /* handlers for main ioctl */
11390 {WLAN_PRIV_SET_INT_GET_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11391 0, "" },
11392};
11393
Jeff Johnson295189b2012-06-20 16:38:30 -070011394/*Maximum command length can be only 15 */
11395static const struct iw_priv_args we_private_args[] = {
11396
Katya Nigamf0511f62015-05-05 16:40:57 +053011397 { WE_SET_MONITOR_STATE,
11398 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11399 0, "monitor" },
11400
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 /* handlers for main ioctl */
11402 { WLAN_PRIV_SET_INT_GET_NONE,
11403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11404 0,
11405 "" },
11406
11407 /* handlers for sub-ioctl */
11408 { WE_SET_11D_STATE,
11409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11410 0,
11411 "set11Dstate" },
11412
11413 { WE_WOWL,
11414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11415 0,
11416 "wowl" },
11417
11418 { WE_SET_POWER,
11419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11420 0,
11421 "setPower" },
11422
11423 { WE_SET_MAX_ASSOC,
11424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11425 0,
11426 "setMaxAssoc" },
11427
11428 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11429 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11430 0,
11431 "setAutoChannel" },
11432
11433 { WE_SET_DATA_INACTIVITY_TO,
11434 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11435 0,
11436 "inactivityTO" },
11437
11438 { WE_SET_MAX_TX_POWER,
11439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11440 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011441 "setMaxTxPower" },
11442
11443 { WE_SET_MAX_TX_POWER_2_4,
11444 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11445 0,
11446 "setTxMaxPower2G" },
11447
11448 { WE_SET_MAX_TX_POWER_5_0,
11449 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11450 0,
11451 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011452
11453 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11454 * as well to keep same syntax as in SAP. Now onwards, STA
11455 * will support both */
11456 { WE_SET_MAX_TX_POWER,
11457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11458 0,
11459 "setTxMaxPower" },
11460
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11462 * 1 = enable and 0 = disable */
11463 {
11464 WE_SET_HIGHER_DTIM_TRANSITION,
11465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11466 0,
11467 "setHDtimTransn" },
11468
11469 { WE_SET_TM_LEVEL,
11470 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011471 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 "setTmLevel" },
11473
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011474 { WE_ENABLE_STRICT_FCC_REG,
11475 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11476 0,
11477 "setStrictFCCreg" },
11478
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011479 { WE_SET_DEBUG_LOG,
11480 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11481 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011482#ifdef FEATURE_WLAN_TDLS
11483 {
11484 WE_SET_TDLS_OFF_CHAN,
11485 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11486 0,
11487 "tdlsoffchan" },
11488 {
11489 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11490 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11491 0,
11492 "tdlsecchnoffst" },
11493 {
11494 WE_SET_TDLS_OFF_CHAN_MODE,
11495 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11496 0,
11497 "tdlsoffchnmode" },
11498#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011499
Peng Xu2446a892014-09-05 17:21:18 +053011500 { WE_SET_SCAN_BAND_PREFERENCE,
11501 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11502 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011503 {
11504 WE_GET_FRAME_LOG,
11505 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11506 0,
11507 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011508
Abhishek Singh01c73d12015-03-12 15:13:44 +053011509 { WE_SET_MIRACAST_VENDOR_CONFIG,
11510 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11511 0, "setMiracstConf" },
11512
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011513#ifdef FEATURE_WLAN_TDLS
11514 {
11515 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11516 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11517 0,
11518 "tdls_2040bsscox" },
11519#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011520 { WE_SET_RTS_CTS_HTVHT,
11521 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11522 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011523 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11525 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011526 { WE_SET_PROXIMITY_ENABLE,
11527 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11528 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011529
11530#ifdef WLAN_FEATURE_TSF
11531 { WE_CAP_TSF,
11532 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11533 0, "cap_tsf" },
11534#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011535 { WE_SET_MODULATED_DTIM,
11536 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11537 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011538 {
11539 WLAN_SET_DYNNAMIC_AGGREGATION,
11540 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11541 0, "setAggregation" },
11542
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 /* handlers for main ioctl */
11544 { WLAN_PRIV_SET_NONE_GET_INT,
11545 0,
11546 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11547 "" },
11548
11549 /* handlers for sub-ioctl */
11550 { WE_GET_11D_STATE,
11551 0,
11552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11553 "get11Dstate" },
11554
11555 { WE_IBSS_STATUS,
11556 0,
11557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11558 "getAdhocStatus" },
11559
11560 { WE_PMC_STATE,
11561 0,
11562 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11563 "pmcState" },
11564
11565 { WE_GET_WLAN_DBG,
11566 0,
11567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11568 "getwlandbg" },
11569
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 { WE_GET_MAX_ASSOC,
11571 0,
11572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11573 "getMaxAssoc" },
11574
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 { WE_GET_WDI_DBG,
11576 0,
11577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11578 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011579
11580 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11581 0,
11582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11583 "getAutoChannel" },
11584
11585 { WE_GET_CONCURRENCY_MODE,
11586 0,
11587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11588 "getconcurrency" },
11589
Peng Xu2446a892014-09-05 17:21:18 +053011590 { WE_GET_SCAN_BAND_PREFERENCE,
11591 0,
11592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11593 "get_scan_pref"},
11594
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011595 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11596 0,
11597 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11598 "getCurAnt"},
11599
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 /* handlers for main ioctl */
11601 { WLAN_PRIV_SET_CHAR_GET_NONE,
11602 IW_PRIV_TYPE_CHAR| 512,
11603 0,
11604 "" },
11605
11606 /* handlers for sub-ioctl */
11607 { WE_WOWL_ADD_PTRN,
11608 IW_PRIV_TYPE_CHAR| 512,
11609 0,
11610 "wowlAddPtrn" },
11611
11612 { WE_WOWL_DEL_PTRN,
11613 IW_PRIV_TYPE_CHAR| 512,
11614 0,
11615 "wowlDelPtrn" },
11616
11617#if defined WLAN_FEATURE_VOWIFI
11618 /* handlers for sub-ioctl */
11619 { WE_NEIGHBOR_REPORT_REQUEST,
11620 IW_PRIV_TYPE_CHAR | 512,
11621 0,
11622 "neighbor" },
11623#endif
11624 { WE_SET_AP_WPS_IE,
11625 IW_PRIV_TYPE_CHAR| 512,
11626 0,
11627 "set_ap_wps_ie" },
11628
11629 { WE_SET_CONFIG,
11630 IW_PRIV_TYPE_CHAR| 512,
11631 0,
11632 "setConfig" },
11633
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011634 { WE_SET_ENCRYPT_MSG,
11635 IW_PRIV_TYPE_CHAR| 512,
11636 0,
11637 "encryptMsg" },
11638
11639
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 /* handlers for main ioctl */
11641 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11642 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11643 0,
11644 "" },
11645
11646 /* handlers for sub-ioctl */
11647 { WE_SET_WLAN_DBG,
11648 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11649 0,
11650 "setwlandbg" },
11651
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 { WE_SET_WDI_DBG,
11653 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11654 0,
11655 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011656
11657 { WE_SET_SAP_CHANNELS,
11658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11659 0,
11660 "setsapchannels" },
11661
11662 /* handlers for main ioctl */
11663 { WLAN_PRIV_GET_CHAR_SET_NONE,
11664 0,
11665 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11666 "" },
11667
11668 /* handlers for sub-ioctl */
11669 { WE_WLAN_VERSION,
11670 0,
11671 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11672 "version" },
11673 { WE_GET_STATS,
11674 0,
11675 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11676 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011677 { WE_GET_STATES,
11678 0,
11679 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11680 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 { WE_GET_CFG,
11682 0,
11683 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11684 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011685#ifdef WLAN_FEATURE_11AC
11686 { WE_GET_RSSI,
11687 0,
11688 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11689 "getRSSI" },
11690#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011691#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011692 { WE_GET_ROAM_RSSI,
11693 0,
11694 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11695 "getRoamRSSI" },
11696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 { WE_GET_WMM_STATUS,
11698 0,
11699 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11700 "getWmmStatus" },
11701 {
11702 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011703 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011704 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11705 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011706#ifdef FEATURE_WLAN_TDLS
11707 {
11708 WE_GET_TDLS_PEERS,
11709 0,
11710 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11711 "getTdlsPeers" },
11712#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011713#ifdef WLAN_FEATURE_11W
11714 {
11715 WE_GET_11W_INFO,
11716 0,
11717 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11718 "getPMFInfo" },
11719#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011720#ifdef WLAN_FEATURE_RMC
11721 {
11722 WE_GET_IBSS_STA_INFO,
11723 0,
11724 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11725 "getIbssSTAs" },
11726#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011727 { WE_GET_SNR,
11728 0,
11729 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11730 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011731#ifdef FEATURE_OEM_DATA_SUPPORT
11732 {
11733 WE_GET_OEM_DATA_CAP,
11734 0,
11735 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11736 "getOemDataCap" },
11737#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 /* handlers for main ioctl */
11739 { WLAN_PRIV_SET_NONE_GET_NONE,
11740 0,
11741 0,
11742 "" },
11743
11744 /* handlers for sub-ioctl */
11745 { WE_CLEAR_STATS,
11746 0,
11747 0,
11748 "clearStats" },
11749 { WE_INIT_AP,
11750 0,
11751 0,
11752 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011753#ifdef WLAN_FEATURE_RMC
11754 {
11755 WE_IBSS_GET_PEER_INFO_ALL,
11756 0,
11757 0,
11758 "ibssPeerInfoAll" },
11759#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 { WE_STOP_AP,
11761 0,
11762 0,
11763 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011764#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 { WE_ENABLE_AMP,
11766 0,
11767 0,
11768 "enableAMP" },
11769 { WE_DISABLE_AMP,
11770 0,
11771 0,
11772 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011773#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011774 { WE_ENABLE_DXE_STALL_DETECT,
11775 0,
11776 0,
11777 "dxeStallDetect" },
11778 { WE_DISPLAY_DXE_SNAP_SHOT,
11779 0,
11780 0,
11781 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011782 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11783 0,
11784 0,
11785 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011786 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011787 WE_SET_REASSOC_TRIGGER,
11788 0,
11789 0,
11790 "reassoc" },
11791 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011792 WE_STOP_OBSS_SCAN,
11793 0,
11794 0,
11795 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011796 {
11797 WE_DUMP_ROAM_TIMER_LOG,
11798 0,
11799 0,
11800 "dumpRoamDelay" },
11801 {
11802 WE_RESET_ROAM_TIMER_LOG,
11803 0,
11804 0,
11805 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011806 {
11807 WE_GET_FW_LOGS,
11808 0,
11809 0,
11810 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011811 {
11812 WE_GET_FW_MEMDUMP,
11813 0,
11814 0,
11815 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 /* handlers for main ioctl */
11817 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11818 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11819 0,
11820 "" },
11821
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011822
11823
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 /* handlers for sub-ioctl */
11825 { WE_LOG_DUMP_CMD,
11826 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11827 0,
11828 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011829#ifdef WLAN_FEATURE_RMC
11830 { WE_IBSS_GET_PEER_INFO,
11831 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11832 0,
11833 "ibssPeerInfo" },
11834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011835
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011836 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011837 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11838 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11839 0,
11840 "setdumplog" },
11841
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011842 { WE_MTRACE_DUMP_CMD,
11843 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11844 0,
11845 "dumplog" },
11846
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011847 /* handlers for sub ioctl */
11848 {
11849 WE_MCC_CONFIG_CREDENTIAL,
11850 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11851 0,
11852 "setMccCrdnl" },
11853
11854 /* handlers for sub ioctl */
11855 {
11856 WE_MCC_CONFIG_PARAMS,
11857 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11858 0,
11859 "setMccConfig" },
11860
Chilam NG571c65a2013-01-19 12:27:36 +053011861#ifdef FEATURE_WLAN_TDLS
11862 /* handlers for sub ioctl */
11863 {
11864 WE_TDLS_CONFIG_PARAMS,
11865 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11866 0,
11867 "setTdlsConfig" },
11868#endif
11869
Katya Nigamf0511f62015-05-05 16:40:57 +053011870 {
11871 WE_CONFIGURE_MONITOR_MODE,
11872 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11873 0,
11874 "MonitorModeConf" },
11875
11876 {
11877 WE_SET_MONITOR_MODE_FILTER,
11878 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11879 0,
11880 "MonitorFilter" },
11881
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 /* handlers for main ioctl */
11883 { WLAN_PRIV_ADD_TSPEC,
11884 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11886 "addTspec" },
11887
11888 /* handlers for main ioctl */
11889 { WLAN_PRIV_DEL_TSPEC,
11890 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11892 "delTspec" },
11893
11894 /* handlers for main ioctl */
11895 { WLAN_PRIV_GET_TSPEC,
11896 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11898 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011899 /* handlers for main ioctl */
11900 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11901 0,
11902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11903 "" },
11904#ifdef WLAN_FEATURE_TSF
11905 { WE_GET_TSF,
11906 0,
11907 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11908 "get_tsf" },
11909#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011910#ifdef FEATURE_OEM_DATA_SUPPORT
11911 /* handlers for main ioctl - OEM DATA */
11912 {
11913 WLAN_PRIV_SET_OEM_DATA_REQ,
11914 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11915 0,
11916 "set_oem_data_req" },
11917
11918 /* handlers for main ioctl - OEM DATA */
11919 {
11920 WLAN_PRIV_GET_OEM_DATA_RSP,
11921 0,
11922 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11923 "get_oem_data_rsp" },
11924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011925
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 /* handlers for main ioctl - host offload */
11927 {
11928 WLAN_PRIV_SET_HOST_OFFLOAD,
11929 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11930 0,
11931 "setHostOffload" },
11932
11933 {
11934 WLAN_GET_WLAN_STATISTICS,
11935 0,
11936 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11937 "getWlanStats" },
11938
11939 {
11940 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011941 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11942 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 0,
11944 "setKeepAlive" },
11945#ifdef WLAN_FEATURE_PACKET_FILTERING
11946 {
11947 WLAN_SET_PACKET_FILTER_PARAMS,
11948 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11949 0,
11950 "setPktFilter" },
11951#endif
11952#ifdef FEATURE_WLAN_SCAN_PNO
11953 {
11954 WLAN_SET_PNO,
11955 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11956 0,
11957 "setpno" },
11958#endif
11959 {
11960 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011961 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 0,
11963 "SETBAND" },
11964 /* handlers for dynamic MC BC ioctl */
11965 {
11966 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011967 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 0,
11969 "setMCBCFilter" },
11970 {
11971 WLAN_PRIV_CLEAR_MCBC_FILTER,
11972 0,
11973 0,
11974 "clearMCBCFilter" },
11975 {
11976 WLAN_SET_POWER_PARAMS,
11977 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11978 0,
11979 "setpowerparams" },
11980 {
11981 WLAN_GET_LINK_SPEED,
11982 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011983 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011984 {
11985 WLAN_PRIV_SET_FTIES,
11986 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11987 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011988};
11989
11990
11991
11992const struct iw_handler_def we_handler_def = {
11993 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11994 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11995 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11996
11997 .standard = (iw_handler *)we_handler,
11998 .private = (iw_handler *)we_private,
11999 .private_args = we_private_args,
12000 .get_wireless_stats = get_wireless_stats,
12001};
12002
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012003const struct iw_handler_def we_mon_handler_def = {
12004 .num_standard = 0,
12005 .num_private = sizeof(we_mon_private) / sizeof(we_mon_private[0]),
12006 .num_private_args =
12007 sizeof(we_mon_private_args) / sizeof(we_mon_private_args[0]),
12008 .standard = NULL,
12009 .private = (iw_handler *)we_mon_private,
12010 .private_args = we_mon_private_args,
12011 .get_wireless_stats = NULL,
12012};
12013
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012014int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
12015{
12016 v_U32_t cmd = 288; //Command to RIVA
12017 hdd_context_t *pHddCtx = NULL;
12018 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12019 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12020 /*
12021 *configMccParam : specify the bit which needs to be modified
12022 *allowed to update based on wlan_qcom_cfg.ini
12023 * configuration
12024 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
12025 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
12026 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
12027 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
12028 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
12029 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
12030 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
12031 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
12032 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
12033 * Bit 9 : Reserved
12034 */
12035 switch (arg1)
12036 {
12037 //Update MCC SCHEDULE_TIME_SLICE parameter
12038 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
12039 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
12040 {
12041 if((arg2 >= 5) && (arg2 <= 20))
12042 {
12043 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12044 }
12045 else
12046 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012047 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012048 return 0;
12049 }
12050 }
12051 break;
12052
12053 //Update MCC MAX_NULL_SEND_TIME parameter
12054 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
12055 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
12056 {
12057 if((arg2 >= 1) && (arg2 <= 10))
12058 {
12059 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12060 }
12061 else
12062 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012063 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012064 return 0;
12065 }
12066 }
12067 break;
12068
12069 //Update MCC TX_EARLY_STOP_TIME parameter
12070 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
12071 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
12072 {
12073 if((arg2 >= 1) && (arg2 <= 10))
12074 {
12075 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12076 }
12077 else
12078 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012079 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012080 return 0;
12081 }
12082 }
12083 break;
12084
12085 //Update MCC RX_DRAIN_TIME parameter
12086 case MCC_RX_DRAIN_TIME_CFG_PARAM :
12087 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
12088 {
12089 if((arg2 >= 1) && (arg2 <= 10))
12090 {
12091 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12092 }
12093 else
12094 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012095 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012096 return 0;
12097 }
12098 }
12099 break;
12100
12101 //Update MCC CHANNEL_SWITCH_TIME parameter
12102 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
12103 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
12104 {
12105 if((arg2 >= 1) && (arg2 <= 20))
12106 {
12107 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12108 }
12109 else
12110 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012111 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012112 return 0;
12113 }
12114 }
12115 break;
12116
12117 //Update MCC MIN_CHANNEL_TIME parameter
12118 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
12119 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
12120 {
12121 if((arg2 >= 5) && (arg2 <= 20))
12122 {
12123 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12124 }
12125 else
12126 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012127 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012128 return 0;
12129 }
12130 }
12131 break;
12132
12133 //Update MCC PARK_BEFORE_TBTT parameter
12134 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
12135 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
12136 {
12137 if((arg2 >= 1) && (arg2 <= 5))
12138 {
12139 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12140 }
12141 else
12142 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012143 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012144 return 0;
12145 }
12146 }
12147 break;
12148
12149 //Update MCC MIN_AFTER_DTIM parameter
12150 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
12151 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
12152 {
12153 if((arg2 >= 5) && (arg2 <= 15))
12154 {
12155 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12156 }
12157 else
12158 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012159 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012160 return 0;
12161 }
12162 }
12163 break;
12164
12165 //Update MCC TOO_CLOSE_MARGIN parameter
12166 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
12167 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
12168 {
12169 if((arg2 >= 1) && (arg2 <= 3))
12170 {
12171 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
12172 }
12173 else
12174 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012175 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012176 return 0;
12177 }
12178 }
12179 break;
12180
12181 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080012182 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080012183 __FUNCTION__,arg1);
12184 break;
12185 }
12186 return 0;
12187}
12188
Jeff Johnson295189b2012-06-20 16:38:30 -070012189int hdd_set_wext(hdd_adapter_t *pAdapter)
12190{
12191 hdd_wext_state_t *pwextBuf;
12192 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012193 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012194
12195 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12196
12197 // Now configure the roaming profile links. To SSID and bssid.
12198 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
12199 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
12200
12201 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
12202 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
12203
12204 /*Set the numOfChannels to zero to scan all the channels*/
12205 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
12206 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
12207
12208 /* Default is no encryption */
12209 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
12210 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
12211
12212 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
12213 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
12214
12215 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
12216
12217 /* Default is no authentication */
12218 pwextBuf->roamProfile.AuthType.numEntries = 1;
12219 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
12220
12221 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
12222 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12223
12224 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070012225 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070012226
12227 hdd_clearRoamProfileIe(pAdapter);
12228
12229 return VOS_STATUS_SUCCESS;
12230
12231 }
12232
12233int hdd_register_wext(struct net_device *dev)
12234 {
12235 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12236 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12237 VOS_STATUS status;
12238
12239 ENTER();
12240
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +053012241 if (pAdapter->device_mode == WLAN_HDD_MONITOR &&
12242 hdd_get_conparam() != VOS_MONITOR_MODE) {
12243 // Register as a wireless device
12244 dev->wireless_handlers = (struct iw_handler_def *)&we_mon_handler_def;
12245 return 0;
12246 }
12247
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 // Zero the memory. This zeros the profile structure.
12249 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
12250
12251 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
12252
12253
12254 status = hdd_set_wext(pAdapter);
12255
12256 if(!VOS_IS_STATUS_SUCCESS(status)) {
12257
Arif Hussain6d2a3322013-11-17 19:50:10 -080012258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 return eHAL_STATUS_FAILURE;
12260 }
12261
12262 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
12263 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012265 return eHAL_STATUS_FAILURE;
12266 }
12267
12268 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
12269 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 return eHAL_STATUS_FAILURE;
12272 }
12273
12274 // Register as a wireless device
12275 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12276
12277 EXIT();
12278 return 0;
12279}
12280
12281int hdd_UnregisterWext(struct net_device *dev)
12282{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070012283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053012284 if (dev != NULL)
12285 {
12286 rtnl_lock();
12287 dev->wireless_handlers = NULL;
12288 rtnl_unlock();
12289 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053012290
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 return 0;
12292}
12293
12294