blob: 60befd9047d69ee04f7dc7f2189c0991627944cc [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530176#define WE_SET_PROXIMITY_ENABLE 24
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
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301541 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001542#ifdef WLAN_FEATURE_11W
1543 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1544 pWextState->roamProfile.MFPRequired = 0;
1545 pWextState->roamProfile.MFPCapable = 0;
1546#endif
1547
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 pWextState->authKeyMgmt = 0;
1549
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301550 vos_mem_zero(&pWextState->roamProfile.Keys,
1551 sizeof(pWextState->roamProfile.Keys));
1552
Jeff Johnson295189b2012-06-20 16:38:30 -07001553#ifdef FEATURE_WLAN_WAPI
1554 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1555 pAdapter->wapi_info.nWapiMode = 0;
1556#endif
1557
1558 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1559
1560}
1561
1562void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1563{
1564 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001565
Nirav Shahf6bd2672015-03-11 12:53:15 +05301566 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001567 {
1568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301569 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001570 }
1571 else
1572 {
1573 complete(&pAdapter->ula_complete);
1574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001575}
1576
1577VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1578{
1579 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001581 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
1583 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1584 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001585 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001586
1587 /*To avoid race condition between the set key and the last EAPOL
1588 packet, notify TL to finish upper layer authentication incase if the
1589 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001590 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001591
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001592 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 {
1594 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1595 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1596 __LINE__, vos_status );
1597 return vos_status;
1598
1599 }
1600
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001601 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301603 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001604 {
1605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301606 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001607 /* we'll still fall through and return success since the
1608 * connection may still get established but is just taking
1609 * too long for us to wait */
1610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 }
1612 return VOS_STATUS_SUCCESS;
1613}
1614
1615v_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)
1616{
1617
1618 int left = ie_len;
1619 v_U8_t *ptr = ie;
1620 v_U8_t elem_id,elem_len;
1621 v_U8_t eid = 0xDD;
1622
1623 if ( NULL == ie || 0 == ie_len )
1624 return NULL;
1625
1626 while(left >= 2)
1627 {
1628 elem_id = ptr[0];
1629 elem_len = ptr[1];
1630 left -= 2;
1631 if(elem_len > left)
1632 {
1633 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001634 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 eid,elem_len,left);
1636 return NULL;
1637 }
1638 if (elem_id == eid)
1639 {
1640 if(memcmp( &ptr[2], oui, oui_size)==0)
1641 return ptr;
1642 }
1643
1644 left -= elem_len;
1645 ptr += (elem_len + 2);
1646 }
1647 return NULL;
1648}
1649
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301650static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 union iwreq_data *wrqu, char *extra)
1652{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301653 hdd_adapter_t *pAdapter;
1654 hdd_context_t *pHddCtx;
1655 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301656
1657 ENTER();
1658
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301659 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1660 if (NULL == pAdapter)
1661 {
1662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1663 "%s: pAdapter is NULL\n", __func__);
1664 return -EINVAL;
1665 }
1666 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1667 ret = wlan_hdd_validate_context(pHddCtx);
1668 if (0 != ret)
1669 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301670 return ret;
1671 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301672
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301674
1675 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301676 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001677}
1678
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301679static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1680 union iwreq_data *wrqu, char *extra)
1681{
1682 int ret;
1683
1684 vos_ssr_protect(__func__);
1685 ret = __iw_set_commit(dev, info, wrqu, extra);
1686 vos_ssr_unprotect(__func__);
1687
1688 return ret;
1689}
1690
1691static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 struct iw_request_info *info,
1693 char *wrqu, char *extra)
1694{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301695 hdd_adapter_t *pAdapter;
1696 hdd_context_t *pHddCtx;
1697 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301698
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301700 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1701 if (NULL == pAdapter)
1702 {
1703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1704 "%s: pAdapter is NULL\n", __func__);
1705 return -EINVAL;
1706 }
1707 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1708 ret = wlan_hdd_validate_context(pHddCtx);
1709 if (0 != ret)
1710 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301711 return ret;
1712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1714 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301715 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001716}
1717
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301718static int iw_get_name(struct net_device *dev,
1719 struct iw_request_info *info,
1720 char *wrqu, char *extra)
1721{
1722 int ret;
1723
1724 vos_ssr_protect(__func__);
1725 ret = __iw_get_name(dev, info, wrqu, extra);
1726 vos_ssr_unprotect(__func__);
1727
1728 return ret;
1729}
1730
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301731static int __iw_set_mode(struct net_device *dev,
1732 struct iw_request_info *info,
1733 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001734{
1735 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301736 hdd_adapter_t *pAdapter;
1737 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 tCsrRoamProfile *pRoamProfile;
1739 eCsrRoamBssType LastBSSType;
1740 eMib_dot11DesiredBssType connectedBssType;
1741 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301743 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001744
1745 ENTER();
1746
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301747 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 if (NULL == pAdapter)
1749 {
1750 hddLog(VOS_TRACE_LEVEL_WARN,
1751 "%s: Invalid context, pAdapter", __func__);
1752 return 0;
1753 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301754 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1755 status = wlan_hdd_validate_context(pHddCtx);
1756 if (0 != status)
1757 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301758 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 }
1760
1761 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1762 if (pWextState == NULL)
1763 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301764 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 return -EINVAL;
1766 }
1767
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 pRoamProfile = &pWextState->roamProfile;
1770 LastBSSType = pRoamProfile->BSSType;
1771
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301772 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773
1774 switch (wrqu->mode)
1775 {
1776 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301777 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1779 // Set the phymode correctly for IBSS.
1780 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1781 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001782 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 break;
1785 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301786 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 break;
1790 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301791 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1793 break;
1794 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301795 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 return -EOPNOTSUPP;
1797 }
1798
1799 if ( LastBSSType != pRoamProfile->BSSType )
1800 {
1801 //the BSS mode changed
1802 // We need to issue disconnect if connected or in IBSS disconnect state
1803 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1804 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1805 {
1806 VOS_STATUS vosStatus;
1807 // need to issue a disconnect to CSR.
1808 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1809 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1810 pAdapter->sessionId,
1811 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1812 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301813 {
1814 long ret;
1815 ret = wait_for_completion_interruptible_timeout(
1816 &pAdapter->disconnect_comp_var,
1817 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1818 if (ret <= 0)
1819 hddLog(VOS_TRACE_LEVEL_ERROR,
1820 FL("failed wait on disconnect_comp_var %ld"), ret);
1821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 }
1823 }
1824
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 EXIT();
1826 return 0;
1827}
1828
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301829static int iw_set_mode(struct net_device *dev,
1830 struct iw_request_info *info,
1831 union iwreq_data *wrqu, char *extra)
1832{
1833 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001834
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301835 vos_ssr_protect(__func__);
1836 ret = __iw_set_mode(dev, info, wrqu, extra);
1837 vos_ssr_unprotect(__func__);
1838
1839 return ret;
1840}
1841
1842static int __iw_get_mode(struct net_device *dev,
1843 struct iw_request_info *info,
1844 union iwreq_data *wrqu,
1845 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001846{
1847
1848 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301849 hdd_adapter_t *pAdapter;
1850 hdd_context_t *pHddCtx;
1851 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001852
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301853 ENTER();
1854
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301855 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 if (NULL == pAdapter)
1857 {
1858 hddLog(VOS_TRACE_LEVEL_WARN,
1859 "%s: Invalid context, pAdapter", __func__);
1860 return 0;
1861 }
1862
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301863 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1864 ret = wlan_hdd_validate_context(pHddCtx);
1865 if (0 != ret)
1866 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301867 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1870 if (pWextState == NULL)
1871 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301872 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 return -EINVAL;
1874 }
1875
1876 switch (pWextState->roamProfile.BSSType)
1877 {
1878 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001879 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301880 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 break;
1882 case eCSR_BSS_TYPE_IBSS:
1883 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001884 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301885 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 break;
1887 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001888 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301889 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 break;
1891 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001892 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 break;
1894 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301895
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301896 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 return 0;
1898}
1899
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301900static int iw_get_mode(struct net_device *dev,
1901 struct iw_request_info *info,
1902 union iwreq_data *wrqu,
1903 char *extra)
1904{
1905 int ret;
1906
1907 vos_ssr_protect(__func__);
1908 ret = __iw_get_mode(dev, info, wrqu, extra);
1909 vos_ssr_unprotect(__func__);
1910
1911 return ret;
1912}
1913
1914static int __iw_set_freq(struct net_device *dev,
1915 struct iw_request_info *info,
1916 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001917{
1918 v_U32_t numChans = 0;
1919 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1920 v_U32_t indx = 0;
1921 v_U32_t status = 0;
1922
1923 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301924 hdd_adapter_t *pAdapter;
1925 hdd_context_t *pHddCtx;
1926 tHalHandle hHal;
1927 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301929
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 ENTER();
1931
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301932 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1933 if (NULL == pAdapter)
1934 {
1935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1936 "%s:Invalid Adapter",__func__);
1937 return -EINVAL;
1938 }
1939
1940 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1941 status = wlan_hdd_validate_context(pHddCtx);
1942 if (0 != status)
1943 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 return status;
1945 }
1946
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301947 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1948 if (NULL == hHal)
1949 {
1950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1951 "%s: Hal Context is NULL",__func__);
1952 return -EINVAL;
1953 }
1954
1955 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1956 if (NULL == pHddStaCtx)
1957 {
1958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1959 "%s:STA context is NULL",__func__);
1960 return -EINVAL;
1961 }
1962
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301964 if (NULL == pWextState)
1965 {
1966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1967 "%s: pWextState is NULL",__func__);
1968 return -EINVAL;
1969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
1971 pRoamProfile = &pWextState->roamProfile;
1972
Arif Hussain6d2a3322013-11-17 19:50:10 -08001973 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001974
1975 /* Link is up then return cant set channel*/
1976 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1977 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1978 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001979 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 return -EOPNOTSUPP;
1981 }
1982
1983 /* Settings by Frequency as input */
1984 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1985 (wrqu->freq.m <= (tANI_U32)5.825e8))
1986 {
1987 tANI_U32 freq = wrqu->freq.m / 100000;
1988
1989 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1990 indx++;
1991 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1992 {
1993 return -EINVAL;
1994 }
1995 wrqu->freq.e = 0;
1996 wrqu->freq.m = freq_chan_map[indx].chan;
1997
1998 }
1999
2000 if (wrqu->freq.e == 0)
2001 {
2002 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2003 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
2004 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002005 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002006 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 WNI_CFG_CURRENT_CHANNEL_STAMAX);
2008 return -EINVAL;
2009 }
2010
2011 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2012
2013 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2014 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05302015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2016 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 return -EIO;
2018 }
2019
2020 for (indx = 0; indx < numChans; indx++) {
2021 if (wrqu->freq.m == validChan[indx]){
2022 break;
2023 }
2024 }
2025 }
2026 else{
2027
2028 return -EINVAL;
2029 }
2030
2031 if(indx >= numChans)
2032 {
2033 return -EINVAL;
2034 }
2035
2036 /* Set the Operational Channel */
2037 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2038 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2039 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
2040
Arif Hussain6d2a3322013-11-17 19:50:10 -08002041 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07002042
2043 EXIT();
2044
2045 return status;
2046}
2047
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302048static int iw_set_freq(struct net_device *dev,
2049 struct iw_request_info *info,
2050 union iwreq_data *wrqu, char *extra)
2051{
2052 int ret;
2053
2054 vos_ssr_protect(__func__);
2055 ret = __iw_set_freq(dev, info, wrqu, extra);
2056 vos_ssr_unprotect(__func__);
2057
2058 return ret;
2059}
2060
2061static int __iw_get_freq(struct net_device *dev,
2062 struct iw_request_info *info,
2063 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002064{
Jeff Johnsone7245742012-09-05 17:12:55 -07002065 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302066 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 tHalHandle hHal;
2068 hdd_wext_state_t *pWextState;
2069 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302070 hdd_station_ctx_t *pHddStaCtx;
2071 hdd_context_t *pHddCtx;
2072 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
2074 ENTER();
2075
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302076 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2077 if (NULL == pAdapter)
2078 {
2079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2080 "%s: Adapter is NULL", __func__);
2081 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302083 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2084 ret = wlan_hdd_validate_context(pHddCtx);
2085 if (0 != ret)
2086 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302087 return ret;
2088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302090 if (NULL == hHal)
2091 {
2092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2093 "%s: Hal Context is NULL",__func__);
2094 return -EINVAL;
2095 }
2096 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2097 if (NULL == pHddStaCtx)
2098 {
2099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2100 "%s: HddStaCtx is NULL", __func__);
2101 return -EINVAL;
2102 }
2103 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2104 if (NULL == pWextState)
2105 {
2106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2107 "%s: pWextState is NULL",__func__);
2108 return -EINVAL;
2109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 pRoamProfile = &pWextState->roamProfile;
2111
2112 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2113 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002114 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 {
c_hpothub8245442013-11-20 23:41:09 +05302116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2117 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 return -EIO;
2119 }
2120 else
2121 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002122 status = hdd_wlan_get_freq(channel, &freq);
2123 if( TRUE == status )
2124 {
2125 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2126 * iwlist & iwconfig command shows frequency into proper
2127 * format (2.412 GHz instead of 246.2 MHz)*/
2128 fwrq->m = freq;
2129 fwrq->e = MHZ;
2130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 }
2132 }
2133 else
2134 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002135 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2136 * iwlist & iwconfig command shows frequency into proper
2137 * format (2.412 GHz instead of 246.2 MHz)*/
2138 fwrq->m = 0;
2139 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302141
2142 EXIT();
2143 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002144}
2145
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302146static int iw_get_freq(struct net_device *dev,
2147 struct iw_request_info *info,
2148 struct iw_freq *fwrq, char *extra)
2149{
2150 int ret;
2151
2152 vos_ssr_protect(__func__);
2153 ret = __iw_get_freq(dev, info, fwrq, extra);
2154 vos_ssr_unprotect(__func__);
2155
2156 return ret;
2157}
2158
2159static int __iw_get_tx_power(struct net_device *dev,
2160 struct iw_request_info *info,
2161 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002162{
2163
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302164 hdd_adapter_t *pAdapter;
2165 hdd_context_t *pHddCtx;
2166 hdd_station_ctx_t *pHddStaCtx;
2167 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302169 ENTER();
2170
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302171 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2172 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2175 "%s: Adapter is NULL",__func__);
2176 return -EINVAL;
2177 }
2178 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2179 ret = wlan_hdd_validate_context(pHddCtx);
2180 if (0 != ret)
2181 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302182 return ret;
2183 }
2184
2185 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2186 if (NULL == pHddStaCtx)
2187 {
2188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2189 "%s: STA Context is NULL",__func__);
2190 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 }
2192
2193 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2194 {
2195 wrqu->txpower.value = 0;
2196 return 0;
2197 }
2198 wlan_hdd_get_classAstats(pAdapter);
2199 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302201 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 return 0;
2203}
2204
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302205static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 struct iw_request_info *info,
2207 union iwreq_data *wrqu, char *extra)
2208{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302209 int ret;
2210
2211 vos_ssr_protect(__func__);
2212 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2213 vos_ssr_unprotect(__func__);
2214
2215 return ret;
2216}
2217
2218static int __iw_set_tx_power(struct net_device *dev,
2219 struct iw_request_info *info,
2220 union iwreq_data *wrqu, char *extra)
2221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302222 hdd_adapter_t *pAdapter;
2223 tHalHandle hHal;
2224 hdd_context_t *pHddCtx;
2225 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
2227 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302228 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2229 if (NULL == pAdapter)
2230 {
2231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2232 "%s: Adapter is NULL",__func__);
2233 return -EINVAL;
2234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302236 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2237 ret = wlan_hdd_validate_context(pHddCtx);
2238 if (0 != ret)
2239 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302240 return ret;
2241 }
2242
2243 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2244 if (NULL == hHal)
2245 {
2246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2247 "%s: Hal Context is NULL",__func__);
2248 return -EINVAL;
2249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2251 {
c_hpothub8245442013-11-20 23:41:09 +05302252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2253 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 return -EIO;
2255 }
2256
2257 EXIT();
2258
2259 return 0;
2260}
2261
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302262static int iw_set_tx_power(struct net_device *dev,
2263 struct iw_request_info *info,
2264 union iwreq_data *wrqu, char *extra)
2265{
2266 int ret;
2267
2268 vos_ssr_protect(__func__);
2269 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2270 vos_ssr_unprotect(__func__);
2271
2272 return ret;
2273}
2274
2275static int __iw_get_bitrate(struct net_device *dev,
2276 struct iw_request_info *info,
2277 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002278{
2279 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2280 eHalStatus status = eHAL_STATUS_SUCCESS;
2281 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302282 hdd_adapter_t *pAdapter;
2283 hdd_context_t *pHddCtx;
2284 hdd_station_ctx_t *pHddStaCtx;
2285 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002286
2287 ENTER();
2288
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302289 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2290 if (NULL == pAdapter)
2291 {
2292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2293 "%s: Adapter is NULL",__func__);
2294 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 }
2296
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302297 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2298 ret = wlan_hdd_validate_context(pHddCtx);
2299 if (0 != ret)
2300 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302301 return ret;
2302 }
2303
2304 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2305 if (NULL == pHddStaCtx)
2306 {
2307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2308 "%s: STA Context is NULL",__func__);
2309 return -EINVAL;
2310 }
2311
2312 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 wrqu->bitrate.value = 0;
2314 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302315 else
2316 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2318 SME_SUMMARY_STATS |
2319 SME_GLOBAL_CLASSA_STATS |
2320 SME_GLOBAL_CLASSB_STATS |
2321 SME_GLOBAL_CLASSC_STATS |
2322 SME_GLOBAL_CLASSD_STATS |
2323 SME_PER_STA_STATS,
2324 hdd_StatisticsCB, 0, FALSE,
2325 pHddStaCtx->conn_info.staId[0], pAdapter );
2326
2327 if(eHAL_STATUS_SUCCESS != status)
2328 {
2329 hddLog(VOS_TRACE_LEVEL_ERROR,
2330 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002331 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 return status;
2333 }
2334
2335 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302336 if (NULL == pWextState)
2337 {
2338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2339 "%s: pWextState is NULL",__func__);
2340 return -EINVAL;
2341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002342
2343 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2344
2345 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2346 {
2347 hddLog(VOS_TRACE_LEVEL_ERROR,
2348 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002349 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 return VOS_STATUS_E_FAILURE;
2351 }
2352
2353 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2354 }
2355
2356 EXIT();
2357
2358 return vos_status;
2359}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302360
2361static int iw_get_bitrate(struct net_device *dev,
2362 struct iw_request_info *info,
2363 union iwreq_data *wrqu, char *extra)
2364{
2365 int ret;
2366
2367 vos_ssr_protect(__func__);
2368 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2369 vos_ssr_unprotect(__func__);
2370
2371 return ret;
2372}
2373
2374
Jeff Johnson295189b2012-06-20 16:38:30 -07002375/* ccm call back function */
2376
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302377static int __iw_set_bitrate(struct net_device *dev,
2378 struct iw_request_info *info,
2379 union iwreq_data *wrqu,
2380 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002381{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302382 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302384 hdd_station_ctx_t *pHddStaCtx;
2385 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2387 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2388 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2389 v_U32_t i, rate;
2390 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302391 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002392
2393 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302394 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2395 if (NULL == pAdapter)
2396 {
2397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2398 "%s: Adapter is NULL",__func__);
2399 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 }
2401
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302402 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2403 ret = wlan_hdd_validate_context(pHddCtx);
2404 if (0 != ret)
2405 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302406 return ret;
2407 }
2408
2409 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2410 if (NULL == pHddStaCtx)
2411 {
2412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2413 "%s: STA Context is NULL",__func__);
2414 return -EINVAL;
2415 }
2416
2417
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302419 if (NULL == pWextState)
2420 {
2421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2422 "%s: pWextState is NULL",__func__);
2423 return -EINVAL;
2424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425
2426 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2427 {
2428 return -ENXIO ;
2429 }
2430
2431 rate = wrqu->bitrate.value;
2432
2433 if (rate == -1)
2434 {
2435 rate = WNI_CFG_FIXED_RATE_AUTO;
2436 valid_rate = TRUE;
2437 }
2438 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2439 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2440 {
2441 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2442 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2443 {
2444 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2445 WNI_CFG_SUPPORTED_RATES_11A,
2446 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2447 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2448 WNI_CFG_SUPPORTED_RATES_11B,
2449 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2450 {
2451 for (i = 0; i < (b_len + a_len); ++i)
2452 {
2453 /* supported rates returned is double the actual rate so we divide it by 2 */
2454 if ((supp_rates[i]&0x7F)/2 == rate)
2455 {
2456 valid_rate = TRUE;
2457 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2458 break;
2459 }
2460 }
2461 }
2462 }
2463 }
2464 if (valid_rate != TRUE)
2465 {
2466 return -EINVAL;
2467 }
2468 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2469 WNI_CFG_FIXED_RATE, rate,
2470 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2471 {
c_hpothub8245442013-11-20 23:41:09 +05302472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2473 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 return -EIO;
2475 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302476
2477 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 return 0;
2479}
2480
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302481static int iw_set_bitrate(struct net_device *dev,
2482 struct iw_request_info *info,
2483 union iwreq_data *wrqu,
2484 char *extra)
2485{
2486 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002487
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302488 vos_ssr_protect(__func__);
2489 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2490 vos_ssr_unprotect(__func__);
2491
2492 return ret;
2493}
2494
2495static int __iw_set_genie(struct net_device *dev,
2496 struct iw_request_info *info,
2497 union iwreq_data *wrqu,
2498 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002499{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302500 hdd_adapter_t *pAdapter;
2501 hdd_context_t *pHddCtx;
2502 hdd_wext_state_t *pWextState;
2503 u_int8_t *genie = NULL;
2504 u_int8_t *base_genie = NULL;
2505 v_U16_t remLen;
2506 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002507
2508 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002509
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302510 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2511 if (NULL == pAdapter)
2512 {
2513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2514 "%s: Adapter is NULL",__func__);
2515 return -EINVAL;
2516 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002517
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302518 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2519 ret = wlan_hdd_validate_context(pHddCtx);
2520 if (0 != ret)
2521 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302522 return ret;
2523 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002524
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302525 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2526 if (NULL == pWextState)
2527 {
2528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2529 "%s: pWextState is NULL",__func__);
2530 return -EINVAL;
2531 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002532
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302533 if (!wrqu->data.length) {
2534 hdd_clearRoamProfileIe(pAdapter);
2535 EXIT();
2536 return 0;
2537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002538
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302539 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2540 wrqu->data.length);
2541 if (NULL == base_genie)
2542 {
2543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2544 "mem_alloc_copy_from_user_helper fail");
2545 return -ENOMEM;
2546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302548 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002549
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302550 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002551
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302552 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2553
2554 /* clear any previous genIE before this call */
2555 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2556
2557 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 {
2559 v_U16_t eLen = 0;
2560 v_U8_t elementId;
2561 elementId = *genie++;
2562 eLen = *genie++;
2563 remLen -= 2;
2564
Arif Hussain6d2a3322013-11-17 19:50:10 -08002565 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 __func__, elementId, eLen);
2567
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302568 if (remLen < eLen) {
2569 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2570 remLen, eLen);
2571 ret = -EINVAL;
2572 goto exit;
2573 }
2574
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 switch ( elementId )
2576 {
2577 case IE_EID_VENDOR:
2578 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002579 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302580 ret = -EINVAL;
2581 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002583
2584 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2585 {
2586 v_U16_t curGenIELen = pWextState->genIE.length;
2587 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2588 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2589
2590 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2591 {
2592 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002593 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302595 ret = -EINVAL;
2596 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 }
2598 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2599 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2600 pWextState->genIE.length += eLen + 2;
2601 }
2602 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2603 {
2604 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302605 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2606 {
2607 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2608 "Need bigger buffer space");
2609 ret = -EINVAL;
2610 VOS_ASSERT(0);
2611 goto exit;
2612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2614 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2615 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2616 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2617 }
2618 else /* any vendorId except WPA IE should be accumulated to genIE */
2619 {
2620 v_U16_t curGenIELen = pWextState->genIE.length;
2621 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2622 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2623
2624 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2625 {
2626 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002627 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302629 ret = -ENOMEM;
2630 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 }
2632 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2633 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2634 pWextState->genIE.length += eLen + 2;
2635 }
2636 break;
2637 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002638 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302639 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2640 {
2641 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2642 "Need bigger buffer space");
2643 ret = -EINVAL;
2644 VOS_ASSERT(0);
2645 goto exit;
2646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2648 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2649 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2650 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2651 break;
2652
2653 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002654 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302655 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302658
2659 /* Move genie only if next element is present */
2660 if (remLen >= 2)
2661 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302663
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302664exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002666 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302667 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002668}
2669
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302670static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 struct iw_request_info *info,
2672 union iwreq_data *wrqu,
2673 char *extra)
2674{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302675 int ret;
2676
2677 vos_ssr_protect(__func__);
2678 ret = __iw_set_genie(dev, info, wrqu, extra);
2679 vos_ssr_unprotect(__func__);
2680
2681 return ret;
2682}
2683
2684static int __iw_get_genie(struct net_device *dev,
2685 struct iw_request_info *info,
2686 union iwreq_data *wrqu,
2687 char *extra)
2688{
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302690 hdd_context_t *pHddCtx;
2691 hdd_adapter_t *pAdapter;
2692 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 eHalStatus status;
2694 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2695 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2696
2697 ENTER();
2698
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302699 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2700 if (NULL == pAdapter)
2701 {
2702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2703 "%s: Adapter is NULL",__func__);
2704 return -EINVAL;
2705 }
2706 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2707 status = wlan_hdd_validate_context(pHddCtx);
2708 if (0 != status)
2709 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302710 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 }
2712
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302714 if (NULL == pWextState)
2715 {
2716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2717 "%s: pWextState is NULL",__func__);
2718 return -EINVAL;
2719 }
2720
2721 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2722 if (NULL == pHddStaCtx)
2723 {
2724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2725 "%s: STA Context is NULL",__func__);
2726 return -EINVAL;
2727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002728
2729 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2730 {
2731 return -ENXIO;
2732 }
2733
2734 // Return something ONLY if we are associated with an RSN or WPA network
2735 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2736 pWextState->roamProfile.negotiatedAuthType))
2737 {
2738 return -ENXIO;
2739 }
2740
2741 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2742 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2743 pAdapter->sessionId,
2744 &length,
2745 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302746 if (eHAL_STATUS_SUCCESS != status) {
2747 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002748 return -EFAULT;
2749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002750
Manjeet Singh715d47e2016-08-02 19:08:02 +05302751 wrqu->data.length = length;
2752 if (length > DOT11F_IE_RSN_MAX_LEN) {
2753 hddLog(LOGE,
2754 FL("invalid buffer length length:%d"), length);
2755 return -E2BIG;
2756 }
2757
2758 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2759
2760 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002761
2762 EXIT();
2763
2764 return 0;
2765}
2766
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302767static int iw_get_genie(struct net_device *dev,
2768 struct iw_request_info *info,
2769 union iwreq_data *wrqu,
2770 char *extra)
2771{
2772 int ret;
2773
2774 vos_ssr_protect(__func__);
2775 ret = __iw_get_genie(dev, info, wrqu, extra);
2776 vos_ssr_unprotect(__func__);
2777
2778 return ret;
2779}
2780
2781
2782static int __iw_get_encode(struct net_device *dev,
2783 struct iw_request_info *info,
2784 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002785{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302786 hdd_adapter_t *pAdapter;
2787 hdd_context_t *pHddCtx;
2788 hdd_wext_state_t *pWextState;
2789 tCsrRoamProfile *pRoamProfile;
2790 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002792
2793 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302794 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2795 if (NULL == pAdapter)
2796 {
2797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2798 "%s: Adapter is NULL",__func__);
2799 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 }
2801
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302802 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2803 ret = wlan_hdd_validate_context(pHddCtx);
2804 if (0 != ret)
2805 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302806 return ret;
2807 }
2808 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2809 if (NULL == pWextState)
2810 {
2811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2812 "%s: pWextState is NULL",__func__);
2813 return -EINVAL;
2814 }
2815
2816 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 keyId = pRoamProfile->Keys.defaultIndex;
2818
2819 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2820 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002821 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 return -EINVAL;
2823 }
2824
2825 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2826 {
2827 dwrq->flags |= IW_ENCODE_ENABLED;
2828 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2829 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2830
2831 dwrq->flags |= (keyId + 1);
2832
2833 }
2834 else
2835 {
2836 dwrq->flags |= IW_ENCODE_DISABLED;
2837 }
2838
2839 for(i=0; i < MAX_WEP_KEYS; i++)
2840 {
2841 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2842 {
2843 continue;
2844 }
2845 else
2846 {
2847 break;
2848 }
2849 }
2850
2851 if(MAX_WEP_KEYS == i)
2852 {
2853 dwrq->flags |= IW_ENCODE_NOKEY;
2854 }
2855
2856 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2857
2858 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2859 {
2860 dwrq->flags |= IW_ENCODE_OPEN;
2861 }
2862 else
2863 {
2864 dwrq->flags |= IW_ENCODE_RESTRICTED;
2865 }
2866 EXIT();
2867 return 0;
2868}
2869
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302870static int iw_get_encode(struct net_device *dev,
2871 struct iw_request_info *info,
2872 struct iw_point *dwrq, char *extra)
2873{
2874 int ret;
2875
2876 vos_ssr_protect(__func__);
2877 ret = __iw_get_encode(dev, info, dwrq, extra);
2878 vos_ssr_unprotect(__func__);
2879
2880 return ret;
2881}
2882
Jeff Johnson295189b2012-06-20 16:38:30 -07002883#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2884#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2885
2886
2887/*
2888 * This function sends a single 'key' to LIM at all time.
2889 */
2890
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302891static int __iw_get_rts_threshold(struct net_device *dev,
2892 struct iw_request_info *info,
2893 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002894{
2895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2896 v_U32_t status = 0;
2897
2898 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2899
2900 return status;
2901}
2902
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302903static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 struct iw_request_info *info,
2905 union iwreq_data *wrqu, char *extra)
2906{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302907 int ret;
2908
2909 vos_ssr_protect(__func__);
2910 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2911 vos_ssr_unprotect(__func__);
2912
2913 return ret;
2914}
2915
2916static int __iw_set_rts_threshold(struct net_device *dev,
2917 struct iw_request_info *info,
2918 union iwreq_data *wrqu, char *extra)
2919{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302920 hdd_adapter_t *pAdapter;
2921 hdd_context_t *pHddCtx;
2922 tHalHandle hHal;
2923 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002924
2925 ENTER();
2926
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302927 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2928 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002929 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2931 "%s: Adapter is NULL",__func__);
2932 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002933 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302934
2935 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2936 ret = wlan_hdd_validate_context(pHddCtx);
2937 if (0 != ret)
2938 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302939 return ret;
2940 }
2941
2942 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2943 if (NULL == hHal)
2944 {
2945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2946 "%s: Hal Context is NULL",__func__);
2947 return -EINVAL;
2948 }
2949
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2951 {
2952 return -EINVAL;
2953 }
2954
2955 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2956 {
c_hpothub8245442013-11-20 23:41:09 +05302957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2958 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 return -EIO;
2960 }
2961
2962 EXIT();
2963
2964 return 0;
2965}
2966
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302967static int iw_set_rts_threshold(struct net_device *dev,
2968 struct iw_request_info *info,
2969 union iwreq_data *wrqu, char *extra)
2970{
2971 int ret;
2972
2973 vos_ssr_protect(__func__);
2974 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2975 vos_ssr_unprotect(__func__);
2976
2977 return ret;
2978}
2979
2980static int __iw_get_frag_threshold(struct net_device *dev,
2981 struct iw_request_info *info,
2982 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002983{
2984 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2985 v_U32_t status = 0;
2986
2987 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2988
2989 return status;
2990}
2991
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302992static int iw_get_frag_threshold(struct net_device *dev,
2993 struct iw_request_info *info,
2994 union iwreq_data *wrqu, char *extra)
2995{
2996 int ret;
2997
2998 vos_ssr_protect(__func__);
2999 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3000 vos_ssr_unprotect(__func__);
3001
3002 return ret;
3003}
3004
3005static int __iw_set_frag_threshold(struct net_device *dev,
3006 struct iw_request_info *info,
3007 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003008{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303009 hdd_adapter_t *pAdapter;
3010 hdd_context_t *pHddCtx;
3011 tHalHandle hHal;
3012 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003013
3014 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303015 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3016 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003017 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3019 "%s: Adapter is NULL",__func__);
3020 return -EINVAL;
3021 }
3022
3023 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3024 ret = wlan_hdd_validate_context(pHddCtx);
3025 if (0 != ret)
3026 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303027 return ret;
3028 }
3029
3030 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3031 if (NULL == hHal)
3032 {
3033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3034 "%s: Hal Context is NULL",__func__);
3035 return -EINVAL;
3036 }
3037
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3039 {
3040 return -EINVAL;
3041 }
3042
3043 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3044 {
c_hpothub8245442013-11-20 23:41:09 +05303045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3046 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 return -EIO;
3048 }
3049
3050 EXIT();
3051
3052 return 0;
3053}
3054
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303055static int iw_set_frag_threshold(struct net_device *dev,
3056 struct iw_request_info *info,
3057 union iwreq_data *wrqu, char *extra)
3058{
3059 int ret;
3060
3061 vos_ssr_protect(__func__);
3062 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3063 vos_ssr_unprotect(__func__);
3064
3065 return ret;
3066}
3067
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303068static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 struct iw_request_info *info,
3070 union iwreq_data *wrqu, char *extra)
3071{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303072 hdd_adapter_t *pAdapter;
3073 hdd_context_t *pHddCtx;
3074 int ret = 0;
3075
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303077 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3078 if (NULL == pAdapter)
3079 {
3080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3081 "%s: Adapter is NULL",__func__);
3082 return -EINVAL;
3083 }
3084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3085 ret = wlan_hdd_validate_context(pHddCtx);
3086 if (0 != ret)
3087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303088 return ret;
3089 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303090
3091 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 return -EOPNOTSUPP;
3093}
3094
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303095static int iw_get_power_mode(struct net_device *dev,
3096 struct iw_request_info *info,
3097 union iwreq_data *wrqu, char *extra)
3098{
3099 int ret;
3100
3101 vos_ssr_protect(__func__);
3102 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3103 vos_ssr_unprotect(__func__);
3104
3105 return ret;
3106}
3107static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 struct iw_request_info *info,
3109 union iwreq_data *wrqu, char *extra)
3110{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303111 hdd_adapter_t *pAdapter;
3112 hdd_context_t *pHddCtx;
3113 int ret = 0;
3114
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303116 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3117 if (NULL == pAdapter)
3118 {
3119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3120 "%s: Adapter is NULL",__func__);
3121 return -EINVAL;
3122 }
3123 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3124 ret = wlan_hdd_validate_context(pHddCtx);
3125 if (0 != ret)
3126 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303127 return ret;
3128 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303129
3130 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 return -EOPNOTSUPP;
3132}
3133
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303134static int iw_set_power_mode(struct net_device *dev,
3135 struct iw_request_info *info,
3136 union iwreq_data *wrqu, char *extra)
3137{
3138 int ret;
3139
3140 vos_ssr_protect(__func__);
3141 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3142 vos_ssr_unprotect(__func__);
3143
3144 return ret;
3145}
3146
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303147static int __iw_get_range(struct net_device *dev,
3148 struct iw_request_info *info,
3149 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003150{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303151 hdd_adapter_t *pAdapter;
3152 tHalHandle hHal;
3153 hdd_context_t *pHddCtx;
3154 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 struct iw_range *range = (struct iw_range *) extra;
3156
3157 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3158
3159 v_U32_t num_channels = sizeof(channels);
3160 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3161 v_U32_t a_len;
3162 v_U32_t b_len;
3163 v_U32_t active_phy_mode = 0;
3164 v_U8_t index = 0, i;
3165
3166 ENTER();
3167
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303168 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3169 if (NULL == pAdapter)
3170 {
3171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3172 "%s: pAdapter is NULL", __func__);
3173 return -EINVAL;
3174 }
3175 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3176 ret = wlan_hdd_validate_context(pHddCtx);
3177 if (0 != ret)
3178 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303179 return ret;
3180 }
3181 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3182 if (NULL == hHal)
3183 {
3184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3185 "%s: pAdapter is NULL", __func__);
3186 return -EINVAL;
3187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 wrqu->data.length = sizeof(struct iw_range);
3189 memset(range, 0, sizeof(struct iw_range));
3190
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 /*Get the phy mode*/
3192 if (ccmCfgGetInt(hHal,
3193 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3194 {
3195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003196 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003197
3198 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3199 {
3200 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003201 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 if (ccmCfgGetStr(hHal,
3203 WNI_CFG_SUPPORTED_RATES_11A,
3204 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3205 {
3206 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3207 {
3208 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3209 }
3210 for (i = 0; i < a_len; i++)
3211 {
3212 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3213 }
3214 range->num_bitrates = a_len;
3215 }
3216 else
3217 {
3218 return -EIO;
3219 }
3220 }
3221 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3222 {
3223 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003224 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 if (ccmCfgGetStr(hHal,
3226 WNI_CFG_SUPPORTED_RATES_11B,
3227 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3228 {
3229 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3230 {
3231 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3232 }
3233 for (i = 0; i < b_len; i++)
3234 {
3235 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3236 }
3237 range->num_bitrates = b_len;
3238 }
3239 else
3240 {
3241 return -EIO;
3242 }
3243 }
3244 }
3245
3246 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3247 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3248 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3249
3250 range->encoding_size[0] = 5;
3251 range->encoding_size[1] = 13;
3252 range->num_encoding_sizes = 2;
3253 range->max_encoding_tokens = MAX_WEP_KEYS;
3254
3255 // we support through Wireless Extensions 22
3256 range->we_version_compiled = WIRELESS_EXT;
3257 range->we_version_source = 22;
3258
3259 /*Supported Channels and Frequencies*/
3260 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3261 {
c_hpothub8245442013-11-20 23:41:09 +05303262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3263 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 return -EIO;
3265 }
3266 if (num_channels > IW_MAX_FREQUENCIES)
3267 {
3268 num_channels = IW_MAX_FREQUENCIES;
3269 }
3270
3271 range->num_channels = num_channels;
3272 range->num_frequency = num_channels;
3273
3274 for (index=0; index < num_channels; index++)
3275 {
3276 v_U32_t frq_indx = 0;
3277
3278 range->freq[index].i = channels[index];
3279 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3280 {
3281 if(channels[index] == freq_chan_map[frq_indx].chan)
3282 {
3283 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3284 range->freq[index].e = 1;
3285 break;
3286 }
3287 frq_indx++;
3288 }
3289 }
3290
3291 /* Event capability (kernel + driver) */
3292 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3293 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3294 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3295 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3296
3297 /*Encryption capability*/
3298 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3299 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3300
3301 /* Txpower capability */
3302 range->txpower_capa = IW_TXPOW_MWATT;
3303
3304 /*Scanning capability*/
3305 #if WIRELESS_EXT >= 22
3306 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3307 #endif
3308
3309 EXIT();
3310 return 0;
3311}
3312
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303313static int iw_get_range(struct net_device *dev,
3314 struct iw_request_info *info,
3315 union iwreq_data *wrqu, char *extra)
3316{
3317 int ret;
3318
3319 vos_ssr_protect(__func__);
3320 ret = __iw_get_range(dev, info, wrqu, extra);
3321 vos_ssr_unprotect(__func__);
3322
3323 return ret;
3324}
3325
Jeff Johnson295189b2012-06-20 16:38:30 -07003326/* Callback function registered with PMC to know status of PMC request */
3327static void iw_power_callback_fn (void *pContext, eHalStatus status)
3328{
3329 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330
3331 if (NULL == pContext)
3332 {
3333 hddLog(VOS_TRACE_LEVEL_ERROR,
3334 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003335 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 return;
3337 }
3338
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003340
Jeff Johnson72a40512013-12-19 10:14:15 -08003341 /* there is a race condition that exists between this callback
3342 function and the caller since the caller could time out either
3343 before or while this code is executing. we use a spinlock to
3344 serialize these actions */
3345 spin_lock(&hdd_context_lock);
3346
3347 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 {
3349 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003350 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003352 "%s: Invalid context, magic [%08x]",
3353 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003354
3355 if (ioctl_debug)
3356 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003357 pr_info("%s: Invalid context, magic [%08x]\n",
3358 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 }
3360 return;
3361 }
3362
Jeff Johnson72a40512013-12-19 10:14:15 -08003363 /* context is valid so caller is still waiting */
3364
3365 /* paranoia: invalidate the magic */
3366 pStatsContext->magic = 0;
3367
3368 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003370
3371 /* serialization is complete */
3372 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003373}
3374
3375/* Callback function for tx per hit */
3376void hdd_tx_per_hit_cb (void *pCallbackContext)
3377{
3378 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3379 unsigned char tx_fail[16];
3380 union iwreq_data wrqu;
3381
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303382 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003384 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 return;
3386 }
3387 memset(&wrqu, 0, sizeof(wrqu));
3388 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3389 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3390}
3391
3392void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3393{
3394 struct statsContext *pStatsContext;
3395 tCsrGlobalClassAStatsInfo *pClassAStats;
3396 hdd_adapter_t *pAdapter;
3397
3398 if (ioctl_debug)
3399 {
3400 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003401 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 }
3403
3404 if ((NULL == pStats) || (NULL == pContext))
3405 {
3406 hddLog(VOS_TRACE_LEVEL_ERROR,
3407 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003408 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 return;
3410 }
3411
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 pClassAStats = pStats;
3413 pStatsContext = pContext;
3414 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003415
3416 /* there is a race condition that exists between this callback
3417 function and the caller since the caller could time out either
3418 before or while this code is executing. we use a spinlock to
3419 serialize these actions */
3420 spin_lock(&hdd_context_lock);
3421
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3423 {
3424 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003425 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 hddLog(VOS_TRACE_LEVEL_WARN,
3427 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003428 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 if (ioctl_debug)
3430 {
3431 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003432 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 }
3434 return;
3435 }
3436
Jeff Johnson72a40512013-12-19 10:14:15 -08003437 /* context is valid so caller is still waiting */
3438
3439 /* paranoia: invalidate the magic */
3440 pStatsContext->magic = 0;
3441
3442 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3444
Jeff Johnson72a40512013-12-19 10:14:15 -08003445 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003447
3448 /* serialization is complete */
3449 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003450}
3451
3452VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3453{
3454 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3455 eHalStatus hstatus;
3456 long lrc;
3457 struct statsContext context;
3458
3459 if (NULL == pAdapter)
3460 {
3461 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3462 return VOS_STATUS_E_FAULT;
3463 }
3464 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3465 {
3466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3467 return VOS_STATUS_SUCCESS;
3468 }
3469
3470 /* we are connected
3471 prepare our callback context */
3472 init_completion(&context.completion);
3473 context.pAdapter = pAdapter;
3474 context.magic = STATS_CONTEXT_MAGIC;
3475 /* query only for Class A statistics (which include link speed) */
3476 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3477 eCSR_HDD,
3478 SME_GLOBAL_CLASSA_STATS,
3479 hdd_GetClassA_statisticsCB,
3480 0, // not periodic
3481 FALSE, //non-cached results
3482 pHddStaCtx->conn_info.staId[0],
3483 &context);
3484 if (eHAL_STATUS_SUCCESS != hstatus)
3485 {
3486 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003487 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003488 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 /* we'll returned a cached value below */
3490 }
3491 else
3492 {
3493 /* request was sent -- wait for the response */
3494 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3495 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 if (lrc <= 0)
3497 {
3498 hddLog(VOS_TRACE_LEVEL_ERROR,
3499 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003500 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 }
3502 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003503
3504 /* either we never sent a request, we sent a request and received a
3505 response or we sent a request and timed out. if we never sent a
3506 request or if we sent a request and got a response, we want to
3507 clear the magic out of paranoia. if we timed out there is a
3508 race condition such that the callback function could be
3509 executing at the same time we are. of primary concern is if the
3510 callback function had already verified the "magic" but had not
3511 yet set the completion variable when a timeout occurred. we
3512 serialize these activities by invalidating the magic while
3513 holding a shared spinlock which will cause us to block if the
3514 callback is currently executing */
3515 spin_lock(&hdd_context_lock);
3516 context.magic = 0;
3517 spin_unlock(&hdd_context_lock);
3518
3519 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 return VOS_STATUS_SUCCESS;
3521}
3522
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003523static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3524{
3525 struct statsContext *pStatsContext;
3526 tCsrSummaryStatsInfo *pSummaryStats;
3527 tCsrGlobalClassAStatsInfo *pClassAStats;
3528 hdd_adapter_t *pAdapter;
3529
3530 if (ioctl_debug)
3531 {
3532 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003533 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003534 }
3535
3536 if ((NULL == pStats) || (NULL == pContext))
3537 {
3538 hddLog(VOS_TRACE_LEVEL_ERROR,
3539 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003540 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003541 return;
3542 }
3543
Jeff Johnson72a40512013-12-19 10:14:15 -08003544 /* there is a race condition that exists between this callback
3545 function and the caller since the caller could time out either
3546 before or while this code is executing. we use a spinlock to
3547 serialize these actions */
3548 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003549
3550 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3551 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3552 pStatsContext = pContext;
3553 pAdapter = pStatsContext->pAdapter;
3554 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3555 {
3556 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003557 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003558 hddLog(VOS_TRACE_LEVEL_WARN,
3559 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003560 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003561 if (ioctl_debug)
3562 {
3563 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003564 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003565 }
3566 return;
3567 }
3568
Jeff Johnson72a40512013-12-19 10:14:15 -08003569 /* context is valid so caller is still waiting */
3570
3571 /* paranoia: invalidate the magic */
3572 pStatsContext->magic = 0;
3573
3574 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003575 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3576 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3577
Jeff Johnson72a40512013-12-19 10:14:15 -08003578 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003579 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003580
3581 /* serialization is complete */
3582 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003583}
3584
3585VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3586{
3587 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3588 eHalStatus hstatus;
3589 long lrc;
3590 struct statsContext context;
3591
3592 if (NULL == pAdapter)
3593 {
3594 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3595 return VOS_STATUS_SUCCESS;
3596 }
3597
3598 /* we are connected
3599 prepare our callback context */
3600 init_completion(&context.completion);
3601 context.pAdapter = pAdapter;
3602 context.magic = STATS_CONTEXT_MAGIC;
3603
3604 /* query only for Summary & Class A statistics */
3605 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3606 eCSR_HDD,
3607 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303608 SME_GLOBAL_CLASSA_STATS |
3609 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003610 hdd_get_station_statisticsCB,
3611 0, // not periodic
3612 FALSE, //non-cached results
3613 pHddStaCtx->conn_info.staId[0],
3614 &context);
3615 if (eHAL_STATUS_SUCCESS != hstatus)
3616 {
3617 hddLog(VOS_TRACE_LEVEL_ERROR,
3618 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003619 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003620 /* we'll return with cached values */
3621 }
3622 else
3623 {
3624 /* request was sent -- wait for the response */
3625 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3626 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003627
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003628 if (lrc <= 0)
3629 {
3630 hddLog(VOS_TRACE_LEVEL_ERROR,
3631 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003632 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003633 }
3634 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003635
3636 /* either we never sent a request, we sent a request and received a
3637 response or we sent a request and timed out. if we never sent a
3638 request or if we sent a request and got a response, we want to
3639 clear the magic out of paranoia. if we timed out there is a
3640 race condition such that the callback function could be
3641 executing at the same time we are. of primary concern is if the
3642 callback function had already verified the "magic" but had not
3643 yet set the completion variable when a timeout occurred. we
3644 serialize these activities by invalidating the magic while
3645 holding a shared spinlock which will cause us to block if the
3646 callback is currently executing */
3647 spin_lock(&hdd_context_lock);
3648 context.magic = 0;
3649 spin_unlock(&hdd_context_lock);
3650
3651 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003652 return VOS_STATUS_SUCCESS;
3653}
3654
3655
Jeff Johnson295189b2012-06-20 16:38:30 -07003656/*
3657 * Support for the LINKSPEED private command
3658 * Per the WiFi framework the response must be of the form
3659 * "LinkSpeed xx"
3660 */
3661static int iw_get_linkspeed(struct net_device *dev,
3662 struct iw_request_info *info,
3663 union iwreq_data *wrqu, char *extra)
3664{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303665 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303666 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303668 int len = sizeof(v_U32_t) + 1;
3669 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303670 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303671 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303672 int rc, valid = 0;
3673
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303674 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303675 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3676 if (NULL == pAdapter)
3677 {
3678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3679 "%s: Adapter is NULL",__func__);
3680 return -EINVAL;
3681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003682
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303683 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303684 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303685 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003686 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303687 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003688 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303689 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3690 if (NULL == pHddStaCtx)
3691 {
3692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3693 "%s: STA Context is NULL",__func__);
3694 return -EINVAL;
3695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3697 {
3698 /* we are not connected so we don't have a classAstats */
3699 link_speed = 0;
3700 }
3701 else
3702 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303703 status = wlan_hdd_get_classAstats(pAdapter);
3704
3705 if (!VOS_IS_STATUS_SUCCESS(status ))
3706 {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3708 return -EINVAL;
3709 }
3710
3711 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3712 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3713 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3714 &link_speed);
3715
3716 link_speed = link_speed / 10;
3717
3718 if (0 == link_speed)
3719 {
3720 /* The linkspeed returned by HAL is in units of 500kbps.
3721 * converting it to mbps.
3722 * This is required to support legacy firmware which does
3723 * not return link capacity.
3724 */
3725 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3726 }
3727
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 }
3729
3730 wrqu->data.length = len;
3731 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003732 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 if ((rc < 0) || (rc >= len))
3734 {
3735 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303736 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 return -EIO;
3738 }
3739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303740 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003742 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003743}
3744
Arif Hussain695279c2014-03-24 14:06:07 -07003745/*
3746 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3747 *
3748 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303749static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003750 struct iw_request_info *info,
3751 union iwreq_data *wrqu, char *extra)
3752{
3753 int rc;
3754
3755 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3756
3757 if (rc < 0)
3758 return rc;
3759
3760 /* a value is being successfully returned */
3761 return 0;
3762}
Jeff Johnson295189b2012-06-20 16:38:30 -07003763
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303764static int iw_get_linkspeed_priv(struct net_device *dev,
3765 struct iw_request_info *info,
3766 union iwreq_data *wrqu, char *extra)
3767{
3768 int ret;
3769
3770 vos_ssr_protect(__func__);
3771 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3772 vos_ssr_unprotect(__func__);
3773
3774 return ret;
3775}
3776
Jeff Johnson295189b2012-06-20 16:38:30 -07003777/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303778 * Support for the RSSI & RSSI-APPROX private commands
3779 * Per the WiFi framework the response must be of the form
3780 * "<ssid> rssi <xx>"
3781 * unless we are not associated, in which case the response is
3782 * "OK"
3783 */
3784static int iw_get_rssi(struct net_device *dev,
3785 struct iw_request_info *info,
3786 union iwreq_data *wrqu, char *extra)
3787{
3788 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3789 char *cmd = extra;
3790 int len = wrqu->data.length;
3791 v_S7_t s7Rssi = 0;
3792 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3793 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3794 VOS_STATUS vosStatus;
3795 int rc;
3796
3797 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3798 (0 == ssidlen) || (ssidlen >= len))
3799 {
3800 /* we are not connected or our SSID is too long
3801 so we cannot report an rssi */
3802 rc = scnprintf(cmd, len, "OK");
3803 }
3804 else
3805 {
3806 /* we are connected with a valid SSID
3807 so we can write the SSID into the return buffer
3808 (note that it is not NUL-terminated) */
3809 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3810
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303811 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303812 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3813
3814 if (VOS_STATUS_SUCCESS == vosStatus)
3815 {
3816 /* append the rssi to the ssid in the format required by
3817 the WiFI Framework */
3818 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3819 rc += ssidlen;
3820 }
3821 else
3822 {
3823 rc = -1;
3824 }
3825 }
3826
3827 /* verify that we wrote a valid response */
3828 if ((rc < 0) || (rc >= len))
3829 {
3830 // encoding or length error?
3831 hddLog(VOS_TRACE_LEVEL_ERROR,
3832 "%s: Unable to encode RSSI, got [%s]",
3833 __func__, cmd);
3834 return -EIO;
3835 }
3836
3837 /* a value is being successfully returned */
3838 return rc;
3839}
3840
3841/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 * Support for SoftAP channel range private command
3843 */
3844static int iw_softap_set_channel_range( struct net_device *dev,
3845 int startChannel,
3846 int endChannel,
3847 int band)
3848{
Jeff Johnson43971f52012-07-17 12:26:56 -07003849 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 int ret = 0;
3851 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3852 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003853 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855
3856 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3857 if (VOS_STATUS_SUCCESS != status)
3858 {
3859 ret = -EINVAL;
3860 }
Yathish9f22e662012-12-10 14:21:35 -08003861 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 return ret;
3863}
3864
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303865static uint8 chartohex(char c)
3866{
3867 uint8 val = 0;
3868 if (c >= '0' && c <= '9')
3869 val = c - '0';
3870 else if (c >= 'a' && c <= 'f')
3871 val = c - 'a' + 10;
3872 else if (c >= 'A' && c <= 'F')
3873 val = c - 'A' + 10;
3874 else
3875 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3876
3877 return val;
3878}
3879
3880uint8 getByte(char **buf)
3881{
3882 uint8 byte = 0;
3883 char *temp = *buf;
3884 byte = chartohex(*temp) * 16;
3885 temp++;
3886 byte += chartohex(*temp);
3887 temp++;
3888 *buf = temp;
3889 return byte;
3890}
3891
3892static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3893{
3894 tSir80211Header *macHeader;
3895 int i = 0, j = 0, length = 0;
3896 uint8 byte = 0;
3897 char *temp = pBuffer;
3898 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303899 char *pHeader;
3900 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303901
3902 macHeader = &pkt->macHeader;
3903
3904 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3905
3906 temp++;
3907
3908 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3909 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3910 pkt->encParams.keyParams.key[0].keyId);
3911
3912 for (i = 0; i< 16; i++) {
3913 pkt->encParams.keyParams.key[0].key[i]
3914 = getByte(&temp);
3915 }
3916
3917 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3918 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3919
3920 for (i = 0; i< 6; i++) {
3921 pkt->encParams.pn[i]
3922 = getByte(&temp);
3923 }
3924
3925 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3926 &pkt->encParams.pn[0], 6, 0);
3927
3928 for (i = 0, j= 5; i< 3; i++, j--) {
3929 byte = pkt->encParams.pn[i];
3930 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3931 pkt->encParams.pn[j] = byte;
3932 }
3933
3934 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303935 if (length > sizeof(tSir80211Header))
3936 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303937
Srinivas Dasari2382de62015-01-22 15:00:04 +05303938 pHeader = temp;
3939 vos_mem_zero(&header, sizeof(tSir80211Header));
3940 for (i = 0; i < length; i++) {
3941 *((uint8 *)&header + i) = getByte(&pHeader);
3942 }
3943
3944 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3945 (char *)&header, length, 0);
3946
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303947 byte = getByte(&temp);
3948
3949 macHeader->frameCtrl.protVer = byte & 0x3;
3950 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3951 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3952
3953 byte = getByte(&temp);
3954 macHeader->frameCtrl.toDS = (byte) & 0x1;
3955 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3956 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3957 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3958 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3959 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3960 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3961 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3962
3963 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3964 "macHeader->frameCtrl.type : %x "
3965 "macHeader->frameCtrl.subType : %x "
3966 "macHeader->frameCtrl.toDS : %x "
3967 "macHeader->frameCtrl.fromDS : %x "
3968 "macHeader->frameCtrl.moreFrag : %x "
3969 "macHeader->frameCtrl.retry : %x "
3970 "macHeader->frameCtrl.powerMgmt : %x "
3971 "macHeader->frameCtrl.MoreData : %x "
3972 "macHeader->frameCtrl.wep : %x "
3973 "macHeader->frameCtrl.order : %x "
3974 , macHeader->frameCtrl.protVer
3975 , macHeader->frameCtrl.type
3976 , macHeader->frameCtrl.subType
3977 , macHeader->frameCtrl.toDS
3978 , macHeader->frameCtrl.fromDS
3979 , macHeader->frameCtrl.moreFrag
3980 , macHeader->frameCtrl.retry
3981 , macHeader->frameCtrl.powerMgmt
3982 , macHeader->frameCtrl.moreData
3983 , macHeader->frameCtrl.wep
3984 , macHeader->frameCtrl.order);
3985
3986
3987 macHeader->usDurationId = getByte(&temp);
3988 macHeader->usDurationId += getByte(&temp) << 8;
3989
3990 macHeader->vA1[0] = getByte(&temp);
3991 macHeader->vA1[1] = getByte(&temp);
3992 macHeader->vA1[2] = getByte(&temp);
3993 macHeader->vA1[3] = getByte(&temp);
3994 macHeader->vA1[4] = getByte(&temp);
3995 macHeader->vA1[5] = getByte(&temp);
3996
3997 macHeader->vA2[0] = getByte(&temp);
3998 macHeader->vA2[1] = getByte(&temp);
3999 macHeader->vA2[2] = getByte(&temp);
4000 macHeader->vA2[3] = getByte(&temp);
4001 macHeader->vA2[4] = getByte(&temp);
4002 macHeader->vA2[5] = getByte(&temp);
4003
4004 macHeader->vA3[0] = getByte(&temp);
4005 macHeader->vA3[1] = getByte(&temp);
4006 macHeader->vA3[2] = getByte(&temp);
4007 macHeader->vA3[3] = getByte(&temp);
4008 macHeader->vA3[4] = getByte(&temp);
4009 macHeader->vA3[5] = getByte(&temp);
4010
4011 macHeader->sSeqCtrl = getByte(&temp);
4012 fragNum = macHeader->sSeqCtrl & 0xF;
4013 macHeader->sSeqCtrl >>= 4;
4014
4015 macHeader->sSeqCtrl += getByte(&temp) << 4;
4016
4017 macHeader->sSeqCtrl |= fragNum << 12;
4018
4019 if (length == 30 || length == 32) {
4020 macHeader->optvA4[0] = getByte(&temp);
4021 macHeader->optvA4[1] = getByte(&temp);
4022 macHeader->optvA4[2] = getByte(&temp);
4023 macHeader->optvA4[3] = getByte(&temp);
4024 macHeader->optvA4[4] = getByte(&temp);
4025 macHeader->optvA4[5] = getByte(&temp);
4026 }
4027
4028 if (length == 26 || length == 32) {
4029 macHeader->usQosCtrl = getByte(&temp);
4030 macHeader->usQosCtrl += getByte(&temp) << 8;
4031 }
4032
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304033 //parse payload
4034 length = getByte(&temp);
4035 length += getByte(&temp) << 8;
4036 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4037
Manjeet Singh5830f142016-11-21 18:21:17 +05304038 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
4039 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
4040
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304041 pkt->data.length = length;
4042
4043 for (i = 0; i< length; i++) {
4044 pkt->data.data[i] = getByte(&temp);
4045 }
4046
4047 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4048 &pkt->data.data[0], pkt->data.length, 0);
4049}
4050
4051/**---------------------------------------------------------------------------
4052
4053 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4054 encrypt message request
4055 This is an asynchronous callback function from SME when the encrypted data
4056 is received
4057
4058 \pEncInfoRsp -> Encrypted data info
4059
4060 \return - 0 for success non-zero for failure
4061 --------------------------------------------------------------------------*/
4062static void
4063hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4064{
4065 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4066
4067 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4068
4069 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4070 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4071 pEncryptedDataRsp->encryptedPayload.length);
4072 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4073 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4074 pEncryptedDataRsp->encryptedPayload.data,
4075 pEncryptedDataRsp->encryptedPayload.length, 0);
4076}
4077
Jeff Johnson295189b2012-06-20 16:38:30 -07004078VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4079{
4080 struct statsContext context;
4081 eHalStatus status;
4082 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304083 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004084
4085 if (NULL == pAdapter)
4086 {
4087 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4088 return VOS_STATUS_E_FAULT;
4089 }
4090
4091 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304093 if (pHddCtx->isLogpInProgress) {
4094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4095 "%s:LOGP in Progress. Ignore!!!", __func__);
4096 return VOS_STATUS_E_FAILURE;
4097 }
4098
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 init_completion(&context.completion);
4100
4101 context.pAdapter = pAdapter;
4102 context.magic = POWER_CONTEXT_MAGIC;
4103
4104 if (DRIVER_POWER_MODE_ACTIVE == mode)
4105 {
4106 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4107 "Full Power", __func__);
4108 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4109 iw_power_callback_fn, &context,
4110 eSME_FULL_PWR_NEEDED_BY_HDD);
4111 // Enter Full power command received from GUI this means we are disconnected
4112 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4113 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4114 if (eHAL_STATUS_PMC_PENDING == status)
4115 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004116 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 int lrc = wait_for_completion_interruptible_timeout(
4118 &context.completion,
4119 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004120
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 if (lrc <= 0)
4122 {
4123 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004124 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 }
4126 }
4127 }
4128 else if (DRIVER_POWER_MODE_AUTO == mode)
4129 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304130 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4131 * was already in BMPS state and thus either STA or P2P-CLI is in
4132 * associated state and authenticated, so even if STA connState is
4133 * not associated it can be assumed that P2P-CLI is associated and
4134 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4135 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4136 * if all condition are satisfied for entering BMPS.
4137 */
4138 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4139 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304140 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304141 hddLog(LOGE,
4142 FL("Station is associated but, still not Authenticated ignore "
4143 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304144 return VOS_STATUS_E_AGAIN;
4145 }
4146
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4148 {
4149 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4150 __func__);
4151 // Enter BMPS command received from GUI this means DHCP is completed
4152 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4153 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4154 FALSE);
4155 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4156 iw_power_callback_fn, &context);
4157 if (eHAL_STATUS_PMC_PENDING == status)
4158 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004159 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 int lrc = wait_for_completion_interruptible_timeout(
4161 &context.completion,
4162 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 if (lrc <= 0)
4164 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004165 hddLog(VOS_TRACE_LEVEL_ERROR,
4166 "%s: SME %s while requesting BMPS",
4167 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 }
4169 }
4170 }
4171 else
4172 {
4173 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4174 "enabled in the cfg");
4175 }
4176 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004177
4178 /* either we never sent a request, we sent a request and received a
4179 response or we sent a request and timed out. if we never sent a
4180 request or if we sent a request and got a response, we want to
4181 clear the magic out of paranoia. if we timed out there is a
4182 race condition such that the callback function could be
4183 executing at the same time we are. of primary concern is if the
4184 callback function had already verified the "magic" but had not
4185 yet set the completion variable when a timeout occurred. we
4186 serialize these activities by invalidating the magic while
4187 holding a shared spinlock which will cause us to block if the
4188 callback is currently executing */
4189 spin_lock(&hdd_context_lock);
4190 context.magic = 0;
4191 spin_unlock(&hdd_context_lock);
4192
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 return VOS_STATUS_SUCCESS;
4194}
4195
4196VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4197 hdd_adapter_t *pAdapter)
4198{
4199 VOS_STATUS vos_Status;
4200
4201 if ((NULL == pAdapter) || (NULL == pHddCtx))
4202 {
4203 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4204 return VOS_STATUS_E_FAULT;
4205 }
4206
4207 /**Exit from Deep sleep or standby if we get the driver
4208 START cmd from android GUI
4209 */
4210 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4211 {
4212 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4213 "from Stand by",__func__);
4214 vos_Status = hdd_exit_standby(pHddCtx);
4215 }
4216 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4217 {
4218 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4219 "from deep sleep",__func__);
4220 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4221 }
4222 else
4223 {
4224 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4225 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4226 vos_Status = VOS_STATUS_SUCCESS;
4227 }
4228
4229 return vos_Status;
4230}
4231
4232VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4233{
4234 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4235
4236 if (NULL == pHddCtx)
4237 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304238 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 return VOS_STATUS_E_FAULT;
4240 }
4241
4242 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4243 {
4244 //Execute standby procedure.
4245 //Executing standby procedure will cause the STA to
4246 //disassociate first and then the chip will be put into standby.
4247 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4248 vos_Status = hdd_enter_standby(pHddCtx);
4249 }
4250 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4251 pHddCtx->cfg_ini->nEnableDriverStop)
4252 {
4253 //Execute deep sleep procedure
4254 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004255 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 //Deep sleep not supported
4257 vos_Status = hdd_enter_standby(pHddCtx);
4258 }
4259 else
4260 {
4261 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4262 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4263 vos_Status = VOS_STATUS_SUCCESS;
4264 }
4265
4266 return vos_Status;
4267}
4268
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004269
4270void* wlan_hdd_change_country_code_callback(void *pAdapter)
4271{
4272
4273 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004274 complete(&call_back_pAdapter->change_country_code);
4275
4276 return NULL;
4277}
4278
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304279static int __iw_set_priv(struct net_device *dev,
4280 struct iw_request_info *info,
4281 union iwreq_data *wrqu, char *extra)
4282{
4283 hdd_adapter_t *pAdapter;
4284 char *cmd = NULL;
4285 int cmd_len = wrqu->data.length;
4286 int rc = 0, ret = 0;
4287 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4288
4289 hdd_context_t *pHddCtx;
4290
4291 ENTER();
4292
4293 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4294 if (NULL == pAdapter)
4295 {
4296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4297 "mem_alloc_copy_from_user_helper fail");
4298 return -EINVAL;
4299 }
4300 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4301 rc = wlan_hdd_validate_context(pHddCtx);
4302 if (0 != rc)
4303 {
4304 return rc;
4305 }
4306
4307 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4308 wrqu->data.length);
4309 if (NULL == cmd)
4310 {
4311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4312 "mem_alloc_copy_from_user_helper fail");
4313 return -ENOMEM;
4314 }
4315
4316 if (ioctl_debug)
4317 {
4318 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4319 }
4320
4321 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4322 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4323
4324 if (strncmp(cmd, "CSCAN", 5) == 0 )
4325 {
4326 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4328 "%s: Error in iw_set_scan!", __func__);
4329 rc = -EINVAL;
4330 }
4331 }
4332 else if( strcasecmp(cmd, "start") == 0 ) {
4333
4334 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4335 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4336
4337 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4338 if (vos_status == VOS_STATUS_SUCCESS)
4339 {
4340 union iwreq_data wrqu;
4341 char buf[10];
4342
4343 memset(&wrqu, 0, sizeof(wrqu));
4344 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4345 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4346 }
4347 else
4348 {
4349 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4350 rc = -EIO;
4351 }
4352 goto done;
4353 }
4354 else if( strcasecmp(cmd, "stop") == 0 )
4355 {
4356 union iwreq_data wrqu;
4357 char buf[10];
4358
4359 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4360
4361 wlan_hdd_enter_lowpower(pHddCtx);
4362 memset(&wrqu, 0, sizeof(wrqu));
4363 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4364 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4365 goto done;
4366 }
4367 else if (strcasecmp(cmd, "macaddr") == 0)
4368 {
4369 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4370 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4371 }
4372 else if (strcasecmp(cmd, "scan-active") == 0)
4373 {
4374 hddLog(LOG1,
4375 FL("making default scan to active"));
4376 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4377 ret = snprintf(cmd, cmd_len, "OK");
4378 }
4379 else if (strcasecmp(cmd, "scan-passive") == 0)
4380 {
4381 hddLog(LOG1,
4382 FL("making default scan to passive"));
4383 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4384 ret = snprintf(cmd, cmd_len, "OK");
4385 }
4386 else if( strcasecmp(cmd, "scan-mode") == 0 )
4387 {
4388 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4389 }
4390 else if( strcasecmp(cmd, "linkspeed") == 0 )
4391 {
4392 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4393 }
4394 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4395 {
4396 ret = iw_get_rssi(dev, info, wrqu, cmd);
4397 }
4398 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4399 int mode;
4400 char *ptr;
4401
4402 if (9 < cmd_len)
4403 {
4404 ptr = (char*)(cmd + 9);
4405
4406 }else{
4407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4408 "CMD LENGTH %d is not correct",cmd_len);
4409 kfree(cmd);
4410 return -EINVAL;
4411 }
4412
4413 if (1 != sscanf(ptr,"%d",&mode))
4414 {
4415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4416 "powermode input %s is not correct",ptr);
4417 kfree(cmd);
4418 return -EIO;
4419 }
4420
4421 wlan_hdd_enter_bmps(pAdapter, mode);
4422 /*TODO:Set the power mode*/
4423 }
4424 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4425 v_U32_t pmc_state;
4426 v_U16_t value;
4427
4428 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4429 if(pmc_state == BMPS) {
4430 value = DRIVER_POWER_MODE_AUTO;
4431 }
4432 else {
4433 value = DRIVER_POWER_MODE_ACTIVE;
4434 }
4435 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4436 }
4437 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4438 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4439 /*TODO: set the btcoexmode*/
4440 }
4441 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4442
4443 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4444 /*TODO: Return the btcoex status*/
4445 }
4446 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4447
4448 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4449
4450 /*TODO: Enable Rx data Filter*/
4451 }
4452 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4453
4454 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4455
4456 /*TODO: Disable Rx data Filter*/
4457 }
4458 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4459
4460 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4461 /*TODO: rxfilter-statistics*/
4462 }
4463 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4464
4465 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4466 /*TODO: rxfilter-add*/
4467 }
4468 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4469
4470 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4471 /*TODO: rxfilter-remove*/
4472 }
4473#ifdef FEATURE_WLAN_SCAN_PNO
4474 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4475 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4476 /*TODO: support pnosetup*/
4477 }
4478 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4479 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4480 /*TODO: support pnoforce*/
4481 }
4482 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4483
4484 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4485 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4486 kfree(cmd);
4487 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4488 }
4489 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4490 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4491 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4492 kfree(cmd);
4493 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4494 }
4495#endif /*FEATURE_WLAN_SCAN_PNO*/
4496 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4497 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4498 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4499 kfree(cmd);
4500 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4501 }
4502 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4503 tSirTxPerTrackingParam tTxPerTrackingParam;
4504 char *ptr;
4505
4506 if (18 < cmd_len)
4507 {
4508 ptr = (char*)(cmd + 18);
4509 }else{
4510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4511 "CMD LENGTH %d is not correct",cmd_len);
4512 kfree(cmd);
4513 return -EINVAL;
4514 }
4515
4516 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4517 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4518 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4519 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4520 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4521 {
4522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4523 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4524 kfree(cmd);
4525 return -EIO;
4526 }
4527
4528 // parameters checking
4529 // period has to be larger than 0
4530 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4531 {
4532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4533 kfree(cmd);
4534 return -EIO;
4535 }
4536
4537 // use default value 5 is the input is not reasonable. in unit of 10%
4538 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4539 {
4540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4541 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4542 }
4543
4544 // default is 5
4545 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4546 {
4547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4548 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4549 }
4550
4551 if (eHAL_STATUS_SUCCESS !=
4552 sme_SetTxPerTracking(pHddCtx->hHal,
4553 hdd_tx_per_hit_cb,
4554 (void*)pAdapter, &tTxPerTrackingParam)) {
4555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4556 rc = -EIO;
4557 }
4558 }
4559 else {
4560 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4561 __func__, cmd);
4562 }
4563done:
4564 /* many of the commands write information back into the command
4565 string using snprintf(). check the return value here in one
4566 place */
4567 if ((ret < 0) || (ret >= cmd_len))
4568 {
4569 /* there was an encoding error or overflow */
4570 rc = -EINVAL;
4571 }
4572 else if (ret > 0)
4573 {
4574 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4575 {
4576 hddLog(VOS_TRACE_LEVEL_ERROR,
4577 "%s: failed to copy data to user buffer", __func__);
4578 kfree(cmd);
4579 return -EFAULT;
4580 }
4581 wrqu->data.length = ret;
4582 }
4583
4584 if (ioctl_debug)
4585 {
4586 pr_info("%s: rsp [%s] len [%d] status %d\n",
4587 __func__, cmd, wrqu->data.length, rc);
4588 }
4589 kfree(cmd);
4590 EXIT();
4591 return rc;
4592}
4593
4594static int iw_set_priv(struct net_device *dev,
4595 struct iw_request_info *info,
4596 union iwreq_data *wrqu, char *extra)
4597{
4598 int ret;
4599 vos_ssr_protect(__func__);
4600 ret = __iw_set_priv(dev, info, wrqu, extra);
4601 vos_ssr_unprotect(__func__);
4602
4603 return ret;
4604}
4605
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304606static int __iw_set_nick(struct net_device *dev,
4607 struct iw_request_info *info,
4608 union iwreq_data *wrqu, char *extra)
4609{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304610 hdd_adapter_t *pAdapter;
4611 hdd_context_t *pHddCtx;
4612 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304613
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304614 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615
4616 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4617 if (NULL == pAdapter)
4618 {
4619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4620 "%s: Adapter is NULL",__func__);
4621 return -EINVAL;
4622 }
4623
4624 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4625 ret = wlan_hdd_validate_context(pHddCtx);
4626 if (0 != ret)
4627 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304628 return ret;
4629 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304630 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304631 return 0;
4632}
4633
Jeff Johnson295189b2012-06-20 16:38:30 -07004634static int iw_set_nick(struct net_device *dev,
4635 struct iw_request_info *info,
4636 union iwreq_data *wrqu, char *extra)
4637{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304638 int ret;
4639
4640 vos_ssr_protect(__func__);
4641 ret = __iw_set_nick(dev, info, wrqu, extra);
4642 vos_ssr_unprotect(__func__);
4643
4644 return ret;
4645}
4646
4647static int __iw_get_nick(struct net_device *dev,
4648 struct iw_request_info *info,
4649 union iwreq_data *wrqu, char *extra)
4650{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304651 hdd_adapter_t *pAdapter;
4652 hdd_context_t *pHddCtx;
4653 int ret = 0;
4654
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304656
4657 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4658 if (NULL == pAdapter)
4659 {
4660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4661 "%s: Adapter is NULL",__func__);
4662 return -EINVAL;
4663 }
4664
4665 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4666 ret = wlan_hdd_validate_context(pHddCtx);
4667 if (0 != ret)
4668 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304669 return ret;
4670 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304671 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 return 0;
4673}
4674
4675static int iw_get_nick(struct net_device *dev,
4676 struct iw_request_info *info,
4677 union iwreq_data *wrqu, char *extra)
4678{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304679 int ret;
4680
4681 vos_ssr_protect(__func__);
4682 ret = __iw_get_nick(dev, info, wrqu, extra);
4683 vos_ssr_unprotect(__func__);
4684
4685 return ret;
4686}
4687
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304688/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304689static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4690{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304691 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4692 hdd_context_t *pHddCtx;
4693 hdd_station_ctx_t *pHddStaCtx;
4694 v_S7_t snr = 0, rssi = 0;
4695 eHalStatus status = eHAL_STATUS_SUCCESS;
4696
4697 ENTER();
4698
4699 if (NULL == pAdapter)
4700 {
4701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4702 "%s: Adapter is NULL",__func__);
4703 return NULL;
4704 }
4705
4706 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4707 status = wlan_hdd_validate_context(pHddCtx);
4708 if (0 != status)
4709 {
4710 return NULL;
4711 }
4712
4713 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4714 if (NULL == pHddStaCtx)
4715 {
4716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4717 "%s: STA Context is NULL",__func__);
4718 return NULL;
4719 }
4720
4721 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4722 {
4723 wlan_hdd_get_station_stats(pAdapter);
4724 wlan_hdd_get_snr(pAdapter, &snr);
4725 wlan_hdd_get_rssi(pAdapter, &rssi);
4726
4727 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4728 pAdapter->iwStats.status = 0;
4729 pAdapter->iwStats.qual.qual = snr;
4730 pAdapter->iwStats.qual.level = rssi;
4731 pAdapter->iwStats.qual.noise = rssi - snr;
4732 pAdapter->iwStats.discard.code = 0;
4733 pAdapter->iwStats.discard.retries= 0;
4734 pAdapter->iwStats.miss.beacon = 0;
4735 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4736 }
4737 else
4738 {
4739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4740 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4741 return NULL;
4742 }
4743
4744 EXIT();
4745 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004746}
4747
4748static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4749{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304750
4751 struct iw_statistics *stats;
4752
4753 vos_ssr_protect(__func__);
4754 stats = __get_wireless_stats(dev);
4755 vos_ssr_unprotect(__func__);
4756
4757 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004758}
4759
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304760static int __iw_set_encode(struct net_device *dev,
4761 struct iw_request_info *info,
4762 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004763
4764{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304765 hdd_adapter_t *pAdapter;
4766 hdd_station_ctx_t *pHddStaCtx;
4767 hdd_wext_state_t *pWextState;
4768 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 struct iw_point *encoderq = &(wrqu->encoding);
4770 v_U32_t keyId;
4771 v_U8_t key_length;
4772 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4773 v_BOOL_t fKeyPresent = 0;
4774 int i;
4775 eHalStatus status = eHAL_STATUS_SUCCESS;
4776
4777
4778 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304779 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4780 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4783 "%s: Adapter is NULL",__func__);
4784 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 }
4786
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304787 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4788 status = wlan_hdd_validate_context(pHddCtx);
4789 if (0 != status)
4790 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304791 return status;
4792 }
4793 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4794 if (NULL == pWextState)
4795 {
4796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4797 "%s: pWextState is NULL ",__func__);
4798 return -EINVAL;
4799 }
4800 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4801 if (NULL == pHddStaCtx)
4802 {
4803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4804 "%s: STA Context is NULL",__func__);
4805 return -EINVAL;
4806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004807
4808 keyId = encoderq->flags & IW_ENCODE_INDEX;
4809
4810 if(keyId)
4811 {
4812 if(keyId > MAX_WEP_KEYS)
4813 {
4814 return -EINVAL;
4815 }
4816
4817 fKeyPresent = 1;
4818 keyId--;
4819 }
4820 else
4821 {
4822 fKeyPresent = 0;
4823 }
4824
4825
4826 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4827 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 if(!fKeyPresent) {
4830
4831 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4832
4833 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4834 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4835 }
4836 }
4837 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4838 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4839 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4840 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4841
4842 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4843 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4844
4845 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4846 {
4847 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4848 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004849 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304850 {
4851 long ret;
4852 ret = wait_for_completion_interruptible_timeout(
4853 &pAdapter->disconnect_comp_var,
4854 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4855 if (ret <= 0)
4856 hddLog(VOS_TRACE_LEVEL_ERROR,
4857 FL("failed wait on disconnect_comp_var %ld"), ret);
4858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 }
4860
4861 return status;
4862
4863 }
4864
4865 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4866 {
4867 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4868
4869 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4870
4871 }
4872
4873
4874 if(wrqu->data.length > 0)
4875 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004876 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004877
4878 key_length = wrqu->data.length;
4879
4880 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4881
4882 if(5 == key_length)
4883 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004884 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004885
4886 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4887 {
4888 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4889 }
4890 else
4891 {
4892 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4893 }
4894 }
4895 else if(13 == key_length)
4896 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004897 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004898
4899 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4900 {
4901 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4902 }
4903 else
4904 {
4905 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4906 }
4907 }
4908 else
4909 {
4910 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004911 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 return -EINVAL;
4913 }
4914
4915 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4916 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4917 pWextState->roamProfile.EncryptionType.numEntries = 1;
4918 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4919 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4920 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4921
4922 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4923 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4924 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4925 {
4926
4927 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4928
4929 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4930 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4931
4932 return status;
4933 }
4934 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304935 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 return 0;
4937}
4938
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304939static int iw_set_encode(struct net_device *dev,
4940 struct iw_request_info *info,
4941 union iwreq_data *wrqu,char *extra)
4942{
4943 int ret;
4944
4945 vos_ssr_protect(__func__);
4946 ret = __iw_set_encode(dev, info, wrqu, extra);
4947 vos_ssr_unprotect(__func__);
4948
4949 return ret;
4950}
4951
4952static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 struct iw_request_info *info,
4954 struct iw_point *dwrq,
4955 char *extra)
4956{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304957 hdd_adapter_t *pAdapter;
4958 hdd_wext_state_t *pWextState;
4959 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 int keyId;
4961 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4962 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304963 int i, ret = 0;
4964 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004965
4966 ENTER();
4967
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304968 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4969 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004970 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4972 "%s: Adapter is NULL",__func__);
4973 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004974 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304975 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4976 ret = wlan_hdd_validate_context(pHddCtx);
4977 if (0 != ret)
4978 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304979 return ret;
4980 }
4981 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4982 if (NULL == pWextState)
4983 {
4984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4985 "%s: pWextState is NULL",__func__);
4986 return -EINVAL;
4987 }
4988 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004989
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 keyId = pRoamProfile->Keys.defaultIndex;
4991
4992 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4993 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004994 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 return -EINVAL;
4996 }
4997
4998 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4999 {
5000 dwrq->flags |= IW_ENCODE_ENABLED;
5001 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05305002 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
5003 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 }
5005 else
5006 {
5007 dwrq->flags |= IW_ENCODE_DISABLED;
5008 }
5009
5010 for(i=0; i < MAX_WEP_KEYS; i++)
5011 {
5012 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5013 {
5014 continue;
5015 }
5016 else
5017 {
5018 break;
5019 }
5020 }
5021
5022 if(MAX_WEP_KEYS == i)
5023 {
5024 dwrq->flags |= IW_ENCODE_NOKEY;
5025 }
5026 else
5027 {
5028 dwrq->flags |= IW_ENCODE_ENABLED;
5029 }
5030
5031 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5032
5033 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5034 {
5035 dwrq->flags |= IW_ENCODE_DISABLED;
5036 }
5037
5038 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5039
5040 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5041 {
5042 dwrq->flags |= IW_ENCODE_OPEN;
5043 }
5044 else
5045 {
5046 dwrq->flags |= IW_ENCODE_RESTRICTED;
5047 }
5048 EXIT();
5049 return 0;
5050
5051}
5052
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305053static int iw_get_encodeext(struct net_device *dev,
5054 struct iw_request_info *info,
5055 struct iw_point *dwrq,
5056 char *extra)
5057{
5058 int ret;
5059 vos_ssr_protect(__func__);
5060 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5061 vos_ssr_unprotect(__func__);
5062
5063 return ret;
5064}
5065
5066static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 struct iw_request_info *info,
5068 union iwreq_data *wrqu, char *extra)
5069{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305070 hdd_adapter_t *pAdapter;
5071 hdd_station_ctx_t *pHddStaCtx;
5072 hdd_wext_state_t *pWextState;
5073 hdd_context_t *pHddCtx;
5074 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305076 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 v_U32_t status = 0;
5078
5079 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5080
5081 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5082
5083 int key_index;
5084 struct iw_point *encoding = &wrqu->encoding;
5085 tCsrRoamSetKey setKey;
5086 v_U32_t roamId= 0xFF;
5087 VOS_STATUS vos_status;
5088
5089 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305090 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5091 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5094 "%s: Adapter is NULL",__func__);
5095 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305097 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5098 status = wlan_hdd_validate_context(pHddCtx);
5099 if (0 != status)
5100 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305101 return status;
5102 }
5103 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5104 if (NULL == pHddStaCtx)
5105 {
5106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5107 "%s: STA Context is NULL",__func__);
5108 return -EINVAL;
5109 }
5110 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5111 if (NULL == pWextState)
5112 {
5113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5114 "%s: pWextState is NULL",__func__);
5115 return -EINVAL;
5116 }
5117 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 key_index = encoding->flags & IW_ENCODE_INDEX;
5119
5120 if(key_index > 0) {
5121
5122 /*Convert from 1-based to 0-based keying*/
5123 key_index--;
5124 }
5125 if(!ext->key_len) {
5126
5127 /*Set the encrytion type to NONE*/
5128 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5129 return status;
5130 }
5131
5132 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5133 (IW_ENCODE_ALG_WEP == ext->alg))
5134 {
5135 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5136
Agarwal Ashish971c2882013-10-30 20:11:12 +05305137 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5138 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 return -EINVAL;
5140 }
5141 else {
5142 /*Static wep, update the roam profile with the keys */
5143 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5144 key_index < CSR_MAX_NUM_KEY) {
5145 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5146 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5147
5148 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5149 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5150
5151 }
5152 }
5153 return status;
5154 }
5155
5156 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5157
5158 setKey.keyId = key_index;
5159 setKey.keyLength = ext->key_len;
5160
5161 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5162 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5163 }
5164
5165 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5166 /*Key direction for group is RX only*/
5167 setKey.keyDirection = eSIR_RX_ONLY;
5168 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5169 }
5170 else {
5171
5172 setKey.keyDirection = eSIR_TX_RX;
5173 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5174 }
5175
5176 /*For supplicant pae role is zero*/
5177 setKey.paeRole = 0;
5178
5179 switch(ext->alg)
5180 {
5181 case IW_ENCODE_ALG_NONE:
5182 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5183 break;
5184
5185 case IW_ENCODE_ALG_WEP:
5186 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5187 break;
5188
5189 case IW_ENCODE_ALG_TKIP:
5190 {
5191 v_U8_t *pKey = &setKey.Key[0];
5192
5193 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5194
5195 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5196
5197 /*Supplicant sends the 32bytes key in this order
5198
5199 |--------------|----------|----------|
5200 | Tk1 |TX-MIC | RX Mic |
5201 |--------------|----------|----------|
5202 <---16bytes---><--8bytes--><--8bytes-->
5203
5204 */
5205 /*Sme expects the 32 bytes key to be in the below order
5206
5207 |--------------|----------|----------|
5208 | Tk1 |RX-MIC | TX Mic |
5209 |--------------|----------|----------|
5210 <---16bytes---><--8bytes--><--8bytes-->
5211 */
5212 /* Copy the Temporal Key 1 (TK1) */
5213 vos_mem_copy(pKey,ext->key,16);
5214
5215 /*Copy the rx mic first*/
5216 vos_mem_copy(&pKey[16],&ext->key[24],8);
5217
5218 /*Copy the tx mic */
5219 vos_mem_copy(&pKey[24],&ext->key[16],8);
5220
5221 }
5222 break;
5223
5224 case IW_ENCODE_ALG_CCMP:
5225 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5226 break;
5227
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005228#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005229#define IW_ENCODE_ALG_KRK 6
5230 case IW_ENCODE_ALG_KRK:
5231 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5232 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005233#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005234
5235 default:
5236 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5237 break;
5238 }
5239
5240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005241 ("%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 -07005242
5243#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305244 /* The supplicant may attempt to set the PTK once pre-authentication
5245 is done. Save the key in the UMAC and include it in the ADD
5246 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305248 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305250 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5251 "%s: Update PreAuth Key success", __func__);
5252 return 0;
5253 }
5254 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5255 {
5256 hddLog(VOS_TRACE_LEVEL_ERROR,
5257 "%s: Update PreAuth Key failed", __func__);
5258 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 }
5260#endif /* WLAN_FEATURE_VOWIFI_11R */
5261
5262 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5263
5264 vos_status = wlan_hdd_check_ula_done(pAdapter);
5265 if ( vos_status != VOS_STATUS_SUCCESS )
5266 {
5267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5268 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5269 __LINE__, vos_status );
5270
5271 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5272 }
5273
5274 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5275
5276 if ( halStatus != eHAL_STATUS_SUCCESS )
5277 {
5278 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5279 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5280 __LINE__, halStatus );
5281
5282 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5283 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305284 EXIT();
5285 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005286}
5287
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305288static int iw_set_encodeext(struct net_device *dev,
5289 struct iw_request_info *info,
5290 union iwreq_data *wrqu, char *extra)
5291{
5292 int ret;
5293
5294 vos_ssr_protect(__func__);
5295 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5296 vos_ssr_unprotect(__func__);
5297
5298 return ret;
5299}
5300
5301static int __iw_set_retry(struct net_device *dev,
5302 struct iw_request_info *info,
5303 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005304{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305305 hdd_adapter_t *pAdapter;
5306 tHalHandle hHal;
5307 hdd_context_t *pHddCtx;
5308 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005309
5310 ENTER();
5311
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305312 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5313 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005314 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5316 "%s: Adapter is NULL",__func__);
5317 return -EINVAL;
5318 }
5319
5320 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5321 ret = wlan_hdd_validate_context(pHddCtx);
5322 if (0 != ret)
5323 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305324 return ret;
5325 }
5326
5327 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5328 if (NULL == hHal)
5329 {
5330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5331 "%s: Hal Context is NULL",__func__);
5332 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005333 }
5334
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5336 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5337
Arif Hussain6d2a3322013-11-17 19:50:10 -08005338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005339
5340 return -EINVAL;
5341 }
5342
5343 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5344
5345 if((wrqu->retry.flags & IW_RETRY_LONG))
5346 {
5347 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5348 {
c_hpothub8245442013-11-20 23:41:09 +05305349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5350 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 return -EIO;
5352 }
5353 }
5354 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5355 {
5356 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5357 {
c_hpothub8245442013-11-20 23:41:09 +05305358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5359 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 return -EIO;
5361 }
5362 }
5363 }
5364 else
5365 {
5366 return -EOPNOTSUPP;
5367 }
5368
Arif Hussain6d2a3322013-11-17 19:50:10 -08005369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005370
5371 EXIT();
5372
5373 return 0;
5374
5375}
5376
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305377static int iw_set_retry(struct net_device *dev,
5378 struct iw_request_info *info,
5379 union iwreq_data *wrqu, char *extra)
5380{
5381 int ret;
5382
5383 vos_ssr_protect(__func__);
5384 ret = __iw_set_retry(dev, info, wrqu, extra);
5385 vos_ssr_unprotect(__func__);
5386
5387 return ret;
5388}
5389
5390static int __iw_get_retry(struct net_device *dev,
5391 struct iw_request_info *info,
5392 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005393{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305394 hdd_adapter_t *pAdapter;
5395 hdd_context_t *pHddCtx;
5396 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305398 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399
5400 ENTER();
5401
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305402 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5403 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005404 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5406 "%s: Adapter is NULL",__func__);
5407 return -EINVAL;
5408 }
5409
5410 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5411 ret = wlan_hdd_validate_context(pHddCtx);
5412 if (0 != ret)
5413 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305414 return ret;
5415 }
5416
5417 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5418 if (NULL == hHal)
5419 {
5420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5421 "%s: Hal Context is NULL",__func__);
5422 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005423 }
5424
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 if((wrqu->retry.flags & IW_RETRY_LONG))
5426 {
5427 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5428
5429 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5430 {
c_hpothub8245442013-11-20 23:41:09 +05305431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5432 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 return -EIO;
5434 }
5435
5436 wrqu->retry.value = retry;
5437 }
5438 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5439 {
5440 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5441
5442 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5443 {
c_hpothub8245442013-11-20 23:41:09 +05305444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5445 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 return -EIO;
5447 }
5448
5449 wrqu->retry.value = retry;
5450 }
5451 else {
5452 return -EOPNOTSUPP;
5453 }
5454
Arif Hussain6d2a3322013-11-17 19:50:10 -08005455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005456
5457 EXIT();
5458
5459 return 0;
5460}
5461
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305462static int iw_get_retry(struct net_device *dev,
5463 struct iw_request_info *info,
5464 union iwreq_data *wrqu, char *extra)
5465{
5466 int ret;
5467
5468 vos_ssr_protect(__func__);
5469 ret = __iw_get_retry(dev, info, wrqu, extra);
5470 vos_ssr_unprotect(__func__);
5471
5472 return ret;
5473}
5474
5475static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 struct iw_request_info *info,
5477 union iwreq_data *wrqu,
5478 char *extra)
5479{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305480 hdd_adapter_t *pAdapter;
5481 hdd_context_t *pHddCtx;
5482 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5484 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305485 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005486
5487 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305488 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5489 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5492 "%s:Adapter is NULL",__func__);
5493 return -EINVAL;
5494 }
5495 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5496 ret = wlan_hdd_validate_context(pHddCtx);
5497 if (0 != ret)
5498 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305499 return ret;
5500 }
5501 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5502 if (NULL == pHddStaCtx)
5503 {
5504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5505 "%s:STA context is NULL",__func__);
5506 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 }
5508
5509 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5510 switch (mlme->cmd) {
5511 case IW_MLME_DISASSOC:
5512 case IW_MLME_DEAUTH:
5513
5514 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5515 {
5516 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5517
5518 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5519 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5520
5521 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5522 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5523
Jeff Johnson43971f52012-07-17 12:26:56 -07005524 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305525 {
5526 long ret;
5527 ret = wait_for_completion_interruptible_timeout(
5528 &pAdapter->disconnect_comp_var,
5529 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5530 if (ret <= 0)
5531 hddLog(VOS_TRACE_LEVEL_ERROR,
5532 FL("failed wait on disconnect_comp_var %ld"), ret);
5533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005535 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005536 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005537
5538 /* Resetting authKeyMgmt */
5539 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5540
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305541 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 netif_tx_disable(dev);
5543 netif_carrier_off(dev);
5544
5545 }
5546 else
5547 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005548 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 -07005549 }
5550 break;
5551 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005552 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 return -EINVAL;
5554 }//end of switch
5555
5556 EXIT();
5557
5558 return status;
5559
5560}
5561
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305562static int iw_set_mlme(struct net_device *dev,
5563 struct iw_request_info *info,
5564 union iwreq_data *wrqu,
5565 char *extra)
5566{
5567 int ret;
5568
5569 vos_ssr_protect(__func__);
5570 ret = __iw_set_mlme(dev, info, wrqu, extra);
5571 vos_ssr_unprotect(__func__);
5572
5573 return ret;
5574}
5575
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305576int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305577{
5578 sHwCalValues hwCalValues;
5579 uint16 hwCalTxPower;
5580 uint8 txPwr = TX_PWR_DEF;
5581
5582 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5583
5584 if (TRUE == set_value) {
5585 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5586 NULL, sizeof(sHwCalValues) )
5587 != VOS_STATUS_SUCCESS) {
5588 return -EINVAL;
5589 }
5590 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5591
5592 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5593 hwCalTxPower, hwCalValues.calData.hwParam7);
5594
5595 txPwr = (int8)(hwCalTxPower & 0x00FF);
5596 txPwr = txPwr/10;
5597 if (txPwr < TX_PWR_MIN)
5598 txPwr = TX_PWR_MIN;
5599 if (txPwr > TX_PWR_MAX)
5600 txPwr = TX_PWR_MAX;
5601
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305602 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305603 eHAL_STATUS_SUCCESS) {
5604 hddLog(VOS_TRACE_LEVEL_ERROR,
5605 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5606 return -EIO;
5607 }
5608
5609 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5610 txPwr /= 10;
5611 if (txPwr < TX_PWR_MIN)
5612 txPwr = TX_PWR_MIN;
5613 if (txPwr > TX_PWR_MAX)
5614 txPwr = TX_PWR_MAX;
5615
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305616 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305617 eHAL_STATUS_SUCCESS) {
5618 hddLog(VOS_TRACE_LEVEL_ERROR,
5619 FL("setting tx power failed for 5GHz band %d"), txPwr);
5620 return -EIO;
5621 }
5622 }
5623 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305624 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305625 eHAL_STATUS_SUCCESS) {
5626 hddLog(VOS_TRACE_LEVEL_ERROR,
5627 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5628 return -EIO;
5629 }
5630
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305631 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305632 eHAL_STATUS_SUCCESS) {
5633 hddLog(VOS_TRACE_LEVEL_ERROR,
5634 FL("setting tx power failed for 5GHz band %d"), txPwr);
5635 return -EIO;
5636 }
5637 }
5638 else {
5639 return -EINVAL;
5640 }
5641
5642 return eHAL_STATUS_SUCCESS;
5643}
Jeff Johnson295189b2012-06-20 16:38:30 -07005644/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305645static int __iw_setint_getnone(struct net_device *dev,
5646 struct iw_request_info *info,
5647 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005648{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305649 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305650 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305651 hdd_wext_state_t *pWextState;
5652 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305653 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 int *value = (int *)extra;
5655 int sub_cmd = value[0];
5656 int set_value = value[1];
5657 int ret = 0; /* success */
5658 int enable_pbm, enable_mp;
5659#ifdef CONFIG_HAS_EARLYSUSPEND
5660 v_U8_t nEnableSuspendOld;
5661#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005662
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305663 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305664 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5665 if (NULL == pAdapter)
5666 {
5667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5668 "%s: Adapter is NULL",__func__);
5669 return -EINVAL;
5670 }
5671 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5672 ret = wlan_hdd_validate_context(pHddCtx);
5673 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005674 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305675 return ret;
5676 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305677
Katya Nigameae74b62015-05-28 17:19:16 +05305678 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305679 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305680 /* In monitor mode hHal is NULL */
5681 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5682 if (NULL == hHal)
5683 {
5684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5685 "%s: Hal Context is NULL",__func__);
5686 return -EINVAL;
5687 }
Katya Nigameae74b62015-05-28 17:19:16 +05305688 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5689 if (NULL == pWextState)
5690 {
5691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5692 "%s: pWextState is NULL",__func__);
5693 return -EINVAL;
5694 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005695
Katya Nigameae74b62015-05-28 17:19:16 +05305696 INIT_COMPLETION(pWextState->completion_var);
5697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 switch(sub_cmd)
5699 {
5700 case WE_SET_11D_STATE:
5701 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005702 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005703 memset(&smeConfig, 0x00, sizeof(smeConfig));
5704
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305705 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5706 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 sme_GetConfigParam(hHal,&smeConfig);
5708 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5709
Arif Hussain6d2a3322013-11-17 19:50:10 -08005710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005711
5712 sme_UpdateConfig(hHal,&smeConfig);
5713 }
5714 else {
5715 return -EINVAL;
5716 }
5717 break;
5718 }
5719
5720 case WE_WOWL:
5721 {
5722 switch (set_value)
5723 {
5724 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305725 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 break;
5727 case 0x01:
5728 case 0x02:
5729 case 0x03:
5730 enable_mp = (set_value & 0x01) ? 1 : 0;
5731 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005732 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5734 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5735 break;
5736 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005737 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 ret = -EINVAL;
5739 break;
5740 }
5741
5742 break;
5743 }
5744 case WE_SET_POWER:
5745 {
5746 switch (set_value)
5747 {
5748 case 0: //Full Power
5749 {
5750 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305751 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005752
5753 init_completion(&context.completion);
5754
5755 context.pAdapter = pAdapter;
5756 context.magic = POWER_CONTEXT_MAGIC;
5757
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305758 if (NULL == hHal)
5759 return -EINVAL;
5760
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5762 iw_power_callback_fn, &context,
5763 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305764
Jeff Johnson72a40512013-12-19 10:14:15 -08005765 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 {
5767 int lrc = wait_for_completion_interruptible_timeout(
5768 &context.completion,
5769 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005770
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 if (lrc <= 0)
5772 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005773 hddLog(VOS_TRACE_LEVEL_ERROR,
5774 "%s: SME %s while requesting fullpower",
5775 __func__, (0 == lrc) ?
5776 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 }
5778 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005779 /* either we have a response or we timed out. if we timed
5780 out there is a race condition such that the callback
5781 function could be executing at the same time we are. of
5782 primary concern is if the callback function had already
5783 verified the "magic" but had not yet set the completion
5784 variable when a timeout occurred. we serialize these
5785 activities by invalidating the magic while holding a
5786 shared spinlock which will cause us to block if the
5787 callback is currently executing */
5788 spin_lock(&hdd_context_lock);
5789 context.magic = 0;
5790 spin_unlock(&hdd_context_lock);
5791
Arif Hussain6d2a3322013-11-17 19:50:10 -08005792 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 break;
5794 }
5795 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305796 if (hHal)
5797 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5798 else
5799 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 break;
5801 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305802 if (hHal)
5803 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5804 else
5805 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 break;
5807 case 3: //Request Bmps
5808 {
5809 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305810 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
5812 init_completion(&context.completion);
5813
5814 context.pAdapter = pAdapter;
5815 context.magic = POWER_CONTEXT_MAGIC;
5816
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305817 if (NULL == hHal)
5818 return -EINVAL;
5819
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305821 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005822 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 {
5824 int lrc = wait_for_completion_interruptible_timeout(
5825 &context.completion,
5826 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 if (lrc <= 0)
5828 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005829 hddLog(VOS_TRACE_LEVEL_ERROR,
5830 "%s: SME %s while requesting BMPS",
5831 __func__, (0 == lrc) ? "timeout" :
5832 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 }
5834 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005835 /* either we have a response or we timed out. if we
5836 timed out there is a race condition such that the
5837 callback function could be executing at the same
5838 time we are. of primary concern is if the callback
5839 function had already verified the "magic" but had
5840 not yet set the completion variable when a timeout
5841 occurred. we serialize these activities by
5842 invalidating the magic while holding a shared
5843 spinlock which will cause us to block if the
5844 callback is currently executing */
5845 spin_lock(&hdd_context_lock);
5846 context.magic = 0;
5847 spin_unlock(&hdd_context_lock);
5848
Arif Hussain6d2a3322013-11-17 19:50:10 -08005849 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 break;
5851 }
5852 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305853 if (hHal)
5854 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5855 else
5856 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 break;
5858 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305859 if (hHal)
5860 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5861 else
5862 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 break;
5864 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305865 if (hHal)
5866 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5867 else
5868 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 break;
5870 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305871 if (hHal)
5872 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5873 else
5874 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 break;
5876 case 8: //Request Standby
5877#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005878#endif
5879 break;
5880 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305881 if (hHal)
5882 sme_StartAutoBmpsTimer(hHal);
5883 else
5884 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 break;
5886 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305887 if (hHal)
5888 sme_StopAutoBmpsTimer(hHal);
5889 else
5890 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 break;
5892#ifdef CONFIG_HAS_EARLYSUSPEND
5893 case 11://suspend to standby
5894#ifdef CONFIG_HAS_EARLYSUSPEND
5895 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5896 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5898#endif
5899 break;
5900 case 12://suspend to deep sleep
5901#ifdef CONFIG_HAS_EARLYSUSPEND
5902 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5903 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5905#endif
5906 break;
5907 case 13://resume from suspend
5908#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005909#endif
5910 break;
5911#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005913 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 ret = -EINVAL;
5915 break;
5916 }
5917 break;
5918 }
5919
5920 case WE_SET_MAX_ASSOC:
5921 {
5922 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305923 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5924 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 {
5926 ret = -EINVAL;
5927 }
5928 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5929 set_value, NULL, eANI_BOOLEAN_FALSE)
5930 != eHAL_STATUS_SUCCESS )
5931 {
c_hpothub8245442013-11-20 23:41:09 +05305932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5933 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 ret = -EIO;
5935 }
5936 break;
5937 }
5938
5939 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5940 {
5941 if( 0 == set_value )
5942 {
5943 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5944 }
5945 else if ( 1 == set_value )
5946 {
5947 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5948 }
5949 else
5950 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005951 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 ret = -EINVAL;
5953 }
5954 break;
5955 }
5956
5957 case WE_SET_DATA_INACTIVITY_TO:
5958 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305959 if (NULL == hHal)
5960 return -EINVAL;
5961
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5963 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5964 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5965 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5966 set_value,
5967 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5968 {
5969 hddLog(LOGE,"Failure: Could not pass on "
5970 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005971 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 ret = -EINVAL;
5973 }
5974 break;
5975 }
5976 case WE_SET_MAX_TX_POWER:
5977 {
5978 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5979 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5980
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305981 if (NULL == hHal)
5982 return -EINVAL;
5983
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5985 __func__, set_value);
5986 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5987 eHAL_STATUS_SUCCESS )
5988 {
5989 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5990 __func__);
5991 return -EIO;
5992 }
5993
5994 break;
5995 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005996 case WE_SET_MAX_TX_POWER_2_4:
5997 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305998 if (NULL == hHal)
5999 return -EINVAL;
6000
Arif Hussaina5ebce02013-08-09 15:09:58 -07006001 hddLog(VOS_TRACE_LEVEL_INFO,
6002 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6003 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306004 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006005 eHAL_STATUS_SUCCESS)
6006 {
6007 hddLog(VOS_TRACE_LEVEL_ERROR,
6008 "%s: Setting maximum tx power failed for 2.4 GHz band",
6009 __func__);
6010 return -EIO;
6011 }
6012
6013 break;
6014 }
6015 case WE_SET_MAX_TX_POWER_5_0:
6016 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306017 if (NULL == hHal)
6018 return -EINVAL;
6019
Arif Hussaina5ebce02013-08-09 15:09:58 -07006020 hddLog(VOS_TRACE_LEVEL_INFO,
6021 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6022 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306023 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006024 eHAL_STATUS_SUCCESS)
6025 {
6026 hddLog(VOS_TRACE_LEVEL_ERROR,
6027 "%s: Setting maximum tx power failed for 5.0 GHz band",
6028 __func__);
6029 return -EIO;
6030 }
6031
6032 break;
6033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 case WE_SET_HIGHER_DTIM_TRANSITION:
6035 {
6036 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6037 (set_value == eANI_BOOLEAN_TRUE)))
6038 {
6039 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6040 ret = -EINVAL;
6041 }
6042 else
6043 {
6044 if(pAdapter->higherDtimTransition != set_value)
6045 {
6046 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006047 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 }
6049 }
6050
6051 break;
6052 }
6053
6054 case WE_SET_TM_LEVEL:
6055 {
6056 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006057 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6059
6060 break;
6061 }
6062
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306063 case WE_ENABLE_STRICT_FCC_REG:
6064 {
6065 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6066 struct wiphy *wiphy = NULL;
6067 long lrc;
6068 int status;
6069
6070 wiphy = hddCtxt->wiphy;
6071 if(wiphy == NULL)
6072 {
6073 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6074 break;
6075 }
6076 init_completion(&hddCtxt->wiphy_channel_update_event);
6077
6078 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6079
6080 status = regulatory_hint(wiphy, "00");
6081 if(status < 0)
6082 {
6083 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6084 break;
6085 }
6086
6087 /* Wait for completion */
6088 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6089 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6090 if (lrc <= 0)
6091 {
6092 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6093 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6094 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6095 }
6096 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6097
6098 break;
6099 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006100 case WE_SET_DEBUG_LOG:
6101 {
6102 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6103 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306104 if (hHal)
6105 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6106 else
6107 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006108 break;
6109 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306110#ifdef FEATURE_WLAN_TDLS
6111 case WE_SET_TDLS_OFF_CHAN:
6112 {
6113 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6115 __func__, set_value);
6116 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6117 break;
6118 }
6119 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6120 {
6121 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6123 __func__, set_value);
6124 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6125 break;
6126 }
6127 case WE_SET_TDLS_OFF_CHAN_MODE:
6128 {
6129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6130 __func__, set_value);
6131 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6132 break;
6133 }
6134#endif
Peng Xu2446a892014-09-05 17:21:18 +05306135 case WE_SET_SCAN_BAND_PREFERENCE:
6136 {
6137 tSmeConfigParams smeConfig;
6138 memset(&smeConfig, 0x00, sizeof(smeConfig));
6139 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6140 ret = -EINVAL;
6141 break;
6142 }
6143 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6144
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306145 if ((eCSR_BAND_ALL == set_value ||
6146 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6147 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306148 sme_GetConfigParam(hHal, &smeConfig);
6149 smeConfig.csrConfig.scanBandPreference = set_value;
6150
6151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6152 "set band scan preference = %d\n",
6153 smeConfig.csrConfig.scanBandPreference);
6154
6155 sme_UpdateConfig(hHal, &smeConfig);
6156 }
6157 else {
6158 ret = -EINVAL;
6159 }
6160 break;
6161 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306162 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6163 * connection happens so that the params can take effect during
6164 * association. Also this should not be used in STA+p2p concurrency
6165 * as the param will also effect the STA mode.
6166 */
6167 case WE_SET_MIRACAST_VENDOR_CONFIG:
6168 {
6169 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306170
Abhishek Singh01c73d12015-03-12 15:13:44 +05306171 hddLog(LOG1, FL(
6172 "Set Miracast vendor tuning %d"), set_value);
6173
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306174 if (NULL == hHal)
6175 return -EINVAL;
6176
Abhishek Singh01c73d12015-03-12 15:13:44 +05306177 if (1 == set_value || 0 == set_value)
6178 {
6179 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6180 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6181 {
6182 hddLog( LOGE, FL("set vendor miracast config failed"));
6183 ret = -EIO;
6184 }
6185 }
6186 else
6187 {
6188 hddLog(LOGE,
6189 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6190 ret = -EINVAL;
6191 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306192 break;
6193 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306194
6195 case WE_GET_FRAME_LOG:
6196 {
6197 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6198 != VOS_STATUS_SUCCESS)
6199 {
6200 ret = -EINVAL;
6201 }
6202 break;
6203 }
6204
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306205 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6206 {
6207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6208 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306209 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306210 {
6211 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6212 set_value);
6213 }
6214 else
6215 ret = -EINVAL;
6216
6217 break;
6218 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306219 /* Bit mask value to enable RTS/CTS for different modes
6220 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6221 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6222 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6223 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6224 * for 5 GHz, VHT80 - 0x1000
6225 */
6226 case WE_SET_RTS_CTS_HTVHT:
6227 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306228
Abhishek Singh41988ba2015-05-25 19:42:29 +05306229 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6230
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306231 if (NULL == hHal)
6232 return -EINVAL;
6233
Abhishek Singh41988ba2015-05-25 19:42:29 +05306234 if (eHAL_STATUS_SUCCESS !=
6235 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6236 {
6237 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6238 ret = -EINVAL;
6239 }
6240 break;
6241 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306242 case WE_SET_MONITOR_STATE:
6243 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306244 v_U32_t magic = 0;
6245 struct completion cmpVar;
6246 long waitRet = 0;
6247 tVOS_CON_MODE mode = hdd_get_conparam();
6248
6249 if( VOS_MONITOR_MODE != mode)
6250 {
6251 hddLog(LOGE, "invalid mode %d", mode);
6252 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306253 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306254 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306255
6256 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6257 if( pMonCtx == NULL )
6258 {
6259 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306260 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306261 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306262 }
6263 if (pMonCtx->state == set_value)
6264 {
6265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6266 FL("already in same mode curr_mode:%d req_mode: %d"),
6267 pMonCtx->state, set_value);
6268 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306269 }
6270 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306271 magic = MON_MODE_MSG_MAGIC;
6272 init_completion(&cmpVar);
6273 if (VOS_STATUS_SUCCESS !=
6274 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6275 pMonCtx, hdd_monPostMsgCb)) {
6276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6277 FL("failed to post MON MODE REQ"));
6278 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6279 MON_MODE_STOP : MON_MODE_START;
6280 magic = 0;
6281 ret = -EIO;
6282 break;
6283 }
6284 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6285 magic = 0;
6286 if (waitRet <= 0 ){
6287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6288 FL("failed to wait on monitor mode completion %ld"),
6289 waitRet);
6290 }
6291 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306292 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306293 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6294 {
6295 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6296 tAniWifiStartLog start_log;
6297 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6298 !vos_isPktStatsEnabled())
6299 {
6300 hddLog(LOGE, FL("per pkt stats not enabled"));
6301 return -EINVAL;
6302 }
6303 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6304
6305 if (1 == set_value || 0 == set_value)
6306 {
6307 start_log.ringId = RING_ID_PER_PACKET_STATS;
6308 start_log.flag = 0;
6309 if (set_value)
6310 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6311 else
6312 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6313
6314 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6315 }
6316 else
6317 {
6318 hddLog(LOGE,
6319 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6320 set_value);
6321 ret = -EINVAL;
6322 }
6323 break;
6324 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306325 case WE_SET_PROXIMITY_ENABLE:
6326 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306327 if (NULL == hHal)
6328 return -EINVAL;
6329
6330 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306331 break;
6332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 default:
6334 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006335 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 sub_cmd, set_value);
6337 break;
6338 }
6339 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306340 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 return ret;
6342}
6343
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306344static int iw_setint_getnone(struct net_device *dev,
6345 struct iw_request_info *info,
6346 union iwreq_data *wrqu, char *extra)
6347{
6348 int ret;
6349
6350 vos_ssr_protect(__func__);
6351 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6352 vos_ssr_unprotect(__func__);
6353
6354 return 0;
6355}
Jeff Johnson295189b2012-06-20 16:38:30 -07006356/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306357static int __iw_setchar_getnone(struct net_device *dev,
6358 struct iw_request_info *info,
6359 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006360{
6361 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306362 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006364 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306365 hdd_adapter_t *pAdapter;
6366 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006367#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306368 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006369#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306370 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306371 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306373 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306374
6375 if (!capable(CAP_NET_ADMIN))
6376 {
6377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6378 FL("permission check failed"));
6379 return -EPERM;
6380 }
6381
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306382 pAdapter = (netdev_priv(dev));
6383 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006384 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6386 "%s: Adapter is NULL",__func__);
6387 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006388 }
6389
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306390 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6391 ret = wlan_hdd_validate_context(pHddCtx);
6392 if (0 != ret)
6393 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306394 return ret;
6395 }
6396#ifdef WLAN_FEATURE_VOWIFI
6397 pConfig = pHddCtx->cfg_ini;
6398#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306399 /* helper function to get iwreq_data with compat handling. */
6400 if (hdd_priv_get_data(&s_priv_data, wrqu))
6401 {
6402 return -EINVAL;
6403 }
6404
6405 /* make sure all params are correctly passed to function */
6406 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6407 {
6408 return -EINVAL;
6409 }
6410
6411 sub_cmd = s_priv_data.flags;
6412
Arif Hussain0273cba2014-01-07 20:58:29 -08006413 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306414 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6415 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006416 if (NULL == pBuffer)
6417 {
6418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6419 "mem_alloc_copy_from_user_helper fail");
6420 return -ENOMEM;
6421 }
6422
6423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306424 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6426 "%s: Received data %s", __func__, pBuffer);
6427
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 switch(sub_cmd)
6429 {
6430 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006432 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 break;
6434 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006436 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 break;
6438#if defined WLAN_FEATURE_VOWIFI
6439 case WE_NEIGHBOR_REPORT_REQUEST:
6440 {
6441 tRrmNeighborReq neighborReq;
6442 tRrmNeighborRspCallbackInfo callbackInfo;
6443
6444 if (pConfig->fRrmEnable)
6445 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306447 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 if( !neighborReq.no_ssid )
6449 {
Girish Gowli552fc072014-06-14 18:26:16 +05306450 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006451 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 }
6453
6454 callbackInfo.neighborRspCallback = NULL;
6455 callbackInfo.neighborRspCallbackContext = NULL;
6456 callbackInfo.timeout = 5000; //5 seconds
6457 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6458 }
6459 else
6460 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006461 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 ret = -EINVAL;
6463 }
6464 }
6465 break;
6466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 case WE_SET_AP_WPS_IE:
6468 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306469 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006472 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 if (VOS_STATUS_SUCCESS != vstatus)
6474 {
6475 ret = -EINVAL;
6476 }
6477 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306478 case WE_SET_ENCRYPT_MSG:
6479 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6480 if (NULL == pkt)
6481 {
6482 hddLog(VOS_TRACE_LEVEL_ERROR,
6483 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306484 ret = -ENOMEM;
6485 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306486 }
6487
6488 memset(pkt, 0, sizeof(tSirpkt80211));
6489
6490 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6491 hddLog(VOS_TRACE_LEVEL_ERROR,
6492 FL("Firmware is not DISA capable"));
6493 ret = -EINVAL;
6494 vos_mem_free(pkt);
6495 break;
6496 }
6497
6498 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6499
6500 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6501 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6502 if (eHAL_STATUS_SUCCESS != ret) {
6503 hddLog(VOS_TRACE_LEVEL_ERROR,
6504 FL("SENDEncryptMSG: fail to post WDA cmd"));
6505 ret = -EINVAL;
6506 }
6507 vos_mem_free(pkt);
6508
6509 break;
6510
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 default:
6512 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006513 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 ret = -EINVAL;
6515 break;
6516 }
6517 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006518 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306519
6520 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 return ret;
6522}
6523
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306524static int iw_setchar_getnone(struct net_device *dev,
6525 struct iw_request_info *info,
6526 union iwreq_data *wrqu, char *extra)
6527{
6528 int ret;
6529
6530 vos_ssr_protect(__func__);
6531 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6532 vos_ssr_unprotect(__func__);
6533
6534 return ret;
6535}
6536
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306537static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6538{
6539 struct statsContext *context;
6540 hdd_adapter_t *pAdapter;
6541
6542 if (NULL == pContext)
6543 {
6544 hddLog(VOS_TRACE_LEVEL_ERROR,
6545 "%s: Bad param, pContext [%p]",
6546 __func__, pContext);
6547 return;
6548 }
6549
6550 context = pContext;
6551 pAdapter = context->pAdapter;
6552
6553 spin_lock(&hdd_context_lock);
6554
6555 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6556 {
6557 /* the caller presumably timed out so there is nothing we can do */
6558 spin_unlock(&hdd_context_lock);
6559 hddLog(VOS_TRACE_LEVEL_WARN,
6560 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6561 __func__, pAdapter, context->magic);
6562 return;
6563 }
6564
6565 context->magic = 0;
6566 pAdapter->antennaIndex = antennaId;
6567
6568 complete(&context->completion);
6569 spin_unlock(&hdd_context_lock);
6570}
6571
6572static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6573 int *antennaIndex)
6574{
6575 hdd_context_t *pHddCtx;
6576 eHalStatus halStatus;
6577 struct statsContext context;
6578 long lrc;
6579
6580 ENTER();
6581 if (NULL == pAdapter)
6582 {
6583 hddLog(VOS_TRACE_LEVEL_WARN,
6584 "%s: Invalid context, pAdapter", __func__);
6585 return VOS_STATUS_E_FAULT;
6586 }
6587 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6588 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6589 {
6590 return VOS_STATUS_E_FAULT;
6591 }
6592 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6593 {
6594 hddLog(VOS_TRACE_LEVEL_ERROR,
6595 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6596 __func__);
6597 return VOS_STATUS_E_NOSUPPORT;
6598 }
6599 init_completion(&context.completion);
6600 context.pAdapter = pAdapter;
6601 context.magic = ANTENNA_CONTEXT_MAGIC;
6602
6603 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6604 hdd_GetCurrentAntennaIndex,
6605 &context, pAdapter->sessionId);
6606 if (eHAL_STATUS_SUCCESS != halStatus)
6607 {
6608 spin_lock(&hdd_context_lock);
6609 context.magic = 0;
6610 spin_unlock(&hdd_context_lock);
6611 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6612 __func__);
6613 /* we'll returned a cached value below */
6614 *antennaIndex = -1;
6615 return VOS_STATUS_E_FAILURE;
6616 }
6617 else
6618 {
6619 /* request was sent -- wait for the response */
6620 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6621 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6622 if (lrc <= 0)
6623 {
6624 spin_lock(&hdd_context_lock);
6625 context.magic = 0;
6626 spin_unlock(&hdd_context_lock);
6627 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6628 " Index",
6629 __func__, (0 == lrc) ? "timeout" : "interrupt");
6630 *antennaIndex = -1;
6631 return VOS_STATUS_E_FAILURE;
6632 }
6633 }
6634 spin_lock(&hdd_context_lock);
6635 context.magic = 0;
6636 spin_unlock(&hdd_context_lock);
6637
6638 *antennaIndex = pAdapter->antennaIndex;
6639
6640 EXIT();
6641 return VOS_STATUS_SUCCESS;
6642}
6643
Jeff Johnson295189b2012-06-20 16:38:30 -07006644/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306645static int __iw_setnone_getint(struct net_device *dev,
6646 struct iw_request_info *info,
6647 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006648{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306649 hdd_adapter_t *pAdapter;
6650 tHalHandle hHal;
6651 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 int *value = (int *)extra;
6653 int ret = 0; /* success */
6654
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306655 ENTER();
6656
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306657 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6658 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006659 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6661 "%s: Adapter is NULL",__func__);
6662 return -EINVAL;
6663 }
6664 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6665 ret = wlan_hdd_validate_context(pHddCtx);
6666 if (0 != ret)
6667 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306668 return ret;
6669 }
6670 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6671 if (NULL == hHal)
6672 {
6673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6674 "%s: Hal Context is NULL",__func__);
6675 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006677
6678 switch (value[0])
6679 {
6680 case WE_GET_11D_STATE:
6681 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006682 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306684
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6686
Arif Hussain6d2a3322013-11-17 19:50:10 -08006687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006688
6689 break;
6690 }
6691
6692 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 break;
6695
6696 case WE_PMC_STATE:
6697 {
6698 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 break;
6701 }
6702 case WE_GET_WLAN_DBG:
6703 {
6704 vos_trace_display();
6705 *value = 0;
6706 break;
6707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 case WE_GET_MAX_ASSOC:
6709 {
6710 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6711 {
c_hpothub8245442013-11-20 23:41:09 +05306712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6713 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 ret = -EIO;
6715 }
Girish Gowli385be612014-09-18 11:17:20 +05306716#ifdef WLAN_SOFTAP_VSTA_FEATURE
6717 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6718 {
6719 if (*value > VSTA_NUM_ASSOC_STA)
6720 {
6721 *value = VSTA_NUM_ASSOC_STA;
6722 }
6723 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6724 (*value > (VSTA_NUM_ASSOC_STA -
6725 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6726 {
6727 *value = (VSTA_NUM_ASSOC_STA -
6728 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6729 }
6730 }
6731 else
6732#endif
6733 {
6734 if (*value > NUM_ASSOC_STA)
6735 {
6736 *value = NUM_ASSOC_STA;
6737 }
6738 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6739 (*value > (NUM_ASSOC_STA -
6740 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6741 {
6742 *value = (NUM_ASSOC_STA -
6743 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6744 }
6745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 break;
6747 }
6748
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 case WE_GET_WDI_DBG:
6750 {
6751 wpalTraceDisplay();
6752 *value = 0;
6753 break;
6754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006755
6756 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6757 {
6758 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6759 break;
6760 }
6761 case WE_GET_CONCURRENCY_MODE:
6762 {
6763 *value = hdd_get_concurrency_mode ( );
6764
Arif Hussain6d2a3322013-11-17 19:50:10 -08006765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 break;
6767 }
6768
Peng Xu2446a892014-09-05 17:21:18 +05306769 case WE_GET_SCAN_BAND_PREFERENCE:
6770 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306771 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306772 sme_GetConfigParam(hHal, &smeConfig);
6773 *value = smeConfig.csrConfig.scanBandPreference;
6774
6775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6776 "scanBandPreference = %d\n", *value);
6777 break;
6778 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306779 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6780 {
6781 wlan_hdd_get_current_antenna_index(pAdapter, value);
6782 break;
6783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 default:
6785 {
6786 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6787 break;
6788 }
6789 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306790 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 return ret;
6792}
6793
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306794static int iw_setnone_getint(struct net_device *dev,
6795 struct iw_request_info *info,
6796 union iwreq_data *wrqu, char *extra)
6797{
6798 int ret;
6799
6800 vos_ssr_protect(__func__);
6801 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6802 vos_ssr_unprotect(__func__);
6803
6804 return ret;
6805
6806}
Jeff Johnson295189b2012-06-20 16:38:30 -07006807/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306808int __iw_set_three_ints_getnone(struct net_device *dev,
6809 struct iw_request_info *info,
6810 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006811{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306812 hdd_adapter_t *pAdapter;
6813 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 int *value = (int *)extra;
6815 int sub_cmd = value[0];
6816 int ret = 0;
6817
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306818 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306819
6820 if (!capable(CAP_NET_ADMIN))
6821 {
6822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6823 FL("permission check failed"));
6824 return -EPERM;
6825 }
6826
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306827 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6828 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006829 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6831 "%s: Adapter is NULL",__func__);
6832 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006833 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306834 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6835 ret = wlan_hdd_validate_context(pHddCtx);
6836 if (0 != ret)
6837 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306838 return ret;
6839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 switch(sub_cmd)
6841 {
6842 case WE_SET_WLAN_DBG:
6843 {
6844 vos_trace_setValue( value[1], value[2], value[3]);
6845 break;
6846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 case WE_SET_WDI_DBG:
6848 {
6849 wpalTraceSetLevel( value[1], value[2], value[3]);
6850 break;
6851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 case WE_SET_SAP_CHANNELS:
6853 {
6854 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6855 break;
6856 }
6857
6858 default:
6859 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006860 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 break;
6862 }
6863 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306864 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 return ret;
6866}
6867
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306868int iw_set_three_ints_getnone(struct net_device *dev,
6869 struct iw_request_info *info,
6870 union iwreq_data *wrqu, char *extra)
6871{
6872 int ret;
6873
6874 vos_ssr_protect(__func__);
6875 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6876 vos_ssr_unprotect(__func__);
6877
6878 return ret;
6879}
6880
6881static int __iw_get_char_setnone(struct net_device *dev,
6882 struct iw_request_info *info,
6883 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006884{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306885 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306887 hdd_context_t *pHddCtx;
6888 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006889#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006890 hdd_wext_state_t *pWextState;
6891#endif
6892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306893 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306894 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006895 if (pAdapter == NULL)
6896 {
6897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6898 "%s: pAdapter is NULL!", __func__);
6899 return -EINVAL;
6900 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306901 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6902 ret = wlan_hdd_validate_context(pHddCtx);
6903 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006904 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306905 return ret;
6906 }
6907#ifdef WLAN_FEATURE_11W
6908 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6909 if (NULL == pWextState)
6910 {
6911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6912 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006913 return -EINVAL;
6914 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306915#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006916
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 switch(sub_cmd)
6918 {
6919 case WE_WLAN_VERSION:
6920 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006921 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 break;
6923 }
6924
6925 case WE_GET_STATS:
6926 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306927 tHalHandle hHal = NULL;
6928 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6930 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6931 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6932
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306933
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 snprintf(extra, WE_MAX_STR_LEN,
6935 "\nTransmit"
6936 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6937 "\n dropped BK %u, BE %u, VI %u, VO %u"
6938 "\n classified BK %u, BE %u, VI %u, VO %u"
6939 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6940 "\n queued BK %u, BE %u, VI %u, VO %u"
6941 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006942 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 "\n fetched BK %u, BE %u, VI %u, VO %u"
6944 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6945 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006946 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 "\n flushed BK %u, BE %u, VI %u, VO %u"
6948 "\n\nReceive"
6949 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6950 "\n\nResetsStats"
6951 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6952 "\n",
6953 pStats->txXmitCalled,
6954 pStats->txXmitDropped,
6955 pStats->txXmitBackPressured,
6956 pStats->txXmitQueued,
6957
6958 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6959 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6960 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6961 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6962
6963 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6964 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6965 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6966 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6967
6968 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6969 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6970 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6971 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6972
6973 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6974 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6975 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6976 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6977
6978 pStats->txFetched,
6979 pStats->txFetchEmpty,
6980 pStats->txFetchLowResources,
6981 pStats->txFetchDequeueError,
6982
6983 pStats->txFetchDequeued,
6984 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006985 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 pStats->txCompleted,
6987 pStats->txFlushed,
6988
6989 pStats->txFetchedAC[WLANTL_AC_BK],
6990 pStats->txFetchedAC[WLANTL_AC_BE],
6991 pStats->txFetchedAC[WLANTL_AC_VI],
6992 pStats->txFetchedAC[WLANTL_AC_VO],
6993
6994 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6995 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6996 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6997 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6998
6999 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7000 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7001 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7002 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7003
Ravi Joshi41914632013-10-21 23:02:21 -07007004 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7005 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7006 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7007 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7008
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 pStats->txFlushedAC[WLANTL_AC_BK],
7010 pStats->txFlushedAC[WLANTL_AC_BE],
7011 pStats->txFlushedAC[WLANTL_AC_VI],
7012 pStats->txFlushedAC[WLANTL_AC_VO],
7013
7014 pStats->rxChains,
7015 pStats->rxPackets,
7016 pStats->rxDropped,
7017 pStats->rxDelivered,
7018 pStats->rxRefused,
7019
7020 pResetStats->totalLogpResets,
7021 pResetStats->totalCMD53Failures,
7022 pResetStats->totalMutexReadFailures,
7023 pResetStats->totalMIFErrorFailures,
7024 pResetStats->totalFWHearbeatFailures,
7025 pResetStats->totalUnknownExceptions
7026 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307027 wrqu->data.length = strlen(extra);
7028
7029 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7030
7031 if (hHal)
7032 pMac = PMAC_STRUCT( hHal );
7033
7034 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7035 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7036 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307037 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7038 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7039 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7040 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307041 "\n",
7042 pMac->pmm.BmpscntSleep,
7043 pMac->pmm.BmpscntAwake,
7044 pMac->pmm.BmpsSleeReqFailCnt,
7045 pMac->pmm.BmpsWakeupReqFailCnt,
7046 pMac->pmm.ImpsCntSleep,
7047 pMac->pmm.ImpsCntAwake,
7048 pMac->pmm.ImpsSleepErrCnt,
7049 pMac->pmm.ImpsWakeupErrCnt,
7050 pMac->pmm.ImpsLastErr
7051 );
7052 }
7053
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 wrqu->data.length = strlen(extra)+1;
7055 break;
7056 }
7057
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307058/* The case prints the current state of the HDD, SME, CSR, PE, TL
7059 *it can be extended for WDI Global State as well.
7060 *And currently it only checks P2P_CLIENT adapter.
7061 *P2P_DEVICE and P2P_GO have not been added as of now.
7062*/
7063 case WE_GET_STATES:
7064 {
7065 int buf = 0, len = 0;
7066 int adapter_num = 0;
7067 int count = 0, check = 1;
7068
7069 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007070 tHalHandle hHal = NULL;
7071 tpAniSirGlobal pMac = NULL;
7072 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307073
7074 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7075 hdd_adapter_t *useAdapter = NULL;
7076
7077 /* Print wlan0 or p2p0 states based on the adapter_num
7078 *by using the correct adapter
7079 */
7080 while ( adapter_num < 2 )
7081 {
7082 if ( WLAN_ADAPTER == adapter_num )
7083 {
7084 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007085 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307086 "\n\n wlan0 States:-");
7087 len += buf;
7088 }
7089 else if ( P2P_ADAPTER == adapter_num )
7090 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007091 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307092 "\n\n p2p0 States:-");
7093 len += buf;
7094
7095 if( !pHddCtx )
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 pHddCtx is NULL");
7099 len += buf;
7100 break;
7101 }
7102
7103 /*Printing p2p0 states only in the case when the device is
7104 configured as a p2p_client*/
7105 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7106 if ( !useAdapter )
7107 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007108 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307109 "\n Device not configured as P2P_CLIENT.");
7110 len += buf;
7111 break;
7112 }
7113 }
7114
7115 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007116 if (!hHal) {
7117 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7118 "\n pMac is NULL");
7119 len += buf;
7120 break;
7121 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307122 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007123 if (!pMac) {
7124 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7125 "\n pMac is NULL");
7126 len += buf;
7127 break;
7128 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307129 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7130 if( !pHddStaCtx )
7131 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007132 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307133 "\n pHddStaCtx is NULL");
7134 len += buf;
7135 break;
7136 }
7137
7138 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7139
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007140 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307141 "\n HDD Conn State - %s "
7142 "\n \n SME State:"
7143 "\n Neighbour Roam State - %s"
7144 "\n CSR State - %s"
7145 "\n CSR Substate - %s"
7146 "\n \n TL STA %d State: %s",
7147 macTraceGetHDDWlanConnState(
7148 pHddStaCtx->conn_info.connState),
7149 macTraceGetNeighbourRoamState(
7150 pMac->roam.neighborRoamInfo.neighborRoamState),
7151 macTraceGetcsrRoamState(
7152 pMac->roam.curState[useAdapter->sessionId]),
7153 macTraceGetcsrRoamSubState(
7154 pMac->roam.curSubState[useAdapter->sessionId]),
7155 pHddStaCtx->conn_info.staId[0],
7156 macTraceGetTLState(tlState)
7157 );
7158 len += buf;
7159 adapter_num++;
7160 }
7161
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007162 if (pMac) {
7163 /* Printing Lim State starting with global lim states */
7164 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7165 "\n \n LIM STATES:-"
7166 "\n Global Sme State - %s "\
7167 "\n Global mlm State - %s "\
7168 "\n",
7169 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7170 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7171 );
7172 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307173
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007174 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307175 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307176 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007177 if ( pMac->lim.gpSession[count].valid )
7178 {
7179 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7180 "\n Lim Valid Session %d:-"
7181 "\n PE Sme State - %s "
7182 "\n PE Mlm State - %s "
7183 "\n",
7184 check,
7185 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7186 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7187 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307188
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007189 len += buf;
7190 check++;
7191 }
7192 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307193 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307194 }
7195
7196 wrqu->data.length = strlen(extra)+1;
7197 break;
7198 }
7199
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 case WE_GET_CFG:
7201 {
7202 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7203 wrqu->data.length = strlen(extra)+1;
7204 break;
7205 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007206#ifdef WLAN_FEATURE_11AC
7207 case WE_GET_RSSI:
7208 {
7209 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307210 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007211 wlan_hdd_get_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
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307217
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007218#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007219 case WE_GET_ROAM_RSSI:
7220 {
7221 v_S7_t s7Rssi = 0;
7222 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7223 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7224 wrqu->data.length = strlen(extra)+1;
7225 break;
7226 }
7227#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 case WE_GET_WMM_STATUS:
7229 {
7230 snprintf(extra, WE_MAX_STR_LEN,
7231 "\nDir: 0=up, 1=down, 3=both\n"
7232 "|------------------------|\n"
7233 "|AC | ACM |Admitted| Dir |\n"
7234 "|------------------------|\n"
7235 "|VO | %d | %3s | %d |\n"
7236 "|VI | %d | %3s | %d |\n"
7237 "|BE | %d | %3s | %d |\n"
7238 "|BK | %d | %3s | %d |\n"
7239 "|------------------------|\n",
7240 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7241 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7242 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7243 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7244 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7245 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7246 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7247 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7248 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7249 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7250 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7251 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7252
Jeff Johnsone7245742012-09-05 17:12:55 -07007253
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 wrqu->data.length = strlen(extra)+1;
7255 break;
7256 }
7257 case WE_GET_CHANNEL_LIST:
7258 {
7259 VOS_STATUS status;
7260 v_U8_t i, len;
7261 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307262 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7263 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7264 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 tChannelListInfo channel_list;
7266
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007267 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007269 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 return -EINVAL;
7273 }
7274 buf = extra;
7275
7276 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007277 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7278 * needed = 5 * number of channels. Check ifsufficient
7279 * buffer is available and then proceed to fill the buffer.
7280 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7282 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007283 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007284 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007285 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 return -EINVAL;
7287 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007288 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7289 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307290 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7291 {
7292 //Printing Country code in getChannelList
7293 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7294 {
7295 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7296 "%c ", pBuf[i]);
7297 }
7298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 for(i = 0 ; i < channel_list.num_channels; i++)
7300 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007301 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007303 }
7304 wrqu->data.length = strlen(extra)+1;
7305
7306 break;
7307 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007308#ifdef FEATURE_WLAN_TDLS
7309 case WE_GET_TDLS_PEERS:
7310 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007311 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007312 break;
7313 }
7314#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007315#ifdef WLAN_FEATURE_11W
7316 case WE_GET_11W_INFO:
7317 {
7318 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7319
7320 snprintf(extra, WE_MAX_STR_LEN,
7321 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7322 "\n Number of Unprotected Disassocs %d"
7323 "\n Number of Unprotected Deauths %d",
7324 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7325 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7326 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7327 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7328 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7329
7330 wrqu->data.length = strlen(extra)+1;
7331 break;
7332 }
7333#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307334#ifdef WLAN_FEATURE_RMC
7335 case WE_GET_IBSS_STA_INFO:
7336 {
7337 hdd_station_ctx_t *pHddStaCtx =
7338 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7339 int idx = 0;
7340 int length = 0, buf = 0;
7341
7342 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7343 {
7344 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7345 {
7346 buf = snprintf
7347 (
7348 (extra + length), WE_MAX_STR_LEN - length,
7349 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7350 pHddStaCtx->conn_info.staId[ idx ],
7351 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7352 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7353 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7354 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7355 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7356 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7357 );
7358 length += buf;
7359 }
7360 }
7361 wrqu->data.length = strlen(extra)+1;
7362 break;
7363 }
7364#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307365 case WE_GET_SNR:
7366 {
7367 v_S7_t s7snr = 0;
7368 int status = 0;
7369 hdd_context_t *pHddCtx;
7370 hdd_station_ctx_t *pHddStaCtx;
7371
7372 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7373 status = wlan_hdd_validate_context(pHddCtx);
7374 if (0 != status)
7375 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307376 return status;
7377 }
7378
7379 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7380
7381 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7382 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7383 {
7384 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7385 " ConnectionState-%d", __func__,
7386 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7387 pHddStaCtx->conn_info.connState);
7388 return -ENONET;
7389 }
7390
7391 /*update the stats in TL*/
7392 wlan_hdd_get_station_stats(pAdapter);
7393 wlan_hdd_get_snr(pAdapter, &s7snr);
7394 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7395 wrqu->data.length = strlen(extra) + 1;
7396 break;
7397 }
7398
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307399#ifdef FEATURE_OEM_DATA_SUPPORT
7400 case WE_GET_OEM_DATA_CAP:
7401 {
7402 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7403 }
7404#endif /* FEATURE_OEM_DATA_SUPPORT */
7405
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307406 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007408 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 break;
7410 }
7411 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307412 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 return 0;
7414}
7415
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307416static int iw_get_char_setnone(struct net_device *dev,
7417 struct iw_request_info *info,
7418 union iwreq_data *wrqu, char *extra)
7419{
7420 int ret;
7421
7422 vos_ssr_protect(__func__);
7423 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7424 vos_ssr_unprotect(__func__);
7425
7426 return ret;
7427}
7428
Jeff Johnson295189b2012-06-20 16:38:30 -07007429/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307430static int __iw_setnone_getnone(struct net_device *dev,
7431 struct iw_request_info *info,
7432 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007433{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307434 hdd_adapter_t *pAdapter;
7435 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307436 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007437 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307438 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007439
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307440 ENTER();
7441
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307442 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7443 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007444 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7446 "%s: Adapter is NULL",__func__);
7447 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007448 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307449 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7450 ret = wlan_hdd_validate_context(pHddCtx);
7451 if (0 != ret)
7452 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307453 return ret;
7454 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307455 /* helper function to get iwreq_data with compat handling. */
7456 if (hdd_priv_get_data(&s_priv_data, wrqu))
7457 {
7458 return -EINVAL;
7459 }
7460
7461 sub_cmd = s_priv_data.flags;
7462
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 switch (sub_cmd)
7464 {
7465 case WE_CLEAR_STATS:
7466 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007468 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7469 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7470 break;
7471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 case WE_INIT_AP:
7473 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307474 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7475
7476 /* As Soft AP mode might been changed to STA already with
7477 * killing of Hostapd, need to find the adpater by name
7478 * rather than mode */
7479 hdd_adapter_t* pAdapter_to_stop =
7480 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7481 if( pAdapter_to_stop )
7482 {
7483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7484 "Adapter with name softap.0 already "
7485 "exist, ignoring the request.\nRemove the "
7486 "adapter and try again\n");
7487 break;
7488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 pr_info("Init AP trigger\n");
7490 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7491 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7492 break;
7493 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307494#ifdef WLAN_FEATURE_RMC
7495 case WE_IBSS_GET_PEER_INFO_ALL:
7496 {
7497 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7498 break;
7499 }
7500#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 case WE_STOP_AP:
7502 {
7503 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7504 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7505 * this is a dead code and need to find the adpater by name rather than mode */
7506 hdd_adapter_t* pAdapter_to_stop =
7507 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7508 if( pAdapter_to_stop )
7509 {
7510 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7511
7512 pr_info("Stopping AP mode\n");
7513
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307514 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7515 {
7516 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7517 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7518 }
7519
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307521 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307522 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007523 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7524
7525 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7526 pAdapter_to_stop->macAddressCurrent.bytes);
7527 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7528 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307529
7530 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7531 {
7532 /* put the device back into BMPS */
7533 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 }
7536 else
7537 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007538 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 }
7540
7541 break;
7542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007543#ifdef WLAN_BTAMP_FEATURE
7544 case WE_ENABLE_AMP:
7545 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 WLANBAP_RegisterWithHCI(pAdapter);
7548 break;
7549 }
7550 case WE_DISABLE_AMP:
7551 {
7552 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7553 VOS_STATUS status;
7554
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007556
7557 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7558 status = WLANBAP_StopAmp();
7559 if(VOS_STATUS_SUCCESS != status )
7560 {
7561 pHddCtx->isAmpAllowed = VOS_TRUE;
7562 hddLog(VOS_TRACE_LEVEL_FATAL,
7563 "%s: Failed to stop AMP", __func__);
7564 }
7565 else
7566 {
7567 //a state m/c implementation in PAL is TBD to avoid this delay
7568 msleep(500);
7569 pHddCtx->isAmpAllowed = VOS_FALSE;
7570 WLANBAP_DeregisterFromHCI();
7571 }
7572
7573 break;
7574 }
7575#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007576 case WE_ENABLE_DXE_STALL_DETECT:
7577 {
schang6295e542013-03-12 15:31:23 -07007578 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7579 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007580 break;
7581 }
7582 case WE_DISPLAY_DXE_SNAP_SHOT:
7583 {
schang6295e542013-03-12 15:31:23 -07007584 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7585 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007586 break;
7587 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307588 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7589 {
7590 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7591 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307592 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307593 break;
7594 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307595
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307596 case WE_SET_REASSOC_TRIGGER:
7597 {
7598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7599 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7600 v_U32_t roamId = 0;
7601 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307602 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7603 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307604 return 0;
7605 }
7606
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307607 case WE_STOP_OBSS_SCAN:
7608 {
7609 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7610 2.OBSS scan is stopped by Firmware during the disassociation
7611 3.OBSS stop comamnd is added for debugging purpose*/
7612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7613 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007614
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307615 if (pAdapter == NULL)
7616 {
7617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7618 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307619 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307620 }
7621 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7622 if (pMac == NULL)
7623 {
7624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7625 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307626 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307627 }
7628 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7629 }
7630 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307631 case WE_DUMP_ROAM_TIMER_LOG:
7632 {
7633 vos_dump_roam_time_log_service();
7634 break;
7635 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307636
Mukul Sharma84f27252014-07-14 18:11:42 +05307637 case WE_RESET_ROAM_TIMER_LOG:
7638 {
7639 vos_reset_roam_timer_log();
7640 break;
7641 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307642 case WE_GET_FW_LOGS:
7643 {
7644 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7645 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307646 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307647 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307648 break;
7649 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307650 case WE_GET_FW_MEMDUMP:
7651 {
7652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7653 "FW_MEM_DUMP requested ");
7654 get_fwr_memdump(dev,info,wrqu,extra);
7655 break;
7656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 default:
7658 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007659 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 break;
7661 }
7662 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307663 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 return ret;
7665}
7666
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307667static int iw_setnone_getnone(struct net_device *dev,
7668 struct iw_request_info *info,
7669 union iwreq_data *wrqu, char *extra)
7670{
7671 int ret;
7672
7673 vos_ssr_protect(__func__);
7674 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7675 vos_ssr_unprotect(__func__);
7676
7677 return ret;
7678}
7679
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307680void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7681{
7682 /*
7683 * Function to display HDD WMM information
7684 * for Tx Queues.
7685 * Prints globala as well as per client depending
7686 * whether the clients are registered or not.
7687 */
7688 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307689 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7690 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307691 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7692 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307693 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307694
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307695 for ( i=0; i< NUM_TX_QUEUES; i++)
7696 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307697 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307698 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307699 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307700 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307701
7702 for ( i=0; i< NUM_TX_QUEUES; i++) {
7703 if (tx_queue_count[i]) {
7704 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7705 i, tx_queue_count[i]);
7706 }
7707 }
7708
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307709 if(pSapCtx == NULL){
7710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7711 FL("psapCtx is NULL"));
7712 return;
7713 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307714
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307715 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307716 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7717 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307718 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307719 {
7720 hddLog(LOGE, "******STAIndex: %d*********", i);
7721 for ( j=0; j< NUM_TX_QUEUES; j++)
7722 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307723 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7724 {
7725 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307726 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7727 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307728 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7729 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307730 }
7731 }
7732 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307733 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307734
Katya Nigam1fd24402015-02-16 14:52:19 +05307735 if(pHddStaCtx == NULL){
7736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7737 FL("pHddStaCtx is NULL"));
7738 return;
7739 }
7740
7741 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7742 if(pPeerInfo == NULL){
7743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7744 FL("ppeerinfo is NULL"));
7745 return;
7746 }
7747
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307748 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7749 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7750 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7751 for (j = 0; j < NUM_TX_QUEUES; j++) {
7752 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7753 spin_lock_bh(
7754 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7755 hddLog(LOGE,
7756 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7757 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7758 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7759 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7760 spin_unlock_bh(
7761 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7762 }
7763 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307764 }
7765 }
7766
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307767}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307768
Girish Gowlifb9758e2014-11-19 15:19:17 +05307769static int __iw_set_var_ints_getnone(struct net_device *dev,
7770 struct iw_request_info *info,
7771 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007772{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307773 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307774 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307775 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307776 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007777 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307778 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307779 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007780 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307781 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007782 int cmd = 0;
7783 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307784 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007785
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307786 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307787 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307788 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7790 "%s: NULL extra buffer pointer", __func__);
7791 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307792 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307793 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7794 if (NULL == pAdapter)
7795 {
7796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7797 "%s: Adapter is NULL",__func__);
7798 return -EINVAL;
7799 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307800 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7802 ret = wlan_hdd_validate_context(pHddCtx);
7803 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007804 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307805 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007806 }
Katya Nigameae74b62015-05-28 17:19:16 +05307807 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307808 {
Katya Nigameae74b62015-05-28 17:19:16 +05307809 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7810 if (NULL == hHal)
7811 {
7812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7813 "%s: Hal Context is NULL",__func__);
7814 return -EINVAL;
7815 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307816 }
7817 sub_cmd = wrqu->data.flags;
7818
7819 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7820
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007821
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007822 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7823 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7824 {
7825 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7826 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7827 {
7828 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7829 staId = pStaCtx->conn_info.staId[0];
7830 }
7831 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7832 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7833 {
7834 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7835 staId = pAPCtx->uBCStaId;
7836 }
7837 else
7838 {
7839 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7840 return 0;
7841 }
7842 }
7843
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 switch (sub_cmd)
7845 {
7846 case WE_LOG_DUMP_CMD:
7847 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307848 if(apps_args[0] == 26) {
7849 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7850 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7851 return 0;
7852 }
7853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007855 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307857 if (hHal)
7858 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7859 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007860
7861 }
7862 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307863#ifdef WLAN_FEATURE_RMC
7864 case WE_IBSS_GET_PEER_INFO:
7865 {
7866 pr_info ( "Station ID = %d\n",apps_args[0]);
7867 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7868 }
7869 break;
7870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007871
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 case WE_P2P_NOA_CMD:
7873 {
7874 p2p_app_setP2pPs_t p2pNoA;
7875
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307876 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7877 hddLog(LOGE,
7878 FL("Setting NoA is not allowed in Device mode:%d"),
7879 pAdapter->device_mode);
7880 return -EINVAL;
7881 }
7882
Jeff Johnson295189b2012-06-20 16:38:30 -07007883 p2pNoA.opp_ps = apps_args[0];
7884 p2pNoA.ctWindow = apps_args[1];
7885 p2pNoA.duration = apps_args[2];
7886 p2pNoA.interval = apps_args[3];
7887 p2pNoA.count = apps_args[4];
7888 p2pNoA.single_noa_duration = apps_args[5];
7889 p2pNoA.psSelection = apps_args[6];
7890
7891 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7892 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007893 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7895
7896 hdd_setP2pPs(dev, &p2pNoA);
7897
7898 }
7899 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007900
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307901 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7902 {
7903 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7904 __func__, apps_args[0], apps_args[1]);
7905 vosTraceEnable(apps_args[0], apps_args[1]);
7906 }
7907 break;
7908
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007909 case WE_MTRACE_DUMP_CMD:
7910 {
7911 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7912 "bitmask_of_module %d ",
7913 __func__, apps_args[0], apps_args[1], apps_args[2],
7914 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307915 if (hHal)
7916 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7917 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007918
7919 }
7920 break;
7921
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007922 case WE_MCC_CONFIG_CREDENTIAL :
7923 {
7924 cmd = 287; //Command should be updated if there is any change
7925 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007926 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007927 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307928 if (hHal)
7929 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7930 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007931 }
7932 else
7933 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007934 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007935 return 0;
7936 }
7937 }
7938 break;
7939
7940 case WE_MCC_CONFIG_PARAMS :
7941 {
7942 cmd = 288; //command Should be updated if there is any change
7943 // in the Riva dump command
7944 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7945 }
7946 break;
7947
Chilam NG571c65a2013-01-19 12:27:36 +05307948#ifdef FEATURE_WLAN_TDLS
7949 case WE_TDLS_CONFIG_PARAMS :
7950 {
7951 tdls_config_params_t tdlsParams;
7952
Chilam Ng01120412013-02-19 18:32:21 -08007953 tdlsParams.tdls = apps_args[0];
7954 tdlsParams.tx_period_t = apps_args[1];
7955 tdlsParams.tx_packet_n = apps_args[2];
7956 tdlsParams.discovery_period_t = apps_args[3];
7957 tdlsParams.discovery_tries_n = apps_args[4];
7958 tdlsParams.idle_timeout_t = apps_args[5];
7959 tdlsParams.idle_packet_n = apps_args[6];
7960 tdlsParams.rssi_hysteresis = apps_args[7];
7961 tdlsParams.rssi_trigger_threshold = apps_args[8];
7962 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307963
Chilam Ng01120412013-02-19 18:32:21 -08007964 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307965 }
7966 break;
7967#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307968 case WE_CONFIGURE_MONITOR_MODE:
7969 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307970 v_U32_t magic = 0;
7971 struct completion cmpVar;
7972 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307973 tVOS_CON_MODE mode = hdd_get_conparam();
7974
7975 if (VOS_MONITOR_MODE != mode) {
7976 hddLog(LOGE, FL("invalid mode %d"), mode);
7977 return -EIO;
7978 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307979
Katya Nigamf0511f62015-05-05 16:40:57 +05307980 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7981 if( pMonCtx == NULL )
7982 {
7983 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307984 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307985 }
7986 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7987 __func__, apps_args[0], apps_args[1], apps_args[2],
7988 apps_args[3], apps_args[4]);
7989 /* Input Validation part of FW */
7990 pMonCtx->ChannelNo = apps_args[0];
7991 pMonCtx->ChannelBW = apps_args[1];
7992 pMonCtx->crcCheckEnabled = apps_args[2];
7993 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7994 pMonCtx->is80211to803ConReq = apps_args[4];
7995 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7996 if( pMonCtx->is80211to803ConReq )
7997 pAdapter->dev->type = ARPHRD_ETHER;
7998 else
7999 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8000 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8001 {
8002 hddLog(LOGE, "%s: Filtering data packets as management and control"
8003 " cannot be converted to 802.3 ",__func__);
8004 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8005 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308006 if (MON_MODE_START == pMonCtx->state) {
8007 magic = MON_MODE_MSG_MAGIC;
8008 init_completion(&cmpVar);
8009 if (VOS_STATUS_SUCCESS !=
8010 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8011 pMonCtx, hdd_monPostMsgCb)) {
8012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8013 FL("failed to post MON MODE REQ"));
8014 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308015 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308016 }
8017 waitRet = wait_for_completion_timeout(&cmpVar,
8018 MON_MODE_MSG_TIMEOUT);
8019 magic = 0;
8020 if (waitRet <= 0 ) {
8021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8022 FL("failed to wait on monitor mode completion %ld"),
8023 waitRet);
8024 }
8025 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308026 }
8027 break;
8028
8029 case WE_SET_MONITOR_MODE_FILTER:
8030 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308031 v_U32_t magic = 0;
8032 struct completion cmpVar;
8033 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308034 tVOS_CON_MODE mode = hdd_get_conparam();
8035
8036 if (VOS_MONITOR_MODE != mode) {
8037 hddLog(LOGE, FL("invalid mode %d"), mode);
8038 return -EIO;
8039 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308040
Katya Nigamf0511f62015-05-05 16:40:57 +05308041 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8042 if( pMonCtx == NULL )
8043 {
8044 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308045 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308046 }
8047 /* Input Validation Part of FW */
8048 pMonCtx->numOfMacFilters=1;
8049 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8050 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8051 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8052 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8053 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8054 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8055 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8056 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8057 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8058 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8059 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8060 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308061 if (MON_MODE_START == pMonCtx->state) {
8062 magic = MON_MODE_MSG_MAGIC;
8063 init_completion(&cmpVar);
8064 if (VOS_STATUS_SUCCESS !=
8065 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8066 pMonCtx, hdd_monPostMsgCb)) {
8067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8068 FL("failed to post MON MODE REQ"));
8069 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308070 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308071 }
8072 waitRet = wait_for_completion_timeout(&cmpVar,
8073 MON_MODE_MSG_TIMEOUT);
8074 magic = 0;
8075 if (waitRet <= 0 ) {
8076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8077 FL("failed to wait on monitor mode completion %ld"),
8078 waitRet);
8079 }
8080 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308081 }
8082 break;
8083
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 default:
8085 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008086 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8087 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 }
8089 break;
8090 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308091 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 return 0;
8093}
8094
Girish Gowlifb9758e2014-11-19 15:19:17 +05308095static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8096 struct iw_request_info *info,
8097 union iwreq_data *wrqu, char *extra)
8098{
8099 int ret;
8100 union iwreq_data u_priv_wrqu;
8101 int apps_args[MAX_VAR_ARGS] = {0};
8102 int num_args;
8103
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308104 if (!capable(CAP_NET_ADMIN))
8105 {
8106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8107 FL("permission check failed"));
8108 return -EPERM;
8109 }
8110
Girish Gowlifb9758e2014-11-19 15:19:17 +05308111 /* helper function to get iwreq_data with compat handling. */
8112 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8113 {
8114 return -EINVAL;
8115 }
8116
8117 if (NULL == u_priv_wrqu.data.pointer)
8118 {
8119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8120 "%s: NULL data pointer", __func__);
8121 return -EINVAL;
8122 }
8123
8124 num_args = u_priv_wrqu.data.length;
8125 if (num_args > MAX_VAR_ARGS)
8126 {
8127 num_args = MAX_VAR_ARGS;
8128 }
8129
8130 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8131 (sizeof(int)) * num_args))
8132 {
8133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8134 "%s: failed to copy data from user buffer", __func__);
8135 return -EFAULT;
8136 }
8137
8138 vos_ssr_protect(__func__);
8139 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8140 (char *)&apps_args);
8141 vos_ssr_unprotect(__func__);
8142
8143 return ret;
8144}
8145
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308146int iw_set_var_ints_getnone(struct net_device *dev,
8147 struct iw_request_info *info,
8148 union iwreq_data *wrqu, char *extra)
8149{
8150 int ret;
8151 vos_ssr_protect(__func__);
8152 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8153 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008154
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308155 return ret;
8156}
8157
8158static int __iw_add_tspec(struct net_device *dev,
8159 struct iw_request_info *info,
8160 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008161{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308162 hdd_adapter_t *pAdapter;
8163 hdd_station_ctx_t *pHddStaCtx;
8164 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8166 int params[HDD_WLAN_WMM_PARAM_COUNT];
8167 sme_QosWmmTspecInfo tSpec;
8168 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308169 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308170 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008171
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308172 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308173 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8174 if (NULL == pAdapter)
8175 {
8176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8177 "%s: Adapter is NULL",__func__);
8178 return -EINVAL;
8179 }
8180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8181 ret = wlan_hdd_validate_context(pHddCtx);
8182 if (0 != ret)
8183 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308184 return ret;
8185 }
8186 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8187 if (NULL == pHddStaCtx)
8188 {
8189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8190 "%s: STA Context is NULL",__func__);
8191 return -EINVAL;
8192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 // make sure the application is sufficiently priviledged
8194 // note that the kernel will do this for "set" ioctls, but since
8195 // this ioctl wants to return status to user space it must be
8196 // defined as a "get" ioctl
8197 if (!capable(CAP_NET_ADMIN))
8198 {
8199 return -EPERM;
8200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 // we must be associated in order to add a tspec
8202 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8203 {
8204 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8205 return 0;
8206 }
8207
8208 // since we are defined to be a "get" ioctl, and since the number
8209 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308210 // will pass down in the iwreq_data, we must copy the "set" params.
8211 // We must handle the compat for iwreq_data in 32U/64K environment.
8212
8213 // helper fucntion to get iwreq_data with compat handling.
8214 if (hdd_priv_get_data(&s_priv_data, wrqu))
8215 {
8216 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8217 return 0;
8218 }
8219
8220 // make sure all params are correctly passed to function
8221 if ((NULL == s_priv_data.pointer) ||
8222 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8223 {
8224 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8225 return 0;
8226 }
8227
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308229 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 {
8231 // hmmm, can't get them
8232 return -EIO;
8233 }
8234
8235 // clear the tspec
8236 memset(&tSpec, 0, sizeof(tSpec));
8237
8238 // validate the handle
8239 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8240 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8241 {
8242 // that one is reserved
8243 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8244 return 0;
8245 }
8246
8247 // validate the TID
8248 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8249 {
8250 // out of range
8251 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8252 return 0;
8253 }
8254 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8255
8256 // validate the direction
8257 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8258 {
8259 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8260 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8261 break;
8262
8263 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8264 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8265 break;
8266
8267 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8268 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8269 break;
8270
8271 default:
8272 // unknown
8273 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8274 return 0;
8275 }
8276
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308277 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8278
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 // validate the user priority
8280 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8281 {
8282 // out of range
8283 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8284 return 0;
8285 }
8286 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308287 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8288 {
8289 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8290 return 0;
8291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008292
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8294 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8295 tSpec.ts_info.psb, tSpec.ts_info.up);
8296
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8298 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8299 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8300 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8301 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8302 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8303 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8304 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8305 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8306 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8307 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8308 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8309
8310 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8311
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308312 // Save the expected UAPSD settings by application, this will be needed
8313 // when re-negotiating UAPSD settings during BT Coex cases.
8314 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8315
Jeff Johnson295189b2012-06-20 16:38:30 -07008316 // validate the ts info ack policy
8317 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8318 {
8319 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8320 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8321 break;
8322
8323 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8324 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8325 break;
8326
8327 default:
8328 // unknown
8329 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8330 return 0;
8331 }
8332
8333 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308334
8335 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 return 0;
8337}
8338
8339
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308340static int iw_add_tspec(struct net_device *dev,
8341 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 union iwreq_data *wrqu, char *extra)
8343{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308344 int ret;
8345
8346 vos_ssr_protect(__func__);
8347 ret = __iw_add_tspec(dev, info, wrqu, extra);
8348 vos_ssr_unprotect(__func__);
8349
8350 return ret;
8351}
8352
8353static int __iw_del_tspec(struct net_device *dev,
8354 struct iw_request_info *info,
8355 union iwreq_data *wrqu, char *extra)
8356{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308357 hdd_adapter_t *pAdapter;
8358 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 int *params = (int *)extra;
8360 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8361 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308362 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008363
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308364 ENTER();
8365
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308366 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8367 if (NULL == pAdapter)
8368 {
8369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8370 "%s: Adapter is NULL",__func__);
8371 return -EINVAL;
8372 }
8373
8374 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8375 ret = wlan_hdd_validate_context(pHddCtx);
8376 if (0 != ret)
8377 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308378 return ret;
8379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 // make sure the application is sufficiently priviledged
8381 // note that the kernel will do this for "set" ioctls, but since
8382 // this ioctl wants to return status to user space it must be
8383 // defined as a "get" ioctl
8384 if (!capable(CAP_NET_ADMIN))
8385 {
8386 return -EPERM;
8387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 // although we are defined to be a "get" ioctl, the params we require
8389 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8390 // is no need to copy the params from user space
8391
8392 // validate the handle
8393 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8394 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8395 {
8396 // that one is reserved
8397 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8398 return 0;
8399 }
8400
8401 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308402
8403 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 return 0;
8405}
8406
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308407static int iw_del_tspec(struct net_device *dev,
8408 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 union iwreq_data *wrqu, char *extra)
8410{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308411 int ret;
8412
8413 vos_ssr_protect(__func__);
8414 ret = __iw_del_tspec(dev, info, wrqu, extra);
8415 vos_ssr_unprotect(__func__);
8416
8417 return ret;
8418}
8419
8420
8421static int __iw_get_tspec(struct net_device *dev,
8422 struct iw_request_info *info,
8423 union iwreq_data *wrqu, char *extra)
8424{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308425 hdd_adapter_t *pAdapter;
8426 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 int *params = (int *)extra;
8428 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8429 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308430 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008431
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308432 ENTER();
8433
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 // although we are defined to be a "get" ioctl, the params we require
8435 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8436 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308437 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8438 if (NULL == pAdapter)
8439 {
8440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8441 "%s: Adapter is NULL",__func__);
8442 return -EINVAL;
8443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008444
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308445 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8446 ret = wlan_hdd_validate_context(pHddCtx);
8447 if (0 != ret)
8448 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308449 return ret;
8450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 // validate the handle
8452 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8453 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8454 {
8455 // that one is reserved
8456 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8457 return 0;
8458 }
8459
8460 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 return 0;
8463}
8464
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308465static int iw_get_tspec(struct net_device *dev,
8466 struct iw_request_info *info,
8467 union iwreq_data *wrqu, char *extra)
8468{
8469 int ret;
8470
8471 vos_ssr_protect(__func__);
8472 ret = __iw_get_tspec(dev, info, wrqu, extra);
8473 vos_ssr_unprotect(__func__);
8474
8475 return ret;
8476}
8477
Jeff Johnson295189b2012-06-20 16:38:30 -07008478#ifdef WLAN_FEATURE_VOWIFI_11R
8479//
8480//
8481// Each time the supplicant has the auth_request or reassoc request
8482// IEs ready. This is pushed to the driver. The driver will inturn use
8483// it to send out the auth req and reassoc req for 11r FT Assoc.
8484//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308485static int __iw_set_fties(struct net_device *dev,
8486 struct iw_request_info *info,
8487 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008488{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308489 hdd_adapter_t *pAdapter;
8490 hdd_station_ctx_t *pHddStaCtx;
8491 hdd_context_t *pHddCtx;
8492 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 //v_CONTEXT_t pVosContext;
8494
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308495 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308496 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8497 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008498 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8500 "%s: Adapter is NULL",__func__);
8501 return -EINVAL;
8502 }
8503 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8504 ret = wlan_hdd_validate_context(pHddCtx);
8505 if (0 != ret)
8506 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308507 return ret;
8508 }
8509 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8510 if (NULL == pHddStaCtx)
8511 {
8512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8513 "%s: STA Context is NULL",__func__);
8514 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 if (!wrqu->data.length)
8517 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008518 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 return -EINVAL;
8520 }
8521 if (wrqu->data.pointer == NULL)
8522 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008523 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 return -EINVAL;
8525 }
8526
8527 // Added for debug on reception of Re-assoc Req.
8528 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8529 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008530 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008532 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 }
8534
8535#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008536 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008537#endif
8538
8539 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008540 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 wrqu->data.length);
8542
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308543 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 return 0;
8545}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308546
8547static int iw_set_fties(struct net_device *dev,
8548 struct iw_request_info *info,
8549 union iwreq_data *wrqu, char *extra)
8550{
8551 int ret;
8552
8553 vos_ssr_protect(__func__);
8554 ret = __iw_set_fties(dev, info, wrqu, extra);
8555 vos_ssr_unprotect(__func__);
8556
8557 return ret;
8558}
Jeff Johnson295189b2012-06-20 16:38:30 -07008559#endif
8560
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308561static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008562 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008564{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308565 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008566 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308567 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008568 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308569 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008570 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8571 int idx;
8572 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008573
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308574 ENTER();
8575
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308576 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8577 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008578 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8580 "%s: Adapter is NULL",__func__);
8581 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008582 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308583 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8584 ret_val = wlan_hdd_validate_context(pHddCtx);
8585 if (0 != ret_val)
8586 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308587 return ret_val;
8588 }
8589 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8590 if (NULL == hHal)
8591 {
8592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8593 "%s: Hal Context is NULL",__func__);
8594 return -EINVAL;
8595 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308596 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8597 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308598#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008599
Amar Singhalf3a6e762013-02-19 15:06:50 -08008600 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8601 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008602 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008603 hddLog(VOS_TRACE_LEVEL_ERROR,
8604 "%s: vos_mem_alloc failed", __func__);
8605 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008606 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008607
8608 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8609
8610 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8611 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8612
8613 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8614 mc_addr_list_ptr->ulMulticastAddrCnt);
8615
8616 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008617 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008618 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8619 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8620
8621 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8622 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008623 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008624
Amar Singhalf3a6e762013-02-19 15:06:50 -08008625 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8626 vos_mem_free(mc_addr_list_ptr);
8627 if (eHAL_STATUS_SUCCESS != ret_val)
8628 {
8629 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8630 __func__);
8631 return -EINVAL;
8632 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308633#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308634 }
8635 else
8636 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008637
Amar Singhalf3a6e762013-02-19 15:06:50 -08008638 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8639 "%s: Set MC BC Filter Config request: %d suspend %d",
8640 __func__, pRequest->mcastBcastFilterSetting,
8641 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308642 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308643 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308644 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008645
8646 if (pHddCtx->hdd_wlan_suspended)
8647 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008648 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8649 if (NULL == wlanRxpFilterParam)
8650 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308651 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008652 "%s: vos_mem_alloc failed", __func__);
8653 return -EINVAL;
8654 }
8655
Amar Singhalf3a6e762013-02-19 15:06:50 -08008656 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8657 pRequest->mcastBcastFilterSetting;
8658 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308659 /* Fwr expect offload needs to clear before set */
8660 hdd_conf_hostoffload(pAdapter, FALSE);
8661 spin_lock(&pHddCtx->filter_lock);
8662 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8663 spin_unlock(&pHddCtx->filter_lock);
8664 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8665 {
8666 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8667 pHddCtx->sus_res_mcastbcast_filter =
8668 pRequest->mcastBcastFilterSetting;
8669 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008670
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308671 hdd_conf_hostoffload(pAdapter, TRUE);
8672 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8673 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008674
8675 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8676 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308677 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008678 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8679 wlanRxpFilterParam->setMcstBcstFilter);
8680
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308681 if (eHAL_STATUS_SUCCESS !=
8682 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8683 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008684 {
8685 hddLog(VOS_TRACE_LEVEL_ERROR,
8686 "%s: Failure to execute set HW MC/BC Filter request",
8687 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008688 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008689 return -EINVAL;
8690 }
8691
mukul sharmae4abd892016-11-24 22:03:31 +05308692 /* mc add list cfg item configuration in fwr */
8693 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008694 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008696
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308697 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 return 0;
8699}
8700
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308701static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8702 struct iw_request_info *info,
8703 union iwreq_data *wrqu, char *extra)
8704{
8705 int ret;
8706
8707 vos_ssr_protect(__func__);
8708 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8709 vos_ssr_unprotect(__func__);
8710
8711 return ret;
8712}
8713
8714static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8715 struct iw_request_info *info,
8716 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008717{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308718 hdd_adapter_t *pAdapter;
8719 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308720 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308721 int ret = 0;
8722
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308723 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008724
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308725 if (!capable(CAP_NET_ADMIN))
8726 {
8727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8728 FL("permission check failed"));
8729 return -EPERM;
8730 }
8731
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308732 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8733 if (NULL == pAdapter)
8734 {
8735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8736 "%s: Adapter is NULL",__func__);
8737 return -EINVAL;
8738 }
8739
8740 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8741 ret = wlan_hdd_validate_context(pHddCtx);
8742 if (0 != ret)
8743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308744 return ret;
8745 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308746 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308747 //Reset the filter to INI value as we have to clear the dynamic filter
8748 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308749 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008750
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308751 //Configure FW with new setting
8752 if (pHddCtx->hdd_wlan_suspended)
8753 {
8754 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8755 if (NULL == wlanRxpFilterParam)
8756 {
8757 hddLog(VOS_TRACE_LEVEL_ERROR,
8758 "%s: vos_mem_alloc failed", __func__);
8759 return -EINVAL;
8760 }
8761
8762 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8763 pHddCtx->configuredMcastBcastFilter;
8764 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308765 /* Fwr expect offload needs to clear before set */
8766 hdd_conf_hostoffload(pAdapter, FALSE);
8767 spin_lock(&pHddCtx->filter_lock);
8768 pHddCtx->configuredMcastBcastFilter =
8769 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8770 spin_unlock(&pHddCtx->filter_lock);
8771
8772 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8773 {
8774 pHddCtx->sus_res_mcastbcast_filter =
8775 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8776 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308777
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308778 hdd_conf_hostoffload(pAdapter, TRUE);
8779 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8780 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308781 if (eHAL_STATUS_SUCCESS !=
8782 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8783 wlanRxpFilterParam))
8784 {
8785 hddLog(VOS_TRACE_LEVEL_ERROR,
8786 "%s: Failure to execute set HW MC/BC Filter request",
8787 __func__);
8788 vos_mem_free(wlanRxpFilterParam);
8789 return -EINVAL;
8790 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308791
mukul sharmae4abd892016-11-24 22:03:31 +05308792 /* mc add list cfg item configuration in fwr */
8793 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308794 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308795 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008796 return 0;
8797}
8798
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308799
8800static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8801 struct iw_request_info *info,
8802 union iwreq_data *wrqu, char *extra)
8803{
8804 int ret;
8805
8806 vos_ssr_protect(__func__);
8807 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8808 vos_ssr_unprotect(__func__);
8809
8810 return ret;
8811}
8812
8813static int __iw_set_host_offload(struct net_device *dev,
8814 struct iw_request_info *info,
8815 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008816{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308817 hdd_adapter_t *pAdapter;
8818 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008819 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308821 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008822
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308823 ENTER();
8824
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308825 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8826 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008827 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8829 "%s: Adapter is NULL",__func__);
8830 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008831 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8833 ret = wlan_hdd_validate_context(pHddCtx);
8834 if (0 != ret)
8835 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308836 return ret;
8837 }
8838
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 /* Debug display of request components. */
8840 switch (pRequest->offloadType)
8841 {
8842 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008843 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008844 switch (pRequest->enableOrDisable)
8845 {
8846 case WLAN_OFFLOAD_DISABLE:
8847 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8848 break;
8849 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8850 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8851 case WLAN_OFFLOAD_ENABLE:
8852 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8853 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8854 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8855 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8856 }
8857 break;
8858
8859 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008860 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008861 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 switch (pRequest->enableOrDisable)
8863 {
8864 case WLAN_OFFLOAD_DISABLE:
8865 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8866 break;
8867 case WLAN_OFFLOAD_ENABLE:
8868 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8869 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8870 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8871 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8872 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8873 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8874 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8875 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8876 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8877 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8878 }
8879 }
8880
8881 /* Execute offload request. The reason that we can copy the request information
8882 from the ioctl structure to the SME structure is that they are laid out
8883 exactly the same. Otherwise, each piece of information would have to be
8884 copied individually. */
8885 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008886 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8887 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008889 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 __func__);
8891 return -EINVAL;
8892 }
8893
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308894 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 return 0;
8896}
8897
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308898static int iw_set_host_offload(struct net_device *dev,
8899 struct iw_request_info *info,
8900 union iwreq_data *wrqu, char *extra)
8901{
8902 int ret;
8903
8904 vos_ssr_protect(__func__);
8905 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8906 vos_ssr_unprotect(__func__);
8907
8908 return ret;
8909}
8910
8911static int __iw_set_keepalive_params(struct net_device *dev,
8912 struct iw_request_info *info,
8913 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008914{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308915 hdd_adapter_t *pAdapter;
8916 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008917 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308919 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008920
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308921 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308922 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8923 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8926 "%s: Adapter is NULL",__func__);
8927 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308929 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8930 ret = wlan_hdd_validate_context(pHddCtx);
8931 if (0 != ret)
8932 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308933 return ret;
8934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008936 hddLog(VOS_TRACE_LEVEL_INFO,
8937 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8938 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008939
8940 switch (pRequest->packetType)
8941 {
8942 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008943 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 break;
8945
8946 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8947
Arif Hussain6d2a3322013-11-17 19:50:10 -08008948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008949 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008950
8951 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8952 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8953 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8954
8955 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8956 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8957 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8958
8959 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8960 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8961 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8962 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8963 break;
8964
8965 }
8966
8967 /* Execute keep alive request. The reason that we can copy the request information
8968 from the ioctl structure to the SME structure is that they are laid out
8969 exactly the same. Otherwise, each piece of information would have to be
8970 copied individually. */
8971 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8972
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308973 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8974 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008975
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008976 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008977 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008979 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 __func__);
8981 return -EINVAL;
8982 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308983 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 return 0;
8985}
8986
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308987static int iw_set_keepalive_params(struct net_device *dev,
8988 struct iw_request_info *info,
8989 union iwreq_data *wrqu, char *extra)
8990{
8991 int ret;
8992 vos_ssr_protect(__func__);
8993 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8994 vos_ssr_unprotect(__func__);
8995
8996 return ret;
8997}
8998
Jeff Johnson295189b2012-06-20 16:38:30 -07008999#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309000/**-----------------------------------------------------------------
9001
9002 \brief hdd_pkt_filter_done - callback to be executed on completion
9003 successful/failure) for clear filter request.
9004
9005 \return - None
9006
9007 --------------------------------------------------------------------------*/
9008static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009009{
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309010 struct statsContext *cbCtx = (struct statsContext *)data;
9011
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309012 hddLog(VOS_TRACE_LEVEL_INFO,
9013 FL("Pkt Filter Clear Status : %d"), status);
9014
9015 if (data == NULL)
9016 {
9017 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context"));
9018 return;
9019 }
9020
9021 spin_lock(&hdd_context_lock);
9022 if (cbCtx->magic != CLEAR_FILTER_MAGIC)
9023 {
9024 spin_unlock(&hdd_context_lock);
9025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context, magic %x"), cbCtx->magic);
9026 if (ioctl_debug)
9027 {
9028 pr_info("%s: Invalid context, magic [%08x]\n",
9029 __func__, cbCtx->magic);
9030 }
9031 return;
9032 }
9033
9034 complete(&cbCtx->completion);
9035 spin_unlock(&hdd_context_lock);
9036}
9037
9038int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9039{
9040 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309041 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009042 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9043 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309044 struct statsContext cbCtx;
9045 int i=0, status;
9046
9047 status = wlan_hdd_validate_context(pHddCtx);
9048 if (0 != status)
9049 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009050
9051 if (pHddCtx->cfg_ini->disablePacketFilter)
9052 {
9053 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009054 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 return 0;
9056 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309057 if (pHddCtx->isLogpInProgress)
9058 {
9059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9060 "%s:LOGP in Progress. Ignore!!!", __func__);
9061 return -EBUSY;
9062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 /* Debug display of request components. */
9064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009065 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009066
9067 switch (pRequest->filterAction)
9068 {
9069 case HDD_RCV_FILTER_SET:
9070 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009071 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009072
9073 packetFilterSetReq.filterId = pRequest->filterId;
9074 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9075 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 __func__, pRequest->numParams);
9078 return -EINVAL;
9079 }
9080 packetFilterSetReq.numFieldParams = pRequest->numParams;
9081 packetFilterSetReq.coalesceTime = 0;
9082 packetFilterSetReq.filterType = 1;
9083 for (i=0; i < pRequest->numParams; i++)
9084 {
9085 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9086 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9087 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9088 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9089 packetFilterSetReq.paramsData[i].reserved = 0;
9090
Arif Hussain6d2a3322013-11-17 19:50:10 -08009091 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9093 packetFilterSetReq.filterType);
9094
Arif Hussain6d2a3322013-11-17 19:50:10 -08009095 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309097 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9098 (pRequest->paramsData[i].dataLength))
9099 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009100
9101 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9102 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9103 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9104 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9105
Arif Hussain6d2a3322013-11-17 19:50:10 -08009106 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9108 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9109 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9110
Arif Hussain6d2a3322013-11-17 19:50:10 -08009111 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9113 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9114 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9115 }
9116
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309117 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009119 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 __func__);
9121 return -EINVAL;
9122 }
9123
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309124 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9125 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009126 break;
9127
9128 case HDD_RCV_FILTER_CLEAR:
9129
Arif Hussain6d2a3322013-11-17 19:50:10 -08009130 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009131 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309132
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309133 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9134 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9135 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9136 pHddStaCtx->conn_info.staId[0]);
9137 }
9138
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309139 init_completion(&cbCtx.completion);
9140 cbCtx.magic = CLEAR_FILTER_MAGIC;
9141 cbCtx.pAdapter = pAdapter;
9142 packetFilterClrReq.cbCtx = &cbCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309144 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
9145 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009147 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 __func__);
9149 return -EINVAL;
9150 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309151
9152 status = wait_for_completion_interruptible_timeout(&cbCtx.completion,
9153 msecs_to_jiffies(PKT_FILTER_TIMEOUT));
9154 spin_lock(&hdd_context_lock);
9155 cbCtx.magic = 0;
9156 spin_unlock(&hdd_context_lock);
9157 if (0 >= status)
9158 {
9159 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9160 status);
9161 return -EINVAL;
9162 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309163
9164 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9165 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 break;
9167
9168 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009169 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009170 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 return -EINVAL;
9172 }
9173 return 0;
9174}
9175
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309176int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9177 tANI_U8 sessionId)
9178{
9179 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9180 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9181
9182 if (NULL == pHddCtx)
9183 {
9184 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9185 return -EINVAL;
9186 }
9187
9188 if (pHddCtx->isLogpInProgress)
9189 {
9190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9191 "%s:LOGP in Progress. Ignore!!!", __func__);
9192 return -EBUSY;
9193 }
9194
9195 if (pHddCtx->cfg_ini->disablePacketFilter)
9196 {
9197 hddLog(VOS_TRACE_LEVEL_ERROR,
9198 "%s: Packet Filtering Disabled. Returning ",
9199 __func__ );
9200 return -EINVAL;
9201 }
9202
9203 switch (filterType)
9204 {
9205 /* For setting IPV6 MC and UC Filter we need to configure
9206 * 2 filters, one for MC and one for UC.
9207 * The Filter ID shouldn't be swapped, which results in making
9208 * UC Filter ineffective.
9209 * We have Hardcode all the values
9210 *
9211 * Reason for a seperate UC filter is because, driver need to
9212 * specify the FW that the specific filter is for unicast
9213 * otherwise FW will not pass the unicast frames by default
9214 * through the filter. This is required to avoid any performance
9215 * hits when no unicast filter is set and only MC/BC are set.
9216 * The way driver informs host is by using the MAC protocol
9217 * layer, CMP flag set to MAX, CMP Data set to 1.
9218 */
9219
9220 case HDD_FILTER_IPV6_MC_UC:
9221 /* Setting IPV6 MC Filter below
9222 */
9223 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9224 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9225 packetFilterSetReq.numFieldParams = 2;
9226 packetFilterSetReq.paramsData[0].protocolLayer =
9227 HDD_FILTER_PROTO_TYPE_MAC;
9228 packetFilterSetReq.paramsData[0].cmpFlag =
9229 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9230 packetFilterSetReq.paramsData[0].dataOffset =
9231 WLAN_HDD_80211_FRM_DA_OFFSET;
9232 packetFilterSetReq.paramsData[0].dataLength = 1;
9233 packetFilterSetReq.paramsData[0].compareData[0] =
9234 HDD_IPV6_MC_CMP_DATA;
9235
9236 packetFilterSetReq.paramsData[1].protocolLayer =
9237 HDD_FILTER_PROTO_TYPE_ARP;
9238 packetFilterSetReq.paramsData[1].cmpFlag =
9239 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9240 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9241 packetFilterSetReq.paramsData[1].dataLength = 2;
9242 packetFilterSetReq.paramsData[1].compareData[0] =
9243 HDD_IPV6_CMP_DATA_0;
9244 packetFilterSetReq.paramsData[1].compareData[1] =
9245 HDD_IPV6_CMP_DATA_1;
9246
9247
9248 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9249 &packetFilterSetReq, sessionId))
9250 {
9251 hddLog(VOS_TRACE_LEVEL_ERROR,
9252 "%s: Failure to execute Set IPv6 Mulicast Filter",
9253 __func__);
9254 return -EINVAL;
9255 }
9256
9257 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9258
9259 /*
9260 * Setting IPV6 UC Filter below
9261 */
9262 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9263 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9264 packetFilterSetReq.numFieldParams = 2;
9265 packetFilterSetReq.paramsData[0].protocolLayer =
9266 HDD_FILTER_PROTO_TYPE_MAC;
9267 packetFilterSetReq.paramsData[0].cmpFlag =
9268 HDD_FILTER_CMP_TYPE_MAX;
9269 packetFilterSetReq.paramsData[0].dataOffset = 0;
9270 packetFilterSetReq.paramsData[0].dataLength = 1;
9271 packetFilterSetReq.paramsData[0].compareData[0] =
9272 HDD_IPV6_UC_CMP_DATA;
9273
9274 packetFilterSetReq.paramsData[1].protocolLayer =
9275 HDD_FILTER_PROTO_TYPE_ARP;
9276 packetFilterSetReq.paramsData[1].cmpFlag =
9277 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9278 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9279 packetFilterSetReq.paramsData[1].dataLength = 2;
9280 packetFilterSetReq.paramsData[1].compareData[0] =
9281 HDD_IPV6_CMP_DATA_0;
9282 packetFilterSetReq.paramsData[1].compareData[1] =
9283 HDD_IPV6_CMP_DATA_1;
9284
9285 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9286 &packetFilterSetReq, sessionId))
9287 {
9288 hddLog(VOS_TRACE_LEVEL_ERROR,
9289 "%s: Failure to execute Set IPv6 Unicast Filter",
9290 __func__);
9291 return -EINVAL;
9292 }
9293
9294 break;
9295
9296 case HDD_FILTER_IPV6_MC:
9297 /*
9298 * IPV6 UC Filter might be already set,
9299 * clear the UC Filter. As the Filter
9300 * IDs are static, we can directly clear it.
9301 */
9302 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9303 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9304 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9305 &packetFilterClrReq, sessionId))
9306 {
9307 hddLog(VOS_TRACE_LEVEL_ERROR,
9308 "%s: Failure to execute Clear IPv6 Unicast Filter",
9309 __func__);
9310 return -EINVAL;
9311 }
9312
9313 /*
9314 * Setting IPV6 MC Filter below
9315 */
9316 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9317 packetFilterSetReq.numFieldParams = 2;
9318 packetFilterSetReq.paramsData[0].protocolLayer =
9319 HDD_FILTER_PROTO_TYPE_MAC;
9320 packetFilterSetReq.paramsData[0].cmpFlag =
9321 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9322 packetFilterSetReq.paramsData[0].dataOffset =
9323 WLAN_HDD_80211_FRM_DA_OFFSET;
9324 packetFilterSetReq.paramsData[0].dataLength = 1;
9325 packetFilterSetReq.paramsData[0].compareData[0] =
9326 HDD_IPV6_MC_CMP_DATA;
9327
9328 packetFilterSetReq.paramsData[1].protocolLayer =
9329 HDD_FILTER_PROTO_TYPE_ARP;
9330 packetFilterSetReq.paramsData[1].cmpFlag =
9331 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9332 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9333 packetFilterSetReq.paramsData[1].dataLength = 2;
9334 packetFilterSetReq.paramsData[1].compareData[0] =
9335 HDD_IPV6_CMP_DATA_0;
9336 packetFilterSetReq.paramsData[1].compareData[1] =
9337 HDD_IPV6_CMP_DATA_1;
9338
9339
9340 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9341 &packetFilterSetReq, sessionId))
9342 {
9343 hddLog(VOS_TRACE_LEVEL_ERROR,
9344 "%s: Failure to execute Set IPv6 Multicast Filter",
9345 __func__);
9346 return -EINVAL;
9347 }
9348 break;
9349
9350 default :
9351 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9352 "%s: Packet Filter Request: Invalid",
9353 __func__);
9354 return -EINVAL;
9355 }
9356 return 0;
9357}
9358
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309359void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009360{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309361 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309362 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009363 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309364 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009365
Yue Ma3ede6052013-08-29 00:33:26 -07009366 if (NULL == pHddCtx)
9367 {
9368 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9369 return;
9370 }
9371
9372 hHal = pHddCtx->hHal;
9373
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309374 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9377 return;
9378 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309379
9380 /* Check if INI is enabled or not, other wise just return
9381 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309382 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309383 {
9384 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9385 if (NULL == pMulticastAddrs)
9386 {
9387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9388 return;
9389 }
9390
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 if (set)
9392 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309393 /* Following pre-conditions should be satisfied before wei
9394 * configure the MC address list.
9395 */
9396 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9397 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9398 && pAdapter->mc_addr_list.mc_cnt
9399 && (eConnectionState_Associated ==
9400 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9401 {
9402 pMulticastAddrs->ulMulticastAddrCnt =
9403 pAdapter->mc_addr_list.mc_cnt;
9404 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9405 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009406 memcpy(pMulticastAddrs->multicastAddr[i],
9407 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309408 sizeof(pAdapter->mc_addr_list.addr[i]));
9409 hddLog(VOS_TRACE_LEVEL_INFO,
9410 "%s: %s multicast filter: addr ="
9411 MAC_ADDRESS_STR,
9412 __func__, set ? "setting" : "clearing",
9413 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9414 }
9415 /* Set multicast filter */
9416 sme_8023MulticastList(hHal, pAdapter->sessionId,
9417 pMulticastAddrs);
9418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009419 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309420 else
9421 {
9422 /* Need to clear only if it was previously configured
9423 */
9424 if (pAdapter->mc_addr_list.isFilterApplied)
9425 {
9426 pMulticastAddrs->ulMulticastAddrCnt = 0;
9427 sme_8023MulticastList(hHal, pAdapter->sessionId,
9428 pMulticastAddrs);
9429 }
9430
9431 }
9432 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009433 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309435 else
9436 {
9437 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309438 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309439 }
9440 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009441}
9442
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309443static int __iw_set_packet_filter_params(struct net_device *dev,
9444 struct iw_request_info *info,
9445 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309446{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309447 hdd_adapter_t *pAdapter;
9448 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009449 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309450 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309451 struct iw_point s_priv_data;
9452
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309453 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309454
9455 if (!capable(CAP_NET_ADMIN))
9456 {
9457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9458 FL("permission check failed"));
9459 return -EPERM;
9460 }
9461
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309462 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9463 if (NULL == pAdapter)
9464 {
9465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9466 "%s: Adapter is NULL",__func__);
9467 return -EINVAL;
9468 }
9469 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9470 ret = wlan_hdd_validate_context(pHddCtx);
9471 if (0 != ret)
9472 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309473 return ret;
9474 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309475 if (hdd_priv_get_data(&s_priv_data, wrqu))
9476 {
9477 return -EINVAL;
9478 }
9479
9480 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9481 {
9482 return -EINVAL;
9483 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009484
Arif Hussain0273cba2014-01-07 20:58:29 -08009485 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309486 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9487 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009488 if (NULL == pRequest)
9489 {
9490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9491 "mem_alloc_copy_from_user_helper fail");
9492 return -ENOMEM;
9493 }
9494
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309495 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009496 kfree(pRequest);
9497
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309498 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009499 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009500}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309501
9502static int iw_set_packet_filter_params(struct net_device *dev,
9503 struct iw_request_info *info,
9504 union iwreq_data *wrqu, char *extra)
9505{
9506 int ret;
9507
9508 vos_ssr_protect(__func__);
9509 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9510 vos_ssr_unprotect(__func__);
9511
9512 return ret;
9513}
Jeff Johnson295189b2012-06-20 16:38:30 -07009514#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309515static int __iw_get_statistics(struct net_device *dev,
9516 struct iw_request_info *info,
9517 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009518{
9519
9520 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9521 eHalStatus status = eHAL_STATUS_SUCCESS;
9522 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309523 hdd_adapter_t *pAdapter;
9524 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309526 int tlen = 0, ret = 0;
9527 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309529 tCsrGlobalClassAStatsInfo *aStats;
9530 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009531
9532 ENTER();
9533
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309534 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9535 if (NULL == pAdapter)
9536 {
9537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9538 "%s: Adapter is NULL",__func__);
9539 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309541 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9542 ret = wlan_hdd_validate_context(pHddCtx);
9543 if (0 != ret)
9544 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309545 return ret;
9546 }
9547 pStats = &(pAdapter->hdd_stats.summary_stat);
9548 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9549 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9551
9552 wrqu->txpower.value = 0;
9553 }
9554 else {
9555 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9556 SME_SUMMARY_STATS |
9557 SME_GLOBAL_CLASSA_STATS |
9558 SME_GLOBAL_CLASSB_STATS |
9559 SME_GLOBAL_CLASSC_STATS |
9560 SME_GLOBAL_CLASSD_STATS |
9561 SME_PER_STA_STATS,
9562 hdd_StatisticsCB, 0, FALSE,
9563 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9564
9565 if (eHAL_STATUS_SUCCESS != status)
9566 {
9567 hddLog(VOS_TRACE_LEVEL_ERROR,
9568 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009569 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 return -EINVAL;
9571 }
9572
9573 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309574 if (NULL == pWextState)
9575 {
9576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9577 "%s: pWextState is NULL",__func__);
9578 return -EINVAL;
9579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009580
9581 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9582 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9583 {
9584 hddLog(VOS_TRACE_LEVEL_ERROR,
9585 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009586 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 /*Remove the SME statistics list by passing NULL in callback argument*/
9588 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9589 SME_SUMMARY_STATS |
9590 SME_GLOBAL_CLASSA_STATS |
9591 SME_GLOBAL_CLASSB_STATS |
9592 SME_GLOBAL_CLASSC_STATS |
9593 SME_GLOBAL_CLASSD_STATS |
9594 SME_PER_STA_STATS,
9595 NULL, 0, FALSE,
9596 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9597
9598 return -EINVAL;
9599 }
9600 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9601 (tANI_U8) sizeof (pStats->retry_cnt),
9602 (char*) &(pStats->retry_cnt[0]),
9603 tlen);
9604
9605 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9606 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9607 (char*) &(pStats->multiple_retry_cnt[0]),
9608 tlen);
9609
9610 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9611 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9612 (char*) &(pStats->tx_frm_cnt[0]),
9613 tlen);
9614
9615 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9616 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9617 (char*) &(pStats->rx_frm_cnt),
9618 tlen);
9619
9620 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9621 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9622 (char*) &(pStats->frm_dup_cnt),
9623 tlen);
9624
9625 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9626 (tANI_U8) sizeof (pStats->fail_cnt),
9627 (char*) &(pStats->fail_cnt[0]),
9628 tlen);
9629
9630 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9631 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9632 (char*) &(pStats->rts_fail_cnt),
9633 tlen);
9634
9635 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9636 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9637 (char*) &(pStats->ack_fail_cnt),
9638 tlen);
9639
9640 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9641 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9642 (char*) &(pStats->rts_succ_cnt),
9643 tlen);
9644
9645 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9646 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9647 (char*) &(pStats->rx_discard_cnt),
9648 tlen);
9649
9650 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9651 (tANI_U8) sizeof (pStats->rx_error_cnt),
9652 (char*) &(pStats->rx_error_cnt),
9653 tlen);
9654
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009655 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009656 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009657 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 tlen);
9659
9660 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9661 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9662 (char*) &(dStats->rx_byte_cnt),
9663 tlen);
9664
9665 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9666 (tANI_U8) sizeof (dStats->rx_rate),
9667 (char*) &(dStats->rx_rate),
9668 tlen);
9669
9670 /* Transmit rate, in units of 500 kbit/sec */
9671 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9672 (tANI_U8) sizeof (aStats->tx_rate),
9673 (char*) &(aStats->tx_rate),
9674 tlen);
9675
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009676 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9677 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9678 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009679 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009680 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9681 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9682 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009683 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009684 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9685 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9686 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009687 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009688 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9689 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9690 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009691 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009692 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9693 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9694 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009695 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009696 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9697 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9698 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009699 tlen);
9700
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 wrqu->data.length = tlen;
9702
9703 }
9704
9705 EXIT();
9706
9707 return 0;
9708}
9709
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309710static int iw_get_statistics(struct net_device *dev,
9711 struct iw_request_info *info,
9712 union iwreq_data *wrqu, char *extra)
9713{
9714 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009715
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309716 vos_ssr_protect(__func__);
9717 ret = __iw_get_statistics(dev, info, wrqu, extra);
9718 vos_ssr_unprotect(__func__);
9719
9720 return ret;
9721}
Jeff Johnson295189b2012-06-20 16:38:30 -07009722#ifdef FEATURE_WLAN_SCAN_PNO
9723
9724/*Max Len for PNO notification*/
9725#define MAX_PNO_NOTIFY_LEN 100
9726void found_pref_network_cb (void *callbackContext,
9727 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9728{
9729 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9730 union iwreq_data wrqu;
9731 char buf[MAX_PNO_NOTIFY_LEN+1];
9732
9733 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9734 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9735
9736 // create the event
9737 memset(&wrqu, 0, sizeof(wrqu));
9738 memset(buf, 0, sizeof(buf));
9739
9740 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9741 pPrefNetworkFoundInd->ssId.ssId,
9742 (unsigned int)pPrefNetworkFoundInd->rssi);
9743
9744 wrqu.data.pointer = buf;
9745 wrqu.data.length = strlen(buf);
9746
9747 // send the event
9748
9749 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9750
9751}
9752
9753
9754/*string based input*/
9755VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9756 union iwreq_data *wrqu, char *extra, int nOffset)
9757{
9758 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309759 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009760 /* pnoRequest is a large struct, so we make it static to avoid stack
9761 overflow. This API is only invoked via ioctl, so it is
9762 serialized by the kernel rtnl_lock and hence does not need to be
9763 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309764 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 char *ptr;
9766 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309767 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9769
9770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9771 "PNO data len %d data %s",
9772 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009773 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009774
9775 if (wrqu->data.length <= nOffset )
9776 {
9777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9778 return VOS_STATUS_E_FAILURE;
9779 }
9780
9781 pnoRequest.enable = 0;
9782 pnoRequest.ucNetworksCount = 0;
9783 /*-----------------------------------------------------------------------
9784 Input is string based and expected to be like this:
9785
9786 <enabled> <netw_count>
9787 for each network:
9788 <ssid_len> <ssid> <authentication> <encryption>
9789 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9790 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9791
9792 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009793 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 -07009794
9795 this translates into:
9796 -----------------------------
9797 enable PNO
9798 look for 2 networks:
9799 test - with authentication type 0 and encryption type 0,
9800 that can be found on 3 channels: 1 6 and 11 ,
9801 SSID bcast type is unknown (directed probe will be sent if AP not found)
9802 and must meet -40dBm RSSI
9803
9804 test2 - with auth and enrytption type 4/4
9805 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9806 bcast type is non-bcast (directed probe will be sent)
9807 and must not meet any RSSI threshold
9808
Jeff Johnson8301aa12013-03-28 14:27:29 -07009809 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009811 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009812
Wilson Yang623f6592013-10-08 16:33:37 -07009813 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9814 {
9815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9816 "PNO enable input is not valid %s",ptr);
9817 return VOS_STATUS_E_FAILURE;
9818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009819
9820 if ( 0 == pnoRequest.enable )
9821 {
9822 /*Disable PNO*/
9823 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309824 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9825 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 pAdapter->sessionId,
9827 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309828 if (eHAL_STATUS_SUCCESS != status)
9829 {
9830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9831 "%s: failed to disable PNO", __func__);
9832 return VOS_STATUS_E_FAILURE;
9833 }
9834 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 return VOS_STATUS_SUCCESS;
9836 }
9837
c_hpothu37f21312014-04-09 21:49:54 +05309838 if (TRUE == pHddCtx->isPnoEnable)
9839 {
9840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9841 FL("already PNO is enabled"));
9842 return -EBUSY;
9843 }
9844 pHddCtx->isPnoEnable = TRUE;
9845
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009847
9848 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9849 {
9850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9851 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309852 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009854
9855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9856 "PNO enable %d networks count %d offset %d",
9857 pnoRequest.enable,
9858 pnoRequest.ucNetworksCount,
9859 nOffset);
9860
9861 /* Parameters checking:
9862 ucNetworksCount has to be larger than 0*/
9863 if (( 0 == pnoRequest.ucNetworksCount ) ||
9864 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9865 {
9866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309867 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 }
9869
9870 ptr += nOffset;
9871
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309872 pnoRequest.aNetworks =
9873 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9874 if (pnoRequest.aNetworks == NULL)
9875 {
9876 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9877 FL("failed to allocate memory aNetworks %u"),
9878 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9879 goto error;
9880 }
9881 vos_mem_zero(pnoRequest.aNetworks,
9882 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9883
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9885 {
9886
9887 pnoRequest.aNetworks[i].ssId.length = 0;
9888
Wilson Yang623f6592013-10-08 16:33:37 -07009889 ucParams = sscanf(ptr,"%hhu %n",
9890 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9891
9892 if (1 != ucParams)
9893 {
9894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9895 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309896 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009898
9899 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9900 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9901 {
9902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9903 "SSID Len %d is not correct for network %d",
9904 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309905 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 }
9907
9908 /*Advance to SSID*/
9909 ptr += nOffset;
9910
Jeff Johnson8301aa12013-03-28 14:27:29 -07009911 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009912 pnoRequest.aNetworks[i].ssId.length);
9913 ptr += pnoRequest.aNetworks[i].ssId.length;
9914
Jeff Johnson02797792013-10-26 19:17:13 -07009915 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009916 &(pnoRequest.aNetworks[i].authentication),
9917 &(pnoRequest.aNetworks[i].encryption),
9918 &(pnoRequest.aNetworks[i].ucChannelCount),
9919 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009920
Wilson Yang623f6592013-10-08 16:33:37 -07009921 if ( 3 != ucParams )
9922 {
9923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9924 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309925 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009926 }
9927
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009929 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009930 "auth %d encry %d channel count %d offset %d",
9931 pnoRequest.aNetworks[i].ssId.length,
9932 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9933 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9934 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9935 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9936 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9937 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9938 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9939 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9940 pnoRequest.aNetworks[i].authentication,
9941 pnoRequest.aNetworks[i].encryption,
9942 pnoRequest.aNetworks[i].ucChannelCount,
9943 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009944
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 /*Advance to channel list*/
9946 ptr += nOffset;
9947
Wilson Yang623f6592013-10-08 16:33:37 -07009948 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 {
9950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9951 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309952 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 }
9954
9955 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9956 {
9957 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9958 {
Wilson Yang623f6592013-10-08 16:33:37 -07009959 if (1 != sscanf(ptr,"%hhu %n",
9960 &(pnoRequest.aNetworks[i].aChannels[j]),
9961 &nOffset))
9962 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9963 "PNO network channel input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309964 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009965 }
9966 /*Advance to next channel number*/
9967 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 }
9969 }
9970
Jeff Johnson02797792013-10-26 19:17:13 -07009971 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009972 &(pnoRequest.aNetworks[i].bcastNetwType),
9973 &nOffset))
9974 {
9975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9976 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309977 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009979
9980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9981 "PNO bcastNetwType %d offset %d",
9982 pnoRequest.aNetworks[i].bcastNetwType,
9983 nOffset );
9984
9985 /*Advance to rssi Threshold*/
9986 ptr += nOffset;
9987
Wilson Yang623f6592013-10-08 16:33:37 -07009988 if (1 != sscanf(ptr,"%hhu %n",
9989 &(pnoRequest.aNetworks[i].rssiThreshold),
9990 &nOffset))
9991 {
9992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9993 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309994 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009996
9997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9998 "PNO rssi %d offset %d",
9999 pnoRequest.aNetworks[i].rssiThreshold,
10000 nOffset );
10001 /*Advance to next network*/
10002 ptr += nOffset;
10003 }/*For ucNetworkCount*/
10004
10005 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010006 &(pnoRequest.scanTimers.ucScanTimersCount),
10007 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010008
10009 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010010 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 {
10012 ptr += nOffset;
10013
Jeff Johnson8301aa12013-03-28 14:27:29 -070010014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10015 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010016 pnoRequest.scanTimers.ucScanTimersCount,
10017 nOffset );
10018
10019 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10020 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010023 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 }
10025
10026 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10027 {
Jeff Johnson02797792013-10-26 19:17:13 -070010028 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10030 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10031 &nOffset);
10032
Wilson Yang623f6592013-10-08 16:33:37 -070010033 if (2 != ucParams)
10034 {
10035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10036 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010037 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010038 }
10039
Jeff Johnson8301aa12013-03-28 14:27:29 -070010040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10041 "PNO Timer value %d Timer repeat %d offset %d",
10042 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10044 nOffset );
10045
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 ptr += nOffset;
10047 }
10048
10049 }
10050 else
10051 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10053 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10055
10056 /*Scan timers defaults to 5 minutes*/
10057 pnoRequest.scanTimers.ucScanTimersCount = 1;
10058 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10059 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10060 }
10061
Wilson Yang623f6592013-10-08 16:33:37 -070010062 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010063
10064 pnoRequest.modePNO = ucMode;
10065 /*for LA we just expose suspend option*/
10066 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10067 {
10068 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10069 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010070 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10071 if (pnoRequest.p24GProbeTemplate == NULL){
10072 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10073 FL("failed to allocate memory p24GProbeTemplate %u"),
10074 SIR_PNO_MAX_PB_REQ_SIZE);
10075 goto error;
10076 }
10077
10078 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10079 if (pnoRequest.p5GProbeTemplate == NULL){
10080 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10081 FL("failed to allocate memory p5GProbeTemplate %u"),
10082 SIR_PNO_MAX_PB_REQ_SIZE);
10083 goto error;
10084 }
10085
10086 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10087 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010088
c_hpothu37f21312014-04-09 21:49:54 +053010089 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 pAdapter->sessionId,
10091 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010092 if (eHAL_STATUS_SUCCESS == status)
10093 {
10094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10095 "%s: PNO enabled", __func__);
10096 return VOS_STATUS_SUCCESS;
10097 }
10098error:
10099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10100 "%s: Failed to enable PNO", __func__);
10101 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010102 if (pnoRequest.aNetworks)
10103 vos_mem_free(pnoRequest.aNetworks);
10104 if (pnoRequest.p24GProbeTemplate)
10105 vos_mem_free(pnoRequest.p24GProbeTemplate);
10106 if (pnoRequest.p5GProbeTemplate)
10107 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +053010108 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010109}/*iw_set_pno*/
10110
10111VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10112 union iwreq_data *wrqu, char *extra, int nOffset)
10113{
10114 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10115 v_U8_t rssiThreshold = 0;
10116 v_U8_t nRead;
10117
Arif Hussain7adce1b2013-11-11 22:59:34 -080010118 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 &rssiThreshold);
10120
10121 if ( 1 != nRead )
10122 {
10123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10124 "Incorrect format");
10125 return VOS_STATUS_E_FAILURE;
10126 }
10127
10128 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10129 return VOS_STATUS_SUCCESS;
10130}
10131
10132
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010133static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 struct iw_request_info *info,
10135 union iwreq_data *wrqu, char *extra)
10136{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010137 hdd_adapter_t *pAdapter;
10138 hdd_context_t *pHddCtx;
10139 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010140 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010141
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010142 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010143 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10144 if (NULL == pAdapter)
10145 {
10146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10147 "%s: Adapter is NULL",__func__);
10148 return -EINVAL;
10149 }
10150
10151 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10152 ret = wlan_hdd_validate_context(pHddCtx);
10153 if (0 != ret)
10154 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010155 return ret;
10156 }
10157
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010158
10159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010161
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010162 status = iw_set_pno(dev,info,wrqu,extra,0);
10163
10164 EXIT();
10165 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010166}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010167
10168static int iw_set_pno_priv(struct net_device *dev,
10169 struct iw_request_info *info,
10170 union iwreq_data *wrqu, char *extra)
10171{
10172 int ret;
10173
10174 vos_ssr_protect(__func__);
10175 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10176 vos_ssr_unprotect(__func__);
10177
10178 return ret;
10179}
Jeff Johnson295189b2012-06-20 16:38:30 -070010180#endif /*FEATURE_WLAN_SCAN_PNO*/
10181
10182//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010183int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010184{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010185 hdd_adapter_t *pAdapter;
10186 tHalHandle hHal;
10187 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010188 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010189 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010190 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010192 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010193 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010194 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010195
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010196 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010197 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10198 if (NULL == pAdapter)
10199 {
10200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10201 "%s: Adapter is NULL",__func__);
10202 return -EINVAL;
10203 }
10204 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10205 retval = wlan_hdd_validate_context(pHddCtx);
10206 if (0 != retval)
10207 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010208 return retval;
10209 }
10210 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10211 if (NULL == hHal)
10212 {
10213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10214 "%s: Hal Context is NULL",__func__);
10215 return -EINVAL;
10216 }
10217 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010218
Atul Mittal54378cb2014-04-02 16:51:50 +053010219 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 {
10221 case WLAN_HDD_UI_BAND_AUTO:
10222 band = eCSR_BAND_ALL;
10223 break;
10224 case WLAN_HDD_UI_BAND_5_GHZ:
10225 band = eCSR_BAND_5G;
10226 break;
10227 case WLAN_HDD_UI_BAND_2_4_GHZ:
10228 band = eCSR_BAND_24;
10229 break;
10230 default:
10231 band = eCSR_BAND_MAX;
10232 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010233 connectedBand =
10234 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010235
Atul Mittal54378cb2014-04-02 16:51:50 +053010236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010237 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010238
10239 if (band == eCSR_BAND_MAX)
10240 {
10241 /* Received change band request with invalid band value */
10242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010243 "%s: Invalid band value %u", __func__, ui_band);
10244 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 }
10246
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010247 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010248 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010249 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010251 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010252 band, pHddCtx->cfg_ini->nBandCapability);
10253 return -EIO;
10254 }
10255
Sushant Kaushik1165f872015-03-30 20:25:27 +053010256 if (band == eCSR_BAND_ALL)
10257 {
10258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10259 "received. Setting band same as ini value %d"),
10260 pHddCtx->cfg_ini->nBandCapability);
10261 band = pHddCtx->cfg_ini->nBandCapability;
10262 }
10263
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10265 {
10266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10267 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010268 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 return -EIO;
10270 }
10271
10272 if (currBand != band)
10273 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010274 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010275 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010276 /* Return failure if current country code is world regulatory domain*/
10277 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10278 pMac->scan.countryCodeCurrent[1] == '0') )
10279 {
10280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10281 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010282 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010283 return -EAGAIN;
10284 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010285 }
10286
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 /* Change band request received.
10288 * Abort pending scan requests, flush the existing scan results,
10289 * and change the band capability
10290 */
10291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10292 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010293 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010294
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010295 /* We need to change the band and flush the scan results here itself
10296 * as we may get timeout for disconnection in which we will return
10297 * with out doing any of these
10298 */
10299 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10300 {
10301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10302 "%s: failed to set the band value to %u ",
10303 __func__, band);
10304 return -EINVAL;
10305 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010306 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10307 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010308 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010309 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10310 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010311 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010312 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10313 * information available in NV so to get the channel information from kernel
10314 * we need to send regulatory hint for the currunt country
10315 * And to set the same country again we need to set the dummy country
10316 * first and then the actual country.
10317 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010318#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10319 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10320#else
10321 regulatory_hint_user("00");
10322#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010323 wait_result = wait_for_completion_interruptible_timeout(
10324 &pHddCtx->linux_reg_req,
10325 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10326
10327 /* if the country information does not exist with the kernel,
10328 then the driver callback would not be called */
10329
10330 if (wait_result >= 0)
10331 {
10332 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10333 "runtime country code is found in kernel db");
10334 }
10335 else
10336 {
10337 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10338 "runtime country code is not found"
10339 " in kernel db");
10340 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010341
10342 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010343
10344 /*
10345 * Update 11dcountry and current country here as the hint
10346 * with 00 results in 11d and current country with 00
10347 */
10348 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10349 WNI_CFG_COUNTRY_CODE_LEN);
10350 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10351 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010352#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10353 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10354#else
10355 regulatory_hint_user(curr_country);
10356#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010357 wait_result = wait_for_completion_interruptible_timeout(
10358 &pHddCtx->linux_reg_req,
10359 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10360
10361 /* if the country information does not exist with the kernel,
10362 then the driver callback would not be called */
10363 if (wait_result >= 0)
10364 {
10365 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10366 "runtime country code is found in kernel db");
10367 }
10368 else
10369 {
10370 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10371 "runtime country code is not found"
10372 " in kernel db");
10373 }
10374
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010375 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010376 }
10377 else
10378 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010379#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010380 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10381 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010382#else
10383 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10384#endif
10385
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010386 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010387 pScanInfo = &pHddCtx->scan_info;
10388 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10389 {
10390 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10391 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10392 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010393 sme_FilterScanResults(hHal, pAdapter->sessionId);
10394
10395 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010396 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10397 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010399 eHalStatus status = eHAL_STATUS_SUCCESS;
10400 long lrc;
10401
10402 /* STA already connected on current band, So issue disconnect first,
10403 * then change the band*/
10404
10405 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010406 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010407 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010408
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10410
10411 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10412 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10413
Jeff Johnson43971f52012-07-17 12:26:56 -070010414 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 {
10416 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010417 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 __func__, (int)status );
10419 return -EINVAL;
10420 }
10421
10422 lrc = wait_for_completion_interruptible_timeout(
10423 &pAdapter->disconnect_comp_var,
10424 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10425
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010426 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010427
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010428 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010429 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010430
10431 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10432 }
10433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010435 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010436 if (TRUE == pHddCtx->isSetBandByNL)
10437 return 0;
10438 else
10439 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010440}
10441
Atul Mittal54378cb2014-04-02 16:51:50 +053010442int hdd_setBand_helper(struct net_device *dev, const char *command)
10443{
10444 u8 band;
10445
10446 /*convert the band value from ascii to integer*/
10447 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10448
10449 return hdd_setBand(dev, band);
10450
10451}
10452
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010453static int __iw_set_band_config(struct net_device *dev,
10454 struct iw_request_info *info,
10455 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010456{
Atul Mittal54378cb2014-04-02 16:51:50 +053010457 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010458
Arif Hussain0273cba2014-01-07 20:58:29 -080010459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010460
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010461 if (!capable(CAP_NET_ADMIN))
10462 {
10463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10464 FL("permission check failed"));
10465 return -EPERM;
10466 }
10467
Atul Mittal54378cb2014-04-02 16:51:50 +053010468 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010469}
10470
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010471static int iw_set_band_config(struct net_device *dev,
10472 struct iw_request_info *info,
10473 union iwreq_data *wrqu, char *extra)
10474{
10475 int ret;
10476
10477 vos_ssr_protect(__func__);
10478 ret = __iw_set_band_config(dev, info, wrqu, extra);
10479 vos_ssr_unprotect(__func__);
10480
10481 return ret;
10482}
10483
c_manjeecfd1efb2015-09-25 19:32:34 +053010484static int get_fwr_memdump(struct net_device *dev,
10485 struct iw_request_info *info,
10486 union iwreq_data *wrqu, char *extra)
10487{
10488 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10489 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10490 int ret;
10491 ENTER();
10492 // HddCtx sanity
10493 ret = wlan_hdd_validate_context(pHddCtx);
10494 if (0 != ret)
10495 {
10496 return ret;
10497 }
10498 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10499 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10500 {
10501 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10502 return -EINVAL;
10503 }
10504 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10505
10506 EXIT();
10507 return ret;
10508}
10509
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010510static int __iw_set_power_params_priv(struct net_device *dev,
10511 struct iw_request_info *info,
10512 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010513{
Arif Hussain0273cba2014-01-07 20:58:29 -080010514 int ret;
10515 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010516
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10518 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010519
10520 if (!capable(CAP_NET_ADMIN))
10521 {
10522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10523 FL("permission check failed"));
10524 return -EPERM;
10525 }
10526
Arif Hussain0273cba2014-01-07 20:58:29 -080010527 /* ODD number is used for set, copy data using copy_from_user */
10528 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10529 wrqu->data.length);
10530 if (NULL == ptr)
10531 {
10532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10533 "mem_alloc_copy_from_user_helper fail");
10534 return -ENOMEM;
10535 }
10536
10537 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10538 kfree(ptr);
10539 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540}
10541
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010542static int iw_set_power_params_priv(struct net_device *dev,
10543 struct iw_request_info *info,
10544 union iwreq_data *wrqu, char *extra)
10545{
10546 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010547
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010548 vos_ssr_protect(__func__);
10549 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10550 vos_ssr_unprotect(__func__);
10551
10552 return ret;
10553}
Jeff Johnson295189b2012-06-20 16:38:30 -070010554
10555/*string based input*/
10556VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10557 union iwreq_data *wrqu, char *extra, int nOffset)
10558{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010559 hdd_adapter_t *pAdapter;
10560 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 tSirSetPowerParamsReq powerRequest;
10562 char *ptr;
10563 v_U8_t ucType;
10564 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010565 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010566
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010567 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010568 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10569 if (NULL == pAdapter)
10570 {
10571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10572 "%s: Adapter is NULL",__func__);
10573 return -EINVAL;
10574 }
10575
10576 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10577 ret = wlan_hdd_validate_context(pHddCtx);
10578 if (0 != ret)
10579 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010580 return ret;
10581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10583 "Power Params data len %d data %s",
10584 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010585 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010586
10587 if (wrqu->data.length <= nOffset )
10588 {
10589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10590 return VOS_STATUS_E_FAILURE;
10591 }
10592
10593 uTotalSize = wrqu->data.length - nOffset;
10594
10595 /*-----------------------------------------------------------------------
10596 Input is string based and expected to be like this:
10597
10598 <param_type> <param_value> <param_type> <param_value> ...
10599
10600 e.g:
10601 1 2 2 3 3 0 4 1 5 1
10602
10603 e.g. setting just a few:
10604 1 2 4 1
10605
10606 parameter types:
10607 -----------------------------
10608 1 - Ignore DTIM
10609 2 - Listen Interval
10610 3 - Broadcast Multicas Filter
10611 4 - Beacon Early Termination
10612 5 - Beacon Early Termination Interval
10613 -----------------------------------------------------------------------*/
10614 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10615 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10616 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10617 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10618 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10619
Arif Hussain7adce1b2013-11-11 22:59:34 -080010620 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010621
10622 while ( uTotalSize )
10623 {
Wilson Yang6f971452013-10-08 15:00:00 -070010624 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10625 {
10626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10627 "Invalid input parameter type %s",ptr);
10628 return VOS_STATUS_E_FAILURE;
10629 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010630
10631 uTotalSize -= nOffset;
10632
10633 if (!uTotalSize)
10634 {
10635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010636 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 ucType, nOffset);
10638 return VOS_STATUS_E_FAILURE;
10639 }
10640
10641 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010642
Jeff Johnson02797792013-10-26 19:17:13 -070010643 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010644 {
10645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10646 "Invalid input parameter value %s",ptr);
10647 return VOS_STATUS_E_FAILURE;
10648 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010649
10650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10651 "Power request parameter %d value %d offset %d",
10652 ucType, uValue, nOffset);
10653
10654 switch (ucType)
10655 {
10656 case eSIR_IGNORE_DTIM:
10657 powerRequest.uIgnoreDTIM = uValue;
10658 break;
10659 case eSIR_LISTEN_INTERVAL:
10660 powerRequest.uListenInterval = uValue;
10661 break;
10662 case eSIR_MCAST_BCAST_FILTER:
10663 powerRequest.uBcastMcastFilter = uValue;
10664 break;
10665 case eSIR_ENABLE_BET:
10666 powerRequest.uEnableBET = uValue;
10667 break;
10668 case eSIR_BET_INTERVAL:
10669 powerRequest.uBETInterval = uValue;
10670 break;
10671 default:
10672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010673 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 ucType, uValue, nOffset);
10675 return VOS_STATUS_E_FAILURE;
10676 }
10677
10678 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10680 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010681 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010683 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010684 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010685 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10686 {
10687 uTotalSize = 0;
10688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010689
10690 }/*Go for as long as we have a valid string*/
10691
10692 /* put the device into full power*/
10693 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10694
10695 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010696 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010697
10698 /* put the device back to power save*/
10699 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10700
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010701 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010702 return VOS_STATUS_SUCCESS;
10703}/*iw_set_power_params*/
10704
Atul Mittalc0f739f2014-07-31 13:47:47 +053010705// tdlsoffchan
10706#ifdef FEATURE_WLAN_TDLS
10707
Atul Mittal87ec2422014-09-24 13:12:50 +053010708int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010709{
10710 if (offchannel < 0 || offchannel > 165)
10711 {
10712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10713 __func__, offchannel);
10714 return -1;
10715
10716 }
10717
10718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10719 __func__, tdlsOffCh, offchannel);
10720
10721 tdlsOffCh = offchannel;
10722 return 0;
10723}
10724
Atul Mittal87ec2422014-09-24 13:12:50 +053010725int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010726{
10727 if (offchanoffset == 0)
10728 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010729 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10731 __func__, tdlsOffChBwOffset);
10732
10733 return 0;
10734
10735 }
10736
10737 if ( offchanoffset == 40 )
10738 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010739 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10741 __func__, tdlsOffChBwOffset);
10742
10743 return 0;
10744
10745 }
10746 if (offchanoffset == -40)
10747 {
10748 tdlsOffChBwOffset = 3;
10749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10750 __func__, tdlsOffChBwOffset);
10751
10752 return 0;
10753
10754 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010755
10756 if ((offchanoffset == 80) &&
10757 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10758 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10759 {
10760 tdlsOffChBwOffset = 4;
10761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10762 "%s: change tdls secondary off channel offset to %u",
10763 __func__, tdlsOffChBwOffset);
10764
10765 return 0;
10766 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10768 __func__, offchanoffset);
10769 return -1;
10770}
10771
Atul Mittal87ec2422014-09-24 13:12:50 +053010772int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010773{
10774 hddTdlsPeer_t *connPeer = NULL;
10775 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10776 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010777 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010778 if (offchanmode < 0 || offchanmode > 4)
10779 {
10780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10781 "%s: Invalid tdls off channel mode %d",
10782 __func__, offchanmode);
10783 return -1;
10784 }
10785
10786 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10787 {
10788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10789 "%s: tdls off channel mode req in not associated state %d",
10790 __func__, offchanmode);
10791 return -1;
10792 }
10793
10794 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10795 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10796 {
10797 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010798 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010799 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010800 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010801 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10803 "%s: No TDLS Connected Peer", __func__);
10804 return -1;
10805 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010806 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010807 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010808 }
10809 else
10810 {
10811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10812 "%s: TDLS Connection not supported", __func__);
10813 return -1;
10814 }
10815
10816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10817 ("%s: TDLS Channel Switch in swmode=%d"),
10818 __func__, offchanmode);
10819
10820 switch (offchanmode)
10821 {
10822 case 1:/*Enable*/
10823 case 2:/*Disable*/
10824 {
10825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10826 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10827 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10828 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10829 {
10830
10831 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010832 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010833 tdlsOffCh, tdlsOffChBwOffset,
10834 offchanmode);
10835 }
10836 else
10837 {
10838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10839 "%s: TDLS Off Channel not supported", __func__);
10840 return -1;
10841 }
10842 break;
10843 }
10844 case 3:
10845 {
10846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10847 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10848 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10849
10850 break;
10851 }
10852 case 4:
10853 {
10854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10855 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10856 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10857 break;
10858 }
10859 default:
10860 {
10861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10862 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10863 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10864 break;
10865 }
10866
10867 }
10868
10869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10870 __func__, offchanmode);
10871 return 0;
10872}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010873#endif
10874
Jeff Johnson295189b2012-06-20 16:38:30 -070010875
10876// Define the Wireless Extensions to the Linux Network Device structure
10877// A number of these routines are NULL (meaning they are not implemented.)
10878
10879static const iw_handler we_handler[] =
10880{
10881 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10882 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10883 (iw_handler) NULL, /* SIOCSIWNWID */
10884 (iw_handler) NULL, /* SIOCGIWNWID */
10885 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10886 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10887 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10888 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10889 (iw_handler) NULL, /* SIOCSIWSENS */
10890 (iw_handler) NULL, /* SIOCGIWSENS */
10891 (iw_handler) NULL, /* SIOCSIWRANGE */
10892 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010893 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010894 (iw_handler) NULL, /* SIOCGIWPRIV */
10895 (iw_handler) NULL, /* SIOCSIWSTATS */
10896 (iw_handler) NULL, /* SIOCGIWSTATS */
10897 iw_handler_set_spy, /* SIOCSIWSPY */
10898 iw_handler_get_spy, /* SIOCGIWSPY */
10899 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10900 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10901 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10902 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10903 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10904 (iw_handler) NULL, /* SIOCGIWAPLIST */
10905 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10906 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10907 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10908 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10909 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10910 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10911 (iw_handler) NULL, /* -- hole -- */
10912 (iw_handler) NULL, /* -- hole -- */
10913 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10914 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10915 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10916 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10917 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10918 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10919 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10920 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10921 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10922 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10923 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10924 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10925 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10926 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10927 (iw_handler) NULL, /* -- hole -- */
10928 (iw_handler) NULL, /* -- hole -- */
10929 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10930 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10931 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10932 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10933 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10934 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10935 (iw_handler) NULL, /* SIOCSIWPMKSA */
10936};
10937
10938static const iw_handler we_private[] = {
10939
10940 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10941 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10942 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10943 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10944 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10945 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010946 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10948 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10949 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010950#ifdef FEATURE_OEM_DATA_SUPPORT
10951 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10952 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010954
Jeff Johnson295189b2012-06-20 16:38:30 -070010955#ifdef WLAN_FEATURE_VOWIFI_11R
10956 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10957#endif
10958 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10959 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10960 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10961#ifdef WLAN_FEATURE_PACKET_FILTERING
10962 ,
10963 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10964#endif
10965#ifdef FEATURE_WLAN_SCAN_PNO
10966 ,
10967 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10968#endif
10969 ,
10970 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10971 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10972 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10973 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010974 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010975};
10976
10977/*Maximum command length can be only 15 */
10978static const struct iw_priv_args we_private_args[] = {
10979
Katya Nigamf0511f62015-05-05 16:40:57 +053010980 { WE_SET_MONITOR_STATE,
10981 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10982 0, "monitor" },
10983
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 /* handlers for main ioctl */
10985 { WLAN_PRIV_SET_INT_GET_NONE,
10986 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10987 0,
10988 "" },
10989
10990 /* handlers for sub-ioctl */
10991 { WE_SET_11D_STATE,
10992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10993 0,
10994 "set11Dstate" },
10995
10996 { WE_WOWL,
10997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10998 0,
10999 "wowl" },
11000
11001 { WE_SET_POWER,
11002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11003 0,
11004 "setPower" },
11005
11006 { WE_SET_MAX_ASSOC,
11007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11008 0,
11009 "setMaxAssoc" },
11010
11011 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11013 0,
11014 "setAutoChannel" },
11015
11016 { WE_SET_DATA_INACTIVITY_TO,
11017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11018 0,
11019 "inactivityTO" },
11020
11021 { WE_SET_MAX_TX_POWER,
11022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11023 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011024 "setMaxTxPower" },
11025
11026 { WE_SET_MAX_TX_POWER_2_4,
11027 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11028 0,
11029 "setTxMaxPower2G" },
11030
11031 { WE_SET_MAX_TX_POWER_5_0,
11032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11033 0,
11034 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011035
11036 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11037 * as well to keep same syntax as in SAP. Now onwards, STA
11038 * will support both */
11039 { WE_SET_MAX_TX_POWER,
11040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11041 0,
11042 "setTxMaxPower" },
11043
Jeff Johnson295189b2012-06-20 16:38:30 -070011044 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11045 * 1 = enable and 0 = disable */
11046 {
11047 WE_SET_HIGHER_DTIM_TRANSITION,
11048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11049 0,
11050 "setHDtimTransn" },
11051
11052 { WE_SET_TM_LEVEL,
11053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011054 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 "setTmLevel" },
11056
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011057 { WE_ENABLE_STRICT_FCC_REG,
11058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11059 0,
11060 "setStrictFCCreg" },
11061
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011062 { WE_SET_DEBUG_LOG,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011065#ifdef FEATURE_WLAN_TDLS
11066 {
11067 WE_SET_TDLS_OFF_CHAN,
11068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11069 0,
11070 "tdlsoffchan" },
11071 {
11072 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11074 0,
11075 "tdlsecchnoffst" },
11076 {
11077 WE_SET_TDLS_OFF_CHAN_MODE,
11078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11079 0,
11080 "tdlsoffchnmode" },
11081#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011082
Peng Xu2446a892014-09-05 17:21:18 +053011083 { WE_SET_SCAN_BAND_PREFERENCE,
11084 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11085 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011086 {
11087 WE_GET_FRAME_LOG,
11088 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11089 0,
11090 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011091
Abhishek Singh01c73d12015-03-12 15:13:44 +053011092 { WE_SET_MIRACAST_VENDOR_CONFIG,
11093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11094 0, "setMiracstConf" },
11095
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011096#ifdef FEATURE_WLAN_TDLS
11097 {
11098 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11100 0,
11101 "tdls_2040bsscox" },
11102#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011103 { WE_SET_RTS_CTS_HTVHT,
11104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11105 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011106 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11108 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011109 { WE_SET_PROXIMITY_ENABLE,
11110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11111 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011112 /* handlers for main ioctl */
11113 { WLAN_PRIV_SET_NONE_GET_INT,
11114 0,
11115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11116 "" },
11117
11118 /* handlers for sub-ioctl */
11119 { WE_GET_11D_STATE,
11120 0,
11121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11122 "get11Dstate" },
11123
11124 { WE_IBSS_STATUS,
11125 0,
11126 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11127 "getAdhocStatus" },
11128
11129 { WE_PMC_STATE,
11130 0,
11131 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11132 "pmcState" },
11133
11134 { WE_GET_WLAN_DBG,
11135 0,
11136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11137 "getwlandbg" },
11138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 { WE_GET_MAX_ASSOC,
11140 0,
11141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11142 "getMaxAssoc" },
11143
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 { WE_GET_WDI_DBG,
11145 0,
11146 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11147 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011148
11149 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11150 0,
11151 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11152 "getAutoChannel" },
11153
11154 { WE_GET_CONCURRENCY_MODE,
11155 0,
11156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11157 "getconcurrency" },
11158
Peng Xu2446a892014-09-05 17:21:18 +053011159 { WE_GET_SCAN_BAND_PREFERENCE,
11160 0,
11161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11162 "get_scan_pref"},
11163
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011164 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11165 0,
11166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11167 "getCurAnt"},
11168
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 /* handlers for main ioctl */
11170 { WLAN_PRIV_SET_CHAR_GET_NONE,
11171 IW_PRIV_TYPE_CHAR| 512,
11172 0,
11173 "" },
11174
11175 /* handlers for sub-ioctl */
11176 { WE_WOWL_ADD_PTRN,
11177 IW_PRIV_TYPE_CHAR| 512,
11178 0,
11179 "wowlAddPtrn" },
11180
11181 { WE_WOWL_DEL_PTRN,
11182 IW_PRIV_TYPE_CHAR| 512,
11183 0,
11184 "wowlDelPtrn" },
11185
11186#if defined WLAN_FEATURE_VOWIFI
11187 /* handlers for sub-ioctl */
11188 { WE_NEIGHBOR_REPORT_REQUEST,
11189 IW_PRIV_TYPE_CHAR | 512,
11190 0,
11191 "neighbor" },
11192#endif
11193 { WE_SET_AP_WPS_IE,
11194 IW_PRIV_TYPE_CHAR| 512,
11195 0,
11196 "set_ap_wps_ie" },
11197
11198 { WE_SET_CONFIG,
11199 IW_PRIV_TYPE_CHAR| 512,
11200 0,
11201 "setConfig" },
11202
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011203 { WE_SET_ENCRYPT_MSG,
11204 IW_PRIV_TYPE_CHAR| 512,
11205 0,
11206 "encryptMsg" },
11207
11208
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 /* handlers for main ioctl */
11210 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11212 0,
11213 "" },
11214
11215 /* handlers for sub-ioctl */
11216 { WE_SET_WLAN_DBG,
11217 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11218 0,
11219 "setwlandbg" },
11220
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 { WE_SET_WDI_DBG,
11222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11223 0,
11224 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011225
11226 { WE_SET_SAP_CHANNELS,
11227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11228 0,
11229 "setsapchannels" },
11230
11231 /* handlers for main ioctl */
11232 { WLAN_PRIV_GET_CHAR_SET_NONE,
11233 0,
11234 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11235 "" },
11236
11237 /* handlers for sub-ioctl */
11238 { WE_WLAN_VERSION,
11239 0,
11240 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11241 "version" },
11242 { WE_GET_STATS,
11243 0,
11244 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11245 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011246 { WE_GET_STATES,
11247 0,
11248 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11249 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 { WE_GET_CFG,
11251 0,
11252 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11253 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011254#ifdef WLAN_FEATURE_11AC
11255 { WE_GET_RSSI,
11256 0,
11257 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11258 "getRSSI" },
11259#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011260#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011261 { WE_GET_ROAM_RSSI,
11262 0,
11263 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11264 "getRoamRSSI" },
11265#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 { WE_GET_WMM_STATUS,
11267 0,
11268 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11269 "getWmmStatus" },
11270 {
11271 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011272 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011273 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11274 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011275#ifdef FEATURE_WLAN_TDLS
11276 {
11277 WE_GET_TDLS_PEERS,
11278 0,
11279 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11280 "getTdlsPeers" },
11281#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011282#ifdef WLAN_FEATURE_11W
11283 {
11284 WE_GET_11W_INFO,
11285 0,
11286 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11287 "getPMFInfo" },
11288#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011289#ifdef WLAN_FEATURE_RMC
11290 {
11291 WE_GET_IBSS_STA_INFO,
11292 0,
11293 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11294 "getIbssSTAs" },
11295#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011296 { WE_GET_SNR,
11297 0,
11298 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11299 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011300#ifdef FEATURE_OEM_DATA_SUPPORT
11301 {
11302 WE_GET_OEM_DATA_CAP,
11303 0,
11304 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11305 "getOemDataCap" },
11306#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011307 /* handlers for main ioctl */
11308 { WLAN_PRIV_SET_NONE_GET_NONE,
11309 0,
11310 0,
11311 "" },
11312
11313 /* handlers for sub-ioctl */
11314 { WE_CLEAR_STATS,
11315 0,
11316 0,
11317 "clearStats" },
11318 { WE_INIT_AP,
11319 0,
11320 0,
11321 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011322#ifdef WLAN_FEATURE_RMC
11323 {
11324 WE_IBSS_GET_PEER_INFO_ALL,
11325 0,
11326 0,
11327 "ibssPeerInfoAll" },
11328#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011329 { WE_STOP_AP,
11330 0,
11331 0,
11332 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011333#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 { WE_ENABLE_AMP,
11335 0,
11336 0,
11337 "enableAMP" },
11338 { WE_DISABLE_AMP,
11339 0,
11340 0,
11341 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011342#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011343 { WE_ENABLE_DXE_STALL_DETECT,
11344 0,
11345 0,
11346 "dxeStallDetect" },
11347 { WE_DISPLAY_DXE_SNAP_SHOT,
11348 0,
11349 0,
11350 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011351 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11352 0,
11353 0,
11354 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011355 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011356 WE_SET_REASSOC_TRIGGER,
11357 0,
11358 0,
11359 "reassoc" },
11360 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011361 WE_STOP_OBSS_SCAN,
11362 0,
11363 0,
11364 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011365 {
11366 WE_DUMP_ROAM_TIMER_LOG,
11367 0,
11368 0,
11369 "dumpRoamDelay" },
11370 {
11371 WE_RESET_ROAM_TIMER_LOG,
11372 0,
11373 0,
11374 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011375 {
11376 WE_GET_FW_LOGS,
11377 0,
11378 0,
11379 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011380 {
11381 WE_GET_FW_MEMDUMP,
11382 0,
11383 0,
11384 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 /* handlers for main ioctl */
11386 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11387 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11388 0,
11389 "" },
11390
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011391
11392
Jeff Johnson295189b2012-06-20 16:38:30 -070011393 /* handlers for sub-ioctl */
11394 { WE_LOG_DUMP_CMD,
11395 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11396 0,
11397 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011398#ifdef WLAN_FEATURE_RMC
11399 { WE_IBSS_GET_PEER_INFO,
11400 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11401 0,
11402 "ibssPeerInfo" },
11403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011404
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011405 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011406 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11407 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11408 0,
11409 "setdumplog" },
11410
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011411 { WE_MTRACE_DUMP_CMD,
11412 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11413 0,
11414 "dumplog" },
11415
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011416 /* handlers for sub ioctl */
11417 {
11418 WE_MCC_CONFIG_CREDENTIAL,
11419 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11420 0,
11421 "setMccCrdnl" },
11422
11423 /* handlers for sub ioctl */
11424 {
11425 WE_MCC_CONFIG_PARAMS,
11426 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11427 0,
11428 "setMccConfig" },
11429
Chilam NG571c65a2013-01-19 12:27:36 +053011430#ifdef FEATURE_WLAN_TDLS
11431 /* handlers for sub ioctl */
11432 {
11433 WE_TDLS_CONFIG_PARAMS,
11434 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11435 0,
11436 "setTdlsConfig" },
11437#endif
11438
Katya Nigamf0511f62015-05-05 16:40:57 +053011439 {
11440 WE_CONFIGURE_MONITOR_MODE,
11441 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11442 0,
11443 "MonitorModeConf" },
11444
11445 {
11446 WE_SET_MONITOR_MODE_FILTER,
11447 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11448 0,
11449 "MonitorFilter" },
11450
Jeff Johnson295189b2012-06-20 16:38:30 -070011451 /* handlers for main ioctl */
11452 { WLAN_PRIV_ADD_TSPEC,
11453 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11454 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11455 "addTspec" },
11456
11457 /* handlers for main ioctl */
11458 { WLAN_PRIV_DEL_TSPEC,
11459 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11460 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11461 "delTspec" },
11462
11463 /* handlers for main ioctl */
11464 { WLAN_PRIV_GET_TSPEC,
11465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11466 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11467 "getTspec" },
11468
Jeff Johnsone7245742012-09-05 17:12:55 -070011469#ifdef FEATURE_OEM_DATA_SUPPORT
11470 /* handlers for main ioctl - OEM DATA */
11471 {
11472 WLAN_PRIV_SET_OEM_DATA_REQ,
11473 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11474 0,
11475 "set_oem_data_req" },
11476
11477 /* handlers for main ioctl - OEM DATA */
11478 {
11479 WLAN_PRIV_GET_OEM_DATA_RSP,
11480 0,
11481 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11482 "get_oem_data_rsp" },
11483#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011484
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 /* handlers for main ioctl - host offload */
11486 {
11487 WLAN_PRIV_SET_HOST_OFFLOAD,
11488 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11489 0,
11490 "setHostOffload" },
11491
11492 {
11493 WLAN_GET_WLAN_STATISTICS,
11494 0,
11495 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11496 "getWlanStats" },
11497
11498 {
11499 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011500 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11501 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 0,
11503 "setKeepAlive" },
11504#ifdef WLAN_FEATURE_PACKET_FILTERING
11505 {
11506 WLAN_SET_PACKET_FILTER_PARAMS,
11507 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11508 0,
11509 "setPktFilter" },
11510#endif
11511#ifdef FEATURE_WLAN_SCAN_PNO
11512 {
11513 WLAN_SET_PNO,
11514 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11515 0,
11516 "setpno" },
11517#endif
11518 {
11519 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011520 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 0,
11522 "SETBAND" },
11523 /* handlers for dynamic MC BC ioctl */
11524 {
11525 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011526 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 0,
11528 "setMCBCFilter" },
11529 {
11530 WLAN_PRIV_CLEAR_MCBC_FILTER,
11531 0,
11532 0,
11533 "clearMCBCFilter" },
11534 {
11535 WLAN_SET_POWER_PARAMS,
11536 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11537 0,
11538 "setpowerparams" },
11539 {
11540 WLAN_GET_LINK_SPEED,
11541 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011542 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011543};
11544
11545
11546
11547const struct iw_handler_def we_handler_def = {
11548 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11549 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11550 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11551
11552 .standard = (iw_handler *)we_handler,
11553 .private = (iw_handler *)we_private,
11554 .private_args = we_private_args,
11555 .get_wireless_stats = get_wireless_stats,
11556};
11557
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011558int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11559{
11560 v_U32_t cmd = 288; //Command to RIVA
11561 hdd_context_t *pHddCtx = NULL;
11562 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11563 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11564 /*
11565 *configMccParam : specify the bit which needs to be modified
11566 *allowed to update based on wlan_qcom_cfg.ini
11567 * configuration
11568 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11569 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11570 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11571 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11572 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11573 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11574 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11575 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11576 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11577 * Bit 9 : Reserved
11578 */
11579 switch (arg1)
11580 {
11581 //Update MCC SCHEDULE_TIME_SLICE parameter
11582 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11583 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11584 {
11585 if((arg2 >= 5) && (arg2 <= 20))
11586 {
11587 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11588 }
11589 else
11590 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011591 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011592 return 0;
11593 }
11594 }
11595 break;
11596
11597 //Update MCC MAX_NULL_SEND_TIME parameter
11598 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11599 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11600 {
11601 if((arg2 >= 1) && (arg2 <= 10))
11602 {
11603 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11604 }
11605 else
11606 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011607 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011608 return 0;
11609 }
11610 }
11611 break;
11612
11613 //Update MCC TX_EARLY_STOP_TIME parameter
11614 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11615 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11616 {
11617 if((arg2 >= 1) && (arg2 <= 10))
11618 {
11619 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11620 }
11621 else
11622 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011623 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011624 return 0;
11625 }
11626 }
11627 break;
11628
11629 //Update MCC RX_DRAIN_TIME parameter
11630 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11631 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11632 {
11633 if((arg2 >= 1) && (arg2 <= 10))
11634 {
11635 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11636 }
11637 else
11638 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011639 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011640 return 0;
11641 }
11642 }
11643 break;
11644
11645 //Update MCC CHANNEL_SWITCH_TIME parameter
11646 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11647 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11648 {
11649 if((arg2 >= 1) && (arg2 <= 20))
11650 {
11651 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11652 }
11653 else
11654 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011655 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011656 return 0;
11657 }
11658 }
11659 break;
11660
11661 //Update MCC MIN_CHANNEL_TIME parameter
11662 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11663 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11664 {
11665 if((arg2 >= 5) && (arg2 <= 20))
11666 {
11667 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11668 }
11669 else
11670 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011671 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011672 return 0;
11673 }
11674 }
11675 break;
11676
11677 //Update MCC PARK_BEFORE_TBTT parameter
11678 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11679 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11680 {
11681 if((arg2 >= 1) && (arg2 <= 5))
11682 {
11683 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11684 }
11685 else
11686 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011687 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011688 return 0;
11689 }
11690 }
11691 break;
11692
11693 //Update MCC MIN_AFTER_DTIM parameter
11694 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11695 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11696 {
11697 if((arg2 >= 5) && (arg2 <= 15))
11698 {
11699 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11700 }
11701 else
11702 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011703 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011704 return 0;
11705 }
11706 }
11707 break;
11708
11709 //Update MCC TOO_CLOSE_MARGIN parameter
11710 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11711 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11712 {
11713 if((arg2 >= 1) && (arg2 <= 3))
11714 {
11715 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11716 }
11717 else
11718 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011719 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011720 return 0;
11721 }
11722 }
11723 break;
11724
11725 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011726 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011727 __FUNCTION__,arg1);
11728 break;
11729 }
11730 return 0;
11731}
11732
Jeff Johnson295189b2012-06-20 16:38:30 -070011733int hdd_set_wext(hdd_adapter_t *pAdapter)
11734{
11735 hdd_wext_state_t *pwextBuf;
11736 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011737 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011738
11739 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11740
11741 // Now configure the roaming profile links. To SSID and bssid.
11742 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11743 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11744
11745 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11746 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11747
11748 /*Set the numOfChannels to zero to scan all the channels*/
11749 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11750 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11751
11752 /* Default is no encryption */
11753 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11754 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11755
11756 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11757 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11758
11759 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11760
11761 /* Default is no authentication */
11762 pwextBuf->roamProfile.AuthType.numEntries = 1;
11763 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11764
11765 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11766 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11767
11768 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011769 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011770
11771 hdd_clearRoamProfileIe(pAdapter);
11772
11773 return VOS_STATUS_SUCCESS;
11774
11775 }
11776
11777int hdd_register_wext(struct net_device *dev)
11778 {
11779 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11780 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11781 VOS_STATUS status;
11782
11783 ENTER();
11784
11785 // Zero the memory. This zeros the profile structure.
11786 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11787
11788 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11789
11790
11791 status = hdd_set_wext(pAdapter);
11792
11793 if(!VOS_IS_STATUS_SUCCESS(status)) {
11794
Arif Hussain6d2a3322013-11-17 19:50:10 -080011795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 return eHAL_STATUS_FAILURE;
11797 }
11798
11799 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11800 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 return eHAL_STATUS_FAILURE;
11803 }
11804
11805 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 return eHAL_STATUS_FAILURE;
11809 }
11810
11811 // Register as a wireless device
11812 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11813
11814 EXIT();
11815 return 0;
11816}
11817
11818int hdd_UnregisterWext(struct net_device *dev)
11819{
c_hpothu2a13bc32015-01-21 12:48:54 +053011820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11821 if (dev != NULL)
11822 {
11823 rtnl_lock();
11824 dev->wireless_handlers = NULL;
11825 rtnl_unlock();
11826 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011827
Jeff Johnson295189b2012-06-20 16:38:30 -070011828 return 0;
11829}
11830
11831