blob: 1be6e670d9872081c700d39d93a5943d18791641 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05302 * Copyright (c) 2011-2016 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
Jeff Johnson295189b2012-06-20 16:38:30 -0700177
178/* Private ioctls and their sub-ioctls */
179#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
180#define WE_GET_11D_STATE 1
181#define WE_IBSS_STATUS 2
182#define WE_PMC_STATE 3
183#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700184#define WE_GET_MAX_ASSOC 6
185#define WE_GET_WDI_DBG 7
186#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
187#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530188#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530189#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700190/* Private ioctls and their sub-ioctls */
191#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
192
193/* Private ioctls and their sub-ioctls */
194#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
195#define WE_WOWL_ADD_PTRN 1
196#define WE_WOWL_DEL_PTRN 2
197#if defined WLAN_FEATURE_VOWIFI
198#define WE_NEIGHBOR_REPORT_REQUEST 3
199#endif
200#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
201#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530202#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700203
204/* Private ioctls and their sub-ioctls */
205#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
206#define WE_SET_WLAN_DBG 1
207#define WE_SET_WDI_DBG 2
208#define WE_SET_SAP_CHANNELS 3
209
210/* Private ioctls and their sub-ioctls */
211#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
212#define WE_WLAN_VERSION 1
213#define WE_GET_STATS 2
214#define WE_GET_CFG 3
215#define WE_GET_WMM_STATUS 4
216#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700217#ifdef WLAN_FEATURE_11AC
218#define WE_GET_RSSI 6
219#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800220#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800221#ifdef FEATURE_WLAN_TDLS
222#define WE_GET_TDLS_PEERS 8
223#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700224#ifdef WLAN_FEATURE_11W
225#define WE_GET_11W_INFO 9
226#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530227#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530228#ifdef WLAN_FEATURE_RMC
229#define WE_GET_IBSS_STA_INFO 11
230#endif
231#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700232
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530233#ifdef FEATURE_OEM_DATA_SUPPORT
234#define WE_GET_OEM_DATA_CAP 13
235#endif
236
Jeff Johnson295189b2012-06-20 16:38:30 -0700237/* Private ioctls and their sub-ioctls */
238#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
239#define WE_CLEAR_STATS 1
240#define WE_INIT_AP 2
241#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530242#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700243#define WE_ENABLE_AMP 4
244#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530245#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700246#define WE_ENABLE_DXE_STALL_DETECT 6
247#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700248#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530249#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530250#ifdef WLAN_FEATURE_RMC
251#define WE_IBSS_GET_PEER_INFO_ALL 10
252#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530253#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530254#define WE_DUMP_ROAM_TIMER_LOG 12
255#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530256#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530257#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530258
Jeff Johnson295189b2012-06-20 16:38:30 -0700259/* Private ioctls and their sub-ioctls */
260#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
261#define WE_LOG_DUMP_CMD 1
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800264//IOCTL to configure MCC params
265#define WE_MCC_CONFIG_CREDENTIAL 3
266#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700267
Chilam NG571c65a2013-01-19 12:27:36 +0530268#ifdef FEATURE_WLAN_TDLS
269#define WE_TDLS_CONFIG_PARAMS 5
270#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530271#ifdef WLAN_FEATURE_RMC
272#define WE_IBSS_GET_PEER_INFO 6
273#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530274
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700275#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530276#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530277#define WE_CONFIGURE_MONITOR_MODE 10
278#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700279
Chilam Ng01120412013-02-19 18:32:21 -0800280#ifdef FEATURE_WLAN_TDLS
281#undef MAX_VAR_ARGS
282#define MAX_VAR_ARGS 10
283#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700284#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800285#endif
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287/* Private ioctls (with no sub-ioctls) */
288/* note that they must be odd so that they have "get" semantics */
289#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
290#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
291#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
292
Girish Gowli464c9c82014-06-09 19:47:53 +0530293/* (SIOCIWFIRSTPRIV + 8) is currently unused */
294/* (SIOCIWFIRSTPRIV + 16) is currently unused */
295/* (SIOCIWFIRSTPRIV + 10) is currently unused */
296/* (SIOCIWFIRSTPRIV + 12) is currently unused */
297/* (SIOCIWFIRSTPRIV + 14) is currently unused */
298/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
Jeff Johnsone7245742012-09-05 17:12:55 -0700300#ifdef FEATURE_OEM_DATA_SUPPORT
301/* Private ioctls for setting the measurement configuration */
302#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
303#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700305
306#ifdef WLAN_FEATURE_VOWIFI_11R
307#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
308#endif
309
310/* Private ioctl for setting the host offload feature */
311#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
312
313/* Private ioctl to get the statistics */
314#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
315
316/* Private ioctl to set the Keep Alive Params */
317#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
318#ifdef WLAN_FEATURE_PACKET_FILTERING
319/* Private ioctl to set the Packet Filtering Params */
320#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
321#endif
322
323#ifdef FEATURE_WLAN_SCAN_PNO
324/* Private ioctl to get the statistics */
325#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
326#endif
327
328#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
329
330#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
331#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700332/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
335#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
336
337#define WLAN_STATS_INVALID 0
338#define WLAN_STATS_RETRY_CNT 1
339#define WLAN_STATS_MUL_RETRY_CNT 2
340#define WLAN_STATS_TX_FRM_CNT 3
341#define WLAN_STATS_RX_FRM_CNT 4
342#define WLAN_STATS_FRM_DUP_CNT 5
343#define WLAN_STATS_FAIL_CNT 6
344#define WLAN_STATS_RTS_FAIL_CNT 7
345#define WLAN_STATS_ACK_FAIL_CNT 8
346#define WLAN_STATS_RTS_SUC_CNT 9
347#define WLAN_STATS_RX_DISCARD_CNT 10
348#define WLAN_STATS_RX_ERROR_CNT 11
349#define WLAN_STATS_TX_BYTE_CNT 12
350
351#define WLAN_STATS_RX_BYTE_CNT 13
352#define WLAN_STATS_RX_RATE 14
353#define WLAN_STATS_TX_RATE 15
354
Jeff Johnsone7245742012-09-05 17:12:55 -0700355#define WLAN_STATS_RX_UC_BYTE_CNT 16
356#define WLAN_STATS_RX_MC_BYTE_CNT 17
357#define WLAN_STATS_RX_BC_BYTE_CNT 18
358#define WLAN_STATS_TX_UC_BYTE_CNT 19
359#define WLAN_STATS_TX_MC_BYTE_CNT 20
360#define WLAN_STATS_TX_BC_BYTE_CNT 21
361
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800362#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
363 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
364 { \
365 *__p++ = __type; \
366 *__p++ = __size; \
367 memcpy(__p, __val, __size); \
368 __p += __size; \
369 __tlen += __size + 2; \
370 } \
371 else \
372 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800373 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800374 } \
375 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
377#define VERSION_VALUE_MAX_LEN 32
378
379#define TX_PER_TRACKING_DEFAULT_RATIO 5
380#define TX_PER_TRACKING_MAX_RATIO 10
381#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
382
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530383#define WLAN_ADAPTER 0
384#define P2P_ADAPTER 1
385
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530386#define TX_PWR_MIN 6
387#define TX_PWR_MAX 22
388#define TX_PWR_DEF 50
389
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530390/*
391 * When supplicant sends SETBAND ioctl it queries for channels from
392 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
393 * This is not required if the return type from ioctl is
394 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
395 * event as part of regulatory_hint.
396 */
397enum {
398 SEND_CHANNEL_CHANGE_EVENT = 0,
399 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
400};
401
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800402/*MCC Configuration parameters */
403enum {
404 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
405 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
406 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
407 MCC_RX_DRAIN_TIME_CFG_PARAM,
408 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
409 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
410 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
411 MCC_MIN_AFTER_DTIM_CFG_PARAM,
412 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
413};
414
415int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
416 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
417
Jeff Johnson295189b2012-06-20 16:38:30 -0700418#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530419int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700420#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530421static int get_fwr_memdump(struct net_device *,
422 struct iw_request_info *,
423 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700424/**---------------------------------------------------------------------------
425
Arif Hussain0273cba2014-01-07 20:58:29 -0800426 \brief mem_alloc_copy_from_user_helper -
427
428 Helper function to allocate buffer and copy user data.
429
430 \param - wrqu - Pointer to IOCTL Data.
431 len - size
432
433 \return - On Success pointer to buffer, On failure NULL
434
435 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530436void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800437{
438 u8 *ptr = NULL;
439
440 /* in order to protect the code, an extra byte is post appended to the buffer
441 * and the null termination is added. However, when allocating (len+1) byte
442 * of memory, we need to make sure that there is no uint overflow when doing
443 * addition. In theory check len < UINT_MAX protects the uint overflow. For
444 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
445 * guess, now, it is assumed that the private command buffer size is no
446 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
447 */
448 if (len > MAX_USER_COMMAND_SIZE)
449 {
450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
451 "Invalid length");
452 return NULL;
453 }
454
455 ptr = kmalloc(len + 1, GFP_KERNEL);
456 if (NULL == ptr)
457 {
458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
459 "unable to allocate memory");
460 return NULL;
461 }
462
463 if (copy_from_user(ptr, wrqu_data, len))
464 {
465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
466 "%s: failed to copy data to user buffer", __func__);
467 kfree(ptr);
468 return NULL;
469 }
470 ptr[len] = '\0';
471 return ptr;
472}
473
Girish Gowli488ef492014-06-12 18:44:33 +0530474// Function to handle and get compatible struct iw_point passed to ioctl.
475int hdd_priv_get_data(struct iw_point *p_priv_data,
476 union iwreq_data *wrqu)
477{
478 if ((NULL == p_priv_data) || (NULL == wrqu))
479 {
480 return -EINVAL;
481 }
482
483#ifdef CONFIG_COMPAT
484 if (is_compat_task())
485 {
486 struct compat_iw_point *p_compat_priv_data;
487
488 // Compat task: typecast to campat structure and copy the members.
489 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
490
491 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
492 p_priv_data->length = p_compat_priv_data->length;
493 p_priv_data->flags = p_compat_priv_data->flags;
494 }//if(is_compat_task())
495 else
496 {
497#endif //#ifdef CONFIG_COMPAT
498
499 // Non compat task: directly copy the structure.
500 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
501
502#ifdef CONFIG_COMPAT
503 }//else of - if(is_compat_task())
504#endif //#ifdef CONFIG_COMPAT
505
506 return 0;
507}
508
Arif Hussain0273cba2014-01-07 20:58:29 -0800509/**---------------------------------------------------------------------------
510
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 \brief hdd_wlan_get_version() -
512
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800513 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 \param - pAdapter Pointer to the adapter.
516 wrqu - Pointer to IOCTL REQUEST Data.
517 extra - Pointer to char
518
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800519 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700520
521 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800522void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
523 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700524{
525 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800526 tSirVersionString wcnss_SW_version;
527 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530528 tSirVersionString iris_name;
529 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800530 char *pSWversion;
531 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800534 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
535 sizeof(wcnss_SW_version));
536 if (VOS_IS_STATUS_SUCCESS(status))
537 {
538 pSWversion = wcnss_SW_version;
539 }
540 else
541 {
542 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 }
544
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800545 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
546 sizeof(wcnss_HW_version));
547 if (VOS_IS_STATUS_SUCCESS(status))
548 {
549 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800551 else
552 {
553 pHWversion = "Unknown";
554 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530556 status = wcnss_get_iris_name(iris_name);
557
558 if (!status) {
559 pIRISversion = iris_name;
560 } else {
561 pIRISversion = "Unknown";
562 }
563
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700564 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530565 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800566 QWLAN_VERSIONSTR,
567 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530568 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800569
570 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700571}
572
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530573#ifdef WLAN_FEATURE_RMC
574void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
575{
576 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
577 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
578 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
579 v_U8_t i;
580
581 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
582 {
583 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
584 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
585 for (i = 0; i < pPeerInfo->numPeers; i++)
586 {
587 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
588 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
589 }
590 }
591 else
592 {
593 hddLog(LOGE,
594 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
595 }
596
597 complete(&pAdapter->ibss_peer_info_comp);
598}
599
600v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
601{
602 v_U8_t idx;
603 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
604
605 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
606 {
607 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
608 staIdx == pHddStaCtx->conn_info.staId[ idx ])
609 {
610 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
611 }
612 }
613 return NULL;
614}
615
616eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
617{
618 eHalStatus status = eHAL_STATUS_FAILURE;
619 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
620 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
621 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
622
623 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
624 VOS_FALSE, staIdx);
625
626 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
627
628 if (eHAL_STATUS_SUCCESS == status)
629 {
630 long ret;
631 ret = wait_for_completion_interruptible_timeout
632 (&pAdapter->ibss_peer_info_comp,
633 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
634 if (ret <= 0)
635 {
636 hddLog(VOS_TRACE_LEVEL_ERROR,
637 FL("failed wait on ibss_peer_info_comp %ld"), ret);
638 return eHAL_STATUS_FAILURE;
639 }
640
641 /** Print the peer info */
642 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
643 pr_info("============================================================");
644 {
645 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
646 staIdx);
647 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
648
649 if (NULL != macAddr)
650 {
651 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
652 MAC_ADDR_ARRAY(macAddr->bytes),
653 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
654 }
655 else
656 {
657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
658 " ERROR: PEER MAC ADDRESS NOT FOUND ");
659 }
660 }
661 }
662 else
663 {
664 hddLog(VOS_TRACE_LEVEL_WARN,
665 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
666 }
667
668 return status;
669}
670
671eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
672{
673 eHalStatus status = eHAL_STATUS_FAILURE;
674 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
675 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
676 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
677 int i;
678
679 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
680 VOS_TRUE, 0xFF);
681 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
682
683 if (eHAL_STATUS_SUCCESS == status)
684 {
685 long ret;
686 ret = wait_for_completion_interruptible_timeout
687 (&pAdapter->ibss_peer_info_comp,
688 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
689 if (ret <= 0)
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("failed wait on ibss_peer_info_comp %ld"), ret);
693 return eHAL_STATUS_FAILURE;
694 }
695
696 /** Print the peer info */
697 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
698 pr_info("============================================================");
699 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
700 {
701 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
702 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
703 staIdx);
704 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
705
706 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
707 if (NULL != macAddr)
708 {
709 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
710 MAC_ADDR_ARRAY(macAddr->bytes),
711 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
712 }
713 else
714 {
715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
716 " ERROR: PEER MAC ADDRESS NOT FOUND ");
717 }
718 }
719 }
720 else
721 {
722 hddLog(VOS_TRACE_LEVEL_WARN,
723 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
724 }
725
726 return status;
727}
728#endif /* WLAN_FEATURE_RMC */
729
Jeff Johnson295189b2012-06-20 16:38:30 -0700730int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
731{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530732 tHalHandle hHal;
733 hdd_context_t *pHddCtx;
734 v_U32_t threshold = 0;
735 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700736
737 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530738 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530739 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 "%s: Adapter is NULL",__func__);
742 return -EINVAL;
743 }
744
745 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
746 ret = wlan_hdd_validate_context(pHddCtx);
747 if (0 != ret)
748 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530749 return ret;
750 }
751
752 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
753 if (NULL == hHal)
754 {
755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
756 "%s: Hal Context is NULL",__func__);
757 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 }
759
760 if ( eHAL_STATUS_SUCCESS !=
761 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
762 {
c_hpothub8245442013-11-20 23:41:09 +0530763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
764 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 return -EIO;
766 }
767 wrqu->rts.value = threshold;
768
769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800770 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
772 EXIT();
773
774 return 0;
775}
776
777int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
778{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530779 tHalHandle hHal;
780 hdd_context_t *pHddCtx;
781 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700782
783 ENTER();
784
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530785 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530786 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
788 "%s: Adapter is NULL",__func__);
789 return -EINVAL;
790 }
791
792 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
793 status = wlan_hdd_validate_context(pHddCtx);
794 if (0 != status)
795 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530796 return status;
797 }
798
799 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
800 if (NULL == hHal)
801 {
802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
803 "%s: Hal Context is NULL",__func__);
804 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
806
807 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
808 != eHAL_STATUS_SUCCESS )
809 {
c_hpothub8245442013-11-20 23:41:09 +0530810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
811 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 return -EIO;
813 }
814 wrqu->frag.value = threshold;
815
816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800817 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700818
819 EXIT();
820
821 return 0;
822}
823
824int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
825{
Jeff Johnsone7245742012-09-05 17:12:55 -0700826 int i;
827 if (channel > 0)
828 {
829 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
830 {
831 if (channel == freq_chan_map[i].chan)
832 {
833 *pfreq = freq_chan_map[i].freq;
834 return 1;
835 }
836 }
837 }
838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800839 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700840 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700841}
842
843static v_BOOL_t
844hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
845{
846 v_BOOL_t rsnType = VOS_FALSE;
847 // is the authType supported?
848 switch (authType)
849 {
850 case eCSR_AUTH_TYPE_NONE: //never used
851 rsnType = eANI_BOOLEAN_FALSE;
852 break;
853 // MAC layer authentication types
854 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
855 rsnType = eANI_BOOLEAN_FALSE;
856 break;
857 case eCSR_AUTH_TYPE_SHARED_KEY:
858 rsnType = eANI_BOOLEAN_FALSE;
859 break;
860 case eCSR_AUTH_TYPE_AUTOSWITCH:
861 rsnType = eANI_BOOLEAN_FALSE;
862 break;
863
864 // Upper layer authentication types
865 case eCSR_AUTH_TYPE_WPA:
866 rsnType = eANI_BOOLEAN_TRUE;
867 break;
868 case eCSR_AUTH_TYPE_WPA_PSK:
869 rsnType = eANI_BOOLEAN_TRUE;
870 break;
871 case eCSR_AUTH_TYPE_WPA_NONE:
872 rsnType = eANI_BOOLEAN_TRUE;
873 break;
874#ifdef WLAN_FEATURE_VOWIFI_11R
875 case eCSR_AUTH_TYPE_FT_RSN:
876#endif
877 case eCSR_AUTH_TYPE_RSN:
878 rsnType = eANI_BOOLEAN_TRUE;
879 break;
880#ifdef WLAN_FEATURE_VOWIFI_11R
881 case eCSR_AUTH_TYPE_FT_RSN_PSK:
882#endif
883 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700884#ifdef WLAN_FEATURE_11W
885 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530886 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700887#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 rsnType = eANI_BOOLEAN_TRUE;
889 break;
890 //case eCSR_AUTH_TYPE_FAILED:
891 case eCSR_AUTH_TYPE_UNKNOWN:
892 rsnType = eANI_BOOLEAN_FALSE;
893 break;
894 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800895 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
896 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 rsnType = eANI_BOOLEAN_FALSE;
898 break;
899 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800900 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700901 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 return rsnType;
903}
904
905static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
906{
907 struct statsContext *pStatsContext;
908 hdd_adapter_t *pAdapter;
909
910 if (ioctl_debug)
911 {
912 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700913 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 }
915
916 if (NULL == pContext)
917 {
918 hddLog(VOS_TRACE_LEVEL_ERROR,
919 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700920 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 return;
922 }
923
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 pStatsContext = pContext;
925 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800926
927 /* there is a race condition that exists between this callback
928 function and the caller since the caller could time out either
929 before or while this code is executing. we use a spinlock to
930 serialize these actions */
931 spin_lock(&hdd_context_lock);
932
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
934 {
935 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800936 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 hddLog(VOS_TRACE_LEVEL_WARN,
938 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700939 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if (ioctl_debug)
941 {
942 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700943 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 }
945 return;
946 }
947
Jeff Johnson72a40512013-12-19 10:14:15 -0800948 /* context is valid so caller is still waiting */
949
950 /* paranoia: invalidate the magic */
951 pStatsContext->magic = 0;
952
Sachin Ahujaa082b672015-10-05 19:51:31 +0530953 /* copy over the rssi.FW will return RSSI as -100
954 * if there are no samples to calculate the average
955 * RSSI
956 */
957 if (rssi != -100)
958 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530959 if (pAdapter->rssi > 0)
960 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800961 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800963
964 /* serialization is complete */
965 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700966}
967
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530968static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
969{
970 struct statsContext *pStatsContext;
971 hdd_adapter_t *pAdapter;
972
973 if (ioctl_debug)
974 {
975 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
976 __func__, (int)snr, (int)staId, pContext);
977 }
978
979 if (NULL == pContext)
980 {
981 hddLog(VOS_TRACE_LEVEL_ERROR,
982 "%s: Bad param, pContext [%p]",
983 __func__, pContext);
984 return;
985 }
986
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530987 pStatsContext = pContext;
988 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800989
990 /* there is a race condition that exists between this callback
991 function and the caller since the caller could time out either
992 before or while this code is executing. we use a spinlock to
993 serialize these actions */
994 spin_lock(&hdd_context_lock);
995
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530996 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
997 {
998 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800999 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301000 hddLog(VOS_TRACE_LEVEL_WARN,
1001 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1002 __func__, pAdapter, pStatsContext->magic);
1003 if (ioctl_debug)
1004 {
1005 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1006 __func__, pAdapter, pStatsContext->magic);
1007 }
1008 return;
1009 }
1010
Jeff Johnson72a40512013-12-19 10:14:15 -08001011 /* context is valid so caller is still waiting */
1012
1013 /* paranoia: invalidate the magic */
1014 pStatsContext->magic = 0;
1015
1016 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301017 pAdapter->snr = snr;
1018
Jeff Johnson72a40512013-12-19 10:14:15 -08001019 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301020 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001021
1022 /* serialization is complete */
1023 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301024}
1025
Jeff Johnson295189b2012-06-20 16:38:30 -07001026VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1027{
1028 struct statsContext context;
1029 hdd_context_t *pHddCtx;
1030 hdd_station_ctx_t *pHddStaCtx;
1031 eHalStatus hstatus;
1032 long lrc;
1033
1034 if (NULL == pAdapter)
1035 {
1036 hddLog(VOS_TRACE_LEVEL_WARN,
1037 "%s: Invalid context, pAdapter", __func__);
1038 return VOS_STATUS_E_FAULT;
1039 }
1040 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1041 {
1042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1043 /* return a cached value */
1044 *rssi_value = pAdapter->rssi;
1045 return VOS_STATUS_SUCCESS;
1046 }
1047
1048 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1049 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1050
mukul sharma8aec69b2015-06-10 22:28:43 +05301051 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1052 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1054 __func__, pAdapter->rssi_on_disconnect);
1055 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301056 return VOS_STATUS_SUCCESS;
1057 }
1058
1059 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1060 {
1061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1062 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1063 *rssi_value = pAdapter->rssi;
1064 return VOS_STATUS_SUCCESS;
1065 }
1066
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 init_completion(&context.completion);
1068 context.pAdapter = pAdapter;
1069 context.magic = RSSI_CONTEXT_MAGIC;
1070
1071 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
1072 pHddStaCtx->conn_info.staId[ 0 ],
1073 pHddStaCtx->conn_info.bssId,
1074 &context, pHddCtx->pvosContext);
1075 if (eHAL_STATUS_SUCCESS != hstatus)
1076 {
1077 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001078 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 /* we'll returned a cached value below */
1080 }
1081 else
1082 {
1083 /* request was sent -- wait for the response */
1084 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1085 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 if (lrc <= 0)
1087 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001088 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001089 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 /* we'll now returned a cached value below */
1091 }
1092 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001093
1094 /* either we never sent a request, we sent a request and received a
1095 response or we sent a request and timed out. if we never sent a
1096 request or if we sent a request and got a response, we want to
1097 clear the magic out of paranoia. if we timed out there is a
1098 race condition such that the callback function could be
1099 executing at the same time we are. of primary concern is if the
1100 callback function had already verified the "magic" but had not
1101 yet set the completion variable when a timeout occurred. we
1102 serialize these activities by invalidating the magic while
1103 holding a shared spinlock which will cause us to block if the
1104 callback is currently executing */
1105 spin_lock(&hdd_context_lock);
1106 context.magic = 0;
1107 spin_unlock(&hdd_context_lock);
1108
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 *rssi_value = pAdapter->rssi;
1110
1111 return VOS_STATUS_SUCCESS;
1112}
Siddharth Bhal64246172015-02-27 01:04:37 +05301113/**---------------------------------------------------------------------------
1114
1115 \brief wlan_hdd_get_frame_logs() -
1116
1117 This function use to get Frames log.
1118
1119 \param - pAdapter Pointer to the adapter.
1120 flag - Specify type of request. Clear and Send request are
1121 supported.
1122
1123 \return - none
1124
1125 --------------------------------------------------------------------------*/
1126VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1127{
Siddharth Bhal64246172015-02-27 01:04:37 +05301128 hdd_context_t *pHddCtx;
1129 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301130
1131 if (NULL == pAdapter)
1132 {
1133 hddLog(VOS_TRACE_LEVEL_WARN,
1134 "%s: Invalid context, pAdapter", __func__);
1135 return VOS_STATUS_E_FAULT;
1136 }
1137
1138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1139 if (!pHddCtx->mgmt_frame_logging)
1140 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301141 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301142 return VOS_STATUS_E_AGAIN;
1143 }
1144
Siddharth Bhal4507c262015-04-29 20:20:42 +05301145 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1146 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1147 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301148 {
1149 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1150 return VOS_STATUS_E_INVAL;
1151 }
1152
Siddharth Bhal4507c262015-04-29 20:20:42 +05301153 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1154 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1155 {
1156 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1157 return VOS_STATUS_E_INVAL;
1158 }
1159
Abhishek Singh611295e2015-07-09 11:11:54 +05301160 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301161 if (eHAL_STATUS_SUCCESS != hstatus)
1162 {
1163 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301164 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301165 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301166
1167 return VOS_STATUS_SUCCESS;
1168}
1169
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301170
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301171VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1172{
1173 struct statsContext context;
1174 hdd_context_t *pHddCtx;
1175 hdd_station_ctx_t *pHddStaCtx;
1176 eHalStatus hstatus;
1177 long lrc;
1178 int valid;
1179
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301180 ENTER();
1181
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301182 if (NULL == pAdapter)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Invalid context, pAdapter", __func__);
1186 return VOS_STATUS_E_FAULT;
1187 }
1188
1189 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1190
1191 valid = wlan_hdd_validate_context(pHddCtx);
1192 if (0 != valid)
1193 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301194 return VOS_STATUS_E_FAULT;
1195 }
1196
1197 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1198 if (NULL == pHddStaCtx)
1199 {
1200 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1201 return VOS_STATUS_E_FAULT;
1202 }
1203
1204 init_completion(&context.completion);
1205 context.pAdapter = pAdapter;
1206 context.magic = SNR_CONTEXT_MAGIC;
1207
1208 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1209 pHddStaCtx->conn_info.staId[ 0 ],
1210 pHddStaCtx->conn_info.bssId,
1211 &context);
1212 if (eHAL_STATUS_SUCCESS != hstatus)
1213 {
1214 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1215 __func__);
1216 /* we'll returned a cached value below */
1217 }
1218 else
1219 {
1220 /* request was sent -- wait for the response */
1221 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1222 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301223 if (lrc <= 0)
1224 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301226 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301227 /* we'll now returned a cached value below */
1228 }
1229 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001230
1231 /* either we never sent a request, we sent a request and received a
1232 response or we sent a request and timed out. if we never sent a
1233 request or if we sent a request and got a response, we want to
1234 clear the magic out of paranoia. if we timed out there is a
1235 race condition such that the callback function could be
1236 executing at the same time we are. of primary concern is if the
1237 callback function had already verified the "magic" but had not
1238 yet set the completion variable when a timeout occurred. we
1239 serialize these activities by invalidating the magic while
1240 holding a shared spinlock which will cause us to block if the
1241 callback is currently executing */
1242 spin_lock(&hdd_context_lock);
1243 context.magic = 0;
1244 spin_unlock(&hdd_context_lock);
1245
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301246 *snr = pAdapter->snr;
1247
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301248 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301249 return VOS_STATUS_SUCCESS;
1250}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301251
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001252#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001253
1254static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1255{
1256 struct statsContext *pStatsContext;
1257 hdd_adapter_t *pAdapter;
1258 if (ioctl_debug)
1259 {
1260 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1261 __func__, (int)rssi, (int)staId, pContext);
1262 }
1263
1264 if (NULL == pContext)
1265 {
1266 hddLog(VOS_TRACE_LEVEL_ERROR,
1267 "%s: Bad param, pContext [%p]",
1268 __func__, pContext);
1269 return;
1270 }
1271
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001272 pStatsContext = pContext;
1273 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001274
1275 /* there is a race condition that exists between this callback
1276 function and the caller since the caller could time out either
1277 before or while this code is executing. we use a spinlock to
1278 serialize these actions */
1279 spin_lock(&hdd_context_lock);
1280
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001281 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1282 {
1283 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001284 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001285 hddLog(VOS_TRACE_LEVEL_WARN,
1286 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1287 __func__, pAdapter, pStatsContext->magic);
1288 if (ioctl_debug)
1289 {
1290 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1291 __func__, pAdapter, pStatsContext->magic);
1292 }
1293 return;
1294 }
1295
Jeff Johnson72a40512013-12-19 10:14:15 -08001296 /* context is valid so caller is still waiting */
1297
1298 /* paranoia: invalidate the magic */
1299 pStatsContext->magic = 0;
1300
Sachin Ahujaa082b672015-10-05 19:51:31 +05301301 /* copy over the rssi.FW will return RSSI as -100
1302 * if there are no samples to calculate the average
1303 * RSSI
1304 */
1305 if (rssi != -100)
1306 pAdapter->rssi = rssi;
1307
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301308 if (pAdapter->rssi > 0)
1309 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001310 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001311 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001312
1313 /* serialization is complete */
1314 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001315}
1316
1317
1318
1319VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1320{
1321 struct statsContext context;
1322 hdd_context_t *pHddCtx = NULL;
1323 hdd_station_ctx_t *pHddStaCtx = NULL;
1324 eHalStatus hstatus;
1325 long lrc;
1326
1327 if (NULL == pAdapter)
1328 {
1329 hddLog(VOS_TRACE_LEVEL_WARN,
1330 "%s: Invalid context, pAdapter", __func__);
1331 return VOS_STATUS_E_FAULT;
1332 }
1333 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1334 {
1335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1336 /* return a cached value */
1337 *rssi_value = pAdapter->rssi;
1338 return VOS_STATUS_SUCCESS;
1339 }
1340
1341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1342 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1343
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301344 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001345 {
1346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1347 /* return a cached value */
1348 *rssi_value = 0;
1349 return VOS_STATUS_SUCCESS;
1350 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301351
1352 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1353 {
1354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1355 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1356 *rssi_value = pAdapter->rssi;
1357 return VOS_STATUS_SUCCESS;
1358 }
1359
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001360 init_completion(&context.completion);
1361 context.pAdapter = pAdapter;
1362 context.magic = RSSI_CONTEXT_MAGIC;
1363
1364 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1365 pHddStaCtx->conn_info.staId[ 0 ],
1366 pHddStaCtx->conn_info.bssId,
1367 &context, pHddCtx->pvosContext);
1368 if (eHAL_STATUS_SUCCESS != hstatus)
1369 {
1370 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1371 __func__);
1372 /* we'll returned a cached value below */
1373 }
1374 else
1375 {
1376 /* request was sent -- wait for the response */
1377 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1378 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001379 if (lrc <= 0)
1380 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001381 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001382 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001383 /* we'll now returned a cached value below */
1384 }
1385 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001386
1387 /* either we never sent a request, we sent a request and received a
1388 response or we sent a request and timed out. if we never sent a
1389 request or if we sent a request and got a response, we want to
1390 clear the magic out of paranoia. if we timed out there is a
1391 race condition such that the callback function could be
1392 executing at the same time we are. of primary concern is if the
1393 callback function had already verified the "magic" but had not
1394 yet set the completion variable when a timeout occurred. we
1395 serialize these activities by invalidating the magic while
1396 holding a shared spinlock which will cause us to block if the
1397 callback is currently executing */
1398 spin_lock(&hdd_context_lock);
1399 context.magic = 0;
1400 spin_unlock(&hdd_context_lock);
1401
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001402 *rssi_value = pAdapter->rssi;
1403
1404 return VOS_STATUS_SUCCESS;
1405}
1406#endif
1407
1408
Jeff Johnson295189b2012-06-20 16:38:30 -07001409void hdd_StatisticsCB( void *pStats, void *pContext )
1410{
1411 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1412 hdd_stats_t *pStatsCache = NULL;
1413 hdd_wext_state_t *pWextState;
1414 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1415
1416 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1417 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1418 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1419 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1420 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1421 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1422
1423 if (pAdapter!= NULL)
1424 pStatsCache = &pAdapter->hdd_stats;
1425
1426
1427 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1428 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1429 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1430 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1431 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1432 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1433
1434 if (pStatsCache!=NULL)
1435 {
1436 // and copy the stats into the cache we keep in the adapter instance structure
1437 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1438 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1439 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1440 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1441 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1442 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1443 }
1444
1445 if(pAdapter)
1446 {
1447 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1448 if(pWextState)
1449 {
1450 vos_status = vos_event_set(&pWextState->vosevent);
1451 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1452 {
1453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001454 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 return;
1456 }
1457 }
1458 }
1459}
1460
1461void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1462{
1463 v_CONTEXT_t pVosContext;
1464 hdd_context_t *pHddCtx;
1465 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1466#if 0
1467 hdd_wext_state_t *pWextState;
1468 v_U32_t roamId;
1469#endif
1470
1471 ENTER();
1472
1473 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1474
1475 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1476 if (NULL == pHddCtx)
1477 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 return;
1480 }
1481#if 0
1482 pWextState = pAdapter->pWextState;
1483#endif
1484
1485 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1486 {
1487 //TODO Verify is this is really used. If yes need to fix it.
1488 hdd_reconnect_all_adapters( pHddCtx );
1489#if 0
1490 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1491 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1492 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1493
1494 if(VOS_STATUS_SUCCESS == vosStatus)
1495 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1496 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1497
1498 sme_RoamConnect(halHandle,
1499 pAdapter->sessionId, &(pWextState->roamProfile),
1500 &roamId);
1501#endif
1502 }
1503
1504 EXIT();
1505
1506}
1507
1508void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1509{
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1511
1512 /* clear WPA/RSN/WSC IE information in the profile */
1513 pWextState->roamProfile.nWPAReqIELength = 0;
1514 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1515 pWextState->roamProfile.nRSNReqIELength = 0;
1516 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1517
Chet Lanctot186b5732013-03-18 10:26:30 -07001518#ifdef FEATURE_WLAN_WAPI
1519 pWextState->roamProfile.nWAPIReqIELength = 0;
1520 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1521#endif
1522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001524 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301526 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1528 pWextState->roamProfile.nAddIEAssocLength = 0;
1529
1530 pWextState->roamProfile.EncryptionType.numEntries = 1;
1531 pWextState->roamProfile.EncryptionType.encryptionType[0]
1532 = eCSR_ENCRYPT_TYPE_NONE;
1533
1534 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1535 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1536 = eCSR_ENCRYPT_TYPE_NONE;
1537
1538 pWextState->roamProfile.AuthType.numEntries = 1;
1539 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1540
Chet Lanctot186b5732013-03-18 10:26:30 -07001541#ifdef WLAN_FEATURE_11W
1542 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1543 pWextState->roamProfile.MFPRequired = 0;
1544 pWextState->roamProfile.MFPCapable = 0;
1545#endif
1546
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 pWextState->authKeyMgmt = 0;
1548
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301549 vos_mem_zero(&pWextState->roamProfile.Keys,
1550 sizeof(pWextState->roamProfile.Keys));
1551
Jeff Johnson295189b2012-06-20 16:38:30 -07001552#ifdef FEATURE_WLAN_WAPI
1553 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1554 pAdapter->wapi_info.nWapiMode = 0;
1555#endif
1556
1557 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1558
1559}
1560
1561void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1562{
1563 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001564
Nirav Shahf6bd2672015-03-11 12:53:15 +05301565 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001566 {
1567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301568 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001569 }
1570 else
1571 {
1572 complete(&pAdapter->ula_complete);
1573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001574}
1575
1576VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1577{
1578 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001580 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581
1582 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1583 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001584 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
1586 /*To avoid race condition between the set key and the last EAPOL
1587 packet, notify TL to finish upper layer authentication incase if the
1588 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001589 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001590
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001591 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 {
1593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1594 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1595 __LINE__, vos_status );
1596 return vos_status;
1597
1598 }
1599
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001600 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301602 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001603 {
1604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301605 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001606 /* we'll still fall through and return success since the
1607 * connection may still get established but is just taking
1608 * too long for us to wait */
1609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 }
1611 return VOS_STATUS_SUCCESS;
1612}
1613
1614v_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)
1615{
1616
1617 int left = ie_len;
1618 v_U8_t *ptr = ie;
1619 v_U8_t elem_id,elem_len;
1620 v_U8_t eid = 0xDD;
1621
1622 if ( NULL == ie || 0 == ie_len )
1623 return NULL;
1624
1625 while(left >= 2)
1626 {
1627 elem_id = ptr[0];
1628 elem_len = ptr[1];
1629 left -= 2;
1630 if(elem_len > left)
1631 {
1632 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001633 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 eid,elem_len,left);
1635 return NULL;
1636 }
1637 if (elem_id == eid)
1638 {
1639 if(memcmp( &ptr[2], oui, oui_size)==0)
1640 return ptr;
1641 }
1642
1643 left -= elem_len;
1644 ptr += (elem_len + 2);
1645 }
1646 return NULL;
1647}
1648
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301649static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 union iwreq_data *wrqu, char *extra)
1651{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301652 hdd_adapter_t *pAdapter;
1653 hdd_context_t *pHddCtx;
1654 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301655
1656 ENTER();
1657
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301658 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1659 if (NULL == pAdapter)
1660 {
1661 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1662 "%s: pAdapter is NULL\n", __func__);
1663 return -EINVAL;
1664 }
1665 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1666 ret = wlan_hdd_validate_context(pHddCtx);
1667 if (0 != ret)
1668 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301669 return ret;
1670 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301671
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301673
1674 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301675 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676}
1677
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301678static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1679 union iwreq_data *wrqu, char *extra)
1680{
1681 int ret;
1682
1683 vos_ssr_protect(__func__);
1684 ret = __iw_set_commit(dev, info, wrqu, extra);
1685 vos_ssr_unprotect(__func__);
1686
1687 return ret;
1688}
1689
1690static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 struct iw_request_info *info,
1692 char *wrqu, char *extra)
1693{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301694 hdd_adapter_t *pAdapter;
1695 hdd_context_t *pHddCtx;
1696 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301697
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301699 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1700 if (NULL == pAdapter)
1701 {
1702 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1703 "%s: pAdapter is NULL\n", __func__);
1704 return -EINVAL;
1705 }
1706 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1707 ret = wlan_hdd_validate_context(pHddCtx);
1708 if (0 != ret)
1709 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301710 return ret;
1711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1713 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301714 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001715}
1716
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301717static int iw_get_name(struct net_device *dev,
1718 struct iw_request_info *info,
1719 char *wrqu, char *extra)
1720{
1721 int ret;
1722
1723 vos_ssr_protect(__func__);
1724 ret = __iw_get_name(dev, info, wrqu, extra);
1725 vos_ssr_unprotect(__func__);
1726
1727 return ret;
1728}
1729
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301730static int __iw_set_mode(struct net_device *dev,
1731 struct iw_request_info *info,
1732 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001733{
1734 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301735 hdd_adapter_t *pAdapter;
1736 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 tCsrRoamProfile *pRoamProfile;
1738 eCsrRoamBssType LastBSSType;
1739 eMib_dot11DesiredBssType connectedBssType;
1740 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301742 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001743
1744 ENTER();
1745
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301746 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 if (NULL == pAdapter)
1748 {
1749 hddLog(VOS_TRACE_LEVEL_WARN,
1750 "%s: Invalid context, pAdapter", __func__);
1751 return 0;
1752 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301753 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1754 status = wlan_hdd_validate_context(pHddCtx);
1755 if (0 != status)
1756 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301757 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 }
1759
1760 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1761 if (pWextState == NULL)
1762 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301763 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 return -EINVAL;
1765 }
1766
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 pRoamProfile = &pWextState->roamProfile;
1769 LastBSSType = pRoamProfile->BSSType;
1770
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301771 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001772
1773 switch (wrqu->mode)
1774 {
1775 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301776 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1778 // Set the phymode correctly for IBSS.
1779 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1780 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001781 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 break;
1784 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301785 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 break;
1789 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301790 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1792 break;
1793 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301794 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 return -EOPNOTSUPP;
1796 }
1797
1798 if ( LastBSSType != pRoamProfile->BSSType )
1799 {
1800 //the BSS mode changed
1801 // We need to issue disconnect if connected or in IBSS disconnect state
1802 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1803 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1804 {
1805 VOS_STATUS vosStatus;
1806 // need to issue a disconnect to CSR.
1807 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1808 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1809 pAdapter->sessionId,
1810 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1811 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301812 {
1813 long ret;
1814 ret = wait_for_completion_interruptible_timeout(
1815 &pAdapter->disconnect_comp_var,
1816 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1817 if (ret <= 0)
1818 hddLog(VOS_TRACE_LEVEL_ERROR,
1819 FL("failed wait on disconnect_comp_var %ld"), ret);
1820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 }
1822 }
1823
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 EXIT();
1825 return 0;
1826}
1827
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301828static int iw_set_mode(struct net_device *dev,
1829 struct iw_request_info *info,
1830 union iwreq_data *wrqu, char *extra)
1831{
1832 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301834 vos_ssr_protect(__func__);
1835 ret = __iw_set_mode(dev, info, wrqu, extra);
1836 vos_ssr_unprotect(__func__);
1837
1838 return ret;
1839}
1840
1841static int __iw_get_mode(struct net_device *dev,
1842 struct iw_request_info *info,
1843 union iwreq_data *wrqu,
1844 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001845{
1846
1847 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301848 hdd_adapter_t *pAdapter;
1849 hdd_context_t *pHddCtx;
1850 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301852 ENTER();
1853
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301854 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 if (NULL == pAdapter)
1856 {
1857 hddLog(VOS_TRACE_LEVEL_WARN,
1858 "%s: Invalid context, pAdapter", __func__);
1859 return 0;
1860 }
1861
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301862 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1863 ret = wlan_hdd_validate_context(pHddCtx);
1864 if (0 != ret)
1865 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301866 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1869 if (pWextState == NULL)
1870 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301871 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 return -EINVAL;
1873 }
1874
1875 switch (pWextState->roamProfile.BSSType)
1876 {
1877 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001878 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301879 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 break;
1881 case eCSR_BSS_TYPE_IBSS:
1882 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001883 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301884 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 break;
1886 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001887 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301888 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 break;
1890 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001891 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 break;
1893 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301894
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301895 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 return 0;
1897}
1898
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301899static int iw_get_mode(struct net_device *dev,
1900 struct iw_request_info *info,
1901 union iwreq_data *wrqu,
1902 char *extra)
1903{
1904 int ret;
1905
1906 vos_ssr_protect(__func__);
1907 ret = __iw_get_mode(dev, info, wrqu, extra);
1908 vos_ssr_unprotect(__func__);
1909
1910 return ret;
1911}
1912
1913static int __iw_set_freq(struct net_device *dev,
1914 struct iw_request_info *info,
1915 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001916{
1917 v_U32_t numChans = 0;
1918 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1919 v_U32_t indx = 0;
1920 v_U32_t status = 0;
1921
1922 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301923 hdd_adapter_t *pAdapter;
1924 hdd_context_t *pHddCtx;
1925 tHalHandle hHal;
1926 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301928
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 ENTER();
1930
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301931 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1932 if (NULL == pAdapter)
1933 {
1934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1935 "%s:Invalid Adapter",__func__);
1936 return -EINVAL;
1937 }
1938
1939 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1940 status = wlan_hdd_validate_context(pHddCtx);
1941 if (0 != status)
1942 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 return status;
1944 }
1945
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301946 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1947 if (NULL == hHal)
1948 {
1949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1950 "%s: Hal Context is NULL",__func__);
1951 return -EINVAL;
1952 }
1953
1954 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1955 if (NULL == pHddStaCtx)
1956 {
1957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1958 "%s:STA context is NULL",__func__);
1959 return -EINVAL;
1960 }
1961
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301963 if (NULL == pWextState)
1964 {
1965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1966 "%s: pWextState is NULL",__func__);
1967 return -EINVAL;
1968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001969
1970 pRoamProfile = &pWextState->roamProfile;
1971
Arif Hussain6d2a3322013-11-17 19:50:10 -08001972 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001973
1974 /* Link is up then return cant set channel*/
1975 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1976 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1977 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001978 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 return -EOPNOTSUPP;
1980 }
1981
1982 /* Settings by Frequency as input */
1983 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1984 (wrqu->freq.m <= (tANI_U32)5.825e8))
1985 {
1986 tANI_U32 freq = wrqu->freq.m / 100000;
1987
1988 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1989 indx++;
1990 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1991 {
1992 return -EINVAL;
1993 }
1994 wrqu->freq.e = 0;
1995 wrqu->freq.m = freq_chan_map[indx].chan;
1996
1997 }
1998
1999 if (wrqu->freq.e == 0)
2000 {
2001 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2002 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
2003 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002004 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002005 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 WNI_CFG_CURRENT_CHANNEL_STAMAX);
2007 return -EINVAL;
2008 }
2009
2010 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2011
2012 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2013 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05302014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2015 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 return -EIO;
2017 }
2018
2019 for (indx = 0; indx < numChans; indx++) {
2020 if (wrqu->freq.m == validChan[indx]){
2021 break;
2022 }
2023 }
2024 }
2025 else{
2026
2027 return -EINVAL;
2028 }
2029
2030 if(indx >= numChans)
2031 {
2032 return -EINVAL;
2033 }
2034
2035 /* Set the Operational Channel */
2036 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2037 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2038 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
2039
Arif Hussain6d2a3322013-11-17 19:50:10 -08002040 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07002041
2042 EXIT();
2043
2044 return status;
2045}
2046
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302047static int iw_set_freq(struct net_device *dev,
2048 struct iw_request_info *info,
2049 union iwreq_data *wrqu, char *extra)
2050{
2051 int ret;
2052
2053 vos_ssr_protect(__func__);
2054 ret = __iw_set_freq(dev, info, wrqu, extra);
2055 vos_ssr_unprotect(__func__);
2056
2057 return ret;
2058}
2059
2060static int __iw_get_freq(struct net_device *dev,
2061 struct iw_request_info *info,
2062 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002063{
Jeff Johnsone7245742012-09-05 17:12:55 -07002064 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302065 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 tHalHandle hHal;
2067 hdd_wext_state_t *pWextState;
2068 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302069 hdd_station_ctx_t *pHddStaCtx;
2070 hdd_context_t *pHddCtx;
2071 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
2073 ENTER();
2074
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302075 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2076 if (NULL == pAdapter)
2077 {
2078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2079 "%s: Adapter is NULL", __func__);
2080 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2083 ret = wlan_hdd_validate_context(pHddCtx);
2084 if (0 != ret)
2085 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302086 return ret;
2087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302089 if (NULL == hHal)
2090 {
2091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2092 "%s: Hal Context is NULL",__func__);
2093 return -EINVAL;
2094 }
2095 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2096 if (NULL == pHddStaCtx)
2097 {
2098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2099 "%s: HddStaCtx is NULL", __func__);
2100 return -EINVAL;
2101 }
2102 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2103 if (NULL == pWextState)
2104 {
2105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2106 "%s: pWextState is NULL",__func__);
2107 return -EINVAL;
2108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 pRoamProfile = &pWextState->roamProfile;
2110
2111 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2112 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002113 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 {
c_hpothub8245442013-11-20 23:41:09 +05302115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2116 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 return -EIO;
2118 }
2119 else
2120 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002121 status = hdd_wlan_get_freq(channel, &freq);
2122 if( TRUE == status )
2123 {
2124 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2125 * iwlist & iwconfig command shows frequency into proper
2126 * format (2.412 GHz instead of 246.2 MHz)*/
2127 fwrq->m = freq;
2128 fwrq->e = MHZ;
2129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 }
2131 }
2132 else
2133 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002134 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2135 * iwlist & iwconfig command shows frequency into proper
2136 * format (2.412 GHz instead of 246.2 MHz)*/
2137 fwrq->m = 0;
2138 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302140
2141 EXIT();
2142 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002143}
2144
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302145static int iw_get_freq(struct net_device *dev,
2146 struct iw_request_info *info,
2147 struct iw_freq *fwrq, char *extra)
2148{
2149 int ret;
2150
2151 vos_ssr_protect(__func__);
2152 ret = __iw_get_freq(dev, info, fwrq, extra);
2153 vos_ssr_unprotect(__func__);
2154
2155 return ret;
2156}
2157
2158static int __iw_get_tx_power(struct net_device *dev,
2159 struct iw_request_info *info,
2160 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002161{
2162
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302163 hdd_adapter_t *pAdapter;
2164 hdd_context_t *pHddCtx;
2165 hdd_station_ctx_t *pHddStaCtx;
2166 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302168 ENTER();
2169
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302170 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2171 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2174 "%s: Adapter is NULL",__func__);
2175 return -EINVAL;
2176 }
2177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2178 ret = wlan_hdd_validate_context(pHddCtx);
2179 if (0 != ret)
2180 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302181 return ret;
2182 }
2183
2184 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2185 if (NULL == pHddStaCtx)
2186 {
2187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2188 "%s: STA Context is NULL",__func__);
2189 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 }
2191
2192 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2193 {
2194 wrqu->txpower.value = 0;
2195 return 0;
2196 }
2197 wlan_hdd_get_classAstats(pAdapter);
2198 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2199
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302200 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 return 0;
2202}
2203
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302204static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 struct iw_request_info *info,
2206 union iwreq_data *wrqu, char *extra)
2207{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302208 int ret;
2209
2210 vos_ssr_protect(__func__);
2211 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2212 vos_ssr_unprotect(__func__);
2213
2214 return ret;
2215}
2216
2217static int __iw_set_tx_power(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu, char *extra)
2220{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302221 hdd_adapter_t *pAdapter;
2222 tHalHandle hHal;
2223 hdd_context_t *pHddCtx;
2224 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302227 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2228 if (NULL == pAdapter)
2229 {
2230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2231 "%s: Adapter is NULL",__func__);
2232 return -EINVAL;
2233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002234
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2236 ret = wlan_hdd_validate_context(pHddCtx);
2237 if (0 != ret)
2238 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302239 return ret;
2240 }
2241
2242 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2243 if (NULL == hHal)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2246 "%s: Hal Context is NULL",__func__);
2247 return -EINVAL;
2248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2250 {
c_hpothub8245442013-11-20 23:41:09 +05302251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2252 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 return -EIO;
2254 }
2255
2256 EXIT();
2257
2258 return 0;
2259}
2260
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302261static int iw_set_tx_power(struct net_device *dev,
2262 struct iw_request_info *info,
2263 union iwreq_data *wrqu, char *extra)
2264{
2265 int ret;
2266
2267 vos_ssr_protect(__func__);
2268 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2269 vos_ssr_unprotect(__func__);
2270
2271 return ret;
2272}
2273
2274static int __iw_get_bitrate(struct net_device *dev,
2275 struct iw_request_info *info,
2276 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002277{
2278 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2279 eHalStatus status = eHAL_STATUS_SUCCESS;
2280 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302281 hdd_adapter_t *pAdapter;
2282 hdd_context_t *pHddCtx;
2283 hdd_station_ctx_t *pHddStaCtx;
2284 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
2286 ENTER();
2287
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302288 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2289 if (NULL == pAdapter)
2290 {
2291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2292 "%s: Adapter is NULL",__func__);
2293 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 }
2295
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302296 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2297 ret = wlan_hdd_validate_context(pHddCtx);
2298 if (0 != ret)
2299 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302300 return ret;
2301 }
2302
2303 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2304 if (NULL == pHddStaCtx)
2305 {
2306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2307 "%s: STA Context is NULL",__func__);
2308 return -EINVAL;
2309 }
2310
2311 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 wrqu->bitrate.value = 0;
2313 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302314 else
2315 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2317 SME_SUMMARY_STATS |
2318 SME_GLOBAL_CLASSA_STATS |
2319 SME_GLOBAL_CLASSB_STATS |
2320 SME_GLOBAL_CLASSC_STATS |
2321 SME_GLOBAL_CLASSD_STATS |
2322 SME_PER_STA_STATS,
2323 hdd_StatisticsCB, 0, FALSE,
2324 pHddStaCtx->conn_info.staId[0], pAdapter );
2325
2326 if(eHAL_STATUS_SUCCESS != status)
2327 {
2328 hddLog(VOS_TRACE_LEVEL_ERROR,
2329 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002330 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 return status;
2332 }
2333
2334 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302335 if (NULL == pWextState)
2336 {
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2338 "%s: pWextState is NULL",__func__);
2339 return -EINVAL;
2340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002341
2342 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2343
2344 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2345 {
2346 hddLog(VOS_TRACE_LEVEL_ERROR,
2347 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002348 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 return VOS_STATUS_E_FAILURE;
2350 }
2351
2352 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2353 }
2354
2355 EXIT();
2356
2357 return vos_status;
2358}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302359
2360static int iw_get_bitrate(struct net_device *dev,
2361 struct iw_request_info *info,
2362 union iwreq_data *wrqu, char *extra)
2363{
2364 int ret;
2365
2366 vos_ssr_protect(__func__);
2367 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2368 vos_ssr_unprotect(__func__);
2369
2370 return ret;
2371}
2372
2373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374/* ccm call back function */
2375
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302376static int __iw_set_bitrate(struct net_device *dev,
2377 struct iw_request_info *info,
2378 union iwreq_data *wrqu,
2379 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002380{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302381 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302383 hdd_station_ctx_t *pHddStaCtx;
2384 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2386 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2387 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2388 v_U32_t i, rate;
2389 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302390 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002391
2392 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302393 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2394 if (NULL == pAdapter)
2395 {
2396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2397 "%s: Adapter is NULL",__func__);
2398 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
2400
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302401 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2402 ret = wlan_hdd_validate_context(pHddCtx);
2403 if (0 != ret)
2404 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302405 return ret;
2406 }
2407
2408 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2409 if (NULL == pHddStaCtx)
2410 {
2411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2412 "%s: STA Context is NULL",__func__);
2413 return -EINVAL;
2414 }
2415
2416
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302418 if (NULL == pWextState)
2419 {
2420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2421 "%s: pWextState is NULL",__func__);
2422 return -EINVAL;
2423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002424
2425 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2426 {
2427 return -ENXIO ;
2428 }
2429
2430 rate = wrqu->bitrate.value;
2431
2432 if (rate == -1)
2433 {
2434 rate = WNI_CFG_FIXED_RATE_AUTO;
2435 valid_rate = TRUE;
2436 }
2437 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2438 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2439 {
2440 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2441 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2442 {
2443 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2444 WNI_CFG_SUPPORTED_RATES_11A,
2445 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2446 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2447 WNI_CFG_SUPPORTED_RATES_11B,
2448 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2449 {
2450 for (i = 0; i < (b_len + a_len); ++i)
2451 {
2452 /* supported rates returned is double the actual rate so we divide it by 2 */
2453 if ((supp_rates[i]&0x7F)/2 == rate)
2454 {
2455 valid_rate = TRUE;
2456 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2457 break;
2458 }
2459 }
2460 }
2461 }
2462 }
2463 if (valid_rate != TRUE)
2464 {
2465 return -EINVAL;
2466 }
2467 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2468 WNI_CFG_FIXED_RATE, rate,
2469 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2470 {
c_hpothub8245442013-11-20 23:41:09 +05302471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2472 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 return -EIO;
2474 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302475
2476 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 return 0;
2478}
2479
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302480static int iw_set_bitrate(struct net_device *dev,
2481 struct iw_request_info *info,
2482 union iwreq_data *wrqu,
2483 char *extra)
2484{
2485 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002486
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302487 vos_ssr_protect(__func__);
2488 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2489 vos_ssr_unprotect(__func__);
2490
2491 return ret;
2492}
2493
2494static int __iw_set_genie(struct net_device *dev,
2495 struct iw_request_info *info,
2496 union iwreq_data *wrqu,
2497 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302499 hdd_adapter_t *pAdapter;
2500 hdd_context_t *pHddCtx;
2501 hdd_wext_state_t *pWextState;
2502 u_int8_t *genie = NULL;
2503 u_int8_t *base_genie = NULL;
2504 v_U16_t remLen;
2505 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002506
2507 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002508
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302509 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2510 if (NULL == pAdapter)
2511 {
2512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2513 "%s: Adapter is NULL",__func__);
2514 return -EINVAL;
2515 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002516
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302517 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2518 ret = wlan_hdd_validate_context(pHddCtx);
2519 if (0 != ret)
2520 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302521 return ret;
2522 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002523
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2525 if (NULL == pWextState)
2526 {
2527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2528 "%s: pWextState is NULL",__func__);
2529 return -EINVAL;
2530 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002531
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302532 if (!wrqu->data.length) {
2533 hdd_clearRoamProfileIe(pAdapter);
2534 EXIT();
2535 return 0;
2536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302538 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2539 wrqu->data.length);
2540 if (NULL == base_genie)
2541 {
2542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2543 "mem_alloc_copy_from_user_helper fail");
2544 return -ENOMEM;
2545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002546
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302547 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002548
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302549 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002550
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302551 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2552
2553 /* clear any previous genIE before this call */
2554 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2555
2556 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
2558 v_U16_t eLen = 0;
2559 v_U8_t elementId;
2560 elementId = *genie++;
2561 eLen = *genie++;
2562 remLen -= 2;
2563
Arif Hussain6d2a3322013-11-17 19:50:10 -08002564 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 __func__, elementId, eLen);
2566
2567 switch ( elementId )
2568 {
2569 case IE_EID_VENDOR:
2570 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002571 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302572 ret = -EINVAL;
2573 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002575
2576 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2577 {
2578 v_U16_t curGenIELen = pWextState->genIE.length;
2579 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2580 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2581
2582 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2583 {
2584 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002585 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302587 ret = -EINVAL;
2588 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 }
2590 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2591 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2592 pWextState->genIE.length += eLen + 2;
2593 }
2594 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2595 {
2596 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302597 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2598 {
2599 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2600 "Need bigger buffer space");
2601 ret = -EINVAL;
2602 VOS_ASSERT(0);
2603 goto exit;
2604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2606 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2607 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2608 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2609 }
2610 else /* any vendorId except WPA IE should be accumulated to genIE */
2611 {
2612 v_U16_t curGenIELen = pWextState->genIE.length;
2613 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2614 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2615
2616 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2617 {
2618 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002619 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302621 ret = -ENOMEM;
2622 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 }
2624 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2625 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2626 pWextState->genIE.length += eLen + 2;
2627 }
2628 break;
2629 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002630 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302631 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2632 {
2633 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2634 "Need bigger buffer space");
2635 ret = -EINVAL;
2636 VOS_ASSERT(0);
2637 goto exit;
2638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2640 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2641 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2642 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2643 break;
2644
2645 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002646 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302647 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 }
2649 genie += eLen;
2650 remLen -= eLen;
2651 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302652
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302653exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002655 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302656 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002657}
2658
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302659static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 struct iw_request_info *info,
2661 union iwreq_data *wrqu,
2662 char *extra)
2663{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302664 int ret;
2665
2666 vos_ssr_protect(__func__);
2667 ret = __iw_set_genie(dev, info, wrqu, extra);
2668 vos_ssr_unprotect(__func__);
2669
2670 return ret;
2671}
2672
2673static int __iw_get_genie(struct net_device *dev,
2674 struct iw_request_info *info,
2675 union iwreq_data *wrqu,
2676 char *extra)
2677{
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302679 hdd_context_t *pHddCtx;
2680 hdd_adapter_t *pAdapter;
2681 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 eHalStatus status;
2683 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2684 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2685
2686 ENTER();
2687
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302688 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2689 if (NULL == pAdapter)
2690 {
2691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2692 "%s: Adapter is NULL",__func__);
2693 return -EINVAL;
2694 }
2695 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2696 status = wlan_hdd_validate_context(pHddCtx);
2697 if (0 != status)
2698 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302699 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 }
2701
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302703 if (NULL == pWextState)
2704 {
2705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2706 "%s: pWextState is NULL",__func__);
2707 return -EINVAL;
2708 }
2709
2710 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2711 if (NULL == pHddStaCtx)
2712 {
2713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2714 "%s: STA Context is NULL",__func__);
2715 return -EINVAL;
2716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
2718 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2719 {
2720 return -ENXIO;
2721 }
2722
2723 // Return something ONLY if we are associated with an RSN or WPA network
2724 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2725 pWextState->roamProfile.negotiatedAuthType))
2726 {
2727 return -ENXIO;
2728 }
2729
2730 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2731 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2732 pAdapter->sessionId,
2733 &length,
2734 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302735 if (eHAL_STATUS_SUCCESS != status) {
2736 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002737 return -EFAULT;
2738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002739
Manjeet Singh715d47e2016-08-02 19:08:02 +05302740 wrqu->data.length = length;
2741 if (length > DOT11F_IE_RSN_MAX_LEN) {
2742 hddLog(LOGE,
2743 FL("invalid buffer length length:%d"), length);
2744 return -E2BIG;
2745 }
2746
2747 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2748
2749 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002750
2751 EXIT();
2752
2753 return 0;
2754}
2755
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302756static int iw_get_genie(struct net_device *dev,
2757 struct iw_request_info *info,
2758 union iwreq_data *wrqu,
2759 char *extra)
2760{
2761 int ret;
2762
2763 vos_ssr_protect(__func__);
2764 ret = __iw_get_genie(dev, info, wrqu, extra);
2765 vos_ssr_unprotect(__func__);
2766
2767 return ret;
2768}
2769
2770
2771static int __iw_get_encode(struct net_device *dev,
2772 struct iw_request_info *info,
2773 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002774{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302775 hdd_adapter_t *pAdapter;
2776 hdd_context_t *pHddCtx;
2777 hdd_wext_state_t *pWextState;
2778 tCsrRoamProfile *pRoamProfile;
2779 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002781
2782 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302783 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2784 if (NULL == pAdapter)
2785 {
2786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2787 "%s: Adapter is NULL",__func__);
2788 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 }
2790
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302791 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2792 ret = wlan_hdd_validate_context(pHddCtx);
2793 if (0 != ret)
2794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302795 return ret;
2796 }
2797 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2798 if (NULL == pWextState)
2799 {
2800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2801 "%s: pWextState is NULL",__func__);
2802 return -EINVAL;
2803 }
2804
2805 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 keyId = pRoamProfile->Keys.defaultIndex;
2807
2808 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2809 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002810 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 return -EINVAL;
2812 }
2813
2814 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2815 {
2816 dwrq->flags |= IW_ENCODE_ENABLED;
2817 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2818 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2819
2820 dwrq->flags |= (keyId + 1);
2821
2822 }
2823 else
2824 {
2825 dwrq->flags |= IW_ENCODE_DISABLED;
2826 }
2827
2828 for(i=0; i < MAX_WEP_KEYS; i++)
2829 {
2830 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2831 {
2832 continue;
2833 }
2834 else
2835 {
2836 break;
2837 }
2838 }
2839
2840 if(MAX_WEP_KEYS == i)
2841 {
2842 dwrq->flags |= IW_ENCODE_NOKEY;
2843 }
2844
2845 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2846
2847 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2848 {
2849 dwrq->flags |= IW_ENCODE_OPEN;
2850 }
2851 else
2852 {
2853 dwrq->flags |= IW_ENCODE_RESTRICTED;
2854 }
2855 EXIT();
2856 return 0;
2857}
2858
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302859static int iw_get_encode(struct net_device *dev,
2860 struct iw_request_info *info,
2861 struct iw_point *dwrq, char *extra)
2862{
2863 int ret;
2864
2865 vos_ssr_protect(__func__);
2866 ret = __iw_get_encode(dev, info, dwrq, extra);
2867 vos_ssr_unprotect(__func__);
2868
2869 return ret;
2870}
2871
Jeff Johnson295189b2012-06-20 16:38:30 -07002872#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2873#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2874
2875
2876/*
2877 * This function sends a single 'key' to LIM at all time.
2878 */
2879
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302880static int __iw_get_rts_threshold(struct net_device *dev,
2881 struct iw_request_info *info,
2882 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002883{
2884 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2885 v_U32_t status = 0;
2886
2887 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2888
2889 return status;
2890}
2891
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302892static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 struct iw_request_info *info,
2894 union iwreq_data *wrqu, char *extra)
2895{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302896 int ret;
2897
2898 vos_ssr_protect(__func__);
2899 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2900 vos_ssr_unprotect(__func__);
2901
2902 return ret;
2903}
2904
2905static int __iw_set_rts_threshold(struct net_device *dev,
2906 struct iw_request_info *info,
2907 union iwreq_data *wrqu, char *extra)
2908{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302909 hdd_adapter_t *pAdapter;
2910 hdd_context_t *pHddCtx;
2911 tHalHandle hHal;
2912 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002913
2914 ENTER();
2915
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302916 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2917 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002918 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2920 "%s: Adapter is NULL",__func__);
2921 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002922 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302923
2924 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2925 ret = wlan_hdd_validate_context(pHddCtx);
2926 if (0 != ret)
2927 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302928 return ret;
2929 }
2930
2931 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2932 if (NULL == hHal)
2933 {
2934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2935 "%s: Hal Context is NULL",__func__);
2936 return -EINVAL;
2937 }
2938
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2940 {
2941 return -EINVAL;
2942 }
2943
2944 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2945 {
c_hpothub8245442013-11-20 23:41:09 +05302946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2947 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 return -EIO;
2949 }
2950
2951 EXIT();
2952
2953 return 0;
2954}
2955
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302956static int iw_set_rts_threshold(struct net_device *dev,
2957 struct iw_request_info *info,
2958 union iwreq_data *wrqu, char *extra)
2959{
2960 int ret;
2961
2962 vos_ssr_protect(__func__);
2963 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2964 vos_ssr_unprotect(__func__);
2965
2966 return ret;
2967}
2968
2969static int __iw_get_frag_threshold(struct net_device *dev,
2970 struct iw_request_info *info,
2971 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002972{
2973 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2974 v_U32_t status = 0;
2975
2976 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2977
2978 return status;
2979}
2980
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302981static int iw_get_frag_threshold(struct net_device *dev,
2982 struct iw_request_info *info,
2983 union iwreq_data *wrqu, char *extra)
2984{
2985 int ret;
2986
2987 vos_ssr_protect(__func__);
2988 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2989 vos_ssr_unprotect(__func__);
2990
2991 return ret;
2992}
2993
2994static int __iw_set_frag_threshold(struct net_device *dev,
2995 struct iw_request_info *info,
2996 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002997{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302998 hdd_adapter_t *pAdapter;
2999 hdd_context_t *pHddCtx;
3000 tHalHandle hHal;
3001 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003002
3003 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303004 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3005 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003006 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3008 "%s: Adapter is NULL",__func__);
3009 return -EINVAL;
3010 }
3011
3012 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3013 ret = wlan_hdd_validate_context(pHddCtx);
3014 if (0 != ret)
3015 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303016 return ret;
3017 }
3018
3019 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3020 if (NULL == hHal)
3021 {
3022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3023 "%s: Hal Context is NULL",__func__);
3024 return -EINVAL;
3025 }
3026
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3028 {
3029 return -EINVAL;
3030 }
3031
3032 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3033 {
c_hpothub8245442013-11-20 23:41:09 +05303034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3035 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 return -EIO;
3037 }
3038
3039 EXIT();
3040
3041 return 0;
3042}
3043
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303044static int iw_set_frag_threshold(struct net_device *dev,
3045 struct iw_request_info *info,
3046 union iwreq_data *wrqu, char *extra)
3047{
3048 int ret;
3049
3050 vos_ssr_protect(__func__);
3051 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3052 vos_ssr_unprotect(__func__);
3053
3054 return ret;
3055}
3056
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303057static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 struct iw_request_info *info,
3059 union iwreq_data *wrqu, char *extra)
3060{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303061 hdd_adapter_t *pAdapter;
3062 hdd_context_t *pHddCtx;
3063 int ret = 0;
3064
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303066 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3067 if (NULL == pAdapter)
3068 {
3069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3070 "%s: Adapter is NULL",__func__);
3071 return -EINVAL;
3072 }
3073 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3074 ret = wlan_hdd_validate_context(pHddCtx);
3075 if (0 != ret)
3076 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303077 return ret;
3078 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303079
3080 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 return -EOPNOTSUPP;
3082}
3083
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303084static int iw_get_power_mode(struct net_device *dev,
3085 struct iw_request_info *info,
3086 union iwreq_data *wrqu, char *extra)
3087{
3088 int ret;
3089
3090 vos_ssr_protect(__func__);
3091 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3092 vos_ssr_unprotect(__func__);
3093
3094 return ret;
3095}
3096static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 struct iw_request_info *info,
3098 union iwreq_data *wrqu, char *extra)
3099{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303100 hdd_adapter_t *pAdapter;
3101 hdd_context_t *pHddCtx;
3102 int ret = 0;
3103
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303105 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3106 if (NULL == pAdapter)
3107 {
3108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3109 "%s: Adapter is NULL",__func__);
3110 return -EINVAL;
3111 }
3112 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3113 ret = wlan_hdd_validate_context(pHddCtx);
3114 if (0 != ret)
3115 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303116 return ret;
3117 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303118
3119 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 return -EOPNOTSUPP;
3121}
3122
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303123static int iw_set_power_mode(struct net_device *dev,
3124 struct iw_request_info *info,
3125 union iwreq_data *wrqu, char *extra)
3126{
3127 int ret;
3128
3129 vos_ssr_protect(__func__);
3130 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3131 vos_ssr_unprotect(__func__);
3132
3133 return ret;
3134}
3135
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303136static int __iw_get_range(struct net_device *dev,
3137 struct iw_request_info *info,
3138 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003139{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303140 hdd_adapter_t *pAdapter;
3141 tHalHandle hHal;
3142 hdd_context_t *pHddCtx;
3143 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 struct iw_range *range = (struct iw_range *) extra;
3145
3146 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3147
3148 v_U32_t num_channels = sizeof(channels);
3149 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3150 v_U32_t a_len;
3151 v_U32_t b_len;
3152 v_U32_t active_phy_mode = 0;
3153 v_U8_t index = 0, i;
3154
3155 ENTER();
3156
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303157 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3158 if (NULL == pAdapter)
3159 {
3160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3161 "%s: pAdapter is NULL", __func__);
3162 return -EINVAL;
3163 }
3164 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3165 ret = wlan_hdd_validate_context(pHddCtx);
3166 if (0 != ret)
3167 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303168 return ret;
3169 }
3170 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3171 if (NULL == hHal)
3172 {
3173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3174 "%s: pAdapter is NULL", __func__);
3175 return -EINVAL;
3176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 wrqu->data.length = sizeof(struct iw_range);
3178 memset(range, 0, sizeof(struct iw_range));
3179
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 /*Get the phy mode*/
3181 if (ccmCfgGetInt(hHal,
3182 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3183 {
3184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003185 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003186
3187 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3188 {
3189 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003190 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 if (ccmCfgGetStr(hHal,
3192 WNI_CFG_SUPPORTED_RATES_11A,
3193 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3194 {
3195 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3196 {
3197 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3198 }
3199 for (i = 0; i < a_len; i++)
3200 {
3201 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3202 }
3203 range->num_bitrates = a_len;
3204 }
3205 else
3206 {
3207 return -EIO;
3208 }
3209 }
3210 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3211 {
3212 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003213 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 if (ccmCfgGetStr(hHal,
3215 WNI_CFG_SUPPORTED_RATES_11B,
3216 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3217 {
3218 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3219 {
3220 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3221 }
3222 for (i = 0; i < b_len; i++)
3223 {
3224 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3225 }
3226 range->num_bitrates = b_len;
3227 }
3228 else
3229 {
3230 return -EIO;
3231 }
3232 }
3233 }
3234
3235 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3236 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3237 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3238
3239 range->encoding_size[0] = 5;
3240 range->encoding_size[1] = 13;
3241 range->num_encoding_sizes = 2;
3242 range->max_encoding_tokens = MAX_WEP_KEYS;
3243
3244 // we support through Wireless Extensions 22
3245 range->we_version_compiled = WIRELESS_EXT;
3246 range->we_version_source = 22;
3247
3248 /*Supported Channels and Frequencies*/
3249 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3250 {
c_hpothub8245442013-11-20 23:41:09 +05303251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3252 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 return -EIO;
3254 }
3255 if (num_channels > IW_MAX_FREQUENCIES)
3256 {
3257 num_channels = IW_MAX_FREQUENCIES;
3258 }
3259
3260 range->num_channels = num_channels;
3261 range->num_frequency = num_channels;
3262
3263 for (index=0; index < num_channels; index++)
3264 {
3265 v_U32_t frq_indx = 0;
3266
3267 range->freq[index].i = channels[index];
3268 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3269 {
3270 if(channels[index] == freq_chan_map[frq_indx].chan)
3271 {
3272 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3273 range->freq[index].e = 1;
3274 break;
3275 }
3276 frq_indx++;
3277 }
3278 }
3279
3280 /* Event capability (kernel + driver) */
3281 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3282 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3283 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3284 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3285
3286 /*Encryption capability*/
3287 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3288 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3289
3290 /* Txpower capability */
3291 range->txpower_capa = IW_TXPOW_MWATT;
3292
3293 /*Scanning capability*/
3294 #if WIRELESS_EXT >= 22
3295 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3296 #endif
3297
3298 EXIT();
3299 return 0;
3300}
3301
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303302static int iw_get_range(struct net_device *dev,
3303 struct iw_request_info *info,
3304 union iwreq_data *wrqu, char *extra)
3305{
3306 int ret;
3307
3308 vos_ssr_protect(__func__);
3309 ret = __iw_get_range(dev, info, wrqu, extra);
3310 vos_ssr_unprotect(__func__);
3311
3312 return ret;
3313}
3314
Jeff Johnson295189b2012-06-20 16:38:30 -07003315/* Callback function registered with PMC to know status of PMC request */
3316static void iw_power_callback_fn (void *pContext, eHalStatus status)
3317{
3318 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319
3320 if (NULL == pContext)
3321 {
3322 hddLog(VOS_TRACE_LEVEL_ERROR,
3323 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003324 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 return;
3326 }
3327
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
Jeff Johnson72a40512013-12-19 10:14:15 -08003330 /* there is a race condition that exists between this callback
3331 function and the caller since the caller could time out either
3332 before or while this code is executing. we use a spinlock to
3333 serialize these actions */
3334 spin_lock(&hdd_context_lock);
3335
3336 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 {
3338 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003339 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003341 "%s: Invalid context, magic [%08x]",
3342 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003343
3344 if (ioctl_debug)
3345 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003346 pr_info("%s: Invalid context, magic [%08x]\n",
3347 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 }
3349 return;
3350 }
3351
Jeff Johnson72a40512013-12-19 10:14:15 -08003352 /* context is valid so caller is still waiting */
3353
3354 /* paranoia: invalidate the magic */
3355 pStatsContext->magic = 0;
3356
3357 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003359
3360 /* serialization is complete */
3361 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003362}
3363
3364/* Callback function for tx per hit */
3365void hdd_tx_per_hit_cb (void *pCallbackContext)
3366{
3367 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3368 unsigned char tx_fail[16];
3369 union iwreq_data wrqu;
3370
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303371 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003373 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 return;
3375 }
3376 memset(&wrqu, 0, sizeof(wrqu));
3377 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3378 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3379}
3380
3381void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3382{
3383 struct statsContext *pStatsContext;
3384 tCsrGlobalClassAStatsInfo *pClassAStats;
3385 hdd_adapter_t *pAdapter;
3386
3387 if (ioctl_debug)
3388 {
3389 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003390 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 }
3392
3393 if ((NULL == pStats) || (NULL == pContext))
3394 {
3395 hddLog(VOS_TRACE_LEVEL_ERROR,
3396 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003397 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 return;
3399 }
3400
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 pClassAStats = pStats;
3402 pStatsContext = pContext;
3403 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003404
3405 /* there is a race condition that exists between this callback
3406 function and the caller since the caller could time out either
3407 before or while this code is executing. we use a spinlock to
3408 serialize these actions */
3409 spin_lock(&hdd_context_lock);
3410
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3412 {
3413 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003414 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 hddLog(VOS_TRACE_LEVEL_WARN,
3416 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003417 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 if (ioctl_debug)
3419 {
3420 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003421 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 }
3423 return;
3424 }
3425
Jeff Johnson72a40512013-12-19 10:14:15 -08003426 /* context is valid so caller is still waiting */
3427
3428 /* paranoia: invalidate the magic */
3429 pStatsContext->magic = 0;
3430
3431 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3433
Jeff Johnson72a40512013-12-19 10:14:15 -08003434 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003436
3437 /* serialization is complete */
3438 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003439}
3440
3441VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3442{
3443 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3444 eHalStatus hstatus;
3445 long lrc;
3446 struct statsContext context;
3447
3448 if (NULL == pAdapter)
3449 {
3450 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3451 return VOS_STATUS_E_FAULT;
3452 }
3453 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3454 {
3455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3456 return VOS_STATUS_SUCCESS;
3457 }
3458
3459 /* we are connected
3460 prepare our callback context */
3461 init_completion(&context.completion);
3462 context.pAdapter = pAdapter;
3463 context.magic = STATS_CONTEXT_MAGIC;
3464 /* query only for Class A statistics (which include link speed) */
3465 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3466 eCSR_HDD,
3467 SME_GLOBAL_CLASSA_STATS,
3468 hdd_GetClassA_statisticsCB,
3469 0, // not periodic
3470 FALSE, //non-cached results
3471 pHddStaCtx->conn_info.staId[0],
3472 &context);
3473 if (eHAL_STATUS_SUCCESS != hstatus)
3474 {
3475 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003476 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003477 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 /* we'll returned a cached value below */
3479 }
3480 else
3481 {
3482 /* request was sent -- wait for the response */
3483 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3484 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 if (lrc <= 0)
3486 {
3487 hddLog(VOS_TRACE_LEVEL_ERROR,
3488 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003489 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 }
3491 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003492
3493 /* either we never sent a request, we sent a request and received a
3494 response or we sent a request and timed out. if we never sent a
3495 request or if we sent a request and got a response, we want to
3496 clear the magic out of paranoia. if we timed out there is a
3497 race condition such that the callback function could be
3498 executing at the same time we are. of primary concern is if the
3499 callback function had already verified the "magic" but had not
3500 yet set the completion variable when a timeout occurred. we
3501 serialize these activities by invalidating the magic while
3502 holding a shared spinlock which will cause us to block if the
3503 callback is currently executing */
3504 spin_lock(&hdd_context_lock);
3505 context.magic = 0;
3506 spin_unlock(&hdd_context_lock);
3507
3508 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 return VOS_STATUS_SUCCESS;
3510}
3511
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003512static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3513{
3514 struct statsContext *pStatsContext;
3515 tCsrSummaryStatsInfo *pSummaryStats;
3516 tCsrGlobalClassAStatsInfo *pClassAStats;
3517 hdd_adapter_t *pAdapter;
3518
3519 if (ioctl_debug)
3520 {
3521 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003522 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003523 }
3524
3525 if ((NULL == pStats) || (NULL == pContext))
3526 {
3527 hddLog(VOS_TRACE_LEVEL_ERROR,
3528 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003529 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003530 return;
3531 }
3532
Jeff Johnson72a40512013-12-19 10:14:15 -08003533 /* there is a race condition that exists between this callback
3534 function and the caller since the caller could time out either
3535 before or while this code is executing. we use a spinlock to
3536 serialize these actions */
3537 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003538
3539 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3540 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3541 pStatsContext = pContext;
3542 pAdapter = pStatsContext->pAdapter;
3543 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3544 {
3545 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003546 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003547 hddLog(VOS_TRACE_LEVEL_WARN,
3548 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003549 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003550 if (ioctl_debug)
3551 {
3552 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003553 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003554 }
3555 return;
3556 }
3557
Jeff Johnson72a40512013-12-19 10:14:15 -08003558 /* context is valid so caller is still waiting */
3559
3560 /* paranoia: invalidate the magic */
3561 pStatsContext->magic = 0;
3562
3563 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003564 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3565 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3566
Jeff Johnson72a40512013-12-19 10:14:15 -08003567 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003568 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003569
3570 /* serialization is complete */
3571 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003572}
3573
3574VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3575{
3576 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3577 eHalStatus hstatus;
3578 long lrc;
3579 struct statsContext context;
3580
3581 if (NULL == pAdapter)
3582 {
3583 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3584 return VOS_STATUS_SUCCESS;
3585 }
3586
3587 /* we are connected
3588 prepare our callback context */
3589 init_completion(&context.completion);
3590 context.pAdapter = pAdapter;
3591 context.magic = STATS_CONTEXT_MAGIC;
3592
3593 /* query only for Summary & Class A statistics */
3594 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3595 eCSR_HDD,
3596 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303597 SME_GLOBAL_CLASSA_STATS |
3598 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003599 hdd_get_station_statisticsCB,
3600 0, // not periodic
3601 FALSE, //non-cached results
3602 pHddStaCtx->conn_info.staId[0],
3603 &context);
3604 if (eHAL_STATUS_SUCCESS != hstatus)
3605 {
3606 hddLog(VOS_TRACE_LEVEL_ERROR,
3607 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003608 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003609 /* we'll return with cached values */
3610 }
3611 else
3612 {
3613 /* request was sent -- wait for the response */
3614 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3615 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003616
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003617 if (lrc <= 0)
3618 {
3619 hddLog(VOS_TRACE_LEVEL_ERROR,
3620 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003621 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003622 }
3623 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003624
3625 /* either we never sent a request, we sent a request and received a
3626 response or we sent a request and timed out. if we never sent a
3627 request or if we sent a request and got a response, we want to
3628 clear the magic out of paranoia. if we timed out there is a
3629 race condition such that the callback function could be
3630 executing at the same time we are. of primary concern is if the
3631 callback function had already verified the "magic" but had not
3632 yet set the completion variable when a timeout occurred. we
3633 serialize these activities by invalidating the magic while
3634 holding a shared spinlock which will cause us to block if the
3635 callback is currently executing */
3636 spin_lock(&hdd_context_lock);
3637 context.magic = 0;
3638 spin_unlock(&hdd_context_lock);
3639
3640 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003641 return VOS_STATUS_SUCCESS;
3642}
3643
3644
Jeff Johnson295189b2012-06-20 16:38:30 -07003645/*
3646 * Support for the LINKSPEED private command
3647 * Per the WiFi framework the response must be of the form
3648 * "LinkSpeed xx"
3649 */
3650static int iw_get_linkspeed(struct net_device *dev,
3651 struct iw_request_info *info,
3652 union iwreq_data *wrqu, char *extra)
3653{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303654 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303655 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303657 int len = sizeof(v_U32_t) + 1;
3658 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303659 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303660 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303661 int rc, valid = 0;
3662
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303663 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303664 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3665 if (NULL == pAdapter)
3666 {
3667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3668 "%s: Adapter is NULL",__func__);
3669 return -EINVAL;
3670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303672 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303673 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303674 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003675 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303676 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003677 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303678 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3679 if (NULL == pHddStaCtx)
3680 {
3681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3682 "%s: STA Context is NULL",__func__);
3683 return -EINVAL;
3684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3686 {
3687 /* we are not connected so we don't have a classAstats */
3688 link_speed = 0;
3689 }
3690 else
3691 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303692 status = wlan_hdd_get_classAstats(pAdapter);
3693
3694 if (!VOS_IS_STATUS_SUCCESS(status ))
3695 {
3696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3697 return -EINVAL;
3698 }
3699
3700 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3701 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3702 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3703 &link_speed);
3704
3705 link_speed = link_speed / 10;
3706
3707 if (0 == link_speed)
3708 {
3709 /* The linkspeed returned by HAL is in units of 500kbps.
3710 * converting it to mbps.
3711 * This is required to support legacy firmware which does
3712 * not return link capacity.
3713 */
3714 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3715 }
3716
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 }
3718
3719 wrqu->data.length = len;
3720 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003721 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 if ((rc < 0) || (rc >= len))
3723 {
3724 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303725 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 return -EIO;
3727 }
3728
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303729 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003731 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003732}
3733
Arif Hussain695279c2014-03-24 14:06:07 -07003734/*
3735 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3736 *
3737 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303738static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003739 struct iw_request_info *info,
3740 union iwreq_data *wrqu, char *extra)
3741{
3742 int rc;
3743
3744 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3745
3746 if (rc < 0)
3747 return rc;
3748
3749 /* a value is being successfully returned */
3750 return 0;
3751}
Jeff Johnson295189b2012-06-20 16:38:30 -07003752
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303753static int iw_get_linkspeed_priv(struct net_device *dev,
3754 struct iw_request_info *info,
3755 union iwreq_data *wrqu, char *extra)
3756{
3757 int ret;
3758
3759 vos_ssr_protect(__func__);
3760 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3761 vos_ssr_unprotect(__func__);
3762
3763 return ret;
3764}
3765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303767 * Support for the RSSI & RSSI-APPROX private commands
3768 * Per the WiFi framework the response must be of the form
3769 * "<ssid> rssi <xx>"
3770 * unless we are not associated, in which case the response is
3771 * "OK"
3772 */
3773static int iw_get_rssi(struct net_device *dev,
3774 struct iw_request_info *info,
3775 union iwreq_data *wrqu, char *extra)
3776{
3777 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3778 char *cmd = extra;
3779 int len = wrqu->data.length;
3780 v_S7_t s7Rssi = 0;
3781 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3782 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3783 VOS_STATUS vosStatus;
3784 int rc;
3785
3786 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3787 (0 == ssidlen) || (ssidlen >= len))
3788 {
3789 /* we are not connected or our SSID is too long
3790 so we cannot report an rssi */
3791 rc = scnprintf(cmd, len, "OK");
3792 }
3793 else
3794 {
3795 /* we are connected with a valid SSID
3796 so we can write the SSID into the return buffer
3797 (note that it is not NUL-terminated) */
3798 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3799
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303800 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303801 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3802
3803 if (VOS_STATUS_SUCCESS == vosStatus)
3804 {
3805 /* append the rssi to the ssid in the format required by
3806 the WiFI Framework */
3807 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3808 rc += ssidlen;
3809 }
3810 else
3811 {
3812 rc = -1;
3813 }
3814 }
3815
3816 /* verify that we wrote a valid response */
3817 if ((rc < 0) || (rc >= len))
3818 {
3819 // encoding or length error?
3820 hddLog(VOS_TRACE_LEVEL_ERROR,
3821 "%s: Unable to encode RSSI, got [%s]",
3822 __func__, cmd);
3823 return -EIO;
3824 }
3825
3826 /* a value is being successfully returned */
3827 return rc;
3828}
3829
3830/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 * Support for SoftAP channel range private command
3832 */
3833static int iw_softap_set_channel_range( struct net_device *dev,
3834 int startChannel,
3835 int endChannel,
3836 int band)
3837{
Jeff Johnson43971f52012-07-17 12:26:56 -07003838 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 int ret = 0;
3840 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3841 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003842 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3843
Jeff Johnson295189b2012-06-20 16:38:30 -07003844
3845 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3846 if (VOS_STATUS_SUCCESS != status)
3847 {
3848 ret = -EINVAL;
3849 }
Yathish9f22e662012-12-10 14:21:35 -08003850 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 return ret;
3852}
3853
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303854static uint8 chartohex(char c)
3855{
3856 uint8 val = 0;
3857 if (c >= '0' && c <= '9')
3858 val = c - '0';
3859 else if (c >= 'a' && c <= 'f')
3860 val = c - 'a' + 10;
3861 else if (c >= 'A' && c <= 'F')
3862 val = c - 'A' + 10;
3863 else
3864 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3865
3866 return val;
3867}
3868
3869uint8 getByte(char **buf)
3870{
3871 uint8 byte = 0;
3872 char *temp = *buf;
3873 byte = chartohex(*temp) * 16;
3874 temp++;
3875 byte += chartohex(*temp);
3876 temp++;
3877 *buf = temp;
3878 return byte;
3879}
3880
3881static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3882{
3883 tSir80211Header *macHeader;
3884 int i = 0, j = 0, length = 0;
3885 uint8 byte = 0;
3886 char *temp = pBuffer;
3887 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303888 char *pHeader;
3889 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303890
3891 macHeader = &pkt->macHeader;
3892
3893 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3894
3895 temp++;
3896
3897 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3898 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3899 pkt->encParams.keyParams.key[0].keyId);
3900
3901 for (i = 0; i< 16; i++) {
3902 pkt->encParams.keyParams.key[0].key[i]
3903 = getByte(&temp);
3904 }
3905
3906 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3907 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3908
3909 for (i = 0; i< 6; i++) {
3910 pkt->encParams.pn[i]
3911 = getByte(&temp);
3912 }
3913
3914 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3915 &pkt->encParams.pn[0], 6, 0);
3916
3917 for (i = 0, j= 5; i< 3; i++, j--) {
3918 byte = pkt->encParams.pn[i];
3919 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3920 pkt->encParams.pn[j] = byte;
3921 }
3922
3923 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303924 if (length > sizeof(tSir80211Header))
3925 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303926
Srinivas Dasari2382de62015-01-22 15:00:04 +05303927 pHeader = temp;
3928 vos_mem_zero(&header, sizeof(tSir80211Header));
3929 for (i = 0; i < length; i++) {
3930 *((uint8 *)&header + i) = getByte(&pHeader);
3931 }
3932
3933 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3934 (char *)&header, length, 0);
3935
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303936 byte = getByte(&temp);
3937
3938 macHeader->frameCtrl.protVer = byte & 0x3;
3939 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3940 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3941
3942 byte = getByte(&temp);
3943 macHeader->frameCtrl.toDS = (byte) & 0x1;
3944 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3945 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3946 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3947 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3948 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3949 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3950 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3951
3952 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3953 "macHeader->frameCtrl.type : %x "
3954 "macHeader->frameCtrl.subType : %x "
3955 "macHeader->frameCtrl.toDS : %x "
3956 "macHeader->frameCtrl.fromDS : %x "
3957 "macHeader->frameCtrl.moreFrag : %x "
3958 "macHeader->frameCtrl.retry : %x "
3959 "macHeader->frameCtrl.powerMgmt : %x "
3960 "macHeader->frameCtrl.MoreData : %x "
3961 "macHeader->frameCtrl.wep : %x "
3962 "macHeader->frameCtrl.order : %x "
3963 , macHeader->frameCtrl.protVer
3964 , macHeader->frameCtrl.type
3965 , macHeader->frameCtrl.subType
3966 , macHeader->frameCtrl.toDS
3967 , macHeader->frameCtrl.fromDS
3968 , macHeader->frameCtrl.moreFrag
3969 , macHeader->frameCtrl.retry
3970 , macHeader->frameCtrl.powerMgmt
3971 , macHeader->frameCtrl.moreData
3972 , macHeader->frameCtrl.wep
3973 , macHeader->frameCtrl.order);
3974
3975
3976 macHeader->usDurationId = getByte(&temp);
3977 macHeader->usDurationId += getByte(&temp) << 8;
3978
3979 macHeader->vA1[0] = getByte(&temp);
3980 macHeader->vA1[1] = getByte(&temp);
3981 macHeader->vA1[2] = getByte(&temp);
3982 macHeader->vA1[3] = getByte(&temp);
3983 macHeader->vA1[4] = getByte(&temp);
3984 macHeader->vA1[5] = getByte(&temp);
3985
3986 macHeader->vA2[0] = getByte(&temp);
3987 macHeader->vA2[1] = getByte(&temp);
3988 macHeader->vA2[2] = getByte(&temp);
3989 macHeader->vA2[3] = getByte(&temp);
3990 macHeader->vA2[4] = getByte(&temp);
3991 macHeader->vA2[5] = getByte(&temp);
3992
3993 macHeader->vA3[0] = getByte(&temp);
3994 macHeader->vA3[1] = getByte(&temp);
3995 macHeader->vA3[2] = getByte(&temp);
3996 macHeader->vA3[3] = getByte(&temp);
3997 macHeader->vA3[4] = getByte(&temp);
3998 macHeader->vA3[5] = getByte(&temp);
3999
4000 macHeader->sSeqCtrl = getByte(&temp);
4001 fragNum = macHeader->sSeqCtrl & 0xF;
4002 macHeader->sSeqCtrl >>= 4;
4003
4004 macHeader->sSeqCtrl += getByte(&temp) << 4;
4005
4006 macHeader->sSeqCtrl |= fragNum << 12;
4007
4008 if (length == 30 || length == 32) {
4009 macHeader->optvA4[0] = getByte(&temp);
4010 macHeader->optvA4[1] = getByte(&temp);
4011 macHeader->optvA4[2] = getByte(&temp);
4012 macHeader->optvA4[3] = getByte(&temp);
4013 macHeader->optvA4[4] = getByte(&temp);
4014 macHeader->optvA4[5] = getByte(&temp);
4015 }
4016
4017 if (length == 26 || length == 32) {
4018 macHeader->usQosCtrl = getByte(&temp);
4019 macHeader->usQosCtrl += getByte(&temp) << 8;
4020 }
4021
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304022 //parse payload
4023 length = getByte(&temp);
4024 length += getByte(&temp) << 8;
4025 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4026
Manjeet Singh5830f142016-11-21 18:21:17 +05304027 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
4028 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
4029
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304030 pkt->data.length = length;
4031
4032 for (i = 0; i< length; i++) {
4033 pkt->data.data[i] = getByte(&temp);
4034 }
4035
4036 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4037 &pkt->data.data[0], pkt->data.length, 0);
4038}
4039
4040/**---------------------------------------------------------------------------
4041
4042 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4043 encrypt message request
4044 This is an asynchronous callback function from SME when the encrypted data
4045 is received
4046
4047 \pEncInfoRsp -> Encrypted data info
4048
4049 \return - 0 for success non-zero for failure
4050 --------------------------------------------------------------------------*/
4051static void
4052hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4053{
4054 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4055
4056 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4057
4058 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4059 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4060 pEncryptedDataRsp->encryptedPayload.length);
4061 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4062 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4063 pEncryptedDataRsp->encryptedPayload.data,
4064 pEncryptedDataRsp->encryptedPayload.length, 0);
4065}
4066
Jeff Johnson295189b2012-06-20 16:38:30 -07004067VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4068{
4069 struct statsContext context;
4070 eHalStatus status;
4071 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304072 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004073
4074 if (NULL == pAdapter)
4075 {
4076 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4077 return VOS_STATUS_E_FAULT;
4078 }
4079
4080 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4081 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304082 if (pHddCtx->isLogpInProgress) {
4083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4084 "%s:LOGP in Progress. Ignore!!!", __func__);
4085 return VOS_STATUS_E_FAILURE;
4086 }
4087
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 init_completion(&context.completion);
4089
4090 context.pAdapter = pAdapter;
4091 context.magic = POWER_CONTEXT_MAGIC;
4092
4093 if (DRIVER_POWER_MODE_ACTIVE == mode)
4094 {
4095 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4096 "Full Power", __func__);
4097 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4098 iw_power_callback_fn, &context,
4099 eSME_FULL_PWR_NEEDED_BY_HDD);
4100 // Enter Full power command received from GUI this means we are disconnected
4101 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4102 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4103 if (eHAL_STATUS_PMC_PENDING == status)
4104 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004105 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 int lrc = wait_for_completion_interruptible_timeout(
4107 &context.completion,
4108 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004109
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 if (lrc <= 0)
4111 {
4112 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004113 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 }
4115 }
4116 }
4117 else if (DRIVER_POWER_MODE_AUTO == mode)
4118 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304119 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4120 * was already in BMPS state and thus either STA or P2P-CLI is in
4121 * associated state and authenticated, so even if STA connState is
4122 * not associated it can be assumed that P2P-CLI is associated and
4123 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4124 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4125 * if all condition are satisfied for entering BMPS.
4126 */
4127 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4128 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304129 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304130 hddLog(LOGE,
4131 FL("Station is associated but, still not Authenticated ignore "
4132 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304133 return VOS_STATUS_E_AGAIN;
4134 }
4135
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4137 {
4138 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4139 __func__);
4140 // Enter BMPS command received from GUI this means DHCP is completed
4141 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4142 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4143 FALSE);
4144 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4145 iw_power_callback_fn, &context);
4146 if (eHAL_STATUS_PMC_PENDING == status)
4147 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004148 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 int lrc = wait_for_completion_interruptible_timeout(
4150 &context.completion,
4151 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 if (lrc <= 0)
4153 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004154 hddLog(VOS_TRACE_LEVEL_ERROR,
4155 "%s: SME %s while requesting BMPS",
4156 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 }
4158 }
4159 }
4160 else
4161 {
4162 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4163 "enabled in the cfg");
4164 }
4165 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004166
4167 /* either we never sent a request, we sent a request and received a
4168 response or we sent a request and timed out. if we never sent a
4169 request or if we sent a request and got a response, we want to
4170 clear the magic out of paranoia. if we timed out there is a
4171 race condition such that the callback function could be
4172 executing at the same time we are. of primary concern is if the
4173 callback function had already verified the "magic" but had not
4174 yet set the completion variable when a timeout occurred. we
4175 serialize these activities by invalidating the magic while
4176 holding a shared spinlock which will cause us to block if the
4177 callback is currently executing */
4178 spin_lock(&hdd_context_lock);
4179 context.magic = 0;
4180 spin_unlock(&hdd_context_lock);
4181
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 return VOS_STATUS_SUCCESS;
4183}
4184
4185VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4186 hdd_adapter_t *pAdapter)
4187{
4188 VOS_STATUS vos_Status;
4189
4190 if ((NULL == pAdapter) || (NULL == pHddCtx))
4191 {
4192 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4193 return VOS_STATUS_E_FAULT;
4194 }
4195
4196 /**Exit from Deep sleep or standby if we get the driver
4197 START cmd from android GUI
4198 */
4199 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4200 {
4201 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4202 "from Stand by",__func__);
4203 vos_Status = hdd_exit_standby(pHddCtx);
4204 }
4205 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4206 {
4207 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4208 "from deep sleep",__func__);
4209 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4210 }
4211 else
4212 {
4213 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4214 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4215 vos_Status = VOS_STATUS_SUCCESS;
4216 }
4217
4218 return vos_Status;
4219}
4220
4221VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4222{
4223 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4224
4225 if (NULL == pHddCtx)
4226 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304227 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 return VOS_STATUS_E_FAULT;
4229 }
4230
4231 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4232 {
4233 //Execute standby procedure.
4234 //Executing standby procedure will cause the STA to
4235 //disassociate first and then the chip will be put into standby.
4236 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4237 vos_Status = hdd_enter_standby(pHddCtx);
4238 }
4239 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4240 pHddCtx->cfg_ini->nEnableDriverStop)
4241 {
4242 //Execute deep sleep procedure
4243 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004244 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 //Deep sleep not supported
4246 vos_Status = hdd_enter_standby(pHddCtx);
4247 }
4248 else
4249 {
4250 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4251 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4252 vos_Status = VOS_STATUS_SUCCESS;
4253 }
4254
4255 return vos_Status;
4256}
4257
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004258
4259void* wlan_hdd_change_country_code_callback(void *pAdapter)
4260{
4261
4262 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004263 complete(&call_back_pAdapter->change_country_code);
4264
4265 return NULL;
4266}
4267
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304268static int __iw_set_priv(struct net_device *dev,
4269 struct iw_request_info *info,
4270 union iwreq_data *wrqu, char *extra)
4271{
4272 hdd_adapter_t *pAdapter;
4273 char *cmd = NULL;
4274 int cmd_len = wrqu->data.length;
4275 int rc = 0, ret = 0;
4276 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4277
4278 hdd_context_t *pHddCtx;
4279
4280 ENTER();
4281
4282 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4283 if (NULL == pAdapter)
4284 {
4285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4286 "mem_alloc_copy_from_user_helper fail");
4287 return -EINVAL;
4288 }
4289 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4290 rc = wlan_hdd_validate_context(pHddCtx);
4291 if (0 != rc)
4292 {
4293 return rc;
4294 }
4295
4296 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4297 wrqu->data.length);
4298 if (NULL == cmd)
4299 {
4300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4301 "mem_alloc_copy_from_user_helper fail");
4302 return -ENOMEM;
4303 }
4304
4305 if (ioctl_debug)
4306 {
4307 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4308 }
4309
4310 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4311 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4312
4313 if (strncmp(cmd, "CSCAN", 5) == 0 )
4314 {
4315 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4317 "%s: Error in iw_set_scan!", __func__);
4318 rc = -EINVAL;
4319 }
4320 }
4321 else if( strcasecmp(cmd, "start") == 0 ) {
4322
4323 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4324 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4325
4326 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4327 if (vos_status == VOS_STATUS_SUCCESS)
4328 {
4329 union iwreq_data wrqu;
4330 char buf[10];
4331
4332 memset(&wrqu, 0, sizeof(wrqu));
4333 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4334 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4335 }
4336 else
4337 {
4338 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4339 rc = -EIO;
4340 }
4341 goto done;
4342 }
4343 else if( strcasecmp(cmd, "stop") == 0 )
4344 {
4345 union iwreq_data wrqu;
4346 char buf[10];
4347
4348 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4349
4350 wlan_hdd_enter_lowpower(pHddCtx);
4351 memset(&wrqu, 0, sizeof(wrqu));
4352 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4353 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4354 goto done;
4355 }
4356 else if (strcasecmp(cmd, "macaddr") == 0)
4357 {
4358 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4359 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4360 }
4361 else if (strcasecmp(cmd, "scan-active") == 0)
4362 {
4363 hddLog(LOG1,
4364 FL("making default scan to active"));
4365 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4366 ret = snprintf(cmd, cmd_len, "OK");
4367 }
4368 else if (strcasecmp(cmd, "scan-passive") == 0)
4369 {
4370 hddLog(LOG1,
4371 FL("making default scan to passive"));
4372 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4373 ret = snprintf(cmd, cmd_len, "OK");
4374 }
4375 else if( strcasecmp(cmd, "scan-mode") == 0 )
4376 {
4377 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4378 }
4379 else if( strcasecmp(cmd, "linkspeed") == 0 )
4380 {
4381 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4382 }
4383 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4384 {
4385 ret = iw_get_rssi(dev, info, wrqu, cmd);
4386 }
4387 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4388 int mode;
4389 char *ptr;
4390
4391 if (9 < cmd_len)
4392 {
4393 ptr = (char*)(cmd + 9);
4394
4395 }else{
4396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4397 "CMD LENGTH %d is not correct",cmd_len);
4398 kfree(cmd);
4399 return -EINVAL;
4400 }
4401
4402 if (1 != sscanf(ptr,"%d",&mode))
4403 {
4404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4405 "powermode input %s is not correct",ptr);
4406 kfree(cmd);
4407 return -EIO;
4408 }
4409
4410 wlan_hdd_enter_bmps(pAdapter, mode);
4411 /*TODO:Set the power mode*/
4412 }
4413 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4414 v_U32_t pmc_state;
4415 v_U16_t value;
4416
4417 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4418 if(pmc_state == BMPS) {
4419 value = DRIVER_POWER_MODE_AUTO;
4420 }
4421 else {
4422 value = DRIVER_POWER_MODE_ACTIVE;
4423 }
4424 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4425 }
4426 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4427 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4428 /*TODO: set the btcoexmode*/
4429 }
4430 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4431
4432 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4433 /*TODO: Return the btcoex status*/
4434 }
4435 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4436
4437 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4438
4439 /*TODO: Enable Rx data Filter*/
4440 }
4441 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4442
4443 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4444
4445 /*TODO: Disable Rx data Filter*/
4446 }
4447 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4448
4449 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4450 /*TODO: rxfilter-statistics*/
4451 }
4452 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4453
4454 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4455 /*TODO: rxfilter-add*/
4456 }
4457 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4458
4459 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4460 /*TODO: rxfilter-remove*/
4461 }
4462#ifdef FEATURE_WLAN_SCAN_PNO
4463 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4464 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4465 /*TODO: support pnosetup*/
4466 }
4467 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4468 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4469 /*TODO: support pnoforce*/
4470 }
4471 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4472
4473 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4474 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4475 kfree(cmd);
4476 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4477 }
4478 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4479 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4480 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4481 kfree(cmd);
4482 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4483 }
4484#endif /*FEATURE_WLAN_SCAN_PNO*/
4485 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4486 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4487 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4488 kfree(cmd);
4489 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4490 }
4491 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4492 tSirTxPerTrackingParam tTxPerTrackingParam;
4493 char *ptr;
4494
4495 if (18 < cmd_len)
4496 {
4497 ptr = (char*)(cmd + 18);
4498 }else{
4499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4500 "CMD LENGTH %d is not correct",cmd_len);
4501 kfree(cmd);
4502 return -EINVAL;
4503 }
4504
4505 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4506 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4507 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4508 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4509 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4510 {
4511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4512 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4513 kfree(cmd);
4514 return -EIO;
4515 }
4516
4517 // parameters checking
4518 // period has to be larger than 0
4519 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4520 {
4521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4522 kfree(cmd);
4523 return -EIO;
4524 }
4525
4526 // use default value 5 is the input is not reasonable. in unit of 10%
4527 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4528 {
4529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4530 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4531 }
4532
4533 // default is 5
4534 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4535 {
4536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4537 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4538 }
4539
4540 if (eHAL_STATUS_SUCCESS !=
4541 sme_SetTxPerTracking(pHddCtx->hHal,
4542 hdd_tx_per_hit_cb,
4543 (void*)pAdapter, &tTxPerTrackingParam)) {
4544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4545 rc = -EIO;
4546 }
4547 }
4548 else {
4549 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4550 __func__, cmd);
4551 }
4552done:
4553 /* many of the commands write information back into the command
4554 string using snprintf(). check the return value here in one
4555 place */
4556 if ((ret < 0) || (ret >= cmd_len))
4557 {
4558 /* there was an encoding error or overflow */
4559 rc = -EINVAL;
4560 }
4561 else if (ret > 0)
4562 {
4563 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4564 {
4565 hddLog(VOS_TRACE_LEVEL_ERROR,
4566 "%s: failed to copy data to user buffer", __func__);
4567 kfree(cmd);
4568 return -EFAULT;
4569 }
4570 wrqu->data.length = ret;
4571 }
4572
4573 if (ioctl_debug)
4574 {
4575 pr_info("%s: rsp [%s] len [%d] status %d\n",
4576 __func__, cmd, wrqu->data.length, rc);
4577 }
4578 kfree(cmd);
4579 EXIT();
4580 return rc;
4581}
4582
4583static int iw_set_priv(struct net_device *dev,
4584 struct iw_request_info *info,
4585 union iwreq_data *wrqu, char *extra)
4586{
4587 int ret;
4588 vos_ssr_protect(__func__);
4589 ret = __iw_set_priv(dev, info, wrqu, extra);
4590 vos_ssr_unprotect(__func__);
4591
4592 return ret;
4593}
4594
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304595static int __iw_set_nick(struct net_device *dev,
4596 struct iw_request_info *info,
4597 union iwreq_data *wrqu, char *extra)
4598{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304599 hdd_adapter_t *pAdapter;
4600 hdd_context_t *pHddCtx;
4601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304602
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304603 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304604
4605 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4606 if (NULL == pAdapter)
4607 {
4608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4609 "%s: Adapter is NULL",__func__);
4610 return -EINVAL;
4611 }
4612
4613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4614 ret = wlan_hdd_validate_context(pHddCtx);
4615 if (0 != ret)
4616 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304617 return ret;
4618 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304619 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304620 return 0;
4621}
4622
Jeff Johnson295189b2012-06-20 16:38:30 -07004623static int iw_set_nick(struct net_device *dev,
4624 struct iw_request_info *info,
4625 union iwreq_data *wrqu, char *extra)
4626{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304627 int ret;
4628
4629 vos_ssr_protect(__func__);
4630 ret = __iw_set_nick(dev, info, wrqu, extra);
4631 vos_ssr_unprotect(__func__);
4632
4633 return ret;
4634}
4635
4636static int __iw_get_nick(struct net_device *dev,
4637 struct iw_request_info *info,
4638 union iwreq_data *wrqu, char *extra)
4639{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304640 hdd_adapter_t *pAdapter;
4641 hdd_context_t *pHddCtx;
4642 int ret = 0;
4643
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304645
4646 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4647 if (NULL == pAdapter)
4648 {
4649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4650 "%s: Adapter is NULL",__func__);
4651 return -EINVAL;
4652 }
4653
4654 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4655 ret = wlan_hdd_validate_context(pHddCtx);
4656 if (0 != ret)
4657 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304658 return ret;
4659 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304660 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 return 0;
4662}
4663
4664static int iw_get_nick(struct net_device *dev,
4665 struct iw_request_info *info,
4666 union iwreq_data *wrqu, char *extra)
4667{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304668 int ret;
4669
4670 vos_ssr_protect(__func__);
4671 ret = __iw_get_nick(dev, info, wrqu, extra);
4672 vos_ssr_unprotect(__func__);
4673
4674 return ret;
4675}
4676
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304677/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304678static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4679{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4681 hdd_context_t *pHddCtx;
4682 hdd_station_ctx_t *pHddStaCtx;
4683 v_S7_t snr = 0, rssi = 0;
4684 eHalStatus status = eHAL_STATUS_SUCCESS;
4685
4686 ENTER();
4687
4688 if (NULL == pAdapter)
4689 {
4690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4691 "%s: Adapter is NULL",__func__);
4692 return NULL;
4693 }
4694
4695 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4696 status = wlan_hdd_validate_context(pHddCtx);
4697 if (0 != status)
4698 {
4699 return NULL;
4700 }
4701
4702 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4703 if (NULL == pHddStaCtx)
4704 {
4705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4706 "%s: STA Context is NULL",__func__);
4707 return NULL;
4708 }
4709
4710 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4711 {
4712 wlan_hdd_get_station_stats(pAdapter);
4713 wlan_hdd_get_snr(pAdapter, &snr);
4714 wlan_hdd_get_rssi(pAdapter, &rssi);
4715
4716 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4717 pAdapter->iwStats.status = 0;
4718 pAdapter->iwStats.qual.qual = snr;
4719 pAdapter->iwStats.qual.level = rssi;
4720 pAdapter->iwStats.qual.noise = rssi - snr;
4721 pAdapter->iwStats.discard.code = 0;
4722 pAdapter->iwStats.discard.retries= 0;
4723 pAdapter->iwStats.miss.beacon = 0;
4724 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4725 }
4726 else
4727 {
4728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4729 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4730 return NULL;
4731 }
4732
4733 EXIT();
4734 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004735}
4736
4737static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4738{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304739
4740 struct iw_statistics *stats;
4741
4742 vos_ssr_protect(__func__);
4743 stats = __get_wireless_stats(dev);
4744 vos_ssr_unprotect(__func__);
4745
4746 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004747}
4748
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304749static int __iw_set_encode(struct net_device *dev,
4750 struct iw_request_info *info,
4751 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004752
4753{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304754 hdd_adapter_t *pAdapter;
4755 hdd_station_ctx_t *pHddStaCtx;
4756 hdd_wext_state_t *pWextState;
4757 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 struct iw_point *encoderq = &(wrqu->encoding);
4759 v_U32_t keyId;
4760 v_U8_t key_length;
4761 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4762 v_BOOL_t fKeyPresent = 0;
4763 int i;
4764 eHalStatus status = eHAL_STATUS_SUCCESS;
4765
4766
4767 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304768 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4769 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4772 "%s: Adapter is NULL",__func__);
4773 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 }
4775
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304776 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4777 status = wlan_hdd_validate_context(pHddCtx);
4778 if (0 != status)
4779 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304780 return status;
4781 }
4782 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4783 if (NULL == pWextState)
4784 {
4785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4786 "%s: pWextState is NULL ",__func__);
4787 return -EINVAL;
4788 }
4789 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4790 if (NULL == pHddStaCtx)
4791 {
4792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4793 "%s: STA Context is NULL",__func__);
4794 return -EINVAL;
4795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004796
4797 keyId = encoderq->flags & IW_ENCODE_INDEX;
4798
4799 if(keyId)
4800 {
4801 if(keyId > MAX_WEP_KEYS)
4802 {
4803 return -EINVAL;
4804 }
4805
4806 fKeyPresent = 1;
4807 keyId--;
4808 }
4809 else
4810 {
4811 fKeyPresent = 0;
4812 }
4813
4814
4815 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4816 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 if(!fKeyPresent) {
4819
4820 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4821
4822 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4823 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4824 }
4825 }
4826 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4827 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4828 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4829 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4830
4831 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4832 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4833
4834 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4835 {
4836 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4837 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004838 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304839 {
4840 long ret;
4841 ret = wait_for_completion_interruptible_timeout(
4842 &pAdapter->disconnect_comp_var,
4843 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4844 if (ret <= 0)
4845 hddLog(VOS_TRACE_LEVEL_ERROR,
4846 FL("failed wait on disconnect_comp_var %ld"), ret);
4847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
4849
4850 return status;
4851
4852 }
4853
4854 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4855 {
4856 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4857
4858 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4859
4860 }
4861
4862
4863 if(wrqu->data.length > 0)
4864 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004865 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004866
4867 key_length = wrqu->data.length;
4868
4869 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4870
4871 if(5 == key_length)
4872 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004873 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004874
4875 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4876 {
4877 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4878 }
4879 else
4880 {
4881 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4882 }
4883 }
4884 else if(13 == key_length)
4885 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004886 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,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_WEP104;
4891 }
4892 else
4893 {
4894 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4895 }
4896 }
4897 else
4898 {
4899 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004900 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 return -EINVAL;
4902 }
4903
4904 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4905 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4906 pWextState->roamProfile.EncryptionType.numEntries = 1;
4907 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4908 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4909 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4910
4911 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4912 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4913 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4914 {
4915
4916 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4917
4918 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4919 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4920
4921 return status;
4922 }
4923 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304924 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 return 0;
4926}
4927
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304928static int iw_set_encode(struct net_device *dev,
4929 struct iw_request_info *info,
4930 union iwreq_data *wrqu,char *extra)
4931{
4932 int ret;
4933
4934 vos_ssr_protect(__func__);
4935 ret = __iw_set_encode(dev, info, wrqu, extra);
4936 vos_ssr_unprotect(__func__);
4937
4938 return ret;
4939}
4940
4941static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 struct iw_request_info *info,
4943 struct iw_point *dwrq,
4944 char *extra)
4945{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304946 hdd_adapter_t *pAdapter;
4947 hdd_wext_state_t *pWextState;
4948 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 int keyId;
4950 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4951 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304952 int i, ret = 0;
4953 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004954
4955 ENTER();
4956
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304957 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4958 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004959 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4961 "%s: Adapter is NULL",__func__);
4962 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004963 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304964 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4965 ret = wlan_hdd_validate_context(pHddCtx);
4966 if (0 != ret)
4967 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304968 return ret;
4969 }
4970 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4971 if (NULL == pWextState)
4972 {
4973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4974 "%s: pWextState is NULL",__func__);
4975 return -EINVAL;
4976 }
4977 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004978
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 keyId = pRoamProfile->Keys.defaultIndex;
4980
4981 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4982 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004983 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 return -EINVAL;
4985 }
4986
4987 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4988 {
4989 dwrq->flags |= IW_ENCODE_ENABLED;
4990 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304991 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4992 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 }
4994 else
4995 {
4996 dwrq->flags |= IW_ENCODE_DISABLED;
4997 }
4998
4999 for(i=0; i < MAX_WEP_KEYS; i++)
5000 {
5001 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5002 {
5003 continue;
5004 }
5005 else
5006 {
5007 break;
5008 }
5009 }
5010
5011 if(MAX_WEP_KEYS == i)
5012 {
5013 dwrq->flags |= IW_ENCODE_NOKEY;
5014 }
5015 else
5016 {
5017 dwrq->flags |= IW_ENCODE_ENABLED;
5018 }
5019
5020 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5021
5022 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5023 {
5024 dwrq->flags |= IW_ENCODE_DISABLED;
5025 }
5026
5027 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5028
5029 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5030 {
5031 dwrq->flags |= IW_ENCODE_OPEN;
5032 }
5033 else
5034 {
5035 dwrq->flags |= IW_ENCODE_RESTRICTED;
5036 }
5037 EXIT();
5038 return 0;
5039
5040}
5041
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305042static int iw_get_encodeext(struct net_device *dev,
5043 struct iw_request_info *info,
5044 struct iw_point *dwrq,
5045 char *extra)
5046{
5047 int ret;
5048 vos_ssr_protect(__func__);
5049 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5050 vos_ssr_unprotect(__func__);
5051
5052 return ret;
5053}
5054
5055static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 struct iw_request_info *info,
5057 union iwreq_data *wrqu, char *extra)
5058{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305059 hdd_adapter_t *pAdapter;
5060 hdd_station_ctx_t *pHddStaCtx;
5061 hdd_wext_state_t *pWextState;
5062 hdd_context_t *pHddCtx;
5063 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005064
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305065 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 v_U32_t status = 0;
5067
5068 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5069
5070 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5071
5072 int key_index;
5073 struct iw_point *encoding = &wrqu->encoding;
5074 tCsrRoamSetKey setKey;
5075 v_U32_t roamId= 0xFF;
5076 VOS_STATUS vos_status;
5077
5078 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305079 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5080 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5083 "%s: Adapter is NULL",__func__);
5084 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305086 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5087 status = wlan_hdd_validate_context(pHddCtx);
5088 if (0 != status)
5089 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305090 return status;
5091 }
5092 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5093 if (NULL == pHddStaCtx)
5094 {
5095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5096 "%s: STA Context is NULL",__func__);
5097 return -EINVAL;
5098 }
5099 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5100 if (NULL == pWextState)
5101 {
5102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5103 "%s: pWextState is NULL",__func__);
5104 return -EINVAL;
5105 }
5106 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 key_index = encoding->flags & IW_ENCODE_INDEX;
5108
5109 if(key_index > 0) {
5110
5111 /*Convert from 1-based to 0-based keying*/
5112 key_index--;
5113 }
5114 if(!ext->key_len) {
5115
5116 /*Set the encrytion type to NONE*/
5117 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5118 return status;
5119 }
5120
5121 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5122 (IW_ENCODE_ALG_WEP == ext->alg))
5123 {
5124 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5125
Agarwal Ashish971c2882013-10-30 20:11:12 +05305126 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5127 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 return -EINVAL;
5129 }
5130 else {
5131 /*Static wep, update the roam profile with the keys */
5132 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5133 key_index < CSR_MAX_NUM_KEY) {
5134 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5135 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5136
5137 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5138 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5139
5140 }
5141 }
5142 return status;
5143 }
5144
5145 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5146
5147 setKey.keyId = key_index;
5148 setKey.keyLength = ext->key_len;
5149
5150 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5151 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5152 }
5153
5154 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5155 /*Key direction for group is RX only*/
5156 setKey.keyDirection = eSIR_RX_ONLY;
5157 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5158 }
5159 else {
5160
5161 setKey.keyDirection = eSIR_TX_RX;
5162 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5163 }
5164
5165 /*For supplicant pae role is zero*/
5166 setKey.paeRole = 0;
5167
5168 switch(ext->alg)
5169 {
5170 case IW_ENCODE_ALG_NONE:
5171 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5172 break;
5173
5174 case IW_ENCODE_ALG_WEP:
5175 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5176 break;
5177
5178 case IW_ENCODE_ALG_TKIP:
5179 {
5180 v_U8_t *pKey = &setKey.Key[0];
5181
5182 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5183
5184 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5185
5186 /*Supplicant sends the 32bytes key in this order
5187
5188 |--------------|----------|----------|
5189 | Tk1 |TX-MIC | RX Mic |
5190 |--------------|----------|----------|
5191 <---16bytes---><--8bytes--><--8bytes-->
5192
5193 */
5194 /*Sme expects the 32 bytes key to be in the below order
5195
5196 |--------------|----------|----------|
5197 | Tk1 |RX-MIC | TX Mic |
5198 |--------------|----------|----------|
5199 <---16bytes---><--8bytes--><--8bytes-->
5200 */
5201 /* Copy the Temporal Key 1 (TK1) */
5202 vos_mem_copy(pKey,ext->key,16);
5203
5204 /*Copy the rx mic first*/
5205 vos_mem_copy(&pKey[16],&ext->key[24],8);
5206
5207 /*Copy the tx mic */
5208 vos_mem_copy(&pKey[24],&ext->key[16],8);
5209
5210 }
5211 break;
5212
5213 case IW_ENCODE_ALG_CCMP:
5214 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5215 break;
5216
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005217#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005218#define IW_ENCODE_ALG_KRK 6
5219 case IW_ENCODE_ALG_KRK:
5220 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5221 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005222#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005223
5224 default:
5225 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5226 break;
5227 }
5228
5229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005230 ("%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 -07005231
5232#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305233 /* The supplicant may attempt to set the PTK once pre-authentication
5234 is done. Save the key in the UMAC and include it in the ADD
5235 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305237 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305239 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5240 "%s: Update PreAuth Key success", __func__);
5241 return 0;
5242 }
5243 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5244 {
5245 hddLog(VOS_TRACE_LEVEL_ERROR,
5246 "%s: Update PreAuth Key failed", __func__);
5247 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 }
5249#endif /* WLAN_FEATURE_VOWIFI_11R */
5250
5251 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5252
5253 vos_status = wlan_hdd_check_ula_done(pAdapter);
5254 if ( vos_status != VOS_STATUS_SUCCESS )
5255 {
5256 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5257 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5258 __LINE__, vos_status );
5259
5260 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5261 }
5262
5263 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5264
5265 if ( halStatus != eHAL_STATUS_SUCCESS )
5266 {
5267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5268 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5269 __LINE__, halStatus );
5270
5271 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5272 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305273 EXIT();
5274 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005275}
5276
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305277static int iw_set_encodeext(struct net_device *dev,
5278 struct iw_request_info *info,
5279 union iwreq_data *wrqu, char *extra)
5280{
5281 int ret;
5282
5283 vos_ssr_protect(__func__);
5284 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5285 vos_ssr_unprotect(__func__);
5286
5287 return ret;
5288}
5289
5290static int __iw_set_retry(struct net_device *dev,
5291 struct iw_request_info *info,
5292 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005293{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305294 hdd_adapter_t *pAdapter;
5295 tHalHandle hHal;
5296 hdd_context_t *pHddCtx;
5297 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005298
5299 ENTER();
5300
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305301 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5302 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005303 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5305 "%s: Adapter is NULL",__func__);
5306 return -EINVAL;
5307 }
5308
5309 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5310 ret = wlan_hdd_validate_context(pHddCtx);
5311 if (0 != ret)
5312 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305313 return ret;
5314 }
5315
5316 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5317 if (NULL == hHal)
5318 {
5319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5320 "%s: Hal Context is NULL",__func__);
5321 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005322 }
5323
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5325 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5326
Arif Hussain6d2a3322013-11-17 19:50:10 -08005327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005328
5329 return -EINVAL;
5330 }
5331
5332 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5333
5334 if((wrqu->retry.flags & IW_RETRY_LONG))
5335 {
5336 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5337 {
c_hpothub8245442013-11-20 23:41:09 +05305338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5339 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 return -EIO;
5341 }
5342 }
5343 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5344 {
5345 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5346 {
c_hpothub8245442013-11-20 23:41:09 +05305347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5348 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 return -EIO;
5350 }
5351 }
5352 }
5353 else
5354 {
5355 return -EOPNOTSUPP;
5356 }
5357
Arif Hussain6d2a3322013-11-17 19:50:10 -08005358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005359
5360 EXIT();
5361
5362 return 0;
5363
5364}
5365
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305366static int iw_set_retry(struct net_device *dev,
5367 struct iw_request_info *info,
5368 union iwreq_data *wrqu, char *extra)
5369{
5370 int ret;
5371
5372 vos_ssr_protect(__func__);
5373 ret = __iw_set_retry(dev, info, wrqu, extra);
5374 vos_ssr_unprotect(__func__);
5375
5376 return ret;
5377}
5378
5379static int __iw_get_retry(struct net_device *dev,
5380 struct iw_request_info *info,
5381 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005382{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305383 hdd_adapter_t *pAdapter;
5384 hdd_context_t *pHddCtx;
5385 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305387 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005388
5389 ENTER();
5390
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305391 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5392 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005393 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5395 "%s: Adapter is NULL",__func__);
5396 return -EINVAL;
5397 }
5398
5399 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5400 ret = wlan_hdd_validate_context(pHddCtx);
5401 if (0 != ret)
5402 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305403 return ret;
5404 }
5405
5406 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5407 if (NULL == hHal)
5408 {
5409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5410 "%s: Hal Context is NULL",__func__);
5411 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005412 }
5413
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 if((wrqu->retry.flags & IW_RETRY_LONG))
5415 {
5416 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5417
5418 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5419 {
c_hpothub8245442013-11-20 23:41:09 +05305420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5421 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 return -EIO;
5423 }
5424
5425 wrqu->retry.value = retry;
5426 }
5427 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5428 {
5429 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5430
5431 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_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_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 return -EIO;
5436 }
5437
5438 wrqu->retry.value = retry;
5439 }
5440 else {
5441 return -EOPNOTSUPP;
5442 }
5443
Arif Hussain6d2a3322013-11-17 19:50:10 -08005444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005445
5446 EXIT();
5447
5448 return 0;
5449}
5450
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305451static int iw_get_retry(struct net_device *dev,
5452 struct iw_request_info *info,
5453 union iwreq_data *wrqu, char *extra)
5454{
5455 int ret;
5456
5457 vos_ssr_protect(__func__);
5458 ret = __iw_get_retry(dev, info, wrqu, extra);
5459 vos_ssr_unprotect(__func__);
5460
5461 return ret;
5462}
5463
5464static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 struct iw_request_info *info,
5466 union iwreq_data *wrqu,
5467 char *extra)
5468{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305469 hdd_adapter_t *pAdapter;
5470 hdd_context_t *pHddCtx;
5471 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5473 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305474 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005475
5476 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305477 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5478 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5481 "%s:Adapter is NULL",__func__);
5482 return -EINVAL;
5483 }
5484 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5485 ret = wlan_hdd_validate_context(pHddCtx);
5486 if (0 != ret)
5487 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305488 return ret;
5489 }
5490 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5491 if (NULL == pHddStaCtx)
5492 {
5493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5494 "%s:STA context is NULL",__func__);
5495 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 }
5497
5498 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5499 switch (mlme->cmd) {
5500 case IW_MLME_DISASSOC:
5501 case IW_MLME_DEAUTH:
5502
5503 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5504 {
5505 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5506
5507 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5508 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5509
5510 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5511 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5512
Jeff Johnson43971f52012-07-17 12:26:56 -07005513 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305514 {
5515 long ret;
5516 ret = wait_for_completion_interruptible_timeout(
5517 &pAdapter->disconnect_comp_var,
5518 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5519 if (ret <= 0)
5520 hddLog(VOS_TRACE_LEVEL_ERROR,
5521 FL("failed wait on disconnect_comp_var %ld"), ret);
5522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005524 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005525 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005526
5527 /* Resetting authKeyMgmt */
5528 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5529
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305530 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 netif_tx_disable(dev);
5532 netif_carrier_off(dev);
5533
5534 }
5535 else
5536 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005537 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 -07005538 }
5539 break;
5540 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005541 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 return -EINVAL;
5543 }//end of switch
5544
5545 EXIT();
5546
5547 return status;
5548
5549}
5550
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305551static int iw_set_mlme(struct net_device *dev,
5552 struct iw_request_info *info,
5553 union iwreq_data *wrqu,
5554 char *extra)
5555{
5556 int ret;
5557
5558 vos_ssr_protect(__func__);
5559 ret = __iw_set_mlme(dev, info, wrqu, extra);
5560 vos_ssr_unprotect(__func__);
5561
5562 return ret;
5563}
5564
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305565int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305566{
5567 sHwCalValues hwCalValues;
5568 uint16 hwCalTxPower;
5569 uint8 txPwr = TX_PWR_DEF;
5570
5571 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5572
5573 if (TRUE == set_value) {
5574 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5575 NULL, sizeof(sHwCalValues) )
5576 != VOS_STATUS_SUCCESS) {
5577 return -EINVAL;
5578 }
5579 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5580
5581 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5582 hwCalTxPower, hwCalValues.calData.hwParam7);
5583
5584 txPwr = (int8)(hwCalTxPower & 0x00FF);
5585 txPwr = txPwr/10;
5586 if (txPwr < TX_PWR_MIN)
5587 txPwr = TX_PWR_MIN;
5588 if (txPwr > TX_PWR_MAX)
5589 txPwr = TX_PWR_MAX;
5590
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305591 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305592 eHAL_STATUS_SUCCESS) {
5593 hddLog(VOS_TRACE_LEVEL_ERROR,
5594 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5595 return -EIO;
5596 }
5597
5598 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5599 txPwr /= 10;
5600 if (txPwr < TX_PWR_MIN)
5601 txPwr = TX_PWR_MIN;
5602 if (txPwr > TX_PWR_MAX)
5603 txPwr = TX_PWR_MAX;
5604
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305605 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305606 eHAL_STATUS_SUCCESS) {
5607 hddLog(VOS_TRACE_LEVEL_ERROR,
5608 FL("setting tx power failed for 5GHz band %d"), txPwr);
5609 return -EIO;
5610 }
5611 }
5612 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305613 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305614 eHAL_STATUS_SUCCESS) {
5615 hddLog(VOS_TRACE_LEVEL_ERROR,
5616 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5617 return -EIO;
5618 }
5619
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305620 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305621 eHAL_STATUS_SUCCESS) {
5622 hddLog(VOS_TRACE_LEVEL_ERROR,
5623 FL("setting tx power failed for 5GHz band %d"), txPwr);
5624 return -EIO;
5625 }
5626 }
5627 else {
5628 return -EINVAL;
5629 }
5630
5631 return eHAL_STATUS_SUCCESS;
5632}
Jeff Johnson295189b2012-06-20 16:38:30 -07005633/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305634static int __iw_setint_getnone(struct net_device *dev,
5635 struct iw_request_info *info,
5636 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005637{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305638 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305639 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305640 hdd_wext_state_t *pWextState;
5641 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305642 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 int *value = (int *)extra;
5644 int sub_cmd = value[0];
5645 int set_value = value[1];
5646 int ret = 0; /* success */
5647 int enable_pbm, enable_mp;
5648#ifdef CONFIG_HAS_EARLYSUSPEND
5649 v_U8_t nEnableSuspendOld;
5650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305652 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305653 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5654 if (NULL == pAdapter)
5655 {
5656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5657 "%s: Adapter is NULL",__func__);
5658 return -EINVAL;
5659 }
5660 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5661 ret = wlan_hdd_validate_context(pHddCtx);
5662 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005663 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305664 return ret;
5665 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305666
Katya Nigameae74b62015-05-28 17:19:16 +05305667 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305668 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305669 /* In monitor mode hHal is NULL */
5670 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5671 if (NULL == hHal)
5672 {
5673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5674 "%s: Hal Context is NULL",__func__);
5675 return -EINVAL;
5676 }
Katya Nigameae74b62015-05-28 17:19:16 +05305677 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5678 if (NULL == pWextState)
5679 {
5680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5681 "%s: pWextState is NULL",__func__);
5682 return -EINVAL;
5683 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005684
Katya Nigameae74b62015-05-28 17:19:16 +05305685 INIT_COMPLETION(pWextState->completion_var);
5686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 switch(sub_cmd)
5688 {
5689 case WE_SET_11D_STATE:
5690 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005691 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005692 memset(&smeConfig, 0x00, sizeof(smeConfig));
5693
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305694 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5695 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 sme_GetConfigParam(hHal,&smeConfig);
5697 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5698
Arif Hussain6d2a3322013-11-17 19:50:10 -08005699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005700
5701 sme_UpdateConfig(hHal,&smeConfig);
5702 }
5703 else {
5704 return -EINVAL;
5705 }
5706 break;
5707 }
5708
5709 case WE_WOWL:
5710 {
5711 switch (set_value)
5712 {
5713 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305714 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 break;
5716 case 0x01:
5717 case 0x02:
5718 case 0x03:
5719 enable_mp = (set_value & 0x01) ? 1 : 0;
5720 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005721 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5723 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5724 break;
5725 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005726 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 ret = -EINVAL;
5728 break;
5729 }
5730
5731 break;
5732 }
5733 case WE_SET_POWER:
5734 {
5735 switch (set_value)
5736 {
5737 case 0: //Full Power
5738 {
5739 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305740 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005741
5742 init_completion(&context.completion);
5743
5744 context.pAdapter = pAdapter;
5745 context.magic = POWER_CONTEXT_MAGIC;
5746
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305747 if (NULL == hHal)
5748 return -EINVAL;
5749
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5751 iw_power_callback_fn, &context,
5752 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305753
Jeff Johnson72a40512013-12-19 10:14:15 -08005754 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 {
5756 int lrc = wait_for_completion_interruptible_timeout(
5757 &context.completion,
5758 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005759
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 if (lrc <= 0)
5761 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005762 hddLog(VOS_TRACE_LEVEL_ERROR,
5763 "%s: SME %s while requesting fullpower",
5764 __func__, (0 == lrc) ?
5765 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 }
5767 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005768 /* either we have a response or we timed out. if we timed
5769 out there is a race condition such that the callback
5770 function could be executing at the same time we are. of
5771 primary concern is if the callback function had already
5772 verified the "magic" but had not yet set the completion
5773 variable when a timeout occurred. we serialize these
5774 activities by invalidating the magic while holding a
5775 shared spinlock which will cause us to block if the
5776 callback is currently executing */
5777 spin_lock(&hdd_context_lock);
5778 context.magic = 0;
5779 spin_unlock(&hdd_context_lock);
5780
Arif Hussain6d2a3322013-11-17 19:50:10 -08005781 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 break;
5783 }
5784 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305785 if (hHal)
5786 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5787 else
5788 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 break;
5790 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305791 if (hHal)
5792 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5793 else
5794 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 break;
5796 case 3: //Request Bmps
5797 {
5798 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305799 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005800
5801 init_completion(&context.completion);
5802
5803 context.pAdapter = pAdapter;
5804 context.magic = POWER_CONTEXT_MAGIC;
5805
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305806 if (NULL == hHal)
5807 return -EINVAL;
5808
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305810 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005811 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 {
5813 int lrc = wait_for_completion_interruptible_timeout(
5814 &context.completion,
5815 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 if (lrc <= 0)
5817 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005818 hddLog(VOS_TRACE_LEVEL_ERROR,
5819 "%s: SME %s while requesting BMPS",
5820 __func__, (0 == lrc) ? "timeout" :
5821 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 }
5823 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005824 /* either we have a response or we timed out. if we
5825 timed out there is a race condition such that the
5826 callback function could be executing at the same
5827 time we are. of primary concern is if the callback
5828 function had already verified the "magic" but had
5829 not yet set the completion variable when a timeout
5830 occurred. we serialize these activities by
5831 invalidating the magic while holding a shared
5832 spinlock which will cause us to block if the
5833 callback is currently executing */
5834 spin_lock(&hdd_context_lock);
5835 context.magic = 0;
5836 spin_unlock(&hdd_context_lock);
5837
Arif Hussain6d2a3322013-11-17 19:50:10 -08005838 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 break;
5840 }
5841 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305842 if (hHal)
5843 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5844 else
5845 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 break;
5847 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305848 if (hHal)
5849 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5850 else
5851 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 break;
5853 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305854 if (hHal)
5855 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5856 else
5857 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 break;
5859 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305860 if (hHal)
5861 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5862 else
5863 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 break;
5865 case 8: //Request Standby
5866#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005867#endif
5868 break;
5869 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305870 if (hHal)
5871 sme_StartAutoBmpsTimer(hHal);
5872 else
5873 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 break;
5875 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305876 if (hHal)
5877 sme_StopAutoBmpsTimer(hHal);
5878 else
5879 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 break;
5881#ifdef CONFIG_HAS_EARLYSUSPEND
5882 case 11://suspend to standby
5883#ifdef CONFIG_HAS_EARLYSUSPEND
5884 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5885 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5887#endif
5888 break;
5889 case 12://suspend to deep sleep
5890#ifdef CONFIG_HAS_EARLYSUSPEND
5891 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5892 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5894#endif
5895 break;
5896 case 13://resume from suspend
5897#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005898#endif
5899 break;
5900#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005902 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 ret = -EINVAL;
5904 break;
5905 }
5906 break;
5907 }
5908
5909 case WE_SET_MAX_ASSOC:
5910 {
5911 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305912 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5913 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 {
5915 ret = -EINVAL;
5916 }
5917 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5918 set_value, NULL, eANI_BOOLEAN_FALSE)
5919 != eHAL_STATUS_SUCCESS )
5920 {
c_hpothub8245442013-11-20 23:41:09 +05305921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5922 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 ret = -EIO;
5924 }
5925 break;
5926 }
5927
5928 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5929 {
5930 if( 0 == set_value )
5931 {
5932 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5933 }
5934 else if ( 1 == set_value )
5935 {
5936 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5937 }
5938 else
5939 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005940 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 ret = -EINVAL;
5942 }
5943 break;
5944 }
5945
5946 case WE_SET_DATA_INACTIVITY_TO:
5947 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305948 if (NULL == hHal)
5949 return -EINVAL;
5950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5952 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5953 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5954 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5955 set_value,
5956 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5957 {
5958 hddLog(LOGE,"Failure: Could not pass on "
5959 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005960 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 ret = -EINVAL;
5962 }
5963 break;
5964 }
5965 case WE_SET_MAX_TX_POWER:
5966 {
5967 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5968 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5969
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305970 if (NULL == hHal)
5971 return -EINVAL;
5972
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5974 __func__, set_value);
5975 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5976 eHAL_STATUS_SUCCESS )
5977 {
5978 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5979 __func__);
5980 return -EIO;
5981 }
5982
5983 break;
5984 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005985 case WE_SET_MAX_TX_POWER_2_4:
5986 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305987 if (NULL == hHal)
5988 return -EINVAL;
5989
Arif Hussaina5ebce02013-08-09 15:09:58 -07005990 hddLog(VOS_TRACE_LEVEL_INFO,
5991 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5992 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305993 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005994 eHAL_STATUS_SUCCESS)
5995 {
5996 hddLog(VOS_TRACE_LEVEL_ERROR,
5997 "%s: Setting maximum tx power failed for 2.4 GHz band",
5998 __func__);
5999 return -EIO;
6000 }
6001
6002 break;
6003 }
6004 case WE_SET_MAX_TX_POWER_5_0:
6005 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306006 if (NULL == hHal)
6007 return -EINVAL;
6008
Arif Hussaina5ebce02013-08-09 15:09:58 -07006009 hddLog(VOS_TRACE_LEVEL_INFO,
6010 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6011 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306012 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006013 eHAL_STATUS_SUCCESS)
6014 {
6015 hddLog(VOS_TRACE_LEVEL_ERROR,
6016 "%s: Setting maximum tx power failed for 5.0 GHz band",
6017 __func__);
6018 return -EIO;
6019 }
6020
6021 break;
6022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 case WE_SET_HIGHER_DTIM_TRANSITION:
6024 {
6025 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6026 (set_value == eANI_BOOLEAN_TRUE)))
6027 {
6028 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6029 ret = -EINVAL;
6030 }
6031 else
6032 {
6033 if(pAdapter->higherDtimTransition != set_value)
6034 {
6035 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006036 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 }
6038 }
6039
6040 break;
6041 }
6042
6043 case WE_SET_TM_LEVEL:
6044 {
6045 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006046 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6048
6049 break;
6050 }
6051
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306052 case WE_ENABLE_STRICT_FCC_REG:
6053 {
6054 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6055 struct wiphy *wiphy = NULL;
6056 long lrc;
6057 int status;
6058
6059 wiphy = hddCtxt->wiphy;
6060 if(wiphy == NULL)
6061 {
6062 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6063 break;
6064 }
6065 init_completion(&hddCtxt->wiphy_channel_update_event);
6066
6067 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6068
6069 status = regulatory_hint(wiphy, "00");
6070 if(status < 0)
6071 {
6072 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6073 break;
6074 }
6075
6076 /* Wait for completion */
6077 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6078 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6079 if (lrc <= 0)
6080 {
6081 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6082 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6083 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6084 }
6085 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6086
6087 break;
6088 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006089 case WE_SET_DEBUG_LOG:
6090 {
6091 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6092 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306093 if (hHal)
6094 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6095 else
6096 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006097 break;
6098 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306099#ifdef FEATURE_WLAN_TDLS
6100 case WE_SET_TDLS_OFF_CHAN:
6101 {
6102 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6104 __func__, set_value);
6105 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6106 break;
6107 }
6108 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6109 {
6110 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6112 __func__, set_value);
6113 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6114 break;
6115 }
6116 case WE_SET_TDLS_OFF_CHAN_MODE:
6117 {
6118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6119 __func__, set_value);
6120 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6121 break;
6122 }
6123#endif
Peng Xu2446a892014-09-05 17:21:18 +05306124 case WE_SET_SCAN_BAND_PREFERENCE:
6125 {
6126 tSmeConfigParams smeConfig;
6127 memset(&smeConfig, 0x00, sizeof(smeConfig));
6128 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6129 ret = -EINVAL;
6130 break;
6131 }
6132 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6133
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306134 if ((eCSR_BAND_ALL == set_value ||
6135 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6136 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306137 sme_GetConfigParam(hHal, &smeConfig);
6138 smeConfig.csrConfig.scanBandPreference = set_value;
6139
6140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6141 "set band scan preference = %d\n",
6142 smeConfig.csrConfig.scanBandPreference);
6143
6144 sme_UpdateConfig(hHal, &smeConfig);
6145 }
6146 else {
6147 ret = -EINVAL;
6148 }
6149 break;
6150 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306151 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6152 * connection happens so that the params can take effect during
6153 * association. Also this should not be used in STA+p2p concurrency
6154 * as the param will also effect the STA mode.
6155 */
6156 case WE_SET_MIRACAST_VENDOR_CONFIG:
6157 {
6158 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306159
Abhishek Singh01c73d12015-03-12 15:13:44 +05306160 hddLog(LOG1, FL(
6161 "Set Miracast vendor tuning %d"), set_value);
6162
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306163 if (NULL == hHal)
6164 return -EINVAL;
6165
Abhishek Singh01c73d12015-03-12 15:13:44 +05306166 if (1 == set_value || 0 == set_value)
6167 {
6168 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6169 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6170 {
6171 hddLog( LOGE, FL("set vendor miracast config failed"));
6172 ret = -EIO;
6173 }
6174 }
6175 else
6176 {
6177 hddLog(LOGE,
6178 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6179 ret = -EINVAL;
6180 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306181 break;
6182 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306183
6184 case WE_GET_FRAME_LOG:
6185 {
6186 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6187 != VOS_STATUS_SUCCESS)
6188 {
6189 ret = -EINVAL;
6190 }
6191 break;
6192 }
6193
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306194 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6195 {
6196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6197 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306198 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306199 {
6200 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6201 set_value);
6202 }
6203 else
6204 ret = -EINVAL;
6205
6206 break;
6207 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306208 /* Bit mask value to enable RTS/CTS for different modes
6209 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6210 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6211 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6212 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6213 * for 5 GHz, VHT80 - 0x1000
6214 */
6215 case WE_SET_RTS_CTS_HTVHT:
6216 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306217
Abhishek Singh41988ba2015-05-25 19:42:29 +05306218 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6219
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306220 if (NULL == hHal)
6221 return -EINVAL;
6222
Abhishek Singh41988ba2015-05-25 19:42:29 +05306223 if (eHAL_STATUS_SUCCESS !=
6224 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6225 {
6226 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6227 ret = -EINVAL;
6228 }
6229 break;
6230 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306231 case WE_SET_MONITOR_STATE:
6232 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306233 v_U32_t magic = 0;
6234 struct completion cmpVar;
6235 long waitRet = 0;
6236 tVOS_CON_MODE mode = hdd_get_conparam();
6237
6238 if( VOS_MONITOR_MODE != mode)
6239 {
6240 hddLog(LOGE, "invalid mode %d", mode);
6241 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306242 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306243 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306244
6245 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6246 if( pMonCtx == NULL )
6247 {
6248 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306249 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306250 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306251 }
6252 if (pMonCtx->state == set_value)
6253 {
6254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6255 FL("already in same mode curr_mode:%d req_mode: %d"),
6256 pMonCtx->state, set_value);
6257 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306258 }
6259 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306260 magic = MON_MODE_MSG_MAGIC;
6261 init_completion(&cmpVar);
6262 if (VOS_STATUS_SUCCESS !=
6263 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6264 pMonCtx, hdd_monPostMsgCb)) {
6265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6266 FL("failed to post MON MODE REQ"));
6267 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6268 MON_MODE_STOP : MON_MODE_START;
6269 magic = 0;
6270 ret = -EIO;
6271 break;
6272 }
6273 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6274 magic = 0;
6275 if (waitRet <= 0 ){
6276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6277 FL("failed to wait on monitor mode completion %ld"),
6278 waitRet);
6279 }
6280 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306281 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306282 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6283 {
6284 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6285 tAniWifiStartLog start_log;
6286 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6287 !vos_isPktStatsEnabled())
6288 {
6289 hddLog(LOGE, FL("per pkt stats not enabled"));
6290 return -EINVAL;
6291 }
6292 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6293
6294 if (1 == set_value || 0 == set_value)
6295 {
6296 start_log.ringId = RING_ID_PER_PACKET_STATS;
6297 start_log.flag = 0;
6298 if (set_value)
6299 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6300 else
6301 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6302
6303 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6304 }
6305 else
6306 {
6307 hddLog(LOGE,
6308 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6309 set_value);
6310 ret = -EINVAL;
6311 }
6312 break;
6313 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306314 case WE_SET_PROXIMITY_ENABLE:
6315 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306316 if (NULL == hHal)
6317 return -EINVAL;
6318
6319 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306320 break;
6321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 default:
6323 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006324 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 sub_cmd, set_value);
6326 break;
6327 }
6328 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306329 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 return ret;
6331}
6332
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306333static int iw_setint_getnone(struct net_device *dev,
6334 struct iw_request_info *info,
6335 union iwreq_data *wrqu, char *extra)
6336{
6337 int ret;
6338
6339 vos_ssr_protect(__func__);
6340 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6341 vos_ssr_unprotect(__func__);
6342
6343 return 0;
6344}
Jeff Johnson295189b2012-06-20 16:38:30 -07006345/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306346static int __iw_setchar_getnone(struct net_device *dev,
6347 struct iw_request_info *info,
6348 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006349{
6350 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306351 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006353 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306354 hdd_adapter_t *pAdapter;
6355 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006356#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306357 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006358#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306359 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306360 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306362 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306363
6364 if (!capable(CAP_NET_ADMIN))
6365 {
6366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6367 FL("permission check failed"));
6368 return -EPERM;
6369 }
6370
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306371 pAdapter = (netdev_priv(dev));
6372 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006373 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6375 "%s: Adapter is NULL",__func__);
6376 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006377 }
6378
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306379 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6380 ret = wlan_hdd_validate_context(pHddCtx);
6381 if (0 != ret)
6382 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306383 return ret;
6384 }
6385#ifdef WLAN_FEATURE_VOWIFI
6386 pConfig = pHddCtx->cfg_ini;
6387#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306388 /* helper function to get iwreq_data with compat handling. */
6389 if (hdd_priv_get_data(&s_priv_data, wrqu))
6390 {
6391 return -EINVAL;
6392 }
6393
6394 /* make sure all params are correctly passed to function */
6395 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6396 {
6397 return -EINVAL;
6398 }
6399
6400 sub_cmd = s_priv_data.flags;
6401
Arif Hussain0273cba2014-01-07 20:58:29 -08006402 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306403 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6404 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006405 if (NULL == pBuffer)
6406 {
6407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6408 "mem_alloc_copy_from_user_helper fail");
6409 return -ENOMEM;
6410 }
6411
6412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306413 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6415 "%s: Received data %s", __func__, pBuffer);
6416
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 switch(sub_cmd)
6418 {
6419 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006421 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 break;
6423 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006425 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 break;
6427#if defined WLAN_FEATURE_VOWIFI
6428 case WE_NEIGHBOR_REPORT_REQUEST:
6429 {
6430 tRrmNeighborReq neighborReq;
6431 tRrmNeighborRspCallbackInfo callbackInfo;
6432
6433 if (pConfig->fRrmEnable)
6434 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306436 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 if( !neighborReq.no_ssid )
6438 {
Girish Gowli552fc072014-06-14 18:26:16 +05306439 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006440 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 }
6442
6443 callbackInfo.neighborRspCallback = NULL;
6444 callbackInfo.neighborRspCallbackContext = NULL;
6445 callbackInfo.timeout = 5000; //5 seconds
6446 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6447 }
6448 else
6449 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006450 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 ret = -EINVAL;
6452 }
6453 }
6454 break;
6455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 case WE_SET_AP_WPS_IE:
6457 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306458 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006461 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 if (VOS_STATUS_SUCCESS != vstatus)
6463 {
6464 ret = -EINVAL;
6465 }
6466 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306467 case WE_SET_ENCRYPT_MSG:
6468 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6469 if (NULL == pkt)
6470 {
6471 hddLog(VOS_TRACE_LEVEL_ERROR,
6472 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306473 ret = -ENOMEM;
6474 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306475 }
6476
6477 memset(pkt, 0, sizeof(tSirpkt80211));
6478
6479 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6480 hddLog(VOS_TRACE_LEVEL_ERROR,
6481 FL("Firmware is not DISA capable"));
6482 ret = -EINVAL;
6483 vos_mem_free(pkt);
6484 break;
6485 }
6486
6487 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6488
6489 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6490 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6491 if (eHAL_STATUS_SUCCESS != ret) {
6492 hddLog(VOS_TRACE_LEVEL_ERROR,
6493 FL("SENDEncryptMSG: fail to post WDA cmd"));
6494 ret = -EINVAL;
6495 }
6496 vos_mem_free(pkt);
6497
6498 break;
6499
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 default:
6501 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006502 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 ret = -EINVAL;
6504 break;
6505 }
6506 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006507 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306508
6509 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 return ret;
6511}
6512
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306513static int iw_setchar_getnone(struct net_device *dev,
6514 struct iw_request_info *info,
6515 union iwreq_data *wrqu, char *extra)
6516{
6517 int ret;
6518
6519 vos_ssr_protect(__func__);
6520 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6521 vos_ssr_unprotect(__func__);
6522
6523 return ret;
6524}
6525
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306526static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6527{
6528 struct statsContext *context;
6529 hdd_adapter_t *pAdapter;
6530
6531 if (NULL == pContext)
6532 {
6533 hddLog(VOS_TRACE_LEVEL_ERROR,
6534 "%s: Bad param, pContext [%p]",
6535 __func__, pContext);
6536 return;
6537 }
6538
6539 context = pContext;
6540 pAdapter = context->pAdapter;
6541
6542 spin_lock(&hdd_context_lock);
6543
6544 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6545 {
6546 /* the caller presumably timed out so there is nothing we can do */
6547 spin_unlock(&hdd_context_lock);
6548 hddLog(VOS_TRACE_LEVEL_WARN,
6549 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6550 __func__, pAdapter, context->magic);
6551 return;
6552 }
6553
6554 context->magic = 0;
6555 pAdapter->antennaIndex = antennaId;
6556
6557 complete(&context->completion);
6558 spin_unlock(&hdd_context_lock);
6559}
6560
6561static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6562 int *antennaIndex)
6563{
6564 hdd_context_t *pHddCtx;
6565 eHalStatus halStatus;
6566 struct statsContext context;
6567 long lrc;
6568
6569 ENTER();
6570 if (NULL == pAdapter)
6571 {
6572 hddLog(VOS_TRACE_LEVEL_WARN,
6573 "%s: Invalid context, pAdapter", __func__);
6574 return VOS_STATUS_E_FAULT;
6575 }
6576 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6577 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6578 {
6579 return VOS_STATUS_E_FAULT;
6580 }
6581 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6582 {
6583 hddLog(VOS_TRACE_LEVEL_ERROR,
6584 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6585 __func__);
6586 return VOS_STATUS_E_NOSUPPORT;
6587 }
6588 init_completion(&context.completion);
6589 context.pAdapter = pAdapter;
6590 context.magic = ANTENNA_CONTEXT_MAGIC;
6591
6592 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6593 hdd_GetCurrentAntennaIndex,
6594 &context, pAdapter->sessionId);
6595 if (eHAL_STATUS_SUCCESS != halStatus)
6596 {
6597 spin_lock(&hdd_context_lock);
6598 context.magic = 0;
6599 spin_unlock(&hdd_context_lock);
6600 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6601 __func__);
6602 /* we'll returned a cached value below */
6603 *antennaIndex = -1;
6604 return VOS_STATUS_E_FAILURE;
6605 }
6606 else
6607 {
6608 /* request was sent -- wait for the response */
6609 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6610 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6611 if (lrc <= 0)
6612 {
6613 spin_lock(&hdd_context_lock);
6614 context.magic = 0;
6615 spin_unlock(&hdd_context_lock);
6616 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6617 " Index",
6618 __func__, (0 == lrc) ? "timeout" : "interrupt");
6619 *antennaIndex = -1;
6620 return VOS_STATUS_E_FAILURE;
6621 }
6622 }
6623 spin_lock(&hdd_context_lock);
6624 context.magic = 0;
6625 spin_unlock(&hdd_context_lock);
6626
6627 *antennaIndex = pAdapter->antennaIndex;
6628
6629 EXIT();
6630 return VOS_STATUS_SUCCESS;
6631}
6632
Jeff Johnson295189b2012-06-20 16:38:30 -07006633/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306634static int __iw_setnone_getint(struct net_device *dev,
6635 struct iw_request_info *info,
6636 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006637{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306638 hdd_adapter_t *pAdapter;
6639 tHalHandle hHal;
6640 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 int *value = (int *)extra;
6642 int ret = 0; /* success */
6643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306644 ENTER();
6645
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306646 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6647 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006648 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6650 "%s: Adapter is NULL",__func__);
6651 return -EINVAL;
6652 }
6653 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6654 ret = wlan_hdd_validate_context(pHddCtx);
6655 if (0 != ret)
6656 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306657 return ret;
6658 }
6659 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6660 if (NULL == hHal)
6661 {
6662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6663 "%s: Hal Context is NULL",__func__);
6664 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006666
6667 switch (value[0])
6668 {
6669 case WE_GET_11D_STATE:
6670 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006671 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306673
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6675
Arif Hussain6d2a3322013-11-17 19:50:10 -08006676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006677
6678 break;
6679 }
6680
6681 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 break;
6684
6685 case WE_PMC_STATE:
6686 {
6687 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 break;
6690 }
6691 case WE_GET_WLAN_DBG:
6692 {
6693 vos_trace_display();
6694 *value = 0;
6695 break;
6696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 case WE_GET_MAX_ASSOC:
6698 {
6699 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6700 {
c_hpothub8245442013-11-20 23:41:09 +05306701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6702 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 ret = -EIO;
6704 }
Girish Gowli385be612014-09-18 11:17:20 +05306705#ifdef WLAN_SOFTAP_VSTA_FEATURE
6706 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6707 {
6708 if (*value > VSTA_NUM_ASSOC_STA)
6709 {
6710 *value = VSTA_NUM_ASSOC_STA;
6711 }
6712 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6713 (*value > (VSTA_NUM_ASSOC_STA -
6714 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6715 {
6716 *value = (VSTA_NUM_ASSOC_STA -
6717 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6718 }
6719 }
6720 else
6721#endif
6722 {
6723 if (*value > NUM_ASSOC_STA)
6724 {
6725 *value = NUM_ASSOC_STA;
6726 }
6727 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6728 (*value > (NUM_ASSOC_STA -
6729 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6730 {
6731 *value = (NUM_ASSOC_STA -
6732 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6733 }
6734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 break;
6736 }
6737
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 case WE_GET_WDI_DBG:
6739 {
6740 wpalTraceDisplay();
6741 *value = 0;
6742 break;
6743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006744
6745 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6746 {
6747 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6748 break;
6749 }
6750 case WE_GET_CONCURRENCY_MODE:
6751 {
6752 *value = hdd_get_concurrency_mode ( );
6753
Arif Hussain6d2a3322013-11-17 19:50:10 -08006754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 break;
6756 }
6757
Peng Xu2446a892014-09-05 17:21:18 +05306758 case WE_GET_SCAN_BAND_PREFERENCE:
6759 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306760 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306761 sme_GetConfigParam(hHal, &smeConfig);
6762 *value = smeConfig.csrConfig.scanBandPreference;
6763
6764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6765 "scanBandPreference = %d\n", *value);
6766 break;
6767 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306768 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6769 {
6770 wlan_hdd_get_current_antenna_index(pAdapter, value);
6771 break;
6772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 default:
6774 {
6775 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6776 break;
6777 }
6778 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306779 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 return ret;
6781}
6782
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306783static int iw_setnone_getint(struct net_device *dev,
6784 struct iw_request_info *info,
6785 union iwreq_data *wrqu, char *extra)
6786{
6787 int ret;
6788
6789 vos_ssr_protect(__func__);
6790 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6791 vos_ssr_unprotect(__func__);
6792
6793 return ret;
6794
6795}
Jeff Johnson295189b2012-06-20 16:38:30 -07006796/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306797int __iw_set_three_ints_getnone(struct net_device *dev,
6798 struct iw_request_info *info,
6799 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006800{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306801 hdd_adapter_t *pAdapter;
6802 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 int *value = (int *)extra;
6804 int sub_cmd = value[0];
6805 int ret = 0;
6806
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306807 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306808
6809 if (!capable(CAP_NET_ADMIN))
6810 {
6811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6812 FL("permission check failed"));
6813 return -EPERM;
6814 }
6815
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306816 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6817 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006818 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6820 "%s: Adapter is NULL",__func__);
6821 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006822 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306823 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6824 ret = wlan_hdd_validate_context(pHddCtx);
6825 if (0 != ret)
6826 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306827 return ret;
6828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 switch(sub_cmd)
6830 {
6831 case WE_SET_WLAN_DBG:
6832 {
6833 vos_trace_setValue( value[1], value[2], value[3]);
6834 break;
6835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 case WE_SET_WDI_DBG:
6837 {
6838 wpalTraceSetLevel( value[1], value[2], value[3]);
6839 break;
6840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 case WE_SET_SAP_CHANNELS:
6842 {
6843 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6844 break;
6845 }
6846
6847 default:
6848 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006849 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 break;
6851 }
6852 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306853 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 return ret;
6855}
6856
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306857int iw_set_three_ints_getnone(struct net_device *dev,
6858 struct iw_request_info *info,
6859 union iwreq_data *wrqu, char *extra)
6860{
6861 int ret;
6862
6863 vos_ssr_protect(__func__);
6864 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6865 vos_ssr_unprotect(__func__);
6866
6867 return ret;
6868}
6869
6870static int __iw_get_char_setnone(struct net_device *dev,
6871 struct iw_request_info *info,
6872 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006873{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306874 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306876 hdd_context_t *pHddCtx;
6877 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006878#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006879 hdd_wext_state_t *pWextState;
6880#endif
6881
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306882 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306883 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006884 if (pAdapter == NULL)
6885 {
6886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6887 "%s: pAdapter is NULL!", __func__);
6888 return -EINVAL;
6889 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306890 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6891 ret = wlan_hdd_validate_context(pHddCtx);
6892 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006893 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306894 return ret;
6895 }
6896#ifdef WLAN_FEATURE_11W
6897 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6898 if (NULL == pWextState)
6899 {
6900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6901 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006902 return -EINVAL;
6903 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306904#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006905
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 switch(sub_cmd)
6907 {
6908 case WE_WLAN_VERSION:
6909 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006910 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 break;
6912 }
6913
6914 case WE_GET_STATS:
6915 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306916 tHalHandle hHal = NULL;
6917 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6919 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6920 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6921
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306922
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 snprintf(extra, WE_MAX_STR_LEN,
6924 "\nTransmit"
6925 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6926 "\n dropped BK %u, BE %u, VI %u, VO %u"
6927 "\n classified BK %u, BE %u, VI %u, VO %u"
6928 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6929 "\n queued BK %u, BE %u, VI %u, VO %u"
6930 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006931 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 "\n fetched BK %u, BE %u, VI %u, VO %u"
6933 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6934 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006935 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 "\n flushed BK %u, BE %u, VI %u, VO %u"
6937 "\n\nReceive"
6938 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6939 "\n\nResetsStats"
6940 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6941 "\n",
6942 pStats->txXmitCalled,
6943 pStats->txXmitDropped,
6944 pStats->txXmitBackPressured,
6945 pStats->txXmitQueued,
6946
6947 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6948 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6949 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6950 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6951
6952 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6953 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6954 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6955 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6956
6957 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6958 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6959 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6960 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6961
6962 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6963 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6964 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6965 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6966
6967 pStats->txFetched,
6968 pStats->txFetchEmpty,
6969 pStats->txFetchLowResources,
6970 pStats->txFetchDequeueError,
6971
6972 pStats->txFetchDequeued,
6973 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006974 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 pStats->txCompleted,
6976 pStats->txFlushed,
6977
6978 pStats->txFetchedAC[WLANTL_AC_BK],
6979 pStats->txFetchedAC[WLANTL_AC_BE],
6980 pStats->txFetchedAC[WLANTL_AC_VI],
6981 pStats->txFetchedAC[WLANTL_AC_VO],
6982
6983 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6984 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6985 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6986 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6987
6988 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6989 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6990 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6991 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6992
Ravi Joshi41914632013-10-21 23:02:21 -07006993 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6994 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6995 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6996 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6997
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 pStats->txFlushedAC[WLANTL_AC_BK],
6999 pStats->txFlushedAC[WLANTL_AC_BE],
7000 pStats->txFlushedAC[WLANTL_AC_VI],
7001 pStats->txFlushedAC[WLANTL_AC_VO],
7002
7003 pStats->rxChains,
7004 pStats->rxPackets,
7005 pStats->rxDropped,
7006 pStats->rxDelivered,
7007 pStats->rxRefused,
7008
7009 pResetStats->totalLogpResets,
7010 pResetStats->totalCMD53Failures,
7011 pResetStats->totalMutexReadFailures,
7012 pResetStats->totalMIFErrorFailures,
7013 pResetStats->totalFWHearbeatFailures,
7014 pResetStats->totalUnknownExceptions
7015 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307016 wrqu->data.length = strlen(extra);
7017
7018 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7019
7020 if (hHal)
7021 pMac = PMAC_STRUCT( hHal );
7022
7023 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7024 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7025 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307026 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7027 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7028 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7029 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307030 "\n",
7031 pMac->pmm.BmpscntSleep,
7032 pMac->pmm.BmpscntAwake,
7033 pMac->pmm.BmpsSleeReqFailCnt,
7034 pMac->pmm.BmpsWakeupReqFailCnt,
7035 pMac->pmm.ImpsCntSleep,
7036 pMac->pmm.ImpsCntAwake,
7037 pMac->pmm.ImpsSleepErrCnt,
7038 pMac->pmm.ImpsWakeupErrCnt,
7039 pMac->pmm.ImpsLastErr
7040 );
7041 }
7042
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 wrqu->data.length = strlen(extra)+1;
7044 break;
7045 }
7046
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307047/* The case prints the current state of the HDD, SME, CSR, PE, TL
7048 *it can be extended for WDI Global State as well.
7049 *And currently it only checks P2P_CLIENT adapter.
7050 *P2P_DEVICE and P2P_GO have not been added as of now.
7051*/
7052 case WE_GET_STATES:
7053 {
7054 int buf = 0, len = 0;
7055 int adapter_num = 0;
7056 int count = 0, check = 1;
7057
7058 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007059 tHalHandle hHal = NULL;
7060 tpAniSirGlobal pMac = NULL;
7061 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307062
7063 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7064 hdd_adapter_t *useAdapter = NULL;
7065
7066 /* Print wlan0 or p2p0 states based on the adapter_num
7067 *by using the correct adapter
7068 */
7069 while ( adapter_num < 2 )
7070 {
7071 if ( WLAN_ADAPTER == adapter_num )
7072 {
7073 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007074 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307075 "\n\n wlan0 States:-");
7076 len += buf;
7077 }
7078 else if ( P2P_ADAPTER == adapter_num )
7079 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007080 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307081 "\n\n p2p0 States:-");
7082 len += buf;
7083
7084 if( !pHddCtx )
7085 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007086 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307087 "\n pHddCtx is NULL");
7088 len += buf;
7089 break;
7090 }
7091
7092 /*Printing p2p0 states only in the case when the device is
7093 configured as a p2p_client*/
7094 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7095 if ( !useAdapter )
7096 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007097 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307098 "\n Device not configured as P2P_CLIENT.");
7099 len += buf;
7100 break;
7101 }
7102 }
7103
7104 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007105 if (!hHal) {
7106 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7107 "\n pMac is NULL");
7108 len += buf;
7109 break;
7110 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307111 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007112 if (!pMac) {
7113 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7114 "\n pMac is NULL");
7115 len += buf;
7116 break;
7117 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307118 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7119 if( !pHddStaCtx )
7120 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007121 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307122 "\n pHddStaCtx is NULL");
7123 len += buf;
7124 break;
7125 }
7126
7127 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7128
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007129 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307130 "\n HDD Conn State - %s "
7131 "\n \n SME State:"
7132 "\n Neighbour Roam State - %s"
7133 "\n CSR State - %s"
7134 "\n CSR Substate - %s"
7135 "\n \n TL STA %d State: %s",
7136 macTraceGetHDDWlanConnState(
7137 pHddStaCtx->conn_info.connState),
7138 macTraceGetNeighbourRoamState(
7139 pMac->roam.neighborRoamInfo.neighborRoamState),
7140 macTraceGetcsrRoamState(
7141 pMac->roam.curState[useAdapter->sessionId]),
7142 macTraceGetcsrRoamSubState(
7143 pMac->roam.curSubState[useAdapter->sessionId]),
7144 pHddStaCtx->conn_info.staId[0],
7145 macTraceGetTLState(tlState)
7146 );
7147 len += buf;
7148 adapter_num++;
7149 }
7150
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007151 if (pMac) {
7152 /* Printing Lim State starting with global lim states */
7153 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7154 "\n \n LIM STATES:-"
7155 "\n Global Sme State - %s "\
7156 "\n Global mlm State - %s "\
7157 "\n",
7158 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7159 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7160 );
7161 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307162
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007163 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307164 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307165 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007166 if ( pMac->lim.gpSession[count].valid )
7167 {
7168 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7169 "\n Lim Valid Session %d:-"
7170 "\n PE Sme State - %s "
7171 "\n PE Mlm State - %s "
7172 "\n",
7173 check,
7174 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7175 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7176 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307177
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007178 len += buf;
7179 check++;
7180 }
7181 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307182 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307183 }
7184
7185 wrqu->data.length = strlen(extra)+1;
7186 break;
7187 }
7188
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 case WE_GET_CFG:
7190 {
7191 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7192 wrqu->data.length = strlen(extra)+1;
7193 break;
7194 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007195#ifdef WLAN_FEATURE_11AC
7196 case WE_GET_RSSI:
7197 {
7198 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307199 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007200 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7201 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7202 wrqu->data.length = strlen(extra)+1;
7203 break;
7204 }
7205#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307206
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007207#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007208 case WE_GET_ROAM_RSSI:
7209 {
7210 v_S7_t s7Rssi = 0;
7211 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7212 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7213 wrqu->data.length = strlen(extra)+1;
7214 break;
7215 }
7216#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 case WE_GET_WMM_STATUS:
7218 {
7219 snprintf(extra, WE_MAX_STR_LEN,
7220 "\nDir: 0=up, 1=down, 3=both\n"
7221 "|------------------------|\n"
7222 "|AC | ACM |Admitted| Dir |\n"
7223 "|------------------------|\n"
7224 "|VO | %d | %3s | %d |\n"
7225 "|VI | %d | %3s | %d |\n"
7226 "|BE | %d | %3s | %d |\n"
7227 "|BK | %d | %3s | %d |\n"
7228 "|------------------------|\n",
7229 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7230 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7231 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7232 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7233 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7234 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7235 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7236 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7237 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7238 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7239 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7240 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7241
Jeff Johnsone7245742012-09-05 17:12:55 -07007242
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 wrqu->data.length = strlen(extra)+1;
7244 break;
7245 }
7246 case WE_GET_CHANNEL_LIST:
7247 {
7248 VOS_STATUS status;
7249 v_U8_t i, len;
7250 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307251 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7252 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7253 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 tChannelListInfo channel_list;
7255
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007256 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007258 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007260 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 return -EINVAL;
7262 }
7263 buf = extra;
7264
7265 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007266 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7267 * needed = 5 * number of channels. Check ifsufficient
7268 * buffer is available and then proceed to fill the buffer.
7269 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7271 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007272 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007273 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007274 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 return -EINVAL;
7276 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007277 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7278 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307279 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7280 {
7281 //Printing Country code in getChannelList
7282 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7283 {
7284 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7285 "%c ", pBuf[i]);
7286 }
7287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 for(i = 0 ; i < channel_list.num_channels; i++)
7289 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007290 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 }
7293 wrqu->data.length = strlen(extra)+1;
7294
7295 break;
7296 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007297#ifdef FEATURE_WLAN_TDLS
7298 case WE_GET_TDLS_PEERS:
7299 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007300 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007301 break;
7302 }
7303#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007304#ifdef WLAN_FEATURE_11W
7305 case WE_GET_11W_INFO:
7306 {
7307 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7308
7309 snprintf(extra, WE_MAX_STR_LEN,
7310 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7311 "\n Number of Unprotected Disassocs %d"
7312 "\n Number of Unprotected Deauths %d",
7313 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7314 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7315 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7316 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7317 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7318
7319 wrqu->data.length = strlen(extra)+1;
7320 break;
7321 }
7322#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307323#ifdef WLAN_FEATURE_RMC
7324 case WE_GET_IBSS_STA_INFO:
7325 {
7326 hdd_station_ctx_t *pHddStaCtx =
7327 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7328 int idx = 0;
7329 int length = 0, buf = 0;
7330
7331 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7332 {
7333 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7334 {
7335 buf = snprintf
7336 (
7337 (extra + length), WE_MAX_STR_LEN - length,
7338 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7339 pHddStaCtx->conn_info.staId[ idx ],
7340 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7341 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7342 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7343 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7344 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7345 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7346 );
7347 length += buf;
7348 }
7349 }
7350 wrqu->data.length = strlen(extra)+1;
7351 break;
7352 }
7353#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307354 case WE_GET_SNR:
7355 {
7356 v_S7_t s7snr = 0;
7357 int status = 0;
7358 hdd_context_t *pHddCtx;
7359 hdd_station_ctx_t *pHddStaCtx;
7360
7361 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7362 status = wlan_hdd_validate_context(pHddCtx);
7363 if (0 != status)
7364 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307365 return status;
7366 }
7367
7368 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7369
7370 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7371 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7372 {
7373 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7374 " ConnectionState-%d", __func__,
7375 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7376 pHddStaCtx->conn_info.connState);
7377 return -ENONET;
7378 }
7379
7380 /*update the stats in TL*/
7381 wlan_hdd_get_station_stats(pAdapter);
7382 wlan_hdd_get_snr(pAdapter, &s7snr);
7383 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7384 wrqu->data.length = strlen(extra) + 1;
7385 break;
7386 }
7387
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307388#ifdef FEATURE_OEM_DATA_SUPPORT
7389 case WE_GET_OEM_DATA_CAP:
7390 {
7391 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7392 }
7393#endif /* FEATURE_OEM_DATA_SUPPORT */
7394
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307395 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007397 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 break;
7399 }
7400 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307401 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 return 0;
7403}
7404
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307405static int iw_get_char_setnone(struct net_device *dev,
7406 struct iw_request_info *info,
7407 union iwreq_data *wrqu, char *extra)
7408{
7409 int ret;
7410
7411 vos_ssr_protect(__func__);
7412 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7413 vos_ssr_unprotect(__func__);
7414
7415 return ret;
7416}
7417
Jeff Johnson295189b2012-06-20 16:38:30 -07007418/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307419static int __iw_setnone_getnone(struct net_device *dev,
7420 struct iw_request_info *info,
7421 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007422{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307423 hdd_adapter_t *pAdapter;
7424 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307425 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007426 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307427 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307429 ENTER();
7430
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307431 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7432 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007433 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7435 "%s: Adapter is NULL",__func__);
7436 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007437 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307438 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7439 ret = wlan_hdd_validate_context(pHddCtx);
7440 if (0 != ret)
7441 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307442 return ret;
7443 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307444 /* helper function to get iwreq_data with compat handling. */
7445 if (hdd_priv_get_data(&s_priv_data, wrqu))
7446 {
7447 return -EINVAL;
7448 }
7449
7450 sub_cmd = s_priv_data.flags;
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 switch (sub_cmd)
7453 {
7454 case WE_CLEAR_STATS:
7455 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7458 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7459 break;
7460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 case WE_INIT_AP:
7462 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307463 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7464
7465 /* As Soft AP mode might been changed to STA already with
7466 * killing of Hostapd, need to find the adpater by name
7467 * rather than mode */
7468 hdd_adapter_t* pAdapter_to_stop =
7469 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7470 if( pAdapter_to_stop )
7471 {
7472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7473 "Adapter with name softap.0 already "
7474 "exist, ignoring the request.\nRemove the "
7475 "adapter and try again\n");
7476 break;
7477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 pr_info("Init AP trigger\n");
7479 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7480 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7481 break;
7482 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307483#ifdef WLAN_FEATURE_RMC
7484 case WE_IBSS_GET_PEER_INFO_ALL:
7485 {
7486 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7487 break;
7488 }
7489#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 case WE_STOP_AP:
7491 {
7492 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7493 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7494 * this is a dead code and need to find the adpater by name rather than mode */
7495 hdd_adapter_t* pAdapter_to_stop =
7496 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7497 if( pAdapter_to_stop )
7498 {
7499 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7500
7501 pr_info("Stopping AP mode\n");
7502
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307503 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7504 {
7505 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7506 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7507 }
7508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307510 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307511 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7513
7514 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7515 pAdapter_to_stop->macAddressCurrent.bytes);
7516 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7517 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307518
7519 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7520 {
7521 /* put the device back into BMPS */
7522 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 }
7525 else
7526 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007527 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007528 }
7529
7530 break;
7531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007532#ifdef WLAN_BTAMP_FEATURE
7533 case WE_ENABLE_AMP:
7534 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 WLANBAP_RegisterWithHCI(pAdapter);
7537 break;
7538 }
7539 case WE_DISABLE_AMP:
7540 {
7541 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7542 VOS_STATUS status;
7543
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007545
7546 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7547 status = WLANBAP_StopAmp();
7548 if(VOS_STATUS_SUCCESS != status )
7549 {
7550 pHddCtx->isAmpAllowed = VOS_TRUE;
7551 hddLog(VOS_TRACE_LEVEL_FATAL,
7552 "%s: Failed to stop AMP", __func__);
7553 }
7554 else
7555 {
7556 //a state m/c implementation in PAL is TBD to avoid this delay
7557 msleep(500);
7558 pHddCtx->isAmpAllowed = VOS_FALSE;
7559 WLANBAP_DeregisterFromHCI();
7560 }
7561
7562 break;
7563 }
7564#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007565 case WE_ENABLE_DXE_STALL_DETECT:
7566 {
schang6295e542013-03-12 15:31:23 -07007567 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7568 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007569 break;
7570 }
7571 case WE_DISPLAY_DXE_SNAP_SHOT:
7572 {
schang6295e542013-03-12 15:31:23 -07007573 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7574 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007575 break;
7576 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307577 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7578 {
7579 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7580 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307581 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307582 break;
7583 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307584
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307585 case WE_SET_REASSOC_TRIGGER:
7586 {
7587 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7588 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7589 v_U32_t roamId = 0;
7590 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307591 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7592 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307593 return 0;
7594 }
7595
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307596 case WE_STOP_OBSS_SCAN:
7597 {
7598 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7599 2.OBSS scan is stopped by Firmware during the disassociation
7600 3.OBSS stop comamnd is added for debugging purpose*/
7601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7602 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007603
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307604 if (pAdapter == NULL)
7605 {
7606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7607 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307608 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307609 }
7610 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7611 if (pMac == NULL)
7612 {
7613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7614 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307615 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307616 }
7617 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7618 }
7619 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307620 case WE_DUMP_ROAM_TIMER_LOG:
7621 {
7622 vos_dump_roam_time_log_service();
7623 break;
7624 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307625
Mukul Sharma84f27252014-07-14 18:11:42 +05307626 case WE_RESET_ROAM_TIMER_LOG:
7627 {
7628 vos_reset_roam_timer_log();
7629 break;
7630 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307631 case WE_GET_FW_LOGS:
7632 {
7633 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7634 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307635 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307636 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307637 break;
7638 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307639 case WE_GET_FW_MEMDUMP:
7640 {
7641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7642 "FW_MEM_DUMP requested ");
7643 get_fwr_memdump(dev,info,wrqu,extra);
7644 break;
7645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 default:
7647 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007648 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 break;
7650 }
7651 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307652 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 return ret;
7654}
7655
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307656static int iw_setnone_getnone(struct net_device *dev,
7657 struct iw_request_info *info,
7658 union iwreq_data *wrqu, char *extra)
7659{
7660 int ret;
7661
7662 vos_ssr_protect(__func__);
7663 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7664 vos_ssr_unprotect(__func__);
7665
7666 return ret;
7667}
7668
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307669void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7670{
7671 /*
7672 * Function to display HDD WMM information
7673 * for Tx Queues.
7674 * Prints globala as well as per client depending
7675 * whether the clients are registered or not.
7676 */
7677 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307678 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7679 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307680 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7681 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307682 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307683
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307684 for ( i=0; i< NUM_TX_QUEUES; i++)
7685 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307686 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307687 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307688 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307689 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307690
7691 for ( i=0; i< NUM_TX_QUEUES; i++) {
7692 if (tx_queue_count[i]) {
7693 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7694 i, tx_queue_count[i]);
7695 }
7696 }
7697
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307698 if(pSapCtx == NULL){
7699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7700 FL("psapCtx is NULL"));
7701 return;
7702 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307703
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307704 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307705 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7706 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307707 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307708 {
7709 hddLog(LOGE, "******STAIndex: %d*********", i);
7710 for ( j=0; j< NUM_TX_QUEUES; j++)
7711 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307712 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7713 {
7714 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307715 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7716 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307717 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7718 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307719 }
7720 }
7721 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307722 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307723
Katya Nigam1fd24402015-02-16 14:52:19 +05307724 if(pHddStaCtx == NULL){
7725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7726 FL("pHddStaCtx is NULL"));
7727 return;
7728 }
7729
7730 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7731 if(pPeerInfo == NULL){
7732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7733 FL("ppeerinfo is NULL"));
7734 return;
7735 }
7736
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307737 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7738 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7739 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7740 for (j = 0; j < NUM_TX_QUEUES; j++) {
7741 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7742 spin_lock_bh(
7743 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7744 hddLog(LOGE,
7745 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7746 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7747 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7748 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7749 spin_unlock_bh(
7750 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7751 }
7752 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307753 }
7754 }
7755
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307756}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307757
Girish Gowlifb9758e2014-11-19 15:19:17 +05307758static int __iw_set_var_ints_getnone(struct net_device *dev,
7759 struct iw_request_info *info,
7760 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007761{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307762 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307763 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307764 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307765 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007766 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307767 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307768 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007769 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307770 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007771 int cmd = 0;
7772 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307773 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007774
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307775 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307776 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307777 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7779 "%s: NULL extra buffer pointer", __func__);
7780 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307781 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307782 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7783 if (NULL == pAdapter)
7784 {
7785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7786 "%s: Adapter is NULL",__func__);
7787 return -EINVAL;
7788 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307789 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307790 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7791 ret = wlan_hdd_validate_context(pHddCtx);
7792 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007793 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307794 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007795 }
Katya Nigameae74b62015-05-28 17:19:16 +05307796 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307797 {
Katya Nigameae74b62015-05-28 17:19:16 +05307798 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7799 if (NULL == hHal)
7800 {
7801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7802 "%s: Hal Context is NULL",__func__);
7803 return -EINVAL;
7804 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307805 }
7806 sub_cmd = wrqu->data.flags;
7807
7808 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7809
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007810
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007811 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7812 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7813 {
7814 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7815 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7816 {
7817 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7818 staId = pStaCtx->conn_info.staId[0];
7819 }
7820 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7821 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7822 {
7823 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7824 staId = pAPCtx->uBCStaId;
7825 }
7826 else
7827 {
7828 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7829 return 0;
7830 }
7831 }
7832
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 switch (sub_cmd)
7834 {
7835 case WE_LOG_DUMP_CMD:
7836 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307837 if(apps_args[0] == 26) {
7838 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7839 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7840 return 0;
7841 }
7842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007844 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307846 if (hHal)
7847 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7848 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007849
7850 }
7851 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307852#ifdef WLAN_FEATURE_RMC
7853 case WE_IBSS_GET_PEER_INFO:
7854 {
7855 pr_info ( "Station ID = %d\n",apps_args[0]);
7856 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7857 }
7858 break;
7859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007860
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 case WE_P2P_NOA_CMD:
7862 {
7863 p2p_app_setP2pPs_t p2pNoA;
7864
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307865 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7866 hddLog(LOGE,
7867 FL("Setting NoA is not allowed in Device mode:%d"),
7868 pAdapter->device_mode);
7869 return -EINVAL;
7870 }
7871
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 p2pNoA.opp_ps = apps_args[0];
7873 p2pNoA.ctWindow = apps_args[1];
7874 p2pNoA.duration = apps_args[2];
7875 p2pNoA.interval = apps_args[3];
7876 p2pNoA.count = apps_args[4];
7877 p2pNoA.single_noa_duration = apps_args[5];
7878 p2pNoA.psSelection = apps_args[6];
7879
7880 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7881 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007882 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007883 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7884
7885 hdd_setP2pPs(dev, &p2pNoA);
7886
7887 }
7888 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007889
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307890 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7891 {
7892 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7893 __func__, apps_args[0], apps_args[1]);
7894 vosTraceEnable(apps_args[0], apps_args[1]);
7895 }
7896 break;
7897
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007898 case WE_MTRACE_DUMP_CMD:
7899 {
7900 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7901 "bitmask_of_module %d ",
7902 __func__, apps_args[0], apps_args[1], apps_args[2],
7903 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307904 if (hHal)
7905 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7906 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007907
7908 }
7909 break;
7910
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007911 case WE_MCC_CONFIG_CREDENTIAL :
7912 {
7913 cmd = 287; //Command should be updated if there is any change
7914 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007915 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007916 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307917 if (hHal)
7918 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7919 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007920 }
7921 else
7922 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007923 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007924 return 0;
7925 }
7926 }
7927 break;
7928
7929 case WE_MCC_CONFIG_PARAMS :
7930 {
7931 cmd = 288; //command Should be updated if there is any change
7932 // in the Riva dump command
7933 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7934 }
7935 break;
7936
Chilam NG571c65a2013-01-19 12:27:36 +05307937#ifdef FEATURE_WLAN_TDLS
7938 case WE_TDLS_CONFIG_PARAMS :
7939 {
7940 tdls_config_params_t tdlsParams;
7941
Chilam Ng01120412013-02-19 18:32:21 -08007942 tdlsParams.tdls = apps_args[0];
7943 tdlsParams.tx_period_t = apps_args[1];
7944 tdlsParams.tx_packet_n = apps_args[2];
7945 tdlsParams.discovery_period_t = apps_args[3];
7946 tdlsParams.discovery_tries_n = apps_args[4];
7947 tdlsParams.idle_timeout_t = apps_args[5];
7948 tdlsParams.idle_packet_n = apps_args[6];
7949 tdlsParams.rssi_hysteresis = apps_args[7];
7950 tdlsParams.rssi_trigger_threshold = apps_args[8];
7951 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307952
Chilam Ng01120412013-02-19 18:32:21 -08007953 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307954 }
7955 break;
7956#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307957 case WE_CONFIGURE_MONITOR_MODE:
7958 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307959 v_U32_t magic = 0;
7960 struct completion cmpVar;
7961 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307962 tVOS_CON_MODE mode = hdd_get_conparam();
7963
7964 if (VOS_MONITOR_MODE != mode) {
7965 hddLog(LOGE, FL("invalid mode %d"), mode);
7966 return -EIO;
7967 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307968
Katya Nigamf0511f62015-05-05 16:40:57 +05307969 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7970 if( pMonCtx == NULL )
7971 {
7972 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307973 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307974 }
7975 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7976 __func__, apps_args[0], apps_args[1], apps_args[2],
7977 apps_args[3], apps_args[4]);
7978 /* Input Validation part of FW */
7979 pMonCtx->ChannelNo = apps_args[0];
7980 pMonCtx->ChannelBW = apps_args[1];
7981 pMonCtx->crcCheckEnabled = apps_args[2];
7982 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7983 pMonCtx->is80211to803ConReq = apps_args[4];
7984 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7985 if( pMonCtx->is80211to803ConReq )
7986 pAdapter->dev->type = ARPHRD_ETHER;
7987 else
7988 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7989 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7990 {
7991 hddLog(LOGE, "%s: Filtering data packets as management and control"
7992 " cannot be converted to 802.3 ",__func__);
7993 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7994 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307995 if (MON_MODE_START == pMonCtx->state) {
7996 magic = MON_MODE_MSG_MAGIC;
7997 init_completion(&cmpVar);
7998 if (VOS_STATUS_SUCCESS !=
7999 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8000 pMonCtx, hdd_monPostMsgCb)) {
8001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8002 FL("failed to post MON MODE REQ"));
8003 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308004 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308005 }
8006 waitRet = wait_for_completion_timeout(&cmpVar,
8007 MON_MODE_MSG_TIMEOUT);
8008 magic = 0;
8009 if (waitRet <= 0 ) {
8010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8011 FL("failed to wait on monitor mode completion %ld"),
8012 waitRet);
8013 }
8014 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308015 }
8016 break;
8017
8018 case WE_SET_MONITOR_MODE_FILTER:
8019 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308020 v_U32_t magic = 0;
8021 struct completion cmpVar;
8022 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308023 tVOS_CON_MODE mode = hdd_get_conparam();
8024
8025 if (VOS_MONITOR_MODE != mode) {
8026 hddLog(LOGE, FL("invalid mode %d"), mode);
8027 return -EIO;
8028 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308029
Katya Nigamf0511f62015-05-05 16:40:57 +05308030 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8031 if( pMonCtx == NULL )
8032 {
8033 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308034 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308035 }
8036 /* Input Validation Part of FW */
8037 pMonCtx->numOfMacFilters=1;
8038 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8039 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8040 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8041 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8042 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8043 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8044 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8045 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8046 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8047 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8048 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8049 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308050 if (MON_MODE_START == pMonCtx->state) {
8051 magic = MON_MODE_MSG_MAGIC;
8052 init_completion(&cmpVar);
8053 if (VOS_STATUS_SUCCESS !=
8054 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8055 pMonCtx, hdd_monPostMsgCb)) {
8056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8057 FL("failed to post MON MODE REQ"));
8058 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308059 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308060 }
8061 waitRet = wait_for_completion_timeout(&cmpVar,
8062 MON_MODE_MSG_TIMEOUT);
8063 magic = 0;
8064 if (waitRet <= 0 ) {
8065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8066 FL("failed to wait on monitor mode completion %ld"),
8067 waitRet);
8068 }
8069 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308070 }
8071 break;
8072
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 default:
8074 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008075 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8076 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 }
8078 break;
8079 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308080 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 return 0;
8082}
8083
Girish Gowlifb9758e2014-11-19 15:19:17 +05308084static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8085 struct iw_request_info *info,
8086 union iwreq_data *wrqu, char *extra)
8087{
8088 int ret;
8089 union iwreq_data u_priv_wrqu;
8090 int apps_args[MAX_VAR_ARGS] = {0};
8091 int num_args;
8092
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308093 if (!capable(CAP_NET_ADMIN))
8094 {
8095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8096 FL("permission check failed"));
8097 return -EPERM;
8098 }
8099
Girish Gowlifb9758e2014-11-19 15:19:17 +05308100 /* helper function to get iwreq_data with compat handling. */
8101 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8102 {
8103 return -EINVAL;
8104 }
8105
8106 if (NULL == u_priv_wrqu.data.pointer)
8107 {
8108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8109 "%s: NULL data pointer", __func__);
8110 return -EINVAL;
8111 }
8112
8113 num_args = u_priv_wrqu.data.length;
8114 if (num_args > MAX_VAR_ARGS)
8115 {
8116 num_args = MAX_VAR_ARGS;
8117 }
8118
8119 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8120 (sizeof(int)) * num_args))
8121 {
8122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8123 "%s: failed to copy data from user buffer", __func__);
8124 return -EFAULT;
8125 }
8126
8127 vos_ssr_protect(__func__);
8128 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8129 (char *)&apps_args);
8130 vos_ssr_unprotect(__func__);
8131
8132 return ret;
8133}
8134
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308135int iw_set_var_ints_getnone(struct net_device *dev,
8136 struct iw_request_info *info,
8137 union iwreq_data *wrqu, char *extra)
8138{
8139 int ret;
8140 vos_ssr_protect(__func__);
8141 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8142 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008143
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308144 return ret;
8145}
8146
8147static int __iw_add_tspec(struct net_device *dev,
8148 struct iw_request_info *info,
8149 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008150{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308151 hdd_adapter_t *pAdapter;
8152 hdd_station_ctx_t *pHddStaCtx;
8153 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8155 int params[HDD_WLAN_WMM_PARAM_COUNT];
8156 sme_QosWmmTspecInfo tSpec;
8157 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308158 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308159 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308161 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308162 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8163 if (NULL == pAdapter)
8164 {
8165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8166 "%s: Adapter is NULL",__func__);
8167 return -EINVAL;
8168 }
8169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8170 ret = wlan_hdd_validate_context(pHddCtx);
8171 if (0 != ret)
8172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308173 return ret;
8174 }
8175 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8176 if (NULL == pHddStaCtx)
8177 {
8178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8179 "%s: STA Context is NULL",__func__);
8180 return -EINVAL;
8181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 // make sure the application is sufficiently priviledged
8183 // note that the kernel will do this for "set" ioctls, but since
8184 // this ioctl wants to return status to user space it must be
8185 // defined as a "get" ioctl
8186 if (!capable(CAP_NET_ADMIN))
8187 {
8188 return -EPERM;
8189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 // we must be associated in order to add a tspec
8191 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8192 {
8193 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8194 return 0;
8195 }
8196
8197 // since we are defined to be a "get" ioctl, and since the number
8198 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308199 // will pass down in the iwreq_data, we must copy the "set" params.
8200 // We must handle the compat for iwreq_data in 32U/64K environment.
8201
8202 // helper fucntion to get iwreq_data with compat handling.
8203 if (hdd_priv_get_data(&s_priv_data, wrqu))
8204 {
8205 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8206 return 0;
8207 }
8208
8209 // make sure all params are correctly passed to function
8210 if ((NULL == s_priv_data.pointer) ||
8211 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8212 {
8213 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8214 return 0;
8215 }
8216
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308218 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 {
8220 // hmmm, can't get them
8221 return -EIO;
8222 }
8223
8224 // clear the tspec
8225 memset(&tSpec, 0, sizeof(tSpec));
8226
8227 // validate the handle
8228 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8229 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8230 {
8231 // that one is reserved
8232 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8233 return 0;
8234 }
8235
8236 // validate the TID
8237 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8238 {
8239 // out of range
8240 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8241 return 0;
8242 }
8243 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8244
8245 // validate the direction
8246 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8247 {
8248 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8249 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8250 break;
8251
8252 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8253 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8254 break;
8255
8256 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8257 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8258 break;
8259
8260 default:
8261 // unknown
8262 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8263 return 0;
8264 }
8265
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308266 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8267
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 // validate the user priority
8269 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8270 {
8271 // out of range
8272 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8273 return 0;
8274 }
8275 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308276 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8277 {
8278 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8279 return 0;
8280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008281
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8283 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8284 tSpec.ts_info.psb, tSpec.ts_info.up);
8285
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8287 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8288 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8289 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8290 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8291 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8292 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8293 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8294 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8295 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8296 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8297 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8298
8299 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8300
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308301 // Save the expected UAPSD settings by application, this will be needed
8302 // when re-negotiating UAPSD settings during BT Coex cases.
8303 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8304
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 // validate the ts info ack policy
8306 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8307 {
8308 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8309 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8310 break;
8311
8312 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8313 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8314 break;
8315
8316 default:
8317 // unknown
8318 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8319 return 0;
8320 }
8321
8322 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308323
8324 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 return 0;
8326}
8327
8328
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308329static int iw_add_tspec(struct net_device *dev,
8330 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 union iwreq_data *wrqu, char *extra)
8332{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308333 int ret;
8334
8335 vos_ssr_protect(__func__);
8336 ret = __iw_add_tspec(dev, info, wrqu, extra);
8337 vos_ssr_unprotect(__func__);
8338
8339 return ret;
8340}
8341
8342static int __iw_del_tspec(struct net_device *dev,
8343 struct iw_request_info *info,
8344 union iwreq_data *wrqu, char *extra)
8345{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308346 hdd_adapter_t *pAdapter;
8347 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 int *params = (int *)extra;
8349 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8350 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308351 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308353 ENTER();
8354
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308355 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8356 if (NULL == pAdapter)
8357 {
8358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8359 "%s: Adapter is NULL",__func__);
8360 return -EINVAL;
8361 }
8362
8363 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8364 ret = wlan_hdd_validate_context(pHddCtx);
8365 if (0 != ret)
8366 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308367 return ret;
8368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 // make sure the application is sufficiently priviledged
8370 // note that the kernel will do this for "set" ioctls, but since
8371 // this ioctl wants to return status to user space it must be
8372 // defined as a "get" ioctl
8373 if (!capable(CAP_NET_ADMIN))
8374 {
8375 return -EPERM;
8376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 // although we are defined to be a "get" ioctl, the params we require
8378 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8379 // is no need to copy the params from user space
8380
8381 // validate the handle
8382 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8383 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8384 {
8385 // that one is reserved
8386 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8387 return 0;
8388 }
8389
8390 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308391
8392 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 return 0;
8394}
8395
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308396static int iw_del_tspec(struct net_device *dev,
8397 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 union iwreq_data *wrqu, char *extra)
8399{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308400 int ret;
8401
8402 vos_ssr_protect(__func__);
8403 ret = __iw_del_tspec(dev, info, wrqu, extra);
8404 vos_ssr_unprotect(__func__);
8405
8406 return ret;
8407}
8408
8409
8410static int __iw_get_tspec(struct net_device *dev,
8411 struct iw_request_info *info,
8412 union iwreq_data *wrqu, char *extra)
8413{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308414 hdd_adapter_t *pAdapter;
8415 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 int *params = (int *)extra;
8417 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8418 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308419 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308421 ENTER();
8422
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 // although we are defined to be a "get" ioctl, the params we require
8424 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8425 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308426 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8427 if (NULL == pAdapter)
8428 {
8429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8430 "%s: Adapter is NULL",__func__);
8431 return -EINVAL;
8432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008433
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308434 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8435 ret = wlan_hdd_validate_context(pHddCtx);
8436 if (0 != ret)
8437 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308438 return ret;
8439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 // validate the handle
8441 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8442 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8443 {
8444 // that one is reserved
8445 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8446 return 0;
8447 }
8448
8449 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308450 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 return 0;
8452}
8453
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308454static int iw_get_tspec(struct net_device *dev,
8455 struct iw_request_info *info,
8456 union iwreq_data *wrqu, char *extra)
8457{
8458 int ret;
8459
8460 vos_ssr_protect(__func__);
8461 ret = __iw_get_tspec(dev, info, wrqu, extra);
8462 vos_ssr_unprotect(__func__);
8463
8464 return ret;
8465}
8466
Jeff Johnson295189b2012-06-20 16:38:30 -07008467#ifdef WLAN_FEATURE_VOWIFI_11R
8468//
8469//
8470// Each time the supplicant has the auth_request or reassoc request
8471// IEs ready. This is pushed to the driver. The driver will inturn use
8472// it to send out the auth req and reassoc req for 11r FT Assoc.
8473//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308474static int __iw_set_fties(struct net_device *dev,
8475 struct iw_request_info *info,
8476 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008477{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308478 hdd_adapter_t *pAdapter;
8479 hdd_station_ctx_t *pHddStaCtx;
8480 hdd_context_t *pHddCtx;
8481 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 //v_CONTEXT_t pVosContext;
8483
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308484 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308485 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8486 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008487 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8489 "%s: Adapter is NULL",__func__);
8490 return -EINVAL;
8491 }
8492 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8493 ret = wlan_hdd_validate_context(pHddCtx);
8494 if (0 != ret)
8495 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308496 return ret;
8497 }
8498 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8499 if (NULL == pHddStaCtx)
8500 {
8501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8502 "%s: STA Context is NULL",__func__);
8503 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 if (!wrqu->data.length)
8506 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008507 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 return -EINVAL;
8509 }
8510 if (wrqu->data.pointer == NULL)
8511 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008512 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 return -EINVAL;
8514 }
8515
8516 // Added for debug on reception of Re-assoc Req.
8517 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8518 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008519 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008521 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 }
8523
8524#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008525 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008526#endif
8527
8528 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008529 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 wrqu->data.length);
8531
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308532 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 return 0;
8534}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308535
8536static int iw_set_fties(struct net_device *dev,
8537 struct iw_request_info *info,
8538 union iwreq_data *wrqu, char *extra)
8539{
8540 int ret;
8541
8542 vos_ssr_protect(__func__);
8543 ret = __iw_set_fties(dev, info, wrqu, extra);
8544 vos_ssr_unprotect(__func__);
8545
8546 return ret;
8547}
Jeff Johnson295189b2012-06-20 16:38:30 -07008548#endif
8549
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308550static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008551 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008553{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308554 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008555 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308556 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008557 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308558 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008559 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8560 int idx;
8561 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008562
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308563 ENTER();
8564
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308565 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8566 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008567 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8569 "%s: Adapter is NULL",__func__);
8570 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008571 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308572 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8573 ret_val = wlan_hdd_validate_context(pHddCtx);
8574 if (0 != ret_val)
8575 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308576 return ret_val;
8577 }
8578 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8579 if (NULL == hHal)
8580 {
8581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8582 "%s: Hal Context is NULL",__func__);
8583 return -EINVAL;
8584 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308585 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8586 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308587#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008588
Amar Singhalf3a6e762013-02-19 15:06:50 -08008589 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8590 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008591 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008592 hddLog(VOS_TRACE_LEVEL_ERROR,
8593 "%s: vos_mem_alloc failed", __func__);
8594 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008595 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008596
8597 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8598
8599 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8600 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8601
8602 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8603 mc_addr_list_ptr->ulMulticastAddrCnt);
8604
8605 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008606 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008607 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8608 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8609
8610 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8611 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008612 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008613
Amar Singhalf3a6e762013-02-19 15:06:50 -08008614 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8615 vos_mem_free(mc_addr_list_ptr);
8616 if (eHAL_STATUS_SUCCESS != ret_val)
8617 {
8618 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8619 __func__);
8620 return -EINVAL;
8621 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308622#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308623 }
8624 else
8625 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008626
Amar Singhalf3a6e762013-02-19 15:06:50 -08008627 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8628 "%s: Set MC BC Filter Config request: %d suspend %d",
8629 __func__, pRequest->mcastBcastFilterSetting,
8630 pHddCtx->hdd_wlan_suspended);
8631
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308632 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008633
8634 if (pHddCtx->hdd_wlan_suspended)
8635 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008636 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8637 if (NULL == wlanRxpFilterParam)
8638 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308639 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008640 "%s: vos_mem_alloc failed", __func__);
8641 return -EINVAL;
8642 }
8643
Amar Singhalf3a6e762013-02-19 15:06:50 -08008644 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8645 pRequest->mcastBcastFilterSetting;
8646 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8647
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308648 hdd_conf_hostoffload(pAdapter, TRUE);
8649 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8650 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008651
8652 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8653 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308654 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008655 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8656 wlanRxpFilterParam->setMcstBcstFilter);
8657
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308658 if (eHAL_STATUS_SUCCESS !=
8659 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8660 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008661 {
8662 hddLog(VOS_TRACE_LEVEL_ERROR,
8663 "%s: Failure to execute set HW MC/BC Filter request",
8664 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008665 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008666 return -EINVAL;
8667 }
8668
c_hpothud3ce76d2014-10-28 10:34:13 +05308669 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8670 {
8671 pHddCtx->sus_res_mcastbcast_filter =
8672 pRequest->mcastBcastFilterSetting;
8673 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008674 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008676
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308677 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 return 0;
8679}
8680
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308681static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8682 struct iw_request_info *info,
8683 union iwreq_data *wrqu, char *extra)
8684{
8685 int ret;
8686
8687 vos_ssr_protect(__func__);
8688 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8689 vos_ssr_unprotect(__func__);
8690
8691 return ret;
8692}
8693
8694static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8695 struct iw_request_info *info,
8696 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008697{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308698 hdd_adapter_t *pAdapter;
8699 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308700 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308701 int ret = 0;
8702
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308703 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008704
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308705 if (!capable(CAP_NET_ADMIN))
8706 {
8707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8708 FL("permission check failed"));
8709 return -EPERM;
8710 }
8711
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308712 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8713 if (NULL == pAdapter)
8714 {
8715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8716 "%s: Adapter is NULL",__func__);
8717 return -EINVAL;
8718 }
8719
8720 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8721 ret = wlan_hdd_validate_context(pHddCtx);
8722 if (0 != ret)
8723 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308724 return ret;
8725 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308726 //Reset the filter to INI value as we have to clear the dynamic filter
8727 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008728
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308729 //Configure FW with new setting
8730 if (pHddCtx->hdd_wlan_suspended)
8731 {
8732 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8733 if (NULL == wlanRxpFilterParam)
8734 {
8735 hddLog(VOS_TRACE_LEVEL_ERROR,
8736 "%s: vos_mem_alloc failed", __func__);
8737 return -EINVAL;
8738 }
8739
8740 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8741 pHddCtx->configuredMcastBcastFilter;
8742 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8743
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308744 hdd_conf_hostoffload(pAdapter, TRUE);
8745 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8746 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308747
8748 if (eHAL_STATUS_SUCCESS !=
8749 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8750 wlanRxpFilterParam))
8751 {
8752 hddLog(VOS_TRACE_LEVEL_ERROR,
8753 "%s: Failure to execute set HW MC/BC Filter request",
8754 __func__);
8755 vos_mem_free(wlanRxpFilterParam);
8756 return -EINVAL;
8757 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308758
8759 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8760 {
8761 pHddCtx->sus_res_mcastbcast_filter =
8762 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8763 }
8764
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308765 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308766 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 return 0;
8768}
8769
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308770
8771static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8772 struct iw_request_info *info,
8773 union iwreq_data *wrqu, char *extra)
8774{
8775 int ret;
8776
8777 vos_ssr_protect(__func__);
8778 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8779 vos_ssr_unprotect(__func__);
8780
8781 return ret;
8782}
8783
8784static int __iw_set_host_offload(struct net_device *dev,
8785 struct iw_request_info *info,
8786 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008787{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308788 hdd_adapter_t *pAdapter;
8789 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008790 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308792 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008793
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308794 ENTER();
8795
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8797 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008798 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8800 "%s: Adapter is NULL",__func__);
8801 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008802 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308803 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8804 ret = wlan_hdd_validate_context(pHddCtx);
8805 if (0 != ret)
8806 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308807 return ret;
8808 }
8809
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 /* Debug display of request components. */
8811 switch (pRequest->offloadType)
8812 {
8813 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008814 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 switch (pRequest->enableOrDisable)
8816 {
8817 case WLAN_OFFLOAD_DISABLE:
8818 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8819 break;
8820 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8821 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8822 case WLAN_OFFLOAD_ENABLE:
8823 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8824 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8825 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8826 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8827 }
8828 break;
8829
8830 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008831 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008832 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 switch (pRequest->enableOrDisable)
8834 {
8835 case WLAN_OFFLOAD_DISABLE:
8836 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8837 break;
8838 case WLAN_OFFLOAD_ENABLE:
8839 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8840 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8841 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8842 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8843 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8844 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8845 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8846 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8847 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8848 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8849 }
8850 }
8851
8852 /* Execute offload request. The reason that we can copy the request information
8853 from the ioctl structure to the SME structure is that they are laid out
8854 exactly the same. Otherwise, each piece of information would have to be
8855 copied individually. */
8856 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008857 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8858 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 __func__);
8862 return -EINVAL;
8863 }
8864
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308865 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 return 0;
8867}
8868
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308869static int iw_set_host_offload(struct net_device *dev,
8870 struct iw_request_info *info,
8871 union iwreq_data *wrqu, char *extra)
8872{
8873 int ret;
8874
8875 vos_ssr_protect(__func__);
8876 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8877 vos_ssr_unprotect(__func__);
8878
8879 return ret;
8880}
8881
8882static int __iw_set_keepalive_params(struct net_device *dev,
8883 struct iw_request_info *info,
8884 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008885{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308886 hdd_adapter_t *pAdapter;
8887 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008888 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308890 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008891
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308892 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308893 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8894 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8897 "%s: Adapter is NULL",__func__);
8898 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8901 ret = wlan_hdd_validate_context(pHddCtx);
8902 if (0 != ret)
8903 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308904 return ret;
8905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008907 hddLog(VOS_TRACE_LEVEL_INFO,
8908 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8909 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008910
8911 switch (pRequest->packetType)
8912 {
8913 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008914 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 break;
8916
8917 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8918
Arif Hussain6d2a3322013-11-17 19:50:10 -08008919 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008920 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008921
8922 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8923 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8924 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8925
8926 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8927 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8928 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8929
8930 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8931 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8932 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8933 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8934 break;
8935
8936 }
8937
8938 /* Execute keep alive request. The reason that we can copy the request information
8939 from the ioctl structure to the SME structure is that they are laid out
8940 exactly the same. Otherwise, each piece of information would have to be
8941 copied individually. */
8942 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8943
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308944 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8945 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008946
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008947 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008948 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008951 __func__);
8952 return -EINVAL;
8953 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308954 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 return 0;
8956}
8957
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308958static int iw_set_keepalive_params(struct net_device *dev,
8959 struct iw_request_info *info,
8960 union iwreq_data *wrqu, char *extra)
8961{
8962 int ret;
8963 vos_ssr_protect(__func__);
8964 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8965 vos_ssr_unprotect(__func__);
8966
8967 return ret;
8968}
8969
Jeff Johnson295189b2012-06-20 16:38:30 -07008970#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05308971/**-----------------------------------------------------------------
8972
8973 \brief hdd_pkt_filter_done - callback to be executed on completion
8974 successful/failure) for clear filter request.
8975
8976 \return - None
8977
8978 --------------------------------------------------------------------------*/
8979static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008980{
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05308981 struct statsContext *cbCtx = (struct statsContext *)data;
8982
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05308983 hddLog(VOS_TRACE_LEVEL_INFO,
8984 FL("Pkt Filter Clear Status : %d"), status);
8985
8986 if (data == NULL)
8987 {
8988 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context"));
8989 return;
8990 }
8991
8992 spin_lock(&hdd_context_lock);
8993 if (cbCtx->magic != CLEAR_FILTER_MAGIC)
8994 {
8995 spin_unlock(&hdd_context_lock);
8996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context, magic %x"), cbCtx->magic);
8997 if (ioctl_debug)
8998 {
8999 pr_info("%s: Invalid context, magic [%08x]\n",
9000 __func__, cbCtx->magic);
9001 }
9002 return;
9003 }
9004
9005 complete(&cbCtx->completion);
9006 spin_unlock(&hdd_context_lock);
9007}
9008
9009int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9010{
9011 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309012 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009013 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9014 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309015 struct statsContext cbCtx;
9016 int i=0, status;
9017
9018 status = wlan_hdd_validate_context(pHddCtx);
9019 if (0 != status)
9020 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009021
9022 if (pHddCtx->cfg_ini->disablePacketFilter)
9023 {
9024 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009025 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 return 0;
9027 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309028 if (pHddCtx->isLogpInProgress)
9029 {
9030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9031 "%s:LOGP in Progress. Ignore!!!", __func__);
9032 return -EBUSY;
9033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 /* Debug display of request components. */
9035 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009036 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009037
9038 switch (pRequest->filterAction)
9039 {
9040 case HDD_RCV_FILTER_SET:
9041 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009042 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009043
9044 packetFilterSetReq.filterId = pRequest->filterId;
9045 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9046 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009047 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 __func__, pRequest->numParams);
9049 return -EINVAL;
9050 }
9051 packetFilterSetReq.numFieldParams = pRequest->numParams;
9052 packetFilterSetReq.coalesceTime = 0;
9053 packetFilterSetReq.filterType = 1;
9054 for (i=0; i < pRequest->numParams; i++)
9055 {
9056 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9057 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9058 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9059 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9060 packetFilterSetReq.paramsData[i].reserved = 0;
9061
Arif Hussain6d2a3322013-11-17 19:50:10 -08009062 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9064 packetFilterSetReq.filterType);
9065
Arif Hussain6d2a3322013-11-17 19:50:10 -08009066 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309068 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9069 (pRequest->paramsData[i].dataLength))
9070 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009071
9072 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9073 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9074 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9075 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9076
Arif Hussain6d2a3322013-11-17 19:50:10 -08009077 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9079 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9080 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9081
Arif Hussain6d2a3322013-11-17 19:50:10 -08009082 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9084 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9085 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9086 }
9087
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309088 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 __func__);
9092 return -EINVAL;
9093 }
9094
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309095 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9096 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 break;
9098
9099 case HDD_RCV_FILTER_CLEAR:
9100
Arif Hussain6d2a3322013-11-17 19:50:10 -08009101 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009102 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309103
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309104 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9105 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9106 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9107 pHddStaCtx->conn_info.staId[0]);
9108 }
9109
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309110 init_completion(&cbCtx.completion);
9111 cbCtx.magic = CLEAR_FILTER_MAGIC;
9112 cbCtx.pAdapter = pAdapter;
9113 packetFilterClrReq.cbCtx = &cbCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309115 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
9116 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 __func__);
9120 return -EINVAL;
9121 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309122
9123 status = wait_for_completion_interruptible_timeout(&cbCtx.completion,
9124 msecs_to_jiffies(PKT_FILTER_TIMEOUT));
9125 spin_lock(&hdd_context_lock);
9126 cbCtx.magic = 0;
9127 spin_unlock(&hdd_context_lock);
9128 if (0 >= status)
9129 {
9130 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9131 status);
9132 return -EINVAL;
9133 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309134
9135 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9136 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009137 break;
9138
9139 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009140 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009141 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 return -EINVAL;
9143 }
9144 return 0;
9145}
9146
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309147int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9148 tANI_U8 sessionId)
9149{
9150 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9151 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9152
9153 if (NULL == pHddCtx)
9154 {
9155 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9156 return -EINVAL;
9157 }
9158
9159 if (pHddCtx->isLogpInProgress)
9160 {
9161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9162 "%s:LOGP in Progress. Ignore!!!", __func__);
9163 return -EBUSY;
9164 }
9165
9166 if (pHddCtx->cfg_ini->disablePacketFilter)
9167 {
9168 hddLog(VOS_TRACE_LEVEL_ERROR,
9169 "%s: Packet Filtering Disabled. Returning ",
9170 __func__ );
9171 return -EINVAL;
9172 }
9173
9174 switch (filterType)
9175 {
9176 /* For setting IPV6 MC and UC Filter we need to configure
9177 * 2 filters, one for MC and one for UC.
9178 * The Filter ID shouldn't be swapped, which results in making
9179 * UC Filter ineffective.
9180 * We have Hardcode all the values
9181 *
9182 * Reason for a seperate UC filter is because, driver need to
9183 * specify the FW that the specific filter is for unicast
9184 * otherwise FW will not pass the unicast frames by default
9185 * through the filter. This is required to avoid any performance
9186 * hits when no unicast filter is set and only MC/BC are set.
9187 * The way driver informs host is by using the MAC protocol
9188 * layer, CMP flag set to MAX, CMP Data set to 1.
9189 */
9190
9191 case HDD_FILTER_IPV6_MC_UC:
9192 /* Setting IPV6 MC Filter below
9193 */
9194 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9195 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9196 packetFilterSetReq.numFieldParams = 2;
9197 packetFilterSetReq.paramsData[0].protocolLayer =
9198 HDD_FILTER_PROTO_TYPE_MAC;
9199 packetFilterSetReq.paramsData[0].cmpFlag =
9200 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9201 packetFilterSetReq.paramsData[0].dataOffset =
9202 WLAN_HDD_80211_FRM_DA_OFFSET;
9203 packetFilterSetReq.paramsData[0].dataLength = 1;
9204 packetFilterSetReq.paramsData[0].compareData[0] =
9205 HDD_IPV6_MC_CMP_DATA;
9206
9207 packetFilterSetReq.paramsData[1].protocolLayer =
9208 HDD_FILTER_PROTO_TYPE_ARP;
9209 packetFilterSetReq.paramsData[1].cmpFlag =
9210 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9211 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9212 packetFilterSetReq.paramsData[1].dataLength = 2;
9213 packetFilterSetReq.paramsData[1].compareData[0] =
9214 HDD_IPV6_CMP_DATA_0;
9215 packetFilterSetReq.paramsData[1].compareData[1] =
9216 HDD_IPV6_CMP_DATA_1;
9217
9218
9219 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9220 &packetFilterSetReq, sessionId))
9221 {
9222 hddLog(VOS_TRACE_LEVEL_ERROR,
9223 "%s: Failure to execute Set IPv6 Mulicast Filter",
9224 __func__);
9225 return -EINVAL;
9226 }
9227
9228 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9229
9230 /*
9231 * Setting IPV6 UC Filter below
9232 */
9233 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9234 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9235 packetFilterSetReq.numFieldParams = 2;
9236 packetFilterSetReq.paramsData[0].protocolLayer =
9237 HDD_FILTER_PROTO_TYPE_MAC;
9238 packetFilterSetReq.paramsData[0].cmpFlag =
9239 HDD_FILTER_CMP_TYPE_MAX;
9240 packetFilterSetReq.paramsData[0].dataOffset = 0;
9241 packetFilterSetReq.paramsData[0].dataLength = 1;
9242 packetFilterSetReq.paramsData[0].compareData[0] =
9243 HDD_IPV6_UC_CMP_DATA;
9244
9245 packetFilterSetReq.paramsData[1].protocolLayer =
9246 HDD_FILTER_PROTO_TYPE_ARP;
9247 packetFilterSetReq.paramsData[1].cmpFlag =
9248 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9249 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9250 packetFilterSetReq.paramsData[1].dataLength = 2;
9251 packetFilterSetReq.paramsData[1].compareData[0] =
9252 HDD_IPV6_CMP_DATA_0;
9253 packetFilterSetReq.paramsData[1].compareData[1] =
9254 HDD_IPV6_CMP_DATA_1;
9255
9256 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9257 &packetFilterSetReq, sessionId))
9258 {
9259 hddLog(VOS_TRACE_LEVEL_ERROR,
9260 "%s: Failure to execute Set IPv6 Unicast Filter",
9261 __func__);
9262 return -EINVAL;
9263 }
9264
9265 break;
9266
9267 case HDD_FILTER_IPV6_MC:
9268 /*
9269 * IPV6 UC Filter might be already set,
9270 * clear the UC Filter. As the Filter
9271 * IDs are static, we can directly clear it.
9272 */
9273 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9274 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9275 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9276 &packetFilterClrReq, sessionId))
9277 {
9278 hddLog(VOS_TRACE_LEVEL_ERROR,
9279 "%s: Failure to execute Clear IPv6 Unicast Filter",
9280 __func__);
9281 return -EINVAL;
9282 }
9283
9284 /*
9285 * Setting IPV6 MC Filter below
9286 */
9287 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9288 packetFilterSetReq.numFieldParams = 2;
9289 packetFilterSetReq.paramsData[0].protocolLayer =
9290 HDD_FILTER_PROTO_TYPE_MAC;
9291 packetFilterSetReq.paramsData[0].cmpFlag =
9292 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9293 packetFilterSetReq.paramsData[0].dataOffset =
9294 WLAN_HDD_80211_FRM_DA_OFFSET;
9295 packetFilterSetReq.paramsData[0].dataLength = 1;
9296 packetFilterSetReq.paramsData[0].compareData[0] =
9297 HDD_IPV6_MC_CMP_DATA;
9298
9299 packetFilterSetReq.paramsData[1].protocolLayer =
9300 HDD_FILTER_PROTO_TYPE_ARP;
9301 packetFilterSetReq.paramsData[1].cmpFlag =
9302 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9303 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9304 packetFilterSetReq.paramsData[1].dataLength = 2;
9305 packetFilterSetReq.paramsData[1].compareData[0] =
9306 HDD_IPV6_CMP_DATA_0;
9307 packetFilterSetReq.paramsData[1].compareData[1] =
9308 HDD_IPV6_CMP_DATA_1;
9309
9310
9311 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9312 &packetFilterSetReq, sessionId))
9313 {
9314 hddLog(VOS_TRACE_LEVEL_ERROR,
9315 "%s: Failure to execute Set IPv6 Multicast Filter",
9316 __func__);
9317 return -EINVAL;
9318 }
9319 break;
9320
9321 default :
9322 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9323 "%s: Packet Filter Request: Invalid",
9324 __func__);
9325 return -EINVAL;
9326 }
9327 return 0;
9328}
9329
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309330void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009331{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309332 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309333 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009334 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309335 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009336
Yue Ma3ede6052013-08-29 00:33:26 -07009337 if (NULL == pHddCtx)
9338 {
9339 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9340 return;
9341 }
9342
9343 hHal = pHddCtx->hHal;
9344
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309345 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309347 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9348 return;
9349 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309350
9351 /* Check if INI is enabled or not, other wise just return
9352 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309353 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309354 {
9355 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9356 if (NULL == pMulticastAddrs)
9357 {
9358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9359 return;
9360 }
9361
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 if (set)
9363 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309364 /* Following pre-conditions should be satisfied before wei
9365 * configure the MC address list.
9366 */
9367 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9368 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9369 && pAdapter->mc_addr_list.mc_cnt
9370 && (eConnectionState_Associated ==
9371 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9372 {
9373 pMulticastAddrs->ulMulticastAddrCnt =
9374 pAdapter->mc_addr_list.mc_cnt;
9375 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9376 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009377 memcpy(pMulticastAddrs->multicastAddr[i],
9378 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309379 sizeof(pAdapter->mc_addr_list.addr[i]));
9380 hddLog(VOS_TRACE_LEVEL_INFO,
9381 "%s: %s multicast filter: addr ="
9382 MAC_ADDRESS_STR,
9383 __func__, set ? "setting" : "clearing",
9384 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9385 }
9386 /* Set multicast filter */
9387 sme_8023MulticastList(hHal, pAdapter->sessionId,
9388 pMulticastAddrs);
9389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009390 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309391 else
9392 {
9393 /* Need to clear only if it was previously configured
9394 */
9395 if (pAdapter->mc_addr_list.isFilterApplied)
9396 {
9397 pMulticastAddrs->ulMulticastAddrCnt = 0;
9398 sme_8023MulticastList(hHal, pAdapter->sessionId,
9399 pMulticastAddrs);
9400 }
9401
9402 }
9403 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009404 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309406 else
9407 {
9408 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309409 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309410 }
9411 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009412}
9413
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309414static int __iw_set_packet_filter_params(struct net_device *dev,
9415 struct iw_request_info *info,
9416 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309417{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309418 hdd_adapter_t *pAdapter;
9419 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009420 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309421 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309422 struct iw_point s_priv_data;
9423
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309424 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309425
9426 if (!capable(CAP_NET_ADMIN))
9427 {
9428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9429 FL("permission check failed"));
9430 return -EPERM;
9431 }
9432
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309433 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9434 if (NULL == pAdapter)
9435 {
9436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9437 "%s: Adapter is NULL",__func__);
9438 return -EINVAL;
9439 }
9440 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9441 ret = wlan_hdd_validate_context(pHddCtx);
9442 if (0 != ret)
9443 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309444 return ret;
9445 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309446 if (hdd_priv_get_data(&s_priv_data, wrqu))
9447 {
9448 return -EINVAL;
9449 }
9450
9451 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9452 {
9453 return -EINVAL;
9454 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009455
Arif Hussain0273cba2014-01-07 20:58:29 -08009456 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309457 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9458 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009459 if (NULL == pRequest)
9460 {
9461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9462 "mem_alloc_copy_from_user_helper fail");
9463 return -ENOMEM;
9464 }
9465
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309466 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009467 kfree(pRequest);
9468
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309469 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009470 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009471}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309472
9473static int iw_set_packet_filter_params(struct net_device *dev,
9474 struct iw_request_info *info,
9475 union iwreq_data *wrqu, char *extra)
9476{
9477 int ret;
9478
9479 vos_ssr_protect(__func__);
9480 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9481 vos_ssr_unprotect(__func__);
9482
9483 return ret;
9484}
Jeff Johnson295189b2012-06-20 16:38:30 -07009485#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309486static int __iw_get_statistics(struct net_device *dev,
9487 struct iw_request_info *info,
9488 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009489{
9490
9491 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9492 eHalStatus status = eHAL_STATUS_SUCCESS;
9493 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309494 hdd_adapter_t *pAdapter;
9495 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309497 int tlen = 0, ret = 0;
9498 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009499
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309500 tCsrGlobalClassAStatsInfo *aStats;
9501 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009502
9503 ENTER();
9504
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309505 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9506 if (NULL == pAdapter)
9507 {
9508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9509 "%s: Adapter is NULL",__func__);
9510 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309512 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9513 ret = wlan_hdd_validate_context(pHddCtx);
9514 if (0 != ret)
9515 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309516 return ret;
9517 }
9518 pStats = &(pAdapter->hdd_stats.summary_stat);
9519 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9520 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9522
9523 wrqu->txpower.value = 0;
9524 }
9525 else {
9526 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9527 SME_SUMMARY_STATS |
9528 SME_GLOBAL_CLASSA_STATS |
9529 SME_GLOBAL_CLASSB_STATS |
9530 SME_GLOBAL_CLASSC_STATS |
9531 SME_GLOBAL_CLASSD_STATS |
9532 SME_PER_STA_STATS,
9533 hdd_StatisticsCB, 0, FALSE,
9534 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9535
9536 if (eHAL_STATUS_SUCCESS != status)
9537 {
9538 hddLog(VOS_TRACE_LEVEL_ERROR,
9539 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009540 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 return -EINVAL;
9542 }
9543
9544 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309545 if (NULL == pWextState)
9546 {
9547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9548 "%s: pWextState is NULL",__func__);
9549 return -EINVAL;
9550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009551
9552 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9553 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9554 {
9555 hddLog(VOS_TRACE_LEVEL_ERROR,
9556 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009557 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009558 /*Remove the SME statistics list by passing NULL in callback argument*/
9559 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9560 SME_SUMMARY_STATS |
9561 SME_GLOBAL_CLASSA_STATS |
9562 SME_GLOBAL_CLASSB_STATS |
9563 SME_GLOBAL_CLASSC_STATS |
9564 SME_GLOBAL_CLASSD_STATS |
9565 SME_PER_STA_STATS,
9566 NULL, 0, FALSE,
9567 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9568
9569 return -EINVAL;
9570 }
9571 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9572 (tANI_U8) sizeof (pStats->retry_cnt),
9573 (char*) &(pStats->retry_cnt[0]),
9574 tlen);
9575
9576 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9577 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9578 (char*) &(pStats->multiple_retry_cnt[0]),
9579 tlen);
9580
9581 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9582 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9583 (char*) &(pStats->tx_frm_cnt[0]),
9584 tlen);
9585
9586 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9587 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9588 (char*) &(pStats->rx_frm_cnt),
9589 tlen);
9590
9591 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9592 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9593 (char*) &(pStats->frm_dup_cnt),
9594 tlen);
9595
9596 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9597 (tANI_U8) sizeof (pStats->fail_cnt),
9598 (char*) &(pStats->fail_cnt[0]),
9599 tlen);
9600
9601 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9602 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9603 (char*) &(pStats->rts_fail_cnt),
9604 tlen);
9605
9606 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9607 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9608 (char*) &(pStats->ack_fail_cnt),
9609 tlen);
9610
9611 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9612 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9613 (char*) &(pStats->rts_succ_cnt),
9614 tlen);
9615
9616 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9617 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9618 (char*) &(pStats->rx_discard_cnt),
9619 tlen);
9620
9621 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9622 (tANI_U8) sizeof (pStats->rx_error_cnt),
9623 (char*) &(pStats->rx_error_cnt),
9624 tlen);
9625
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009626 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009627 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009628 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 tlen);
9630
9631 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9632 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9633 (char*) &(dStats->rx_byte_cnt),
9634 tlen);
9635
9636 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9637 (tANI_U8) sizeof (dStats->rx_rate),
9638 (char*) &(dStats->rx_rate),
9639 tlen);
9640
9641 /* Transmit rate, in units of 500 kbit/sec */
9642 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9643 (tANI_U8) sizeof (aStats->tx_rate),
9644 (char*) &(aStats->tx_rate),
9645 tlen);
9646
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009647 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9648 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9649 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009650 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009651 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9652 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9653 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009654 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009655 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9656 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9657 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009658 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009659 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9660 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9661 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009662 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009663 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9664 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9665 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009666 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009667 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9668 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9669 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009670 tlen);
9671
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 wrqu->data.length = tlen;
9673
9674 }
9675
9676 EXIT();
9677
9678 return 0;
9679}
9680
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309681static int iw_get_statistics(struct net_device *dev,
9682 struct iw_request_info *info,
9683 union iwreq_data *wrqu, char *extra)
9684{
9685 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009686
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309687 vos_ssr_protect(__func__);
9688 ret = __iw_get_statistics(dev, info, wrqu, extra);
9689 vos_ssr_unprotect(__func__);
9690
9691 return ret;
9692}
Jeff Johnson295189b2012-06-20 16:38:30 -07009693#ifdef FEATURE_WLAN_SCAN_PNO
9694
9695/*Max Len for PNO notification*/
9696#define MAX_PNO_NOTIFY_LEN 100
9697void found_pref_network_cb (void *callbackContext,
9698 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9699{
9700 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9701 union iwreq_data wrqu;
9702 char buf[MAX_PNO_NOTIFY_LEN+1];
9703
9704 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9705 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9706
9707 // create the event
9708 memset(&wrqu, 0, sizeof(wrqu));
9709 memset(buf, 0, sizeof(buf));
9710
9711 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9712 pPrefNetworkFoundInd->ssId.ssId,
9713 (unsigned int)pPrefNetworkFoundInd->rssi);
9714
9715 wrqu.data.pointer = buf;
9716 wrqu.data.length = strlen(buf);
9717
9718 // send the event
9719
9720 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9721
9722}
9723
9724
9725/*string based input*/
9726VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9727 union iwreq_data *wrqu, char *extra, int nOffset)
9728{
9729 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309730 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009731 /* pnoRequest is a large struct, so we make it static to avoid stack
9732 overflow. This API is only invoked via ioctl, so it is
9733 serialized by the kernel rtnl_lock and hence does not need to be
9734 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309735 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 char *ptr;
9737 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309738 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9740
9741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9742 "PNO data len %d data %s",
9743 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009744 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009745
9746 if (wrqu->data.length <= nOffset )
9747 {
9748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9749 return VOS_STATUS_E_FAILURE;
9750 }
9751
9752 pnoRequest.enable = 0;
9753 pnoRequest.ucNetworksCount = 0;
9754 /*-----------------------------------------------------------------------
9755 Input is string based and expected to be like this:
9756
9757 <enabled> <netw_count>
9758 for each network:
9759 <ssid_len> <ssid> <authentication> <encryption>
9760 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9761 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9762
9763 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009764 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 -07009765
9766 this translates into:
9767 -----------------------------
9768 enable PNO
9769 look for 2 networks:
9770 test - with authentication type 0 and encryption type 0,
9771 that can be found on 3 channels: 1 6 and 11 ,
9772 SSID bcast type is unknown (directed probe will be sent if AP not found)
9773 and must meet -40dBm RSSI
9774
9775 test2 - with auth and enrytption type 4/4
9776 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9777 bcast type is non-bcast (directed probe will be sent)
9778 and must not meet any RSSI threshold
9779
Jeff Johnson8301aa12013-03-28 14:27:29 -07009780 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009782 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009783
Wilson Yang623f6592013-10-08 16:33:37 -07009784 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9785 {
9786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9787 "PNO enable input is not valid %s",ptr);
9788 return VOS_STATUS_E_FAILURE;
9789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009790
9791 if ( 0 == pnoRequest.enable )
9792 {
9793 /*Disable PNO*/
9794 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309795 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9796 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 pAdapter->sessionId,
9798 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309799 if (eHAL_STATUS_SUCCESS != status)
9800 {
9801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9802 "%s: failed to disable PNO", __func__);
9803 return VOS_STATUS_E_FAILURE;
9804 }
9805 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 return VOS_STATUS_SUCCESS;
9807 }
9808
c_hpothu37f21312014-04-09 21:49:54 +05309809 if (TRUE == pHddCtx->isPnoEnable)
9810 {
9811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9812 FL("already PNO is enabled"));
9813 return -EBUSY;
9814 }
9815 pHddCtx->isPnoEnable = TRUE;
9816
Jeff Johnson295189b2012-06-20 16:38:30 -07009817 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009818
9819 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9820 {
9821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9822 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309823 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009825
9826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9827 "PNO enable %d networks count %d offset %d",
9828 pnoRequest.enable,
9829 pnoRequest.ucNetworksCount,
9830 nOffset);
9831
9832 /* Parameters checking:
9833 ucNetworksCount has to be larger than 0*/
9834 if (( 0 == pnoRequest.ucNetworksCount ) ||
9835 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9836 {
9837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309838 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 }
9840
9841 ptr += nOffset;
9842
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309843 pnoRequest.aNetworks =
9844 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9845 if (pnoRequest.aNetworks == NULL)
9846 {
9847 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9848 FL("failed to allocate memory aNetworks %u"),
9849 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9850 goto error;
9851 }
9852 vos_mem_zero(pnoRequest.aNetworks,
9853 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9854
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9856 {
9857
9858 pnoRequest.aNetworks[i].ssId.length = 0;
9859
Wilson Yang623f6592013-10-08 16:33:37 -07009860 ucParams = sscanf(ptr,"%hhu %n",
9861 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9862
9863 if (1 != ucParams)
9864 {
9865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9866 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309867 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009869
9870 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9871 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9872 {
9873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9874 "SSID Len %d is not correct for network %d",
9875 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309876 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 }
9878
9879 /*Advance to SSID*/
9880 ptr += nOffset;
9881
Jeff Johnson8301aa12013-03-28 14:27:29 -07009882 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009883 pnoRequest.aNetworks[i].ssId.length);
9884 ptr += pnoRequest.aNetworks[i].ssId.length;
9885
Jeff Johnson02797792013-10-26 19:17:13 -07009886 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009887 &(pnoRequest.aNetworks[i].authentication),
9888 &(pnoRequest.aNetworks[i].encryption),
9889 &(pnoRequest.aNetworks[i].ucChannelCount),
9890 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009891
Wilson Yang623f6592013-10-08 16:33:37 -07009892 if ( 3 != ucParams )
9893 {
9894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9895 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309896 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009897 }
9898
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009900 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009901 "auth %d encry %d channel count %d offset %d",
9902 pnoRequest.aNetworks[i].ssId.length,
9903 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9904 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9905 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9906 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9907 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9908 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9909 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9910 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9911 pnoRequest.aNetworks[i].authentication,
9912 pnoRequest.aNetworks[i].encryption,
9913 pnoRequest.aNetworks[i].ucChannelCount,
9914 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009915
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 /*Advance to channel list*/
9917 ptr += nOffset;
9918
Wilson Yang623f6592013-10-08 16:33:37 -07009919 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 {
9921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9922 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309923 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 }
9925
9926 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9927 {
9928 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9929 {
Wilson Yang623f6592013-10-08 16:33:37 -07009930 if (1 != sscanf(ptr,"%hhu %n",
9931 &(pnoRequest.aNetworks[i].aChannels[j]),
9932 &nOffset))
9933 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9934 "PNO network channel input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309935 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009936 }
9937 /*Advance to next channel number*/
9938 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 }
9940 }
9941
Jeff Johnson02797792013-10-26 19:17:13 -07009942 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009943 &(pnoRequest.aNetworks[i].bcastNetwType),
9944 &nOffset))
9945 {
9946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9947 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309948 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009950
9951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9952 "PNO bcastNetwType %d offset %d",
9953 pnoRequest.aNetworks[i].bcastNetwType,
9954 nOffset );
9955
9956 /*Advance to rssi Threshold*/
9957 ptr += nOffset;
9958
Wilson Yang623f6592013-10-08 16:33:37 -07009959 if (1 != sscanf(ptr,"%hhu %n",
9960 &(pnoRequest.aNetworks[i].rssiThreshold),
9961 &nOffset))
9962 {
9963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9964 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309965 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009967
9968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9969 "PNO rssi %d offset %d",
9970 pnoRequest.aNetworks[i].rssiThreshold,
9971 nOffset );
9972 /*Advance to next network*/
9973 ptr += nOffset;
9974 }/*For ucNetworkCount*/
9975
9976 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009977 &(pnoRequest.scanTimers.ucScanTimersCount),
9978 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009979
9980 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009981 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 {
9983 ptr += nOffset;
9984
Jeff Johnson8301aa12013-03-28 14:27:29 -07009985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9986 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009987 pnoRequest.scanTimers.ucScanTimersCount,
9988 nOffset );
9989
9990 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9991 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309994 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 }
9996
9997 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9998 {
Jeff Johnson02797792013-10-26 19:17:13 -07009999 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10001 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10002 &nOffset);
10003
Wilson Yang623f6592013-10-08 16:33:37 -070010004 if (2 != ucParams)
10005 {
10006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10007 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010008 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010009 }
10010
Jeff Johnson8301aa12013-03-28 14:27:29 -070010011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10012 "PNO Timer value %d Timer repeat %d offset %d",
10013 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10015 nOffset );
10016
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 ptr += nOffset;
10018 }
10019
10020 }
10021 else
10022 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10024 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10026
10027 /*Scan timers defaults to 5 minutes*/
10028 pnoRequest.scanTimers.ucScanTimersCount = 1;
10029 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10030 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10031 }
10032
Wilson Yang623f6592013-10-08 16:33:37 -070010033 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010034
10035 pnoRequest.modePNO = ucMode;
10036 /*for LA we just expose suspend option*/
10037 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10038 {
10039 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10040 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010041 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10042 if (pnoRequest.p24GProbeTemplate == NULL){
10043 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10044 FL("failed to allocate memory p24GProbeTemplate %u"),
10045 SIR_PNO_MAX_PB_REQ_SIZE);
10046 goto error;
10047 }
10048
10049 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10050 if (pnoRequest.p5GProbeTemplate == NULL){
10051 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10052 FL("failed to allocate memory p5GProbeTemplate %u"),
10053 SIR_PNO_MAX_PB_REQ_SIZE);
10054 goto error;
10055 }
10056
10057 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10058 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010059
c_hpothu37f21312014-04-09 21:49:54 +053010060 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 pAdapter->sessionId,
10062 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010063 if (eHAL_STATUS_SUCCESS == status)
10064 {
10065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10066 "%s: PNO enabled", __func__);
10067 return VOS_STATUS_SUCCESS;
10068 }
10069error:
10070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10071 "%s: Failed to enable PNO", __func__);
10072 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010073 if (pnoRequest.aNetworks)
10074 vos_mem_free(pnoRequest.aNetworks);
10075 if (pnoRequest.p24GProbeTemplate)
10076 vos_mem_free(pnoRequest.p24GProbeTemplate);
10077 if (pnoRequest.p5GProbeTemplate)
10078 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +053010079 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010080}/*iw_set_pno*/
10081
10082VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10083 union iwreq_data *wrqu, char *extra, int nOffset)
10084{
10085 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10086 v_U8_t rssiThreshold = 0;
10087 v_U8_t nRead;
10088
Arif Hussain7adce1b2013-11-11 22:59:34 -080010089 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 &rssiThreshold);
10091
10092 if ( 1 != nRead )
10093 {
10094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10095 "Incorrect format");
10096 return VOS_STATUS_E_FAILURE;
10097 }
10098
10099 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10100 return VOS_STATUS_SUCCESS;
10101}
10102
10103
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010104static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 struct iw_request_info *info,
10106 union iwreq_data *wrqu, char *extra)
10107{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010108 hdd_adapter_t *pAdapter;
10109 hdd_context_t *pHddCtx;
10110 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010111 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010112
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010113 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010114 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10115 if (NULL == pAdapter)
10116 {
10117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10118 "%s: Adapter is NULL",__func__);
10119 return -EINVAL;
10120 }
10121
10122 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10123 ret = wlan_hdd_validate_context(pHddCtx);
10124 if (0 != ret)
10125 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010126 return ret;
10127 }
10128
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010129
10130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010132
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010133 status = iw_set_pno(dev,info,wrqu,extra,0);
10134
10135 EXIT();
10136 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010137}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010138
10139static int iw_set_pno_priv(struct net_device *dev,
10140 struct iw_request_info *info,
10141 union iwreq_data *wrqu, char *extra)
10142{
10143 int ret;
10144
10145 vos_ssr_protect(__func__);
10146 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10147 vos_ssr_unprotect(__func__);
10148
10149 return ret;
10150}
Jeff Johnson295189b2012-06-20 16:38:30 -070010151#endif /*FEATURE_WLAN_SCAN_PNO*/
10152
10153//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010154int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010155{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010156 hdd_adapter_t *pAdapter;
10157 tHalHandle hHal;
10158 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010159 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010160 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010161 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010163 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010164 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010165 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010166
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010167 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010168 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10169 if (NULL == pAdapter)
10170 {
10171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10172 "%s: Adapter is NULL",__func__);
10173 return -EINVAL;
10174 }
10175 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10176 retval = wlan_hdd_validate_context(pHddCtx);
10177 if (0 != retval)
10178 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010179 return retval;
10180 }
10181 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10182 if (NULL == hHal)
10183 {
10184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10185 "%s: Hal Context is NULL",__func__);
10186 return -EINVAL;
10187 }
10188 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010189
Atul Mittal54378cb2014-04-02 16:51:50 +053010190 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 {
10192 case WLAN_HDD_UI_BAND_AUTO:
10193 band = eCSR_BAND_ALL;
10194 break;
10195 case WLAN_HDD_UI_BAND_5_GHZ:
10196 band = eCSR_BAND_5G;
10197 break;
10198 case WLAN_HDD_UI_BAND_2_4_GHZ:
10199 band = eCSR_BAND_24;
10200 break;
10201 default:
10202 band = eCSR_BAND_MAX;
10203 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010204 connectedBand =
10205 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010206
Atul Mittal54378cb2014-04-02 16:51:50 +053010207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010208 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010209
10210 if (band == eCSR_BAND_MAX)
10211 {
10212 /* Received change band request with invalid band value */
10213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010214 "%s: Invalid band value %u", __func__, ui_band);
10215 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 }
10217
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010218 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010219 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010220 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010222 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010223 band, pHddCtx->cfg_ini->nBandCapability);
10224 return -EIO;
10225 }
10226
Sushant Kaushik1165f872015-03-30 20:25:27 +053010227 if (band == eCSR_BAND_ALL)
10228 {
10229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10230 "received. Setting band same as ini value %d"),
10231 pHddCtx->cfg_ini->nBandCapability);
10232 band = pHddCtx->cfg_ini->nBandCapability;
10233 }
10234
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10236 {
10237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10238 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010239 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 return -EIO;
10241 }
10242
10243 if (currBand != band)
10244 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010245 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010246 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010247 /* Return failure if current country code is world regulatory domain*/
10248 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10249 pMac->scan.countryCodeCurrent[1] == '0') )
10250 {
10251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10252 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010253 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010254 return -EAGAIN;
10255 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010256 }
10257
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 /* Change band request received.
10259 * Abort pending scan requests, flush the existing scan results,
10260 * and change the band capability
10261 */
10262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10263 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010264 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010265
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010266 /* We need to change the band and flush the scan results here itself
10267 * as we may get timeout for disconnection in which we will return
10268 * with out doing any of these
10269 */
10270 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10271 {
10272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10273 "%s: failed to set the band value to %u ",
10274 __func__, band);
10275 return -EINVAL;
10276 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010277 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10278 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010279 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010280 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10281 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010282 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010283 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10284 * information available in NV so to get the channel information from kernel
10285 * we need to send regulatory hint for the currunt country
10286 * And to set the same country again we need to set the dummy country
10287 * first and then the actual country.
10288 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010289#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10290 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10291#else
10292 regulatory_hint_user("00");
10293#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010294 wait_result = wait_for_completion_interruptible_timeout(
10295 &pHddCtx->linux_reg_req,
10296 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10297
10298 /* if the country information does not exist with the kernel,
10299 then the driver callback would not be called */
10300
10301 if (wait_result >= 0)
10302 {
10303 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10304 "runtime country code is found in kernel db");
10305 }
10306 else
10307 {
10308 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10309 "runtime country code is not found"
10310 " in kernel db");
10311 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010312
10313 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010314
10315 /*
10316 * Update 11dcountry and current country here as the hint
10317 * with 00 results in 11d and current country with 00
10318 */
10319 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10320 WNI_CFG_COUNTRY_CODE_LEN);
10321 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10322 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010323#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10324 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10325#else
10326 regulatory_hint_user(curr_country);
10327#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010328 wait_result = wait_for_completion_interruptible_timeout(
10329 &pHddCtx->linux_reg_req,
10330 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10331
10332 /* if the country information does not exist with the kernel,
10333 then the driver callback would not be called */
10334 if (wait_result >= 0)
10335 {
10336 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10337 "runtime country code is found in kernel db");
10338 }
10339 else
10340 {
10341 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10342 "runtime country code is not found"
10343 " in kernel db");
10344 }
10345
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010346 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010347 }
10348 else
10349 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010350#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010351 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10352 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010353#else
10354 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10355#endif
10356
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010357 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010358 pScanInfo = &pHddCtx->scan_info;
10359 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10360 {
10361 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10362 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10363 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010364 sme_FilterScanResults(hHal, pAdapter->sessionId);
10365
10366 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010367 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10368 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010369 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 eHalStatus status = eHAL_STATUS_SUCCESS;
10371 long lrc;
10372
10373 /* STA already connected on current band, So issue disconnect first,
10374 * then change the band*/
10375
10376 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010377 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010378 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010379
Jeff Johnson295189b2012-06-20 16:38:30 -070010380 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10381
10382 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10383 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10384
Jeff Johnson43971f52012-07-17 12:26:56 -070010385 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 {
10387 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010388 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 __func__, (int)status );
10390 return -EINVAL;
10391 }
10392
10393 lrc = wait_for_completion_interruptible_timeout(
10394 &pAdapter->disconnect_comp_var,
10395 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10396
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010397 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010398
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010399 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010400 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010401
10402 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10403 }
10404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010406 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010407 if (TRUE == pHddCtx->isSetBandByNL)
10408 return 0;
10409 else
10410 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010411}
10412
Atul Mittal54378cb2014-04-02 16:51:50 +053010413int hdd_setBand_helper(struct net_device *dev, const char *command)
10414{
10415 u8 band;
10416
10417 /*convert the band value from ascii to integer*/
10418 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10419
10420 return hdd_setBand(dev, band);
10421
10422}
10423
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010424static int __iw_set_band_config(struct net_device *dev,
10425 struct iw_request_info *info,
10426 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010427{
Atul Mittal54378cb2014-04-02 16:51:50 +053010428 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010429
Arif Hussain0273cba2014-01-07 20:58:29 -080010430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010431
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010432 if (!capable(CAP_NET_ADMIN))
10433 {
10434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10435 FL("permission check failed"));
10436 return -EPERM;
10437 }
10438
Atul Mittal54378cb2014-04-02 16:51:50 +053010439 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010440}
10441
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010442static int iw_set_band_config(struct net_device *dev,
10443 struct iw_request_info *info,
10444 union iwreq_data *wrqu, char *extra)
10445{
10446 int ret;
10447
10448 vos_ssr_protect(__func__);
10449 ret = __iw_set_band_config(dev, info, wrqu, extra);
10450 vos_ssr_unprotect(__func__);
10451
10452 return ret;
10453}
10454
c_manjeecfd1efb2015-09-25 19:32:34 +053010455static int get_fwr_memdump(struct net_device *dev,
10456 struct iw_request_info *info,
10457 union iwreq_data *wrqu, char *extra)
10458{
10459 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10460 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10461 int ret;
10462 ENTER();
10463 // HddCtx sanity
10464 ret = wlan_hdd_validate_context(pHddCtx);
10465 if (0 != ret)
10466 {
10467 return ret;
10468 }
10469 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10470 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10471 {
10472 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10473 return -EINVAL;
10474 }
10475 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10476
10477 EXIT();
10478 return ret;
10479}
10480
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010481static int __iw_set_power_params_priv(struct net_device *dev,
10482 struct iw_request_info *info,
10483 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010484{
Arif Hussain0273cba2014-01-07 20:58:29 -080010485 int ret;
10486 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010487
Jeff Johnson295189b2012-06-20 16:38:30 -070010488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10489 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010490
10491 if (!capable(CAP_NET_ADMIN))
10492 {
10493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10494 FL("permission check failed"));
10495 return -EPERM;
10496 }
10497
Arif Hussain0273cba2014-01-07 20:58:29 -080010498 /* ODD number is used for set, copy data using copy_from_user */
10499 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10500 wrqu->data.length);
10501 if (NULL == ptr)
10502 {
10503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10504 "mem_alloc_copy_from_user_helper fail");
10505 return -ENOMEM;
10506 }
10507
10508 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10509 kfree(ptr);
10510 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010511}
10512
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010513static int iw_set_power_params_priv(struct net_device *dev,
10514 struct iw_request_info *info,
10515 union iwreq_data *wrqu, char *extra)
10516{
10517 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010518
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010519 vos_ssr_protect(__func__);
10520 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10521 vos_ssr_unprotect(__func__);
10522
10523 return ret;
10524}
Jeff Johnson295189b2012-06-20 16:38:30 -070010525
10526/*string based input*/
10527VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10528 union iwreq_data *wrqu, char *extra, int nOffset)
10529{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010530 hdd_adapter_t *pAdapter;
10531 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 tSirSetPowerParamsReq powerRequest;
10533 char *ptr;
10534 v_U8_t ucType;
10535 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010536 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010538 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010539 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10540 if (NULL == pAdapter)
10541 {
10542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10543 "%s: Adapter is NULL",__func__);
10544 return -EINVAL;
10545 }
10546
10547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10548 ret = wlan_hdd_validate_context(pHddCtx);
10549 if (0 != ret)
10550 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010551 return ret;
10552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10554 "Power Params data len %d data %s",
10555 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010556 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010557
10558 if (wrqu->data.length <= nOffset )
10559 {
10560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10561 return VOS_STATUS_E_FAILURE;
10562 }
10563
10564 uTotalSize = wrqu->data.length - nOffset;
10565
10566 /*-----------------------------------------------------------------------
10567 Input is string based and expected to be like this:
10568
10569 <param_type> <param_value> <param_type> <param_value> ...
10570
10571 e.g:
10572 1 2 2 3 3 0 4 1 5 1
10573
10574 e.g. setting just a few:
10575 1 2 4 1
10576
10577 parameter types:
10578 -----------------------------
10579 1 - Ignore DTIM
10580 2 - Listen Interval
10581 3 - Broadcast Multicas Filter
10582 4 - Beacon Early Termination
10583 5 - Beacon Early Termination Interval
10584 -----------------------------------------------------------------------*/
10585 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10586 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10587 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10588 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10589 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10590
Arif Hussain7adce1b2013-11-11 22:59:34 -080010591 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010592
10593 while ( uTotalSize )
10594 {
Wilson Yang6f971452013-10-08 15:00:00 -070010595 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10596 {
10597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10598 "Invalid input parameter type %s",ptr);
10599 return VOS_STATUS_E_FAILURE;
10600 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010601
10602 uTotalSize -= nOffset;
10603
10604 if (!uTotalSize)
10605 {
10606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010607 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 ucType, nOffset);
10609 return VOS_STATUS_E_FAILURE;
10610 }
10611
10612 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010613
Jeff Johnson02797792013-10-26 19:17:13 -070010614 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010615 {
10616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10617 "Invalid input parameter value %s",ptr);
10618 return VOS_STATUS_E_FAILURE;
10619 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010620
10621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10622 "Power request parameter %d value %d offset %d",
10623 ucType, uValue, nOffset);
10624
10625 switch (ucType)
10626 {
10627 case eSIR_IGNORE_DTIM:
10628 powerRequest.uIgnoreDTIM = uValue;
10629 break;
10630 case eSIR_LISTEN_INTERVAL:
10631 powerRequest.uListenInterval = uValue;
10632 break;
10633 case eSIR_MCAST_BCAST_FILTER:
10634 powerRequest.uBcastMcastFilter = uValue;
10635 break;
10636 case eSIR_ENABLE_BET:
10637 powerRequest.uEnableBET = uValue;
10638 break;
10639 case eSIR_BET_INTERVAL:
10640 powerRequest.uBETInterval = uValue;
10641 break;
10642 default:
10643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010644 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 ucType, uValue, nOffset);
10646 return VOS_STATUS_E_FAILURE;
10647 }
10648
10649 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10651 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010652 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010654 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010655 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010656 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10657 {
10658 uTotalSize = 0;
10659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010660
10661 }/*Go for as long as we have a valid string*/
10662
10663 /* put the device into full power*/
10664 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10665
10666 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010667 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010668
10669 /* put the device back to power save*/
10670 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10671
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010672 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 return VOS_STATUS_SUCCESS;
10674}/*iw_set_power_params*/
10675
Atul Mittalc0f739f2014-07-31 13:47:47 +053010676// tdlsoffchan
10677#ifdef FEATURE_WLAN_TDLS
10678
Atul Mittal87ec2422014-09-24 13:12:50 +053010679int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010680{
10681 if (offchannel < 0 || offchannel > 165)
10682 {
10683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10684 __func__, offchannel);
10685 return -1;
10686
10687 }
10688
10689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10690 __func__, tdlsOffCh, offchannel);
10691
10692 tdlsOffCh = offchannel;
10693 return 0;
10694}
10695
Atul Mittal87ec2422014-09-24 13:12:50 +053010696int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010697{
10698 if (offchanoffset == 0)
10699 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010700 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10702 __func__, tdlsOffChBwOffset);
10703
10704 return 0;
10705
10706 }
10707
10708 if ( offchanoffset == 40 )
10709 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010710 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10712 __func__, tdlsOffChBwOffset);
10713
10714 return 0;
10715
10716 }
10717 if (offchanoffset == -40)
10718 {
10719 tdlsOffChBwOffset = 3;
10720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10721 __func__, tdlsOffChBwOffset);
10722
10723 return 0;
10724
10725 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010726
10727 if ((offchanoffset == 80) &&
10728 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10729 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10730 {
10731 tdlsOffChBwOffset = 4;
10732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10733 "%s: change tdls secondary off channel offset to %u",
10734 __func__, tdlsOffChBwOffset);
10735
10736 return 0;
10737 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10739 __func__, offchanoffset);
10740 return -1;
10741}
10742
Atul Mittal87ec2422014-09-24 13:12:50 +053010743int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010744{
10745 hddTdlsPeer_t *connPeer = NULL;
10746 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10747 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010748 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010749 if (offchanmode < 0 || offchanmode > 4)
10750 {
10751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10752 "%s: Invalid tdls off channel mode %d",
10753 __func__, offchanmode);
10754 return -1;
10755 }
10756
10757 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10758 {
10759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10760 "%s: tdls off channel mode req in not associated state %d",
10761 __func__, offchanmode);
10762 return -1;
10763 }
10764
10765 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10766 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10767 {
10768 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010769 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010770 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010771 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010772 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10774 "%s: No TDLS Connected Peer", __func__);
10775 return -1;
10776 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010777 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010778 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010779 }
10780 else
10781 {
10782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10783 "%s: TDLS Connection not supported", __func__);
10784 return -1;
10785 }
10786
10787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10788 ("%s: TDLS Channel Switch in swmode=%d"),
10789 __func__, offchanmode);
10790
10791 switch (offchanmode)
10792 {
10793 case 1:/*Enable*/
10794 case 2:/*Disable*/
10795 {
10796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10797 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10798 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10799 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10800 {
10801
10802 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010803 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010804 tdlsOffCh, tdlsOffChBwOffset,
10805 offchanmode);
10806 }
10807 else
10808 {
10809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10810 "%s: TDLS Off Channel not supported", __func__);
10811 return -1;
10812 }
10813 break;
10814 }
10815 case 3:
10816 {
10817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10818 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10819 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10820
10821 break;
10822 }
10823 case 4:
10824 {
10825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10826 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10827 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10828 break;
10829 }
10830 default:
10831 {
10832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10833 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10834 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10835 break;
10836 }
10837
10838 }
10839
10840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10841 __func__, offchanmode);
10842 return 0;
10843}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010844#endif
10845
Jeff Johnson295189b2012-06-20 16:38:30 -070010846
10847// Define the Wireless Extensions to the Linux Network Device structure
10848// A number of these routines are NULL (meaning they are not implemented.)
10849
10850static const iw_handler we_handler[] =
10851{
10852 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10853 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10854 (iw_handler) NULL, /* SIOCSIWNWID */
10855 (iw_handler) NULL, /* SIOCGIWNWID */
10856 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10857 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10858 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10859 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10860 (iw_handler) NULL, /* SIOCSIWSENS */
10861 (iw_handler) NULL, /* SIOCGIWSENS */
10862 (iw_handler) NULL, /* SIOCSIWRANGE */
10863 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010864 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 (iw_handler) NULL, /* SIOCGIWPRIV */
10866 (iw_handler) NULL, /* SIOCSIWSTATS */
10867 (iw_handler) NULL, /* SIOCGIWSTATS */
10868 iw_handler_set_spy, /* SIOCSIWSPY */
10869 iw_handler_get_spy, /* SIOCGIWSPY */
10870 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10871 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10872 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10873 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10874 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10875 (iw_handler) NULL, /* SIOCGIWAPLIST */
10876 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10877 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10878 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10879 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10880 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10881 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10882 (iw_handler) NULL, /* -- hole -- */
10883 (iw_handler) NULL, /* -- hole -- */
10884 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10885 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10886 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10887 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10888 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10889 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10890 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10891 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10892 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10893 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10894 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10895 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10896 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10897 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10898 (iw_handler) NULL, /* -- hole -- */
10899 (iw_handler) NULL, /* -- hole -- */
10900 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10901 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10902 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10903 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10904 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10905 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10906 (iw_handler) NULL, /* SIOCSIWPMKSA */
10907};
10908
10909static const iw_handler we_private[] = {
10910
10911 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10912 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10913 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10914 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10915 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10916 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010917 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010918 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10919 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10920 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010921#ifdef FEATURE_OEM_DATA_SUPPORT
10922 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10923 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010925
Jeff Johnson295189b2012-06-20 16:38:30 -070010926#ifdef WLAN_FEATURE_VOWIFI_11R
10927 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10928#endif
10929 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10930 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10931 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10932#ifdef WLAN_FEATURE_PACKET_FILTERING
10933 ,
10934 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10935#endif
10936#ifdef FEATURE_WLAN_SCAN_PNO
10937 ,
10938 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10939#endif
10940 ,
10941 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10942 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10943 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10944 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010945 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010946};
10947
10948/*Maximum command length can be only 15 */
10949static const struct iw_priv_args we_private_args[] = {
10950
Katya Nigamf0511f62015-05-05 16:40:57 +053010951 { WE_SET_MONITOR_STATE,
10952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10953 0, "monitor" },
10954
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 /* handlers for main ioctl */
10956 { WLAN_PRIV_SET_INT_GET_NONE,
10957 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10958 0,
10959 "" },
10960
10961 /* handlers for sub-ioctl */
10962 { WE_SET_11D_STATE,
10963 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10964 0,
10965 "set11Dstate" },
10966
10967 { WE_WOWL,
10968 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10969 0,
10970 "wowl" },
10971
10972 { WE_SET_POWER,
10973 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10974 0,
10975 "setPower" },
10976
10977 { WE_SET_MAX_ASSOC,
10978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10979 0,
10980 "setMaxAssoc" },
10981
10982 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10984 0,
10985 "setAutoChannel" },
10986
10987 { WE_SET_DATA_INACTIVITY_TO,
10988 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10989 0,
10990 "inactivityTO" },
10991
10992 { WE_SET_MAX_TX_POWER,
10993 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10994 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010995 "setMaxTxPower" },
10996
10997 { WE_SET_MAX_TX_POWER_2_4,
10998 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10999 0,
11000 "setTxMaxPower2G" },
11001
11002 { WE_SET_MAX_TX_POWER_5_0,
11003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11004 0,
11005 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011006
11007 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11008 * as well to keep same syntax as in SAP. Now onwards, STA
11009 * will support both */
11010 { WE_SET_MAX_TX_POWER,
11011 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11012 0,
11013 "setTxMaxPower" },
11014
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11016 * 1 = enable and 0 = disable */
11017 {
11018 WE_SET_HIGHER_DTIM_TRANSITION,
11019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11020 0,
11021 "setHDtimTransn" },
11022
11023 { WE_SET_TM_LEVEL,
11024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011025 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 "setTmLevel" },
11027
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011028 { WE_ENABLE_STRICT_FCC_REG,
11029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11030 0,
11031 "setStrictFCCreg" },
11032
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011033 { WE_SET_DEBUG_LOG,
11034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11035 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011036#ifdef FEATURE_WLAN_TDLS
11037 {
11038 WE_SET_TDLS_OFF_CHAN,
11039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11040 0,
11041 "tdlsoffchan" },
11042 {
11043 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11045 0,
11046 "tdlsecchnoffst" },
11047 {
11048 WE_SET_TDLS_OFF_CHAN_MODE,
11049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11050 0,
11051 "tdlsoffchnmode" },
11052#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011053
Peng Xu2446a892014-09-05 17:21:18 +053011054 { WE_SET_SCAN_BAND_PREFERENCE,
11055 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11056 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011057 {
11058 WE_GET_FRAME_LOG,
11059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11060 0,
11061 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011062
Abhishek Singh01c73d12015-03-12 15:13:44 +053011063 { WE_SET_MIRACAST_VENDOR_CONFIG,
11064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11065 0, "setMiracstConf" },
11066
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011067#ifdef FEATURE_WLAN_TDLS
11068 {
11069 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11071 0,
11072 "tdls_2040bsscox" },
11073#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011074 { WE_SET_RTS_CTS_HTVHT,
11075 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11076 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011077 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11079 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011080 { WE_SET_PROXIMITY_ENABLE,
11081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11082 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 /* handlers for main ioctl */
11084 { WLAN_PRIV_SET_NONE_GET_INT,
11085 0,
11086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11087 "" },
11088
11089 /* handlers for sub-ioctl */
11090 { WE_GET_11D_STATE,
11091 0,
11092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11093 "get11Dstate" },
11094
11095 { WE_IBSS_STATUS,
11096 0,
11097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11098 "getAdhocStatus" },
11099
11100 { WE_PMC_STATE,
11101 0,
11102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11103 "pmcState" },
11104
11105 { WE_GET_WLAN_DBG,
11106 0,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11108 "getwlandbg" },
11109
Jeff Johnson295189b2012-06-20 16:38:30 -070011110 { WE_GET_MAX_ASSOC,
11111 0,
11112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11113 "getMaxAssoc" },
11114
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 { WE_GET_WDI_DBG,
11116 0,
11117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11118 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011119
11120 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11121 0,
11122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11123 "getAutoChannel" },
11124
11125 { WE_GET_CONCURRENCY_MODE,
11126 0,
11127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11128 "getconcurrency" },
11129
Peng Xu2446a892014-09-05 17:21:18 +053011130 { WE_GET_SCAN_BAND_PREFERENCE,
11131 0,
11132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11133 "get_scan_pref"},
11134
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011135 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11136 0,
11137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11138 "getCurAnt"},
11139
Jeff Johnson295189b2012-06-20 16:38:30 -070011140 /* handlers for main ioctl */
11141 { WLAN_PRIV_SET_CHAR_GET_NONE,
11142 IW_PRIV_TYPE_CHAR| 512,
11143 0,
11144 "" },
11145
11146 /* handlers for sub-ioctl */
11147 { WE_WOWL_ADD_PTRN,
11148 IW_PRIV_TYPE_CHAR| 512,
11149 0,
11150 "wowlAddPtrn" },
11151
11152 { WE_WOWL_DEL_PTRN,
11153 IW_PRIV_TYPE_CHAR| 512,
11154 0,
11155 "wowlDelPtrn" },
11156
11157#if defined WLAN_FEATURE_VOWIFI
11158 /* handlers for sub-ioctl */
11159 { WE_NEIGHBOR_REPORT_REQUEST,
11160 IW_PRIV_TYPE_CHAR | 512,
11161 0,
11162 "neighbor" },
11163#endif
11164 { WE_SET_AP_WPS_IE,
11165 IW_PRIV_TYPE_CHAR| 512,
11166 0,
11167 "set_ap_wps_ie" },
11168
11169 { WE_SET_CONFIG,
11170 IW_PRIV_TYPE_CHAR| 512,
11171 0,
11172 "setConfig" },
11173
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011174 { WE_SET_ENCRYPT_MSG,
11175 IW_PRIV_TYPE_CHAR| 512,
11176 0,
11177 "encryptMsg" },
11178
11179
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 /* handlers for main ioctl */
11181 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11182 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11183 0,
11184 "" },
11185
11186 /* handlers for sub-ioctl */
11187 { WE_SET_WLAN_DBG,
11188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11189 0,
11190 "setwlandbg" },
11191
Jeff Johnson295189b2012-06-20 16:38:30 -070011192 { WE_SET_WDI_DBG,
11193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11194 0,
11195 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011196
11197 { WE_SET_SAP_CHANNELS,
11198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11199 0,
11200 "setsapchannels" },
11201
11202 /* handlers for main ioctl */
11203 { WLAN_PRIV_GET_CHAR_SET_NONE,
11204 0,
11205 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11206 "" },
11207
11208 /* handlers for sub-ioctl */
11209 { WE_WLAN_VERSION,
11210 0,
11211 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11212 "version" },
11213 { WE_GET_STATS,
11214 0,
11215 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11216 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011217 { WE_GET_STATES,
11218 0,
11219 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11220 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 { WE_GET_CFG,
11222 0,
11223 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11224 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011225#ifdef WLAN_FEATURE_11AC
11226 { WE_GET_RSSI,
11227 0,
11228 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11229 "getRSSI" },
11230#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011231#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011232 { WE_GET_ROAM_RSSI,
11233 0,
11234 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11235 "getRoamRSSI" },
11236#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011237 { WE_GET_WMM_STATUS,
11238 0,
11239 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11240 "getWmmStatus" },
11241 {
11242 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011243 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11245 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011246#ifdef FEATURE_WLAN_TDLS
11247 {
11248 WE_GET_TDLS_PEERS,
11249 0,
11250 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11251 "getTdlsPeers" },
11252#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011253#ifdef WLAN_FEATURE_11W
11254 {
11255 WE_GET_11W_INFO,
11256 0,
11257 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11258 "getPMFInfo" },
11259#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011260#ifdef WLAN_FEATURE_RMC
11261 {
11262 WE_GET_IBSS_STA_INFO,
11263 0,
11264 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11265 "getIbssSTAs" },
11266#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011267 { WE_GET_SNR,
11268 0,
11269 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11270 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011271#ifdef FEATURE_OEM_DATA_SUPPORT
11272 {
11273 WE_GET_OEM_DATA_CAP,
11274 0,
11275 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11276 "getOemDataCap" },
11277#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 /* handlers for main ioctl */
11279 { WLAN_PRIV_SET_NONE_GET_NONE,
11280 0,
11281 0,
11282 "" },
11283
11284 /* handlers for sub-ioctl */
11285 { WE_CLEAR_STATS,
11286 0,
11287 0,
11288 "clearStats" },
11289 { WE_INIT_AP,
11290 0,
11291 0,
11292 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011293#ifdef WLAN_FEATURE_RMC
11294 {
11295 WE_IBSS_GET_PEER_INFO_ALL,
11296 0,
11297 0,
11298 "ibssPeerInfoAll" },
11299#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 { WE_STOP_AP,
11301 0,
11302 0,
11303 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011304#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011305 { WE_ENABLE_AMP,
11306 0,
11307 0,
11308 "enableAMP" },
11309 { WE_DISABLE_AMP,
11310 0,
11311 0,
11312 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011313#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011314 { WE_ENABLE_DXE_STALL_DETECT,
11315 0,
11316 0,
11317 "dxeStallDetect" },
11318 { WE_DISPLAY_DXE_SNAP_SHOT,
11319 0,
11320 0,
11321 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011322 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11323 0,
11324 0,
11325 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011326 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011327 WE_SET_REASSOC_TRIGGER,
11328 0,
11329 0,
11330 "reassoc" },
11331 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011332 WE_STOP_OBSS_SCAN,
11333 0,
11334 0,
11335 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011336 {
11337 WE_DUMP_ROAM_TIMER_LOG,
11338 0,
11339 0,
11340 "dumpRoamDelay" },
11341 {
11342 WE_RESET_ROAM_TIMER_LOG,
11343 0,
11344 0,
11345 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011346 {
11347 WE_GET_FW_LOGS,
11348 0,
11349 0,
11350 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011351 {
11352 WE_GET_FW_MEMDUMP,
11353 0,
11354 0,
11355 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 /* handlers for main ioctl */
11357 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11358 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11359 0,
11360 "" },
11361
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011362
11363
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 /* handlers for sub-ioctl */
11365 { WE_LOG_DUMP_CMD,
11366 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11367 0,
11368 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011369#ifdef WLAN_FEATURE_RMC
11370 { WE_IBSS_GET_PEER_INFO,
11371 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11372 0,
11373 "ibssPeerInfo" },
11374#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011375
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011376 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011377 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11378 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11379 0,
11380 "setdumplog" },
11381
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011382 { WE_MTRACE_DUMP_CMD,
11383 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11384 0,
11385 "dumplog" },
11386
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011387 /* handlers for sub ioctl */
11388 {
11389 WE_MCC_CONFIG_CREDENTIAL,
11390 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11391 0,
11392 "setMccCrdnl" },
11393
11394 /* handlers for sub ioctl */
11395 {
11396 WE_MCC_CONFIG_PARAMS,
11397 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11398 0,
11399 "setMccConfig" },
11400
Chilam NG571c65a2013-01-19 12:27:36 +053011401#ifdef FEATURE_WLAN_TDLS
11402 /* handlers for sub ioctl */
11403 {
11404 WE_TDLS_CONFIG_PARAMS,
11405 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11406 0,
11407 "setTdlsConfig" },
11408#endif
11409
Katya Nigamf0511f62015-05-05 16:40:57 +053011410 {
11411 WE_CONFIGURE_MONITOR_MODE,
11412 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11413 0,
11414 "MonitorModeConf" },
11415
11416 {
11417 WE_SET_MONITOR_MODE_FILTER,
11418 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11419 0,
11420 "MonitorFilter" },
11421
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 /* handlers for main ioctl */
11423 { WLAN_PRIV_ADD_TSPEC,
11424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11425 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11426 "addTspec" },
11427
11428 /* handlers for main ioctl */
11429 { WLAN_PRIV_DEL_TSPEC,
11430 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11432 "delTspec" },
11433
11434 /* handlers for main ioctl */
11435 { WLAN_PRIV_GET_TSPEC,
11436 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11438 "getTspec" },
11439
Jeff Johnsone7245742012-09-05 17:12:55 -070011440#ifdef FEATURE_OEM_DATA_SUPPORT
11441 /* handlers for main ioctl - OEM DATA */
11442 {
11443 WLAN_PRIV_SET_OEM_DATA_REQ,
11444 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11445 0,
11446 "set_oem_data_req" },
11447
11448 /* handlers for main ioctl - OEM DATA */
11449 {
11450 WLAN_PRIV_GET_OEM_DATA_RSP,
11451 0,
11452 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11453 "get_oem_data_rsp" },
11454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011455
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 /* handlers for main ioctl - host offload */
11457 {
11458 WLAN_PRIV_SET_HOST_OFFLOAD,
11459 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11460 0,
11461 "setHostOffload" },
11462
11463 {
11464 WLAN_GET_WLAN_STATISTICS,
11465 0,
11466 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11467 "getWlanStats" },
11468
11469 {
11470 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011471 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11472 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 0,
11474 "setKeepAlive" },
11475#ifdef WLAN_FEATURE_PACKET_FILTERING
11476 {
11477 WLAN_SET_PACKET_FILTER_PARAMS,
11478 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11479 0,
11480 "setPktFilter" },
11481#endif
11482#ifdef FEATURE_WLAN_SCAN_PNO
11483 {
11484 WLAN_SET_PNO,
11485 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11486 0,
11487 "setpno" },
11488#endif
11489 {
11490 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011491 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 0,
11493 "SETBAND" },
11494 /* handlers for dynamic MC BC ioctl */
11495 {
11496 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011497 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 0,
11499 "setMCBCFilter" },
11500 {
11501 WLAN_PRIV_CLEAR_MCBC_FILTER,
11502 0,
11503 0,
11504 "clearMCBCFilter" },
11505 {
11506 WLAN_SET_POWER_PARAMS,
11507 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11508 0,
11509 "setpowerparams" },
11510 {
11511 WLAN_GET_LINK_SPEED,
11512 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011513 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011514};
11515
11516
11517
11518const struct iw_handler_def we_handler_def = {
11519 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11520 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11521 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11522
11523 .standard = (iw_handler *)we_handler,
11524 .private = (iw_handler *)we_private,
11525 .private_args = we_private_args,
11526 .get_wireless_stats = get_wireless_stats,
11527};
11528
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011529int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11530{
11531 v_U32_t cmd = 288; //Command to RIVA
11532 hdd_context_t *pHddCtx = NULL;
11533 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11534 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11535 /*
11536 *configMccParam : specify the bit which needs to be modified
11537 *allowed to update based on wlan_qcom_cfg.ini
11538 * configuration
11539 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11540 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11541 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11542 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11543 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11544 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11545 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11546 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11547 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11548 * Bit 9 : Reserved
11549 */
11550 switch (arg1)
11551 {
11552 //Update MCC SCHEDULE_TIME_SLICE parameter
11553 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11554 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11555 {
11556 if((arg2 >= 5) && (arg2 <= 20))
11557 {
11558 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11559 }
11560 else
11561 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011562 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011563 return 0;
11564 }
11565 }
11566 break;
11567
11568 //Update MCC MAX_NULL_SEND_TIME parameter
11569 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11570 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11571 {
11572 if((arg2 >= 1) && (arg2 <= 10))
11573 {
11574 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11575 }
11576 else
11577 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011578 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011579 return 0;
11580 }
11581 }
11582 break;
11583
11584 //Update MCC TX_EARLY_STOP_TIME parameter
11585 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11586 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11587 {
11588 if((arg2 >= 1) && (arg2 <= 10))
11589 {
11590 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11591 }
11592 else
11593 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011594 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011595 return 0;
11596 }
11597 }
11598 break;
11599
11600 //Update MCC RX_DRAIN_TIME parameter
11601 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11602 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11603 {
11604 if((arg2 >= 1) && (arg2 <= 10))
11605 {
11606 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11607 }
11608 else
11609 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011610 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011611 return 0;
11612 }
11613 }
11614 break;
11615
11616 //Update MCC CHANNEL_SWITCH_TIME parameter
11617 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11618 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11619 {
11620 if((arg2 >= 1) && (arg2 <= 20))
11621 {
11622 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11623 }
11624 else
11625 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011626 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011627 return 0;
11628 }
11629 }
11630 break;
11631
11632 //Update MCC MIN_CHANNEL_TIME parameter
11633 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11634 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11635 {
11636 if((arg2 >= 5) && (arg2 <= 20))
11637 {
11638 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11639 }
11640 else
11641 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011642 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011643 return 0;
11644 }
11645 }
11646 break;
11647
11648 //Update MCC PARK_BEFORE_TBTT parameter
11649 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11650 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11651 {
11652 if((arg2 >= 1) && (arg2 <= 5))
11653 {
11654 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11655 }
11656 else
11657 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011658 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011659 return 0;
11660 }
11661 }
11662 break;
11663
11664 //Update MCC MIN_AFTER_DTIM parameter
11665 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11666 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11667 {
11668 if((arg2 >= 5) && (arg2 <= 15))
11669 {
11670 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11671 }
11672 else
11673 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011674 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011675 return 0;
11676 }
11677 }
11678 break;
11679
11680 //Update MCC TOO_CLOSE_MARGIN parameter
11681 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11682 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11683 {
11684 if((arg2 >= 1) && (arg2 <= 3))
11685 {
11686 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11687 }
11688 else
11689 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011690 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011691 return 0;
11692 }
11693 }
11694 break;
11695
11696 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011697 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011698 __FUNCTION__,arg1);
11699 break;
11700 }
11701 return 0;
11702}
11703
Jeff Johnson295189b2012-06-20 16:38:30 -070011704int hdd_set_wext(hdd_adapter_t *pAdapter)
11705{
11706 hdd_wext_state_t *pwextBuf;
11707 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011708 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011709
11710 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11711
11712 // Now configure the roaming profile links. To SSID and bssid.
11713 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11714 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11715
11716 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11717 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11718
11719 /*Set the numOfChannels to zero to scan all the channels*/
11720 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11721 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11722
11723 /* Default is no encryption */
11724 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11725 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11726
11727 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11728 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11729
11730 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11731
11732 /* Default is no authentication */
11733 pwextBuf->roamProfile.AuthType.numEntries = 1;
11734 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11735
11736 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11737 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11738
11739 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011740 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011741
11742 hdd_clearRoamProfileIe(pAdapter);
11743
11744 return VOS_STATUS_SUCCESS;
11745
11746 }
11747
11748int hdd_register_wext(struct net_device *dev)
11749 {
11750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11751 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11752 VOS_STATUS status;
11753
11754 ENTER();
11755
11756 // Zero the memory. This zeros the profile structure.
11757 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11758
11759 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11760
11761
11762 status = hdd_set_wext(pAdapter);
11763
11764 if(!VOS_IS_STATUS_SUCCESS(status)) {
11765
Arif Hussain6d2a3322013-11-17 19:50:10 -080011766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 return eHAL_STATUS_FAILURE;
11768 }
11769
11770 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11771 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011773 return eHAL_STATUS_FAILURE;
11774 }
11775
11776 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11777 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 return eHAL_STATUS_FAILURE;
11780 }
11781
11782 // Register as a wireless device
11783 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11784
11785 EXIT();
11786 return 0;
11787}
11788
11789int hdd_UnregisterWext(struct net_device *dev)
11790{
c_hpothu2a13bc32015-01-21 12:48:54 +053011791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11792 if (dev != NULL)
11793 {
11794 rtnl_lock();
11795 dev->wireless_handlers = NULL;
11796 rtnl_unlock();
11797 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011798
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 return 0;
11800}
11801
11802