blob: 2f6b9fdbc0b9b7169dec4382a458645ff0a4ba97 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530176#define WE_SET_PROXIMITY_ENABLE 24
Manjeet Singh3ed79242017-01-11 19:04:32 +0530177#define WE_CAP_TSF 25
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
179/* Private ioctls and their sub-ioctls */
180#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
181#define WE_GET_11D_STATE 1
182#define WE_IBSS_STATUS 2
183#define WE_PMC_STATE 3
184#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700185#define WE_GET_MAX_ASSOC 6
186#define WE_GET_WDI_DBG 7
187#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
188#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530189#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530190#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700191/* Private ioctls and their sub-ioctls */
192#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
193
194/* Private ioctls and their sub-ioctls */
195#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
196#define WE_WOWL_ADD_PTRN 1
197#define WE_WOWL_DEL_PTRN 2
198#if defined WLAN_FEATURE_VOWIFI
199#define WE_NEIGHBOR_REPORT_REQUEST 3
200#endif
201#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
202#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530203#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700204
205/* Private ioctls and their sub-ioctls */
206#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
207#define WE_SET_WLAN_DBG 1
208#define WE_SET_WDI_DBG 2
209#define WE_SET_SAP_CHANNELS 3
210
211/* Private ioctls and their sub-ioctls */
212#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
213#define WE_WLAN_VERSION 1
214#define WE_GET_STATS 2
215#define WE_GET_CFG 3
216#define WE_GET_WMM_STATUS 4
217#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700218#ifdef WLAN_FEATURE_11AC
219#define WE_GET_RSSI 6
220#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800221#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800222#ifdef FEATURE_WLAN_TDLS
223#define WE_GET_TDLS_PEERS 8
224#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700225#ifdef WLAN_FEATURE_11W
226#define WE_GET_11W_INFO 9
227#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530228#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530229#ifdef WLAN_FEATURE_RMC
230#define WE_GET_IBSS_STA_INFO 11
231#endif
232#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530234#ifdef FEATURE_OEM_DATA_SUPPORT
235#define WE_GET_OEM_DATA_CAP 13
236#endif
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238/* Private ioctls and their sub-ioctls */
239#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
240#define WE_CLEAR_STATS 1
241#define WE_INIT_AP 2
242#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530243#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700244#define WE_ENABLE_AMP 4
245#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530246#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700247#define WE_ENABLE_DXE_STALL_DETECT 6
248#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700249#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530250#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530251#ifdef WLAN_FEATURE_RMC
252#define WE_IBSS_GET_PEER_INFO_ALL 10
253#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530254#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530255#define WE_DUMP_ROAM_TIMER_LOG 12
256#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530257#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530258#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530259
Jeff Johnson295189b2012-06-20 16:38:30 -0700260/* Private ioctls and their sub-ioctls */
261#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
262#define WE_LOG_DUMP_CMD 1
263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800265//IOCTL to configure MCC params
266#define WE_MCC_CONFIG_CREDENTIAL 3
267#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700268
Chilam NG571c65a2013-01-19 12:27:36 +0530269#ifdef FEATURE_WLAN_TDLS
270#define WE_TDLS_CONFIG_PARAMS 5
271#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530272#ifdef WLAN_FEATURE_RMC
273#define WE_IBSS_GET_PEER_INFO 6
274#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530275
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700276#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530277#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530278#define WE_CONFIGURE_MONITOR_MODE 10
279#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700280
Chilam Ng01120412013-02-19 18:32:21 -0800281#ifdef FEATURE_WLAN_TDLS
282#undef MAX_VAR_ARGS
283#define MAX_VAR_ARGS 10
284#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700285#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800286#endif
287
Jeff Johnson295189b2012-06-20 16:38:30 -0700288/* Private ioctls (with no sub-ioctls) */
289/* note that they must be odd so that they have "get" semantics */
290#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
291#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
292#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
293
Girish Gowli464c9c82014-06-09 19:47:53 +0530294/* (SIOCIWFIRSTPRIV + 8) is currently unused */
295/* (SIOCIWFIRSTPRIV + 16) is currently unused */
296/* (SIOCIWFIRSTPRIV + 10) is currently unused */
297/* (SIOCIWFIRSTPRIV + 12) is currently unused */
298/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manjeet Singh3ed79242017-01-11 19:04:32 +0530299#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
300#define WE_GET_TSF 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700301
Jeff Johnsone7245742012-09-05 17:12:55 -0700302#ifdef FEATURE_OEM_DATA_SUPPORT
303/* Private ioctls for setting the measurement configuration */
304#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
305#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
306#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700307
308#ifdef WLAN_FEATURE_VOWIFI_11R
309#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
310#endif
311
312/* Private ioctl for setting the host offload feature */
313#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
314
315/* Private ioctl to get the statistics */
316#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
317
318/* Private ioctl to set the Keep Alive Params */
319#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
320#ifdef WLAN_FEATURE_PACKET_FILTERING
321/* Private ioctl to set the Packet Filtering Params */
322#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
323#endif
324
325#ifdef FEATURE_WLAN_SCAN_PNO
326/* Private ioctl to get the statistics */
327#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
328#endif
329
330#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
331
332#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
333#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700334/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700335
Jeff Johnson295189b2012-06-20 16:38:30 -0700336#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
337#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
338
339#define WLAN_STATS_INVALID 0
340#define WLAN_STATS_RETRY_CNT 1
341#define WLAN_STATS_MUL_RETRY_CNT 2
342#define WLAN_STATS_TX_FRM_CNT 3
343#define WLAN_STATS_RX_FRM_CNT 4
344#define WLAN_STATS_FRM_DUP_CNT 5
345#define WLAN_STATS_FAIL_CNT 6
346#define WLAN_STATS_RTS_FAIL_CNT 7
347#define WLAN_STATS_ACK_FAIL_CNT 8
348#define WLAN_STATS_RTS_SUC_CNT 9
349#define WLAN_STATS_RX_DISCARD_CNT 10
350#define WLAN_STATS_RX_ERROR_CNT 11
351#define WLAN_STATS_TX_BYTE_CNT 12
352
353#define WLAN_STATS_RX_BYTE_CNT 13
354#define WLAN_STATS_RX_RATE 14
355#define WLAN_STATS_TX_RATE 15
356
Jeff Johnsone7245742012-09-05 17:12:55 -0700357#define WLAN_STATS_RX_UC_BYTE_CNT 16
358#define WLAN_STATS_RX_MC_BYTE_CNT 17
359#define WLAN_STATS_RX_BC_BYTE_CNT 18
360#define WLAN_STATS_TX_UC_BYTE_CNT 19
361#define WLAN_STATS_TX_MC_BYTE_CNT 20
362#define WLAN_STATS_TX_BC_BYTE_CNT 21
363
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800364#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
365 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
366 { \
367 *__p++ = __type; \
368 *__p++ = __size; \
369 memcpy(__p, __val, __size); \
370 __p += __size; \
371 __tlen += __size + 2; \
372 } \
373 else \
374 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800375 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800376 } \
377 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
379#define VERSION_VALUE_MAX_LEN 32
380
381#define TX_PER_TRACKING_DEFAULT_RATIO 5
382#define TX_PER_TRACKING_MAX_RATIO 10
383#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
384
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530385#define WLAN_ADAPTER 0
386#define P2P_ADAPTER 1
387
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530388#define TX_PWR_MIN 6
389#define TX_PWR_MAX 22
390#define TX_PWR_DEF 50
391
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530392/*
393 * When supplicant sends SETBAND ioctl it queries for channels from
394 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
395 * This is not required if the return type from ioctl is
396 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
397 * event as part of regulatory_hint.
398 */
399enum {
400 SEND_CHANNEL_CHANGE_EVENT = 0,
401 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
402};
403
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800404/*MCC Configuration parameters */
405enum {
406 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
407 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
408 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
409 MCC_RX_DRAIN_TIME_CFG_PARAM,
410 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
411 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
412 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
413 MCC_MIN_AFTER_DTIM_CFG_PARAM,
414 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
415};
416
417int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
418 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
419
Jeff Johnson295189b2012-06-20 16:38:30 -0700420#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530421int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700422#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530423static int get_fwr_memdump(struct net_device *,
424 struct iw_request_info *,
425 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700426/**---------------------------------------------------------------------------
427
Arif Hussain0273cba2014-01-07 20:58:29 -0800428 \brief mem_alloc_copy_from_user_helper -
429
430 Helper function to allocate buffer and copy user data.
431
432 \param - wrqu - Pointer to IOCTL Data.
433 len - size
434
435 \return - On Success pointer to buffer, On failure NULL
436
437 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530438void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800439{
440 u8 *ptr = NULL;
441
442 /* in order to protect the code, an extra byte is post appended to the buffer
443 * and the null termination is added. However, when allocating (len+1) byte
444 * of memory, we need to make sure that there is no uint overflow when doing
445 * addition. In theory check len < UINT_MAX protects the uint overflow. For
446 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
447 * guess, now, it is assumed that the private command buffer size is no
448 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
449 */
450 if (len > MAX_USER_COMMAND_SIZE)
451 {
452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
453 "Invalid length");
454 return NULL;
455 }
456
457 ptr = kmalloc(len + 1, GFP_KERNEL);
458 if (NULL == ptr)
459 {
460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
461 "unable to allocate memory");
462 return NULL;
463 }
464
465 if (copy_from_user(ptr, wrqu_data, len))
466 {
467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
468 "%s: failed to copy data to user buffer", __func__);
469 kfree(ptr);
470 return NULL;
471 }
472 ptr[len] = '\0';
473 return ptr;
474}
475
Girish Gowli488ef492014-06-12 18:44:33 +0530476// Function to handle and get compatible struct iw_point passed to ioctl.
477int hdd_priv_get_data(struct iw_point *p_priv_data,
478 union iwreq_data *wrqu)
479{
480 if ((NULL == p_priv_data) || (NULL == wrqu))
481 {
482 return -EINVAL;
483 }
484
485#ifdef CONFIG_COMPAT
486 if (is_compat_task())
487 {
488 struct compat_iw_point *p_compat_priv_data;
489
490 // Compat task: typecast to campat structure and copy the members.
491 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
492
493 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
494 p_priv_data->length = p_compat_priv_data->length;
495 p_priv_data->flags = p_compat_priv_data->flags;
496 }//if(is_compat_task())
497 else
498 {
499#endif //#ifdef CONFIG_COMPAT
500
501 // Non compat task: directly copy the structure.
502 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
503
504#ifdef CONFIG_COMPAT
505 }//else of - if(is_compat_task())
506#endif //#ifdef CONFIG_COMPAT
507
508 return 0;
509}
510
Arif Hussain0273cba2014-01-07 20:58:29 -0800511/**---------------------------------------------------------------------------
512
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 \brief hdd_wlan_get_version() -
514
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800515 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700516
517 \param - pAdapter Pointer to the adapter.
518 wrqu - Pointer to IOCTL REQUEST Data.
519 extra - Pointer to char
520
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800521 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800524void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
525 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700526{
527 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800528 tSirVersionString wcnss_SW_version;
529 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530530 tSirVersionString iris_name;
531 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800532 char *pSWversion;
533 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700535
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800536 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
537 sizeof(wcnss_SW_version));
538 if (VOS_IS_STATUS_SUCCESS(status))
539 {
540 pSWversion = wcnss_SW_version;
541 }
542 else
543 {
544 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 }
546
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800547 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
548 sizeof(wcnss_HW_version));
549 if (VOS_IS_STATUS_SUCCESS(status))
550 {
551 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800553 else
554 {
555 pHWversion = "Unknown";
556 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530558 status = wcnss_get_iris_name(iris_name);
559
560 if (!status) {
561 pIRISversion = iris_name;
562 } else {
563 pIRISversion = "Unknown";
564 }
565
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700566 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530567 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800568 QWLAN_VERSIONSTR,
569 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530570 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800571
572 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700573}
574
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530575#ifdef WLAN_FEATURE_RMC
576void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
577{
578 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
579 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
580 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
581 v_U8_t i;
582
583 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
584 {
585 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
586 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
587 for (i = 0; i < pPeerInfo->numPeers; i++)
588 {
589 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
590 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
591 }
592 }
593 else
594 {
595 hddLog(LOGE,
596 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
597 }
598
599 complete(&pAdapter->ibss_peer_info_comp);
600}
601
602v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
603{
604 v_U8_t idx;
605 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
606
607 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
608 {
609 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
610 staIdx == pHddStaCtx->conn_info.staId[ idx ])
611 {
612 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
613 }
614 }
615 return NULL;
616}
617
618eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
619{
620 eHalStatus status = eHAL_STATUS_FAILURE;
621 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
622 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
623 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
624
625 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
626 VOS_FALSE, staIdx);
627
628 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
629
630 if (eHAL_STATUS_SUCCESS == status)
631 {
632 long ret;
633 ret = wait_for_completion_interruptible_timeout
634 (&pAdapter->ibss_peer_info_comp,
635 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
636 if (ret <= 0)
637 {
638 hddLog(VOS_TRACE_LEVEL_ERROR,
639 FL("failed wait on ibss_peer_info_comp %ld"), ret);
640 return eHAL_STATUS_FAILURE;
641 }
642
643 /** Print the peer info */
644 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
645 pr_info("============================================================");
646 {
647 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
648 staIdx);
649 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
650
651 if (NULL != macAddr)
652 {
653 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
654 MAC_ADDR_ARRAY(macAddr->bytes),
655 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
656 }
657 else
658 {
659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
660 " ERROR: PEER MAC ADDRESS NOT FOUND ");
661 }
662 }
663 }
664 else
665 {
666 hddLog(VOS_TRACE_LEVEL_WARN,
667 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
668 }
669
670 return status;
671}
672
673eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
674{
675 eHalStatus status = eHAL_STATUS_FAILURE;
676 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
677 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
678 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
679 int i;
680
681 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
682 VOS_TRUE, 0xFF);
683 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
684
685 if (eHAL_STATUS_SUCCESS == status)
686 {
687 long ret;
688 ret = wait_for_completion_interruptible_timeout
689 (&pAdapter->ibss_peer_info_comp,
690 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
691 if (ret <= 0)
692 {
693 hddLog(VOS_TRACE_LEVEL_ERROR,
694 FL("failed wait on ibss_peer_info_comp %ld"), ret);
695 return eHAL_STATUS_FAILURE;
696 }
697
698 /** Print the peer info */
699 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
700 pr_info("============================================================");
701 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
702 {
703 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
704 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
705 staIdx);
706 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
707
708 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
709 if (NULL != macAddr)
710 {
711 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
712 MAC_ADDR_ARRAY(macAddr->bytes),
713 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
714 }
715 else
716 {
717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
718 " ERROR: PEER MAC ADDRESS NOT FOUND ");
719 }
720 }
721 }
722 else
723 {
724 hddLog(VOS_TRACE_LEVEL_WARN,
725 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
726 }
727
728 return status;
729}
730#endif /* WLAN_FEATURE_RMC */
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
733{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530734 tHalHandle hHal;
735 hdd_context_t *pHddCtx;
736 v_U32_t threshold = 0;
737 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700738
739 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530740 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530741 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
743 "%s: Adapter is NULL",__func__);
744 return -EINVAL;
745 }
746
747 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
748 ret = wlan_hdd_validate_context(pHddCtx);
749 if (0 != ret)
750 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530751 return ret;
752 }
753
754 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
755 if (NULL == hHal)
756 {
757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
758 "%s: Hal Context is NULL",__func__);
759 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 }
761
762 if ( eHAL_STATUS_SUCCESS !=
763 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
764 {
c_hpothub8245442013-11-20 23:41:09 +0530765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
766 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return -EIO;
768 }
769 wrqu->rts.value = threshold;
770
771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800772 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700773
774 EXIT();
775
776 return 0;
777}
778
779int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
780{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530781 tHalHandle hHal;
782 hdd_context_t *pHddCtx;
783 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700784
785 ENTER();
786
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530787 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530788 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
790 "%s: Adapter is NULL",__func__);
791 return -EINVAL;
792 }
793
794 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
795 status = wlan_hdd_validate_context(pHddCtx);
796 if (0 != status)
797 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530798 return status;
799 }
800
801 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
802 if (NULL == hHal)
803 {
804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
805 "%s: Hal Context is NULL",__func__);
806 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 }
808
809 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
810 != eHAL_STATUS_SUCCESS )
811 {
c_hpothub8245442013-11-20 23:41:09 +0530812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
813 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 return -EIO;
815 }
816 wrqu->frag.value = threshold;
817
818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800819 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700820
821 EXIT();
822
823 return 0;
824}
825
826int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
827{
Jeff Johnsone7245742012-09-05 17:12:55 -0700828 int i;
829 if (channel > 0)
830 {
831 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
832 {
833 if (channel == freq_chan_map[i].chan)
834 {
835 *pfreq = freq_chan_map[i].freq;
836 return 1;
837 }
838 }
839 }
840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800841 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700842 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700843}
844
845static v_BOOL_t
846hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
847{
848 v_BOOL_t rsnType = VOS_FALSE;
849 // is the authType supported?
850 switch (authType)
851 {
852 case eCSR_AUTH_TYPE_NONE: //never used
853 rsnType = eANI_BOOLEAN_FALSE;
854 break;
855 // MAC layer authentication types
856 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
857 rsnType = eANI_BOOLEAN_FALSE;
858 break;
859 case eCSR_AUTH_TYPE_SHARED_KEY:
860 rsnType = eANI_BOOLEAN_FALSE;
861 break;
862 case eCSR_AUTH_TYPE_AUTOSWITCH:
863 rsnType = eANI_BOOLEAN_FALSE;
864 break;
865
866 // Upper layer authentication types
867 case eCSR_AUTH_TYPE_WPA:
868 rsnType = eANI_BOOLEAN_TRUE;
869 break;
870 case eCSR_AUTH_TYPE_WPA_PSK:
871 rsnType = eANI_BOOLEAN_TRUE;
872 break;
873 case eCSR_AUTH_TYPE_WPA_NONE:
874 rsnType = eANI_BOOLEAN_TRUE;
875 break;
876#ifdef WLAN_FEATURE_VOWIFI_11R
877 case eCSR_AUTH_TYPE_FT_RSN:
878#endif
879 case eCSR_AUTH_TYPE_RSN:
880 rsnType = eANI_BOOLEAN_TRUE;
881 break;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 case eCSR_AUTH_TYPE_FT_RSN_PSK:
884#endif
885 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700886#ifdef WLAN_FEATURE_11W
887 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530888 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700889#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 rsnType = eANI_BOOLEAN_TRUE;
891 break;
892 //case eCSR_AUTH_TYPE_FAILED:
893 case eCSR_AUTH_TYPE_UNKNOWN:
894 rsnType = eANI_BOOLEAN_FALSE;
895 break;
896 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800897 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
898 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 rsnType = eANI_BOOLEAN_FALSE;
900 break;
901 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800902 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700903 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return rsnType;
905}
906
907static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
908{
909 struct statsContext *pStatsContext;
910 hdd_adapter_t *pAdapter;
911
912 if (ioctl_debug)
913 {
914 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700915 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
917
918 if (NULL == pContext)
919 {
920 hddLog(VOS_TRACE_LEVEL_ERROR,
921 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700922 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 return;
924 }
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 pStatsContext = pContext;
927 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800928
929 /* there is a race condition that exists between this callback
930 function and the caller since the caller could time out either
931 before or while this code is executing. we use a spinlock to
932 serialize these actions */
933 spin_lock(&hdd_context_lock);
934
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
936 {
937 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800938 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 hddLog(VOS_TRACE_LEVEL_WARN,
940 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700941 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 if (ioctl_debug)
943 {
944 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700945 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 }
947 return;
948 }
949
Jeff Johnson72a40512013-12-19 10:14:15 -0800950 /* context is valid so caller is still waiting */
951
952 /* paranoia: invalidate the magic */
953 pStatsContext->magic = 0;
954
Sachin Ahujaa082b672015-10-05 19:51:31 +0530955 /* copy over the rssi.FW will return RSSI as -100
956 * if there are no samples to calculate the average
957 * RSSI
958 */
959 if (rssi != -100)
960 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530961 if (pAdapter->rssi > 0)
962 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800963 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800965
966 /* serialization is complete */
967 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700968}
969
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530970static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
971{
972 struct statsContext *pStatsContext;
973 hdd_adapter_t *pAdapter;
974
975 if (ioctl_debug)
976 {
977 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
978 __func__, (int)snr, (int)staId, pContext);
979 }
980
981 if (NULL == pContext)
982 {
983 hddLog(VOS_TRACE_LEVEL_ERROR,
984 "%s: Bad param, pContext [%p]",
985 __func__, pContext);
986 return;
987 }
988
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530989 pStatsContext = pContext;
990 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800991
992 /* there is a race condition that exists between this callback
993 function and the caller since the caller could time out either
994 before or while this code is executing. we use a spinlock to
995 serialize these actions */
996 spin_lock(&hdd_context_lock);
997
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530998 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
999 {
1000 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001001 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301002 hddLog(VOS_TRACE_LEVEL_WARN,
1003 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1004 __func__, pAdapter, pStatsContext->magic);
1005 if (ioctl_debug)
1006 {
1007 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1008 __func__, pAdapter, pStatsContext->magic);
1009 }
1010 return;
1011 }
1012
Jeff Johnson72a40512013-12-19 10:14:15 -08001013 /* context is valid so caller is still waiting */
1014
1015 /* paranoia: invalidate the magic */
1016 pStatsContext->magic = 0;
1017
1018 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301019 pAdapter->snr = snr;
1020
Jeff Johnson72a40512013-12-19 10:14:15 -08001021 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301022 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001023
1024 /* serialization is complete */
1025 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301026}
1027
Jeff Johnson295189b2012-06-20 16:38:30 -07001028VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1029{
1030 struct statsContext context;
1031 hdd_context_t *pHddCtx;
1032 hdd_station_ctx_t *pHddStaCtx;
1033 eHalStatus hstatus;
1034 long lrc;
1035
1036 if (NULL == pAdapter)
1037 {
1038 hddLog(VOS_TRACE_LEVEL_WARN,
1039 "%s: Invalid context, pAdapter", __func__);
1040 return VOS_STATUS_E_FAULT;
1041 }
1042 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1043 {
1044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1045 /* return a cached value */
1046 *rssi_value = pAdapter->rssi;
1047 return VOS_STATUS_SUCCESS;
1048 }
1049
1050 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1051 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1052
mukul sharma8aec69b2015-06-10 22:28:43 +05301053 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1054 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1056 __func__, pAdapter->rssi_on_disconnect);
1057 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301058 return VOS_STATUS_SUCCESS;
1059 }
1060
1061 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1062 {
1063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1064 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1065 *rssi_value = pAdapter->rssi;
1066 return VOS_STATUS_SUCCESS;
1067 }
1068
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 init_completion(&context.completion);
1070 context.pAdapter = pAdapter;
1071 context.magic = RSSI_CONTEXT_MAGIC;
1072
1073 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
1074 pHddStaCtx->conn_info.staId[ 0 ],
1075 pHddStaCtx->conn_info.bssId,
1076 &context, pHddCtx->pvosContext);
1077 if (eHAL_STATUS_SUCCESS != hstatus)
1078 {
1079 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001080 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 /* we'll returned a cached value below */
1082 }
1083 else
1084 {
1085 /* request was sent -- wait for the response */
1086 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1087 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 if (lrc <= 0)
1089 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001091 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 /* we'll now returned a cached value below */
1093 }
1094 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001095
1096 /* either we never sent a request, we sent a request and received a
1097 response or we sent a request and timed out. if we never sent a
1098 request or if we sent a request and got a response, we want to
1099 clear the magic out of paranoia. if we timed out there is a
1100 race condition such that the callback function could be
1101 executing at the same time we are. of primary concern is if the
1102 callback function had already verified the "magic" but had not
1103 yet set the completion variable when a timeout occurred. we
1104 serialize these activities by invalidating the magic while
1105 holding a shared spinlock which will cause us to block if the
1106 callback is currently executing */
1107 spin_lock(&hdd_context_lock);
1108 context.magic = 0;
1109 spin_unlock(&hdd_context_lock);
1110
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 *rssi_value = pAdapter->rssi;
1112
1113 return VOS_STATUS_SUCCESS;
1114}
Siddharth Bhal64246172015-02-27 01:04:37 +05301115/**---------------------------------------------------------------------------
1116
1117 \brief wlan_hdd_get_frame_logs() -
1118
1119 This function use to get Frames log.
1120
1121 \param - pAdapter Pointer to the adapter.
1122 flag - Specify type of request. Clear and Send request are
1123 supported.
1124
1125 \return - none
1126
1127 --------------------------------------------------------------------------*/
1128VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1129{
Siddharth Bhal64246172015-02-27 01:04:37 +05301130 hdd_context_t *pHddCtx;
1131 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301132
1133 if (NULL == pAdapter)
1134 {
1135 hddLog(VOS_TRACE_LEVEL_WARN,
1136 "%s: Invalid context, pAdapter", __func__);
1137 return VOS_STATUS_E_FAULT;
1138 }
1139
1140 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1141 if (!pHddCtx->mgmt_frame_logging)
1142 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301143 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301144 return VOS_STATUS_E_AGAIN;
1145 }
1146
Siddharth Bhal4507c262015-04-29 20:20:42 +05301147 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1148 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1149 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301150 {
1151 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1152 return VOS_STATUS_E_INVAL;
1153 }
1154
Siddharth Bhal4507c262015-04-29 20:20:42 +05301155 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1156 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1157 {
1158 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1159 return VOS_STATUS_E_INVAL;
1160 }
1161
Abhishek Singh611295e2015-07-09 11:11:54 +05301162 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301163 if (eHAL_STATUS_SUCCESS != hstatus)
1164 {
1165 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301166 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301167 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301168
1169 return VOS_STATUS_SUCCESS;
1170}
1171
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301172
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301173VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1174{
1175 struct statsContext context;
1176 hdd_context_t *pHddCtx;
1177 hdd_station_ctx_t *pHddStaCtx;
1178 eHalStatus hstatus;
1179 long lrc;
1180 int valid;
1181
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301182 ENTER();
1183
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301184 if (NULL == pAdapter)
1185 {
1186 hddLog(VOS_TRACE_LEVEL_ERROR,
1187 "%s: Invalid context, pAdapter", __func__);
1188 return VOS_STATUS_E_FAULT;
1189 }
1190
1191 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1192
1193 valid = wlan_hdd_validate_context(pHddCtx);
1194 if (0 != valid)
1195 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301196 return VOS_STATUS_E_FAULT;
1197 }
1198
1199 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1200 if (NULL == pHddStaCtx)
1201 {
1202 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1203 return VOS_STATUS_E_FAULT;
1204 }
1205
1206 init_completion(&context.completion);
1207 context.pAdapter = pAdapter;
1208 context.magic = SNR_CONTEXT_MAGIC;
1209
1210 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1211 pHddStaCtx->conn_info.staId[ 0 ],
1212 pHddStaCtx->conn_info.bssId,
1213 &context);
1214 if (eHAL_STATUS_SUCCESS != hstatus)
1215 {
1216 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1217 __func__);
1218 /* we'll returned a cached value below */
1219 }
1220 else
1221 {
1222 /* request was sent -- wait for the response */
1223 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1224 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301225 if (lrc <= 0)
1226 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301228 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301229 /* we'll now returned a cached value below */
1230 }
1231 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001232
1233 /* either we never sent a request, we sent a request and received a
1234 response or we sent a request and timed out. if we never sent a
1235 request or if we sent a request and got a response, we want to
1236 clear the magic out of paranoia. if we timed out there is a
1237 race condition such that the callback function could be
1238 executing at the same time we are. of primary concern is if the
1239 callback function had already verified the "magic" but had not
1240 yet set the completion variable when a timeout occurred. we
1241 serialize these activities by invalidating the magic while
1242 holding a shared spinlock which will cause us to block if the
1243 callback is currently executing */
1244 spin_lock(&hdd_context_lock);
1245 context.magic = 0;
1246 spin_unlock(&hdd_context_lock);
1247
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301248 *snr = pAdapter->snr;
1249
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301250 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301251 return VOS_STATUS_SUCCESS;
1252}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301253
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001254#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001255
1256static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1257{
1258 struct statsContext *pStatsContext;
1259 hdd_adapter_t *pAdapter;
1260 if (ioctl_debug)
1261 {
1262 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1263 __func__, (int)rssi, (int)staId, pContext);
1264 }
1265
1266 if (NULL == pContext)
1267 {
1268 hddLog(VOS_TRACE_LEVEL_ERROR,
1269 "%s: Bad param, pContext [%p]",
1270 __func__, pContext);
1271 return;
1272 }
1273
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001274 pStatsContext = pContext;
1275 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001276
1277 /* there is a race condition that exists between this callback
1278 function and the caller since the caller could time out either
1279 before or while this code is executing. we use a spinlock to
1280 serialize these actions */
1281 spin_lock(&hdd_context_lock);
1282
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001283 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1284 {
1285 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001286 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001287 hddLog(VOS_TRACE_LEVEL_WARN,
1288 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1289 __func__, pAdapter, pStatsContext->magic);
1290 if (ioctl_debug)
1291 {
1292 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1293 __func__, pAdapter, pStatsContext->magic);
1294 }
1295 return;
1296 }
1297
Jeff Johnson72a40512013-12-19 10:14:15 -08001298 /* context is valid so caller is still waiting */
1299
1300 /* paranoia: invalidate the magic */
1301 pStatsContext->magic = 0;
1302
Sachin Ahujaa082b672015-10-05 19:51:31 +05301303 /* copy over the rssi.FW will return RSSI as -100
1304 * if there are no samples to calculate the average
1305 * RSSI
1306 */
1307 if (rssi != -100)
1308 pAdapter->rssi = rssi;
1309
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301310 if (pAdapter->rssi > 0)
1311 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001312 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001313 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001314
1315 /* serialization is complete */
1316 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001317}
1318
1319
1320
1321VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1322{
1323 struct statsContext context;
1324 hdd_context_t *pHddCtx = NULL;
1325 hdd_station_ctx_t *pHddStaCtx = NULL;
1326 eHalStatus hstatus;
1327 long lrc;
1328
1329 if (NULL == pAdapter)
1330 {
1331 hddLog(VOS_TRACE_LEVEL_WARN,
1332 "%s: Invalid context, pAdapter", __func__);
1333 return VOS_STATUS_E_FAULT;
1334 }
1335 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1336 {
1337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1338 /* return a cached value */
1339 *rssi_value = pAdapter->rssi;
1340 return VOS_STATUS_SUCCESS;
1341 }
1342
1343 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1344 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1345
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301346 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001347 {
1348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1349 /* return a cached value */
1350 *rssi_value = 0;
1351 return VOS_STATUS_SUCCESS;
1352 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301353
1354 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1355 {
1356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1357 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1358 *rssi_value = pAdapter->rssi;
1359 return VOS_STATUS_SUCCESS;
1360 }
1361
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001362 init_completion(&context.completion);
1363 context.pAdapter = pAdapter;
1364 context.magic = RSSI_CONTEXT_MAGIC;
1365
1366 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1367 pHddStaCtx->conn_info.staId[ 0 ],
1368 pHddStaCtx->conn_info.bssId,
1369 &context, pHddCtx->pvosContext);
1370 if (eHAL_STATUS_SUCCESS != hstatus)
1371 {
1372 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1373 __func__);
1374 /* we'll returned a cached value below */
1375 }
1376 else
1377 {
1378 /* request was sent -- wait for the response */
1379 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1380 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001381 if (lrc <= 0)
1382 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001383 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001384 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001385 /* we'll now returned a cached value below */
1386 }
1387 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001388
1389 /* either we never sent a request, we sent a request and received a
1390 response or we sent a request and timed out. if we never sent a
1391 request or if we sent a request and got a response, we want to
1392 clear the magic out of paranoia. if we timed out there is a
1393 race condition such that the callback function could be
1394 executing at the same time we are. of primary concern is if the
1395 callback function had already verified the "magic" but had not
1396 yet set the completion variable when a timeout occurred. we
1397 serialize these activities by invalidating the magic while
1398 holding a shared spinlock which will cause us to block if the
1399 callback is currently executing */
1400 spin_lock(&hdd_context_lock);
1401 context.magic = 0;
1402 spin_unlock(&hdd_context_lock);
1403
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001404 *rssi_value = pAdapter->rssi;
1405
1406 return VOS_STATUS_SUCCESS;
1407}
1408#endif
1409
1410
Jeff Johnson295189b2012-06-20 16:38:30 -07001411void hdd_StatisticsCB( void *pStats, void *pContext )
1412{
1413 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1414 hdd_stats_t *pStatsCache = NULL;
1415 hdd_wext_state_t *pWextState;
1416 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1417
1418 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1419 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1420 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1421 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1422 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1423 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1424
1425 if (pAdapter!= NULL)
1426 pStatsCache = &pAdapter->hdd_stats;
1427
1428
1429 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1430 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1431 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1432 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1433 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1434 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1435
1436 if (pStatsCache!=NULL)
1437 {
1438 // and copy the stats into the cache we keep in the adapter instance structure
1439 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1440 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1441 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1442 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1443 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1444 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1445 }
1446
1447 if(pAdapter)
1448 {
1449 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1450 if(pWextState)
1451 {
1452 vos_status = vos_event_set(&pWextState->vosevent);
1453 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1454 {
1455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001456 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 return;
1458 }
1459 }
1460 }
1461}
1462
1463void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1464{
1465 v_CONTEXT_t pVosContext;
1466 hdd_context_t *pHddCtx;
1467 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1468#if 0
1469 hdd_wext_state_t *pWextState;
1470 v_U32_t roamId;
1471#endif
1472
1473 ENTER();
1474
1475 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1476
1477 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1478 if (NULL == pHddCtx)
1479 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001480 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 return;
1482 }
1483#if 0
1484 pWextState = pAdapter->pWextState;
1485#endif
1486
1487 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1488 {
1489 //TODO Verify is this is really used. If yes need to fix it.
1490 hdd_reconnect_all_adapters( pHddCtx );
1491#if 0
1492 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1493 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1494 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1495
1496 if(VOS_STATUS_SUCCESS == vosStatus)
1497 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1498 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1499
1500 sme_RoamConnect(halHandle,
1501 pAdapter->sessionId, &(pWextState->roamProfile),
1502 &roamId);
1503#endif
1504 }
1505
1506 EXIT();
1507
1508}
1509
1510void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1511{
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1513
1514 /* clear WPA/RSN/WSC IE information in the profile */
1515 pWextState->roamProfile.nWPAReqIELength = 0;
1516 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1517 pWextState->roamProfile.nRSNReqIELength = 0;
1518 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1519
Chet Lanctot186b5732013-03-18 10:26:30 -07001520#ifdef FEATURE_WLAN_WAPI
1521 pWextState->roamProfile.nWAPIReqIELength = 0;
1522 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1523#endif
1524
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001526 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301528 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1530 pWextState->roamProfile.nAddIEAssocLength = 0;
1531
1532 pWextState->roamProfile.EncryptionType.numEntries = 1;
1533 pWextState->roamProfile.EncryptionType.encryptionType[0]
1534 = eCSR_ENCRYPT_TYPE_NONE;
1535
1536 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1537 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1538 = eCSR_ENCRYPT_TYPE_NONE;
1539
1540 pWextState->roamProfile.AuthType.numEntries = 1;
1541 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1542
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301543 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001544#ifdef WLAN_FEATURE_11W
1545 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1546 pWextState->roamProfile.MFPRequired = 0;
1547 pWextState->roamProfile.MFPCapable = 0;
1548#endif
1549
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 pWextState->authKeyMgmt = 0;
1551
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301552 vos_mem_zero(&pWextState->roamProfile.Keys,
1553 sizeof(pWextState->roamProfile.Keys));
1554
Jeff Johnson295189b2012-06-20 16:38:30 -07001555#ifdef FEATURE_WLAN_WAPI
1556 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1557 pAdapter->wapi_info.nWapiMode = 0;
1558#endif
1559
1560 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1561
1562}
1563
1564void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1565{
1566 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001567
Nirav Shahf6bd2672015-03-11 12:53:15 +05301568 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001569 {
1570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301571 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001572 }
1573 else
1574 {
1575 complete(&pAdapter->ula_complete);
1576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001577}
1578
1579VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1580{
1581 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001583 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584
1585 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1586 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001587 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001588
1589 /*To avoid race condition between the set key and the last EAPOL
1590 packet, notify TL to finish upper layer authentication incase if the
1591 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001592 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001593
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001594 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 {
1596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1597 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1598 __LINE__, vos_status );
1599 return vos_status;
1600
1601 }
1602
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001603 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301605 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001606 {
1607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301608 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001609 /* we'll still fall through and return success since the
1610 * connection may still get established but is just taking
1611 * too long for us to wait */
1612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 }
1614 return VOS_STATUS_SUCCESS;
1615}
1616
1617v_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)
1618{
1619
1620 int left = ie_len;
1621 v_U8_t *ptr = ie;
1622 v_U8_t elem_id,elem_len;
1623 v_U8_t eid = 0xDD;
1624
1625 if ( NULL == ie || 0 == ie_len )
1626 return NULL;
1627
1628 while(left >= 2)
1629 {
1630 elem_id = ptr[0];
1631 elem_len = ptr[1];
1632 left -= 2;
1633 if(elem_len > left)
1634 {
1635 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001636 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 eid,elem_len,left);
1638 return NULL;
1639 }
1640 if (elem_id == eid)
1641 {
1642 if(memcmp( &ptr[2], oui, oui_size)==0)
1643 return ptr;
1644 }
1645
1646 left -= elem_len;
1647 ptr += (elem_len + 2);
1648 }
1649 return NULL;
1650}
1651
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301652static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 union iwreq_data *wrqu, char *extra)
1654{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301655 hdd_adapter_t *pAdapter;
1656 hdd_context_t *pHddCtx;
1657 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301658
1659 ENTER();
1660
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301661 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1662 if (NULL == pAdapter)
1663 {
1664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1665 "%s: pAdapter is NULL\n", __func__);
1666 return -EINVAL;
1667 }
1668 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1669 ret = wlan_hdd_validate_context(pHddCtx);
1670 if (0 != ret)
1671 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301672 return ret;
1673 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301674
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301676
1677 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301678 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001679}
1680
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301681static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1682 union iwreq_data *wrqu, char *extra)
1683{
1684 int ret;
1685
1686 vos_ssr_protect(__func__);
1687 ret = __iw_set_commit(dev, info, wrqu, extra);
1688 vos_ssr_unprotect(__func__);
1689
1690 return ret;
1691}
1692
1693static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 struct iw_request_info *info,
1695 char *wrqu, char *extra)
1696{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301697 hdd_adapter_t *pAdapter;
1698 hdd_context_t *pHddCtx;
1699 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301700
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301702 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1703 if (NULL == pAdapter)
1704 {
1705 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1706 "%s: pAdapter is NULL\n", __func__);
1707 return -EINVAL;
1708 }
1709 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1710 ret = wlan_hdd_validate_context(pHddCtx);
1711 if (0 != ret)
1712 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301713 return ret;
1714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1716 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301717 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718}
1719
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301720static int iw_get_name(struct net_device *dev,
1721 struct iw_request_info *info,
1722 char *wrqu, char *extra)
1723{
1724 int ret;
1725
1726 vos_ssr_protect(__func__);
1727 ret = __iw_get_name(dev, info, wrqu, extra);
1728 vos_ssr_unprotect(__func__);
1729
1730 return ret;
1731}
1732
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301733static int __iw_set_mode(struct net_device *dev,
1734 struct iw_request_info *info,
1735 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001736{
1737 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301738 hdd_adapter_t *pAdapter;
1739 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 tCsrRoamProfile *pRoamProfile;
1741 eCsrRoamBssType LastBSSType;
1742 eMib_dot11DesiredBssType connectedBssType;
1743 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301745 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001746
1747 ENTER();
1748
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301749 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 if (NULL == pAdapter)
1751 {
1752 hddLog(VOS_TRACE_LEVEL_WARN,
1753 "%s: Invalid context, pAdapter", __func__);
1754 return 0;
1755 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301756 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1757 status = wlan_hdd_validate_context(pHddCtx);
1758 if (0 != status)
1759 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301760 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 }
1762
1763 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1764 if (pWextState == NULL)
1765 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301766 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 return -EINVAL;
1768 }
1769
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 pRoamProfile = &pWextState->roamProfile;
1772 LastBSSType = pRoamProfile->BSSType;
1773
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301774 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001775
1776 switch (wrqu->mode)
1777 {
1778 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301779 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1781 // Set the phymode correctly for IBSS.
1782 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1783 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001784 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 break;
1787 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301788 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 break;
1792 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301793 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1795 break;
1796 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301797 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 return -EOPNOTSUPP;
1799 }
1800
1801 if ( LastBSSType != pRoamProfile->BSSType )
1802 {
1803 //the BSS mode changed
1804 // We need to issue disconnect if connected or in IBSS disconnect state
1805 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1806 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1807 {
1808 VOS_STATUS vosStatus;
1809 // need to issue a disconnect to CSR.
1810 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1811 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1812 pAdapter->sessionId,
1813 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1814 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301815 {
1816 long ret;
1817 ret = wait_for_completion_interruptible_timeout(
1818 &pAdapter->disconnect_comp_var,
1819 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1820 if (ret <= 0)
1821 hddLog(VOS_TRACE_LEVEL_ERROR,
1822 FL("failed wait on disconnect_comp_var %ld"), ret);
1823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 }
1825 }
1826
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 EXIT();
1828 return 0;
1829}
1830
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301831static int iw_set_mode(struct net_device *dev,
1832 struct iw_request_info *info,
1833 union iwreq_data *wrqu, char *extra)
1834{
1835 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001836
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301837 vos_ssr_protect(__func__);
1838 ret = __iw_set_mode(dev, info, wrqu, extra);
1839 vos_ssr_unprotect(__func__);
1840
1841 return ret;
1842}
1843
1844static int __iw_get_mode(struct net_device *dev,
1845 struct iw_request_info *info,
1846 union iwreq_data *wrqu,
1847 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001848{
1849
1850 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301851 hdd_adapter_t *pAdapter;
1852 hdd_context_t *pHddCtx;
1853 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001854
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301855 ENTER();
1856
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301857 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 if (NULL == pAdapter)
1859 {
1860 hddLog(VOS_TRACE_LEVEL_WARN,
1861 "%s: Invalid context, pAdapter", __func__);
1862 return 0;
1863 }
1864
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1866 ret = wlan_hdd_validate_context(pHddCtx);
1867 if (0 != ret)
1868 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301869 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1872 if (pWextState == NULL)
1873 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301874 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 return -EINVAL;
1876 }
1877
1878 switch (pWextState->roamProfile.BSSType)
1879 {
1880 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001881 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301882 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 break;
1884 case eCSR_BSS_TYPE_IBSS:
1885 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001886 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301887 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 break;
1889 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001890 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301891 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 break;
1893 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001894 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 break;
1896 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301897
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301898 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 return 0;
1900}
1901
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301902static int iw_get_mode(struct net_device *dev,
1903 struct iw_request_info *info,
1904 union iwreq_data *wrqu,
1905 char *extra)
1906{
1907 int ret;
1908
1909 vos_ssr_protect(__func__);
1910 ret = __iw_get_mode(dev, info, wrqu, extra);
1911 vos_ssr_unprotect(__func__);
1912
1913 return ret;
1914}
1915
1916static int __iw_set_freq(struct net_device *dev,
1917 struct iw_request_info *info,
1918 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001919{
1920 v_U32_t numChans = 0;
1921 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1922 v_U32_t indx = 0;
1923 v_U32_t status = 0;
1924
1925 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301926 hdd_adapter_t *pAdapter;
1927 hdd_context_t *pHddCtx;
1928 tHalHandle hHal;
1929 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301931
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 ENTER();
1933
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301934 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1935 if (NULL == pAdapter)
1936 {
1937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1938 "%s:Invalid Adapter",__func__);
1939 return -EINVAL;
1940 }
1941
1942 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1943 status = wlan_hdd_validate_context(pHddCtx);
1944 if (0 != status)
1945 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return status;
1947 }
1948
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301949 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1950 if (NULL == hHal)
1951 {
1952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1953 "%s: Hal Context is NULL",__func__);
1954 return -EINVAL;
1955 }
1956
1957 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1958 if (NULL == pHddStaCtx)
1959 {
1960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1961 "%s:STA context is NULL",__func__);
1962 return -EINVAL;
1963 }
1964
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301966 if (NULL == pWextState)
1967 {
1968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1969 "%s: pWextState is NULL",__func__);
1970 return -EINVAL;
1971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001972
1973 pRoamProfile = &pWextState->roamProfile;
1974
Arif Hussain6d2a3322013-11-17 19:50:10 -08001975 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001976
1977 /* Link is up then return cant set channel*/
1978 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1979 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1980 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001981 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 return -EOPNOTSUPP;
1983 }
1984
1985 /* Settings by Frequency as input */
1986 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1987 (wrqu->freq.m <= (tANI_U32)5.825e8))
1988 {
1989 tANI_U32 freq = wrqu->freq.m / 100000;
1990
1991 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1992 indx++;
1993 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1994 {
1995 return -EINVAL;
1996 }
1997 wrqu->freq.e = 0;
1998 wrqu->freq.m = freq_chan_map[indx].chan;
1999
2000 }
2001
2002 if (wrqu->freq.e == 0)
2003 {
2004 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2005 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
2006 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002007 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002008 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 WNI_CFG_CURRENT_CHANNEL_STAMAX);
2010 return -EINVAL;
2011 }
2012
2013 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2014
2015 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2016 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05302017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2018 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 return -EIO;
2020 }
2021
2022 for (indx = 0; indx < numChans; indx++) {
2023 if (wrqu->freq.m == validChan[indx]){
2024 break;
2025 }
2026 }
2027 }
2028 else{
2029
2030 return -EINVAL;
2031 }
2032
2033 if(indx >= numChans)
2034 {
2035 return -EINVAL;
2036 }
2037
2038 /* Set the Operational Channel */
2039 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2040 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2041 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
2042
Arif Hussain6d2a3322013-11-17 19:50:10 -08002043 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07002044
2045 EXIT();
2046
2047 return status;
2048}
2049
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302050static int iw_set_freq(struct net_device *dev,
2051 struct iw_request_info *info,
2052 union iwreq_data *wrqu, char *extra)
2053{
2054 int ret;
2055
2056 vos_ssr_protect(__func__);
2057 ret = __iw_set_freq(dev, info, wrqu, extra);
2058 vos_ssr_unprotect(__func__);
2059
2060 return ret;
2061}
2062
2063static int __iw_get_freq(struct net_device *dev,
2064 struct iw_request_info *info,
2065 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002066{
Jeff Johnsone7245742012-09-05 17:12:55 -07002067 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 tHalHandle hHal;
2070 hdd_wext_state_t *pWextState;
2071 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302072 hdd_station_ctx_t *pHddStaCtx;
2073 hdd_context_t *pHddCtx;
2074 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
2076 ENTER();
2077
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302078 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2079 if (NULL == pAdapter)
2080 {
2081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2082 "%s: Adapter is NULL", __func__);
2083 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302085 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2086 ret = wlan_hdd_validate_context(pHddCtx);
2087 if (0 != ret)
2088 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302089 return ret;
2090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302092 if (NULL == hHal)
2093 {
2094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2095 "%s: Hal Context is NULL",__func__);
2096 return -EINVAL;
2097 }
2098 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2099 if (NULL == pHddStaCtx)
2100 {
2101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2102 "%s: HddStaCtx is NULL", __func__);
2103 return -EINVAL;
2104 }
2105 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2106 if (NULL == pWextState)
2107 {
2108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2109 "%s: pWextState is NULL",__func__);
2110 return -EINVAL;
2111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 pRoamProfile = &pWextState->roamProfile;
2113
2114 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2115 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002116 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 {
c_hpothub8245442013-11-20 23:41:09 +05302118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2119 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 return -EIO;
2121 }
2122 else
2123 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002124 status = hdd_wlan_get_freq(channel, &freq);
2125 if( TRUE == status )
2126 {
2127 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2128 * iwlist & iwconfig command shows frequency into proper
2129 * format (2.412 GHz instead of 246.2 MHz)*/
2130 fwrq->m = freq;
2131 fwrq->e = MHZ;
2132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 }
2134 }
2135 else
2136 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002137 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2138 * iwlist & iwconfig command shows frequency into proper
2139 * format (2.412 GHz instead of 246.2 MHz)*/
2140 fwrq->m = 0;
2141 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302143
2144 EXIT();
2145 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002146}
2147
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302148static int iw_get_freq(struct net_device *dev,
2149 struct iw_request_info *info,
2150 struct iw_freq *fwrq, char *extra)
2151{
2152 int ret;
2153
2154 vos_ssr_protect(__func__);
2155 ret = __iw_get_freq(dev, info, fwrq, extra);
2156 vos_ssr_unprotect(__func__);
2157
2158 return ret;
2159}
2160
2161static int __iw_get_tx_power(struct net_device *dev,
2162 struct iw_request_info *info,
2163 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002164{
2165
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302166 hdd_adapter_t *pAdapter;
2167 hdd_context_t *pHddCtx;
2168 hdd_station_ctx_t *pHddStaCtx;
2169 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302171 ENTER();
2172
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302173 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2174 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2177 "%s: Adapter is NULL",__func__);
2178 return -EINVAL;
2179 }
2180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2181 ret = wlan_hdd_validate_context(pHddCtx);
2182 if (0 != ret)
2183 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302184 return ret;
2185 }
2186
2187 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2188 if (NULL == pHddStaCtx)
2189 {
2190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2191 "%s: STA Context is NULL",__func__);
2192 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 }
2194
2195 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2196 {
2197 wrqu->txpower.value = 0;
2198 return 0;
2199 }
2200 wlan_hdd_get_classAstats(pAdapter);
2201 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2202
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302203 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 return 0;
2205}
2206
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302207static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 struct iw_request_info *info,
2209 union iwreq_data *wrqu, char *extra)
2210{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302211 int ret;
2212
2213 vos_ssr_protect(__func__);
2214 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2215 vos_ssr_unprotect(__func__);
2216
2217 return ret;
2218}
2219
2220static int __iw_set_tx_power(struct net_device *dev,
2221 struct iw_request_info *info,
2222 union iwreq_data *wrqu, char *extra)
2223{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302224 hdd_adapter_t *pAdapter;
2225 tHalHandle hHal;
2226 hdd_context_t *pHddCtx;
2227 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002228
2229 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2231 if (NULL == pAdapter)
2232 {
2233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2234 "%s: Adapter is NULL",__func__);
2235 return -EINVAL;
2236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002237
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302238 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2239 ret = wlan_hdd_validate_context(pHddCtx);
2240 if (0 != ret)
2241 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302242 return ret;
2243 }
2244
2245 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2246 if (NULL == hHal)
2247 {
2248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2249 "%s: Hal Context is NULL",__func__);
2250 return -EINVAL;
2251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2253 {
c_hpothub8245442013-11-20 23:41:09 +05302254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2255 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 return -EIO;
2257 }
2258
2259 EXIT();
2260
2261 return 0;
2262}
2263
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302264static int iw_set_tx_power(struct net_device *dev,
2265 struct iw_request_info *info,
2266 union iwreq_data *wrqu, char *extra)
2267{
2268 int ret;
2269
2270 vos_ssr_protect(__func__);
2271 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2272 vos_ssr_unprotect(__func__);
2273
2274 return ret;
2275}
2276
2277static int __iw_get_bitrate(struct net_device *dev,
2278 struct iw_request_info *info,
2279 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002280{
2281 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2282 eHalStatus status = eHAL_STATUS_SUCCESS;
2283 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302284 hdd_adapter_t *pAdapter;
2285 hdd_context_t *pHddCtx;
2286 hdd_station_ctx_t *pHddStaCtx;
2287 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002288
2289 ENTER();
2290
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302291 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2292 if (NULL == pAdapter)
2293 {
2294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2295 "%s: Adapter is NULL",__func__);
2296 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 }
2298
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302299 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2300 ret = wlan_hdd_validate_context(pHddCtx);
2301 if (0 != ret)
2302 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302303 return ret;
2304 }
2305
2306 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2307 if (NULL == pHddStaCtx)
2308 {
2309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2310 "%s: STA Context is NULL",__func__);
2311 return -EINVAL;
2312 }
2313
2314 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 wrqu->bitrate.value = 0;
2316 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302317 else
2318 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2320 SME_SUMMARY_STATS |
2321 SME_GLOBAL_CLASSA_STATS |
2322 SME_GLOBAL_CLASSB_STATS |
2323 SME_GLOBAL_CLASSC_STATS |
2324 SME_GLOBAL_CLASSD_STATS |
2325 SME_PER_STA_STATS,
2326 hdd_StatisticsCB, 0, FALSE,
2327 pHddStaCtx->conn_info.staId[0], pAdapter );
2328
2329 if(eHAL_STATUS_SUCCESS != status)
2330 {
2331 hddLog(VOS_TRACE_LEVEL_ERROR,
2332 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002333 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 return status;
2335 }
2336
2337 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302338 if (NULL == pWextState)
2339 {
2340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2341 "%s: pWextState is NULL",__func__);
2342 return -EINVAL;
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344
2345 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2346
2347 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2348 {
2349 hddLog(VOS_TRACE_LEVEL_ERROR,
2350 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002351 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 return VOS_STATUS_E_FAILURE;
2353 }
2354
2355 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2356 }
2357
2358 EXIT();
2359
2360 return vos_status;
2361}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302362
2363static int iw_get_bitrate(struct net_device *dev,
2364 struct iw_request_info *info,
2365 union iwreq_data *wrqu, char *extra)
2366{
2367 int ret;
2368
2369 vos_ssr_protect(__func__);
2370 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2371 vos_ssr_unprotect(__func__);
2372
2373 return ret;
2374}
2375
2376
Jeff Johnson295189b2012-06-20 16:38:30 -07002377/* ccm call back function */
2378
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302379static int __iw_set_bitrate(struct net_device *dev,
2380 struct iw_request_info *info,
2381 union iwreq_data *wrqu,
2382 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002383{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302384 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302386 hdd_station_ctx_t *pHddStaCtx;
2387 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2389 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2390 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2391 v_U32_t i, rate;
2392 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302393 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002394
2395 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302396 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2397 if (NULL == pAdapter)
2398 {
2399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2400 "%s: Adapter is NULL",__func__);
2401 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 }
2403
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302404 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2405 ret = wlan_hdd_validate_context(pHddCtx);
2406 if (0 != ret)
2407 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302408 return ret;
2409 }
2410
2411 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2412 if (NULL == pHddStaCtx)
2413 {
2414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2415 "%s: STA Context is NULL",__func__);
2416 return -EINVAL;
2417 }
2418
2419
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302421 if (NULL == pWextState)
2422 {
2423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2424 "%s: pWextState is NULL",__func__);
2425 return -EINVAL;
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427
2428 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2429 {
2430 return -ENXIO ;
2431 }
2432
2433 rate = wrqu->bitrate.value;
2434
2435 if (rate == -1)
2436 {
2437 rate = WNI_CFG_FIXED_RATE_AUTO;
2438 valid_rate = TRUE;
2439 }
2440 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2441 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2442 {
2443 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2444 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2445 {
2446 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2447 WNI_CFG_SUPPORTED_RATES_11A,
2448 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2449 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2450 WNI_CFG_SUPPORTED_RATES_11B,
2451 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2452 {
2453 for (i = 0; i < (b_len + a_len); ++i)
2454 {
2455 /* supported rates returned is double the actual rate so we divide it by 2 */
2456 if ((supp_rates[i]&0x7F)/2 == rate)
2457 {
2458 valid_rate = TRUE;
2459 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2460 break;
2461 }
2462 }
2463 }
2464 }
2465 }
2466 if (valid_rate != TRUE)
2467 {
2468 return -EINVAL;
2469 }
2470 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2471 WNI_CFG_FIXED_RATE, rate,
2472 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2473 {
c_hpothub8245442013-11-20 23:41:09 +05302474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2475 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 return -EIO;
2477 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302478
2479 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 return 0;
2481}
2482
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302483static int iw_set_bitrate(struct net_device *dev,
2484 struct iw_request_info *info,
2485 union iwreq_data *wrqu,
2486 char *extra)
2487{
2488 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002489
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302490 vos_ssr_protect(__func__);
2491 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2492 vos_ssr_unprotect(__func__);
2493
2494 return ret;
2495}
2496
2497static int __iw_set_genie(struct net_device *dev,
2498 struct iw_request_info *info,
2499 union iwreq_data *wrqu,
2500 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002501{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302502 hdd_adapter_t *pAdapter;
2503 hdd_context_t *pHddCtx;
2504 hdd_wext_state_t *pWextState;
2505 u_int8_t *genie = NULL;
2506 u_int8_t *base_genie = NULL;
2507 v_U16_t remLen;
2508 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002509
2510 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302512 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2513 if (NULL == pAdapter)
2514 {
2515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2516 "%s: Adapter is NULL",__func__);
2517 return -EINVAL;
2518 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002519
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302520 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2521 ret = wlan_hdd_validate_context(pHddCtx);
2522 if (0 != ret)
2523 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 return ret;
2525 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002526
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302527 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2528 if (NULL == pWextState)
2529 {
2530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2531 "%s: pWextState is NULL",__func__);
2532 return -EINVAL;
2533 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002534
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302535 if (!wrqu->data.length) {
2536 hdd_clearRoamProfileIe(pAdapter);
2537 EXIT();
2538 return 0;
2539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002540
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302541 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2542 wrqu->data.length);
2543 if (NULL == base_genie)
2544 {
2545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2546 "mem_alloc_copy_from_user_helper fail");
2547 return -ENOMEM;
2548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002549
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302550 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002551
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302552 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002553
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302554 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2555
2556 /* clear any previous genIE before this call */
2557 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2558
2559 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 {
2561 v_U16_t eLen = 0;
2562 v_U8_t elementId;
2563 elementId = *genie++;
2564 eLen = *genie++;
2565 remLen -= 2;
2566
Arif Hussain6d2a3322013-11-17 19:50:10 -08002567 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 __func__, elementId, eLen);
2569
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302570 if (remLen < eLen) {
2571 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2572 remLen, eLen);
2573 ret = -EINVAL;
2574 goto exit;
2575 }
2576
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 switch ( elementId )
2578 {
2579 case IE_EID_VENDOR:
2580 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002581 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302582 ret = -EINVAL;
2583 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002585
2586 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2587 {
2588 v_U16_t curGenIELen = pWextState->genIE.length;
2589 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2590 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2591
2592 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2593 {
2594 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002595 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302597 ret = -EINVAL;
2598 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 }
2600 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2601 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2602 pWextState->genIE.length += eLen + 2;
2603 }
2604 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2605 {
2606 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302607 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2608 {
2609 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2610 "Need bigger buffer space");
2611 ret = -EINVAL;
2612 VOS_ASSERT(0);
2613 goto exit;
2614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2616 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2617 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2618 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2619 }
2620 else /* any vendorId except WPA IE should be accumulated to genIE */
2621 {
2622 v_U16_t curGenIELen = pWextState->genIE.length;
2623 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2624 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2625
2626 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2627 {
2628 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002629 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302631 ret = -ENOMEM;
2632 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 }
2634 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2635 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2636 pWextState->genIE.length += eLen + 2;
2637 }
2638 break;
2639 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002640 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302641 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2642 {
2643 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2644 "Need bigger buffer space");
2645 ret = -EINVAL;
2646 VOS_ASSERT(0);
2647 goto exit;
2648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2650 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2651 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2652 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2653 break;
2654
2655 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002656 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302657 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302660
2661 /* Move genie only if next element is present */
2662 if (remLen >= 2)
2663 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302665
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302666exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002668 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302669 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002670}
2671
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302672static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 struct iw_request_info *info,
2674 union iwreq_data *wrqu,
2675 char *extra)
2676{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302677 int ret;
2678
2679 vos_ssr_protect(__func__);
2680 ret = __iw_set_genie(dev, info, wrqu, extra);
2681 vos_ssr_unprotect(__func__);
2682
2683 return ret;
2684}
2685
2686static int __iw_get_genie(struct net_device *dev,
2687 struct iw_request_info *info,
2688 union iwreq_data *wrqu,
2689 char *extra)
2690{
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302692 hdd_context_t *pHddCtx;
2693 hdd_adapter_t *pAdapter;
2694 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 eHalStatus status;
2696 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2697 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2698
2699 ENTER();
2700
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302701 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2702 if (NULL == pAdapter)
2703 {
2704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2705 "%s: Adapter is NULL",__func__);
2706 return -EINVAL;
2707 }
2708 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2709 status = wlan_hdd_validate_context(pHddCtx);
2710 if (0 != status)
2711 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302712 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 }
2714
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302716 if (NULL == pWextState)
2717 {
2718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2719 "%s: pWextState is NULL",__func__);
2720 return -EINVAL;
2721 }
2722
2723 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2724 if (NULL == pHddStaCtx)
2725 {
2726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2727 "%s: STA Context is NULL",__func__);
2728 return -EINVAL;
2729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002730
2731 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2732 {
2733 return -ENXIO;
2734 }
2735
2736 // Return something ONLY if we are associated with an RSN or WPA network
2737 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2738 pWextState->roamProfile.negotiatedAuthType))
2739 {
2740 return -ENXIO;
2741 }
2742
2743 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2744 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2745 pAdapter->sessionId,
2746 &length,
2747 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302748 if (eHAL_STATUS_SUCCESS != status) {
2749 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002750 return -EFAULT;
2751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002752
Manjeet Singh715d47e2016-08-02 19:08:02 +05302753 wrqu->data.length = length;
2754 if (length > DOT11F_IE_RSN_MAX_LEN) {
2755 hddLog(LOGE,
2756 FL("invalid buffer length length:%d"), length);
2757 return -E2BIG;
2758 }
2759
2760 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2761
2762 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002763
2764 EXIT();
2765
2766 return 0;
2767}
2768
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302769static int iw_get_genie(struct net_device *dev,
2770 struct iw_request_info *info,
2771 union iwreq_data *wrqu,
2772 char *extra)
2773{
2774 int ret;
2775
2776 vos_ssr_protect(__func__);
2777 ret = __iw_get_genie(dev, info, wrqu, extra);
2778 vos_ssr_unprotect(__func__);
2779
2780 return ret;
2781}
2782
2783
2784static int __iw_get_encode(struct net_device *dev,
2785 struct iw_request_info *info,
2786 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002787{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302788 hdd_adapter_t *pAdapter;
2789 hdd_context_t *pHddCtx;
2790 hdd_wext_state_t *pWextState;
2791 tCsrRoamProfile *pRoamProfile;
2792 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002794
2795 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2797 if (NULL == pAdapter)
2798 {
2799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2800 "%s: Adapter is NULL",__func__);
2801 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 }
2803
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302804 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2805 ret = wlan_hdd_validate_context(pHddCtx);
2806 if (0 != ret)
2807 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302808 return ret;
2809 }
2810 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2811 if (NULL == pWextState)
2812 {
2813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2814 "%s: pWextState is NULL",__func__);
2815 return -EINVAL;
2816 }
2817
2818 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 keyId = pRoamProfile->Keys.defaultIndex;
2820
2821 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2822 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002823 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return -EINVAL;
2825 }
2826
2827 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2828 {
2829 dwrq->flags |= IW_ENCODE_ENABLED;
2830 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2831 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2832
2833 dwrq->flags |= (keyId + 1);
2834
2835 }
2836 else
2837 {
2838 dwrq->flags |= IW_ENCODE_DISABLED;
2839 }
2840
2841 for(i=0; i < MAX_WEP_KEYS; i++)
2842 {
2843 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2844 {
2845 continue;
2846 }
2847 else
2848 {
2849 break;
2850 }
2851 }
2852
2853 if(MAX_WEP_KEYS == i)
2854 {
2855 dwrq->flags |= IW_ENCODE_NOKEY;
2856 }
2857
2858 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2859
2860 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2861 {
2862 dwrq->flags |= IW_ENCODE_OPEN;
2863 }
2864 else
2865 {
2866 dwrq->flags |= IW_ENCODE_RESTRICTED;
2867 }
2868 EXIT();
2869 return 0;
2870}
2871
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302872static int iw_get_encode(struct net_device *dev,
2873 struct iw_request_info *info,
2874 struct iw_point *dwrq, char *extra)
2875{
2876 int ret;
2877
2878 vos_ssr_protect(__func__);
2879 ret = __iw_get_encode(dev, info, dwrq, extra);
2880 vos_ssr_unprotect(__func__);
2881
2882 return ret;
2883}
2884
Jeff Johnson295189b2012-06-20 16:38:30 -07002885#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2886#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2887
2888
2889/*
2890 * This function sends a single 'key' to LIM at all time.
2891 */
2892
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302893static int __iw_get_rts_threshold(struct net_device *dev,
2894 struct iw_request_info *info,
2895 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002896{
2897 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2898 v_U32_t status = 0;
2899
2900 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2901
2902 return status;
2903}
2904
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302905static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 struct iw_request_info *info,
2907 union iwreq_data *wrqu, char *extra)
2908{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302909 int ret;
2910
2911 vos_ssr_protect(__func__);
2912 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2913 vos_ssr_unprotect(__func__);
2914
2915 return ret;
2916}
2917
2918static int __iw_set_rts_threshold(struct net_device *dev,
2919 struct iw_request_info *info,
2920 union iwreq_data *wrqu, char *extra)
2921{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302922 hdd_adapter_t *pAdapter;
2923 hdd_context_t *pHddCtx;
2924 tHalHandle hHal;
2925 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
2927 ENTER();
2928
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2930 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002931 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2933 "%s: Adapter is NULL",__func__);
2934 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002935 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302936
2937 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2938 ret = wlan_hdd_validate_context(pHddCtx);
2939 if (0 != ret)
2940 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302941 return ret;
2942 }
2943
2944 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2945 if (NULL == hHal)
2946 {
2947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2948 "%s: Hal Context is NULL",__func__);
2949 return -EINVAL;
2950 }
2951
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2953 {
2954 return -EINVAL;
2955 }
2956
2957 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2958 {
c_hpothub8245442013-11-20 23:41:09 +05302959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2960 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 return -EIO;
2962 }
2963
2964 EXIT();
2965
2966 return 0;
2967}
2968
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302969static int iw_set_rts_threshold(struct net_device *dev,
2970 struct iw_request_info *info,
2971 union iwreq_data *wrqu, char *extra)
2972{
2973 int ret;
2974
2975 vos_ssr_protect(__func__);
2976 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2977 vos_ssr_unprotect(__func__);
2978
2979 return ret;
2980}
2981
2982static int __iw_get_frag_threshold(struct net_device *dev,
2983 struct iw_request_info *info,
2984 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002985{
2986 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2987 v_U32_t status = 0;
2988
2989 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2990
2991 return status;
2992}
2993
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302994static int iw_get_frag_threshold(struct net_device *dev,
2995 struct iw_request_info *info,
2996 union iwreq_data *wrqu, char *extra)
2997{
2998 int ret;
2999
3000 vos_ssr_protect(__func__);
3001 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3002 vos_ssr_unprotect(__func__);
3003
3004 return ret;
3005}
3006
3007static int __iw_set_frag_threshold(struct net_device *dev,
3008 struct iw_request_info *info,
3009 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003010{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303011 hdd_adapter_t *pAdapter;
3012 hdd_context_t *pHddCtx;
3013 tHalHandle hHal;
3014 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003015
3016 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303017 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3018 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003019 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3021 "%s: Adapter is NULL",__func__);
3022 return -EINVAL;
3023 }
3024
3025 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3026 ret = wlan_hdd_validate_context(pHddCtx);
3027 if (0 != ret)
3028 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303029 return ret;
3030 }
3031
3032 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3033 if (NULL == hHal)
3034 {
3035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3036 "%s: Hal Context is NULL",__func__);
3037 return -EINVAL;
3038 }
3039
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3041 {
3042 return -EINVAL;
3043 }
3044
3045 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3046 {
c_hpothub8245442013-11-20 23:41:09 +05303047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3048 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 return -EIO;
3050 }
3051
3052 EXIT();
3053
3054 return 0;
3055}
3056
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303057static int iw_set_frag_threshold(struct net_device *dev,
3058 struct iw_request_info *info,
3059 union iwreq_data *wrqu, char *extra)
3060{
3061 int ret;
3062
3063 vos_ssr_protect(__func__);
3064 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3065 vos_ssr_unprotect(__func__);
3066
3067 return ret;
3068}
3069
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303070static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 struct iw_request_info *info,
3072 union iwreq_data *wrqu, char *extra)
3073{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303074 hdd_adapter_t *pAdapter;
3075 hdd_context_t *pHddCtx;
3076 int ret = 0;
3077
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303079 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3080 if (NULL == pAdapter)
3081 {
3082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3083 "%s: Adapter is NULL",__func__);
3084 return -EINVAL;
3085 }
3086 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3087 ret = wlan_hdd_validate_context(pHddCtx);
3088 if (0 != ret)
3089 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303090 return ret;
3091 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303092
3093 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 return -EOPNOTSUPP;
3095}
3096
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303097static int iw_get_power_mode(struct net_device *dev,
3098 struct iw_request_info *info,
3099 union iwreq_data *wrqu, char *extra)
3100{
3101 int ret;
3102
3103 vos_ssr_protect(__func__);
3104 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3105 vos_ssr_unprotect(__func__);
3106
3107 return ret;
3108}
3109static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 struct iw_request_info *info,
3111 union iwreq_data *wrqu, char *extra)
3112{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303113 hdd_adapter_t *pAdapter;
3114 hdd_context_t *pHddCtx;
3115 int ret = 0;
3116
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303118 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3119 if (NULL == pAdapter)
3120 {
3121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3122 "%s: Adapter is NULL",__func__);
3123 return -EINVAL;
3124 }
3125 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3126 ret = wlan_hdd_validate_context(pHddCtx);
3127 if (0 != ret)
3128 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303129 return ret;
3130 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303131
3132 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 return -EOPNOTSUPP;
3134}
3135
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303136static int iw_set_power_mode(struct net_device *dev,
3137 struct iw_request_info *info,
3138 union iwreq_data *wrqu, char *extra)
3139{
3140 int ret;
3141
3142 vos_ssr_protect(__func__);
3143 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3144 vos_ssr_unprotect(__func__);
3145
3146 return ret;
3147}
3148
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303149static int __iw_get_range(struct net_device *dev,
3150 struct iw_request_info *info,
3151 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003152{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303153 hdd_adapter_t *pAdapter;
3154 tHalHandle hHal;
3155 hdd_context_t *pHddCtx;
3156 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 struct iw_range *range = (struct iw_range *) extra;
3158
3159 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3160
3161 v_U32_t num_channels = sizeof(channels);
3162 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3163 v_U32_t a_len;
3164 v_U32_t b_len;
3165 v_U32_t active_phy_mode = 0;
3166 v_U8_t index = 0, i;
3167
3168 ENTER();
3169
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303170 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3171 if (NULL == pAdapter)
3172 {
3173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3174 "%s: pAdapter is NULL", __func__);
3175 return -EINVAL;
3176 }
3177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3178 ret = wlan_hdd_validate_context(pHddCtx);
3179 if (0 != ret)
3180 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303181 return ret;
3182 }
3183 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3184 if (NULL == hHal)
3185 {
3186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3187 "%s: pAdapter is NULL", __func__);
3188 return -EINVAL;
3189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 wrqu->data.length = sizeof(struct iw_range);
3191 memset(range, 0, sizeof(struct iw_range));
3192
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 /*Get the phy mode*/
3194 if (ccmCfgGetInt(hHal,
3195 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3196 {
3197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003198 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003199
3200 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3201 {
3202 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003203 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 if (ccmCfgGetStr(hHal,
3205 WNI_CFG_SUPPORTED_RATES_11A,
3206 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3207 {
3208 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3209 {
3210 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3211 }
3212 for (i = 0; i < a_len; i++)
3213 {
3214 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3215 }
3216 range->num_bitrates = a_len;
3217 }
3218 else
3219 {
3220 return -EIO;
3221 }
3222 }
3223 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3224 {
3225 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003226 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 if (ccmCfgGetStr(hHal,
3228 WNI_CFG_SUPPORTED_RATES_11B,
3229 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3230 {
3231 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3232 {
3233 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3234 }
3235 for (i = 0; i < b_len; i++)
3236 {
3237 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3238 }
3239 range->num_bitrates = b_len;
3240 }
3241 else
3242 {
3243 return -EIO;
3244 }
3245 }
3246 }
3247
3248 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3249 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3250 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3251
3252 range->encoding_size[0] = 5;
3253 range->encoding_size[1] = 13;
3254 range->num_encoding_sizes = 2;
3255 range->max_encoding_tokens = MAX_WEP_KEYS;
3256
3257 // we support through Wireless Extensions 22
3258 range->we_version_compiled = WIRELESS_EXT;
3259 range->we_version_source = 22;
3260
3261 /*Supported Channels and Frequencies*/
3262 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3263 {
c_hpothub8245442013-11-20 23:41:09 +05303264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3265 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 return -EIO;
3267 }
3268 if (num_channels > IW_MAX_FREQUENCIES)
3269 {
3270 num_channels = IW_MAX_FREQUENCIES;
3271 }
3272
3273 range->num_channels = num_channels;
3274 range->num_frequency = num_channels;
3275
3276 for (index=0; index < num_channels; index++)
3277 {
3278 v_U32_t frq_indx = 0;
3279
3280 range->freq[index].i = channels[index];
3281 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3282 {
3283 if(channels[index] == freq_chan_map[frq_indx].chan)
3284 {
3285 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3286 range->freq[index].e = 1;
3287 break;
3288 }
3289 frq_indx++;
3290 }
3291 }
3292
3293 /* Event capability (kernel + driver) */
3294 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3295 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3296 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3297 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3298
3299 /*Encryption capability*/
3300 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3301 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3302
3303 /* Txpower capability */
3304 range->txpower_capa = IW_TXPOW_MWATT;
3305
3306 /*Scanning capability*/
3307 #if WIRELESS_EXT >= 22
3308 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3309 #endif
3310
3311 EXIT();
3312 return 0;
3313}
3314
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303315static int iw_get_range(struct net_device *dev,
3316 struct iw_request_info *info,
3317 union iwreq_data *wrqu, char *extra)
3318{
3319 int ret;
3320
3321 vos_ssr_protect(__func__);
3322 ret = __iw_get_range(dev, info, wrqu, extra);
3323 vos_ssr_unprotect(__func__);
3324
3325 return ret;
3326}
3327
Jeff Johnson295189b2012-06-20 16:38:30 -07003328/* Callback function registered with PMC to know status of PMC request */
3329static void iw_power_callback_fn (void *pContext, eHalStatus status)
3330{
3331 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003332
3333 if (NULL == pContext)
3334 {
3335 hddLog(VOS_TRACE_LEVEL_ERROR,
3336 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003337 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 return;
3339 }
3340
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003342
Jeff Johnson72a40512013-12-19 10:14:15 -08003343 /* there is a race condition that exists between this callback
3344 function and the caller since the caller could time out either
3345 before or while this code is executing. we use a spinlock to
3346 serialize these actions */
3347 spin_lock(&hdd_context_lock);
3348
3349 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 {
3351 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003352 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003354 "%s: Invalid context, magic [%08x]",
3355 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003356
3357 if (ioctl_debug)
3358 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003359 pr_info("%s: Invalid context, magic [%08x]\n",
3360 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 }
3362 return;
3363 }
3364
Jeff Johnson72a40512013-12-19 10:14:15 -08003365 /* context is valid so caller is still waiting */
3366
3367 /* paranoia: invalidate the magic */
3368 pStatsContext->magic = 0;
3369
3370 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003372
3373 /* serialization is complete */
3374 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003375}
3376
3377/* Callback function for tx per hit */
3378void hdd_tx_per_hit_cb (void *pCallbackContext)
3379{
3380 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3381 unsigned char tx_fail[16];
3382 union iwreq_data wrqu;
3383
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303384 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003386 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 return;
3388 }
3389 memset(&wrqu, 0, sizeof(wrqu));
3390 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3391 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3392}
3393
3394void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3395{
3396 struct statsContext *pStatsContext;
3397 tCsrGlobalClassAStatsInfo *pClassAStats;
3398 hdd_adapter_t *pAdapter;
3399
3400 if (ioctl_debug)
3401 {
3402 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003403 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 }
3405
3406 if ((NULL == pStats) || (NULL == pContext))
3407 {
3408 hddLog(VOS_TRACE_LEVEL_ERROR,
3409 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003410 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 return;
3412 }
3413
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 pClassAStats = pStats;
3415 pStatsContext = pContext;
3416 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003417
3418 /* there is a race condition that exists between this callback
3419 function and the caller since the caller could time out either
3420 before or while this code is executing. we use a spinlock to
3421 serialize these actions */
3422 spin_lock(&hdd_context_lock);
3423
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3425 {
3426 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003427 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 hddLog(VOS_TRACE_LEVEL_WARN,
3429 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003430 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 if (ioctl_debug)
3432 {
3433 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003434 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 }
3436 return;
3437 }
3438
Jeff Johnson72a40512013-12-19 10:14:15 -08003439 /* context is valid so caller is still waiting */
3440
3441 /* paranoia: invalidate the magic */
3442 pStatsContext->magic = 0;
3443
3444 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3446
Jeff Johnson72a40512013-12-19 10:14:15 -08003447 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003449
3450 /* serialization is complete */
3451 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003452}
3453
3454VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3455{
3456 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3457 eHalStatus hstatus;
3458 long lrc;
3459 struct statsContext context;
3460
3461 if (NULL == pAdapter)
3462 {
3463 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3464 return VOS_STATUS_E_FAULT;
3465 }
3466 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3467 {
3468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3469 return VOS_STATUS_SUCCESS;
3470 }
3471
3472 /* we are connected
3473 prepare our callback context */
3474 init_completion(&context.completion);
3475 context.pAdapter = pAdapter;
3476 context.magic = STATS_CONTEXT_MAGIC;
3477 /* query only for Class A statistics (which include link speed) */
3478 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3479 eCSR_HDD,
3480 SME_GLOBAL_CLASSA_STATS,
3481 hdd_GetClassA_statisticsCB,
3482 0, // not periodic
3483 FALSE, //non-cached results
3484 pHddStaCtx->conn_info.staId[0],
3485 &context);
3486 if (eHAL_STATUS_SUCCESS != hstatus)
3487 {
3488 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003489 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003490 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 /* we'll returned a cached value below */
3492 }
3493 else
3494 {
3495 /* request was sent -- wait for the response */
3496 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3497 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 if (lrc <= 0)
3499 {
3500 hddLog(VOS_TRACE_LEVEL_ERROR,
3501 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003502 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 }
3504 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003505
3506 /* either we never sent a request, we sent a request and received a
3507 response or we sent a request and timed out. if we never sent a
3508 request or if we sent a request and got a response, we want to
3509 clear the magic out of paranoia. if we timed out there is a
3510 race condition such that the callback function could be
3511 executing at the same time we are. of primary concern is if the
3512 callback function had already verified the "magic" but had not
3513 yet set the completion variable when a timeout occurred. we
3514 serialize these activities by invalidating the magic while
3515 holding a shared spinlock which will cause us to block if the
3516 callback is currently executing */
3517 spin_lock(&hdd_context_lock);
3518 context.magic = 0;
3519 spin_unlock(&hdd_context_lock);
3520
3521 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 return VOS_STATUS_SUCCESS;
3523}
3524
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003525static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3526{
3527 struct statsContext *pStatsContext;
3528 tCsrSummaryStatsInfo *pSummaryStats;
3529 tCsrGlobalClassAStatsInfo *pClassAStats;
3530 hdd_adapter_t *pAdapter;
3531
3532 if (ioctl_debug)
3533 {
3534 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003535 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003536 }
3537
3538 if ((NULL == pStats) || (NULL == pContext))
3539 {
3540 hddLog(VOS_TRACE_LEVEL_ERROR,
3541 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003542 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003543 return;
3544 }
3545
Jeff Johnson72a40512013-12-19 10:14:15 -08003546 /* there is a race condition that exists between this callback
3547 function and the caller since the caller could time out either
3548 before or while this code is executing. we use a spinlock to
3549 serialize these actions */
3550 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003551
3552 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3553 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3554 pStatsContext = pContext;
3555 pAdapter = pStatsContext->pAdapter;
3556 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3557 {
3558 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003559 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003560 hddLog(VOS_TRACE_LEVEL_WARN,
3561 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003562 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003563 if (ioctl_debug)
3564 {
3565 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003566 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003567 }
3568 return;
3569 }
3570
Jeff Johnson72a40512013-12-19 10:14:15 -08003571 /* context is valid so caller is still waiting */
3572
3573 /* paranoia: invalidate the magic */
3574 pStatsContext->magic = 0;
3575
3576 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003577 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3578 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3579
Jeff Johnson72a40512013-12-19 10:14:15 -08003580 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003581 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003582
3583 /* serialization is complete */
3584 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003585}
3586
3587VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3588{
3589 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3590 eHalStatus hstatus;
3591 long lrc;
3592 struct statsContext context;
3593
3594 if (NULL == pAdapter)
3595 {
3596 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3597 return VOS_STATUS_SUCCESS;
3598 }
3599
3600 /* we are connected
3601 prepare our callback context */
3602 init_completion(&context.completion);
3603 context.pAdapter = pAdapter;
3604 context.magic = STATS_CONTEXT_MAGIC;
3605
3606 /* query only for Summary & Class A statistics */
3607 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3608 eCSR_HDD,
3609 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303610 SME_GLOBAL_CLASSA_STATS |
3611 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003612 hdd_get_station_statisticsCB,
3613 0, // not periodic
3614 FALSE, //non-cached results
3615 pHddStaCtx->conn_info.staId[0],
3616 &context);
3617 if (eHAL_STATUS_SUCCESS != hstatus)
3618 {
3619 hddLog(VOS_TRACE_LEVEL_ERROR,
3620 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003621 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003622 /* we'll return with cached values */
3623 }
3624 else
3625 {
3626 /* request was sent -- wait for the response */
3627 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3628 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003629
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003630 if (lrc <= 0)
3631 {
3632 hddLog(VOS_TRACE_LEVEL_ERROR,
3633 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003634 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003635 }
3636 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003637
3638 /* either we never sent a request, we sent a request and received a
3639 response or we sent a request and timed out. if we never sent a
3640 request or if we sent a request and got a response, we want to
3641 clear the magic out of paranoia. if we timed out there is a
3642 race condition such that the callback function could be
3643 executing at the same time we are. of primary concern is if the
3644 callback function had already verified the "magic" but had not
3645 yet set the completion variable when a timeout occurred. we
3646 serialize these activities by invalidating the magic while
3647 holding a shared spinlock which will cause us to block if the
3648 callback is currently executing */
3649 spin_lock(&hdd_context_lock);
3650 context.magic = 0;
3651 spin_unlock(&hdd_context_lock);
3652
3653 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003654 return VOS_STATUS_SUCCESS;
3655}
3656
3657
Jeff Johnson295189b2012-06-20 16:38:30 -07003658/*
3659 * Support for the LINKSPEED private command
3660 * Per the WiFi framework the response must be of the form
3661 * "LinkSpeed xx"
3662 */
3663static int iw_get_linkspeed(struct net_device *dev,
3664 struct iw_request_info *info,
3665 union iwreq_data *wrqu, char *extra)
3666{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303667 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303668 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303670 int len = sizeof(v_U32_t) + 1;
3671 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303672 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303673 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303674 int rc, valid = 0;
3675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303676 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303677 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3678 if (NULL == pAdapter)
3679 {
3680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3681 "%s: Adapter is NULL",__func__);
3682 return -EINVAL;
3683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003684
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303685 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303686 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303687 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003688 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303689 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003690 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303691 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3692 if (NULL == pHddStaCtx)
3693 {
3694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3695 "%s: STA Context is NULL",__func__);
3696 return -EINVAL;
3697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3699 {
3700 /* we are not connected so we don't have a classAstats */
3701 link_speed = 0;
3702 }
3703 else
3704 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303705 status = wlan_hdd_get_classAstats(pAdapter);
3706
3707 if (!VOS_IS_STATUS_SUCCESS(status ))
3708 {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3710 return -EINVAL;
3711 }
3712
3713 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3714 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3715 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3716 &link_speed);
3717
3718 link_speed = link_speed / 10;
3719
3720 if (0 == link_speed)
3721 {
3722 /* The linkspeed returned by HAL is in units of 500kbps.
3723 * converting it to mbps.
3724 * This is required to support legacy firmware which does
3725 * not return link capacity.
3726 */
3727 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3728 }
3729
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 }
3731
3732 wrqu->data.length = len;
3733 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003734 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 if ((rc < 0) || (rc >= len))
3736 {
3737 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303738 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 return -EIO;
3740 }
3741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303742 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003744 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003745}
3746
Arif Hussain695279c2014-03-24 14:06:07 -07003747/*
3748 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3749 *
3750 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303751static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003752 struct iw_request_info *info,
3753 union iwreq_data *wrqu, char *extra)
3754{
3755 int rc;
3756
3757 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3758
3759 if (rc < 0)
3760 return rc;
3761
3762 /* a value is being successfully returned */
3763 return 0;
3764}
Jeff Johnson295189b2012-06-20 16:38:30 -07003765
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303766static int iw_get_linkspeed_priv(struct net_device *dev,
3767 struct iw_request_info *info,
3768 union iwreq_data *wrqu, char *extra)
3769{
3770 int ret;
3771
3772 vos_ssr_protect(__func__);
3773 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3774 vos_ssr_unprotect(__func__);
3775
3776 return ret;
3777}
3778
Jeff Johnson295189b2012-06-20 16:38:30 -07003779/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303780 * Support for the RSSI & RSSI-APPROX private commands
3781 * Per the WiFi framework the response must be of the form
3782 * "<ssid> rssi <xx>"
3783 * unless we are not associated, in which case the response is
3784 * "OK"
3785 */
3786static int iw_get_rssi(struct net_device *dev,
3787 struct iw_request_info *info,
3788 union iwreq_data *wrqu, char *extra)
3789{
3790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3791 char *cmd = extra;
3792 int len = wrqu->data.length;
3793 v_S7_t s7Rssi = 0;
3794 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3795 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3796 VOS_STATUS vosStatus;
3797 int rc;
3798
3799 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3800 (0 == ssidlen) || (ssidlen >= len))
3801 {
3802 /* we are not connected or our SSID is too long
3803 so we cannot report an rssi */
3804 rc = scnprintf(cmd, len, "OK");
3805 }
3806 else
3807 {
3808 /* we are connected with a valid SSID
3809 so we can write the SSID into the return buffer
3810 (note that it is not NUL-terminated) */
3811 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3812
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303813 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303814 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3815
3816 if (VOS_STATUS_SUCCESS == vosStatus)
3817 {
3818 /* append the rssi to the ssid in the format required by
3819 the WiFI Framework */
3820 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3821 rc += ssidlen;
3822 }
3823 else
3824 {
3825 rc = -1;
3826 }
3827 }
3828
3829 /* verify that we wrote a valid response */
3830 if ((rc < 0) || (rc >= len))
3831 {
3832 // encoding or length error?
3833 hddLog(VOS_TRACE_LEVEL_ERROR,
3834 "%s: Unable to encode RSSI, got [%s]",
3835 __func__, cmd);
3836 return -EIO;
3837 }
3838
3839 /* a value is being successfully returned */
3840 return rc;
3841}
3842
3843/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 * Support for SoftAP channel range private command
3845 */
3846static int iw_softap_set_channel_range( struct net_device *dev,
3847 int startChannel,
3848 int endChannel,
3849 int band)
3850{
Jeff Johnson43971f52012-07-17 12:26:56 -07003851 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 int ret = 0;
3853 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3854 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003855 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3856
Jeff Johnson295189b2012-06-20 16:38:30 -07003857
3858 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3859 if (VOS_STATUS_SUCCESS != status)
3860 {
3861 ret = -EINVAL;
3862 }
Yathish9f22e662012-12-10 14:21:35 -08003863 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 return ret;
3865}
3866
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303867static uint8 chartohex(char c)
3868{
3869 uint8 val = 0;
3870 if (c >= '0' && c <= '9')
3871 val = c - '0';
3872 else if (c >= 'a' && c <= 'f')
3873 val = c - 'a' + 10;
3874 else if (c >= 'A' && c <= 'F')
3875 val = c - 'A' + 10;
3876 else
3877 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3878
3879 return val;
3880}
3881
3882uint8 getByte(char **buf)
3883{
3884 uint8 byte = 0;
3885 char *temp = *buf;
3886 byte = chartohex(*temp) * 16;
3887 temp++;
3888 byte += chartohex(*temp);
3889 temp++;
3890 *buf = temp;
3891 return byte;
3892}
3893
3894static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3895{
3896 tSir80211Header *macHeader;
3897 int i = 0, j = 0, length = 0;
3898 uint8 byte = 0;
3899 char *temp = pBuffer;
3900 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303901 char *pHeader;
3902 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303903
3904 macHeader = &pkt->macHeader;
3905
3906 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3907
3908 temp++;
3909
3910 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3911 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3912 pkt->encParams.keyParams.key[0].keyId);
3913
3914 for (i = 0; i< 16; i++) {
3915 pkt->encParams.keyParams.key[0].key[i]
3916 = getByte(&temp);
3917 }
3918
3919 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3920 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3921
3922 for (i = 0; i< 6; i++) {
3923 pkt->encParams.pn[i]
3924 = getByte(&temp);
3925 }
3926
3927 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3928 &pkt->encParams.pn[0], 6, 0);
3929
3930 for (i = 0, j= 5; i< 3; i++, j--) {
3931 byte = pkt->encParams.pn[i];
3932 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3933 pkt->encParams.pn[j] = byte;
3934 }
3935
3936 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303937 if (length > sizeof(tSir80211Header))
3938 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303939
Srinivas Dasari2382de62015-01-22 15:00:04 +05303940 pHeader = temp;
3941 vos_mem_zero(&header, sizeof(tSir80211Header));
3942 for (i = 0; i < length; i++) {
3943 *((uint8 *)&header + i) = getByte(&pHeader);
3944 }
3945
3946 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3947 (char *)&header, length, 0);
3948
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303949 byte = getByte(&temp);
3950
3951 macHeader->frameCtrl.protVer = byte & 0x3;
3952 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3953 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3954
3955 byte = getByte(&temp);
3956 macHeader->frameCtrl.toDS = (byte) & 0x1;
3957 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3958 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3959 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3960 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3961 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3962 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3963 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3964
3965 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3966 "macHeader->frameCtrl.type : %x "
3967 "macHeader->frameCtrl.subType : %x "
3968 "macHeader->frameCtrl.toDS : %x "
3969 "macHeader->frameCtrl.fromDS : %x "
3970 "macHeader->frameCtrl.moreFrag : %x "
3971 "macHeader->frameCtrl.retry : %x "
3972 "macHeader->frameCtrl.powerMgmt : %x "
3973 "macHeader->frameCtrl.MoreData : %x "
3974 "macHeader->frameCtrl.wep : %x "
3975 "macHeader->frameCtrl.order : %x "
3976 , macHeader->frameCtrl.protVer
3977 , macHeader->frameCtrl.type
3978 , macHeader->frameCtrl.subType
3979 , macHeader->frameCtrl.toDS
3980 , macHeader->frameCtrl.fromDS
3981 , macHeader->frameCtrl.moreFrag
3982 , macHeader->frameCtrl.retry
3983 , macHeader->frameCtrl.powerMgmt
3984 , macHeader->frameCtrl.moreData
3985 , macHeader->frameCtrl.wep
3986 , macHeader->frameCtrl.order);
3987
3988
3989 macHeader->usDurationId = getByte(&temp);
3990 macHeader->usDurationId += getByte(&temp) << 8;
3991
3992 macHeader->vA1[0] = getByte(&temp);
3993 macHeader->vA1[1] = getByte(&temp);
3994 macHeader->vA1[2] = getByte(&temp);
3995 macHeader->vA1[3] = getByte(&temp);
3996 macHeader->vA1[4] = getByte(&temp);
3997 macHeader->vA1[5] = getByte(&temp);
3998
3999 macHeader->vA2[0] = getByte(&temp);
4000 macHeader->vA2[1] = getByte(&temp);
4001 macHeader->vA2[2] = getByte(&temp);
4002 macHeader->vA2[3] = getByte(&temp);
4003 macHeader->vA2[4] = getByte(&temp);
4004 macHeader->vA2[5] = getByte(&temp);
4005
4006 macHeader->vA3[0] = getByte(&temp);
4007 macHeader->vA3[1] = getByte(&temp);
4008 macHeader->vA3[2] = getByte(&temp);
4009 macHeader->vA3[3] = getByte(&temp);
4010 macHeader->vA3[4] = getByte(&temp);
4011 macHeader->vA3[5] = getByte(&temp);
4012
4013 macHeader->sSeqCtrl = getByte(&temp);
4014 fragNum = macHeader->sSeqCtrl & 0xF;
4015 macHeader->sSeqCtrl >>= 4;
4016
4017 macHeader->sSeqCtrl += getByte(&temp) << 4;
4018
4019 macHeader->sSeqCtrl |= fragNum << 12;
4020
4021 if (length == 30 || length == 32) {
4022 macHeader->optvA4[0] = getByte(&temp);
4023 macHeader->optvA4[1] = getByte(&temp);
4024 macHeader->optvA4[2] = getByte(&temp);
4025 macHeader->optvA4[3] = getByte(&temp);
4026 macHeader->optvA4[4] = getByte(&temp);
4027 macHeader->optvA4[5] = getByte(&temp);
4028 }
4029
4030 if (length == 26 || length == 32) {
4031 macHeader->usQosCtrl = getByte(&temp);
4032 macHeader->usQosCtrl += getByte(&temp) << 8;
4033 }
4034
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304035 //parse payload
4036 length = getByte(&temp);
4037 length += getByte(&temp) << 8;
4038 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4039
Manjeet Singh5830f142016-11-21 18:21:17 +05304040 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
4041 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
4042
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304043 pkt->data.length = length;
4044
4045 for (i = 0; i< length; i++) {
4046 pkt->data.data[i] = getByte(&temp);
4047 }
4048
4049 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4050 &pkt->data.data[0], pkt->data.length, 0);
4051}
4052
4053/**---------------------------------------------------------------------------
4054
4055 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4056 encrypt message request
4057 This is an asynchronous callback function from SME when the encrypted data
4058 is received
4059
4060 \pEncInfoRsp -> Encrypted data info
4061
4062 \return - 0 for success non-zero for failure
4063 --------------------------------------------------------------------------*/
4064static void
4065hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4066{
4067 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4068
4069 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4070
4071 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4072 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4073 pEncryptedDataRsp->encryptedPayload.length);
4074 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4075 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4076 pEncryptedDataRsp->encryptedPayload.data,
4077 pEncryptedDataRsp->encryptedPayload.length, 0);
4078}
4079
Jeff Johnson295189b2012-06-20 16:38:30 -07004080VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4081{
4082 struct statsContext context;
4083 eHalStatus status;
4084 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304085 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004086
4087 if (NULL == pAdapter)
4088 {
4089 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4090 return VOS_STATUS_E_FAULT;
4091 }
4092
4093 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4094 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304095 if (pHddCtx->isLogpInProgress) {
4096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4097 "%s:LOGP in Progress. Ignore!!!", __func__);
4098 return VOS_STATUS_E_FAILURE;
4099 }
4100
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 init_completion(&context.completion);
4102
4103 context.pAdapter = pAdapter;
4104 context.magic = POWER_CONTEXT_MAGIC;
4105
4106 if (DRIVER_POWER_MODE_ACTIVE == mode)
4107 {
4108 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4109 "Full Power", __func__);
4110 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4111 iw_power_callback_fn, &context,
4112 eSME_FULL_PWR_NEEDED_BY_HDD);
4113 // Enter Full power command received from GUI this means we are disconnected
4114 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4115 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4116 if (eHAL_STATUS_PMC_PENDING == status)
4117 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004118 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 int lrc = wait_for_completion_interruptible_timeout(
4120 &context.completion,
4121 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004122
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 if (lrc <= 0)
4124 {
4125 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004126 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128 }
4129 }
4130 else if (DRIVER_POWER_MODE_AUTO == mode)
4131 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304132 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4133 * was already in BMPS state and thus either STA or P2P-CLI is in
4134 * associated state and authenticated, so even if STA connState is
4135 * not associated it can be assumed that P2P-CLI is associated and
4136 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4137 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4138 * if all condition are satisfied for entering BMPS.
4139 */
4140 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4141 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304142 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304143 hddLog(LOGE,
4144 FL("Station is associated but, still not Authenticated ignore "
4145 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304146 return VOS_STATUS_E_AGAIN;
4147 }
4148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4150 {
4151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4152 __func__);
4153 // Enter BMPS command received from GUI this means DHCP is completed
4154 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4155 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4156 FALSE);
4157 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4158 iw_power_callback_fn, &context);
4159 if (eHAL_STATUS_PMC_PENDING == status)
4160 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004161 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 int lrc = wait_for_completion_interruptible_timeout(
4163 &context.completion,
4164 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 if (lrc <= 0)
4166 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004167 hddLog(VOS_TRACE_LEVEL_ERROR,
4168 "%s: SME %s while requesting BMPS",
4169 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 }
4171 }
4172 }
4173 else
4174 {
4175 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4176 "enabled in the cfg");
4177 }
4178 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004179
4180 /* either we never sent a request, we sent a request and received a
4181 response or we sent a request and timed out. if we never sent a
4182 request or if we sent a request and got a response, we want to
4183 clear the magic out of paranoia. if we timed out there is a
4184 race condition such that the callback function could be
4185 executing at the same time we are. of primary concern is if the
4186 callback function had already verified the "magic" but had not
4187 yet set the completion variable when a timeout occurred. we
4188 serialize these activities by invalidating the magic while
4189 holding a shared spinlock which will cause us to block if the
4190 callback is currently executing */
4191 spin_lock(&hdd_context_lock);
4192 context.magic = 0;
4193 spin_unlock(&hdd_context_lock);
4194
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 return VOS_STATUS_SUCCESS;
4196}
4197
4198VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4199 hdd_adapter_t *pAdapter)
4200{
4201 VOS_STATUS vos_Status;
4202
4203 if ((NULL == pAdapter) || (NULL == pHddCtx))
4204 {
4205 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4206 return VOS_STATUS_E_FAULT;
4207 }
4208
4209 /**Exit from Deep sleep or standby if we get the driver
4210 START cmd from android GUI
4211 */
4212 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4213 {
4214 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4215 "from Stand by",__func__);
4216 vos_Status = hdd_exit_standby(pHddCtx);
4217 }
4218 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4219 {
4220 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4221 "from deep sleep",__func__);
4222 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4223 }
4224 else
4225 {
4226 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4227 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4228 vos_Status = VOS_STATUS_SUCCESS;
4229 }
4230
4231 return vos_Status;
4232}
4233
4234VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4235{
4236 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4237
4238 if (NULL == pHddCtx)
4239 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304240 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 return VOS_STATUS_E_FAULT;
4242 }
4243
4244 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4245 {
4246 //Execute standby procedure.
4247 //Executing standby procedure will cause the STA to
4248 //disassociate first and then the chip will be put into standby.
4249 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4250 vos_Status = hdd_enter_standby(pHddCtx);
4251 }
4252 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4253 pHddCtx->cfg_ini->nEnableDriverStop)
4254 {
4255 //Execute deep sleep procedure
4256 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004257 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 //Deep sleep not supported
4259 vos_Status = hdd_enter_standby(pHddCtx);
4260 }
4261 else
4262 {
4263 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4264 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4265 vos_Status = VOS_STATUS_SUCCESS;
4266 }
4267
4268 return vos_Status;
4269}
4270
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004271
4272void* wlan_hdd_change_country_code_callback(void *pAdapter)
4273{
4274
4275 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004276 complete(&call_back_pAdapter->change_country_code);
4277
4278 return NULL;
4279}
4280
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304281static int __iw_set_priv(struct net_device *dev,
4282 struct iw_request_info *info,
4283 union iwreq_data *wrqu, char *extra)
4284{
4285 hdd_adapter_t *pAdapter;
4286 char *cmd = NULL;
4287 int cmd_len = wrqu->data.length;
4288 int rc = 0, ret = 0;
4289 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4290
4291 hdd_context_t *pHddCtx;
4292
4293 ENTER();
4294
4295 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4296 if (NULL == pAdapter)
4297 {
4298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4299 "mem_alloc_copy_from_user_helper fail");
4300 return -EINVAL;
4301 }
4302 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4303 rc = wlan_hdd_validate_context(pHddCtx);
4304 if (0 != rc)
4305 {
4306 return rc;
4307 }
4308
4309 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4310 wrqu->data.length);
4311 if (NULL == cmd)
4312 {
4313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4314 "mem_alloc_copy_from_user_helper fail");
4315 return -ENOMEM;
4316 }
4317
4318 if (ioctl_debug)
4319 {
4320 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4321 }
4322
4323 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4324 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4325
4326 if (strncmp(cmd, "CSCAN", 5) == 0 )
4327 {
4328 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4330 "%s: Error in iw_set_scan!", __func__);
4331 rc = -EINVAL;
4332 }
4333 }
4334 else if( strcasecmp(cmd, "start") == 0 ) {
4335
4336 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4337 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4338
4339 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4340 if (vos_status == VOS_STATUS_SUCCESS)
4341 {
4342 union iwreq_data wrqu;
4343 char buf[10];
4344
4345 memset(&wrqu, 0, sizeof(wrqu));
4346 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4347 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4348 }
4349 else
4350 {
4351 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4352 rc = -EIO;
4353 }
4354 goto done;
4355 }
4356 else if( strcasecmp(cmd, "stop") == 0 )
4357 {
4358 union iwreq_data wrqu;
4359 char buf[10];
4360
4361 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4362
4363 wlan_hdd_enter_lowpower(pHddCtx);
4364 memset(&wrqu, 0, sizeof(wrqu));
4365 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4366 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4367 goto done;
4368 }
4369 else if (strcasecmp(cmd, "macaddr") == 0)
4370 {
4371 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4372 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4373 }
4374 else if (strcasecmp(cmd, "scan-active") == 0)
4375 {
4376 hddLog(LOG1,
4377 FL("making default scan to active"));
4378 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4379 ret = snprintf(cmd, cmd_len, "OK");
4380 }
4381 else if (strcasecmp(cmd, "scan-passive") == 0)
4382 {
4383 hddLog(LOG1,
4384 FL("making default scan to passive"));
4385 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4386 ret = snprintf(cmd, cmd_len, "OK");
4387 }
4388 else if( strcasecmp(cmd, "scan-mode") == 0 )
4389 {
4390 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4391 }
4392 else if( strcasecmp(cmd, "linkspeed") == 0 )
4393 {
4394 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4395 }
4396 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4397 {
4398 ret = iw_get_rssi(dev, info, wrqu, cmd);
4399 }
4400 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4401 int mode;
4402 char *ptr;
4403
4404 if (9 < cmd_len)
4405 {
4406 ptr = (char*)(cmd + 9);
4407
4408 }else{
4409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4410 "CMD LENGTH %d is not correct",cmd_len);
4411 kfree(cmd);
4412 return -EINVAL;
4413 }
4414
4415 if (1 != sscanf(ptr,"%d",&mode))
4416 {
4417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4418 "powermode input %s is not correct",ptr);
4419 kfree(cmd);
4420 return -EIO;
4421 }
4422
4423 wlan_hdd_enter_bmps(pAdapter, mode);
4424 /*TODO:Set the power mode*/
4425 }
4426 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4427 v_U32_t pmc_state;
4428 v_U16_t value;
4429
4430 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4431 if(pmc_state == BMPS) {
4432 value = DRIVER_POWER_MODE_AUTO;
4433 }
4434 else {
4435 value = DRIVER_POWER_MODE_ACTIVE;
4436 }
4437 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4438 }
4439 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4440 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4441 /*TODO: set the btcoexmode*/
4442 }
4443 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4444
4445 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4446 /*TODO: Return the btcoex status*/
4447 }
4448 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4449
4450 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4451
4452 /*TODO: Enable Rx data Filter*/
4453 }
4454 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4455
4456 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4457
4458 /*TODO: Disable Rx data Filter*/
4459 }
4460 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4461
4462 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4463 /*TODO: rxfilter-statistics*/
4464 }
4465 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4466
4467 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4468 /*TODO: rxfilter-add*/
4469 }
4470 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4471
4472 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4473 /*TODO: rxfilter-remove*/
4474 }
4475#ifdef FEATURE_WLAN_SCAN_PNO
4476 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4477 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4478 /*TODO: support pnosetup*/
4479 }
4480 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4481 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4482 /*TODO: support pnoforce*/
4483 }
4484 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4485
4486 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4487 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4488 kfree(cmd);
4489 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4490 }
4491 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4492 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4493 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4494 kfree(cmd);
4495 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4496 }
4497#endif /*FEATURE_WLAN_SCAN_PNO*/
4498 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4499 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4500 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4501 kfree(cmd);
4502 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4503 }
4504 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4505 tSirTxPerTrackingParam tTxPerTrackingParam;
4506 char *ptr;
4507
4508 if (18 < cmd_len)
4509 {
4510 ptr = (char*)(cmd + 18);
4511 }else{
4512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4513 "CMD LENGTH %d is not correct",cmd_len);
4514 kfree(cmd);
4515 return -EINVAL;
4516 }
4517
4518 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4519 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4520 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4521 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4522 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4523 {
4524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4525 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4526 kfree(cmd);
4527 return -EIO;
4528 }
4529
4530 // parameters checking
4531 // period has to be larger than 0
4532 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4533 {
4534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4535 kfree(cmd);
4536 return -EIO;
4537 }
4538
4539 // use default value 5 is the input is not reasonable. in unit of 10%
4540 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4541 {
4542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4543 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4544 }
4545
4546 // default is 5
4547 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4548 {
4549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4550 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4551 }
4552
4553 if (eHAL_STATUS_SUCCESS !=
4554 sme_SetTxPerTracking(pHddCtx->hHal,
4555 hdd_tx_per_hit_cb,
4556 (void*)pAdapter, &tTxPerTrackingParam)) {
4557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4558 rc = -EIO;
4559 }
4560 }
4561 else {
4562 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4563 __func__, cmd);
4564 }
4565done:
4566 /* many of the commands write information back into the command
4567 string using snprintf(). check the return value here in one
4568 place */
4569 if ((ret < 0) || (ret >= cmd_len))
4570 {
4571 /* there was an encoding error or overflow */
4572 rc = -EINVAL;
4573 }
4574 else if (ret > 0)
4575 {
4576 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4577 {
4578 hddLog(VOS_TRACE_LEVEL_ERROR,
4579 "%s: failed to copy data to user buffer", __func__);
4580 kfree(cmd);
4581 return -EFAULT;
4582 }
4583 wrqu->data.length = ret;
4584 }
4585
4586 if (ioctl_debug)
4587 {
4588 pr_info("%s: rsp [%s] len [%d] status %d\n",
4589 __func__, cmd, wrqu->data.length, rc);
4590 }
4591 kfree(cmd);
4592 EXIT();
4593 return rc;
4594}
4595
4596static int iw_set_priv(struct net_device *dev,
4597 struct iw_request_info *info,
4598 union iwreq_data *wrqu, char *extra)
4599{
4600 int ret;
4601 vos_ssr_protect(__func__);
4602 ret = __iw_set_priv(dev, info, wrqu, extra);
4603 vos_ssr_unprotect(__func__);
4604
4605 return ret;
4606}
4607
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304608static int __iw_set_nick(struct net_device *dev,
4609 struct iw_request_info *info,
4610 union iwreq_data *wrqu, char *extra)
4611{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304612 hdd_adapter_t *pAdapter;
4613 hdd_context_t *pHddCtx;
4614 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304615
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304616 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304617
4618 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4619 if (NULL == pAdapter)
4620 {
4621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4622 "%s: Adapter is NULL",__func__);
4623 return -EINVAL;
4624 }
4625
4626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4627 ret = wlan_hdd_validate_context(pHddCtx);
4628 if (0 != ret)
4629 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304630 return ret;
4631 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304632 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304633 return 0;
4634}
4635
Jeff Johnson295189b2012-06-20 16:38:30 -07004636static int iw_set_nick(struct net_device *dev,
4637 struct iw_request_info *info,
4638 union iwreq_data *wrqu, char *extra)
4639{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304640 int ret;
4641
4642 vos_ssr_protect(__func__);
4643 ret = __iw_set_nick(dev, info, wrqu, extra);
4644 vos_ssr_unprotect(__func__);
4645
4646 return ret;
4647}
4648
4649static int __iw_get_nick(struct net_device *dev,
4650 struct iw_request_info *info,
4651 union iwreq_data *wrqu, char *extra)
4652{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304653 hdd_adapter_t *pAdapter;
4654 hdd_context_t *pHddCtx;
4655 int ret = 0;
4656
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304658
4659 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4660 if (NULL == pAdapter)
4661 {
4662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4663 "%s: Adapter is NULL",__func__);
4664 return -EINVAL;
4665 }
4666
4667 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4668 ret = wlan_hdd_validate_context(pHddCtx);
4669 if (0 != ret)
4670 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304671 return ret;
4672 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304673 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 return 0;
4675}
4676
4677static int iw_get_nick(struct net_device *dev,
4678 struct iw_request_info *info,
4679 union iwreq_data *wrqu, char *extra)
4680{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304681 int ret;
4682
4683 vos_ssr_protect(__func__);
4684 ret = __iw_get_nick(dev, info, wrqu, extra);
4685 vos_ssr_unprotect(__func__);
4686
4687 return ret;
4688}
4689
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304690/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304691static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4692{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304693 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4694 hdd_context_t *pHddCtx;
4695 hdd_station_ctx_t *pHddStaCtx;
4696 v_S7_t snr = 0, rssi = 0;
4697 eHalStatus status = eHAL_STATUS_SUCCESS;
4698
4699 ENTER();
4700
4701 if (NULL == pAdapter)
4702 {
4703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4704 "%s: Adapter is NULL",__func__);
4705 return NULL;
4706 }
4707
4708 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4709 status = wlan_hdd_validate_context(pHddCtx);
4710 if (0 != status)
4711 {
4712 return NULL;
4713 }
4714
4715 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4716 if (NULL == pHddStaCtx)
4717 {
4718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4719 "%s: STA Context is NULL",__func__);
4720 return NULL;
4721 }
4722
4723 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4724 {
4725 wlan_hdd_get_station_stats(pAdapter);
4726 wlan_hdd_get_snr(pAdapter, &snr);
4727 wlan_hdd_get_rssi(pAdapter, &rssi);
4728
4729 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4730 pAdapter->iwStats.status = 0;
4731 pAdapter->iwStats.qual.qual = snr;
4732 pAdapter->iwStats.qual.level = rssi;
4733 pAdapter->iwStats.qual.noise = rssi - snr;
4734 pAdapter->iwStats.discard.code = 0;
4735 pAdapter->iwStats.discard.retries= 0;
4736 pAdapter->iwStats.miss.beacon = 0;
4737 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4738 }
4739 else
4740 {
4741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4742 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4743 return NULL;
4744 }
4745
4746 EXIT();
4747 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004748}
4749
4750static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4751{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304752
4753 struct iw_statistics *stats;
4754
4755 vos_ssr_protect(__func__);
4756 stats = __get_wireless_stats(dev);
4757 vos_ssr_unprotect(__func__);
4758
4759 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004760}
4761
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304762static int __iw_set_encode(struct net_device *dev,
4763 struct iw_request_info *info,
4764 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004765
4766{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304767 hdd_adapter_t *pAdapter;
4768 hdd_station_ctx_t *pHddStaCtx;
4769 hdd_wext_state_t *pWextState;
4770 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 struct iw_point *encoderq = &(wrqu->encoding);
4772 v_U32_t keyId;
4773 v_U8_t key_length;
4774 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4775 v_BOOL_t fKeyPresent = 0;
4776 int i;
4777 eHalStatus status = eHAL_STATUS_SUCCESS;
4778
4779
4780 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304781 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4782 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4785 "%s: Adapter is NULL",__func__);
4786 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 }
4788
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304789 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4790 status = wlan_hdd_validate_context(pHddCtx);
4791 if (0 != status)
4792 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304793 return status;
4794 }
4795 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4796 if (NULL == pWextState)
4797 {
4798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4799 "%s: pWextState is NULL ",__func__);
4800 return -EINVAL;
4801 }
4802 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4803 if (NULL == pHddStaCtx)
4804 {
4805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4806 "%s: STA Context is NULL",__func__);
4807 return -EINVAL;
4808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004809
4810 keyId = encoderq->flags & IW_ENCODE_INDEX;
4811
4812 if(keyId)
4813 {
4814 if(keyId > MAX_WEP_KEYS)
4815 {
4816 return -EINVAL;
4817 }
4818
4819 fKeyPresent = 1;
4820 keyId--;
4821 }
4822 else
4823 {
4824 fKeyPresent = 0;
4825 }
4826
4827
4828 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4829 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 if(!fKeyPresent) {
4832
4833 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4834
4835 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4836 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4837 }
4838 }
4839 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4840 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4841 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4842 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4843
4844 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4845 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4846
4847 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4848 {
4849 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4850 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004851 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304852 {
4853 long ret;
4854 ret = wait_for_completion_interruptible_timeout(
4855 &pAdapter->disconnect_comp_var,
4856 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4857 if (ret <= 0)
4858 hddLog(VOS_TRACE_LEVEL_ERROR,
4859 FL("failed wait on disconnect_comp_var %ld"), ret);
4860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 }
4862
4863 return status;
4864
4865 }
4866
4867 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4868 {
4869 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4870
4871 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4872
4873 }
4874
4875
4876 if(wrqu->data.length > 0)
4877 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004878 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879
4880 key_length = wrqu->data.length;
4881
4882 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4883
4884 if(5 == key_length)
4885 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004886 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004887
4888 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4889 {
4890 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4891 }
4892 else
4893 {
4894 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4895 }
4896 }
4897 else if(13 == key_length)
4898 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004899 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004900
4901 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4902 {
4903 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4904 }
4905 else
4906 {
4907 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4908 }
4909 }
4910 else
4911 {
4912 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004913 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 return -EINVAL;
4915 }
4916
4917 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4918 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4919 pWextState->roamProfile.EncryptionType.numEntries = 1;
4920 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4921 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4922 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4923
4924 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4925 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4926 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4927 {
4928
4929 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4930
4931 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4932 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4933
4934 return status;
4935 }
4936 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304937 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 return 0;
4939}
4940
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304941static int iw_set_encode(struct net_device *dev,
4942 struct iw_request_info *info,
4943 union iwreq_data *wrqu,char *extra)
4944{
4945 int ret;
4946
4947 vos_ssr_protect(__func__);
4948 ret = __iw_set_encode(dev, info, wrqu, extra);
4949 vos_ssr_unprotect(__func__);
4950
4951 return ret;
4952}
4953
4954static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 struct iw_request_info *info,
4956 struct iw_point *dwrq,
4957 char *extra)
4958{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304959 hdd_adapter_t *pAdapter;
4960 hdd_wext_state_t *pWextState;
4961 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 int keyId;
4963 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4964 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304965 int i, ret = 0;
4966 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967
4968 ENTER();
4969
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304970 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4971 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004972 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4974 "%s: Adapter is NULL",__func__);
4975 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004976 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4978 ret = wlan_hdd_validate_context(pHddCtx);
4979 if (0 != ret)
4980 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304981 return ret;
4982 }
4983 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4984 if (NULL == pWextState)
4985 {
4986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4987 "%s: pWextState is NULL",__func__);
4988 return -EINVAL;
4989 }
4990 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004991
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 keyId = pRoamProfile->Keys.defaultIndex;
4993
4994 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4995 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004996 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 return -EINVAL;
4998 }
4999
5000 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
5001 {
5002 dwrq->flags |= IW_ENCODE_ENABLED;
5003 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05305004 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
5005 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 }
5007 else
5008 {
5009 dwrq->flags |= IW_ENCODE_DISABLED;
5010 }
5011
5012 for(i=0; i < MAX_WEP_KEYS; i++)
5013 {
5014 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5015 {
5016 continue;
5017 }
5018 else
5019 {
5020 break;
5021 }
5022 }
5023
5024 if(MAX_WEP_KEYS == i)
5025 {
5026 dwrq->flags |= IW_ENCODE_NOKEY;
5027 }
5028 else
5029 {
5030 dwrq->flags |= IW_ENCODE_ENABLED;
5031 }
5032
5033 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5034
5035 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5036 {
5037 dwrq->flags |= IW_ENCODE_DISABLED;
5038 }
5039
5040 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5041
5042 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5043 {
5044 dwrq->flags |= IW_ENCODE_OPEN;
5045 }
5046 else
5047 {
5048 dwrq->flags |= IW_ENCODE_RESTRICTED;
5049 }
5050 EXIT();
5051 return 0;
5052
5053}
5054
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305055static int iw_get_encodeext(struct net_device *dev,
5056 struct iw_request_info *info,
5057 struct iw_point *dwrq,
5058 char *extra)
5059{
5060 int ret;
5061 vos_ssr_protect(__func__);
5062 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5063 vos_ssr_unprotect(__func__);
5064
5065 return ret;
5066}
5067
5068static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 struct iw_request_info *info,
5070 union iwreq_data *wrqu, char *extra)
5071{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305072 hdd_adapter_t *pAdapter;
5073 hdd_station_ctx_t *pHddStaCtx;
5074 hdd_wext_state_t *pWextState;
5075 hdd_context_t *pHddCtx;
5076 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005077
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305078 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 v_U32_t status = 0;
5080
5081 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5082
5083 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5084
5085 int key_index;
5086 struct iw_point *encoding = &wrqu->encoding;
5087 tCsrRoamSetKey setKey;
5088 v_U32_t roamId= 0xFF;
5089 VOS_STATUS vos_status;
5090
5091 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305092 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5093 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5096 "%s: Adapter is NULL",__func__);
5097 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305099 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5100 status = wlan_hdd_validate_context(pHddCtx);
5101 if (0 != status)
5102 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305103 return status;
5104 }
5105 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5106 if (NULL == pHddStaCtx)
5107 {
5108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5109 "%s: STA Context is NULL",__func__);
5110 return -EINVAL;
5111 }
5112 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5113 if (NULL == pWextState)
5114 {
5115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5116 "%s: pWextState is NULL",__func__);
5117 return -EINVAL;
5118 }
5119 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 key_index = encoding->flags & IW_ENCODE_INDEX;
5121
5122 if(key_index > 0) {
5123
5124 /*Convert from 1-based to 0-based keying*/
5125 key_index--;
5126 }
5127 if(!ext->key_len) {
5128
5129 /*Set the encrytion type to NONE*/
5130 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5131 return status;
5132 }
5133
5134 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5135 (IW_ENCODE_ALG_WEP == ext->alg))
5136 {
5137 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5138
Agarwal Ashish971c2882013-10-30 20:11:12 +05305139 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5140 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 return -EINVAL;
5142 }
5143 else {
5144 /*Static wep, update the roam profile with the keys */
5145 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5146 key_index < CSR_MAX_NUM_KEY) {
5147 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5148 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5149
5150 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5151 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5152
5153 }
5154 }
5155 return status;
5156 }
5157
5158 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5159
5160 setKey.keyId = key_index;
5161 setKey.keyLength = ext->key_len;
5162
5163 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5164 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5165 }
5166
5167 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5168 /*Key direction for group is RX only*/
5169 setKey.keyDirection = eSIR_RX_ONLY;
5170 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5171 }
5172 else {
5173
5174 setKey.keyDirection = eSIR_TX_RX;
5175 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5176 }
5177
5178 /*For supplicant pae role is zero*/
5179 setKey.paeRole = 0;
5180
5181 switch(ext->alg)
5182 {
5183 case IW_ENCODE_ALG_NONE:
5184 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5185 break;
5186
5187 case IW_ENCODE_ALG_WEP:
5188 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5189 break;
5190
5191 case IW_ENCODE_ALG_TKIP:
5192 {
5193 v_U8_t *pKey = &setKey.Key[0];
5194
5195 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5196
5197 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5198
5199 /*Supplicant sends the 32bytes key in this order
5200
5201 |--------------|----------|----------|
5202 | Tk1 |TX-MIC | RX Mic |
5203 |--------------|----------|----------|
5204 <---16bytes---><--8bytes--><--8bytes-->
5205
5206 */
5207 /*Sme expects the 32 bytes key to be in the below order
5208
5209 |--------------|----------|----------|
5210 | Tk1 |RX-MIC | TX Mic |
5211 |--------------|----------|----------|
5212 <---16bytes---><--8bytes--><--8bytes-->
5213 */
5214 /* Copy the Temporal Key 1 (TK1) */
5215 vos_mem_copy(pKey,ext->key,16);
5216
5217 /*Copy the rx mic first*/
5218 vos_mem_copy(&pKey[16],&ext->key[24],8);
5219
5220 /*Copy the tx mic */
5221 vos_mem_copy(&pKey[24],&ext->key[16],8);
5222
5223 }
5224 break;
5225
5226 case IW_ENCODE_ALG_CCMP:
5227 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5228 break;
5229
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005230#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005231#define IW_ENCODE_ALG_KRK 6
5232 case IW_ENCODE_ALG_KRK:
5233 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5234 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005235#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005236
5237 default:
5238 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5239 break;
5240 }
5241
5242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005243 ("%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 -07005244
5245#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305246 /* The supplicant may attempt to set the PTK once pre-authentication
5247 is done. Save the key in the UMAC and include it in the ADD
5248 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305250 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305252 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5253 "%s: Update PreAuth Key success", __func__);
5254 return 0;
5255 }
5256 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5257 {
5258 hddLog(VOS_TRACE_LEVEL_ERROR,
5259 "%s: Update PreAuth Key failed", __func__);
5260 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 }
5262#endif /* WLAN_FEATURE_VOWIFI_11R */
5263
5264 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5265
5266 vos_status = wlan_hdd_check_ula_done(pAdapter);
5267 if ( vos_status != VOS_STATUS_SUCCESS )
5268 {
5269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5270 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5271 __LINE__, vos_status );
5272
5273 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5274 }
5275
5276 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5277
5278 if ( halStatus != eHAL_STATUS_SUCCESS )
5279 {
5280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5281 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5282 __LINE__, halStatus );
5283
5284 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5285 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305286 EXIT();
5287 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005288}
5289
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305290static int iw_set_encodeext(struct net_device *dev,
5291 struct iw_request_info *info,
5292 union iwreq_data *wrqu, char *extra)
5293{
5294 int ret;
5295
5296 vos_ssr_protect(__func__);
5297 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5298 vos_ssr_unprotect(__func__);
5299
5300 return ret;
5301}
5302
5303static int __iw_set_retry(struct net_device *dev,
5304 struct iw_request_info *info,
5305 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005306{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305307 hdd_adapter_t *pAdapter;
5308 tHalHandle hHal;
5309 hdd_context_t *pHddCtx;
5310 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005311
5312 ENTER();
5313
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305314 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5315 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005316 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5318 "%s: Adapter is NULL",__func__);
5319 return -EINVAL;
5320 }
5321
5322 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5323 ret = wlan_hdd_validate_context(pHddCtx);
5324 if (0 != ret)
5325 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305326 return ret;
5327 }
5328
5329 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5330 if (NULL == hHal)
5331 {
5332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5333 "%s: Hal Context is NULL",__func__);
5334 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005335 }
5336
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5338 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5339
Arif Hussain6d2a3322013-11-17 19:50:10 -08005340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005341
5342 return -EINVAL;
5343 }
5344
5345 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5346
5347 if((wrqu->retry.flags & IW_RETRY_LONG))
5348 {
5349 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5350 {
c_hpothub8245442013-11-20 23:41:09 +05305351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5352 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 return -EIO;
5354 }
5355 }
5356 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5357 {
5358 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5359 {
c_hpothub8245442013-11-20 23:41:09 +05305360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5361 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 return -EIO;
5363 }
5364 }
5365 }
5366 else
5367 {
5368 return -EOPNOTSUPP;
5369 }
5370
Arif Hussain6d2a3322013-11-17 19:50:10 -08005371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005372
5373 EXIT();
5374
5375 return 0;
5376
5377}
5378
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305379static int iw_set_retry(struct net_device *dev,
5380 struct iw_request_info *info,
5381 union iwreq_data *wrqu, char *extra)
5382{
5383 int ret;
5384
5385 vos_ssr_protect(__func__);
5386 ret = __iw_set_retry(dev, info, wrqu, extra);
5387 vos_ssr_unprotect(__func__);
5388
5389 return ret;
5390}
5391
5392static int __iw_get_retry(struct net_device *dev,
5393 struct iw_request_info *info,
5394 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005395{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305396 hdd_adapter_t *pAdapter;
5397 hdd_context_t *pHddCtx;
5398 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305400 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005401
5402 ENTER();
5403
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305404 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5405 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005406 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5408 "%s: Adapter is NULL",__func__);
5409 return -EINVAL;
5410 }
5411
5412 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5413 ret = wlan_hdd_validate_context(pHddCtx);
5414 if (0 != ret)
5415 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305416 return ret;
5417 }
5418
5419 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5420 if (NULL == hHal)
5421 {
5422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5423 "%s: Hal Context is NULL",__func__);
5424 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005425 }
5426
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 if((wrqu->retry.flags & IW_RETRY_LONG))
5428 {
5429 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5430
5431 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5432 {
c_hpothub8245442013-11-20 23:41:09 +05305433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5434 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 return -EIO;
5436 }
5437
5438 wrqu->retry.value = retry;
5439 }
5440 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5441 {
5442 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5443
5444 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5445 {
c_hpothub8245442013-11-20 23:41:09 +05305446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5447 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 return -EIO;
5449 }
5450
5451 wrqu->retry.value = retry;
5452 }
5453 else {
5454 return -EOPNOTSUPP;
5455 }
5456
Arif Hussain6d2a3322013-11-17 19:50:10 -08005457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005458
5459 EXIT();
5460
5461 return 0;
5462}
5463
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305464static int iw_get_retry(struct net_device *dev,
5465 struct iw_request_info *info,
5466 union iwreq_data *wrqu, char *extra)
5467{
5468 int ret;
5469
5470 vos_ssr_protect(__func__);
5471 ret = __iw_get_retry(dev, info, wrqu, extra);
5472 vos_ssr_unprotect(__func__);
5473
5474 return ret;
5475}
5476
5477static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 struct iw_request_info *info,
5479 union iwreq_data *wrqu,
5480 char *extra)
5481{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305482 hdd_adapter_t *pAdapter;
5483 hdd_context_t *pHddCtx;
5484 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5486 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305487 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005488
5489 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305490 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5491 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5494 "%s:Adapter is NULL",__func__);
5495 return -EINVAL;
5496 }
5497 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5498 ret = wlan_hdd_validate_context(pHddCtx);
5499 if (0 != ret)
5500 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305501 return ret;
5502 }
5503 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5504 if (NULL == pHddStaCtx)
5505 {
5506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5507 "%s:STA context is NULL",__func__);
5508 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 }
5510
5511 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5512 switch (mlme->cmd) {
5513 case IW_MLME_DISASSOC:
5514 case IW_MLME_DEAUTH:
5515
5516 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5517 {
5518 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5519
5520 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5521 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5522
5523 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5524 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5525
Jeff Johnson43971f52012-07-17 12:26:56 -07005526 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305527 {
5528 long ret;
5529 ret = wait_for_completion_interruptible_timeout(
5530 &pAdapter->disconnect_comp_var,
5531 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5532 if (ret <= 0)
5533 hddLog(VOS_TRACE_LEVEL_ERROR,
5534 FL("failed wait on disconnect_comp_var %ld"), ret);
5535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005537 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005538 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005539
5540 /* Resetting authKeyMgmt */
5541 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5542
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305543 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 netif_tx_disable(dev);
5545 netif_carrier_off(dev);
5546
5547 }
5548 else
5549 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005550 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 -07005551 }
5552 break;
5553 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005554 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 return -EINVAL;
5556 }//end of switch
5557
5558 EXIT();
5559
5560 return status;
5561
5562}
5563
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305564static int iw_set_mlme(struct net_device *dev,
5565 struct iw_request_info *info,
5566 union iwreq_data *wrqu,
5567 char *extra)
5568{
5569 int ret;
5570
5571 vos_ssr_protect(__func__);
5572 ret = __iw_set_mlme(dev, info, wrqu, extra);
5573 vos_ssr_unprotect(__func__);
5574
5575 return ret;
5576}
5577
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305578int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305579{
5580 sHwCalValues hwCalValues;
5581 uint16 hwCalTxPower;
5582 uint8 txPwr = TX_PWR_DEF;
5583
5584 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5585
5586 if (TRUE == set_value) {
5587 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5588 NULL, sizeof(sHwCalValues) )
5589 != VOS_STATUS_SUCCESS) {
5590 return -EINVAL;
5591 }
5592 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5593
5594 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5595 hwCalTxPower, hwCalValues.calData.hwParam7);
5596
5597 txPwr = (int8)(hwCalTxPower & 0x00FF);
5598 txPwr = txPwr/10;
5599 if (txPwr < TX_PWR_MIN)
5600 txPwr = TX_PWR_MIN;
5601 if (txPwr > TX_PWR_MAX)
5602 txPwr = TX_PWR_MAX;
5603
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305604 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305605 eHAL_STATUS_SUCCESS) {
5606 hddLog(VOS_TRACE_LEVEL_ERROR,
5607 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5608 return -EIO;
5609 }
5610
5611 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5612 txPwr /= 10;
5613 if (txPwr < TX_PWR_MIN)
5614 txPwr = TX_PWR_MIN;
5615 if (txPwr > TX_PWR_MAX)
5616 txPwr = TX_PWR_MAX;
5617
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305618 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305619 eHAL_STATUS_SUCCESS) {
5620 hddLog(VOS_TRACE_LEVEL_ERROR,
5621 FL("setting tx power failed for 5GHz band %d"), txPwr);
5622 return -EIO;
5623 }
5624 }
5625 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305626 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305627 eHAL_STATUS_SUCCESS) {
5628 hddLog(VOS_TRACE_LEVEL_ERROR,
5629 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5630 return -EIO;
5631 }
5632
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305633 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305634 eHAL_STATUS_SUCCESS) {
5635 hddLog(VOS_TRACE_LEVEL_ERROR,
5636 FL("setting tx power failed for 5GHz band %d"), txPwr);
5637 return -EIO;
5638 }
5639 }
5640 else {
5641 return -EINVAL;
5642 }
5643
5644 return eHAL_STATUS_SUCCESS;
5645}
Jeff Johnson295189b2012-06-20 16:38:30 -07005646/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305647static int __iw_setint_getnone(struct net_device *dev,
5648 struct iw_request_info *info,
5649 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005650{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305651 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305652 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305653 hdd_wext_state_t *pWextState;
5654 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305655 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 int *value = (int *)extra;
5657 int sub_cmd = value[0];
5658 int set_value = value[1];
5659 int ret = 0; /* success */
5660 int enable_pbm, enable_mp;
5661#ifdef CONFIG_HAS_EARLYSUSPEND
5662 v_U8_t nEnableSuspendOld;
5663#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005664
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305665 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5667 if (NULL == pAdapter)
5668 {
5669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5670 "%s: Adapter is NULL",__func__);
5671 return -EINVAL;
5672 }
5673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5674 ret = wlan_hdd_validate_context(pHddCtx);
5675 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005676 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305677 return ret;
5678 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305679
Katya Nigameae74b62015-05-28 17:19:16 +05305680 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305681 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305682 /* In monitor mode hHal is NULL */
5683 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5684 if (NULL == hHal)
5685 {
5686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5687 "%s: Hal Context is NULL",__func__);
5688 return -EINVAL;
5689 }
Katya Nigameae74b62015-05-28 17:19:16 +05305690 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5691 if (NULL == pWextState)
5692 {
5693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5694 "%s: pWextState is NULL",__func__);
5695 return -EINVAL;
5696 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005697
Katya Nigameae74b62015-05-28 17:19:16 +05305698 INIT_COMPLETION(pWextState->completion_var);
5699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 switch(sub_cmd)
5701 {
5702 case WE_SET_11D_STATE:
5703 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005704 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005705 memset(&smeConfig, 0x00, sizeof(smeConfig));
5706
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305707 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5708 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 sme_GetConfigParam(hHal,&smeConfig);
5710 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5711
Arif Hussain6d2a3322013-11-17 19:50:10 -08005712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005713
5714 sme_UpdateConfig(hHal,&smeConfig);
5715 }
5716 else {
5717 return -EINVAL;
5718 }
5719 break;
5720 }
5721
5722 case WE_WOWL:
5723 {
5724 switch (set_value)
5725 {
5726 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305727 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 break;
5729 case 0x01:
5730 case 0x02:
5731 case 0x03:
5732 enable_mp = (set_value & 0x01) ? 1 : 0;
5733 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005734 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5736 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5737 break;
5738 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005739 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 ret = -EINVAL;
5741 break;
5742 }
5743
5744 break;
5745 }
5746 case WE_SET_POWER:
5747 {
5748 switch (set_value)
5749 {
5750 case 0: //Full Power
5751 {
5752 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305753 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754
5755 init_completion(&context.completion);
5756
5757 context.pAdapter = pAdapter;
5758 context.magic = POWER_CONTEXT_MAGIC;
5759
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305760 if (NULL == hHal)
5761 return -EINVAL;
5762
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5764 iw_power_callback_fn, &context,
5765 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305766
Jeff Johnson72a40512013-12-19 10:14:15 -08005767 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 {
5769 int lrc = wait_for_completion_interruptible_timeout(
5770 &context.completion,
5771 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005772
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 if (lrc <= 0)
5774 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005775 hddLog(VOS_TRACE_LEVEL_ERROR,
5776 "%s: SME %s while requesting fullpower",
5777 __func__, (0 == lrc) ?
5778 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 }
5780 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005781 /* either we have a response or we timed out. if we timed
5782 out there is a race condition such that the callback
5783 function could be executing at the same time we are. of
5784 primary concern is if the callback function had already
5785 verified the "magic" but had not yet set the completion
5786 variable when a timeout occurred. we serialize these
5787 activities by invalidating the magic while holding a
5788 shared spinlock which will cause us to block if the
5789 callback is currently executing */
5790 spin_lock(&hdd_context_lock);
5791 context.magic = 0;
5792 spin_unlock(&hdd_context_lock);
5793
Arif Hussain6d2a3322013-11-17 19:50:10 -08005794 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 break;
5796 }
5797 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305798 if (hHal)
5799 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5800 else
5801 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 break;
5803 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305804 if (hHal)
5805 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5806 else
5807 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 break;
5809 case 3: //Request Bmps
5810 {
5811 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305812 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005813
5814 init_completion(&context.completion);
5815
5816 context.pAdapter = pAdapter;
5817 context.magic = POWER_CONTEXT_MAGIC;
5818
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305819 if (NULL == hHal)
5820 return -EINVAL;
5821
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305823 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005824 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 {
5826 int lrc = wait_for_completion_interruptible_timeout(
5827 &context.completion,
5828 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 if (lrc <= 0)
5830 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005831 hddLog(VOS_TRACE_LEVEL_ERROR,
5832 "%s: SME %s while requesting BMPS",
5833 __func__, (0 == lrc) ? "timeout" :
5834 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 }
5836 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005837 /* either we have a response or we timed out. if we
5838 timed out there is a race condition such that the
5839 callback function could be executing at the same
5840 time we are. of primary concern is if the callback
5841 function had already verified the "magic" but had
5842 not yet set the completion variable when a timeout
5843 occurred. we serialize these activities by
5844 invalidating the magic while holding a shared
5845 spinlock which will cause us to block if the
5846 callback is currently executing */
5847 spin_lock(&hdd_context_lock);
5848 context.magic = 0;
5849 spin_unlock(&hdd_context_lock);
5850
Arif Hussain6d2a3322013-11-17 19:50:10 -08005851 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 break;
5853 }
5854 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305855 if (hHal)
5856 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5857 else
5858 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 break;
5860 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305861 if (hHal)
5862 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5863 else
5864 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 break;
5866 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305867 if (hHal)
5868 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5869 else
5870 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 break;
5872 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305873 if (hHal)
5874 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5875 else
5876 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 break;
5878 case 8: //Request Standby
5879#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005880#endif
5881 break;
5882 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305883 if (hHal)
5884 sme_StartAutoBmpsTimer(hHal);
5885 else
5886 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 break;
5888 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305889 if (hHal)
5890 sme_StopAutoBmpsTimer(hHal);
5891 else
5892 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 break;
5894#ifdef CONFIG_HAS_EARLYSUSPEND
5895 case 11://suspend to standby
5896#ifdef CONFIG_HAS_EARLYSUSPEND
5897 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5898 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5900#endif
5901 break;
5902 case 12://suspend to deep sleep
5903#ifdef CONFIG_HAS_EARLYSUSPEND
5904 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5905 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5907#endif
5908 break;
5909 case 13://resume from suspend
5910#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005911#endif
5912 break;
5913#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005915 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 ret = -EINVAL;
5917 break;
5918 }
5919 break;
5920 }
5921
5922 case WE_SET_MAX_ASSOC:
5923 {
5924 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305925 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5926 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 {
5928 ret = -EINVAL;
5929 }
5930 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5931 set_value, NULL, eANI_BOOLEAN_FALSE)
5932 != eHAL_STATUS_SUCCESS )
5933 {
c_hpothub8245442013-11-20 23:41:09 +05305934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5935 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 ret = -EIO;
5937 }
5938 break;
5939 }
5940
5941 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5942 {
5943 if( 0 == set_value )
5944 {
5945 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5946 }
5947 else if ( 1 == set_value )
5948 {
5949 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5950 }
5951 else
5952 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005953 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 ret = -EINVAL;
5955 }
5956 break;
5957 }
5958
5959 case WE_SET_DATA_INACTIVITY_TO:
5960 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305961 if (NULL == hHal)
5962 return -EINVAL;
5963
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5965 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5966 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5967 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5968 set_value,
5969 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5970 {
5971 hddLog(LOGE,"Failure: Could not pass on "
5972 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005973 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 ret = -EINVAL;
5975 }
5976 break;
5977 }
5978 case WE_SET_MAX_TX_POWER:
5979 {
5980 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5981 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5982
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305983 if (NULL == hHal)
5984 return -EINVAL;
5985
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5987 __func__, set_value);
5988 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5989 eHAL_STATUS_SUCCESS )
5990 {
5991 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5992 __func__);
5993 return -EIO;
5994 }
5995
5996 break;
5997 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005998 case WE_SET_MAX_TX_POWER_2_4:
5999 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306000 if (NULL == hHal)
6001 return -EINVAL;
6002
Arif Hussaina5ebce02013-08-09 15:09:58 -07006003 hddLog(VOS_TRACE_LEVEL_INFO,
6004 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6005 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306006 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006007 eHAL_STATUS_SUCCESS)
6008 {
6009 hddLog(VOS_TRACE_LEVEL_ERROR,
6010 "%s: Setting maximum tx power failed for 2.4 GHz band",
6011 __func__);
6012 return -EIO;
6013 }
6014
6015 break;
6016 }
6017 case WE_SET_MAX_TX_POWER_5_0:
6018 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306019 if (NULL == hHal)
6020 return -EINVAL;
6021
Arif Hussaina5ebce02013-08-09 15:09:58 -07006022 hddLog(VOS_TRACE_LEVEL_INFO,
6023 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6024 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306025 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006026 eHAL_STATUS_SUCCESS)
6027 {
6028 hddLog(VOS_TRACE_LEVEL_ERROR,
6029 "%s: Setting maximum tx power failed for 5.0 GHz band",
6030 __func__);
6031 return -EIO;
6032 }
6033
6034 break;
6035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 case WE_SET_HIGHER_DTIM_TRANSITION:
6037 {
6038 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6039 (set_value == eANI_BOOLEAN_TRUE)))
6040 {
6041 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6042 ret = -EINVAL;
6043 }
6044 else
6045 {
6046 if(pAdapter->higherDtimTransition != set_value)
6047 {
6048 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006049 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 }
6051 }
6052
6053 break;
6054 }
6055
6056 case WE_SET_TM_LEVEL:
6057 {
6058 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006059 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6061
6062 break;
6063 }
6064
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306065 case WE_ENABLE_STRICT_FCC_REG:
6066 {
6067 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6068 struct wiphy *wiphy = NULL;
6069 long lrc;
6070 int status;
6071
6072 wiphy = hddCtxt->wiphy;
6073 if(wiphy == NULL)
6074 {
6075 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6076 break;
6077 }
6078 init_completion(&hddCtxt->wiphy_channel_update_event);
6079
6080 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6081
6082 status = regulatory_hint(wiphy, "00");
6083 if(status < 0)
6084 {
6085 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6086 break;
6087 }
6088
6089 /* Wait for completion */
6090 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6091 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6092 if (lrc <= 0)
6093 {
6094 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6095 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6096 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6097 }
6098 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6099
6100 break;
6101 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006102 case WE_SET_DEBUG_LOG:
6103 {
6104 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6105 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306106 if (hHal)
6107 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6108 else
6109 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006110 break;
6111 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306112#ifdef FEATURE_WLAN_TDLS
6113 case WE_SET_TDLS_OFF_CHAN:
6114 {
6115 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6117 __func__, set_value);
6118 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6119 break;
6120 }
6121 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6122 {
6123 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6125 __func__, set_value);
6126 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6127 break;
6128 }
6129 case WE_SET_TDLS_OFF_CHAN_MODE:
6130 {
6131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6132 __func__, set_value);
6133 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6134 break;
6135 }
6136#endif
Peng Xu2446a892014-09-05 17:21:18 +05306137 case WE_SET_SCAN_BAND_PREFERENCE:
6138 {
6139 tSmeConfigParams smeConfig;
6140 memset(&smeConfig, 0x00, sizeof(smeConfig));
6141 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6142 ret = -EINVAL;
6143 break;
6144 }
6145 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6146
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306147 if ((eCSR_BAND_ALL == set_value ||
6148 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6149 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306150 sme_GetConfigParam(hHal, &smeConfig);
6151 smeConfig.csrConfig.scanBandPreference = set_value;
6152
6153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6154 "set band scan preference = %d\n",
6155 smeConfig.csrConfig.scanBandPreference);
6156
6157 sme_UpdateConfig(hHal, &smeConfig);
6158 }
6159 else {
6160 ret = -EINVAL;
6161 }
6162 break;
6163 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306164 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6165 * connection happens so that the params can take effect during
6166 * association. Also this should not be used in STA+p2p concurrency
6167 * as the param will also effect the STA mode.
6168 */
6169 case WE_SET_MIRACAST_VENDOR_CONFIG:
6170 {
6171 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306172
Abhishek Singh01c73d12015-03-12 15:13:44 +05306173 hddLog(LOG1, FL(
6174 "Set Miracast vendor tuning %d"), set_value);
6175
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306176 if (NULL == hHal)
6177 return -EINVAL;
6178
Abhishek Singh01c73d12015-03-12 15:13:44 +05306179 if (1 == set_value || 0 == set_value)
6180 {
6181 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6182 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6183 {
6184 hddLog( LOGE, FL("set vendor miracast config failed"));
6185 ret = -EIO;
6186 }
6187 }
6188 else
6189 {
6190 hddLog(LOGE,
6191 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6192 ret = -EINVAL;
6193 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306194 break;
6195 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306196
6197 case WE_GET_FRAME_LOG:
6198 {
6199 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6200 != VOS_STATUS_SUCCESS)
6201 {
6202 ret = -EINVAL;
6203 }
6204 break;
6205 }
6206
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306207 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6208 {
6209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6210 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306211 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306212 {
6213 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6214 set_value);
6215 }
6216 else
6217 ret = -EINVAL;
6218
6219 break;
6220 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306221 /* Bit mask value to enable RTS/CTS for different modes
6222 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6223 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6224 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6225 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6226 * for 5 GHz, VHT80 - 0x1000
6227 */
6228 case WE_SET_RTS_CTS_HTVHT:
6229 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306230
Abhishek Singh41988ba2015-05-25 19:42:29 +05306231 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6232
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306233 if (NULL == hHal)
6234 return -EINVAL;
6235
Abhishek Singh41988ba2015-05-25 19:42:29 +05306236 if (eHAL_STATUS_SUCCESS !=
6237 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6238 {
6239 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6240 ret = -EINVAL;
6241 }
6242 break;
6243 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306244 case WE_SET_MONITOR_STATE:
6245 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306246 v_U32_t magic = 0;
6247 struct completion cmpVar;
6248 long waitRet = 0;
6249 tVOS_CON_MODE mode = hdd_get_conparam();
6250
6251 if( VOS_MONITOR_MODE != mode)
6252 {
6253 hddLog(LOGE, "invalid mode %d", mode);
6254 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306255 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306256 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306257
6258 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6259 if( pMonCtx == NULL )
6260 {
6261 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306262 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306263 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306264 }
6265 if (pMonCtx->state == set_value)
6266 {
6267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6268 FL("already in same mode curr_mode:%d req_mode: %d"),
6269 pMonCtx->state, set_value);
6270 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306271 }
6272 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306273 magic = MON_MODE_MSG_MAGIC;
6274 init_completion(&cmpVar);
6275 if (VOS_STATUS_SUCCESS !=
6276 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6277 pMonCtx, hdd_monPostMsgCb)) {
6278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6279 FL("failed to post MON MODE REQ"));
6280 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6281 MON_MODE_STOP : MON_MODE_START;
6282 magic = 0;
6283 ret = -EIO;
6284 break;
6285 }
6286 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6287 magic = 0;
6288 if (waitRet <= 0 ){
6289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6290 FL("failed to wait on monitor mode completion %ld"),
6291 waitRet);
6292 }
6293 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306294 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306295 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6296 {
6297 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6298 tAniWifiStartLog start_log;
6299 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6300 !vos_isPktStatsEnabled())
6301 {
6302 hddLog(LOGE, FL("per pkt stats not enabled"));
6303 return -EINVAL;
6304 }
6305 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6306
6307 if (1 == set_value || 0 == set_value)
6308 {
6309 start_log.ringId = RING_ID_PER_PACKET_STATS;
6310 start_log.flag = 0;
6311 if (set_value)
6312 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6313 else
6314 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6315
6316 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6317 }
6318 else
6319 {
6320 hddLog(LOGE,
6321 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6322 set_value);
6323 ret = -EINVAL;
6324 }
6325 break;
6326 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306327 case WE_SET_PROXIMITY_ENABLE:
6328 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306329 if (NULL == hHal)
6330 return -EINVAL;
6331
6332 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306333 break;
6334 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306335 case WE_CAP_TSF:
6336 {
6337 if (NULL == hHal)
6338 return -EINVAL;
6339
6340 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6341 break;
6342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 default:
6344 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006345 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 sub_cmd, set_value);
6347 break;
6348 }
6349 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306350 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 return ret;
6352}
6353
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306354static int iw_setint_getnone(struct net_device *dev,
6355 struct iw_request_info *info,
6356 union iwreq_data *wrqu, char *extra)
6357{
6358 int ret;
6359
6360 vos_ssr_protect(__func__);
6361 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6362 vos_ssr_unprotect(__func__);
6363
6364 return 0;
6365}
Jeff Johnson295189b2012-06-20 16:38:30 -07006366/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306367static int __iw_setchar_getnone(struct net_device *dev,
6368 struct iw_request_info *info,
6369 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006370{
6371 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306372 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006374 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306375 hdd_adapter_t *pAdapter;
6376 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006377#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306378 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006379#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306380 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306381 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006382
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306383 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306384
6385 if (!capable(CAP_NET_ADMIN))
6386 {
6387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6388 FL("permission check failed"));
6389 return -EPERM;
6390 }
6391
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306392 pAdapter = (netdev_priv(dev));
6393 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006394 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6396 "%s: Adapter is NULL",__func__);
6397 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006398 }
6399
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6401 ret = wlan_hdd_validate_context(pHddCtx);
6402 if (0 != ret)
6403 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306404 return ret;
6405 }
6406#ifdef WLAN_FEATURE_VOWIFI
6407 pConfig = pHddCtx->cfg_ini;
6408#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306409 /* helper function to get iwreq_data with compat handling. */
6410 if (hdd_priv_get_data(&s_priv_data, wrqu))
6411 {
6412 return -EINVAL;
6413 }
6414
6415 /* make sure all params are correctly passed to function */
6416 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6417 {
6418 return -EINVAL;
6419 }
6420
6421 sub_cmd = s_priv_data.flags;
6422
Arif Hussain0273cba2014-01-07 20:58:29 -08006423 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306424 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6425 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006426 if (NULL == pBuffer)
6427 {
6428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6429 "mem_alloc_copy_from_user_helper fail");
6430 return -ENOMEM;
6431 }
6432
6433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306434 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6436 "%s: Received data %s", __func__, pBuffer);
6437
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 switch(sub_cmd)
6439 {
6440 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006442 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 break;
6444 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006446 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 break;
6448#if defined WLAN_FEATURE_VOWIFI
6449 case WE_NEIGHBOR_REPORT_REQUEST:
6450 {
6451 tRrmNeighborReq neighborReq;
6452 tRrmNeighborRspCallbackInfo callbackInfo;
6453
6454 if (pConfig->fRrmEnable)
6455 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306457 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 if( !neighborReq.no_ssid )
6459 {
Girish Gowli552fc072014-06-14 18:26:16 +05306460 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006461 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 }
6463
6464 callbackInfo.neighborRspCallback = NULL;
6465 callbackInfo.neighborRspCallbackContext = NULL;
6466 callbackInfo.timeout = 5000; //5 seconds
6467 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6468 }
6469 else
6470 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006471 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 ret = -EINVAL;
6473 }
6474 }
6475 break;
6476#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 case WE_SET_AP_WPS_IE:
6478 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306479 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006482 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 if (VOS_STATUS_SUCCESS != vstatus)
6484 {
6485 ret = -EINVAL;
6486 }
6487 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306488 case WE_SET_ENCRYPT_MSG:
6489 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6490 if (NULL == pkt)
6491 {
6492 hddLog(VOS_TRACE_LEVEL_ERROR,
6493 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306494 ret = -ENOMEM;
6495 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306496 }
6497
6498 memset(pkt, 0, sizeof(tSirpkt80211));
6499
6500 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6501 hddLog(VOS_TRACE_LEVEL_ERROR,
6502 FL("Firmware is not DISA capable"));
6503 ret = -EINVAL;
6504 vos_mem_free(pkt);
6505 break;
6506 }
6507
6508 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6509
6510 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6511 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6512 if (eHAL_STATUS_SUCCESS != ret) {
6513 hddLog(VOS_TRACE_LEVEL_ERROR,
6514 FL("SENDEncryptMSG: fail to post WDA cmd"));
6515 ret = -EINVAL;
6516 }
6517 vos_mem_free(pkt);
6518
6519 break;
6520
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 default:
6522 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006523 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 ret = -EINVAL;
6525 break;
6526 }
6527 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006528 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306529
6530 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 return ret;
6532}
6533
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306534static int iw_setchar_getnone(struct net_device *dev,
6535 struct iw_request_info *info,
6536 union iwreq_data *wrqu, char *extra)
6537{
6538 int ret;
6539
6540 vos_ssr_protect(__func__);
6541 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6542 vos_ssr_unprotect(__func__);
6543
6544 return ret;
6545}
6546
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306547static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6548{
6549 struct statsContext *context;
6550 hdd_adapter_t *pAdapter;
6551
6552 if (NULL == pContext)
6553 {
6554 hddLog(VOS_TRACE_LEVEL_ERROR,
6555 "%s: Bad param, pContext [%p]",
6556 __func__, pContext);
6557 return;
6558 }
6559
6560 context = pContext;
6561 pAdapter = context->pAdapter;
6562
6563 spin_lock(&hdd_context_lock);
6564
6565 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6566 {
6567 /* the caller presumably timed out so there is nothing we can do */
6568 spin_unlock(&hdd_context_lock);
6569 hddLog(VOS_TRACE_LEVEL_WARN,
6570 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6571 __func__, pAdapter, context->magic);
6572 return;
6573 }
6574
6575 context->magic = 0;
6576 pAdapter->antennaIndex = antennaId;
6577
6578 complete(&context->completion);
6579 spin_unlock(&hdd_context_lock);
6580}
6581
6582static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6583 int *antennaIndex)
6584{
6585 hdd_context_t *pHddCtx;
6586 eHalStatus halStatus;
6587 struct statsContext context;
6588 long lrc;
6589
6590 ENTER();
6591 if (NULL == pAdapter)
6592 {
6593 hddLog(VOS_TRACE_LEVEL_WARN,
6594 "%s: Invalid context, pAdapter", __func__);
6595 return VOS_STATUS_E_FAULT;
6596 }
6597 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6598 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6599 {
6600 return VOS_STATUS_E_FAULT;
6601 }
6602 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6603 {
6604 hddLog(VOS_TRACE_LEVEL_ERROR,
6605 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6606 __func__);
6607 return VOS_STATUS_E_NOSUPPORT;
6608 }
6609 init_completion(&context.completion);
6610 context.pAdapter = pAdapter;
6611 context.magic = ANTENNA_CONTEXT_MAGIC;
6612
6613 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6614 hdd_GetCurrentAntennaIndex,
6615 &context, pAdapter->sessionId);
6616 if (eHAL_STATUS_SUCCESS != halStatus)
6617 {
6618 spin_lock(&hdd_context_lock);
6619 context.magic = 0;
6620 spin_unlock(&hdd_context_lock);
6621 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6622 __func__);
6623 /* we'll returned a cached value below */
6624 *antennaIndex = -1;
6625 return VOS_STATUS_E_FAILURE;
6626 }
6627 else
6628 {
6629 /* request was sent -- wait for the response */
6630 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6631 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6632 if (lrc <= 0)
6633 {
6634 spin_lock(&hdd_context_lock);
6635 context.magic = 0;
6636 spin_unlock(&hdd_context_lock);
6637 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6638 " Index",
6639 __func__, (0 == lrc) ? "timeout" : "interrupt");
6640 *antennaIndex = -1;
6641 return VOS_STATUS_E_FAILURE;
6642 }
6643 }
6644 spin_lock(&hdd_context_lock);
6645 context.magic = 0;
6646 spin_unlock(&hdd_context_lock);
6647
6648 *antennaIndex = pAdapter->antennaIndex;
6649
6650 EXIT();
6651 return VOS_STATUS_SUCCESS;
6652}
6653
Jeff Johnson295189b2012-06-20 16:38:30 -07006654/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306655static int __iw_setnone_getint(struct net_device *dev,
6656 struct iw_request_info *info,
6657 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006658{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306659 hdd_adapter_t *pAdapter;
6660 tHalHandle hHal;
6661 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 int *value = (int *)extra;
6663 int ret = 0; /* success */
6664
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306665 ENTER();
6666
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306667 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6668 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006669 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6671 "%s: Adapter is NULL",__func__);
6672 return -EINVAL;
6673 }
6674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6675 ret = wlan_hdd_validate_context(pHddCtx);
6676 if (0 != ret)
6677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306678 return ret;
6679 }
6680 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6681 if (NULL == hHal)
6682 {
6683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6684 "%s: Hal Context is NULL",__func__);
6685 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006687
6688 switch (value[0])
6689 {
6690 case WE_GET_11D_STATE:
6691 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006692 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306694
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6696
Arif Hussain6d2a3322013-11-17 19:50:10 -08006697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006698
6699 break;
6700 }
6701
6702 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 break;
6705
6706 case WE_PMC_STATE:
6707 {
6708 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 break;
6711 }
6712 case WE_GET_WLAN_DBG:
6713 {
6714 vos_trace_display();
6715 *value = 0;
6716 break;
6717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 case WE_GET_MAX_ASSOC:
6719 {
6720 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6721 {
c_hpothub8245442013-11-20 23:41:09 +05306722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6723 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 ret = -EIO;
6725 }
Girish Gowli385be612014-09-18 11:17:20 +05306726#ifdef WLAN_SOFTAP_VSTA_FEATURE
6727 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6728 {
6729 if (*value > VSTA_NUM_ASSOC_STA)
6730 {
6731 *value = VSTA_NUM_ASSOC_STA;
6732 }
6733 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6734 (*value > (VSTA_NUM_ASSOC_STA -
6735 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6736 {
6737 *value = (VSTA_NUM_ASSOC_STA -
6738 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6739 }
6740 }
6741 else
6742#endif
6743 {
6744 if (*value > NUM_ASSOC_STA)
6745 {
6746 *value = NUM_ASSOC_STA;
6747 }
6748 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6749 (*value > (NUM_ASSOC_STA -
6750 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6751 {
6752 *value = (NUM_ASSOC_STA -
6753 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6754 }
6755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 break;
6757 }
6758
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 case WE_GET_WDI_DBG:
6760 {
6761 wpalTraceDisplay();
6762 *value = 0;
6763 break;
6764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006765
6766 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6767 {
6768 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6769 break;
6770 }
6771 case WE_GET_CONCURRENCY_MODE:
6772 {
6773 *value = hdd_get_concurrency_mode ( );
6774
Arif Hussain6d2a3322013-11-17 19:50:10 -08006775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 break;
6777 }
6778
Peng Xu2446a892014-09-05 17:21:18 +05306779 case WE_GET_SCAN_BAND_PREFERENCE:
6780 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306781 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306782 sme_GetConfigParam(hHal, &smeConfig);
6783 *value = smeConfig.csrConfig.scanBandPreference;
6784
6785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6786 "scanBandPreference = %d\n", *value);
6787 break;
6788 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306789 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6790 {
6791 wlan_hdd_get_current_antenna_index(pAdapter, value);
6792 break;
6793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 default:
6795 {
6796 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6797 break;
6798 }
6799 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306800 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 return ret;
6802}
6803
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306804static int iw_setnone_getint(struct net_device *dev,
6805 struct iw_request_info *info,
6806 union iwreq_data *wrqu, char *extra)
6807{
6808 int ret;
6809
6810 vos_ssr_protect(__func__);
6811 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6812 vos_ssr_unprotect(__func__);
6813
6814 return ret;
6815
6816}
Jeff Johnson295189b2012-06-20 16:38:30 -07006817/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306818int __iw_set_three_ints_getnone(struct net_device *dev,
6819 struct iw_request_info *info,
6820 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006821{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306822 hdd_adapter_t *pAdapter;
6823 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 int *value = (int *)extra;
6825 int sub_cmd = value[0];
6826 int ret = 0;
6827
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306828 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306829
6830 if (!capable(CAP_NET_ADMIN))
6831 {
6832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6833 FL("permission check failed"));
6834 return -EPERM;
6835 }
6836
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306837 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6838 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006839 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6841 "%s: Adapter is NULL",__func__);
6842 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006843 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306844 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6845 ret = wlan_hdd_validate_context(pHddCtx);
6846 if (0 != ret)
6847 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306848 return ret;
6849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 switch(sub_cmd)
6851 {
6852 case WE_SET_WLAN_DBG:
6853 {
6854 vos_trace_setValue( value[1], value[2], value[3]);
6855 break;
6856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 case WE_SET_WDI_DBG:
6858 {
6859 wpalTraceSetLevel( value[1], value[2], value[3]);
6860 break;
6861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 case WE_SET_SAP_CHANNELS:
6863 {
6864 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6865 break;
6866 }
6867
6868 default:
6869 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006870 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 break;
6872 }
6873 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306874 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 return ret;
6876}
6877
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306878int iw_set_three_ints_getnone(struct net_device *dev,
6879 struct iw_request_info *info,
6880 union iwreq_data *wrqu, char *extra)
6881{
6882 int ret;
6883
6884 vos_ssr_protect(__func__);
6885 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6886 vos_ssr_unprotect(__func__);
6887
6888 return ret;
6889}
6890
6891static int __iw_get_char_setnone(struct net_device *dev,
6892 struct iw_request_info *info,
6893 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006894{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306895 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306897 hdd_context_t *pHddCtx;
6898 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006899#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006900 hdd_wext_state_t *pWextState;
6901#endif
6902
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306903 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306904 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006905 if (pAdapter == NULL)
6906 {
6907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6908 "%s: pAdapter is NULL!", __func__);
6909 return -EINVAL;
6910 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6912 ret = wlan_hdd_validate_context(pHddCtx);
6913 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006914 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306915 return ret;
6916 }
6917#ifdef WLAN_FEATURE_11W
6918 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6919 if (NULL == pWextState)
6920 {
6921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6922 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006923 return -EINVAL;
6924 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306925#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006926
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 switch(sub_cmd)
6928 {
6929 case WE_WLAN_VERSION:
6930 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006931 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 break;
6933 }
6934
6935 case WE_GET_STATS:
6936 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306937 tHalHandle hHal = NULL;
6938 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6940 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6941 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6942
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306943
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 snprintf(extra, WE_MAX_STR_LEN,
6945 "\nTransmit"
6946 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6947 "\n dropped BK %u, BE %u, VI %u, VO %u"
6948 "\n classified BK %u, BE %u, VI %u, VO %u"
6949 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6950 "\n queued BK %u, BE %u, VI %u, VO %u"
6951 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006952 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 "\n fetched BK %u, BE %u, VI %u, VO %u"
6954 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6955 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006956 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 "\n flushed BK %u, BE %u, VI %u, VO %u"
6958 "\n\nReceive"
6959 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6960 "\n\nResetsStats"
6961 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6962 "\n",
6963 pStats->txXmitCalled,
6964 pStats->txXmitDropped,
6965 pStats->txXmitBackPressured,
6966 pStats->txXmitQueued,
6967
6968 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6969 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6970 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6971 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6972
6973 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6974 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6975 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6976 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6977
6978 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6979 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6980 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6981 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6982
6983 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6984 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6985 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6986 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6987
6988 pStats->txFetched,
6989 pStats->txFetchEmpty,
6990 pStats->txFetchLowResources,
6991 pStats->txFetchDequeueError,
6992
6993 pStats->txFetchDequeued,
6994 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006995 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 pStats->txCompleted,
6997 pStats->txFlushed,
6998
6999 pStats->txFetchedAC[WLANTL_AC_BK],
7000 pStats->txFetchedAC[WLANTL_AC_BE],
7001 pStats->txFetchedAC[WLANTL_AC_VI],
7002 pStats->txFetchedAC[WLANTL_AC_VO],
7003
7004 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7005 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7006 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7007 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7008
7009 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7010 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7011 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7012 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7013
Ravi Joshi41914632013-10-21 23:02:21 -07007014 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7015 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7016 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7017 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7018
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 pStats->txFlushedAC[WLANTL_AC_BK],
7020 pStats->txFlushedAC[WLANTL_AC_BE],
7021 pStats->txFlushedAC[WLANTL_AC_VI],
7022 pStats->txFlushedAC[WLANTL_AC_VO],
7023
7024 pStats->rxChains,
7025 pStats->rxPackets,
7026 pStats->rxDropped,
7027 pStats->rxDelivered,
7028 pStats->rxRefused,
7029
7030 pResetStats->totalLogpResets,
7031 pResetStats->totalCMD53Failures,
7032 pResetStats->totalMutexReadFailures,
7033 pResetStats->totalMIFErrorFailures,
7034 pResetStats->totalFWHearbeatFailures,
7035 pResetStats->totalUnknownExceptions
7036 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307037 wrqu->data.length = strlen(extra);
7038
7039 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7040
7041 if (hHal)
7042 pMac = PMAC_STRUCT( hHal );
7043
7044 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7045 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7046 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307047 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7048 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7049 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7050 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307051 "\n",
7052 pMac->pmm.BmpscntSleep,
7053 pMac->pmm.BmpscntAwake,
7054 pMac->pmm.BmpsSleeReqFailCnt,
7055 pMac->pmm.BmpsWakeupReqFailCnt,
7056 pMac->pmm.ImpsCntSleep,
7057 pMac->pmm.ImpsCntAwake,
7058 pMac->pmm.ImpsSleepErrCnt,
7059 pMac->pmm.ImpsWakeupErrCnt,
7060 pMac->pmm.ImpsLastErr
7061 );
7062 }
7063
Jeff Johnson295189b2012-06-20 16:38:30 -07007064 wrqu->data.length = strlen(extra)+1;
7065 break;
7066 }
7067
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307068/* The case prints the current state of the HDD, SME, CSR, PE, TL
7069 *it can be extended for WDI Global State as well.
7070 *And currently it only checks P2P_CLIENT adapter.
7071 *P2P_DEVICE and P2P_GO have not been added as of now.
7072*/
7073 case WE_GET_STATES:
7074 {
7075 int buf = 0, len = 0;
7076 int adapter_num = 0;
7077 int count = 0, check = 1;
7078
7079 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007080 tHalHandle hHal = NULL;
7081 tpAniSirGlobal pMac = NULL;
7082 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307083
7084 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7085 hdd_adapter_t *useAdapter = NULL;
7086
7087 /* Print wlan0 or p2p0 states based on the adapter_num
7088 *by using the correct adapter
7089 */
7090 while ( adapter_num < 2 )
7091 {
7092 if ( WLAN_ADAPTER == adapter_num )
7093 {
7094 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007095 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307096 "\n\n wlan0 States:-");
7097 len += buf;
7098 }
7099 else if ( P2P_ADAPTER == adapter_num )
7100 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007101 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307102 "\n\n p2p0 States:-");
7103 len += buf;
7104
7105 if( !pHddCtx )
7106 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007107 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307108 "\n pHddCtx is NULL");
7109 len += buf;
7110 break;
7111 }
7112
7113 /*Printing p2p0 states only in the case when the device is
7114 configured as a p2p_client*/
7115 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7116 if ( !useAdapter )
7117 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007118 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307119 "\n Device not configured as P2P_CLIENT.");
7120 len += buf;
7121 break;
7122 }
7123 }
7124
7125 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007126 if (!hHal) {
7127 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7128 "\n pMac is NULL");
7129 len += buf;
7130 break;
7131 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307132 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007133 if (!pMac) {
7134 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7135 "\n pMac is NULL");
7136 len += buf;
7137 break;
7138 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307139 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7140 if( !pHddStaCtx )
7141 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007142 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307143 "\n pHddStaCtx is NULL");
7144 len += buf;
7145 break;
7146 }
7147
7148 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7149
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007150 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307151 "\n HDD Conn State - %s "
7152 "\n \n SME State:"
7153 "\n Neighbour Roam State - %s"
7154 "\n CSR State - %s"
7155 "\n CSR Substate - %s"
7156 "\n \n TL STA %d State: %s",
7157 macTraceGetHDDWlanConnState(
7158 pHddStaCtx->conn_info.connState),
7159 macTraceGetNeighbourRoamState(
7160 pMac->roam.neighborRoamInfo.neighborRoamState),
7161 macTraceGetcsrRoamState(
7162 pMac->roam.curState[useAdapter->sessionId]),
7163 macTraceGetcsrRoamSubState(
7164 pMac->roam.curSubState[useAdapter->sessionId]),
7165 pHddStaCtx->conn_info.staId[0],
7166 macTraceGetTLState(tlState)
7167 );
7168 len += buf;
7169 adapter_num++;
7170 }
7171
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007172 if (pMac) {
7173 /* Printing Lim State starting with global lim states */
7174 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7175 "\n \n LIM STATES:-"
7176 "\n Global Sme State - %s "\
7177 "\n Global mlm State - %s "\
7178 "\n",
7179 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7180 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7181 );
7182 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307183
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007184 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307185 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307186 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007187 if ( pMac->lim.gpSession[count].valid )
7188 {
7189 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7190 "\n Lim Valid Session %d:-"
7191 "\n PE Sme State - %s "
7192 "\n PE Mlm State - %s "
7193 "\n",
7194 check,
7195 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7196 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7197 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307198
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007199 len += buf;
7200 check++;
7201 }
7202 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307203 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307204 }
7205
7206 wrqu->data.length = strlen(extra)+1;
7207 break;
7208 }
7209
Jeff Johnson295189b2012-06-20 16:38:30 -07007210 case WE_GET_CFG:
7211 {
7212 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7213 wrqu->data.length = strlen(extra)+1;
7214 break;
7215 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007216#ifdef WLAN_FEATURE_11AC
7217 case WE_GET_RSSI:
7218 {
7219 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307220 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007221 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7222 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7223 wrqu->data.length = strlen(extra)+1;
7224 break;
7225 }
7226#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307227
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007228#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007229 case WE_GET_ROAM_RSSI:
7230 {
7231 v_S7_t s7Rssi = 0;
7232 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7233 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7234 wrqu->data.length = strlen(extra)+1;
7235 break;
7236 }
7237#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 case WE_GET_WMM_STATUS:
7239 {
7240 snprintf(extra, WE_MAX_STR_LEN,
7241 "\nDir: 0=up, 1=down, 3=both\n"
7242 "|------------------------|\n"
7243 "|AC | ACM |Admitted| Dir |\n"
7244 "|------------------------|\n"
7245 "|VO | %d | %3s | %d |\n"
7246 "|VI | %d | %3s | %d |\n"
7247 "|BE | %d | %3s | %d |\n"
7248 "|BK | %d | %3s | %d |\n"
7249 "|------------------------|\n",
7250 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7251 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7252 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7253 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7254 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7255 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7256 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7257 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7258 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7259 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7260 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7261 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7262
Jeff Johnsone7245742012-09-05 17:12:55 -07007263
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 wrqu->data.length = strlen(extra)+1;
7265 break;
7266 }
7267 case WE_GET_CHANNEL_LIST:
7268 {
7269 VOS_STATUS status;
7270 v_U8_t i, len;
7271 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307272 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7273 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7274 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 tChannelListInfo channel_list;
7276
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007277 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007279 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007281 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 return -EINVAL;
7283 }
7284 buf = extra;
7285
7286 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007287 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7288 * needed = 5 * number of channels. Check ifsufficient
7289 * buffer is available and then proceed to fill the buffer.
7290 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7292 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007293 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007294 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007295 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 return -EINVAL;
7297 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007298 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7299 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307300 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7301 {
7302 //Printing Country code in getChannelList
7303 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7304 {
7305 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7306 "%c ", pBuf[i]);
7307 }
7308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 for(i = 0 ; i < channel_list.num_channels; i++)
7310 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007311 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 }
7314 wrqu->data.length = strlen(extra)+1;
7315
7316 break;
7317 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007318#ifdef FEATURE_WLAN_TDLS
7319 case WE_GET_TDLS_PEERS:
7320 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007321 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007322 break;
7323 }
7324#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007325#ifdef WLAN_FEATURE_11W
7326 case WE_GET_11W_INFO:
7327 {
7328 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7329
7330 snprintf(extra, WE_MAX_STR_LEN,
7331 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7332 "\n Number of Unprotected Disassocs %d"
7333 "\n Number of Unprotected Deauths %d",
7334 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7335 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7336 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7337 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7338 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7339
7340 wrqu->data.length = strlen(extra)+1;
7341 break;
7342 }
7343#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307344#ifdef WLAN_FEATURE_RMC
7345 case WE_GET_IBSS_STA_INFO:
7346 {
7347 hdd_station_ctx_t *pHddStaCtx =
7348 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7349 int idx = 0;
7350 int length = 0, buf = 0;
7351
7352 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7353 {
7354 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7355 {
7356 buf = snprintf
7357 (
7358 (extra + length), WE_MAX_STR_LEN - length,
7359 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7360 pHddStaCtx->conn_info.staId[ idx ],
7361 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7362 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7363 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7364 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7365 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7366 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7367 );
7368 length += buf;
7369 }
7370 }
7371 wrqu->data.length = strlen(extra)+1;
7372 break;
7373 }
7374#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307375 case WE_GET_SNR:
7376 {
7377 v_S7_t s7snr = 0;
7378 int status = 0;
7379 hdd_context_t *pHddCtx;
7380 hdd_station_ctx_t *pHddStaCtx;
7381
7382 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7383 status = wlan_hdd_validate_context(pHddCtx);
7384 if (0 != status)
7385 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307386 return status;
7387 }
7388
7389 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7390
7391 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7392 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7393 {
7394 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7395 " ConnectionState-%d", __func__,
7396 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7397 pHddStaCtx->conn_info.connState);
7398 return -ENONET;
7399 }
7400
7401 /*update the stats in TL*/
7402 wlan_hdd_get_station_stats(pAdapter);
7403 wlan_hdd_get_snr(pAdapter, &s7snr);
7404 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7405 wrqu->data.length = strlen(extra) + 1;
7406 break;
7407 }
7408
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307409#ifdef FEATURE_OEM_DATA_SUPPORT
7410 case WE_GET_OEM_DATA_CAP:
7411 {
7412 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7413 }
7414#endif /* FEATURE_OEM_DATA_SUPPORT */
7415
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307416 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007418 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 break;
7420 }
7421 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307422 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 return 0;
7424}
7425
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307426static int iw_get_char_setnone(struct net_device *dev,
7427 struct iw_request_info *info,
7428 union iwreq_data *wrqu, char *extra)
7429{
7430 int ret;
7431
7432 vos_ssr_protect(__func__);
7433 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7434 vos_ssr_unprotect(__func__);
7435
7436 return ret;
7437}
7438
Jeff Johnson295189b2012-06-20 16:38:30 -07007439/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307440static int __iw_setnone_getnone(struct net_device *dev,
7441 struct iw_request_info *info,
7442 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007443{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307444 hdd_adapter_t *pAdapter;
7445 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307446 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007447 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307448 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307450 ENTER();
7451
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307452 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7453 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007454 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7456 "%s: Adapter is NULL",__func__);
7457 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007458 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307459 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7460 ret = wlan_hdd_validate_context(pHddCtx);
7461 if (0 != ret)
7462 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307463 return ret;
7464 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307465 /* helper function to get iwreq_data with compat handling. */
7466 if (hdd_priv_get_data(&s_priv_data, wrqu))
7467 {
7468 return -EINVAL;
7469 }
7470
7471 sub_cmd = s_priv_data.flags;
7472
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 switch (sub_cmd)
7474 {
7475 case WE_CLEAR_STATS:
7476 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7479 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7480 break;
7481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 case WE_INIT_AP:
7483 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307484 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7485
7486 /* As Soft AP mode might been changed to STA already with
7487 * killing of Hostapd, need to find the adpater by name
7488 * rather than mode */
7489 hdd_adapter_t* pAdapter_to_stop =
7490 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7491 if( pAdapter_to_stop )
7492 {
7493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7494 "Adapter with name softap.0 already "
7495 "exist, ignoring the request.\nRemove the "
7496 "adapter and try again\n");
7497 break;
7498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007499 pr_info("Init AP trigger\n");
7500 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7501 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7502 break;
7503 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307504#ifdef WLAN_FEATURE_RMC
7505 case WE_IBSS_GET_PEER_INFO_ALL:
7506 {
7507 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7508 break;
7509 }
7510#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 case WE_STOP_AP:
7512 {
7513 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7514 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7515 * this is a dead code and need to find the adpater by name rather than mode */
7516 hdd_adapter_t* pAdapter_to_stop =
7517 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7518 if( pAdapter_to_stop )
7519 {
7520 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7521
7522 pr_info("Stopping AP mode\n");
7523
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307524 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7525 {
7526 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7527 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7528 }
7529
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307531 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307532 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7534
7535 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7536 pAdapter_to_stop->macAddressCurrent.bytes);
7537 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7538 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307539
7540 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7541 {
7542 /* put the device back into BMPS */
7543 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 }
7546 else
7547 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007548 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 }
7550
7551 break;
7552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007553#ifdef WLAN_BTAMP_FEATURE
7554 case WE_ENABLE_AMP:
7555 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 WLANBAP_RegisterWithHCI(pAdapter);
7558 break;
7559 }
7560 case WE_DISABLE_AMP:
7561 {
7562 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7563 VOS_STATUS status;
7564
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007566
7567 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7568 status = WLANBAP_StopAmp();
7569 if(VOS_STATUS_SUCCESS != status )
7570 {
7571 pHddCtx->isAmpAllowed = VOS_TRUE;
7572 hddLog(VOS_TRACE_LEVEL_FATAL,
7573 "%s: Failed to stop AMP", __func__);
7574 }
7575 else
7576 {
7577 //a state m/c implementation in PAL is TBD to avoid this delay
7578 msleep(500);
7579 pHddCtx->isAmpAllowed = VOS_FALSE;
7580 WLANBAP_DeregisterFromHCI();
7581 }
7582
7583 break;
7584 }
7585#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007586 case WE_ENABLE_DXE_STALL_DETECT:
7587 {
schang6295e542013-03-12 15:31:23 -07007588 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7589 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007590 break;
7591 }
7592 case WE_DISPLAY_DXE_SNAP_SHOT:
7593 {
schang6295e542013-03-12 15:31:23 -07007594 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7595 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007596 break;
7597 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307598 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7599 {
7600 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7601 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307602 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307603 break;
7604 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307605
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307606 case WE_SET_REASSOC_TRIGGER:
7607 {
7608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7609 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7610 v_U32_t roamId = 0;
7611 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307612 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7613 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307614 return 0;
7615 }
7616
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307617 case WE_STOP_OBSS_SCAN:
7618 {
7619 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7620 2.OBSS scan is stopped by Firmware during the disassociation
7621 3.OBSS stop comamnd is added for debugging purpose*/
7622 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7623 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007624
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307625 if (pAdapter == NULL)
7626 {
7627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7628 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307629 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307630 }
7631 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7632 if (pMac == NULL)
7633 {
7634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7635 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307636 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307637 }
7638 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7639 }
7640 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307641 case WE_DUMP_ROAM_TIMER_LOG:
7642 {
7643 vos_dump_roam_time_log_service();
7644 break;
7645 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307646
Mukul Sharma84f27252014-07-14 18:11:42 +05307647 case WE_RESET_ROAM_TIMER_LOG:
7648 {
7649 vos_reset_roam_timer_log();
7650 break;
7651 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307652 case WE_GET_FW_LOGS:
7653 {
7654 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7655 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307656 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307657 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307658 break;
7659 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307660 case WE_GET_FW_MEMDUMP:
7661 {
7662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7663 "FW_MEM_DUMP requested ");
7664 get_fwr_memdump(dev,info,wrqu,extra);
7665 break;
7666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 default:
7668 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007669 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 break;
7671 }
7672 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307673 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 return ret;
7675}
7676
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307677static int iw_setnone_getnone(struct net_device *dev,
7678 struct iw_request_info *info,
7679 union iwreq_data *wrqu, char *extra)
7680{
7681 int ret;
7682
7683 vos_ssr_protect(__func__);
7684 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7685 vos_ssr_unprotect(__func__);
7686
7687 return ret;
7688}
7689
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307690void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7691{
7692 /*
7693 * Function to display HDD WMM information
7694 * for Tx Queues.
7695 * Prints globala as well as per client depending
7696 * whether the clients are registered or not.
7697 */
7698 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307699 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7700 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307701 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7702 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307703 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307704
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307705 for ( i=0; i< NUM_TX_QUEUES; i++)
7706 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307707 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307708 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307709 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307710 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307711
7712 for ( i=0; i< NUM_TX_QUEUES; i++) {
7713 if (tx_queue_count[i]) {
7714 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7715 i, tx_queue_count[i]);
7716 }
7717 }
7718
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307719 if(pSapCtx == NULL){
7720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7721 FL("psapCtx is NULL"));
7722 return;
7723 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307724
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307725 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307726 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7727 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307728 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307729 {
7730 hddLog(LOGE, "******STAIndex: %d*********", i);
7731 for ( j=0; j< NUM_TX_QUEUES; j++)
7732 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307733 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7734 {
7735 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307736 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7737 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307738 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7739 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307740 }
7741 }
7742 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307743 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307744
Katya Nigam1fd24402015-02-16 14:52:19 +05307745 if(pHddStaCtx == NULL){
7746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7747 FL("pHddStaCtx is NULL"));
7748 return;
7749 }
7750
7751 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7752 if(pPeerInfo == NULL){
7753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7754 FL("ppeerinfo is NULL"));
7755 return;
7756 }
7757
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307758 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7759 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7760 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7761 for (j = 0; j < NUM_TX_QUEUES; j++) {
7762 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7763 spin_lock_bh(
7764 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7765 hddLog(LOGE,
7766 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7767 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7768 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7769 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7770 spin_unlock_bh(
7771 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7772 }
7773 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307774 }
7775 }
7776
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307777}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307778
Girish Gowlifb9758e2014-11-19 15:19:17 +05307779static int __iw_set_var_ints_getnone(struct net_device *dev,
7780 struct iw_request_info *info,
7781 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007782{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307783 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307784 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307785 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307786 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007787 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307788 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307789 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007790 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307791 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007792 int cmd = 0;
7793 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307794 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007795
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307796 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307797 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307798 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7800 "%s: NULL extra buffer pointer", __func__);
7801 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307802 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307803 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7804 if (NULL == pAdapter)
7805 {
7806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 "%s: Adapter is NULL",__func__);
7808 return -EINVAL;
7809 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307810 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307811 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7812 ret = wlan_hdd_validate_context(pHddCtx);
7813 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007814 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307815 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007816 }
Katya Nigameae74b62015-05-28 17:19:16 +05307817 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307818 {
Katya Nigameae74b62015-05-28 17:19:16 +05307819 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7820 if (NULL == hHal)
7821 {
7822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7823 "%s: Hal Context is NULL",__func__);
7824 return -EINVAL;
7825 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307826 }
7827 sub_cmd = wrqu->data.flags;
7828
7829 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7830
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007831
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007832 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7833 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7834 {
7835 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7836 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7837 {
7838 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7839 staId = pStaCtx->conn_info.staId[0];
7840 }
7841 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7842 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7843 {
7844 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7845 staId = pAPCtx->uBCStaId;
7846 }
7847 else
7848 {
7849 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7850 return 0;
7851 }
7852 }
7853
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 switch (sub_cmd)
7855 {
7856 case WE_LOG_DUMP_CMD:
7857 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307858 if(apps_args[0] == 26) {
7859 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7860 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7861 return 0;
7862 }
7863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007865 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307867 if (hHal)
7868 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7869 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007870
7871 }
7872 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307873#ifdef WLAN_FEATURE_RMC
7874 case WE_IBSS_GET_PEER_INFO:
7875 {
7876 pr_info ( "Station ID = %d\n",apps_args[0]);
7877 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7878 }
7879 break;
7880#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007881
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 case WE_P2P_NOA_CMD:
7883 {
7884 p2p_app_setP2pPs_t p2pNoA;
7885
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307886 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7887 hddLog(LOGE,
7888 FL("Setting NoA is not allowed in Device mode:%d"),
7889 pAdapter->device_mode);
7890 return -EINVAL;
7891 }
7892
Jeff Johnson295189b2012-06-20 16:38:30 -07007893 p2pNoA.opp_ps = apps_args[0];
7894 p2pNoA.ctWindow = apps_args[1];
7895 p2pNoA.duration = apps_args[2];
7896 p2pNoA.interval = apps_args[3];
7897 p2pNoA.count = apps_args[4];
7898 p2pNoA.single_noa_duration = apps_args[5];
7899 p2pNoA.psSelection = apps_args[6];
7900
7901 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7902 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007903 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7905
7906 hdd_setP2pPs(dev, &p2pNoA);
7907
7908 }
7909 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007910
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307911 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7912 {
7913 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7914 __func__, apps_args[0], apps_args[1]);
7915 vosTraceEnable(apps_args[0], apps_args[1]);
7916 }
7917 break;
7918
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007919 case WE_MTRACE_DUMP_CMD:
7920 {
7921 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7922 "bitmask_of_module %d ",
7923 __func__, apps_args[0], apps_args[1], apps_args[2],
7924 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307925 if (hHal)
7926 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7927 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007928
7929 }
7930 break;
7931
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007932 case WE_MCC_CONFIG_CREDENTIAL :
7933 {
7934 cmd = 287; //Command should be updated if there is any change
7935 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007936 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007937 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307938 if (hHal)
7939 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7940 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007941 }
7942 else
7943 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007944 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007945 return 0;
7946 }
7947 }
7948 break;
7949
7950 case WE_MCC_CONFIG_PARAMS :
7951 {
7952 cmd = 288; //command Should be updated if there is any change
7953 // in the Riva dump command
7954 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7955 }
7956 break;
7957
Chilam NG571c65a2013-01-19 12:27:36 +05307958#ifdef FEATURE_WLAN_TDLS
7959 case WE_TDLS_CONFIG_PARAMS :
7960 {
7961 tdls_config_params_t tdlsParams;
7962
Chilam Ng01120412013-02-19 18:32:21 -08007963 tdlsParams.tdls = apps_args[0];
7964 tdlsParams.tx_period_t = apps_args[1];
7965 tdlsParams.tx_packet_n = apps_args[2];
7966 tdlsParams.discovery_period_t = apps_args[3];
7967 tdlsParams.discovery_tries_n = apps_args[4];
7968 tdlsParams.idle_timeout_t = apps_args[5];
7969 tdlsParams.idle_packet_n = apps_args[6];
7970 tdlsParams.rssi_hysteresis = apps_args[7];
7971 tdlsParams.rssi_trigger_threshold = apps_args[8];
7972 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307973
Chilam Ng01120412013-02-19 18:32:21 -08007974 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307975 }
7976 break;
7977#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307978 case WE_CONFIGURE_MONITOR_MODE:
7979 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307980 v_U32_t magic = 0;
7981 struct completion cmpVar;
7982 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307983 tVOS_CON_MODE mode = hdd_get_conparam();
7984
7985 if (VOS_MONITOR_MODE != mode) {
7986 hddLog(LOGE, FL("invalid mode %d"), mode);
7987 return -EIO;
7988 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307989
Katya Nigamf0511f62015-05-05 16:40:57 +05307990 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7991 if( pMonCtx == NULL )
7992 {
7993 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307994 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307995 }
7996 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7997 __func__, apps_args[0], apps_args[1], apps_args[2],
7998 apps_args[3], apps_args[4]);
7999 /* Input Validation part of FW */
8000 pMonCtx->ChannelNo = apps_args[0];
8001 pMonCtx->ChannelBW = apps_args[1];
8002 pMonCtx->crcCheckEnabled = apps_args[2];
8003 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8004 pMonCtx->is80211to803ConReq = apps_args[4];
8005 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8006 if( pMonCtx->is80211to803ConReq )
8007 pAdapter->dev->type = ARPHRD_ETHER;
8008 else
8009 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8010 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8011 {
8012 hddLog(LOGE, "%s: Filtering data packets as management and control"
8013 " cannot be converted to 802.3 ",__func__);
8014 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8015 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308016 if (MON_MODE_START == pMonCtx->state) {
8017 magic = MON_MODE_MSG_MAGIC;
8018 init_completion(&cmpVar);
8019 if (VOS_STATUS_SUCCESS !=
8020 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8021 pMonCtx, hdd_monPostMsgCb)) {
8022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8023 FL("failed to post MON MODE REQ"));
8024 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308025 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308026 }
8027 waitRet = wait_for_completion_timeout(&cmpVar,
8028 MON_MODE_MSG_TIMEOUT);
8029 magic = 0;
8030 if (waitRet <= 0 ) {
8031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8032 FL("failed to wait on monitor mode completion %ld"),
8033 waitRet);
8034 }
8035 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308036 }
8037 break;
8038
8039 case WE_SET_MONITOR_MODE_FILTER:
8040 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308041 v_U32_t magic = 0;
8042 struct completion cmpVar;
8043 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308044 tVOS_CON_MODE mode = hdd_get_conparam();
8045
8046 if (VOS_MONITOR_MODE != mode) {
8047 hddLog(LOGE, FL("invalid mode %d"), mode);
8048 return -EIO;
8049 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308050
Katya Nigamf0511f62015-05-05 16:40:57 +05308051 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8052 if( pMonCtx == NULL )
8053 {
8054 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308055 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308056 }
8057 /* Input Validation Part of FW */
8058 pMonCtx->numOfMacFilters=1;
8059 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8060 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8061 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8062 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8063 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8064 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8065 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8066 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8067 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8068 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8069 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8070 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308071 if (MON_MODE_START == pMonCtx->state) {
8072 magic = MON_MODE_MSG_MAGIC;
8073 init_completion(&cmpVar);
8074 if (VOS_STATUS_SUCCESS !=
8075 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8076 pMonCtx, hdd_monPostMsgCb)) {
8077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8078 FL("failed to post MON MODE REQ"));
8079 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308080 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308081 }
8082 waitRet = wait_for_completion_timeout(&cmpVar,
8083 MON_MODE_MSG_TIMEOUT);
8084 magic = 0;
8085 if (waitRet <= 0 ) {
8086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8087 FL("failed to wait on monitor mode completion %ld"),
8088 waitRet);
8089 }
8090 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308091 }
8092 break;
8093
Jeff Johnson295189b2012-06-20 16:38:30 -07008094 default:
8095 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008096 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8097 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 }
8099 break;
8100 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308101 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 return 0;
8103}
8104
Girish Gowlifb9758e2014-11-19 15:19:17 +05308105static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8106 struct iw_request_info *info,
8107 union iwreq_data *wrqu, char *extra)
8108{
8109 int ret;
8110 union iwreq_data u_priv_wrqu;
8111 int apps_args[MAX_VAR_ARGS] = {0};
8112 int num_args;
8113
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308114 if (!capable(CAP_NET_ADMIN))
8115 {
8116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8117 FL("permission check failed"));
8118 return -EPERM;
8119 }
8120
Girish Gowlifb9758e2014-11-19 15:19:17 +05308121 /* helper function to get iwreq_data with compat handling. */
8122 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8123 {
8124 return -EINVAL;
8125 }
8126
8127 if (NULL == u_priv_wrqu.data.pointer)
8128 {
8129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8130 "%s: NULL data pointer", __func__);
8131 return -EINVAL;
8132 }
8133
8134 num_args = u_priv_wrqu.data.length;
8135 if (num_args > MAX_VAR_ARGS)
8136 {
8137 num_args = MAX_VAR_ARGS;
8138 }
8139
8140 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8141 (sizeof(int)) * num_args))
8142 {
8143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8144 "%s: failed to copy data from user buffer", __func__);
8145 return -EFAULT;
8146 }
8147
8148 vos_ssr_protect(__func__);
8149 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8150 (char *)&apps_args);
8151 vos_ssr_unprotect(__func__);
8152
8153 return ret;
8154}
8155
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308156int iw_set_var_ints_getnone(struct net_device *dev,
8157 struct iw_request_info *info,
8158 union iwreq_data *wrqu, char *extra)
8159{
8160 int ret;
8161 vos_ssr_protect(__func__);
8162 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8163 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008164
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308165 return ret;
8166}
8167
8168static int __iw_add_tspec(struct net_device *dev,
8169 struct iw_request_info *info,
8170 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008171{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308172 hdd_adapter_t *pAdapter;
8173 hdd_station_ctx_t *pHddStaCtx;
8174 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8176 int params[HDD_WLAN_WMM_PARAM_COUNT];
8177 sme_QosWmmTspecInfo tSpec;
8178 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308179 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308180 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008181
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308182 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308183 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8184 if (NULL == pAdapter)
8185 {
8186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8187 "%s: Adapter is NULL",__func__);
8188 return -EINVAL;
8189 }
8190 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8191 ret = wlan_hdd_validate_context(pHddCtx);
8192 if (0 != ret)
8193 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308194 return ret;
8195 }
8196 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8197 if (NULL == pHddStaCtx)
8198 {
8199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8200 "%s: STA Context is NULL",__func__);
8201 return -EINVAL;
8202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 // make sure the application is sufficiently priviledged
8204 // note that the kernel will do this for "set" ioctls, but since
8205 // this ioctl wants to return status to user space it must be
8206 // defined as a "get" ioctl
8207 if (!capable(CAP_NET_ADMIN))
8208 {
8209 return -EPERM;
8210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 // we must be associated in order to add a tspec
8212 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8213 {
8214 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8215 return 0;
8216 }
8217
8218 // since we are defined to be a "get" ioctl, and since the number
8219 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308220 // will pass down in the iwreq_data, we must copy the "set" params.
8221 // We must handle the compat for iwreq_data in 32U/64K environment.
8222
8223 // helper fucntion to get iwreq_data with compat handling.
8224 if (hdd_priv_get_data(&s_priv_data, wrqu))
8225 {
8226 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8227 return 0;
8228 }
8229
8230 // make sure all params are correctly passed to function
8231 if ((NULL == s_priv_data.pointer) ||
8232 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8233 {
8234 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8235 return 0;
8236 }
8237
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308239 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 {
8241 // hmmm, can't get them
8242 return -EIO;
8243 }
8244
8245 // clear the tspec
8246 memset(&tSpec, 0, sizeof(tSpec));
8247
8248 // validate the handle
8249 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8250 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8251 {
8252 // that one is reserved
8253 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8254 return 0;
8255 }
8256
8257 // validate the TID
8258 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8259 {
8260 // out of range
8261 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8262 return 0;
8263 }
8264 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8265
8266 // validate the direction
8267 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8268 {
8269 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8270 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8271 break;
8272
8273 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8274 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8275 break;
8276
8277 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8278 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8279 break;
8280
8281 default:
8282 // unknown
8283 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8284 return 0;
8285 }
8286
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308287 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8288
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 // validate the user priority
8290 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8291 {
8292 // out of range
8293 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8294 return 0;
8295 }
8296 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308297 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8298 {
8299 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8300 return 0;
8301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008302
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8304 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8305 tSpec.ts_info.psb, tSpec.ts_info.up);
8306
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8308 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8309 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8310 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8311 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8312 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8313 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8314 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8315 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8316 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8317 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8318 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8319
8320 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8321
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308322 // Save the expected UAPSD settings by application, this will be needed
8323 // when re-negotiating UAPSD settings during BT Coex cases.
8324 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8325
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 // validate the ts info ack policy
8327 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8328 {
8329 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8330 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8331 break;
8332
8333 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8334 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8335 break;
8336
8337 default:
8338 // unknown
8339 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8340 return 0;
8341 }
8342
8343 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308344
8345 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 return 0;
8347}
8348
8349
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308350static int iw_add_tspec(struct net_device *dev,
8351 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 union iwreq_data *wrqu, char *extra)
8353{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308354 int ret;
8355
8356 vos_ssr_protect(__func__);
8357 ret = __iw_add_tspec(dev, info, wrqu, extra);
8358 vos_ssr_unprotect(__func__);
8359
8360 return ret;
8361}
8362
8363static int __iw_del_tspec(struct net_device *dev,
8364 struct iw_request_info *info,
8365 union iwreq_data *wrqu, char *extra)
8366{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308367 hdd_adapter_t *pAdapter;
8368 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 int *params = (int *)extra;
8370 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8371 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308372 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008373
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308374 ENTER();
8375
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308376 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8377 if (NULL == pAdapter)
8378 {
8379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8380 "%s: Adapter is NULL",__func__);
8381 return -EINVAL;
8382 }
8383
8384 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8385 ret = wlan_hdd_validate_context(pHddCtx);
8386 if (0 != ret)
8387 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308388 return ret;
8389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 // make sure the application is sufficiently priviledged
8391 // note that the kernel will do this for "set" ioctls, but since
8392 // this ioctl wants to return status to user space it must be
8393 // defined as a "get" ioctl
8394 if (!capable(CAP_NET_ADMIN))
8395 {
8396 return -EPERM;
8397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 // although we are defined to be a "get" ioctl, the params we require
8399 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8400 // is no need to copy the params from user space
8401
8402 // validate the handle
8403 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8404 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8405 {
8406 // that one is reserved
8407 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8408 return 0;
8409 }
8410
8411 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308412
8413 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 return 0;
8415}
8416
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308417static int iw_del_tspec(struct net_device *dev,
8418 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 union iwreq_data *wrqu, char *extra)
8420{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308421 int ret;
8422
8423 vos_ssr_protect(__func__);
8424 ret = __iw_del_tspec(dev, info, wrqu, extra);
8425 vos_ssr_unprotect(__func__);
8426
8427 return ret;
8428}
8429
8430
8431static int __iw_get_tspec(struct net_device *dev,
8432 struct iw_request_info *info,
8433 union iwreq_data *wrqu, char *extra)
8434{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308435 hdd_adapter_t *pAdapter;
8436 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 int *params = (int *)extra;
8438 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8439 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308440 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008441
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308442 ENTER();
8443
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 // although we are defined to be a "get" ioctl, the params we require
8445 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8446 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308447 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8448 if (NULL == pAdapter)
8449 {
8450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8451 "%s: Adapter is NULL",__func__);
8452 return -EINVAL;
8453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008454
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308455 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8456 ret = wlan_hdd_validate_context(pHddCtx);
8457 if (0 != ret)
8458 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308459 return ret;
8460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 // validate the handle
8462 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8463 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8464 {
8465 // that one is reserved
8466 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8467 return 0;
8468 }
8469
8470 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308471 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 return 0;
8473}
8474
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308475static int iw_get_tspec(struct net_device *dev,
8476 struct iw_request_info *info,
8477 union iwreq_data *wrqu, char *extra)
8478{
8479 int ret;
8480
8481 vos_ssr_protect(__func__);
8482 ret = __iw_get_tspec(dev, info, wrqu, extra);
8483 vos_ssr_unprotect(__func__);
8484
8485 return ret;
8486}
8487
Manjeet Singh3ed79242017-01-11 19:04:32 +05308488/**
8489 * __iw_setnone_get_threeint() - return three value to up layer.
8490 *
8491 * @dev: pointer of net_device of this wireless card
8492 * @info: meta data about Request sent
8493 * @wrqu: include request info
8494 * @extra: buf used for in/Output
8495 *
8496 * Return: execute result
8497 */
8498static int __iw_setnone_get_threeint(struct net_device *dev,
8499 struct iw_request_info *info,
8500 union iwreq_data *wrqu, char *extra)
8501{
8502 int ret = 0; /* success */
8503 uint32_t *value = (int *)extra;
8504 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8505
8506 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8507
8508 switch (value[0]) {
8509 case WE_GET_TSF:
8510 ret = hdd_indicate_tsf(adapter, value, 3);
8511 break;
8512 default:
8513 hddLog(VOS_TRACE_LEVEL_ERROR,
8514 FL("Invalid IOCTL get_value command %d"),
8515 value[0]);
8516 break;
8517 }
8518 return ret;
8519}
8520
8521/**
8522 * iw_setnone_get_threeint() - return three value to up layer.
8523 *
8524 * @dev: pointer of net_device of this wireless card
8525 * @info: meta data about Request sent
8526 * @wrqu: include request info
8527 * @extra: buf used for in/Output
8528 *
8529 * Return: execute result
8530 */
8531static int iw_setnone_get_threeint(struct net_device *dev,
8532 struct iw_request_info *info,
8533 union iwreq_data *wrqu, char *extra)
8534{
8535 int ret;
8536
8537 vos_ssr_protect(__func__);
8538 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8539 vos_ssr_unprotect(__func__);
8540
8541 return ret;
8542}
8543
Jeff Johnson295189b2012-06-20 16:38:30 -07008544#ifdef WLAN_FEATURE_VOWIFI_11R
8545//
8546//
8547// Each time the supplicant has the auth_request or reassoc request
8548// IEs ready. This is pushed to the driver. The driver will inturn use
8549// it to send out the auth req and reassoc req for 11r FT Assoc.
8550//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308551static int __iw_set_fties(struct net_device *dev,
8552 struct iw_request_info *info,
8553 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008554{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308555 hdd_adapter_t *pAdapter;
8556 hdd_station_ctx_t *pHddStaCtx;
8557 hdd_context_t *pHddCtx;
8558 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 //v_CONTEXT_t pVosContext;
8560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308561 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308562 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8563 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008564 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8566 "%s: Adapter is NULL",__func__);
8567 return -EINVAL;
8568 }
8569 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8570 ret = wlan_hdd_validate_context(pHddCtx);
8571 if (0 != ret)
8572 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308573 return ret;
8574 }
8575 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8576 if (NULL == pHddStaCtx)
8577 {
8578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8579 "%s: STA Context is NULL",__func__);
8580 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 if (!wrqu->data.length)
8583 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008584 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 return -EINVAL;
8586 }
8587 if (wrqu->data.pointer == NULL)
8588 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008589 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 return -EINVAL;
8591 }
8592
8593 // Added for debug on reception of Re-assoc Req.
8594 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8595 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008596 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008598 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 }
8600
8601#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008602 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008603#endif
8604
8605 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008606 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008607 wrqu->data.length);
8608
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308609 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 return 0;
8611}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308612
8613static int iw_set_fties(struct net_device *dev,
8614 struct iw_request_info *info,
8615 union iwreq_data *wrqu, char *extra)
8616{
8617 int ret;
8618
8619 vos_ssr_protect(__func__);
8620 ret = __iw_set_fties(dev, info, wrqu, extra);
8621 vos_ssr_unprotect(__func__);
8622
8623 return ret;
8624}
Jeff Johnson295189b2012-06-20 16:38:30 -07008625#endif
8626
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308627static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008628 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008629 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008630{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308631 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008632 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308633 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008634 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308635 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008636 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8637 int idx;
8638 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008639
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308640 ENTER();
8641
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308642 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8643 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008644 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8646 "%s: Adapter is NULL",__func__);
8647 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008648 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308649 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8650 ret_val = wlan_hdd_validate_context(pHddCtx);
8651 if (0 != ret_val)
8652 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308653 return ret_val;
8654 }
8655 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8656 if (NULL == hHal)
8657 {
8658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8659 "%s: Hal Context is NULL",__func__);
8660 return -EINVAL;
8661 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308662 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8663 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308664#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008665
Amar Singhalf3a6e762013-02-19 15:06:50 -08008666 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8667 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008668 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008669 hddLog(VOS_TRACE_LEVEL_ERROR,
8670 "%s: vos_mem_alloc failed", __func__);
8671 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008672 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008673
8674 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8675
8676 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8677 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8678
8679 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8680 mc_addr_list_ptr->ulMulticastAddrCnt);
8681
8682 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008683 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008684 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8685 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8686
8687 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8688 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008689 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008690
Amar Singhalf3a6e762013-02-19 15:06:50 -08008691 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8692 vos_mem_free(mc_addr_list_ptr);
8693 if (eHAL_STATUS_SUCCESS != ret_val)
8694 {
8695 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8696 __func__);
8697 return -EINVAL;
8698 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308699#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308700 }
8701 else
8702 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008703
Amar Singhalf3a6e762013-02-19 15:06:50 -08008704 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8705 "%s: Set MC BC Filter Config request: %d suspend %d",
8706 __func__, pRequest->mcastBcastFilterSetting,
8707 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308708 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308709 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308710 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008711
8712 if (pHddCtx->hdd_wlan_suspended)
8713 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008714 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8715 if (NULL == wlanRxpFilterParam)
8716 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308717 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008718 "%s: vos_mem_alloc failed", __func__);
8719 return -EINVAL;
8720 }
8721
Amar Singhalf3a6e762013-02-19 15:06:50 -08008722 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8723 pRequest->mcastBcastFilterSetting;
8724 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308725 /* Fwr expect offload needs to clear before set */
8726 hdd_conf_hostoffload(pAdapter, FALSE);
8727 spin_lock(&pHddCtx->filter_lock);
8728 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8729 spin_unlock(&pHddCtx->filter_lock);
8730 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8731 {
8732 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8733 pHddCtx->sus_res_mcastbcast_filter =
8734 pRequest->mcastBcastFilterSetting;
8735 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008736
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308737 hdd_conf_hostoffload(pAdapter, TRUE);
8738 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8739 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008740
8741 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8742 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308743 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008744 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8745 wlanRxpFilterParam->setMcstBcstFilter);
8746
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308747 if (eHAL_STATUS_SUCCESS !=
8748 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8749 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008750 {
8751 hddLog(VOS_TRACE_LEVEL_ERROR,
8752 "%s: Failure to execute set HW MC/BC Filter request",
8753 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008754 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008755 return -EINVAL;
8756 }
8757
mukul sharmae4abd892016-11-24 22:03:31 +05308758 /* mc add list cfg item configuration in fwr */
8759 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008760 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008762
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308763 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 return 0;
8765}
8766
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308767static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8768 struct iw_request_info *info,
8769 union iwreq_data *wrqu, char *extra)
8770{
8771 int ret;
8772
8773 vos_ssr_protect(__func__);
8774 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8775 vos_ssr_unprotect(__func__);
8776
8777 return ret;
8778}
8779
8780static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8781 struct iw_request_info *info,
8782 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008783{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308784 hdd_adapter_t *pAdapter;
8785 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308786 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308787 int ret = 0;
8788
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308789 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008790
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308791 if (!capable(CAP_NET_ADMIN))
8792 {
8793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8794 FL("permission check failed"));
8795 return -EPERM;
8796 }
8797
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308798 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8799 if (NULL == pAdapter)
8800 {
8801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8802 "%s: Adapter is NULL",__func__);
8803 return -EINVAL;
8804 }
8805
8806 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8807 ret = wlan_hdd_validate_context(pHddCtx);
8808 if (0 != ret)
8809 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308810 return ret;
8811 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308812 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308813 //Reset the filter to INI value as we have to clear the dynamic filter
8814 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308815 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008816
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308817 //Configure FW with new setting
8818 if (pHddCtx->hdd_wlan_suspended)
8819 {
8820 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8821 if (NULL == wlanRxpFilterParam)
8822 {
8823 hddLog(VOS_TRACE_LEVEL_ERROR,
8824 "%s: vos_mem_alloc failed", __func__);
8825 return -EINVAL;
8826 }
8827
8828 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8829 pHddCtx->configuredMcastBcastFilter;
8830 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308831 /* Fwr expect offload needs to clear before set */
8832 hdd_conf_hostoffload(pAdapter, FALSE);
8833 spin_lock(&pHddCtx->filter_lock);
8834 pHddCtx->configuredMcastBcastFilter =
8835 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8836 spin_unlock(&pHddCtx->filter_lock);
8837
8838 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8839 {
8840 pHddCtx->sus_res_mcastbcast_filter =
8841 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8842 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308843
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308844 hdd_conf_hostoffload(pAdapter, TRUE);
8845 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8846 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308847 if (eHAL_STATUS_SUCCESS !=
8848 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8849 wlanRxpFilterParam))
8850 {
8851 hddLog(VOS_TRACE_LEVEL_ERROR,
8852 "%s: Failure to execute set HW MC/BC Filter request",
8853 __func__);
8854 vos_mem_free(wlanRxpFilterParam);
8855 return -EINVAL;
8856 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308857
mukul sharmae4abd892016-11-24 22:03:31 +05308858 /* mc add list cfg item configuration in fwr */
8859 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308860 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308861 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 return 0;
8863}
8864
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308865
8866static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8867 struct iw_request_info *info,
8868 union iwreq_data *wrqu, char *extra)
8869{
8870 int ret;
8871
8872 vos_ssr_protect(__func__);
8873 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8874 vos_ssr_unprotect(__func__);
8875
8876 return ret;
8877}
8878
8879static int __iw_set_host_offload(struct net_device *dev,
8880 struct iw_request_info *info,
8881 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008882{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308883 hdd_adapter_t *pAdapter;
8884 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008885 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308887 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008888
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308889 ENTER();
8890
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308891 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8892 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008893 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8895 "%s: Adapter is NULL",__func__);
8896 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008897 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8899 ret = wlan_hdd_validate_context(pHddCtx);
8900 if (0 != ret)
8901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308902 return ret;
8903 }
8904
Jeff Johnson295189b2012-06-20 16:38:30 -07008905 /* Debug display of request components. */
8906 switch (pRequest->offloadType)
8907 {
8908 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008909 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 switch (pRequest->enableOrDisable)
8911 {
8912 case WLAN_OFFLOAD_DISABLE:
8913 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8914 break;
8915 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8916 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8917 case WLAN_OFFLOAD_ENABLE:
8918 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8919 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8920 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8921 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8922 }
8923 break;
8924
8925 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008926 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008927 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 switch (pRequest->enableOrDisable)
8929 {
8930 case WLAN_OFFLOAD_DISABLE:
8931 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8932 break;
8933 case WLAN_OFFLOAD_ENABLE:
8934 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8935 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8936 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8937 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8938 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8939 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8940 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8941 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8942 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8943 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8944 }
8945 }
8946
8947 /* Execute offload request. The reason that we can copy the request information
8948 from the ioctl structure to the SME structure is that they are laid out
8949 exactly the same. Otherwise, each piece of information would have to be
8950 copied individually. */
8951 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008952 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8953 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008955 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 __func__);
8957 return -EINVAL;
8958 }
8959
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308960 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 return 0;
8962}
8963
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308964static int iw_set_host_offload(struct net_device *dev,
8965 struct iw_request_info *info,
8966 union iwreq_data *wrqu, char *extra)
8967{
8968 int ret;
8969
8970 vos_ssr_protect(__func__);
8971 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8972 vos_ssr_unprotect(__func__);
8973
8974 return ret;
8975}
8976
8977static int __iw_set_keepalive_params(struct net_device *dev,
8978 struct iw_request_info *info,
8979 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008980{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308981 hdd_adapter_t *pAdapter;
8982 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008983 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308985 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008986
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308987 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308988 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8989 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8992 "%s: Adapter is NULL",__func__);
8993 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308995 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8996 ret = wlan_hdd_validate_context(pHddCtx);
8997 if (0 != ret)
8998 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308999 return ret;
9000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009002 hddLog(VOS_TRACE_LEVEL_INFO,
9003 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9004 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009005
9006 switch (pRequest->packetType)
9007 {
9008 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009009 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 break;
9011
9012 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9013
Arif Hussain6d2a3322013-11-17 19:50:10 -08009014 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009015 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009016
9017 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9018 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9019 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9020
9021 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9022 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9023 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9024
9025 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9026 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9027 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9028 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9029 break;
9030
9031 }
9032
9033 /* Execute keep alive request. The reason that we can copy the request information
9034 from the ioctl structure to the SME structure is that they are laid out
9035 exactly the same. Otherwise, each piece of information would have to be
9036 copied individually. */
9037 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9038
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309039 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9040 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009041
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009042 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009043 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009044 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 __func__);
9047 return -EINVAL;
9048 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309049 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 return 0;
9051}
9052
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309053static int iw_set_keepalive_params(struct net_device *dev,
9054 struct iw_request_info *info,
9055 union iwreq_data *wrqu, char *extra)
9056{
9057 int ret;
9058 vos_ssr_protect(__func__);
9059 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9060 vos_ssr_unprotect(__func__);
9061
9062 return ret;
9063}
9064
Jeff Johnson295189b2012-06-20 16:38:30 -07009065#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309066/**-----------------------------------------------------------------
9067
9068 \brief hdd_pkt_filter_done - callback to be executed on completion
9069 successful/failure) for clear filter request.
9070
9071 \return - None
9072
9073 --------------------------------------------------------------------------*/
9074static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009075{
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309076 struct statsContext *cbCtx = (struct statsContext *)data;
9077
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309078 hddLog(VOS_TRACE_LEVEL_INFO,
9079 FL("Pkt Filter Clear Status : %d"), status);
9080
9081 if (data == NULL)
9082 {
9083 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context"));
9084 return;
9085 }
9086
9087 spin_lock(&hdd_context_lock);
9088 if (cbCtx->magic != CLEAR_FILTER_MAGIC)
9089 {
9090 spin_unlock(&hdd_context_lock);
9091 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context, magic %x"), cbCtx->magic);
9092 if (ioctl_debug)
9093 {
9094 pr_info("%s: Invalid context, magic [%08x]\n",
9095 __func__, cbCtx->magic);
9096 }
9097 return;
9098 }
9099
9100 complete(&cbCtx->completion);
9101 spin_unlock(&hdd_context_lock);
9102}
9103
9104int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9105{
9106 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309107 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009108 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9109 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309110 struct statsContext cbCtx;
9111 int i=0, status;
9112
9113 status = wlan_hdd_validate_context(pHddCtx);
9114 if (0 != status)
9115 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009116
9117 if (pHddCtx->cfg_ini->disablePacketFilter)
9118 {
9119 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009120 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009121 return 0;
9122 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309123 if (pHddCtx->isLogpInProgress)
9124 {
9125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9126 "%s:LOGP in Progress. Ignore!!!", __func__);
9127 return -EBUSY;
9128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 /* Debug display of request components. */
9130 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009131 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009132
9133 switch (pRequest->filterAction)
9134 {
9135 case HDD_RCV_FILTER_SET:
9136 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009137 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009138
9139 packetFilterSetReq.filterId = pRequest->filterId;
9140 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9141 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009142 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 __func__, pRequest->numParams);
9144 return -EINVAL;
9145 }
9146 packetFilterSetReq.numFieldParams = pRequest->numParams;
9147 packetFilterSetReq.coalesceTime = 0;
9148 packetFilterSetReq.filterType = 1;
9149 for (i=0; i < pRequest->numParams; i++)
9150 {
9151 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9152 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9153 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9154 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9155 packetFilterSetReq.paramsData[i].reserved = 0;
9156
Arif Hussain6d2a3322013-11-17 19:50:10 -08009157 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9159 packetFilterSetReq.filterType);
9160
Arif Hussain6d2a3322013-11-17 19:50:10 -08009161 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309163 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9164 (pRequest->paramsData[i].dataLength))
9165 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009166
9167 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9168 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9169 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9170 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9171
Arif Hussain6d2a3322013-11-17 19:50:10 -08009172 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9174 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9175 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9176
Arif Hussain6d2a3322013-11-17 19:50:10 -08009177 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9179 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9180 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9181 }
9182
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309183 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009185 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 __func__);
9187 return -EINVAL;
9188 }
9189
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309190 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9191 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 break;
9193
9194 case HDD_RCV_FILTER_CLEAR:
9195
Arif Hussain6d2a3322013-11-17 19:50:10 -08009196 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009197 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309198
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309199 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9200 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9201 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9202 pHddStaCtx->conn_info.staId[0]);
9203 }
9204
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309205 init_completion(&cbCtx.completion);
9206 cbCtx.magic = CLEAR_FILTER_MAGIC;
9207 cbCtx.pAdapter = pAdapter;
9208 packetFilterClrReq.cbCtx = &cbCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309210 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
9211 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009213 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 __func__);
9215 return -EINVAL;
9216 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309217
9218 status = wait_for_completion_interruptible_timeout(&cbCtx.completion,
9219 msecs_to_jiffies(PKT_FILTER_TIMEOUT));
9220 spin_lock(&hdd_context_lock);
9221 cbCtx.magic = 0;
9222 spin_unlock(&hdd_context_lock);
9223 if (0 >= status)
9224 {
9225 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9226 status);
9227 return -EINVAL;
9228 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309229
9230 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9231 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 break;
9233
9234 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009235 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009236 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 return -EINVAL;
9238 }
9239 return 0;
9240}
9241
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309242int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9243 tANI_U8 sessionId)
9244{
9245 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9246 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9247
9248 if (NULL == pHddCtx)
9249 {
9250 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9251 return -EINVAL;
9252 }
9253
9254 if (pHddCtx->isLogpInProgress)
9255 {
9256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9257 "%s:LOGP in Progress. Ignore!!!", __func__);
9258 return -EBUSY;
9259 }
9260
9261 if (pHddCtx->cfg_ini->disablePacketFilter)
9262 {
9263 hddLog(VOS_TRACE_LEVEL_ERROR,
9264 "%s: Packet Filtering Disabled. Returning ",
9265 __func__ );
9266 return -EINVAL;
9267 }
9268
9269 switch (filterType)
9270 {
9271 /* For setting IPV6 MC and UC Filter we need to configure
9272 * 2 filters, one for MC and one for UC.
9273 * The Filter ID shouldn't be swapped, which results in making
9274 * UC Filter ineffective.
9275 * We have Hardcode all the values
9276 *
9277 * Reason for a seperate UC filter is because, driver need to
9278 * specify the FW that the specific filter is for unicast
9279 * otherwise FW will not pass the unicast frames by default
9280 * through the filter. This is required to avoid any performance
9281 * hits when no unicast filter is set and only MC/BC are set.
9282 * The way driver informs host is by using the MAC protocol
9283 * layer, CMP flag set to MAX, CMP Data set to 1.
9284 */
9285
9286 case HDD_FILTER_IPV6_MC_UC:
9287 /* Setting IPV6 MC Filter below
9288 */
9289 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9290 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9291 packetFilterSetReq.numFieldParams = 2;
9292 packetFilterSetReq.paramsData[0].protocolLayer =
9293 HDD_FILTER_PROTO_TYPE_MAC;
9294 packetFilterSetReq.paramsData[0].cmpFlag =
9295 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9296 packetFilterSetReq.paramsData[0].dataOffset =
9297 WLAN_HDD_80211_FRM_DA_OFFSET;
9298 packetFilterSetReq.paramsData[0].dataLength = 1;
9299 packetFilterSetReq.paramsData[0].compareData[0] =
9300 HDD_IPV6_MC_CMP_DATA;
9301
9302 packetFilterSetReq.paramsData[1].protocolLayer =
9303 HDD_FILTER_PROTO_TYPE_ARP;
9304 packetFilterSetReq.paramsData[1].cmpFlag =
9305 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9306 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9307 packetFilterSetReq.paramsData[1].dataLength = 2;
9308 packetFilterSetReq.paramsData[1].compareData[0] =
9309 HDD_IPV6_CMP_DATA_0;
9310 packetFilterSetReq.paramsData[1].compareData[1] =
9311 HDD_IPV6_CMP_DATA_1;
9312
9313
9314 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9315 &packetFilterSetReq, sessionId))
9316 {
9317 hddLog(VOS_TRACE_LEVEL_ERROR,
9318 "%s: Failure to execute Set IPv6 Mulicast Filter",
9319 __func__);
9320 return -EINVAL;
9321 }
9322
9323 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9324
9325 /*
9326 * Setting IPV6 UC Filter below
9327 */
9328 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9329 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9330 packetFilterSetReq.numFieldParams = 2;
9331 packetFilterSetReq.paramsData[0].protocolLayer =
9332 HDD_FILTER_PROTO_TYPE_MAC;
9333 packetFilterSetReq.paramsData[0].cmpFlag =
9334 HDD_FILTER_CMP_TYPE_MAX;
9335 packetFilterSetReq.paramsData[0].dataOffset = 0;
9336 packetFilterSetReq.paramsData[0].dataLength = 1;
9337 packetFilterSetReq.paramsData[0].compareData[0] =
9338 HDD_IPV6_UC_CMP_DATA;
9339
9340 packetFilterSetReq.paramsData[1].protocolLayer =
9341 HDD_FILTER_PROTO_TYPE_ARP;
9342 packetFilterSetReq.paramsData[1].cmpFlag =
9343 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9344 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9345 packetFilterSetReq.paramsData[1].dataLength = 2;
9346 packetFilterSetReq.paramsData[1].compareData[0] =
9347 HDD_IPV6_CMP_DATA_0;
9348 packetFilterSetReq.paramsData[1].compareData[1] =
9349 HDD_IPV6_CMP_DATA_1;
9350
9351 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9352 &packetFilterSetReq, sessionId))
9353 {
9354 hddLog(VOS_TRACE_LEVEL_ERROR,
9355 "%s: Failure to execute Set IPv6 Unicast Filter",
9356 __func__);
9357 return -EINVAL;
9358 }
9359
9360 break;
9361
9362 case HDD_FILTER_IPV6_MC:
9363 /*
9364 * IPV6 UC Filter might be already set,
9365 * clear the UC Filter. As the Filter
9366 * IDs are static, we can directly clear it.
9367 */
9368 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9369 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9370 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9371 &packetFilterClrReq, sessionId))
9372 {
9373 hddLog(VOS_TRACE_LEVEL_ERROR,
9374 "%s: Failure to execute Clear IPv6 Unicast Filter",
9375 __func__);
9376 return -EINVAL;
9377 }
9378
9379 /*
9380 * Setting IPV6 MC Filter below
9381 */
9382 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9383 packetFilterSetReq.numFieldParams = 2;
9384 packetFilterSetReq.paramsData[0].protocolLayer =
9385 HDD_FILTER_PROTO_TYPE_MAC;
9386 packetFilterSetReq.paramsData[0].cmpFlag =
9387 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9388 packetFilterSetReq.paramsData[0].dataOffset =
9389 WLAN_HDD_80211_FRM_DA_OFFSET;
9390 packetFilterSetReq.paramsData[0].dataLength = 1;
9391 packetFilterSetReq.paramsData[0].compareData[0] =
9392 HDD_IPV6_MC_CMP_DATA;
9393
9394 packetFilterSetReq.paramsData[1].protocolLayer =
9395 HDD_FILTER_PROTO_TYPE_ARP;
9396 packetFilterSetReq.paramsData[1].cmpFlag =
9397 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9398 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9399 packetFilterSetReq.paramsData[1].dataLength = 2;
9400 packetFilterSetReq.paramsData[1].compareData[0] =
9401 HDD_IPV6_CMP_DATA_0;
9402 packetFilterSetReq.paramsData[1].compareData[1] =
9403 HDD_IPV6_CMP_DATA_1;
9404
9405
9406 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9407 &packetFilterSetReq, sessionId))
9408 {
9409 hddLog(VOS_TRACE_LEVEL_ERROR,
9410 "%s: Failure to execute Set IPv6 Multicast Filter",
9411 __func__);
9412 return -EINVAL;
9413 }
9414 break;
9415
9416 default :
9417 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9418 "%s: Packet Filter Request: Invalid",
9419 __func__);
9420 return -EINVAL;
9421 }
9422 return 0;
9423}
9424
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309425void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009426{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309427 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309428 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009429 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309430 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009431
Yue Ma3ede6052013-08-29 00:33:26 -07009432 if (NULL == pHddCtx)
9433 {
9434 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9435 return;
9436 }
9437
9438 hHal = pHddCtx->hHal;
9439
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309440 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309442 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9443 return;
9444 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309445
9446 /* Check if INI is enabled or not, other wise just return
9447 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309448 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309449 {
9450 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9451 if (NULL == pMulticastAddrs)
9452 {
9453 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9454 return;
9455 }
9456
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 if (set)
9458 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309459 /* Following pre-conditions should be satisfied before wei
9460 * configure the MC address list.
9461 */
9462 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9463 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9464 && pAdapter->mc_addr_list.mc_cnt
9465 && (eConnectionState_Associated ==
9466 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9467 {
9468 pMulticastAddrs->ulMulticastAddrCnt =
9469 pAdapter->mc_addr_list.mc_cnt;
9470 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9471 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009472 memcpy(pMulticastAddrs->multicastAddr[i],
9473 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309474 sizeof(pAdapter->mc_addr_list.addr[i]));
9475 hddLog(VOS_TRACE_LEVEL_INFO,
9476 "%s: %s multicast filter: addr ="
9477 MAC_ADDRESS_STR,
9478 __func__, set ? "setting" : "clearing",
9479 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9480 }
9481 /* Set multicast filter */
9482 sme_8023MulticastList(hHal, pAdapter->sessionId,
9483 pMulticastAddrs);
9484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309486 else
9487 {
9488 /* Need to clear only if it was previously configured
9489 */
9490 if (pAdapter->mc_addr_list.isFilterApplied)
9491 {
9492 pMulticastAddrs->ulMulticastAddrCnt = 0;
9493 sme_8023MulticastList(hHal, pAdapter->sessionId,
9494 pMulticastAddrs);
9495 }
9496
9497 }
9498 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009499 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309501 else
9502 {
9503 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309504 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309505 }
9506 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009507}
9508
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309509static int __iw_set_packet_filter_params(struct net_device *dev,
9510 struct iw_request_info *info,
9511 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309512{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309513 hdd_adapter_t *pAdapter;
9514 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009515 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309516 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309517 struct iw_point s_priv_data;
9518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309519 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309520
9521 if (!capable(CAP_NET_ADMIN))
9522 {
9523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9524 FL("permission check failed"));
9525 return -EPERM;
9526 }
9527
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9529 if (NULL == pAdapter)
9530 {
9531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9532 "%s: Adapter is NULL",__func__);
9533 return -EINVAL;
9534 }
9535 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9536 ret = wlan_hdd_validate_context(pHddCtx);
9537 if (0 != ret)
9538 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309539 return ret;
9540 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309541 if (hdd_priv_get_data(&s_priv_data, wrqu))
9542 {
9543 return -EINVAL;
9544 }
9545
9546 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9547 {
9548 return -EINVAL;
9549 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009550
Arif Hussain0273cba2014-01-07 20:58:29 -08009551 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309552 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9553 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009554 if (NULL == pRequest)
9555 {
9556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9557 "mem_alloc_copy_from_user_helper fail");
9558 return -ENOMEM;
9559 }
9560
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309561 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009562 kfree(pRequest);
9563
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309564 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009565 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009566}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309567
9568static int iw_set_packet_filter_params(struct net_device *dev,
9569 struct iw_request_info *info,
9570 union iwreq_data *wrqu, char *extra)
9571{
9572 int ret;
9573
9574 vos_ssr_protect(__func__);
9575 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9576 vos_ssr_unprotect(__func__);
9577
9578 return ret;
9579}
Jeff Johnson295189b2012-06-20 16:38:30 -07009580#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309581static int __iw_get_statistics(struct net_device *dev,
9582 struct iw_request_info *info,
9583 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009584{
9585
9586 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9587 eHalStatus status = eHAL_STATUS_SUCCESS;
9588 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309589 hdd_adapter_t *pAdapter;
9590 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309592 int tlen = 0, ret = 0;
9593 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009594
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309595 tCsrGlobalClassAStatsInfo *aStats;
9596 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009597
9598 ENTER();
9599
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309600 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9601 if (NULL == pAdapter)
9602 {
9603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9604 "%s: Adapter is NULL",__func__);
9605 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309607 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9608 ret = wlan_hdd_validate_context(pHddCtx);
9609 if (0 != ret)
9610 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309611 return ret;
9612 }
9613 pStats = &(pAdapter->hdd_stats.summary_stat);
9614 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9615 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9617
9618 wrqu->txpower.value = 0;
9619 }
9620 else {
9621 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9622 SME_SUMMARY_STATS |
9623 SME_GLOBAL_CLASSA_STATS |
9624 SME_GLOBAL_CLASSB_STATS |
9625 SME_GLOBAL_CLASSC_STATS |
9626 SME_GLOBAL_CLASSD_STATS |
9627 SME_PER_STA_STATS,
9628 hdd_StatisticsCB, 0, FALSE,
9629 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9630
9631 if (eHAL_STATUS_SUCCESS != status)
9632 {
9633 hddLog(VOS_TRACE_LEVEL_ERROR,
9634 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009635 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 return -EINVAL;
9637 }
9638
9639 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309640 if (NULL == pWextState)
9641 {
9642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9643 "%s: pWextState is NULL",__func__);
9644 return -EINVAL;
9645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009646
9647 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9648 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9649 {
9650 hddLog(VOS_TRACE_LEVEL_ERROR,
9651 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009652 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 /*Remove the SME statistics list by passing NULL in callback argument*/
9654 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9655 SME_SUMMARY_STATS |
9656 SME_GLOBAL_CLASSA_STATS |
9657 SME_GLOBAL_CLASSB_STATS |
9658 SME_GLOBAL_CLASSC_STATS |
9659 SME_GLOBAL_CLASSD_STATS |
9660 SME_PER_STA_STATS,
9661 NULL, 0, FALSE,
9662 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9663
9664 return -EINVAL;
9665 }
9666 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9667 (tANI_U8) sizeof (pStats->retry_cnt),
9668 (char*) &(pStats->retry_cnt[0]),
9669 tlen);
9670
9671 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9672 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9673 (char*) &(pStats->multiple_retry_cnt[0]),
9674 tlen);
9675
9676 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9677 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9678 (char*) &(pStats->tx_frm_cnt[0]),
9679 tlen);
9680
9681 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9682 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9683 (char*) &(pStats->rx_frm_cnt),
9684 tlen);
9685
9686 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9687 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9688 (char*) &(pStats->frm_dup_cnt),
9689 tlen);
9690
9691 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9692 (tANI_U8) sizeof (pStats->fail_cnt),
9693 (char*) &(pStats->fail_cnt[0]),
9694 tlen);
9695
9696 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9697 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9698 (char*) &(pStats->rts_fail_cnt),
9699 tlen);
9700
9701 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9702 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9703 (char*) &(pStats->ack_fail_cnt),
9704 tlen);
9705
9706 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9707 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9708 (char*) &(pStats->rts_succ_cnt),
9709 tlen);
9710
9711 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9712 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9713 (char*) &(pStats->rx_discard_cnt),
9714 tlen);
9715
9716 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9717 (tANI_U8) sizeof (pStats->rx_error_cnt),
9718 (char*) &(pStats->rx_error_cnt),
9719 tlen);
9720
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009721 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009722 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009723 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 tlen);
9725
9726 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9727 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9728 (char*) &(dStats->rx_byte_cnt),
9729 tlen);
9730
9731 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9732 (tANI_U8) sizeof (dStats->rx_rate),
9733 (char*) &(dStats->rx_rate),
9734 tlen);
9735
9736 /* Transmit rate, in units of 500 kbit/sec */
9737 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9738 (tANI_U8) sizeof (aStats->tx_rate),
9739 (char*) &(aStats->tx_rate),
9740 tlen);
9741
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009742 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9743 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9744 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009745 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009746 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9747 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9748 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009749 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009750 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9751 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9752 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009753 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009754 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9755 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9756 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009757 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009758 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9759 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9760 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009761 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009762 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9763 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9764 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009765 tlen);
9766
Jeff Johnson295189b2012-06-20 16:38:30 -07009767 wrqu->data.length = tlen;
9768
9769 }
9770
9771 EXIT();
9772
9773 return 0;
9774}
9775
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309776static int iw_get_statistics(struct net_device *dev,
9777 struct iw_request_info *info,
9778 union iwreq_data *wrqu, char *extra)
9779{
9780 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009781
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309782 vos_ssr_protect(__func__);
9783 ret = __iw_get_statistics(dev, info, wrqu, extra);
9784 vos_ssr_unprotect(__func__);
9785
9786 return ret;
9787}
Jeff Johnson295189b2012-06-20 16:38:30 -07009788#ifdef FEATURE_WLAN_SCAN_PNO
9789
9790/*Max Len for PNO notification*/
9791#define MAX_PNO_NOTIFY_LEN 100
9792void found_pref_network_cb (void *callbackContext,
9793 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9794{
9795 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9796 union iwreq_data wrqu;
9797 char buf[MAX_PNO_NOTIFY_LEN+1];
9798
9799 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9800 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9801
9802 // create the event
9803 memset(&wrqu, 0, sizeof(wrqu));
9804 memset(buf, 0, sizeof(buf));
9805
9806 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9807 pPrefNetworkFoundInd->ssId.ssId,
9808 (unsigned int)pPrefNetworkFoundInd->rssi);
9809
9810 wrqu.data.pointer = buf;
9811 wrqu.data.length = strlen(buf);
9812
9813 // send the event
9814
9815 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9816
9817}
9818
9819
9820/*string based input*/
9821VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9822 union iwreq_data *wrqu, char *extra, int nOffset)
9823{
9824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309825 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009826 /* pnoRequest is a large struct, so we make it static to avoid stack
9827 overflow. This API is only invoked via ioctl, so it is
9828 serialized by the kernel rtnl_lock and hence does not need to be
9829 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309830 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309831 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309833 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +05309834 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9836
9837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9838 "PNO data len %d data %s",
9839 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009840 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009841
9842 if (wrqu->data.length <= nOffset )
9843 {
9844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9845 return VOS_STATUS_E_FAILURE;
9846 }
9847
9848 pnoRequest.enable = 0;
9849 pnoRequest.ucNetworksCount = 0;
9850 /*-----------------------------------------------------------------------
9851 Input is string based and expected to be like this:
9852
9853 <enabled> <netw_count>
9854 for each network:
9855 <ssid_len> <ssid> <authentication> <encryption>
9856 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9857 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9858
9859 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009860 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 -07009861
9862 this translates into:
9863 -----------------------------
9864 enable PNO
9865 look for 2 networks:
9866 test - with authentication type 0 and encryption type 0,
9867 that can be found on 3 channels: 1 6 and 11 ,
9868 SSID bcast type is unknown (directed probe will be sent if AP not found)
9869 and must meet -40dBm RSSI
9870
9871 test2 - with auth and enrytption type 4/4
9872 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9873 bcast type is non-bcast (directed probe will be sent)
9874 and must not meet any RSSI threshold
9875
Jeff Johnson8301aa12013-03-28 14:27:29 -07009876 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009878
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309879 /* making sure argument string ends with '\0' */
9880 len = (wrqu->data.length-nOffset) + 1;
9881 data = vos_mem_malloc(len);
9882 if (NULL == data) {
9883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9884 FL("fail to allocate memory %zu"), len);
9885 return -EINVAL;
9886 }
9887 vos_mem_zero(data, len);
9888 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309889 ptr = data;
9890
9891 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009892 {
9893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9894 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309895 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -07009896 return VOS_STATUS_E_FAILURE;
9897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009898
9899 if ( 0 == pnoRequest.enable )
9900 {
9901 /*Disable PNO*/
9902 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309903 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9904 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 pAdapter->sessionId,
9906 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309907 if (eHAL_STATUS_SUCCESS != status)
9908 {
9909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9910 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309911 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +05309912 return VOS_STATUS_E_FAILURE;
9913 }
9914 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309915 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 return VOS_STATUS_SUCCESS;
9917 }
9918
c_hpothu37f21312014-04-09 21:49:54 +05309919 if (TRUE == pHddCtx->isPnoEnable)
9920 {
9921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9922 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309923 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +05309924 return -EBUSY;
9925 }
9926 pHddCtx->isPnoEnable = TRUE;
9927
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009929
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309930 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009931 {
9932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9933 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309934 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009936
9937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9938 "PNO enable %d networks count %d offset %d",
9939 pnoRequest.enable,
9940 pnoRequest.ucNetworksCount,
9941 nOffset);
9942
9943 /* Parameters checking:
9944 ucNetworksCount has to be larger than 0*/
9945 if (( 0 == pnoRequest.ucNetworksCount ) ||
9946 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9947 {
9948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309949 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 }
9951
9952 ptr += nOffset;
9953
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309954 pnoRequest.aNetworks =
9955 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9956 if (pnoRequest.aNetworks == NULL)
9957 {
9958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9959 FL("failed to allocate memory aNetworks %u"),
9960 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9961 goto error;
9962 }
9963 vos_mem_zero(pnoRequest.aNetworks,
9964 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9965
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9967 {
9968
9969 pnoRequest.aNetworks[i].ssId.length = 0;
9970
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309971 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009972 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9973
9974 if (1 != ucParams)
9975 {
9976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9977 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309978 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009980
9981 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9982 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9983 {
9984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9985 "SSID Len %d is not correct for network %d",
9986 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309987 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 }
9989
9990 /*Advance to SSID*/
9991 ptr += nOffset;
9992
Jeff Johnson8301aa12013-03-28 14:27:29 -07009993 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009994 pnoRequest.aNetworks[i].ssId.length);
9995 ptr += pnoRequest.aNetworks[i].ssId.length;
9996
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309997 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009998 &(pnoRequest.aNetworks[i].authentication),
9999 &(pnoRequest.aNetworks[i].encryption),
10000 &(pnoRequest.aNetworks[i].ucChannelCount),
10001 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002
Wilson Yang623f6592013-10-08 16:33:37 -070010003 if ( 3 != ucParams )
10004 {
10005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10006 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010007 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010008 }
10009
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010011 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010012 "auth %d encry %d channel count %d offset %d",
10013 pnoRequest.aNetworks[i].ssId.length,
10014 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10015 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10016 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10017 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10018 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10019 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10020 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10021 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10022 pnoRequest.aNetworks[i].authentication,
10023 pnoRequest.aNetworks[i].encryption,
10024 pnoRequest.aNetworks[i].ucChannelCount,
10025 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010026
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 /*Advance to channel list*/
10028 ptr += nOffset;
10029
Wilson Yang623f6592013-10-08 16:33:37 -070010030 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 {
10032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10033 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010034 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 }
10036
10037 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10038 {
10039 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10040 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010041 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010042 &(pnoRequest.aNetworks[i].aChannels[j]),
10043 &nOffset))
10044 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10045 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010046 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010047 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010048 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10050 FL("invalid channel: %hhu"),
10051 pnoRequest.aNetworks[i].aChannels[j]);
10052 goto error;
10053 }
10054
Wilson Yang623f6592013-10-08 16:33:37 -070010055 /*Advance to next channel number*/
10056 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 }
10058 }
10059
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010060 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010061 &(pnoRequest.aNetworks[i].bcastNetwType),
10062 &nOffset))
10063 {
10064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10065 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010066 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010067 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010068 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10070 FL("invalid bcast nw type: %u"),
10071 pnoRequest.aNetworks[i].bcastNetwType);
10072 goto error;
10073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010074
10075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10076 "PNO bcastNetwType %d offset %d",
10077 pnoRequest.aNetworks[i].bcastNetwType,
10078 nOffset );
10079
10080 /*Advance to rssi Threshold*/
10081 ptr += nOffset;
10082
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010083 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010084 &(pnoRequest.aNetworks[i].rssiThreshold),
10085 &nOffset))
10086 {
10087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10088 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010089 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010091
10092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10093 "PNO rssi %d offset %d",
10094 pnoRequest.aNetworks[i].rssiThreshold,
10095 nOffset );
10096 /*Advance to next network*/
10097 ptr += nOffset;
10098 }/*For ucNetworkCount*/
10099
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010100 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010101 &(pnoRequest.scanTimers.ucScanTimersCount),
10102 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010103
10104 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010105 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 {
10107 ptr += nOffset;
10108
Jeff Johnson8301aa12013-03-28 14:27:29 -070010109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10110 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 pnoRequest.scanTimers.ucScanTimersCount,
10112 nOffset );
10113
10114 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10115 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010118 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 }
10120
10121 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10122 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010123 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10125 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10126 &nOffset);
10127
Wilson Yang623f6592013-10-08 16:33:37 -070010128 if (2 != ucParams)
10129 {
10130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10131 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010132 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010133 }
10134
Jeff Johnson8301aa12013-03-28 14:27:29 -070010135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10136 "PNO Timer value %d Timer repeat %d offset %d",
10137 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10139 nOffset );
10140
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 ptr += nOffset;
10142 }
10143
10144 }
10145 else
10146 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10148 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010149 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10150
10151 /*Scan timers defaults to 5 minutes*/
10152 pnoRequest.scanTimers.ucScanTimersCount = 1;
10153 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10154 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10155 }
10156
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010157 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010158
10159 pnoRequest.modePNO = ucMode;
10160 /*for LA we just expose suspend option*/
10161 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10162 {
10163 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10164 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010165 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10166 if (pnoRequest.p24GProbeTemplate == NULL){
10167 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10168 FL("failed to allocate memory p24GProbeTemplate %u"),
10169 SIR_PNO_MAX_PB_REQ_SIZE);
10170 goto error;
10171 }
10172
10173 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10174 if (pnoRequest.p5GProbeTemplate == NULL){
10175 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10176 FL("failed to allocate memory p5GProbeTemplate %u"),
10177 SIR_PNO_MAX_PB_REQ_SIZE);
10178 goto error;
10179 }
10180
10181 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10182 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010183
c_hpothu37f21312014-04-09 21:49:54 +053010184 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 pAdapter->sessionId,
10186 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010187 if (eHAL_STATUS_SUCCESS == status)
10188 {
10189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10190 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010191 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010192 return VOS_STATUS_SUCCESS;
10193 }
10194error:
10195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10196 "%s: Failed to enable PNO", __func__);
10197 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010198 if (pnoRequest.aNetworks)
10199 vos_mem_free(pnoRequest.aNetworks);
10200 if (pnoRequest.p24GProbeTemplate)
10201 vos_mem_free(pnoRequest.p24GProbeTemplate);
10202 if (pnoRequest.p5GProbeTemplate)
10203 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010204
10205 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010206 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010207}/*iw_set_pno*/
10208
10209VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10210 union iwreq_data *wrqu, char *extra, int nOffset)
10211{
10212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10213 v_U8_t rssiThreshold = 0;
10214 v_U8_t nRead;
10215
Arif Hussain7adce1b2013-11-11 22:59:34 -080010216 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 &rssiThreshold);
10218
10219 if ( 1 != nRead )
10220 {
10221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10222 "Incorrect format");
10223 return VOS_STATUS_E_FAILURE;
10224 }
10225
10226 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10227 return VOS_STATUS_SUCCESS;
10228}
10229
10230
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010231static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 struct iw_request_info *info,
10233 union iwreq_data *wrqu, char *extra)
10234{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010235 hdd_adapter_t *pAdapter;
10236 hdd_context_t *pHddCtx;
10237 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010238 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010240 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010241 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10242 if (NULL == pAdapter)
10243 {
10244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10245 "%s: Adapter is NULL",__func__);
10246 return -EINVAL;
10247 }
10248
10249 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10250 ret = wlan_hdd_validate_context(pHddCtx);
10251 if (0 != ret)
10252 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010253 return ret;
10254 }
10255
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010256
10257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010260 status = iw_set_pno(dev,info,wrqu,extra,0);
10261
10262 EXIT();
10263 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010264}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010265
10266static int iw_set_pno_priv(struct net_device *dev,
10267 struct iw_request_info *info,
10268 union iwreq_data *wrqu, char *extra)
10269{
10270 int ret;
10271
10272 vos_ssr_protect(__func__);
10273 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10274 vos_ssr_unprotect(__func__);
10275
10276 return ret;
10277}
Jeff Johnson295189b2012-06-20 16:38:30 -070010278#endif /*FEATURE_WLAN_SCAN_PNO*/
10279
10280//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010281int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010282{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010283 hdd_adapter_t *pAdapter;
10284 tHalHandle hHal;
10285 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010286 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010287 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010288 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010290 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010291 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010292 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010293
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010294 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010295 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10296 if (NULL == pAdapter)
10297 {
10298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10299 "%s: Adapter is NULL",__func__);
10300 return -EINVAL;
10301 }
10302 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10303 retval = wlan_hdd_validate_context(pHddCtx);
10304 if (0 != retval)
10305 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010306 return retval;
10307 }
10308 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10309 if (NULL == hHal)
10310 {
10311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10312 "%s: Hal Context is NULL",__func__);
10313 return -EINVAL;
10314 }
10315 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010316
Atul Mittal54378cb2014-04-02 16:51:50 +053010317 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 {
10319 case WLAN_HDD_UI_BAND_AUTO:
10320 band = eCSR_BAND_ALL;
10321 break;
10322 case WLAN_HDD_UI_BAND_5_GHZ:
10323 band = eCSR_BAND_5G;
10324 break;
10325 case WLAN_HDD_UI_BAND_2_4_GHZ:
10326 band = eCSR_BAND_24;
10327 break;
10328 default:
10329 band = eCSR_BAND_MAX;
10330 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010331 connectedBand =
10332 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010333
Atul Mittal54378cb2014-04-02 16:51:50 +053010334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010335 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010336
10337 if (band == eCSR_BAND_MAX)
10338 {
10339 /* Received change band request with invalid band value */
10340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010341 "%s: Invalid band value %u", __func__, ui_band);
10342 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010343 }
10344
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010345 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010346 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010347 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010349 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010350 band, pHddCtx->cfg_ini->nBandCapability);
10351 return -EIO;
10352 }
10353
Sushant Kaushik1165f872015-03-30 20:25:27 +053010354 if (band == eCSR_BAND_ALL)
10355 {
10356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10357 "received. Setting band same as ini value %d"),
10358 pHddCtx->cfg_ini->nBandCapability);
10359 band = pHddCtx->cfg_ini->nBandCapability;
10360 }
10361
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10363 {
10364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10365 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010366 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 return -EIO;
10368 }
10369
10370 if (currBand != band)
10371 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010372 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010373 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010374 /* Return failure if current country code is world regulatory domain*/
10375 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10376 pMac->scan.countryCodeCurrent[1] == '0') )
10377 {
10378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10379 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010380 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010381 return -EAGAIN;
10382 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010383 }
10384
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 /* Change band request received.
10386 * Abort pending scan requests, flush the existing scan results,
10387 * and change the band capability
10388 */
10389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10390 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010391 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010392
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010393 /* We need to change the band and flush the scan results here itself
10394 * as we may get timeout for disconnection in which we will return
10395 * with out doing any of these
10396 */
10397 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10398 {
10399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10400 "%s: failed to set the band value to %u ",
10401 __func__, band);
10402 return -EINVAL;
10403 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010404 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10405 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010406 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010407 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10408 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010409 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010410 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10411 * information available in NV so to get the channel information from kernel
10412 * we need to send regulatory hint for the currunt country
10413 * And to set the same country again we need to set the dummy country
10414 * first and then the actual country.
10415 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010416#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10417 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10418#else
10419 regulatory_hint_user("00");
10420#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010421 wait_result = wait_for_completion_interruptible_timeout(
10422 &pHddCtx->linux_reg_req,
10423 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10424
10425 /* if the country information does not exist with the kernel,
10426 then the driver callback would not be called */
10427
10428 if (wait_result >= 0)
10429 {
10430 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10431 "runtime country code is found in kernel db");
10432 }
10433 else
10434 {
10435 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10436 "runtime country code is not found"
10437 " in kernel db");
10438 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010439
10440 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010441
10442 /*
10443 * Update 11dcountry and current country here as the hint
10444 * with 00 results in 11d and current country with 00
10445 */
10446 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10447 WNI_CFG_COUNTRY_CODE_LEN);
10448 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10449 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10451 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10452#else
10453 regulatory_hint_user(curr_country);
10454#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010455 wait_result = wait_for_completion_interruptible_timeout(
10456 &pHddCtx->linux_reg_req,
10457 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10458
10459 /* if the country information does not exist with the kernel,
10460 then the driver callback would not be called */
10461 if (wait_result >= 0)
10462 {
10463 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10464 "runtime country code is found in kernel db");
10465 }
10466 else
10467 {
10468 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10469 "runtime country code is not found"
10470 " in kernel db");
10471 }
10472
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010473 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010474 }
10475 else
10476 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010477#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010478 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10479 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010480#else
10481 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10482#endif
10483
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010484 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010485 pScanInfo = &pHddCtx->scan_info;
10486 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10487 {
10488 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10489 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10490 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010491 sme_FilterScanResults(hHal, pAdapter->sessionId);
10492
10493 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010494 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10495 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 eHalStatus status = eHAL_STATUS_SUCCESS;
10498 long lrc;
10499
10500 /* STA already connected on current band, So issue disconnect first,
10501 * then change the band*/
10502
10503 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010504 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010505 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010506
Jeff Johnson295189b2012-06-20 16:38:30 -070010507 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10508
10509 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10510 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10511
Jeff Johnson43971f52012-07-17 12:26:56 -070010512 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010513 {
10514 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010515 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 __func__, (int)status );
10517 return -EINVAL;
10518 }
10519
10520 lrc = wait_for_completion_interruptible_timeout(
10521 &pAdapter->disconnect_comp_var,
10522 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10523
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010524 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010525
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010526 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010527 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010528
10529 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10530 }
10531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010533 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010534 if (TRUE == pHddCtx->isSetBandByNL)
10535 return 0;
10536 else
10537 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010538}
10539
Atul Mittal54378cb2014-04-02 16:51:50 +053010540int hdd_setBand_helper(struct net_device *dev, const char *command)
10541{
10542 u8 band;
10543
10544 /*convert the band value from ascii to integer*/
10545 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10546
10547 return hdd_setBand(dev, band);
10548
10549}
10550
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010551static int __iw_set_band_config(struct net_device *dev,
10552 struct iw_request_info *info,
10553 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010554{
Atul Mittal54378cb2014-04-02 16:51:50 +053010555 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010556
Arif Hussain0273cba2014-01-07 20:58:29 -080010557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010558
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010559 if (!capable(CAP_NET_ADMIN))
10560 {
10561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10562 FL("permission check failed"));
10563 return -EPERM;
10564 }
10565
Atul Mittal54378cb2014-04-02 16:51:50 +053010566 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010567}
10568
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010569static int iw_set_band_config(struct net_device *dev,
10570 struct iw_request_info *info,
10571 union iwreq_data *wrqu, char *extra)
10572{
10573 int ret;
10574
10575 vos_ssr_protect(__func__);
10576 ret = __iw_set_band_config(dev, info, wrqu, extra);
10577 vos_ssr_unprotect(__func__);
10578
10579 return ret;
10580}
10581
c_manjeecfd1efb2015-09-25 19:32:34 +053010582static int get_fwr_memdump(struct net_device *dev,
10583 struct iw_request_info *info,
10584 union iwreq_data *wrqu, char *extra)
10585{
10586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10587 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10588 int ret;
10589 ENTER();
10590 // HddCtx sanity
10591 ret = wlan_hdd_validate_context(pHddCtx);
10592 if (0 != ret)
10593 {
10594 return ret;
10595 }
10596 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10597 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10598 {
10599 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10600 return -EINVAL;
10601 }
10602 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10603
10604 EXIT();
10605 return ret;
10606}
10607
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010608static int __iw_set_power_params_priv(struct net_device *dev,
10609 struct iw_request_info *info,
10610 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010611{
Arif Hussain0273cba2014-01-07 20:58:29 -080010612 int ret;
10613 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010614
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10616 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010617
10618 if (!capable(CAP_NET_ADMIN))
10619 {
10620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10621 FL("permission check failed"));
10622 return -EPERM;
10623 }
10624
Arif Hussain0273cba2014-01-07 20:58:29 -080010625 /* ODD number is used for set, copy data using copy_from_user */
10626 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10627 wrqu->data.length);
10628 if (NULL == ptr)
10629 {
10630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10631 "mem_alloc_copy_from_user_helper fail");
10632 return -ENOMEM;
10633 }
10634
10635 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10636 kfree(ptr);
10637 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010638}
10639
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010640static int iw_set_power_params_priv(struct net_device *dev,
10641 struct iw_request_info *info,
10642 union iwreq_data *wrqu, char *extra)
10643{
10644 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010645
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010646 vos_ssr_protect(__func__);
10647 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10648 vos_ssr_unprotect(__func__);
10649
10650 return ret;
10651}
Jeff Johnson295189b2012-06-20 16:38:30 -070010652
10653/*string based input*/
10654VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10655 union iwreq_data *wrqu, char *extra, int nOffset)
10656{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010657 hdd_adapter_t *pAdapter;
10658 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 tSirSetPowerParamsReq powerRequest;
10660 char *ptr;
10661 v_U8_t ucType;
10662 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010663 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010664
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010665 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10667 if (NULL == pAdapter)
10668 {
10669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10670 "%s: Adapter is NULL",__func__);
10671 return -EINVAL;
10672 }
10673
10674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10675 ret = wlan_hdd_validate_context(pHddCtx);
10676 if (0 != ret)
10677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010678 return ret;
10679 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10681 "Power Params data len %d data %s",
10682 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010683 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010684
10685 if (wrqu->data.length <= nOffset )
10686 {
10687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10688 return VOS_STATUS_E_FAILURE;
10689 }
10690
10691 uTotalSize = wrqu->data.length - nOffset;
10692
10693 /*-----------------------------------------------------------------------
10694 Input is string based and expected to be like this:
10695
10696 <param_type> <param_value> <param_type> <param_value> ...
10697
10698 e.g:
10699 1 2 2 3 3 0 4 1 5 1
10700
10701 e.g. setting just a few:
10702 1 2 4 1
10703
10704 parameter types:
10705 -----------------------------
10706 1 - Ignore DTIM
10707 2 - Listen Interval
10708 3 - Broadcast Multicas Filter
10709 4 - Beacon Early Termination
10710 5 - Beacon Early Termination Interval
10711 -----------------------------------------------------------------------*/
10712 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10713 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10714 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10715 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10716 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10717
Arif Hussain7adce1b2013-11-11 22:59:34 -080010718 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010719
10720 while ( uTotalSize )
10721 {
Wilson Yang6f971452013-10-08 15:00:00 -070010722 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10723 {
10724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10725 "Invalid input parameter type %s",ptr);
10726 return VOS_STATUS_E_FAILURE;
10727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010728
10729 uTotalSize -= nOffset;
10730
10731 if (!uTotalSize)
10732 {
10733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010734 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 ucType, nOffset);
10736 return VOS_STATUS_E_FAILURE;
10737 }
10738
10739 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010740
Jeff Johnson02797792013-10-26 19:17:13 -070010741 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010742 {
10743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10744 "Invalid input parameter value %s",ptr);
10745 return VOS_STATUS_E_FAILURE;
10746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010747
10748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10749 "Power request parameter %d value %d offset %d",
10750 ucType, uValue, nOffset);
10751
10752 switch (ucType)
10753 {
10754 case eSIR_IGNORE_DTIM:
10755 powerRequest.uIgnoreDTIM = uValue;
10756 break;
10757 case eSIR_LISTEN_INTERVAL:
10758 powerRequest.uListenInterval = uValue;
10759 break;
10760 case eSIR_MCAST_BCAST_FILTER:
10761 powerRequest.uBcastMcastFilter = uValue;
10762 break;
10763 case eSIR_ENABLE_BET:
10764 powerRequest.uEnableBET = uValue;
10765 break;
10766 case eSIR_BET_INTERVAL:
10767 powerRequest.uBETInterval = uValue;
10768 break;
10769 default:
10770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010771 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 ucType, uValue, nOffset);
10773 return VOS_STATUS_E_FAILURE;
10774 }
10775
10776 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10778 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010779 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010781 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010782 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010783 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10784 {
10785 uTotalSize = 0;
10786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010787
10788 }/*Go for as long as we have a valid string*/
10789
10790 /* put the device into full power*/
10791 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10792
10793 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010794 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010795
10796 /* put the device back to power save*/
10797 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10798
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010799 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 return VOS_STATUS_SUCCESS;
10801}/*iw_set_power_params*/
10802
Atul Mittalc0f739f2014-07-31 13:47:47 +053010803// tdlsoffchan
10804#ifdef FEATURE_WLAN_TDLS
10805
Atul Mittal87ec2422014-09-24 13:12:50 +053010806int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010807{
10808 if (offchannel < 0 || offchannel > 165)
10809 {
10810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10811 __func__, offchannel);
10812 return -1;
10813
10814 }
10815
10816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10817 __func__, tdlsOffCh, offchannel);
10818
10819 tdlsOffCh = offchannel;
10820 return 0;
10821}
10822
Atul Mittal87ec2422014-09-24 13:12:50 +053010823int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010824{
10825 if (offchanoffset == 0)
10826 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010827 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10829 __func__, tdlsOffChBwOffset);
10830
10831 return 0;
10832
10833 }
10834
10835 if ( offchanoffset == 40 )
10836 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010837 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10839 __func__, tdlsOffChBwOffset);
10840
10841 return 0;
10842
10843 }
10844 if (offchanoffset == -40)
10845 {
10846 tdlsOffChBwOffset = 3;
10847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10848 __func__, tdlsOffChBwOffset);
10849
10850 return 0;
10851
10852 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010853
10854 if ((offchanoffset == 80) &&
10855 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10856 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10857 {
10858 tdlsOffChBwOffset = 4;
10859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10860 "%s: change tdls secondary off channel offset to %u",
10861 __func__, tdlsOffChBwOffset);
10862
10863 return 0;
10864 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10866 __func__, offchanoffset);
10867 return -1;
10868}
10869
Atul Mittal87ec2422014-09-24 13:12:50 +053010870int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010871{
10872 hddTdlsPeer_t *connPeer = NULL;
10873 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10874 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010875 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010876 if (offchanmode < 0 || offchanmode > 4)
10877 {
10878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10879 "%s: Invalid tdls off channel mode %d",
10880 __func__, offchanmode);
10881 return -1;
10882 }
10883
10884 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10885 {
10886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10887 "%s: tdls off channel mode req in not associated state %d",
10888 __func__, offchanmode);
10889 return -1;
10890 }
10891
10892 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10893 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10894 {
10895 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010896 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010897 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010898 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010899 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10901 "%s: No TDLS Connected Peer", __func__);
10902 return -1;
10903 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010904 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010905 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010906 }
10907 else
10908 {
10909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10910 "%s: TDLS Connection not supported", __func__);
10911 return -1;
10912 }
10913
10914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10915 ("%s: TDLS Channel Switch in swmode=%d"),
10916 __func__, offchanmode);
10917
10918 switch (offchanmode)
10919 {
10920 case 1:/*Enable*/
10921 case 2:/*Disable*/
10922 {
10923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10924 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10925 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10926 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10927 {
10928
10929 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010930 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010931 tdlsOffCh, tdlsOffChBwOffset,
10932 offchanmode);
10933 }
10934 else
10935 {
10936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10937 "%s: TDLS Off Channel not supported", __func__);
10938 return -1;
10939 }
10940 break;
10941 }
10942 case 3:
10943 {
10944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10945 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10946 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10947
10948 break;
10949 }
10950 case 4:
10951 {
10952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10953 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10954 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10955 break;
10956 }
10957 default:
10958 {
10959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10960 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10961 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10962 break;
10963 }
10964
10965 }
10966
10967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10968 __func__, offchanmode);
10969 return 0;
10970}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010971#endif
10972
Jeff Johnson295189b2012-06-20 16:38:30 -070010973
10974// Define the Wireless Extensions to the Linux Network Device structure
10975// A number of these routines are NULL (meaning they are not implemented.)
10976
10977static const iw_handler we_handler[] =
10978{
10979 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10980 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10981 (iw_handler) NULL, /* SIOCSIWNWID */
10982 (iw_handler) NULL, /* SIOCGIWNWID */
10983 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10984 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10985 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10986 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10987 (iw_handler) NULL, /* SIOCSIWSENS */
10988 (iw_handler) NULL, /* SIOCGIWSENS */
10989 (iw_handler) NULL, /* SIOCSIWRANGE */
10990 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010991 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 (iw_handler) NULL, /* SIOCGIWPRIV */
10993 (iw_handler) NULL, /* SIOCSIWSTATS */
10994 (iw_handler) NULL, /* SIOCGIWSTATS */
10995 iw_handler_set_spy, /* SIOCSIWSPY */
10996 iw_handler_get_spy, /* SIOCGIWSPY */
10997 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10998 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10999 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11000 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11001 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11002 (iw_handler) NULL, /* SIOCGIWAPLIST */
11003 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11004 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11005 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11006 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11007 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11008 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11009 (iw_handler) NULL, /* -- hole -- */
11010 (iw_handler) NULL, /* -- hole -- */
11011 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11012 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11013 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11014 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11015 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11016 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11017 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11018 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11019 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11020 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11021 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11022 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11023 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11024 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11025 (iw_handler) NULL, /* -- hole -- */
11026 (iw_handler) NULL, /* -- hole -- */
11027 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11028 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11029 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11030 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11031 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11032 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11033 (iw_handler) NULL, /* SIOCSIWPMKSA */
11034};
11035
11036static const iw_handler we_private[] = {
11037
11038 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11039 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11040 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11041 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11042 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11043 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011044 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11046 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11047 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011048 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11049 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011050#ifdef FEATURE_OEM_DATA_SUPPORT
11051 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11052 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11053#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011054
Jeff Johnson295189b2012-06-20 16:38:30 -070011055#ifdef WLAN_FEATURE_VOWIFI_11R
11056 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11057#endif
11058 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11059 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11060 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11061#ifdef WLAN_FEATURE_PACKET_FILTERING
11062 ,
11063 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11064#endif
11065#ifdef FEATURE_WLAN_SCAN_PNO
11066 ,
11067 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11068#endif
11069 ,
11070 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11071 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11072 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11073 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011074 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011075};
11076
11077/*Maximum command length can be only 15 */
11078static const struct iw_priv_args we_private_args[] = {
11079
Katya Nigamf0511f62015-05-05 16:40:57 +053011080 { WE_SET_MONITOR_STATE,
11081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11082 0, "monitor" },
11083
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 /* handlers for main ioctl */
11085 { WLAN_PRIV_SET_INT_GET_NONE,
11086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11087 0,
11088 "" },
11089
11090 /* handlers for sub-ioctl */
11091 { WE_SET_11D_STATE,
11092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11093 0,
11094 "set11Dstate" },
11095
11096 { WE_WOWL,
11097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11098 0,
11099 "wowl" },
11100
11101 { WE_SET_POWER,
11102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11103 0,
11104 "setPower" },
11105
11106 { WE_SET_MAX_ASSOC,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11108 0,
11109 "setMaxAssoc" },
11110
11111 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11113 0,
11114 "setAutoChannel" },
11115
11116 { WE_SET_DATA_INACTIVITY_TO,
11117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11118 0,
11119 "inactivityTO" },
11120
11121 { WE_SET_MAX_TX_POWER,
11122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11123 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011124 "setMaxTxPower" },
11125
11126 { WE_SET_MAX_TX_POWER_2_4,
11127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11128 0,
11129 "setTxMaxPower2G" },
11130
11131 { WE_SET_MAX_TX_POWER_5_0,
11132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11133 0,
11134 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011135
11136 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11137 * as well to keep same syntax as in SAP. Now onwards, STA
11138 * will support both */
11139 { WE_SET_MAX_TX_POWER,
11140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11141 0,
11142 "setTxMaxPower" },
11143
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11145 * 1 = enable and 0 = disable */
11146 {
11147 WE_SET_HIGHER_DTIM_TRANSITION,
11148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11149 0,
11150 "setHDtimTransn" },
11151
11152 { WE_SET_TM_LEVEL,
11153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011154 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011155 "setTmLevel" },
11156
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011157 { WE_ENABLE_STRICT_FCC_REG,
11158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11159 0,
11160 "setStrictFCCreg" },
11161
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011162 { WE_SET_DEBUG_LOG,
11163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11164 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011165#ifdef FEATURE_WLAN_TDLS
11166 {
11167 WE_SET_TDLS_OFF_CHAN,
11168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11169 0,
11170 "tdlsoffchan" },
11171 {
11172 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11174 0,
11175 "tdlsecchnoffst" },
11176 {
11177 WE_SET_TDLS_OFF_CHAN_MODE,
11178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11179 0,
11180 "tdlsoffchnmode" },
11181#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011182
Peng Xu2446a892014-09-05 17:21:18 +053011183 { WE_SET_SCAN_BAND_PREFERENCE,
11184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11185 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011186 {
11187 WE_GET_FRAME_LOG,
11188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11189 0,
11190 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011191
Abhishek Singh01c73d12015-03-12 15:13:44 +053011192 { WE_SET_MIRACAST_VENDOR_CONFIG,
11193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11194 0, "setMiracstConf" },
11195
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011196#ifdef FEATURE_WLAN_TDLS
11197 {
11198 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11200 0,
11201 "tdls_2040bsscox" },
11202#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011203 { WE_SET_RTS_CTS_HTVHT,
11204 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11205 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011206 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11208 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011209 { WE_SET_PROXIMITY_ENABLE,
11210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11211 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011212
11213#ifdef WLAN_FEATURE_TSF
11214 { WE_CAP_TSF,
11215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11216 0, "cap_tsf" },
11217#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 /* handlers for main ioctl */
11219 { WLAN_PRIV_SET_NONE_GET_INT,
11220 0,
11221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11222 "" },
11223
11224 /* handlers for sub-ioctl */
11225 { WE_GET_11D_STATE,
11226 0,
11227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11228 "get11Dstate" },
11229
11230 { WE_IBSS_STATUS,
11231 0,
11232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11233 "getAdhocStatus" },
11234
11235 { WE_PMC_STATE,
11236 0,
11237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11238 "pmcState" },
11239
11240 { WE_GET_WLAN_DBG,
11241 0,
11242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11243 "getwlandbg" },
11244
Jeff Johnson295189b2012-06-20 16:38:30 -070011245 { WE_GET_MAX_ASSOC,
11246 0,
11247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11248 "getMaxAssoc" },
11249
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 { WE_GET_WDI_DBG,
11251 0,
11252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11253 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011254
11255 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11256 0,
11257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11258 "getAutoChannel" },
11259
11260 { WE_GET_CONCURRENCY_MODE,
11261 0,
11262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11263 "getconcurrency" },
11264
Peng Xu2446a892014-09-05 17:21:18 +053011265 { WE_GET_SCAN_BAND_PREFERENCE,
11266 0,
11267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11268 "get_scan_pref"},
11269
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011270 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11271 0,
11272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11273 "getCurAnt"},
11274
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 /* handlers for main ioctl */
11276 { WLAN_PRIV_SET_CHAR_GET_NONE,
11277 IW_PRIV_TYPE_CHAR| 512,
11278 0,
11279 "" },
11280
11281 /* handlers for sub-ioctl */
11282 { WE_WOWL_ADD_PTRN,
11283 IW_PRIV_TYPE_CHAR| 512,
11284 0,
11285 "wowlAddPtrn" },
11286
11287 { WE_WOWL_DEL_PTRN,
11288 IW_PRIV_TYPE_CHAR| 512,
11289 0,
11290 "wowlDelPtrn" },
11291
11292#if defined WLAN_FEATURE_VOWIFI
11293 /* handlers for sub-ioctl */
11294 { WE_NEIGHBOR_REPORT_REQUEST,
11295 IW_PRIV_TYPE_CHAR | 512,
11296 0,
11297 "neighbor" },
11298#endif
11299 { WE_SET_AP_WPS_IE,
11300 IW_PRIV_TYPE_CHAR| 512,
11301 0,
11302 "set_ap_wps_ie" },
11303
11304 { WE_SET_CONFIG,
11305 IW_PRIV_TYPE_CHAR| 512,
11306 0,
11307 "setConfig" },
11308
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011309 { WE_SET_ENCRYPT_MSG,
11310 IW_PRIV_TYPE_CHAR| 512,
11311 0,
11312 "encryptMsg" },
11313
11314
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 /* handlers for main ioctl */
11316 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11318 0,
11319 "" },
11320
11321 /* handlers for sub-ioctl */
11322 { WE_SET_WLAN_DBG,
11323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11324 0,
11325 "setwlandbg" },
11326
Jeff Johnson295189b2012-06-20 16:38:30 -070011327 { WE_SET_WDI_DBG,
11328 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11329 0,
11330 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011331
11332 { WE_SET_SAP_CHANNELS,
11333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11334 0,
11335 "setsapchannels" },
11336
11337 /* handlers for main ioctl */
11338 { WLAN_PRIV_GET_CHAR_SET_NONE,
11339 0,
11340 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11341 "" },
11342
11343 /* handlers for sub-ioctl */
11344 { WE_WLAN_VERSION,
11345 0,
11346 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11347 "version" },
11348 { WE_GET_STATS,
11349 0,
11350 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11351 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011352 { WE_GET_STATES,
11353 0,
11354 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11355 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 { WE_GET_CFG,
11357 0,
11358 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11359 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011360#ifdef WLAN_FEATURE_11AC
11361 { WE_GET_RSSI,
11362 0,
11363 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11364 "getRSSI" },
11365#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011366#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011367 { WE_GET_ROAM_RSSI,
11368 0,
11369 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11370 "getRoamRSSI" },
11371#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 { WE_GET_WMM_STATUS,
11373 0,
11374 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11375 "getWmmStatus" },
11376 {
11377 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011378 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11380 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011381#ifdef FEATURE_WLAN_TDLS
11382 {
11383 WE_GET_TDLS_PEERS,
11384 0,
11385 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11386 "getTdlsPeers" },
11387#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011388#ifdef WLAN_FEATURE_11W
11389 {
11390 WE_GET_11W_INFO,
11391 0,
11392 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11393 "getPMFInfo" },
11394#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011395#ifdef WLAN_FEATURE_RMC
11396 {
11397 WE_GET_IBSS_STA_INFO,
11398 0,
11399 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11400 "getIbssSTAs" },
11401#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011402 { WE_GET_SNR,
11403 0,
11404 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11405 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011406#ifdef FEATURE_OEM_DATA_SUPPORT
11407 {
11408 WE_GET_OEM_DATA_CAP,
11409 0,
11410 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11411 "getOemDataCap" },
11412#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011413 /* handlers for main ioctl */
11414 { WLAN_PRIV_SET_NONE_GET_NONE,
11415 0,
11416 0,
11417 "" },
11418
11419 /* handlers for sub-ioctl */
11420 { WE_CLEAR_STATS,
11421 0,
11422 0,
11423 "clearStats" },
11424 { WE_INIT_AP,
11425 0,
11426 0,
11427 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011428#ifdef WLAN_FEATURE_RMC
11429 {
11430 WE_IBSS_GET_PEER_INFO_ALL,
11431 0,
11432 0,
11433 "ibssPeerInfoAll" },
11434#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 { WE_STOP_AP,
11436 0,
11437 0,
11438 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011439#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011440 { WE_ENABLE_AMP,
11441 0,
11442 0,
11443 "enableAMP" },
11444 { WE_DISABLE_AMP,
11445 0,
11446 0,
11447 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011448#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011449 { WE_ENABLE_DXE_STALL_DETECT,
11450 0,
11451 0,
11452 "dxeStallDetect" },
11453 { WE_DISPLAY_DXE_SNAP_SHOT,
11454 0,
11455 0,
11456 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011457 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11458 0,
11459 0,
11460 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011461 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011462 WE_SET_REASSOC_TRIGGER,
11463 0,
11464 0,
11465 "reassoc" },
11466 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011467 WE_STOP_OBSS_SCAN,
11468 0,
11469 0,
11470 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011471 {
11472 WE_DUMP_ROAM_TIMER_LOG,
11473 0,
11474 0,
11475 "dumpRoamDelay" },
11476 {
11477 WE_RESET_ROAM_TIMER_LOG,
11478 0,
11479 0,
11480 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011481 {
11482 WE_GET_FW_LOGS,
11483 0,
11484 0,
11485 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011486 {
11487 WE_GET_FW_MEMDUMP,
11488 0,
11489 0,
11490 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 /* handlers for main ioctl */
11492 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11493 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11494 0,
11495 "" },
11496
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011497
11498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 /* handlers for sub-ioctl */
11500 { WE_LOG_DUMP_CMD,
11501 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11502 0,
11503 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011504#ifdef WLAN_FEATURE_RMC
11505 { WE_IBSS_GET_PEER_INFO,
11506 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11507 0,
11508 "ibssPeerInfo" },
11509#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011510
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011511 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011512 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11513 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11514 0,
11515 "setdumplog" },
11516
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011517 { WE_MTRACE_DUMP_CMD,
11518 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11519 0,
11520 "dumplog" },
11521
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011522 /* handlers for sub ioctl */
11523 {
11524 WE_MCC_CONFIG_CREDENTIAL,
11525 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11526 0,
11527 "setMccCrdnl" },
11528
11529 /* handlers for sub ioctl */
11530 {
11531 WE_MCC_CONFIG_PARAMS,
11532 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11533 0,
11534 "setMccConfig" },
11535
Chilam NG571c65a2013-01-19 12:27:36 +053011536#ifdef FEATURE_WLAN_TDLS
11537 /* handlers for sub ioctl */
11538 {
11539 WE_TDLS_CONFIG_PARAMS,
11540 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11541 0,
11542 "setTdlsConfig" },
11543#endif
11544
Katya Nigamf0511f62015-05-05 16:40:57 +053011545 {
11546 WE_CONFIGURE_MONITOR_MODE,
11547 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11548 0,
11549 "MonitorModeConf" },
11550
11551 {
11552 WE_SET_MONITOR_MODE_FILTER,
11553 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11554 0,
11555 "MonitorFilter" },
11556
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 /* handlers for main ioctl */
11558 { WLAN_PRIV_ADD_TSPEC,
11559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11560 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11561 "addTspec" },
11562
11563 /* handlers for main ioctl */
11564 { WLAN_PRIV_DEL_TSPEC,
11565 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11566 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11567 "delTspec" },
11568
11569 /* handlers for main ioctl */
11570 { WLAN_PRIV_GET_TSPEC,
11571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11573 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011574 /* handlers for main ioctl */
11575 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11576 0,
11577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11578 "" },
11579#ifdef WLAN_FEATURE_TSF
11580 { WE_GET_TSF,
11581 0,
11582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11583 "get_tsf" },
11584#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011585#ifdef FEATURE_OEM_DATA_SUPPORT
11586 /* handlers for main ioctl - OEM DATA */
11587 {
11588 WLAN_PRIV_SET_OEM_DATA_REQ,
11589 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11590 0,
11591 "set_oem_data_req" },
11592
11593 /* handlers for main ioctl - OEM DATA */
11594 {
11595 WLAN_PRIV_GET_OEM_DATA_RSP,
11596 0,
11597 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11598 "get_oem_data_rsp" },
11599#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011600
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 /* handlers for main ioctl - host offload */
11602 {
11603 WLAN_PRIV_SET_HOST_OFFLOAD,
11604 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11605 0,
11606 "setHostOffload" },
11607
11608 {
11609 WLAN_GET_WLAN_STATISTICS,
11610 0,
11611 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11612 "getWlanStats" },
11613
11614 {
11615 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011616 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11617 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 0,
11619 "setKeepAlive" },
11620#ifdef WLAN_FEATURE_PACKET_FILTERING
11621 {
11622 WLAN_SET_PACKET_FILTER_PARAMS,
11623 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11624 0,
11625 "setPktFilter" },
11626#endif
11627#ifdef FEATURE_WLAN_SCAN_PNO
11628 {
11629 WLAN_SET_PNO,
11630 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11631 0,
11632 "setpno" },
11633#endif
11634 {
11635 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 0,
11638 "SETBAND" },
11639 /* handlers for dynamic MC BC ioctl */
11640 {
11641 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011642 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 0,
11644 "setMCBCFilter" },
11645 {
11646 WLAN_PRIV_CLEAR_MCBC_FILTER,
11647 0,
11648 0,
11649 "clearMCBCFilter" },
11650 {
11651 WLAN_SET_POWER_PARAMS,
11652 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11653 0,
11654 "setpowerparams" },
11655 {
11656 WLAN_GET_LINK_SPEED,
11657 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011658 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011659};
11660
11661
11662
11663const struct iw_handler_def we_handler_def = {
11664 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11665 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11666 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11667
11668 .standard = (iw_handler *)we_handler,
11669 .private = (iw_handler *)we_private,
11670 .private_args = we_private_args,
11671 .get_wireless_stats = get_wireless_stats,
11672};
11673
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011674int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11675{
11676 v_U32_t cmd = 288; //Command to RIVA
11677 hdd_context_t *pHddCtx = NULL;
11678 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11679 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11680 /*
11681 *configMccParam : specify the bit which needs to be modified
11682 *allowed to update based on wlan_qcom_cfg.ini
11683 * configuration
11684 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11685 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11686 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11687 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11688 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11689 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11690 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11691 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11692 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11693 * Bit 9 : Reserved
11694 */
11695 switch (arg1)
11696 {
11697 //Update MCC SCHEDULE_TIME_SLICE parameter
11698 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11699 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11700 {
11701 if((arg2 >= 5) && (arg2 <= 20))
11702 {
11703 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11704 }
11705 else
11706 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011707 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011708 return 0;
11709 }
11710 }
11711 break;
11712
11713 //Update MCC MAX_NULL_SEND_TIME parameter
11714 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11715 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11716 {
11717 if((arg2 >= 1) && (arg2 <= 10))
11718 {
11719 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11720 }
11721 else
11722 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011723 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011724 return 0;
11725 }
11726 }
11727 break;
11728
11729 //Update MCC TX_EARLY_STOP_TIME parameter
11730 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11731 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11732 {
11733 if((arg2 >= 1) && (arg2 <= 10))
11734 {
11735 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11736 }
11737 else
11738 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011739 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011740 return 0;
11741 }
11742 }
11743 break;
11744
11745 //Update MCC RX_DRAIN_TIME parameter
11746 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11747 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11748 {
11749 if((arg2 >= 1) && (arg2 <= 10))
11750 {
11751 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11752 }
11753 else
11754 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011755 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011756 return 0;
11757 }
11758 }
11759 break;
11760
11761 //Update MCC CHANNEL_SWITCH_TIME parameter
11762 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11763 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11764 {
11765 if((arg2 >= 1) && (arg2 <= 20))
11766 {
11767 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11768 }
11769 else
11770 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011771 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011772 return 0;
11773 }
11774 }
11775 break;
11776
11777 //Update MCC MIN_CHANNEL_TIME parameter
11778 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11779 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11780 {
11781 if((arg2 >= 5) && (arg2 <= 20))
11782 {
11783 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11784 }
11785 else
11786 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011787 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011788 return 0;
11789 }
11790 }
11791 break;
11792
11793 //Update MCC PARK_BEFORE_TBTT parameter
11794 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11795 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11796 {
11797 if((arg2 >= 1) && (arg2 <= 5))
11798 {
11799 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11800 }
11801 else
11802 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011803 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011804 return 0;
11805 }
11806 }
11807 break;
11808
11809 //Update MCC MIN_AFTER_DTIM parameter
11810 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11811 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11812 {
11813 if((arg2 >= 5) && (arg2 <= 15))
11814 {
11815 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11816 }
11817 else
11818 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011819 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011820 return 0;
11821 }
11822 }
11823 break;
11824
11825 //Update MCC TOO_CLOSE_MARGIN parameter
11826 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11827 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11828 {
11829 if((arg2 >= 1) && (arg2 <= 3))
11830 {
11831 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11832 }
11833 else
11834 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011835 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011836 return 0;
11837 }
11838 }
11839 break;
11840
11841 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011842 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011843 __FUNCTION__,arg1);
11844 break;
11845 }
11846 return 0;
11847}
11848
Jeff Johnson295189b2012-06-20 16:38:30 -070011849int hdd_set_wext(hdd_adapter_t *pAdapter)
11850{
11851 hdd_wext_state_t *pwextBuf;
11852 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011853 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011854
11855 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11856
11857 // Now configure the roaming profile links. To SSID and bssid.
11858 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11859 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11860
11861 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11862 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11863
11864 /*Set the numOfChannels to zero to scan all the channels*/
11865 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11866 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11867
11868 /* Default is no encryption */
11869 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11870 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11871
11872 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11873 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11874
11875 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11876
11877 /* Default is no authentication */
11878 pwextBuf->roamProfile.AuthType.numEntries = 1;
11879 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11880
11881 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11882 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11883
11884 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011885 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011886
11887 hdd_clearRoamProfileIe(pAdapter);
11888
11889 return VOS_STATUS_SUCCESS;
11890
11891 }
11892
11893int hdd_register_wext(struct net_device *dev)
11894 {
11895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11896 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11897 VOS_STATUS status;
11898
11899 ENTER();
11900
11901 // Zero the memory. This zeros the profile structure.
11902 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11903
11904 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11905
11906
11907 status = hdd_set_wext(pAdapter);
11908
11909 if(!VOS_IS_STATUS_SUCCESS(status)) {
11910
Arif Hussain6d2a3322013-11-17 19:50:10 -080011911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011912 return eHAL_STATUS_FAILURE;
11913 }
11914
11915 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11916 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 return eHAL_STATUS_FAILURE;
11919 }
11920
11921 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11922 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011924 return eHAL_STATUS_FAILURE;
11925 }
11926
11927 // Register as a wireless device
11928 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11929
11930 EXIT();
11931 return 0;
11932}
11933
11934int hdd_UnregisterWext(struct net_device *dev)
11935{
c_hpothu2a13bc32015-01-21 12:48:54 +053011936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11937 if (dev != NULL)
11938 {
11939 rtnl_lock();
11940 dev->wireless_handlers = NULL;
11941 rtnl_unlock();
11942 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011943
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 return 0;
11945}
11946
11947