blob: 854b6b3c51f9674253460f355b65e081eb52305b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530176#define WE_SET_PROXIMITY_ENABLE 24
Jeff Johnson295189b2012-06-20 16:38:30 -0700177
178/* Private ioctls and their sub-ioctls */
179#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
180#define WE_GET_11D_STATE 1
181#define WE_IBSS_STATUS 2
182#define WE_PMC_STATE 3
183#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700184#define WE_GET_MAX_ASSOC 6
185#define WE_GET_WDI_DBG 7
186#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
187#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530188#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530189#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700190/* Private ioctls and their sub-ioctls */
191#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
192
193/* Private ioctls and their sub-ioctls */
194#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
195#define WE_WOWL_ADD_PTRN 1
196#define WE_WOWL_DEL_PTRN 2
197#if defined WLAN_FEATURE_VOWIFI
198#define WE_NEIGHBOR_REPORT_REQUEST 3
199#endif
200#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
201#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530202#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700203
204/* Private ioctls and their sub-ioctls */
205#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
206#define WE_SET_WLAN_DBG 1
207#define WE_SET_WDI_DBG 2
208#define WE_SET_SAP_CHANNELS 3
209
210/* Private ioctls and their sub-ioctls */
211#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
212#define WE_WLAN_VERSION 1
213#define WE_GET_STATS 2
214#define WE_GET_CFG 3
215#define WE_GET_WMM_STATUS 4
216#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700217#ifdef WLAN_FEATURE_11AC
218#define WE_GET_RSSI 6
219#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800220#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800221#ifdef FEATURE_WLAN_TDLS
222#define WE_GET_TDLS_PEERS 8
223#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700224#ifdef WLAN_FEATURE_11W
225#define WE_GET_11W_INFO 9
226#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530227#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530228#ifdef WLAN_FEATURE_RMC
229#define WE_GET_IBSS_STA_INFO 11
230#endif
231#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700232
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530233#ifdef FEATURE_OEM_DATA_SUPPORT
234#define WE_GET_OEM_DATA_CAP 13
235#endif
236
Jeff Johnson295189b2012-06-20 16:38:30 -0700237/* Private ioctls and their sub-ioctls */
238#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
239#define WE_CLEAR_STATS 1
240#define WE_INIT_AP 2
241#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530242#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700243#define WE_ENABLE_AMP 4
244#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530245#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700246#define WE_ENABLE_DXE_STALL_DETECT 6
247#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700248#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530249#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530250#ifdef WLAN_FEATURE_RMC
251#define WE_IBSS_GET_PEER_INFO_ALL 10
252#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530253#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530254#define WE_DUMP_ROAM_TIMER_LOG 12
255#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530256#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530257#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530258
Jeff Johnson295189b2012-06-20 16:38:30 -0700259/* Private ioctls and their sub-ioctls */
260#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
261#define WE_LOG_DUMP_CMD 1
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800264//IOCTL to configure MCC params
265#define WE_MCC_CONFIG_CREDENTIAL 3
266#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700267
Chilam NG571c65a2013-01-19 12:27:36 +0530268#ifdef FEATURE_WLAN_TDLS
269#define WE_TDLS_CONFIG_PARAMS 5
270#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530271#ifdef WLAN_FEATURE_RMC
272#define WE_IBSS_GET_PEER_INFO 6
273#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530274
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700275#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530276#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530277#define WE_CONFIGURE_MONITOR_MODE 10
278#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700279
Chilam Ng01120412013-02-19 18:32:21 -0800280#ifdef FEATURE_WLAN_TDLS
281#undef MAX_VAR_ARGS
282#define MAX_VAR_ARGS 10
283#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700284#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800285#endif
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287/* Private ioctls (with no sub-ioctls) */
288/* note that they must be odd so that they have "get" semantics */
289#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
290#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
291#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
292
Girish Gowli464c9c82014-06-09 19:47:53 +0530293/* (SIOCIWFIRSTPRIV + 8) is currently unused */
294/* (SIOCIWFIRSTPRIV + 16) is currently unused */
295/* (SIOCIWFIRSTPRIV + 10) is currently unused */
296/* (SIOCIWFIRSTPRIV + 12) is currently unused */
297/* (SIOCIWFIRSTPRIV + 14) is currently unused */
298/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
Jeff Johnsone7245742012-09-05 17:12:55 -0700300#ifdef FEATURE_OEM_DATA_SUPPORT
301/* Private ioctls for setting the measurement configuration */
302#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
303#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700305
306#ifdef WLAN_FEATURE_VOWIFI_11R
307#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
308#endif
309
310/* Private ioctl for setting the host offload feature */
311#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
312
313/* Private ioctl to get the statistics */
314#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
315
316/* Private ioctl to set the Keep Alive Params */
317#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
318#ifdef WLAN_FEATURE_PACKET_FILTERING
319/* Private ioctl to set the Packet Filtering Params */
320#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
321#endif
322
323#ifdef FEATURE_WLAN_SCAN_PNO
324/* Private ioctl to get the statistics */
325#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
326#endif
327
328#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
329
330#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
331#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700332/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
335#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
336
337#define WLAN_STATS_INVALID 0
338#define WLAN_STATS_RETRY_CNT 1
339#define WLAN_STATS_MUL_RETRY_CNT 2
340#define WLAN_STATS_TX_FRM_CNT 3
341#define WLAN_STATS_RX_FRM_CNT 4
342#define WLAN_STATS_FRM_DUP_CNT 5
343#define WLAN_STATS_FAIL_CNT 6
344#define WLAN_STATS_RTS_FAIL_CNT 7
345#define WLAN_STATS_ACK_FAIL_CNT 8
346#define WLAN_STATS_RTS_SUC_CNT 9
347#define WLAN_STATS_RX_DISCARD_CNT 10
348#define WLAN_STATS_RX_ERROR_CNT 11
349#define WLAN_STATS_TX_BYTE_CNT 12
350
351#define WLAN_STATS_RX_BYTE_CNT 13
352#define WLAN_STATS_RX_RATE 14
353#define WLAN_STATS_TX_RATE 15
354
Jeff Johnsone7245742012-09-05 17:12:55 -0700355#define WLAN_STATS_RX_UC_BYTE_CNT 16
356#define WLAN_STATS_RX_MC_BYTE_CNT 17
357#define WLAN_STATS_RX_BC_BYTE_CNT 18
358#define WLAN_STATS_TX_UC_BYTE_CNT 19
359#define WLAN_STATS_TX_MC_BYTE_CNT 20
360#define WLAN_STATS_TX_BC_BYTE_CNT 21
361
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800362#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
363 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
364 { \
365 *__p++ = __type; \
366 *__p++ = __size; \
367 memcpy(__p, __val, __size); \
368 __p += __size; \
369 __tlen += __size + 2; \
370 } \
371 else \
372 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800373 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800374 } \
375 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
377#define VERSION_VALUE_MAX_LEN 32
378
379#define TX_PER_TRACKING_DEFAULT_RATIO 5
380#define TX_PER_TRACKING_MAX_RATIO 10
381#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
382
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530383#define WLAN_ADAPTER 0
384#define P2P_ADAPTER 1
385
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530386#define TX_PWR_MIN 6
387#define TX_PWR_MAX 22
388#define TX_PWR_DEF 50
389
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530390/*
391 * When supplicant sends SETBAND ioctl it queries for channels from
392 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
393 * This is not required if the return type from ioctl is
394 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
395 * event as part of regulatory_hint.
396 */
397enum {
398 SEND_CHANNEL_CHANGE_EVENT = 0,
399 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
400};
401
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800402/*MCC Configuration parameters */
403enum {
404 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
405 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
406 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
407 MCC_RX_DRAIN_TIME_CFG_PARAM,
408 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
409 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
410 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
411 MCC_MIN_AFTER_DTIM_CFG_PARAM,
412 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
413};
414
415int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
416 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
417
Jeff Johnson295189b2012-06-20 16:38:30 -0700418#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800419int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700420 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700421#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530422static int get_fwr_memdump(struct net_device *,
423 struct iw_request_info *,
424 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700425/**---------------------------------------------------------------------------
426
Arif Hussain0273cba2014-01-07 20:58:29 -0800427 \brief mem_alloc_copy_from_user_helper -
428
429 Helper function to allocate buffer and copy user data.
430
431 \param - wrqu - Pointer to IOCTL Data.
432 len - size
433
434 \return - On Success pointer to buffer, On failure NULL
435
436 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530437void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800438{
439 u8 *ptr = NULL;
440
441 /* in order to protect the code, an extra byte is post appended to the buffer
442 * and the null termination is added. However, when allocating (len+1) byte
443 * of memory, we need to make sure that there is no uint overflow when doing
444 * addition. In theory check len < UINT_MAX protects the uint overflow. For
445 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
446 * guess, now, it is assumed that the private command buffer size is no
447 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
448 */
449 if (len > MAX_USER_COMMAND_SIZE)
450 {
451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
452 "Invalid length");
453 return NULL;
454 }
455
456 ptr = kmalloc(len + 1, GFP_KERNEL);
457 if (NULL == ptr)
458 {
459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
460 "unable to allocate memory");
461 return NULL;
462 }
463
464 if (copy_from_user(ptr, wrqu_data, len))
465 {
466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
467 "%s: failed to copy data to user buffer", __func__);
468 kfree(ptr);
469 return NULL;
470 }
471 ptr[len] = '\0';
472 return ptr;
473}
474
Girish Gowli488ef492014-06-12 18:44:33 +0530475// Function to handle and get compatible struct iw_point passed to ioctl.
476int hdd_priv_get_data(struct iw_point *p_priv_data,
477 union iwreq_data *wrqu)
478{
479 if ((NULL == p_priv_data) || (NULL == wrqu))
480 {
481 return -EINVAL;
482 }
483
484#ifdef CONFIG_COMPAT
485 if (is_compat_task())
486 {
487 struct compat_iw_point *p_compat_priv_data;
488
489 // Compat task: typecast to campat structure and copy the members.
490 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
491
492 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
493 p_priv_data->length = p_compat_priv_data->length;
494 p_priv_data->flags = p_compat_priv_data->flags;
495 }//if(is_compat_task())
496 else
497 {
498#endif //#ifdef CONFIG_COMPAT
499
500 // Non compat task: directly copy the structure.
501 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
502
503#ifdef CONFIG_COMPAT
504 }//else of - if(is_compat_task())
505#endif //#ifdef CONFIG_COMPAT
506
507 return 0;
508}
509
Arif Hussain0273cba2014-01-07 20:58:29 -0800510/**---------------------------------------------------------------------------
511
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 \brief hdd_wlan_get_version() -
513
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800514 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
516 \param - pAdapter Pointer to the adapter.
517 wrqu - Pointer to IOCTL REQUEST Data.
518 extra - Pointer to char
519
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800520 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
522 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800523void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
524 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700525{
526 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 tSirVersionString wcnss_SW_version;
528 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530529 tSirVersionString iris_name;
530 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800531 char *pSWversion;
532 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700534
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800535 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
536 sizeof(wcnss_SW_version));
537 if (VOS_IS_STATUS_SUCCESS(status))
538 {
539 pSWversion = wcnss_SW_version;
540 }
541 else
542 {
543 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 }
545
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800546 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
547 sizeof(wcnss_HW_version));
548 if (VOS_IS_STATUS_SUCCESS(status))
549 {
550 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800552 else
553 {
554 pHWversion = "Unknown";
555 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700556
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530557 status = wcnss_get_iris_name(iris_name);
558
559 if (!status) {
560 pIRISversion = iris_name;
561 } else {
562 pIRISversion = "Unknown";
563 }
564
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700565 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530566 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800567 QWLAN_VERSIONSTR,
568 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530569 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800570
571 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700572}
573
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530574#ifdef WLAN_FEATURE_RMC
575void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
576{
577 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
578 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
579 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
580 v_U8_t i;
581
582 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
583 {
584 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
585 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
586 for (i = 0; i < pPeerInfo->numPeers; i++)
587 {
588 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
589 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
590 }
591 }
592 else
593 {
594 hddLog(LOGE,
595 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
596 }
597
598 complete(&pAdapter->ibss_peer_info_comp);
599}
600
601v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
602{
603 v_U8_t idx;
604 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
605
606 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
607 {
608 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
609 staIdx == pHddStaCtx->conn_info.staId[ idx ])
610 {
611 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
612 }
613 }
614 return NULL;
615}
616
617eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
618{
619 eHalStatus status = eHAL_STATUS_FAILURE;
620 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
621 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
622 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
623
624 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
625 VOS_FALSE, staIdx);
626
627 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
628
629 if (eHAL_STATUS_SUCCESS == status)
630 {
631 long ret;
632 ret = wait_for_completion_interruptible_timeout
633 (&pAdapter->ibss_peer_info_comp,
634 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
635 if (ret <= 0)
636 {
637 hddLog(VOS_TRACE_LEVEL_ERROR,
638 FL("failed wait on ibss_peer_info_comp %ld"), ret);
639 return eHAL_STATUS_FAILURE;
640 }
641
642 /** Print the peer info */
643 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
644 pr_info("============================================================");
645 {
646 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
647 staIdx);
648 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
649
650 if (NULL != macAddr)
651 {
652 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
653 MAC_ADDR_ARRAY(macAddr->bytes),
654 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
655 }
656 else
657 {
658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
659 " ERROR: PEER MAC ADDRESS NOT FOUND ");
660 }
661 }
662 }
663 else
664 {
665 hddLog(VOS_TRACE_LEVEL_WARN,
666 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
667 }
668
669 return status;
670}
671
672eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
673{
674 eHalStatus status = eHAL_STATUS_FAILURE;
675 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
676 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
677 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
678 int i;
679
680 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
681 VOS_TRUE, 0xFF);
682 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
683
684 if (eHAL_STATUS_SUCCESS == status)
685 {
686 long ret;
687 ret = wait_for_completion_interruptible_timeout
688 (&pAdapter->ibss_peer_info_comp,
689 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
690 if (ret <= 0)
691 {
692 hddLog(VOS_TRACE_LEVEL_ERROR,
693 FL("failed wait on ibss_peer_info_comp %ld"), ret);
694 return eHAL_STATUS_FAILURE;
695 }
696
697 /** Print the peer info */
698 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
699 pr_info("============================================================");
700 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
701 {
702 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
703 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
704 staIdx);
705 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
706
707 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
708 if (NULL != macAddr)
709 {
710 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
711 MAC_ADDR_ARRAY(macAddr->bytes),
712 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
713 }
714 else
715 {
716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
717 " ERROR: PEER MAC ADDRESS NOT FOUND ");
718 }
719 }
720 }
721 else
722 {
723 hddLog(VOS_TRACE_LEVEL_WARN,
724 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
725 }
726
727 return status;
728}
729#endif /* WLAN_FEATURE_RMC */
730
Jeff Johnson295189b2012-06-20 16:38:30 -0700731int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
732{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530733 tHalHandle hHal;
734 hdd_context_t *pHddCtx;
735 v_U32_t threshold = 0;
736 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700737
738 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530739 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530740 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
742 "%s: Adapter is NULL",__func__);
743 return -EINVAL;
744 }
745
746 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
747 ret = wlan_hdd_validate_context(pHddCtx);
748 if (0 != ret)
749 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530750 return ret;
751 }
752
753 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
754 if (NULL == hHal)
755 {
756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
757 "%s: Hal Context is NULL",__func__);
758 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 }
760
761 if ( eHAL_STATUS_SUCCESS !=
762 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
763 {
c_hpothub8245442013-11-20 23:41:09 +0530764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
765 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 return -EIO;
767 }
768 wrqu->rts.value = threshold;
769
770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800771 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772
773 EXIT();
774
775 return 0;
776}
777
778int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
779{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530780 tHalHandle hHal;
781 hdd_context_t *pHddCtx;
782 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700783
784 ENTER();
785
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530786 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530787 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
789 "%s: Adapter is NULL",__func__);
790 return -EINVAL;
791 }
792
793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
794 status = wlan_hdd_validate_context(pHddCtx);
795 if (0 != status)
796 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530797 return status;
798 }
799
800 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
801 if (NULL == hHal)
802 {
803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
804 "%s: Hal Context is NULL",__func__);
805 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 }
807
808 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
809 != eHAL_STATUS_SUCCESS )
810 {
c_hpothub8245442013-11-20 23:41:09 +0530811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
812 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 return -EIO;
814 }
815 wrqu->frag.value = threshold;
816
817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800818 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700819
820 EXIT();
821
822 return 0;
823}
824
825int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
826{
Jeff Johnsone7245742012-09-05 17:12:55 -0700827 int i;
828 if (channel > 0)
829 {
830 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
831 {
832 if (channel == freq_chan_map[i].chan)
833 {
834 *pfreq = freq_chan_map[i].freq;
835 return 1;
836 }
837 }
838 }
839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800840 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700841 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842}
843
844static v_BOOL_t
845hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
846{
847 v_BOOL_t rsnType = VOS_FALSE;
848 // is the authType supported?
849 switch (authType)
850 {
851 case eCSR_AUTH_TYPE_NONE: //never used
852 rsnType = eANI_BOOLEAN_FALSE;
853 break;
854 // MAC layer authentication types
855 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
856 rsnType = eANI_BOOLEAN_FALSE;
857 break;
858 case eCSR_AUTH_TYPE_SHARED_KEY:
859 rsnType = eANI_BOOLEAN_FALSE;
860 break;
861 case eCSR_AUTH_TYPE_AUTOSWITCH:
862 rsnType = eANI_BOOLEAN_FALSE;
863 break;
864
865 // Upper layer authentication types
866 case eCSR_AUTH_TYPE_WPA:
867 rsnType = eANI_BOOLEAN_TRUE;
868 break;
869 case eCSR_AUTH_TYPE_WPA_PSK:
870 rsnType = eANI_BOOLEAN_TRUE;
871 break;
872 case eCSR_AUTH_TYPE_WPA_NONE:
873 rsnType = eANI_BOOLEAN_TRUE;
874 break;
875#ifdef WLAN_FEATURE_VOWIFI_11R
876 case eCSR_AUTH_TYPE_FT_RSN:
877#endif
878 case eCSR_AUTH_TYPE_RSN:
879 rsnType = eANI_BOOLEAN_TRUE;
880 break;
881#ifdef WLAN_FEATURE_VOWIFI_11R
882 case eCSR_AUTH_TYPE_FT_RSN_PSK:
883#endif
884 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700885#ifdef WLAN_FEATURE_11W
886 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530887 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 rsnType = eANI_BOOLEAN_TRUE;
890 break;
891 //case eCSR_AUTH_TYPE_FAILED:
892 case eCSR_AUTH_TYPE_UNKNOWN:
893 rsnType = eANI_BOOLEAN_FALSE;
894 break;
895 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800896 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
897 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 rsnType = eANI_BOOLEAN_FALSE;
899 break;
900 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800901 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700902 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 return rsnType;
904}
905
906static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
907{
908 struct statsContext *pStatsContext;
909 hdd_adapter_t *pAdapter;
910
911 if (ioctl_debug)
912 {
913 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700914 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 }
916
917 if (NULL == pContext)
918 {
919 hddLog(VOS_TRACE_LEVEL_ERROR,
920 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700921 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 return;
923 }
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 pStatsContext = pContext;
926 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800927
928 /* there is a race condition that exists between this callback
929 function and the caller since the caller could time out either
930 before or while this code is executing. we use a spinlock to
931 serialize these actions */
932 spin_lock(&hdd_context_lock);
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
935 {
936 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800937 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 hddLog(VOS_TRACE_LEVEL_WARN,
939 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700940 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 if (ioctl_debug)
942 {
943 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700944 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 }
946 return;
947 }
948
Jeff Johnson72a40512013-12-19 10:14:15 -0800949 /* context is valid so caller is still waiting */
950
951 /* paranoia: invalidate the magic */
952 pStatsContext->magic = 0;
953
Sachin Ahujaa082b672015-10-05 19:51:31 +0530954 /* copy over the rssi.FW will return RSSI as -100
955 * if there are no samples to calculate the average
956 * RSSI
957 */
958 if (rssi != -100)
959 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530960 if (pAdapter->rssi > 0)
961 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800962 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800964
965 /* serialization is complete */
966 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967}
968
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530969static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
970{
971 struct statsContext *pStatsContext;
972 hdd_adapter_t *pAdapter;
973
974 if (ioctl_debug)
975 {
976 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
977 __func__, (int)snr, (int)staId, pContext);
978 }
979
980 if (NULL == pContext)
981 {
982 hddLog(VOS_TRACE_LEVEL_ERROR,
983 "%s: Bad param, pContext [%p]",
984 __func__, pContext);
985 return;
986 }
987
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530988 pStatsContext = pContext;
989 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800990
991 /* there is a race condition that exists between this callback
992 function and the caller since the caller could time out either
993 before or while this code is executing. we use a spinlock to
994 serialize these actions */
995 spin_lock(&hdd_context_lock);
996
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530997 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
998 {
999 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001000 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301001 hddLog(VOS_TRACE_LEVEL_WARN,
1002 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1003 __func__, pAdapter, pStatsContext->magic);
1004 if (ioctl_debug)
1005 {
1006 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1007 __func__, pAdapter, pStatsContext->magic);
1008 }
1009 return;
1010 }
1011
Jeff Johnson72a40512013-12-19 10:14:15 -08001012 /* context is valid so caller is still waiting */
1013
1014 /* paranoia: invalidate the magic */
1015 pStatsContext->magic = 0;
1016
1017 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301018 pAdapter->snr = snr;
1019
Jeff Johnson72a40512013-12-19 10:14:15 -08001020 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301021 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001022
1023 /* serialization is complete */
1024 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301025}
1026
Jeff Johnson295189b2012-06-20 16:38:30 -07001027VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1028{
1029 struct statsContext context;
1030 hdd_context_t *pHddCtx;
1031 hdd_station_ctx_t *pHddStaCtx;
1032 eHalStatus hstatus;
1033 long lrc;
1034
1035 if (NULL == pAdapter)
1036 {
1037 hddLog(VOS_TRACE_LEVEL_WARN,
1038 "%s: Invalid context, pAdapter", __func__);
1039 return VOS_STATUS_E_FAULT;
1040 }
1041 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1042 {
1043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1044 /* return a cached value */
1045 *rssi_value = pAdapter->rssi;
1046 return VOS_STATUS_SUCCESS;
1047 }
1048
1049 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1050 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1051
mukul sharma8aec69b2015-06-10 22:28:43 +05301052 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1053 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1055 __func__, pAdapter->rssi_on_disconnect);
1056 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301057 return VOS_STATUS_SUCCESS;
1058 }
1059
1060 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1061 {
1062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1063 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1064 *rssi_value = pAdapter->rssi;
1065 return VOS_STATUS_SUCCESS;
1066 }
1067
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 init_completion(&context.completion);
1069 context.pAdapter = pAdapter;
1070 context.magic = RSSI_CONTEXT_MAGIC;
1071
1072 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
1073 pHddStaCtx->conn_info.staId[ 0 ],
1074 pHddStaCtx->conn_info.bssId,
1075 &context, pHddCtx->pvosContext);
1076 if (eHAL_STATUS_SUCCESS != hstatus)
1077 {
1078 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001079 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 /* we'll returned a cached value below */
1081 }
1082 else
1083 {
1084 /* request was sent -- wait for the response */
1085 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1086 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 if (lrc <= 0)
1088 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001090 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 /* we'll now returned a cached value below */
1092 }
1093 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001094
1095 /* either we never sent a request, we sent a request and received a
1096 response or we sent a request and timed out. if we never sent a
1097 request or if we sent a request and got a response, we want to
1098 clear the magic out of paranoia. if we timed out there is a
1099 race condition such that the callback function could be
1100 executing at the same time we are. of primary concern is if the
1101 callback function had already verified the "magic" but had not
1102 yet set the completion variable when a timeout occurred. we
1103 serialize these activities by invalidating the magic while
1104 holding a shared spinlock which will cause us to block if the
1105 callback is currently executing */
1106 spin_lock(&hdd_context_lock);
1107 context.magic = 0;
1108 spin_unlock(&hdd_context_lock);
1109
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 *rssi_value = pAdapter->rssi;
1111
1112 return VOS_STATUS_SUCCESS;
1113}
Siddharth Bhal64246172015-02-27 01:04:37 +05301114/**---------------------------------------------------------------------------
1115
1116 \brief wlan_hdd_get_frame_logs() -
1117
1118 This function use to get Frames log.
1119
1120 \param - pAdapter Pointer to the adapter.
1121 flag - Specify type of request. Clear and Send request are
1122 supported.
1123
1124 \return - none
1125
1126 --------------------------------------------------------------------------*/
1127VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1128{
Siddharth Bhal64246172015-02-27 01:04:37 +05301129 hdd_context_t *pHddCtx;
1130 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301131
1132 if (NULL == pAdapter)
1133 {
1134 hddLog(VOS_TRACE_LEVEL_WARN,
1135 "%s: Invalid context, pAdapter", __func__);
1136 return VOS_STATUS_E_FAULT;
1137 }
1138
1139 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1140 if (!pHddCtx->mgmt_frame_logging)
1141 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301142 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301143 return VOS_STATUS_E_AGAIN;
1144 }
1145
Siddharth Bhal4507c262015-04-29 20:20:42 +05301146 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1147 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1148 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301149 {
1150 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1151 return VOS_STATUS_E_INVAL;
1152 }
1153
Siddharth Bhal4507c262015-04-29 20:20:42 +05301154 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1155 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1156 {
1157 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1158 return VOS_STATUS_E_INVAL;
1159 }
1160
Abhishek Singh611295e2015-07-09 11:11:54 +05301161 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301162 if (eHAL_STATUS_SUCCESS != hstatus)
1163 {
1164 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301165 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301166 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301167
1168 return VOS_STATUS_SUCCESS;
1169}
1170
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301171
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301172VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1173{
1174 struct statsContext context;
1175 hdd_context_t *pHddCtx;
1176 hdd_station_ctx_t *pHddStaCtx;
1177 eHalStatus hstatus;
1178 long lrc;
1179 int valid;
1180
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301181 ENTER();
1182
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301183 if (NULL == pAdapter)
1184 {
1185 hddLog(VOS_TRACE_LEVEL_ERROR,
1186 "%s: Invalid context, pAdapter", __func__);
1187 return VOS_STATUS_E_FAULT;
1188 }
1189
1190 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1191
1192 valid = wlan_hdd_validate_context(pHddCtx);
1193 if (0 != valid)
1194 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301195 return VOS_STATUS_E_FAULT;
1196 }
1197
1198 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1199 if (NULL == pHddStaCtx)
1200 {
1201 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1202 return VOS_STATUS_E_FAULT;
1203 }
1204
1205 init_completion(&context.completion);
1206 context.pAdapter = pAdapter;
1207 context.magic = SNR_CONTEXT_MAGIC;
1208
1209 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1210 pHddStaCtx->conn_info.staId[ 0 ],
1211 pHddStaCtx->conn_info.bssId,
1212 &context);
1213 if (eHAL_STATUS_SUCCESS != hstatus)
1214 {
1215 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1216 __func__);
1217 /* we'll returned a cached value below */
1218 }
1219 else
1220 {
1221 /* request was sent -- wait for the response */
1222 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1223 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301224 if (lrc <= 0)
1225 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001226 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301227 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301228 /* we'll now returned a cached value below */
1229 }
1230 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001231
1232 /* either we never sent a request, we sent a request and received a
1233 response or we sent a request and timed out. if we never sent a
1234 request or if we sent a request and got a response, we want to
1235 clear the magic out of paranoia. if we timed out there is a
1236 race condition such that the callback function could be
1237 executing at the same time we are. of primary concern is if the
1238 callback function had already verified the "magic" but had not
1239 yet set the completion variable when a timeout occurred. we
1240 serialize these activities by invalidating the magic while
1241 holding a shared spinlock which will cause us to block if the
1242 callback is currently executing */
1243 spin_lock(&hdd_context_lock);
1244 context.magic = 0;
1245 spin_unlock(&hdd_context_lock);
1246
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301247 *snr = pAdapter->snr;
1248
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301249 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301250 return VOS_STATUS_SUCCESS;
1251}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301252
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001253#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001254
1255static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1256{
1257 struct statsContext *pStatsContext;
1258 hdd_adapter_t *pAdapter;
1259 if (ioctl_debug)
1260 {
1261 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1262 __func__, (int)rssi, (int)staId, pContext);
1263 }
1264
1265 if (NULL == pContext)
1266 {
1267 hddLog(VOS_TRACE_LEVEL_ERROR,
1268 "%s: Bad param, pContext [%p]",
1269 __func__, pContext);
1270 return;
1271 }
1272
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001273 pStatsContext = pContext;
1274 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001275
1276 /* there is a race condition that exists between this callback
1277 function and the caller since the caller could time out either
1278 before or while this code is executing. we use a spinlock to
1279 serialize these actions */
1280 spin_lock(&hdd_context_lock);
1281
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001282 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1283 {
1284 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001285 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001286 hddLog(VOS_TRACE_LEVEL_WARN,
1287 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1288 __func__, pAdapter, pStatsContext->magic);
1289 if (ioctl_debug)
1290 {
1291 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1292 __func__, pAdapter, pStatsContext->magic);
1293 }
1294 return;
1295 }
1296
Jeff Johnson72a40512013-12-19 10:14:15 -08001297 /* context is valid so caller is still waiting */
1298
1299 /* paranoia: invalidate the magic */
1300 pStatsContext->magic = 0;
1301
Sachin Ahujaa082b672015-10-05 19:51:31 +05301302 /* copy over the rssi.FW will return RSSI as -100
1303 * if there are no samples to calculate the average
1304 * RSSI
1305 */
1306 if (rssi != -100)
1307 pAdapter->rssi = rssi;
1308
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301309 if (pAdapter->rssi > 0)
1310 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001311 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001312 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001313
1314 /* serialization is complete */
1315 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001316}
1317
1318
1319
1320VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1321{
1322 struct statsContext context;
1323 hdd_context_t *pHddCtx = NULL;
1324 hdd_station_ctx_t *pHddStaCtx = NULL;
1325 eHalStatus hstatus;
1326 long lrc;
1327
1328 if (NULL == pAdapter)
1329 {
1330 hddLog(VOS_TRACE_LEVEL_WARN,
1331 "%s: Invalid context, pAdapter", __func__);
1332 return VOS_STATUS_E_FAULT;
1333 }
1334 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1335 {
1336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1337 /* return a cached value */
1338 *rssi_value = pAdapter->rssi;
1339 return VOS_STATUS_SUCCESS;
1340 }
1341
1342 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1343 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1344
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301345 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001346 {
1347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1348 /* return a cached value */
1349 *rssi_value = 0;
1350 return VOS_STATUS_SUCCESS;
1351 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301352
1353 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1354 {
1355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1356 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1357 *rssi_value = pAdapter->rssi;
1358 return VOS_STATUS_SUCCESS;
1359 }
1360
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001361 init_completion(&context.completion);
1362 context.pAdapter = pAdapter;
1363 context.magic = RSSI_CONTEXT_MAGIC;
1364
1365 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1366 pHddStaCtx->conn_info.staId[ 0 ],
1367 pHddStaCtx->conn_info.bssId,
1368 &context, pHddCtx->pvosContext);
1369 if (eHAL_STATUS_SUCCESS != hstatus)
1370 {
1371 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1372 __func__);
1373 /* we'll returned a cached value below */
1374 }
1375 else
1376 {
1377 /* request was sent -- wait for the response */
1378 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1379 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001380 if (lrc <= 0)
1381 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001382 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001383 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001384 /* we'll now returned a cached value below */
1385 }
1386 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001387
1388 /* either we never sent a request, we sent a request and received a
1389 response or we sent a request and timed out. if we never sent a
1390 request or if we sent a request and got a response, we want to
1391 clear the magic out of paranoia. if we timed out there is a
1392 race condition such that the callback function could be
1393 executing at the same time we are. of primary concern is if the
1394 callback function had already verified the "magic" but had not
1395 yet set the completion variable when a timeout occurred. we
1396 serialize these activities by invalidating the magic while
1397 holding a shared spinlock which will cause us to block if the
1398 callback is currently executing */
1399 spin_lock(&hdd_context_lock);
1400 context.magic = 0;
1401 spin_unlock(&hdd_context_lock);
1402
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001403 *rssi_value = pAdapter->rssi;
1404
1405 return VOS_STATUS_SUCCESS;
1406}
1407#endif
1408
1409
Jeff Johnson295189b2012-06-20 16:38:30 -07001410void hdd_StatisticsCB( void *pStats, void *pContext )
1411{
1412 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1413 hdd_stats_t *pStatsCache = NULL;
1414 hdd_wext_state_t *pWextState;
1415 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1416
1417 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1418 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1419 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1420 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1421 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1422 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1423
1424 if (pAdapter!= NULL)
1425 pStatsCache = &pAdapter->hdd_stats;
1426
1427
1428 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1429 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1430 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1431 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1432 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1433 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1434
1435 if (pStatsCache!=NULL)
1436 {
1437 // and copy the stats into the cache we keep in the adapter instance structure
1438 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1439 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1440 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1441 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1442 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1443 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1444 }
1445
1446 if(pAdapter)
1447 {
1448 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1449 if(pWextState)
1450 {
1451 vos_status = vos_event_set(&pWextState->vosevent);
1452 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1453 {
1454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001455 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 return;
1457 }
1458 }
1459 }
1460}
1461
1462void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1463{
1464 v_CONTEXT_t pVosContext;
1465 hdd_context_t *pHddCtx;
1466 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1467#if 0
1468 hdd_wext_state_t *pWextState;
1469 v_U32_t roamId;
1470#endif
1471
1472 ENTER();
1473
1474 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1475
1476 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1477 if (NULL == pHddCtx)
1478 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001479 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 return;
1481 }
1482#if 0
1483 pWextState = pAdapter->pWextState;
1484#endif
1485
1486 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1487 {
1488 //TODO Verify is this is really used. If yes need to fix it.
1489 hdd_reconnect_all_adapters( pHddCtx );
1490#if 0
1491 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1492 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1493 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1494
1495 if(VOS_STATUS_SUCCESS == vosStatus)
1496 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1497 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1498
1499 sme_RoamConnect(halHandle,
1500 pAdapter->sessionId, &(pWextState->roamProfile),
1501 &roamId);
1502#endif
1503 }
1504
1505 EXIT();
1506
1507}
1508
1509void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1510{
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1512
1513 /* clear WPA/RSN/WSC IE information in the profile */
1514 pWextState->roamProfile.nWPAReqIELength = 0;
1515 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1516 pWextState->roamProfile.nRSNReqIELength = 0;
1517 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1518
Chet Lanctot186b5732013-03-18 10:26:30 -07001519#ifdef FEATURE_WLAN_WAPI
1520 pWextState->roamProfile.nWAPIReqIELength = 0;
1521 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1522#endif
1523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001525 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301527 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1529 pWextState->roamProfile.nAddIEAssocLength = 0;
1530
1531 pWextState->roamProfile.EncryptionType.numEntries = 1;
1532 pWextState->roamProfile.EncryptionType.encryptionType[0]
1533 = eCSR_ENCRYPT_TYPE_NONE;
1534
1535 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1536 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1537 = eCSR_ENCRYPT_TYPE_NONE;
1538
1539 pWextState->roamProfile.AuthType.numEntries = 1;
1540 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1541
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
2568 switch ( elementId )
2569 {
2570 case IE_EID_VENDOR:
2571 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002572 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302573 ret = -EINVAL;
2574 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002576
2577 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2578 {
2579 v_U16_t curGenIELen = pWextState->genIE.length;
2580 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2581 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2582
2583 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2584 {
2585 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002586 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302588 ret = -EINVAL;
2589 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 }
2591 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2592 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2593 pWextState->genIE.length += eLen + 2;
2594 }
2595 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2596 {
2597 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302598 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2599 {
2600 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2601 "Need bigger buffer space");
2602 ret = -EINVAL;
2603 VOS_ASSERT(0);
2604 goto exit;
2605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2607 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2608 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2609 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2610 }
2611 else /* any vendorId except WPA IE should be accumulated to genIE */
2612 {
2613 v_U16_t curGenIELen = pWextState->genIE.length;
2614 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2615 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2616
2617 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2618 {
2619 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002620 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302622 ret = -ENOMEM;
2623 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 }
2625 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2626 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2627 pWextState->genIE.length += eLen + 2;
2628 }
2629 break;
2630 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002631 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302632 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2633 {
2634 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2635 "Need bigger buffer space");
2636 ret = -EINVAL;
2637 VOS_ASSERT(0);
2638 goto exit;
2639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2641 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2642 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2643 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2644 break;
2645
2646 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002647 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302648 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 }
2650 genie += eLen;
2651 remLen -= eLen;
2652 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302653
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302654exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002656 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302657 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002658}
2659
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302660static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 struct iw_request_info *info,
2662 union iwreq_data *wrqu,
2663 char *extra)
2664{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302665 int ret;
2666
2667 vos_ssr_protect(__func__);
2668 ret = __iw_set_genie(dev, info, wrqu, extra);
2669 vos_ssr_unprotect(__func__);
2670
2671 return ret;
2672}
2673
2674static int __iw_get_genie(struct net_device *dev,
2675 struct iw_request_info *info,
2676 union iwreq_data *wrqu,
2677 char *extra)
2678{
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302680 hdd_context_t *pHddCtx;
2681 hdd_adapter_t *pAdapter;
2682 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 eHalStatus status;
2684 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2685 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2686
2687 ENTER();
2688
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302689 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2690 if (NULL == pAdapter)
2691 {
2692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2693 "%s: Adapter is NULL",__func__);
2694 return -EINVAL;
2695 }
2696 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2697 status = wlan_hdd_validate_context(pHddCtx);
2698 if (0 != status)
2699 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302700 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 }
2702
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302704 if (NULL == pWextState)
2705 {
2706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2707 "%s: pWextState is NULL",__func__);
2708 return -EINVAL;
2709 }
2710
2711 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2712 if (NULL == pHddStaCtx)
2713 {
2714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2715 "%s: STA Context is NULL",__func__);
2716 return -EINVAL;
2717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002718
2719 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2720 {
2721 return -ENXIO;
2722 }
2723
2724 // Return something ONLY if we are associated with an RSN or WPA network
2725 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2726 pWextState->roamProfile.negotiatedAuthType))
2727 {
2728 return -ENXIO;
2729 }
2730
2731 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2732 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2733 pAdapter->sessionId,
2734 &length,
2735 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302736 if (eHAL_STATUS_SUCCESS != status) {
2737 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002738 return -EFAULT;
2739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002740
Manjeet Singh715d47e2016-08-02 19:08:02 +05302741 wrqu->data.length = length;
2742 if (length > DOT11F_IE_RSN_MAX_LEN) {
2743 hddLog(LOGE,
2744 FL("invalid buffer length length:%d"), length);
2745 return -E2BIG;
2746 }
2747
2748 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2749
2750 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002751
2752 EXIT();
2753
2754 return 0;
2755}
2756
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302757static int iw_get_genie(struct net_device *dev,
2758 struct iw_request_info *info,
2759 union iwreq_data *wrqu,
2760 char *extra)
2761{
2762 int ret;
2763
2764 vos_ssr_protect(__func__);
2765 ret = __iw_get_genie(dev, info, wrqu, extra);
2766 vos_ssr_unprotect(__func__);
2767
2768 return ret;
2769}
2770
2771
2772static int __iw_get_encode(struct net_device *dev,
2773 struct iw_request_info *info,
2774 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002775{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302776 hdd_adapter_t *pAdapter;
2777 hdd_context_t *pHddCtx;
2778 hdd_wext_state_t *pWextState;
2779 tCsrRoamProfile *pRoamProfile;
2780 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002782
2783 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302784 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2785 if (NULL == pAdapter)
2786 {
2787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2788 "%s: Adapter is NULL",__func__);
2789 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 }
2791
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302792 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2793 ret = wlan_hdd_validate_context(pHddCtx);
2794 if (0 != ret)
2795 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302796 return ret;
2797 }
2798 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2799 if (NULL == pWextState)
2800 {
2801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2802 "%s: pWextState is NULL",__func__);
2803 return -EINVAL;
2804 }
2805
2806 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 keyId = pRoamProfile->Keys.defaultIndex;
2808
2809 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2810 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002811 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 return -EINVAL;
2813 }
2814
2815 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2816 {
2817 dwrq->flags |= IW_ENCODE_ENABLED;
2818 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2819 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2820
2821 dwrq->flags |= (keyId + 1);
2822
2823 }
2824 else
2825 {
2826 dwrq->flags |= IW_ENCODE_DISABLED;
2827 }
2828
2829 for(i=0; i < MAX_WEP_KEYS; i++)
2830 {
2831 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2832 {
2833 continue;
2834 }
2835 else
2836 {
2837 break;
2838 }
2839 }
2840
2841 if(MAX_WEP_KEYS == i)
2842 {
2843 dwrq->flags |= IW_ENCODE_NOKEY;
2844 }
2845
2846 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2847
2848 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2849 {
2850 dwrq->flags |= IW_ENCODE_OPEN;
2851 }
2852 else
2853 {
2854 dwrq->flags |= IW_ENCODE_RESTRICTED;
2855 }
2856 EXIT();
2857 return 0;
2858}
2859
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302860static int iw_get_encode(struct net_device *dev,
2861 struct iw_request_info *info,
2862 struct iw_point *dwrq, char *extra)
2863{
2864 int ret;
2865
2866 vos_ssr_protect(__func__);
2867 ret = __iw_get_encode(dev, info, dwrq, extra);
2868 vos_ssr_unprotect(__func__);
2869
2870 return ret;
2871}
2872
Jeff Johnson295189b2012-06-20 16:38:30 -07002873#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2874#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2875
2876
2877/*
2878 * This function sends a single 'key' to LIM at all time.
2879 */
2880
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302881static int __iw_get_rts_threshold(struct net_device *dev,
2882 struct iw_request_info *info,
2883 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002884{
2885 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2886 v_U32_t status = 0;
2887
2888 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2889
2890 return status;
2891}
2892
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302893static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 struct iw_request_info *info,
2895 union iwreq_data *wrqu, char *extra)
2896{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302897 int ret;
2898
2899 vos_ssr_protect(__func__);
2900 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2901 vos_ssr_unprotect(__func__);
2902
2903 return ret;
2904}
2905
2906static int __iw_set_rts_threshold(struct net_device *dev,
2907 struct iw_request_info *info,
2908 union iwreq_data *wrqu, char *extra)
2909{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302910 hdd_adapter_t *pAdapter;
2911 hdd_context_t *pHddCtx;
2912 tHalHandle hHal;
2913 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002914
2915 ENTER();
2916
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302917 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2918 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002919 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2921 "%s: Adapter is NULL",__func__);
2922 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002923 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302924
2925 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2926 ret = wlan_hdd_validate_context(pHddCtx);
2927 if (0 != ret)
2928 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 return ret;
2930 }
2931
2932 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2933 if (NULL == hHal)
2934 {
2935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2936 "%s: Hal Context is NULL",__func__);
2937 return -EINVAL;
2938 }
2939
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2941 {
2942 return -EINVAL;
2943 }
2944
2945 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2946 {
c_hpothub8245442013-11-20 23:41:09 +05302947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2948 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 return -EIO;
2950 }
2951
2952 EXIT();
2953
2954 return 0;
2955}
2956
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302957static int iw_set_rts_threshold(struct net_device *dev,
2958 struct iw_request_info *info,
2959 union iwreq_data *wrqu, char *extra)
2960{
2961 int ret;
2962
2963 vos_ssr_protect(__func__);
2964 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2965 vos_ssr_unprotect(__func__);
2966
2967 return ret;
2968}
2969
2970static int __iw_get_frag_threshold(struct net_device *dev,
2971 struct iw_request_info *info,
2972 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002973{
2974 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2975 v_U32_t status = 0;
2976
2977 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2978
2979 return status;
2980}
2981
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302982static int iw_get_frag_threshold(struct net_device *dev,
2983 struct iw_request_info *info,
2984 union iwreq_data *wrqu, char *extra)
2985{
2986 int ret;
2987
2988 vos_ssr_protect(__func__);
2989 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2990 vos_ssr_unprotect(__func__);
2991
2992 return ret;
2993}
2994
2995static int __iw_set_frag_threshold(struct net_device *dev,
2996 struct iw_request_info *info,
2997 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002998{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302999 hdd_adapter_t *pAdapter;
3000 hdd_context_t *pHddCtx;
3001 tHalHandle hHal;
3002 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
3004 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303005 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3006 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003007 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3009 "%s: Adapter is NULL",__func__);
3010 return -EINVAL;
3011 }
3012
3013 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3014 ret = wlan_hdd_validate_context(pHddCtx);
3015 if (0 != ret)
3016 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303017 return ret;
3018 }
3019
3020 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3021 if (NULL == hHal)
3022 {
3023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3024 "%s: Hal Context is NULL",__func__);
3025 return -EINVAL;
3026 }
3027
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3029 {
3030 return -EINVAL;
3031 }
3032
3033 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3034 {
c_hpothub8245442013-11-20 23:41:09 +05303035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3036 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 return -EIO;
3038 }
3039
3040 EXIT();
3041
3042 return 0;
3043}
3044
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303045static int iw_set_frag_threshold(struct net_device *dev,
3046 struct iw_request_info *info,
3047 union iwreq_data *wrqu, char *extra)
3048{
3049 int ret;
3050
3051 vos_ssr_protect(__func__);
3052 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3053 vos_ssr_unprotect(__func__);
3054
3055 return ret;
3056}
3057
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303058static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 struct iw_request_info *info,
3060 union iwreq_data *wrqu, char *extra)
3061{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303062 hdd_adapter_t *pAdapter;
3063 hdd_context_t *pHddCtx;
3064 int ret = 0;
3065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303067 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3068 if (NULL == pAdapter)
3069 {
3070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3071 "%s: Adapter is NULL",__func__);
3072 return -EINVAL;
3073 }
3074 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3075 ret = wlan_hdd_validate_context(pHddCtx);
3076 if (0 != ret)
3077 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303078 return ret;
3079 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303080
3081 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 return -EOPNOTSUPP;
3083}
3084
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303085static int iw_get_power_mode(struct net_device *dev,
3086 struct iw_request_info *info,
3087 union iwreq_data *wrqu, char *extra)
3088{
3089 int ret;
3090
3091 vos_ssr_protect(__func__);
3092 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3093 vos_ssr_unprotect(__func__);
3094
3095 return ret;
3096}
3097static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 struct iw_request_info *info,
3099 union iwreq_data *wrqu, char *extra)
3100{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303101 hdd_adapter_t *pAdapter;
3102 hdd_context_t *pHddCtx;
3103 int ret = 0;
3104
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303106 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3107 if (NULL == pAdapter)
3108 {
3109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3110 "%s: Adapter is NULL",__func__);
3111 return -EINVAL;
3112 }
3113 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3114 ret = wlan_hdd_validate_context(pHddCtx);
3115 if (0 != ret)
3116 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303117 return ret;
3118 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303119
3120 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 return -EOPNOTSUPP;
3122}
3123
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303124static int iw_set_power_mode(struct net_device *dev,
3125 struct iw_request_info *info,
3126 union iwreq_data *wrqu, char *extra)
3127{
3128 int ret;
3129
3130 vos_ssr_protect(__func__);
3131 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3132 vos_ssr_unprotect(__func__);
3133
3134 return ret;
3135}
3136
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303137static int __iw_get_range(struct net_device *dev,
3138 struct iw_request_info *info,
3139 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003140{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303141 hdd_adapter_t *pAdapter;
3142 tHalHandle hHal;
3143 hdd_context_t *pHddCtx;
3144 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 struct iw_range *range = (struct iw_range *) extra;
3146
3147 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3148
3149 v_U32_t num_channels = sizeof(channels);
3150 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3151 v_U32_t a_len;
3152 v_U32_t b_len;
3153 v_U32_t active_phy_mode = 0;
3154 v_U8_t index = 0, i;
3155
3156 ENTER();
3157
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303158 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3159 if (NULL == pAdapter)
3160 {
3161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3162 "%s: pAdapter is NULL", __func__);
3163 return -EINVAL;
3164 }
3165 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3166 ret = wlan_hdd_validate_context(pHddCtx);
3167 if (0 != ret)
3168 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303169 return ret;
3170 }
3171 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3172 if (NULL == hHal)
3173 {
3174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3175 "%s: pAdapter is NULL", __func__);
3176 return -EINVAL;
3177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 wrqu->data.length = sizeof(struct iw_range);
3179 memset(range, 0, sizeof(struct iw_range));
3180
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 /*Get the phy mode*/
3182 if (ccmCfgGetInt(hHal,
3183 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3184 {
3185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003186 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003187
3188 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3189 {
3190 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003191 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 if (ccmCfgGetStr(hHal,
3193 WNI_CFG_SUPPORTED_RATES_11A,
3194 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3195 {
3196 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3197 {
3198 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3199 }
3200 for (i = 0; i < a_len; i++)
3201 {
3202 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3203 }
3204 range->num_bitrates = a_len;
3205 }
3206 else
3207 {
3208 return -EIO;
3209 }
3210 }
3211 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3212 {
3213 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003214 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 if (ccmCfgGetStr(hHal,
3216 WNI_CFG_SUPPORTED_RATES_11B,
3217 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3218 {
3219 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3220 {
3221 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3222 }
3223 for (i = 0; i < b_len; i++)
3224 {
3225 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3226 }
3227 range->num_bitrates = b_len;
3228 }
3229 else
3230 {
3231 return -EIO;
3232 }
3233 }
3234 }
3235
3236 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3237 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3238 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3239
3240 range->encoding_size[0] = 5;
3241 range->encoding_size[1] = 13;
3242 range->num_encoding_sizes = 2;
3243 range->max_encoding_tokens = MAX_WEP_KEYS;
3244
3245 // we support through Wireless Extensions 22
3246 range->we_version_compiled = WIRELESS_EXT;
3247 range->we_version_source = 22;
3248
3249 /*Supported Channels and Frequencies*/
3250 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3251 {
c_hpothub8245442013-11-20 23:41:09 +05303252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3253 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 return -EIO;
3255 }
3256 if (num_channels > IW_MAX_FREQUENCIES)
3257 {
3258 num_channels = IW_MAX_FREQUENCIES;
3259 }
3260
3261 range->num_channels = num_channels;
3262 range->num_frequency = num_channels;
3263
3264 for (index=0; index < num_channels; index++)
3265 {
3266 v_U32_t frq_indx = 0;
3267
3268 range->freq[index].i = channels[index];
3269 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3270 {
3271 if(channels[index] == freq_chan_map[frq_indx].chan)
3272 {
3273 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3274 range->freq[index].e = 1;
3275 break;
3276 }
3277 frq_indx++;
3278 }
3279 }
3280
3281 /* Event capability (kernel + driver) */
3282 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3283 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3284 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3285 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3286
3287 /*Encryption capability*/
3288 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3289 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3290
3291 /* Txpower capability */
3292 range->txpower_capa = IW_TXPOW_MWATT;
3293
3294 /*Scanning capability*/
3295 #if WIRELESS_EXT >= 22
3296 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3297 #endif
3298
3299 EXIT();
3300 return 0;
3301}
3302
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303303static int iw_get_range(struct net_device *dev,
3304 struct iw_request_info *info,
3305 union iwreq_data *wrqu, char *extra)
3306{
3307 int ret;
3308
3309 vos_ssr_protect(__func__);
3310 ret = __iw_get_range(dev, info, wrqu, extra);
3311 vos_ssr_unprotect(__func__);
3312
3313 return ret;
3314}
3315
Jeff Johnson295189b2012-06-20 16:38:30 -07003316/* Callback function registered with PMC to know status of PMC request */
3317static void iw_power_callback_fn (void *pContext, eHalStatus status)
3318{
3319 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003320
3321 if (NULL == pContext)
3322 {
3323 hddLog(VOS_TRACE_LEVEL_ERROR,
3324 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003325 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 return;
3327 }
3328
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330
Jeff Johnson72a40512013-12-19 10:14:15 -08003331 /* there is a race condition that exists between this callback
3332 function and the caller since the caller could time out either
3333 before or while this code is executing. we use a spinlock to
3334 serialize these actions */
3335 spin_lock(&hdd_context_lock);
3336
3337 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 {
3339 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003340 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003342 "%s: Invalid context, magic [%08x]",
3343 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345 if (ioctl_debug)
3346 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003347 pr_info("%s: Invalid context, magic [%08x]\n",
3348 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 }
3350 return;
3351 }
3352
Jeff Johnson72a40512013-12-19 10:14:15 -08003353 /* context is valid so caller is still waiting */
3354
3355 /* paranoia: invalidate the magic */
3356 pStatsContext->magic = 0;
3357
3358 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003360
3361 /* serialization is complete */
3362 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363}
3364
3365/* Callback function for tx per hit */
3366void hdd_tx_per_hit_cb (void *pCallbackContext)
3367{
3368 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3369 unsigned char tx_fail[16];
3370 union iwreq_data wrqu;
3371
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303372 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003374 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 return;
3376 }
3377 memset(&wrqu, 0, sizeof(wrqu));
3378 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3379 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3380}
3381
3382void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3383{
3384 struct statsContext *pStatsContext;
3385 tCsrGlobalClassAStatsInfo *pClassAStats;
3386 hdd_adapter_t *pAdapter;
3387
3388 if (ioctl_debug)
3389 {
3390 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003391 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 }
3393
3394 if ((NULL == pStats) || (NULL == pContext))
3395 {
3396 hddLog(VOS_TRACE_LEVEL_ERROR,
3397 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003398 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 return;
3400 }
3401
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 pClassAStats = pStats;
3403 pStatsContext = pContext;
3404 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003405
3406 /* there is a race condition that exists between this callback
3407 function and the caller since the caller could time out either
3408 before or while this code is executing. we use a spinlock to
3409 serialize these actions */
3410 spin_lock(&hdd_context_lock);
3411
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3413 {
3414 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003415 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 hddLog(VOS_TRACE_LEVEL_WARN,
3417 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003418 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 if (ioctl_debug)
3420 {
3421 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003422 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 }
3424 return;
3425 }
3426
Jeff Johnson72a40512013-12-19 10:14:15 -08003427 /* context is valid so caller is still waiting */
3428
3429 /* paranoia: invalidate the magic */
3430 pStatsContext->magic = 0;
3431
3432 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3434
Jeff Johnson72a40512013-12-19 10:14:15 -08003435 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003437
3438 /* serialization is complete */
3439 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003440}
3441
3442VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3443{
3444 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3445 eHalStatus hstatus;
3446 long lrc;
3447 struct statsContext context;
3448
3449 if (NULL == pAdapter)
3450 {
3451 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3452 return VOS_STATUS_E_FAULT;
3453 }
3454 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3455 {
3456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3457 return VOS_STATUS_SUCCESS;
3458 }
3459
3460 /* we are connected
3461 prepare our callback context */
3462 init_completion(&context.completion);
3463 context.pAdapter = pAdapter;
3464 context.magic = STATS_CONTEXT_MAGIC;
3465 /* query only for Class A statistics (which include link speed) */
3466 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3467 eCSR_HDD,
3468 SME_GLOBAL_CLASSA_STATS,
3469 hdd_GetClassA_statisticsCB,
3470 0, // not periodic
3471 FALSE, //non-cached results
3472 pHddStaCtx->conn_info.staId[0],
3473 &context);
3474 if (eHAL_STATUS_SUCCESS != hstatus)
3475 {
3476 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003477 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003478 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 /* we'll returned a cached value below */
3480 }
3481 else
3482 {
3483 /* request was sent -- wait for the response */
3484 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3485 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 if (lrc <= 0)
3487 {
3488 hddLog(VOS_TRACE_LEVEL_ERROR,
3489 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003490 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 }
3492 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003493
3494 /* either we never sent a request, we sent a request and received a
3495 response or we sent a request and timed out. if we never sent a
3496 request or if we sent a request and got a response, we want to
3497 clear the magic out of paranoia. if we timed out there is a
3498 race condition such that the callback function could be
3499 executing at the same time we are. of primary concern is if the
3500 callback function had already verified the "magic" but had not
3501 yet set the completion variable when a timeout occurred. we
3502 serialize these activities by invalidating the magic while
3503 holding a shared spinlock which will cause us to block if the
3504 callback is currently executing */
3505 spin_lock(&hdd_context_lock);
3506 context.magic = 0;
3507 spin_unlock(&hdd_context_lock);
3508
3509 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 return VOS_STATUS_SUCCESS;
3511}
3512
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003513static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3514{
3515 struct statsContext *pStatsContext;
3516 tCsrSummaryStatsInfo *pSummaryStats;
3517 tCsrGlobalClassAStatsInfo *pClassAStats;
3518 hdd_adapter_t *pAdapter;
3519
3520 if (ioctl_debug)
3521 {
3522 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003523 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003524 }
3525
3526 if ((NULL == pStats) || (NULL == pContext))
3527 {
3528 hddLog(VOS_TRACE_LEVEL_ERROR,
3529 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003530 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003531 return;
3532 }
3533
Jeff Johnson72a40512013-12-19 10:14:15 -08003534 /* there is a race condition that exists between this callback
3535 function and the caller since the caller could time out either
3536 before or while this code is executing. we use a spinlock to
3537 serialize these actions */
3538 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003539
3540 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3541 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3542 pStatsContext = pContext;
3543 pAdapter = pStatsContext->pAdapter;
3544 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3545 {
3546 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003547 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003548 hddLog(VOS_TRACE_LEVEL_WARN,
3549 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003550 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003551 if (ioctl_debug)
3552 {
3553 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003554 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003555 }
3556 return;
3557 }
3558
Jeff Johnson72a40512013-12-19 10:14:15 -08003559 /* context is valid so caller is still waiting */
3560
3561 /* paranoia: invalidate the magic */
3562 pStatsContext->magic = 0;
3563
3564 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003565 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3566 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3567
Jeff Johnson72a40512013-12-19 10:14:15 -08003568 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003569 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003570
3571 /* serialization is complete */
3572 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003573}
3574
3575VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3576{
3577 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3578 eHalStatus hstatus;
3579 long lrc;
3580 struct statsContext context;
3581
3582 if (NULL == pAdapter)
3583 {
3584 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3585 return VOS_STATUS_SUCCESS;
3586 }
3587
3588 /* we are connected
3589 prepare our callback context */
3590 init_completion(&context.completion);
3591 context.pAdapter = pAdapter;
3592 context.magic = STATS_CONTEXT_MAGIC;
3593
3594 /* query only for Summary & Class A statistics */
3595 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3596 eCSR_HDD,
3597 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303598 SME_GLOBAL_CLASSA_STATS |
3599 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003600 hdd_get_station_statisticsCB,
3601 0, // not periodic
3602 FALSE, //non-cached results
3603 pHddStaCtx->conn_info.staId[0],
3604 &context);
3605 if (eHAL_STATUS_SUCCESS != hstatus)
3606 {
3607 hddLog(VOS_TRACE_LEVEL_ERROR,
3608 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003609 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003610 /* we'll return with cached values */
3611 }
3612 else
3613 {
3614 /* request was sent -- wait for the response */
3615 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3616 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003617
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003618 if (lrc <= 0)
3619 {
3620 hddLog(VOS_TRACE_LEVEL_ERROR,
3621 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003622 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003623 }
3624 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003625
3626 /* either we never sent a request, we sent a request and received a
3627 response or we sent a request and timed out. if we never sent a
3628 request or if we sent a request and got a response, we want to
3629 clear the magic out of paranoia. if we timed out there is a
3630 race condition such that the callback function could be
3631 executing at the same time we are. of primary concern is if the
3632 callback function had already verified the "magic" but had not
3633 yet set the completion variable when a timeout occurred. we
3634 serialize these activities by invalidating the magic while
3635 holding a shared spinlock which will cause us to block if the
3636 callback is currently executing */
3637 spin_lock(&hdd_context_lock);
3638 context.magic = 0;
3639 spin_unlock(&hdd_context_lock);
3640
3641 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003642 return VOS_STATUS_SUCCESS;
3643}
3644
3645
Jeff Johnson295189b2012-06-20 16:38:30 -07003646/*
3647 * Support for the LINKSPEED private command
3648 * Per the WiFi framework the response must be of the form
3649 * "LinkSpeed xx"
3650 */
3651static int iw_get_linkspeed(struct net_device *dev,
3652 struct iw_request_info *info,
3653 union iwreq_data *wrqu, char *extra)
3654{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303655 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303656 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303658 int len = sizeof(v_U32_t) + 1;
3659 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303660 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303661 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303662 int rc, valid = 0;
3663
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303664 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303665 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3666 if (NULL == pAdapter)
3667 {
3668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3669 "%s: Adapter is NULL",__func__);
3670 return -EINVAL;
3671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003672
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303674 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303675 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003676 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303677 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003678 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303679 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3680 if (NULL == pHddStaCtx)
3681 {
3682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3683 "%s: STA Context is NULL",__func__);
3684 return -EINVAL;
3685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3687 {
3688 /* we are not connected so we don't have a classAstats */
3689 link_speed = 0;
3690 }
3691 else
3692 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303693 status = wlan_hdd_get_classAstats(pAdapter);
3694
3695 if (!VOS_IS_STATUS_SUCCESS(status ))
3696 {
3697 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3698 return -EINVAL;
3699 }
3700
3701 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3702 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3703 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3704 &link_speed);
3705
3706 link_speed = link_speed / 10;
3707
3708 if (0 == link_speed)
3709 {
3710 /* The linkspeed returned by HAL is in units of 500kbps.
3711 * converting it to mbps.
3712 * This is required to support legacy firmware which does
3713 * not return link capacity.
3714 */
3715 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3716 }
3717
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 }
3719
3720 wrqu->data.length = len;
3721 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003722 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 if ((rc < 0) || (rc >= len))
3724 {
3725 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303726 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 return -EIO;
3728 }
3729
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303730 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003732 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003733}
3734
Arif Hussain695279c2014-03-24 14:06:07 -07003735/*
3736 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3737 *
3738 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303739static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003740 struct iw_request_info *info,
3741 union iwreq_data *wrqu, char *extra)
3742{
3743 int rc;
3744
3745 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3746
3747 if (rc < 0)
3748 return rc;
3749
3750 /* a value is being successfully returned */
3751 return 0;
3752}
Jeff Johnson295189b2012-06-20 16:38:30 -07003753
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303754static int iw_get_linkspeed_priv(struct net_device *dev,
3755 struct iw_request_info *info,
3756 union iwreq_data *wrqu, char *extra)
3757{
3758 int ret;
3759
3760 vos_ssr_protect(__func__);
3761 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3762 vos_ssr_unprotect(__func__);
3763
3764 return ret;
3765}
3766
Jeff Johnson295189b2012-06-20 16:38:30 -07003767/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303768 * Support for the RSSI & RSSI-APPROX private commands
3769 * Per the WiFi framework the response must be of the form
3770 * "<ssid> rssi <xx>"
3771 * unless we are not associated, in which case the response is
3772 * "OK"
3773 */
3774static int iw_get_rssi(struct net_device *dev,
3775 struct iw_request_info *info,
3776 union iwreq_data *wrqu, char *extra)
3777{
3778 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3779 char *cmd = extra;
3780 int len = wrqu->data.length;
3781 v_S7_t s7Rssi = 0;
3782 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3783 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3784 VOS_STATUS vosStatus;
3785 int rc;
3786
3787 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3788 (0 == ssidlen) || (ssidlen >= len))
3789 {
3790 /* we are not connected or our SSID is too long
3791 so we cannot report an rssi */
3792 rc = scnprintf(cmd, len, "OK");
3793 }
3794 else
3795 {
3796 /* we are connected with a valid SSID
3797 so we can write the SSID into the return buffer
3798 (note that it is not NUL-terminated) */
3799 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3800
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303801 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303802 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3803
3804 if (VOS_STATUS_SUCCESS == vosStatus)
3805 {
3806 /* append the rssi to the ssid in the format required by
3807 the WiFI Framework */
3808 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3809 rc += ssidlen;
3810 }
3811 else
3812 {
3813 rc = -1;
3814 }
3815 }
3816
3817 /* verify that we wrote a valid response */
3818 if ((rc < 0) || (rc >= len))
3819 {
3820 // encoding or length error?
3821 hddLog(VOS_TRACE_LEVEL_ERROR,
3822 "%s: Unable to encode RSSI, got [%s]",
3823 __func__, cmd);
3824 return -EIO;
3825 }
3826
3827 /* a value is being successfully returned */
3828 return rc;
3829}
3830
3831/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 * Support for SoftAP channel range private command
3833 */
3834static int iw_softap_set_channel_range( struct net_device *dev,
3835 int startChannel,
3836 int endChannel,
3837 int band)
3838{
Jeff Johnson43971f52012-07-17 12:26:56 -07003839 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 int ret = 0;
3841 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3842 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003843 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3844
Jeff Johnson295189b2012-06-20 16:38:30 -07003845
3846 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3847 if (VOS_STATUS_SUCCESS != status)
3848 {
3849 ret = -EINVAL;
3850 }
Yathish9f22e662012-12-10 14:21:35 -08003851 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 return ret;
3853}
3854
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303855static uint8 chartohex(char c)
3856{
3857 uint8 val = 0;
3858 if (c >= '0' && c <= '9')
3859 val = c - '0';
3860 else if (c >= 'a' && c <= 'f')
3861 val = c - 'a' + 10;
3862 else if (c >= 'A' && c <= 'F')
3863 val = c - 'A' + 10;
3864 else
3865 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3866
3867 return val;
3868}
3869
3870uint8 getByte(char **buf)
3871{
3872 uint8 byte = 0;
3873 char *temp = *buf;
3874 byte = chartohex(*temp) * 16;
3875 temp++;
3876 byte += chartohex(*temp);
3877 temp++;
3878 *buf = temp;
3879 return byte;
3880}
3881
3882static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3883{
3884 tSir80211Header *macHeader;
3885 int i = 0, j = 0, length = 0;
3886 uint8 byte = 0;
3887 char *temp = pBuffer;
3888 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303889 char *pHeader;
3890 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303891
3892 macHeader = &pkt->macHeader;
3893
3894 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3895
3896 temp++;
3897
3898 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3899 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3900 pkt->encParams.keyParams.key[0].keyId);
3901
3902 for (i = 0; i< 16; i++) {
3903 pkt->encParams.keyParams.key[0].key[i]
3904 = getByte(&temp);
3905 }
3906
3907 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3908 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3909
3910 for (i = 0; i< 6; i++) {
3911 pkt->encParams.pn[i]
3912 = getByte(&temp);
3913 }
3914
3915 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3916 &pkt->encParams.pn[0], 6, 0);
3917
3918 for (i = 0, j= 5; i< 3; i++, j--) {
3919 byte = pkt->encParams.pn[i];
3920 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3921 pkt->encParams.pn[j] = byte;
3922 }
3923
3924 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303925 if (length > sizeof(tSir80211Header))
3926 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303927
Srinivas Dasari2382de62015-01-22 15:00:04 +05303928 pHeader = temp;
3929 vos_mem_zero(&header, sizeof(tSir80211Header));
3930 for (i = 0; i < length; i++) {
3931 *((uint8 *)&header + i) = getByte(&pHeader);
3932 }
3933
3934 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3935 (char *)&header, length, 0);
3936
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303937 byte = getByte(&temp);
3938
3939 macHeader->frameCtrl.protVer = byte & 0x3;
3940 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3941 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3942
3943 byte = getByte(&temp);
3944 macHeader->frameCtrl.toDS = (byte) & 0x1;
3945 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3946 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3947 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3948 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3949 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3950 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3951 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3952
3953 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3954 "macHeader->frameCtrl.type : %x "
3955 "macHeader->frameCtrl.subType : %x "
3956 "macHeader->frameCtrl.toDS : %x "
3957 "macHeader->frameCtrl.fromDS : %x "
3958 "macHeader->frameCtrl.moreFrag : %x "
3959 "macHeader->frameCtrl.retry : %x "
3960 "macHeader->frameCtrl.powerMgmt : %x "
3961 "macHeader->frameCtrl.MoreData : %x "
3962 "macHeader->frameCtrl.wep : %x "
3963 "macHeader->frameCtrl.order : %x "
3964 , macHeader->frameCtrl.protVer
3965 , macHeader->frameCtrl.type
3966 , macHeader->frameCtrl.subType
3967 , macHeader->frameCtrl.toDS
3968 , macHeader->frameCtrl.fromDS
3969 , macHeader->frameCtrl.moreFrag
3970 , macHeader->frameCtrl.retry
3971 , macHeader->frameCtrl.powerMgmt
3972 , macHeader->frameCtrl.moreData
3973 , macHeader->frameCtrl.wep
3974 , macHeader->frameCtrl.order);
3975
3976
3977 macHeader->usDurationId = getByte(&temp);
3978 macHeader->usDurationId += getByte(&temp) << 8;
3979
3980 macHeader->vA1[0] = getByte(&temp);
3981 macHeader->vA1[1] = getByte(&temp);
3982 macHeader->vA1[2] = getByte(&temp);
3983 macHeader->vA1[3] = getByte(&temp);
3984 macHeader->vA1[4] = getByte(&temp);
3985 macHeader->vA1[5] = getByte(&temp);
3986
3987 macHeader->vA2[0] = getByte(&temp);
3988 macHeader->vA2[1] = getByte(&temp);
3989 macHeader->vA2[2] = getByte(&temp);
3990 macHeader->vA2[3] = getByte(&temp);
3991 macHeader->vA2[4] = getByte(&temp);
3992 macHeader->vA2[5] = getByte(&temp);
3993
3994 macHeader->vA3[0] = getByte(&temp);
3995 macHeader->vA3[1] = getByte(&temp);
3996 macHeader->vA3[2] = getByte(&temp);
3997 macHeader->vA3[3] = getByte(&temp);
3998 macHeader->vA3[4] = getByte(&temp);
3999 macHeader->vA3[5] = getByte(&temp);
4000
4001 macHeader->sSeqCtrl = getByte(&temp);
4002 fragNum = macHeader->sSeqCtrl & 0xF;
4003 macHeader->sSeqCtrl >>= 4;
4004
4005 macHeader->sSeqCtrl += getByte(&temp) << 4;
4006
4007 macHeader->sSeqCtrl |= fragNum << 12;
4008
4009 if (length == 30 || length == 32) {
4010 macHeader->optvA4[0] = getByte(&temp);
4011 macHeader->optvA4[1] = getByte(&temp);
4012 macHeader->optvA4[2] = getByte(&temp);
4013 macHeader->optvA4[3] = getByte(&temp);
4014 macHeader->optvA4[4] = getByte(&temp);
4015 macHeader->optvA4[5] = getByte(&temp);
4016 }
4017
4018 if (length == 26 || length == 32) {
4019 macHeader->usQosCtrl = getByte(&temp);
4020 macHeader->usQosCtrl += getByte(&temp) << 8;
4021 }
4022
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304023 //parse payload
4024 length = getByte(&temp);
4025 length += getByte(&temp) << 8;
4026 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4027
4028 pkt->data.length = length;
4029
4030 for (i = 0; i< length; i++) {
4031 pkt->data.data[i] = getByte(&temp);
4032 }
4033
4034 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4035 &pkt->data.data[0], pkt->data.length, 0);
4036}
4037
4038/**---------------------------------------------------------------------------
4039
4040 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4041 encrypt message request
4042 This is an asynchronous callback function from SME when the encrypted data
4043 is received
4044
4045 \pEncInfoRsp -> Encrypted data info
4046
4047 \return - 0 for success non-zero for failure
4048 --------------------------------------------------------------------------*/
4049static void
4050hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4051{
4052 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4053
4054 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4055
4056 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4057 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4058 pEncryptedDataRsp->encryptedPayload.length);
4059 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4060 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4061 pEncryptedDataRsp->encryptedPayload.data,
4062 pEncryptedDataRsp->encryptedPayload.length, 0);
4063}
4064
Jeff Johnson295189b2012-06-20 16:38:30 -07004065VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4066{
4067 struct statsContext context;
4068 eHalStatus status;
4069 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304070 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071
4072 if (NULL == pAdapter)
4073 {
4074 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4075 return VOS_STATUS_E_FAULT;
4076 }
4077
4078 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304080 if (pHddCtx->isLogpInProgress) {
4081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4082 "%s:LOGP in Progress. Ignore!!!", __func__);
4083 return VOS_STATUS_E_FAILURE;
4084 }
4085
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 init_completion(&context.completion);
4087
4088 context.pAdapter = pAdapter;
4089 context.magic = POWER_CONTEXT_MAGIC;
4090
4091 if (DRIVER_POWER_MODE_ACTIVE == mode)
4092 {
4093 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4094 "Full Power", __func__);
4095 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4096 iw_power_callback_fn, &context,
4097 eSME_FULL_PWR_NEEDED_BY_HDD);
4098 // Enter Full power command received from GUI this means we are disconnected
4099 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4100 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4101 if (eHAL_STATUS_PMC_PENDING == status)
4102 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004103 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 int lrc = wait_for_completion_interruptible_timeout(
4105 &context.completion,
4106 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 if (lrc <= 0)
4109 {
4110 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004111 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 }
4113 }
4114 }
4115 else if (DRIVER_POWER_MODE_AUTO == mode)
4116 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304117 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4118 * was already in BMPS state and thus either STA or P2P-CLI is in
4119 * associated state and authenticated, so even if STA connState is
4120 * not associated it can be assumed that P2P-CLI is associated and
4121 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4122 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4123 * if all condition are satisfied for entering BMPS.
4124 */
4125 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4126 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304127 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304128 hddLog(LOGE,
4129 FL("Station is associated but, still not Authenticated ignore "
4130 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304131 return VOS_STATUS_E_AGAIN;
4132 }
4133
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4135 {
4136 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4137 __func__);
4138 // Enter BMPS command received from GUI this means DHCP is completed
4139 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4140 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4141 FALSE);
4142 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4143 iw_power_callback_fn, &context);
4144 if (eHAL_STATUS_PMC_PENDING == status)
4145 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004146 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 int lrc = wait_for_completion_interruptible_timeout(
4148 &context.completion,
4149 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 if (lrc <= 0)
4151 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004152 hddLog(VOS_TRACE_LEVEL_ERROR,
4153 "%s: SME %s while requesting BMPS",
4154 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 }
4156 }
4157 }
4158 else
4159 {
4160 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4161 "enabled in the cfg");
4162 }
4163 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004164
4165 /* either we never sent a request, we sent a request and received a
4166 response or we sent a request and timed out. if we never sent a
4167 request or if we sent a request and got a response, we want to
4168 clear the magic out of paranoia. if we timed out there is a
4169 race condition such that the callback function could be
4170 executing at the same time we are. of primary concern is if the
4171 callback function had already verified the "magic" but had not
4172 yet set the completion variable when a timeout occurred. we
4173 serialize these activities by invalidating the magic while
4174 holding a shared spinlock which will cause us to block if the
4175 callback is currently executing */
4176 spin_lock(&hdd_context_lock);
4177 context.magic = 0;
4178 spin_unlock(&hdd_context_lock);
4179
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 return VOS_STATUS_SUCCESS;
4181}
4182
4183VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4184 hdd_adapter_t *pAdapter)
4185{
4186 VOS_STATUS vos_Status;
4187
4188 if ((NULL == pAdapter) || (NULL == pHddCtx))
4189 {
4190 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4191 return VOS_STATUS_E_FAULT;
4192 }
4193
4194 /**Exit from Deep sleep or standby if we get the driver
4195 START cmd from android GUI
4196 */
4197 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4198 {
4199 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4200 "from Stand by",__func__);
4201 vos_Status = hdd_exit_standby(pHddCtx);
4202 }
4203 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4204 {
4205 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4206 "from deep sleep",__func__);
4207 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4208 }
4209 else
4210 {
4211 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4212 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4213 vos_Status = VOS_STATUS_SUCCESS;
4214 }
4215
4216 return vos_Status;
4217}
4218
4219VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4220{
4221 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4222
4223 if (NULL == pHddCtx)
4224 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304225 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 return VOS_STATUS_E_FAULT;
4227 }
4228
4229 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4230 {
4231 //Execute standby procedure.
4232 //Executing standby procedure will cause the STA to
4233 //disassociate first and then the chip will be put into standby.
4234 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4235 vos_Status = hdd_enter_standby(pHddCtx);
4236 }
4237 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4238 pHddCtx->cfg_ini->nEnableDriverStop)
4239 {
4240 //Execute deep sleep procedure
4241 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004242 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 //Deep sleep not supported
4244 vos_Status = hdd_enter_standby(pHddCtx);
4245 }
4246 else
4247 {
4248 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4249 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4250 vos_Status = VOS_STATUS_SUCCESS;
4251 }
4252
4253 return vos_Status;
4254}
4255
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004256
4257void* wlan_hdd_change_country_code_callback(void *pAdapter)
4258{
4259
4260 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004261 complete(&call_back_pAdapter->change_country_code);
4262
4263 return NULL;
4264}
4265
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304266static int __iw_set_priv(struct net_device *dev,
4267 struct iw_request_info *info,
4268 union iwreq_data *wrqu, char *extra)
4269{
4270 hdd_adapter_t *pAdapter;
4271 char *cmd = NULL;
4272 int cmd_len = wrqu->data.length;
4273 int rc = 0, ret = 0;
4274 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4275
4276 hdd_context_t *pHddCtx;
4277
4278 ENTER();
4279
4280 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4281 if (NULL == pAdapter)
4282 {
4283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4284 "mem_alloc_copy_from_user_helper fail");
4285 return -EINVAL;
4286 }
4287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4288 rc = wlan_hdd_validate_context(pHddCtx);
4289 if (0 != rc)
4290 {
4291 return rc;
4292 }
4293
4294 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4295 wrqu->data.length);
4296 if (NULL == cmd)
4297 {
4298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4299 "mem_alloc_copy_from_user_helper fail");
4300 return -ENOMEM;
4301 }
4302
4303 if (ioctl_debug)
4304 {
4305 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4306 }
4307
4308 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4309 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4310
4311 if (strncmp(cmd, "CSCAN", 5) == 0 )
4312 {
4313 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4315 "%s: Error in iw_set_scan!", __func__);
4316 rc = -EINVAL;
4317 }
4318 }
4319 else if( strcasecmp(cmd, "start") == 0 ) {
4320
4321 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4322 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4323
4324 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4325 if (vos_status == VOS_STATUS_SUCCESS)
4326 {
4327 union iwreq_data wrqu;
4328 char buf[10];
4329
4330 memset(&wrqu, 0, sizeof(wrqu));
4331 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4332 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4333 }
4334 else
4335 {
4336 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4337 rc = -EIO;
4338 }
4339 goto done;
4340 }
4341 else if( strcasecmp(cmd, "stop") == 0 )
4342 {
4343 union iwreq_data wrqu;
4344 char buf[10];
4345
4346 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4347
4348 wlan_hdd_enter_lowpower(pHddCtx);
4349 memset(&wrqu, 0, sizeof(wrqu));
4350 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4351 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4352 goto done;
4353 }
4354 else if (strcasecmp(cmd, "macaddr") == 0)
4355 {
4356 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4357 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4358 }
4359 else if (strcasecmp(cmd, "scan-active") == 0)
4360 {
4361 hddLog(LOG1,
4362 FL("making default scan to active"));
4363 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4364 ret = snprintf(cmd, cmd_len, "OK");
4365 }
4366 else if (strcasecmp(cmd, "scan-passive") == 0)
4367 {
4368 hddLog(LOG1,
4369 FL("making default scan to passive"));
4370 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4371 ret = snprintf(cmd, cmd_len, "OK");
4372 }
4373 else if( strcasecmp(cmd, "scan-mode") == 0 )
4374 {
4375 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4376 }
4377 else if( strcasecmp(cmd, "linkspeed") == 0 )
4378 {
4379 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4380 }
4381 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4382 {
4383 ret = iw_get_rssi(dev, info, wrqu, cmd);
4384 }
4385 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4386 int mode;
4387 char *ptr;
4388
4389 if (9 < cmd_len)
4390 {
4391 ptr = (char*)(cmd + 9);
4392
4393 }else{
4394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4395 "CMD LENGTH %d is not correct",cmd_len);
4396 kfree(cmd);
4397 return -EINVAL;
4398 }
4399
4400 if (1 != sscanf(ptr,"%d",&mode))
4401 {
4402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4403 "powermode input %s is not correct",ptr);
4404 kfree(cmd);
4405 return -EIO;
4406 }
4407
4408 wlan_hdd_enter_bmps(pAdapter, mode);
4409 /*TODO:Set the power mode*/
4410 }
4411 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4412 v_U32_t pmc_state;
4413 v_U16_t value;
4414
4415 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4416 if(pmc_state == BMPS) {
4417 value = DRIVER_POWER_MODE_AUTO;
4418 }
4419 else {
4420 value = DRIVER_POWER_MODE_ACTIVE;
4421 }
4422 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4423 }
4424 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4425 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4426 /*TODO: set the btcoexmode*/
4427 }
4428 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4429
4430 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4431 /*TODO: Return the btcoex status*/
4432 }
4433 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4434
4435 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4436
4437 /*TODO: Enable Rx data Filter*/
4438 }
4439 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4440
4441 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4442
4443 /*TODO: Disable Rx data Filter*/
4444 }
4445 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4446
4447 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4448 /*TODO: rxfilter-statistics*/
4449 }
4450 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4451
4452 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4453 /*TODO: rxfilter-add*/
4454 }
4455 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4456
4457 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4458 /*TODO: rxfilter-remove*/
4459 }
4460#ifdef FEATURE_WLAN_SCAN_PNO
4461 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4462 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4463 /*TODO: support pnosetup*/
4464 }
4465 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4466 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4467 /*TODO: support pnoforce*/
4468 }
4469 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4470
4471 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4472 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4473 kfree(cmd);
4474 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4475 }
4476 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4477 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4478 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4479 kfree(cmd);
4480 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4481 }
4482#endif /*FEATURE_WLAN_SCAN_PNO*/
4483 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4484 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4485 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4486 kfree(cmd);
4487 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4488 }
4489 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4490 tSirTxPerTrackingParam tTxPerTrackingParam;
4491 char *ptr;
4492
4493 if (18 < cmd_len)
4494 {
4495 ptr = (char*)(cmd + 18);
4496 }else{
4497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4498 "CMD LENGTH %d is not correct",cmd_len);
4499 kfree(cmd);
4500 return -EINVAL;
4501 }
4502
4503 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4504 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4505 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4506 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4507 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4508 {
4509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4510 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4511 kfree(cmd);
4512 return -EIO;
4513 }
4514
4515 // parameters checking
4516 // period has to be larger than 0
4517 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4518 {
4519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4520 kfree(cmd);
4521 return -EIO;
4522 }
4523
4524 // use default value 5 is the input is not reasonable. in unit of 10%
4525 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4526 {
4527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4528 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4529 }
4530
4531 // default is 5
4532 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4533 {
4534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4535 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4536 }
4537
4538 if (eHAL_STATUS_SUCCESS !=
4539 sme_SetTxPerTracking(pHddCtx->hHal,
4540 hdd_tx_per_hit_cb,
4541 (void*)pAdapter, &tTxPerTrackingParam)) {
4542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4543 rc = -EIO;
4544 }
4545 }
4546 else {
4547 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4548 __func__, cmd);
4549 }
4550done:
4551 /* many of the commands write information back into the command
4552 string using snprintf(). check the return value here in one
4553 place */
4554 if ((ret < 0) || (ret >= cmd_len))
4555 {
4556 /* there was an encoding error or overflow */
4557 rc = -EINVAL;
4558 }
4559 else if (ret > 0)
4560 {
4561 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4562 {
4563 hddLog(VOS_TRACE_LEVEL_ERROR,
4564 "%s: failed to copy data to user buffer", __func__);
4565 kfree(cmd);
4566 return -EFAULT;
4567 }
4568 wrqu->data.length = ret;
4569 }
4570
4571 if (ioctl_debug)
4572 {
4573 pr_info("%s: rsp [%s] len [%d] status %d\n",
4574 __func__, cmd, wrqu->data.length, rc);
4575 }
4576 kfree(cmd);
4577 EXIT();
4578 return rc;
4579}
4580
4581static int iw_set_priv(struct net_device *dev,
4582 struct iw_request_info *info,
4583 union iwreq_data *wrqu, char *extra)
4584{
4585 int ret;
4586 vos_ssr_protect(__func__);
4587 ret = __iw_set_priv(dev, info, wrqu, extra);
4588 vos_ssr_unprotect(__func__);
4589
4590 return ret;
4591}
4592
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304593static int __iw_set_nick(struct net_device *dev,
4594 struct iw_request_info *info,
4595 union iwreq_data *wrqu, char *extra)
4596{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304597 hdd_adapter_t *pAdapter;
4598 hdd_context_t *pHddCtx;
4599 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304600
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304601 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304602
4603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4604 if (NULL == pAdapter)
4605 {
4606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4607 "%s: Adapter is NULL",__func__);
4608 return -EINVAL;
4609 }
4610
4611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4612 ret = wlan_hdd_validate_context(pHddCtx);
4613 if (0 != ret)
4614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615 return ret;
4616 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304617 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304618 return 0;
4619}
4620
Jeff Johnson295189b2012-06-20 16:38:30 -07004621static int iw_set_nick(struct net_device *dev,
4622 struct iw_request_info *info,
4623 union iwreq_data *wrqu, char *extra)
4624{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304625 int ret;
4626
4627 vos_ssr_protect(__func__);
4628 ret = __iw_set_nick(dev, info, wrqu, extra);
4629 vos_ssr_unprotect(__func__);
4630
4631 return ret;
4632}
4633
4634static int __iw_get_nick(struct net_device *dev,
4635 struct iw_request_info *info,
4636 union iwreq_data *wrqu, char *extra)
4637{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304638 hdd_adapter_t *pAdapter;
4639 hdd_context_t *pHddCtx;
4640 int ret = 0;
4641
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304643
4644 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4645 if (NULL == pAdapter)
4646 {
4647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4648 "%s: Adapter is NULL",__func__);
4649 return -EINVAL;
4650 }
4651
4652 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4653 ret = wlan_hdd_validate_context(pHddCtx);
4654 if (0 != ret)
4655 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304656 return ret;
4657 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304658 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 return 0;
4660}
4661
4662static int iw_get_nick(struct net_device *dev,
4663 struct iw_request_info *info,
4664 union iwreq_data *wrqu, char *extra)
4665{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304666 int ret;
4667
4668 vos_ssr_protect(__func__);
4669 ret = __iw_get_nick(dev, info, wrqu, extra);
4670 vos_ssr_unprotect(__func__);
4671
4672 return ret;
4673}
4674
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304675/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304676static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4677{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4679 hdd_context_t *pHddCtx;
4680 hdd_station_ctx_t *pHddStaCtx;
4681 v_S7_t snr = 0, rssi = 0;
4682 eHalStatus status = eHAL_STATUS_SUCCESS;
4683
4684 ENTER();
4685
4686 if (NULL == pAdapter)
4687 {
4688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4689 "%s: Adapter is NULL",__func__);
4690 return NULL;
4691 }
4692
4693 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4694 status = wlan_hdd_validate_context(pHddCtx);
4695 if (0 != status)
4696 {
4697 return NULL;
4698 }
4699
4700 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4701 if (NULL == pHddStaCtx)
4702 {
4703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4704 "%s: STA Context is NULL",__func__);
4705 return NULL;
4706 }
4707
4708 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4709 {
4710 wlan_hdd_get_station_stats(pAdapter);
4711 wlan_hdd_get_snr(pAdapter, &snr);
4712 wlan_hdd_get_rssi(pAdapter, &rssi);
4713
4714 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4715 pAdapter->iwStats.status = 0;
4716 pAdapter->iwStats.qual.qual = snr;
4717 pAdapter->iwStats.qual.level = rssi;
4718 pAdapter->iwStats.qual.noise = rssi - snr;
4719 pAdapter->iwStats.discard.code = 0;
4720 pAdapter->iwStats.discard.retries= 0;
4721 pAdapter->iwStats.miss.beacon = 0;
4722 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4723 }
4724 else
4725 {
4726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4727 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4728 return NULL;
4729 }
4730
4731 EXIT();
4732 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004733}
4734
4735static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4736{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304737
4738 struct iw_statistics *stats;
4739
4740 vos_ssr_protect(__func__);
4741 stats = __get_wireless_stats(dev);
4742 vos_ssr_unprotect(__func__);
4743
4744 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004745}
4746
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304747static int __iw_set_encode(struct net_device *dev,
4748 struct iw_request_info *info,
4749 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004750
4751{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304752 hdd_adapter_t *pAdapter;
4753 hdd_station_ctx_t *pHddStaCtx;
4754 hdd_wext_state_t *pWextState;
4755 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 struct iw_point *encoderq = &(wrqu->encoding);
4757 v_U32_t keyId;
4758 v_U8_t key_length;
4759 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4760 v_BOOL_t fKeyPresent = 0;
4761 int i;
4762 eHalStatus status = eHAL_STATUS_SUCCESS;
4763
4764
4765 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304766 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4767 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4770 "%s: Adapter is NULL",__func__);
4771 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 }
4773
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4775 status = wlan_hdd_validate_context(pHddCtx);
4776 if (0 != status)
4777 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304778 return status;
4779 }
4780 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4781 if (NULL == pWextState)
4782 {
4783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4784 "%s: pWextState is NULL ",__func__);
4785 return -EINVAL;
4786 }
4787 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4788 if (NULL == pHddStaCtx)
4789 {
4790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4791 "%s: STA Context is NULL",__func__);
4792 return -EINVAL;
4793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004794
4795 keyId = encoderq->flags & IW_ENCODE_INDEX;
4796
4797 if(keyId)
4798 {
4799 if(keyId > MAX_WEP_KEYS)
4800 {
4801 return -EINVAL;
4802 }
4803
4804 fKeyPresent = 1;
4805 keyId--;
4806 }
4807 else
4808 {
4809 fKeyPresent = 0;
4810 }
4811
4812
4813 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4814 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 if(!fKeyPresent) {
4817
4818 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4819
4820 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4821 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4822 }
4823 }
4824 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4825 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4826 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4827 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4828
4829 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4830 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4831
4832 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4833 {
4834 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4835 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004836 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304837 {
4838 long ret;
4839 ret = wait_for_completion_interruptible_timeout(
4840 &pAdapter->disconnect_comp_var,
4841 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4842 if (ret <= 0)
4843 hddLog(VOS_TRACE_LEVEL_ERROR,
4844 FL("failed wait on disconnect_comp_var %ld"), ret);
4845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 }
4847
4848 return status;
4849
4850 }
4851
4852 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4853 {
4854 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4855
4856 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4857
4858 }
4859
4860
4861 if(wrqu->data.length > 0)
4862 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004863 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004864
4865 key_length = wrqu->data.length;
4866
4867 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4868
4869 if(5 == key_length)
4870 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004871 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004872
4873 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4874 {
4875 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4876 }
4877 else
4878 {
4879 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4880 }
4881 }
4882 else if(13 == key_length)
4883 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004884 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,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_WEP104;
4889 }
4890 else
4891 {
4892 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4893 }
4894 }
4895 else
4896 {
4897 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004898 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 return -EINVAL;
4900 }
4901
4902 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4903 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4904 pWextState->roamProfile.EncryptionType.numEntries = 1;
4905 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4906 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4907 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4908
4909 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4910 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4911 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4912 {
4913
4914 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4915
4916 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4917 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4918
4919 return status;
4920 }
4921 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304922 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 return 0;
4924}
4925
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304926static int iw_set_encode(struct net_device *dev,
4927 struct iw_request_info *info,
4928 union iwreq_data *wrqu,char *extra)
4929{
4930 int ret;
4931
4932 vos_ssr_protect(__func__);
4933 ret = __iw_set_encode(dev, info, wrqu, extra);
4934 vos_ssr_unprotect(__func__);
4935
4936 return ret;
4937}
4938
4939static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 struct iw_request_info *info,
4941 struct iw_point *dwrq,
4942 char *extra)
4943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304944 hdd_adapter_t *pAdapter;
4945 hdd_wext_state_t *pWextState;
4946 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 int keyId;
4948 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4949 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304950 int i, ret = 0;
4951 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004952
4953 ENTER();
4954
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304955 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4956 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004957 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4959 "%s: Adapter is NULL",__func__);
4960 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004961 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304962 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4963 ret = wlan_hdd_validate_context(pHddCtx);
4964 if (0 != ret)
4965 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304966 return ret;
4967 }
4968 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4969 if (NULL == pWextState)
4970 {
4971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4972 "%s: pWextState is NULL",__func__);
4973 return -EINVAL;
4974 }
4975 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004976
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 keyId = pRoamProfile->Keys.defaultIndex;
4978
4979 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4980 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004981 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 return -EINVAL;
4983 }
4984
4985 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4986 {
4987 dwrq->flags |= IW_ENCODE_ENABLED;
4988 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304989 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4990 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 }
4992 else
4993 {
4994 dwrq->flags |= IW_ENCODE_DISABLED;
4995 }
4996
4997 for(i=0; i < MAX_WEP_KEYS; i++)
4998 {
4999 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5000 {
5001 continue;
5002 }
5003 else
5004 {
5005 break;
5006 }
5007 }
5008
5009 if(MAX_WEP_KEYS == i)
5010 {
5011 dwrq->flags |= IW_ENCODE_NOKEY;
5012 }
5013 else
5014 {
5015 dwrq->flags |= IW_ENCODE_ENABLED;
5016 }
5017
5018 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5019
5020 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5021 {
5022 dwrq->flags |= IW_ENCODE_DISABLED;
5023 }
5024
5025 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5026
5027 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5028 {
5029 dwrq->flags |= IW_ENCODE_OPEN;
5030 }
5031 else
5032 {
5033 dwrq->flags |= IW_ENCODE_RESTRICTED;
5034 }
5035 EXIT();
5036 return 0;
5037
5038}
5039
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305040static int iw_get_encodeext(struct net_device *dev,
5041 struct iw_request_info *info,
5042 struct iw_point *dwrq,
5043 char *extra)
5044{
5045 int ret;
5046 vos_ssr_protect(__func__);
5047 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5048 vos_ssr_unprotect(__func__);
5049
5050 return ret;
5051}
5052
5053static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 struct iw_request_info *info,
5055 union iwreq_data *wrqu, char *extra)
5056{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305057 hdd_adapter_t *pAdapter;
5058 hdd_station_ctx_t *pHddStaCtx;
5059 hdd_wext_state_t *pWextState;
5060 hdd_context_t *pHddCtx;
5061 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005062
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305063 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 v_U32_t status = 0;
5065
5066 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5067
5068 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5069
5070 int key_index;
5071 struct iw_point *encoding = &wrqu->encoding;
5072 tCsrRoamSetKey setKey;
5073 v_U32_t roamId= 0xFF;
5074 VOS_STATUS vos_status;
5075
5076 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305077 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5078 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5081 "%s: Adapter is NULL",__func__);
5082 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5085 status = wlan_hdd_validate_context(pHddCtx);
5086 if (0 != status)
5087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305088 return status;
5089 }
5090 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5091 if (NULL == pHddStaCtx)
5092 {
5093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5094 "%s: STA Context is NULL",__func__);
5095 return -EINVAL;
5096 }
5097 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5098 if (NULL == pWextState)
5099 {
5100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5101 "%s: pWextState is NULL",__func__);
5102 return -EINVAL;
5103 }
5104 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 key_index = encoding->flags & IW_ENCODE_INDEX;
5106
5107 if(key_index > 0) {
5108
5109 /*Convert from 1-based to 0-based keying*/
5110 key_index--;
5111 }
5112 if(!ext->key_len) {
5113
5114 /*Set the encrytion type to NONE*/
5115 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5116 return status;
5117 }
5118
5119 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5120 (IW_ENCODE_ALG_WEP == ext->alg))
5121 {
5122 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5123
Agarwal Ashish971c2882013-10-30 20:11:12 +05305124 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5125 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 return -EINVAL;
5127 }
5128 else {
5129 /*Static wep, update the roam profile with the keys */
5130 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5131 key_index < CSR_MAX_NUM_KEY) {
5132 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5133 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5134
5135 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5136 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5137
5138 }
5139 }
5140 return status;
5141 }
5142
5143 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5144
5145 setKey.keyId = key_index;
5146 setKey.keyLength = ext->key_len;
5147
5148 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5149 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5150 }
5151
5152 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5153 /*Key direction for group is RX only*/
5154 setKey.keyDirection = eSIR_RX_ONLY;
5155 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5156 }
5157 else {
5158
5159 setKey.keyDirection = eSIR_TX_RX;
5160 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5161 }
5162
5163 /*For supplicant pae role is zero*/
5164 setKey.paeRole = 0;
5165
5166 switch(ext->alg)
5167 {
5168 case IW_ENCODE_ALG_NONE:
5169 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5170 break;
5171
5172 case IW_ENCODE_ALG_WEP:
5173 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5174 break;
5175
5176 case IW_ENCODE_ALG_TKIP:
5177 {
5178 v_U8_t *pKey = &setKey.Key[0];
5179
5180 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5181
5182 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5183
5184 /*Supplicant sends the 32bytes key in this order
5185
5186 |--------------|----------|----------|
5187 | Tk1 |TX-MIC | RX Mic |
5188 |--------------|----------|----------|
5189 <---16bytes---><--8bytes--><--8bytes-->
5190
5191 */
5192 /*Sme expects the 32 bytes key to be in the below order
5193
5194 |--------------|----------|----------|
5195 | Tk1 |RX-MIC | TX Mic |
5196 |--------------|----------|----------|
5197 <---16bytes---><--8bytes--><--8bytes-->
5198 */
5199 /* Copy the Temporal Key 1 (TK1) */
5200 vos_mem_copy(pKey,ext->key,16);
5201
5202 /*Copy the rx mic first*/
5203 vos_mem_copy(&pKey[16],&ext->key[24],8);
5204
5205 /*Copy the tx mic */
5206 vos_mem_copy(&pKey[24],&ext->key[16],8);
5207
5208 }
5209 break;
5210
5211 case IW_ENCODE_ALG_CCMP:
5212 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5213 break;
5214
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005215#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005216#define IW_ENCODE_ALG_KRK 6
5217 case IW_ENCODE_ALG_KRK:
5218 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5219 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005220#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005221
5222 default:
5223 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5224 break;
5225 }
5226
5227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005228 ("%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 -07005229
5230#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305231 /* The supplicant may attempt to set the PTK once pre-authentication
5232 is done. Save the key in the UMAC and include it in the ADD
5233 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305235 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305237 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5238 "%s: Update PreAuth Key success", __func__);
5239 return 0;
5240 }
5241 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5242 {
5243 hddLog(VOS_TRACE_LEVEL_ERROR,
5244 "%s: Update PreAuth Key failed", __func__);
5245 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 }
5247#endif /* WLAN_FEATURE_VOWIFI_11R */
5248
5249 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5250
5251 vos_status = wlan_hdd_check_ula_done(pAdapter);
5252 if ( vos_status != VOS_STATUS_SUCCESS )
5253 {
5254 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5255 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5256 __LINE__, vos_status );
5257
5258 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5259 }
5260
5261 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5262
5263 if ( halStatus != eHAL_STATUS_SUCCESS )
5264 {
5265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5266 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5267 __LINE__, halStatus );
5268
5269 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5270 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305271 EXIT();
5272 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005273}
5274
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305275static int iw_set_encodeext(struct net_device *dev,
5276 struct iw_request_info *info,
5277 union iwreq_data *wrqu, char *extra)
5278{
5279 int ret;
5280
5281 vos_ssr_protect(__func__);
5282 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5283 vos_ssr_unprotect(__func__);
5284
5285 return ret;
5286}
5287
5288static int __iw_set_retry(struct net_device *dev,
5289 struct iw_request_info *info,
5290 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005291{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305292 hdd_adapter_t *pAdapter;
5293 tHalHandle hHal;
5294 hdd_context_t *pHddCtx;
5295 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005296
5297 ENTER();
5298
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305299 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5300 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005301 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5303 "%s: Adapter is NULL",__func__);
5304 return -EINVAL;
5305 }
5306
5307 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5308 ret = wlan_hdd_validate_context(pHddCtx);
5309 if (0 != ret)
5310 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305311 return ret;
5312 }
5313
5314 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5315 if (NULL == hHal)
5316 {
5317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5318 "%s: Hal Context is NULL",__func__);
5319 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005320 }
5321
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5323 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5324
Arif Hussain6d2a3322013-11-17 19:50:10 -08005325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005326
5327 return -EINVAL;
5328 }
5329
5330 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5331
5332 if((wrqu->retry.flags & IW_RETRY_LONG))
5333 {
5334 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5335 {
c_hpothub8245442013-11-20 23:41:09 +05305336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5337 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 return -EIO;
5339 }
5340 }
5341 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5342 {
5343 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5344 {
c_hpothub8245442013-11-20 23:41:09 +05305345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5346 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 return -EIO;
5348 }
5349 }
5350 }
5351 else
5352 {
5353 return -EOPNOTSUPP;
5354 }
5355
Arif Hussain6d2a3322013-11-17 19:50:10 -08005356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005357
5358 EXIT();
5359
5360 return 0;
5361
5362}
5363
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305364static int iw_set_retry(struct net_device *dev,
5365 struct iw_request_info *info,
5366 union iwreq_data *wrqu, char *extra)
5367{
5368 int ret;
5369
5370 vos_ssr_protect(__func__);
5371 ret = __iw_set_retry(dev, info, wrqu, extra);
5372 vos_ssr_unprotect(__func__);
5373
5374 return ret;
5375}
5376
5377static int __iw_get_retry(struct net_device *dev,
5378 struct iw_request_info *info,
5379 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005380{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305381 hdd_adapter_t *pAdapter;
5382 hdd_context_t *pHddCtx;
5383 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305385 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005386
5387 ENTER();
5388
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305389 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5390 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005391 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5393 "%s: Adapter is NULL",__func__);
5394 return -EINVAL;
5395 }
5396
5397 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5398 ret = wlan_hdd_validate_context(pHddCtx);
5399 if (0 != ret)
5400 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305401 return ret;
5402 }
5403
5404 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5405 if (NULL == hHal)
5406 {
5407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5408 "%s: Hal Context is NULL",__func__);
5409 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005410 }
5411
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 if((wrqu->retry.flags & IW_RETRY_LONG))
5413 {
5414 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5415
5416 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5417 {
c_hpothub8245442013-11-20 23:41:09 +05305418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5419 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 return -EIO;
5421 }
5422
5423 wrqu->retry.value = retry;
5424 }
5425 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5426 {
5427 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5428
5429 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_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_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 return -EIO;
5434 }
5435
5436 wrqu->retry.value = retry;
5437 }
5438 else {
5439 return -EOPNOTSUPP;
5440 }
5441
Arif Hussain6d2a3322013-11-17 19:50:10 -08005442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005443
5444 EXIT();
5445
5446 return 0;
5447}
5448
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305449static int iw_get_retry(struct net_device *dev,
5450 struct iw_request_info *info,
5451 union iwreq_data *wrqu, char *extra)
5452{
5453 int ret;
5454
5455 vos_ssr_protect(__func__);
5456 ret = __iw_get_retry(dev, info, wrqu, extra);
5457 vos_ssr_unprotect(__func__);
5458
5459 return ret;
5460}
5461
5462static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 struct iw_request_info *info,
5464 union iwreq_data *wrqu,
5465 char *extra)
5466{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305467 hdd_adapter_t *pAdapter;
5468 hdd_context_t *pHddCtx;
5469 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005470 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5471 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305472 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005473
5474 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305475 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5476 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5479 "%s:Adapter is NULL",__func__);
5480 return -EINVAL;
5481 }
5482 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5483 ret = wlan_hdd_validate_context(pHddCtx);
5484 if (0 != ret)
5485 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305486 return ret;
5487 }
5488 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5489 if (NULL == pHddStaCtx)
5490 {
5491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5492 "%s:STA context is NULL",__func__);
5493 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 }
5495
5496 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5497 switch (mlme->cmd) {
5498 case IW_MLME_DISASSOC:
5499 case IW_MLME_DEAUTH:
5500
5501 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5502 {
5503 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5504
5505 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5506 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5507
5508 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5509 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5510
Jeff Johnson43971f52012-07-17 12:26:56 -07005511 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305512 {
5513 long ret;
5514 ret = wait_for_completion_interruptible_timeout(
5515 &pAdapter->disconnect_comp_var,
5516 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5517 if (ret <= 0)
5518 hddLog(VOS_TRACE_LEVEL_ERROR,
5519 FL("failed wait on disconnect_comp_var %ld"), ret);
5520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005522 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005523 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005524
5525 /* Resetting authKeyMgmt */
5526 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5527
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305528 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 netif_tx_disable(dev);
5530 netif_carrier_off(dev);
5531
5532 }
5533 else
5534 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005535 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 -07005536 }
5537 break;
5538 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005539 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 return -EINVAL;
5541 }//end of switch
5542
5543 EXIT();
5544
5545 return status;
5546
5547}
5548
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305549static int iw_set_mlme(struct net_device *dev,
5550 struct iw_request_info *info,
5551 union iwreq_data *wrqu,
5552 char *extra)
5553{
5554 int ret;
5555
5556 vos_ssr_protect(__func__);
5557 ret = __iw_set_mlme(dev, info, wrqu, extra);
5558 vos_ssr_unprotect(__func__);
5559
5560 return ret;
5561}
5562
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305563int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305564{
5565 sHwCalValues hwCalValues;
5566 uint16 hwCalTxPower;
5567 uint8 txPwr = TX_PWR_DEF;
5568
5569 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5570
5571 if (TRUE == set_value) {
5572 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5573 NULL, sizeof(sHwCalValues) )
5574 != VOS_STATUS_SUCCESS) {
5575 return -EINVAL;
5576 }
5577 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5578
5579 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5580 hwCalTxPower, hwCalValues.calData.hwParam7);
5581
5582 txPwr = (int8)(hwCalTxPower & 0x00FF);
5583 txPwr = txPwr/10;
5584 if (txPwr < TX_PWR_MIN)
5585 txPwr = TX_PWR_MIN;
5586 if (txPwr > TX_PWR_MAX)
5587 txPwr = TX_PWR_MAX;
5588
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305589 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305590 eHAL_STATUS_SUCCESS) {
5591 hddLog(VOS_TRACE_LEVEL_ERROR,
5592 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5593 return -EIO;
5594 }
5595
5596 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5597 txPwr /= 10;
5598 if (txPwr < TX_PWR_MIN)
5599 txPwr = TX_PWR_MIN;
5600 if (txPwr > TX_PWR_MAX)
5601 txPwr = TX_PWR_MAX;
5602
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305603 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305604 eHAL_STATUS_SUCCESS) {
5605 hddLog(VOS_TRACE_LEVEL_ERROR,
5606 FL("setting tx power failed for 5GHz band %d"), txPwr);
5607 return -EIO;
5608 }
5609 }
5610 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305611 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305612 eHAL_STATUS_SUCCESS) {
5613 hddLog(VOS_TRACE_LEVEL_ERROR,
5614 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5615 return -EIO;
5616 }
5617
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305618 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305619 eHAL_STATUS_SUCCESS) {
5620 hddLog(VOS_TRACE_LEVEL_ERROR,
5621 FL("setting tx power failed for 5GHz band %d"), txPwr);
5622 return -EIO;
5623 }
5624 }
5625 else {
5626 return -EINVAL;
5627 }
5628
5629 return eHAL_STATUS_SUCCESS;
5630}
Jeff Johnson295189b2012-06-20 16:38:30 -07005631/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305632static int __iw_setint_getnone(struct net_device *dev,
5633 struct iw_request_info *info,
5634 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005635{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305636 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305637 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305638 hdd_wext_state_t *pWextState;
5639 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305640 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 int *value = (int *)extra;
5642 int sub_cmd = value[0];
5643 int set_value = value[1];
5644 int ret = 0; /* success */
5645 int enable_pbm, enable_mp;
5646#ifdef CONFIG_HAS_EARLYSUSPEND
5647 v_U8_t nEnableSuspendOld;
5648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005649
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305650 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305651 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5652 if (NULL == pAdapter)
5653 {
5654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5655 "%s: Adapter is NULL",__func__);
5656 return -EINVAL;
5657 }
5658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5659 ret = wlan_hdd_validate_context(pHddCtx);
5660 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005661 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305662 return ret;
5663 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305664
Katya Nigameae74b62015-05-28 17:19:16 +05305665 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305666 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305667 /* In monitor mode hHal is NULL */
5668 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5669 if (NULL == hHal)
5670 {
5671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5672 "%s: Hal Context is NULL",__func__);
5673 return -EINVAL;
5674 }
Katya Nigameae74b62015-05-28 17:19:16 +05305675 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5676 if (NULL == pWextState)
5677 {
5678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5679 "%s: pWextState is NULL",__func__);
5680 return -EINVAL;
5681 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005682
Katya Nigameae74b62015-05-28 17:19:16 +05305683 INIT_COMPLETION(pWextState->completion_var);
5684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 switch(sub_cmd)
5686 {
5687 case WE_SET_11D_STATE:
5688 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005689 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005690 memset(&smeConfig, 0x00, sizeof(smeConfig));
5691
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305692 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5693 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 sme_GetConfigParam(hHal,&smeConfig);
5695 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5696
Arif Hussain6d2a3322013-11-17 19:50:10 -08005697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005698
5699 sme_UpdateConfig(hHal,&smeConfig);
5700 }
5701 else {
5702 return -EINVAL;
5703 }
5704 break;
5705 }
5706
5707 case WE_WOWL:
5708 {
5709 switch (set_value)
5710 {
5711 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305712 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 break;
5714 case 0x01:
5715 case 0x02:
5716 case 0x03:
5717 enable_mp = (set_value & 0x01) ? 1 : 0;
5718 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005719 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5721 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5722 break;
5723 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005724 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 ret = -EINVAL;
5726 break;
5727 }
5728
5729 break;
5730 }
5731 case WE_SET_POWER:
5732 {
5733 switch (set_value)
5734 {
5735 case 0: //Full Power
5736 {
5737 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305738 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005739
5740 init_completion(&context.completion);
5741
5742 context.pAdapter = pAdapter;
5743 context.magic = POWER_CONTEXT_MAGIC;
5744
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305745 if (NULL == hHal)
5746 return -EINVAL;
5747
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5749 iw_power_callback_fn, &context,
5750 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305751
Jeff Johnson72a40512013-12-19 10:14:15 -08005752 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 {
5754 int lrc = wait_for_completion_interruptible_timeout(
5755 &context.completion,
5756 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005757
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 if (lrc <= 0)
5759 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005760 hddLog(VOS_TRACE_LEVEL_ERROR,
5761 "%s: SME %s while requesting fullpower",
5762 __func__, (0 == lrc) ?
5763 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 }
5765 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005766 /* either we have a response or we timed out. if we timed
5767 out there is a race condition such that the callback
5768 function could be executing at the same time we are. of
5769 primary concern is if the callback function had already
5770 verified the "magic" but had not yet set the completion
5771 variable when a timeout occurred. we serialize these
5772 activities by invalidating the magic while holding a
5773 shared spinlock which will cause us to block if the
5774 callback is currently executing */
5775 spin_lock(&hdd_context_lock);
5776 context.magic = 0;
5777 spin_unlock(&hdd_context_lock);
5778
Arif Hussain6d2a3322013-11-17 19:50:10 -08005779 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 break;
5781 }
5782 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305783 if (hHal)
5784 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5785 else
5786 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 break;
5788 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305789 if (hHal)
5790 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5791 else
5792 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 break;
5794 case 3: //Request Bmps
5795 {
5796 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305797 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005798
5799 init_completion(&context.completion);
5800
5801 context.pAdapter = pAdapter;
5802 context.magic = POWER_CONTEXT_MAGIC;
5803
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305804 if (NULL == hHal)
5805 return -EINVAL;
5806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305808 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005809 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 {
5811 int lrc = wait_for_completion_interruptible_timeout(
5812 &context.completion,
5813 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 if (lrc <= 0)
5815 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005816 hddLog(VOS_TRACE_LEVEL_ERROR,
5817 "%s: SME %s while requesting BMPS",
5818 __func__, (0 == lrc) ? "timeout" :
5819 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 }
5821 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005822 /* either we have a response or we timed out. if we
5823 timed out there is a race condition such that the
5824 callback function could be executing at the same
5825 time we are. of primary concern is if the callback
5826 function had already verified the "magic" but had
5827 not yet set the completion variable when a timeout
5828 occurred. we serialize these activities by
5829 invalidating the magic while holding a shared
5830 spinlock which will cause us to block if the
5831 callback is currently executing */
5832 spin_lock(&hdd_context_lock);
5833 context.magic = 0;
5834 spin_unlock(&hdd_context_lock);
5835
Arif Hussain6d2a3322013-11-17 19:50:10 -08005836 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 break;
5838 }
5839 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305840 if (hHal)
5841 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5842 else
5843 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 break;
5845 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305846 if (hHal)
5847 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5848 else
5849 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 break;
5851 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305852 if (hHal)
5853 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5854 else
5855 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 break;
5857 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305858 if (hHal)
5859 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5860 else
5861 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 break;
5863 case 8: //Request Standby
5864#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005865#endif
5866 break;
5867 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305868 if (hHal)
5869 sme_StartAutoBmpsTimer(hHal);
5870 else
5871 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 break;
5873 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305874 if (hHal)
5875 sme_StopAutoBmpsTimer(hHal);
5876 else
5877 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 break;
5879#ifdef CONFIG_HAS_EARLYSUSPEND
5880 case 11://suspend to standby
5881#ifdef CONFIG_HAS_EARLYSUSPEND
5882 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5883 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5885#endif
5886 break;
5887 case 12://suspend to deep sleep
5888#ifdef CONFIG_HAS_EARLYSUSPEND
5889 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5890 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5892#endif
5893 break;
5894 case 13://resume from suspend
5895#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005896#endif
5897 break;
5898#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005900 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 ret = -EINVAL;
5902 break;
5903 }
5904 break;
5905 }
5906
5907 case WE_SET_MAX_ASSOC:
5908 {
5909 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305910 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5911 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 {
5913 ret = -EINVAL;
5914 }
5915 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5916 set_value, NULL, eANI_BOOLEAN_FALSE)
5917 != eHAL_STATUS_SUCCESS )
5918 {
c_hpothub8245442013-11-20 23:41:09 +05305919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5920 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 ret = -EIO;
5922 }
5923 break;
5924 }
5925
5926 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5927 {
5928 if( 0 == set_value )
5929 {
5930 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5931 }
5932 else if ( 1 == set_value )
5933 {
5934 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5935 }
5936 else
5937 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005938 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 ret = -EINVAL;
5940 }
5941 break;
5942 }
5943
5944 case WE_SET_DATA_INACTIVITY_TO:
5945 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305946 if (NULL == hHal)
5947 return -EINVAL;
5948
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5950 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5951 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5952 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5953 set_value,
5954 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5955 {
5956 hddLog(LOGE,"Failure: Could not pass on "
5957 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005958 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 ret = -EINVAL;
5960 }
5961 break;
5962 }
5963 case WE_SET_MAX_TX_POWER:
5964 {
5965 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5966 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5967
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305968 if (NULL == hHal)
5969 return -EINVAL;
5970
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5972 __func__, set_value);
5973 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5974 eHAL_STATUS_SUCCESS )
5975 {
5976 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5977 __func__);
5978 return -EIO;
5979 }
5980
5981 break;
5982 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005983 case WE_SET_MAX_TX_POWER_2_4:
5984 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305985 if (NULL == hHal)
5986 return -EINVAL;
5987
Arif Hussaina5ebce02013-08-09 15:09:58 -07005988 hddLog(VOS_TRACE_LEVEL_INFO,
5989 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5990 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305991 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07005992 eHAL_STATUS_SUCCESS)
5993 {
5994 hddLog(VOS_TRACE_LEVEL_ERROR,
5995 "%s: Setting maximum tx power failed for 2.4 GHz band",
5996 __func__);
5997 return -EIO;
5998 }
5999
6000 break;
6001 }
6002 case WE_SET_MAX_TX_POWER_5_0:
6003 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306004 if (NULL == hHal)
6005 return -EINVAL;
6006
Arif Hussaina5ebce02013-08-09 15:09:58 -07006007 hddLog(VOS_TRACE_LEVEL_INFO,
6008 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6009 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306010 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006011 eHAL_STATUS_SUCCESS)
6012 {
6013 hddLog(VOS_TRACE_LEVEL_ERROR,
6014 "%s: Setting maximum tx power failed for 5.0 GHz band",
6015 __func__);
6016 return -EIO;
6017 }
6018
6019 break;
6020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 case WE_SET_HIGHER_DTIM_TRANSITION:
6022 {
6023 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6024 (set_value == eANI_BOOLEAN_TRUE)))
6025 {
6026 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6027 ret = -EINVAL;
6028 }
6029 else
6030 {
6031 if(pAdapter->higherDtimTransition != set_value)
6032 {
6033 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006034 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 }
6036 }
6037
6038 break;
6039 }
6040
6041 case WE_SET_TM_LEVEL:
6042 {
6043 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006044 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6046
6047 break;
6048 }
6049
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306050 case WE_ENABLE_STRICT_FCC_REG:
6051 {
6052 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6053 struct wiphy *wiphy = NULL;
6054 long lrc;
6055 int status;
6056
6057 wiphy = hddCtxt->wiphy;
6058 if(wiphy == NULL)
6059 {
6060 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6061 break;
6062 }
6063 init_completion(&hddCtxt->wiphy_channel_update_event);
6064
6065 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6066
6067 status = regulatory_hint(wiphy, "00");
6068 if(status < 0)
6069 {
6070 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6071 break;
6072 }
6073
6074 /* Wait for completion */
6075 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6076 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6077 if (lrc <= 0)
6078 {
6079 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6080 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6081 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6082 }
6083 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6084
6085 break;
6086 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006087 case WE_SET_DEBUG_LOG:
6088 {
6089 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6090 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306091 if (hHal)
6092 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6093 else
6094 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006095 break;
6096 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306097#ifdef FEATURE_WLAN_TDLS
6098 case WE_SET_TDLS_OFF_CHAN:
6099 {
6100 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6102 __func__, set_value);
6103 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6104 break;
6105 }
6106 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6107 {
6108 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6110 __func__, set_value);
6111 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6112 break;
6113 }
6114 case WE_SET_TDLS_OFF_CHAN_MODE:
6115 {
6116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6117 __func__, set_value);
6118 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6119 break;
6120 }
6121#endif
Peng Xu2446a892014-09-05 17:21:18 +05306122 case WE_SET_SCAN_BAND_PREFERENCE:
6123 {
6124 tSmeConfigParams smeConfig;
6125 memset(&smeConfig, 0x00, sizeof(smeConfig));
6126 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6127 ret = -EINVAL;
6128 break;
6129 }
6130 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6131
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306132 if ((eCSR_BAND_ALL == set_value ||
6133 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6134 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306135 sme_GetConfigParam(hHal, &smeConfig);
6136 smeConfig.csrConfig.scanBandPreference = set_value;
6137
6138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6139 "set band scan preference = %d\n",
6140 smeConfig.csrConfig.scanBandPreference);
6141
6142 sme_UpdateConfig(hHal, &smeConfig);
6143 }
6144 else {
6145 ret = -EINVAL;
6146 }
6147 break;
6148 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306149 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6150 * connection happens so that the params can take effect during
6151 * association. Also this should not be used in STA+p2p concurrency
6152 * as the param will also effect the STA mode.
6153 */
6154 case WE_SET_MIRACAST_VENDOR_CONFIG:
6155 {
6156 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306157
Abhishek Singh01c73d12015-03-12 15:13:44 +05306158 hddLog(LOG1, FL(
6159 "Set Miracast vendor tuning %d"), set_value);
6160
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306161 if (NULL == hHal)
6162 return -EINVAL;
6163
Abhishek Singh01c73d12015-03-12 15:13:44 +05306164 if (1 == set_value || 0 == set_value)
6165 {
6166 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6167 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6168 {
6169 hddLog( LOGE, FL("set vendor miracast config failed"));
6170 ret = -EIO;
6171 }
6172 }
6173 else
6174 {
6175 hddLog(LOGE,
6176 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6177 ret = -EINVAL;
6178 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306179 break;
6180 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306181
6182 case WE_GET_FRAME_LOG:
6183 {
6184 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6185 != VOS_STATUS_SUCCESS)
6186 {
6187 ret = -EINVAL;
6188 }
6189 break;
6190 }
6191
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306192 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6193 {
6194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6195 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306196 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306197 {
6198 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6199 set_value);
6200 }
6201 else
6202 ret = -EINVAL;
6203
6204 break;
6205 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306206 /* Bit mask value to enable RTS/CTS for different modes
6207 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6208 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6209 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6210 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6211 * for 5 GHz, VHT80 - 0x1000
6212 */
6213 case WE_SET_RTS_CTS_HTVHT:
6214 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306215
Abhishek Singh41988ba2015-05-25 19:42:29 +05306216 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6217
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306218 if (NULL == hHal)
6219 return -EINVAL;
6220
Abhishek Singh41988ba2015-05-25 19:42:29 +05306221 if (eHAL_STATUS_SUCCESS !=
6222 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6223 {
6224 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6225 ret = -EINVAL;
6226 }
6227 break;
6228 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306229 case WE_SET_MONITOR_STATE:
6230 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306231 v_U32_t magic = 0;
6232 struct completion cmpVar;
6233 long waitRet = 0;
6234 tVOS_CON_MODE mode = hdd_get_conparam();
6235
6236 if( VOS_MONITOR_MODE != mode)
6237 {
6238 hddLog(LOGE, "invalid mode %d", mode);
6239 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306240 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306241 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306242
6243 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6244 if( pMonCtx == NULL )
6245 {
6246 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306247 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306248 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306249 }
6250 if (pMonCtx->state == set_value)
6251 {
6252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6253 FL("already in same mode curr_mode:%d req_mode: %d"),
6254 pMonCtx->state, set_value);
6255 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306256 }
6257 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306258 magic = MON_MODE_MSG_MAGIC;
6259 init_completion(&cmpVar);
6260 if (VOS_STATUS_SUCCESS !=
6261 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6262 pMonCtx, hdd_monPostMsgCb)) {
6263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6264 FL("failed to post MON MODE REQ"));
6265 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6266 MON_MODE_STOP : MON_MODE_START;
6267 magic = 0;
6268 ret = -EIO;
6269 break;
6270 }
6271 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6272 magic = 0;
6273 if (waitRet <= 0 ){
6274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6275 FL("failed to wait on monitor mode completion %ld"),
6276 waitRet);
6277 }
6278 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306279 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306280 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6281 {
6282 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6283 tAniWifiStartLog start_log;
6284 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6285 !vos_isPktStatsEnabled())
6286 {
6287 hddLog(LOGE, FL("per pkt stats not enabled"));
6288 return -EINVAL;
6289 }
6290 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6291
6292 if (1 == set_value || 0 == set_value)
6293 {
6294 start_log.ringId = RING_ID_PER_PACKET_STATS;
6295 start_log.flag = 0;
6296 if (set_value)
6297 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6298 else
6299 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6300
6301 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6302 }
6303 else
6304 {
6305 hddLog(LOGE,
6306 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6307 set_value);
6308 ret = -EINVAL;
6309 }
6310 break;
6311 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306312 case WE_SET_PROXIMITY_ENABLE:
6313 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306314 if (NULL == hHal)
6315 return -EINVAL;
6316
6317 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306318 break;
6319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 default:
6321 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006322 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 sub_cmd, set_value);
6324 break;
6325 }
6326 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306327 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 return ret;
6329}
6330
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306331static int iw_setint_getnone(struct net_device *dev,
6332 struct iw_request_info *info,
6333 union iwreq_data *wrqu, char *extra)
6334{
6335 int ret;
6336
6337 vos_ssr_protect(__func__);
6338 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6339 vos_ssr_unprotect(__func__);
6340
6341 return 0;
6342}
Jeff Johnson295189b2012-06-20 16:38:30 -07006343/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306344static int __iw_setchar_getnone(struct net_device *dev,
6345 struct iw_request_info *info,
6346 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006347{
6348 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306349 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006351 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306352 hdd_adapter_t *pAdapter;
6353 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006354#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306355 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006356#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306357 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306358 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006359
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306360 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306361
6362 if (!capable(CAP_NET_ADMIN))
6363 {
6364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6365 FL("permission check failed"));
6366 return -EPERM;
6367 }
6368
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306369 pAdapter = (netdev_priv(dev));
6370 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006371 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6373 "%s: Adapter is NULL",__func__);
6374 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006375 }
6376
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306377 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6378 ret = wlan_hdd_validate_context(pHddCtx);
6379 if (0 != ret)
6380 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306381 return ret;
6382 }
6383#ifdef WLAN_FEATURE_VOWIFI
6384 pConfig = pHddCtx->cfg_ini;
6385#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306386 /* helper function to get iwreq_data with compat handling. */
6387 if (hdd_priv_get_data(&s_priv_data, wrqu))
6388 {
6389 return -EINVAL;
6390 }
6391
6392 /* make sure all params are correctly passed to function */
6393 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6394 {
6395 return -EINVAL;
6396 }
6397
6398 sub_cmd = s_priv_data.flags;
6399
Arif Hussain0273cba2014-01-07 20:58:29 -08006400 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306401 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6402 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006403 if (NULL == pBuffer)
6404 {
6405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6406 "mem_alloc_copy_from_user_helper fail");
6407 return -ENOMEM;
6408 }
6409
6410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306411 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6413 "%s: Received data %s", __func__, pBuffer);
6414
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 switch(sub_cmd)
6416 {
6417 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006419 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 break;
6421 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006423 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 break;
6425#if defined WLAN_FEATURE_VOWIFI
6426 case WE_NEIGHBOR_REPORT_REQUEST:
6427 {
6428 tRrmNeighborReq neighborReq;
6429 tRrmNeighborRspCallbackInfo callbackInfo;
6430
6431 if (pConfig->fRrmEnable)
6432 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306434 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 if( !neighborReq.no_ssid )
6436 {
Girish Gowli552fc072014-06-14 18:26:16 +05306437 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006438 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 }
6440
6441 callbackInfo.neighborRspCallback = NULL;
6442 callbackInfo.neighborRspCallbackContext = NULL;
6443 callbackInfo.timeout = 5000; //5 seconds
6444 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6445 }
6446 else
6447 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006448 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006449 ret = -EINVAL;
6450 }
6451 }
6452 break;
6453#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 case WE_SET_AP_WPS_IE:
6455 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306456 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006459 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 if (VOS_STATUS_SUCCESS != vstatus)
6461 {
6462 ret = -EINVAL;
6463 }
6464 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306465 case WE_SET_ENCRYPT_MSG:
6466 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6467 if (NULL == pkt)
6468 {
6469 hddLog(VOS_TRACE_LEVEL_ERROR,
6470 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306471 ret = -ENOMEM;
6472 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306473 }
6474
6475 memset(pkt, 0, sizeof(tSirpkt80211));
6476
6477 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6478 hddLog(VOS_TRACE_LEVEL_ERROR,
6479 FL("Firmware is not DISA capable"));
6480 ret = -EINVAL;
6481 vos_mem_free(pkt);
6482 break;
6483 }
6484
6485 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6486
6487 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6488 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6489 if (eHAL_STATUS_SUCCESS != ret) {
6490 hddLog(VOS_TRACE_LEVEL_ERROR,
6491 FL("SENDEncryptMSG: fail to post WDA cmd"));
6492 ret = -EINVAL;
6493 }
6494 vos_mem_free(pkt);
6495
6496 break;
6497
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 default:
6499 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006500 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 ret = -EINVAL;
6502 break;
6503 }
6504 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006505 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306506
6507 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 return ret;
6509}
6510
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306511static int iw_setchar_getnone(struct net_device *dev,
6512 struct iw_request_info *info,
6513 union iwreq_data *wrqu, char *extra)
6514{
6515 int ret;
6516
6517 vos_ssr_protect(__func__);
6518 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6519 vos_ssr_unprotect(__func__);
6520
6521 return ret;
6522}
6523
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306524static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6525{
6526 struct statsContext *context;
6527 hdd_adapter_t *pAdapter;
6528
6529 if (NULL == pContext)
6530 {
6531 hddLog(VOS_TRACE_LEVEL_ERROR,
6532 "%s: Bad param, pContext [%p]",
6533 __func__, pContext);
6534 return;
6535 }
6536
6537 context = pContext;
6538 pAdapter = context->pAdapter;
6539
6540 spin_lock(&hdd_context_lock);
6541
6542 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6543 {
6544 /* the caller presumably timed out so there is nothing we can do */
6545 spin_unlock(&hdd_context_lock);
6546 hddLog(VOS_TRACE_LEVEL_WARN,
6547 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6548 __func__, pAdapter, context->magic);
6549 return;
6550 }
6551
6552 context->magic = 0;
6553 pAdapter->antennaIndex = antennaId;
6554
6555 complete(&context->completion);
6556 spin_unlock(&hdd_context_lock);
6557}
6558
6559static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6560 int *antennaIndex)
6561{
6562 hdd_context_t *pHddCtx;
6563 eHalStatus halStatus;
6564 struct statsContext context;
6565 long lrc;
6566
6567 ENTER();
6568 if (NULL == pAdapter)
6569 {
6570 hddLog(VOS_TRACE_LEVEL_WARN,
6571 "%s: Invalid context, pAdapter", __func__);
6572 return VOS_STATUS_E_FAULT;
6573 }
6574 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6575 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6576 {
6577 return VOS_STATUS_E_FAULT;
6578 }
6579 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6580 {
6581 hddLog(VOS_TRACE_LEVEL_ERROR,
6582 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6583 __func__);
6584 return VOS_STATUS_E_NOSUPPORT;
6585 }
6586 init_completion(&context.completion);
6587 context.pAdapter = pAdapter;
6588 context.magic = ANTENNA_CONTEXT_MAGIC;
6589
6590 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6591 hdd_GetCurrentAntennaIndex,
6592 &context, pAdapter->sessionId);
6593 if (eHAL_STATUS_SUCCESS != halStatus)
6594 {
6595 spin_lock(&hdd_context_lock);
6596 context.magic = 0;
6597 spin_unlock(&hdd_context_lock);
6598 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6599 __func__);
6600 /* we'll returned a cached value below */
6601 *antennaIndex = -1;
6602 return VOS_STATUS_E_FAILURE;
6603 }
6604 else
6605 {
6606 /* request was sent -- wait for the response */
6607 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6608 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6609 if (lrc <= 0)
6610 {
6611 spin_lock(&hdd_context_lock);
6612 context.magic = 0;
6613 spin_unlock(&hdd_context_lock);
6614 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6615 " Index",
6616 __func__, (0 == lrc) ? "timeout" : "interrupt");
6617 *antennaIndex = -1;
6618 return VOS_STATUS_E_FAILURE;
6619 }
6620 }
6621 spin_lock(&hdd_context_lock);
6622 context.magic = 0;
6623 spin_unlock(&hdd_context_lock);
6624
6625 *antennaIndex = pAdapter->antennaIndex;
6626
6627 EXIT();
6628 return VOS_STATUS_SUCCESS;
6629}
6630
Jeff Johnson295189b2012-06-20 16:38:30 -07006631/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306632static int __iw_setnone_getint(struct net_device *dev,
6633 struct iw_request_info *info,
6634 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006635{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306636 hdd_adapter_t *pAdapter;
6637 tHalHandle hHal;
6638 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 int *value = (int *)extra;
6640 int ret = 0; /* success */
6641
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306642 ENTER();
6643
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306644 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6645 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006646 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6648 "%s: Adapter is NULL",__func__);
6649 return -EINVAL;
6650 }
6651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6652 ret = wlan_hdd_validate_context(pHddCtx);
6653 if (0 != ret)
6654 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306655 return ret;
6656 }
6657 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6658 if (NULL == hHal)
6659 {
6660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6661 "%s: Hal Context is NULL",__func__);
6662 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006664
6665 switch (value[0])
6666 {
6667 case WE_GET_11D_STATE:
6668 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006669 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306671
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6673
Arif Hussain6d2a3322013-11-17 19:50:10 -08006674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006675
6676 break;
6677 }
6678
6679 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 break;
6682
6683 case WE_PMC_STATE:
6684 {
6685 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 break;
6688 }
6689 case WE_GET_WLAN_DBG:
6690 {
6691 vos_trace_display();
6692 *value = 0;
6693 break;
6694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 case WE_GET_MAX_ASSOC:
6696 {
6697 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6698 {
c_hpothub8245442013-11-20 23:41:09 +05306699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6700 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 ret = -EIO;
6702 }
Girish Gowli385be612014-09-18 11:17:20 +05306703#ifdef WLAN_SOFTAP_VSTA_FEATURE
6704 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6705 {
6706 if (*value > VSTA_NUM_ASSOC_STA)
6707 {
6708 *value = VSTA_NUM_ASSOC_STA;
6709 }
6710 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6711 (*value > (VSTA_NUM_ASSOC_STA -
6712 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6713 {
6714 *value = (VSTA_NUM_ASSOC_STA -
6715 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6716 }
6717 }
6718 else
6719#endif
6720 {
6721 if (*value > NUM_ASSOC_STA)
6722 {
6723 *value = NUM_ASSOC_STA;
6724 }
6725 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6726 (*value > (NUM_ASSOC_STA -
6727 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6728 {
6729 *value = (NUM_ASSOC_STA -
6730 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6731 }
6732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 break;
6734 }
6735
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 case WE_GET_WDI_DBG:
6737 {
6738 wpalTraceDisplay();
6739 *value = 0;
6740 break;
6741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006742
6743 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6744 {
6745 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6746 break;
6747 }
6748 case WE_GET_CONCURRENCY_MODE:
6749 {
6750 *value = hdd_get_concurrency_mode ( );
6751
Arif Hussain6d2a3322013-11-17 19:50:10 -08006752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 break;
6754 }
6755
Peng Xu2446a892014-09-05 17:21:18 +05306756 case WE_GET_SCAN_BAND_PREFERENCE:
6757 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306758 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306759 sme_GetConfigParam(hHal, &smeConfig);
6760 *value = smeConfig.csrConfig.scanBandPreference;
6761
6762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6763 "scanBandPreference = %d\n", *value);
6764 break;
6765 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306766 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6767 {
6768 wlan_hdd_get_current_antenna_index(pAdapter, value);
6769 break;
6770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 default:
6772 {
6773 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6774 break;
6775 }
6776 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306777 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 return ret;
6779}
6780
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306781static int iw_setnone_getint(struct net_device *dev,
6782 struct iw_request_info *info,
6783 union iwreq_data *wrqu, char *extra)
6784{
6785 int ret;
6786
6787 vos_ssr_protect(__func__);
6788 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6789 vos_ssr_unprotect(__func__);
6790
6791 return ret;
6792
6793}
Jeff Johnson295189b2012-06-20 16:38:30 -07006794/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306795int __iw_set_three_ints_getnone(struct net_device *dev,
6796 struct iw_request_info *info,
6797 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006798{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306799 hdd_adapter_t *pAdapter;
6800 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 int *value = (int *)extra;
6802 int sub_cmd = value[0];
6803 int ret = 0;
6804
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306805 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306806
6807 if (!capable(CAP_NET_ADMIN))
6808 {
6809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6810 FL("permission check failed"));
6811 return -EPERM;
6812 }
6813
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306814 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6815 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006816 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6818 "%s: Adapter is NULL",__func__);
6819 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006820 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306821 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6822 ret = wlan_hdd_validate_context(pHddCtx);
6823 if (0 != ret)
6824 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306825 return ret;
6826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 switch(sub_cmd)
6828 {
6829 case WE_SET_WLAN_DBG:
6830 {
6831 vos_trace_setValue( value[1], value[2], value[3]);
6832 break;
6833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 case WE_SET_WDI_DBG:
6835 {
6836 wpalTraceSetLevel( value[1], value[2], value[3]);
6837 break;
6838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 case WE_SET_SAP_CHANNELS:
6840 {
6841 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6842 break;
6843 }
6844
6845 default:
6846 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006847 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 break;
6849 }
6850 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306851 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 return ret;
6853}
6854
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306855int iw_set_three_ints_getnone(struct net_device *dev,
6856 struct iw_request_info *info,
6857 union iwreq_data *wrqu, char *extra)
6858{
6859 int ret;
6860
6861 vos_ssr_protect(__func__);
6862 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6863 vos_ssr_unprotect(__func__);
6864
6865 return ret;
6866}
6867
6868static int __iw_get_char_setnone(struct net_device *dev,
6869 struct iw_request_info *info,
6870 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006871{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306872 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306874 hdd_context_t *pHddCtx;
6875 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006876#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006877 hdd_wext_state_t *pWextState;
6878#endif
6879
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306880 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306881 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006882 if (pAdapter == NULL)
6883 {
6884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6885 "%s: pAdapter is NULL!", __func__);
6886 return -EINVAL;
6887 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306888 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6889 ret = wlan_hdd_validate_context(pHddCtx);
6890 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006891 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306892 return ret;
6893 }
6894#ifdef WLAN_FEATURE_11W
6895 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6896 if (NULL == pWextState)
6897 {
6898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6899 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006900 return -EINVAL;
6901 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306902#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006903
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 switch(sub_cmd)
6905 {
6906 case WE_WLAN_VERSION:
6907 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006908 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 break;
6910 }
6911
6912 case WE_GET_STATS:
6913 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306914 tHalHandle hHal = NULL;
6915 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6917 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6918 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6919
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306920
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 snprintf(extra, WE_MAX_STR_LEN,
6922 "\nTransmit"
6923 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6924 "\n dropped BK %u, BE %u, VI %u, VO %u"
6925 "\n classified BK %u, BE %u, VI %u, VO %u"
6926 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6927 "\n queued BK %u, BE %u, VI %u, VO %u"
6928 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006929 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 "\n fetched BK %u, BE %u, VI %u, VO %u"
6931 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6932 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006933 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 "\n flushed BK %u, BE %u, VI %u, VO %u"
6935 "\n\nReceive"
6936 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6937 "\n\nResetsStats"
6938 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6939 "\n",
6940 pStats->txXmitCalled,
6941 pStats->txXmitDropped,
6942 pStats->txXmitBackPressured,
6943 pStats->txXmitQueued,
6944
6945 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6946 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6947 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6948 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6949
6950 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6951 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6952 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6953 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6954
6955 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6956 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6957 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6958 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6959
6960 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6961 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6962 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6963 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6964
6965 pStats->txFetched,
6966 pStats->txFetchEmpty,
6967 pStats->txFetchLowResources,
6968 pStats->txFetchDequeueError,
6969
6970 pStats->txFetchDequeued,
6971 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006972 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 pStats->txCompleted,
6974 pStats->txFlushed,
6975
6976 pStats->txFetchedAC[WLANTL_AC_BK],
6977 pStats->txFetchedAC[WLANTL_AC_BE],
6978 pStats->txFetchedAC[WLANTL_AC_VI],
6979 pStats->txFetchedAC[WLANTL_AC_VO],
6980
6981 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6982 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6983 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6984 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6985
6986 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6987 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6988 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6989 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6990
Ravi Joshi41914632013-10-21 23:02:21 -07006991 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6992 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6993 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6994 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6995
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 pStats->txFlushedAC[WLANTL_AC_BK],
6997 pStats->txFlushedAC[WLANTL_AC_BE],
6998 pStats->txFlushedAC[WLANTL_AC_VI],
6999 pStats->txFlushedAC[WLANTL_AC_VO],
7000
7001 pStats->rxChains,
7002 pStats->rxPackets,
7003 pStats->rxDropped,
7004 pStats->rxDelivered,
7005 pStats->rxRefused,
7006
7007 pResetStats->totalLogpResets,
7008 pResetStats->totalCMD53Failures,
7009 pResetStats->totalMutexReadFailures,
7010 pResetStats->totalMIFErrorFailures,
7011 pResetStats->totalFWHearbeatFailures,
7012 pResetStats->totalUnknownExceptions
7013 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307014 wrqu->data.length = strlen(extra);
7015
7016 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7017
7018 if (hHal)
7019 pMac = PMAC_STRUCT( hHal );
7020
7021 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7022 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7023 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307024 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7025 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7026 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7027 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307028 "\n",
7029 pMac->pmm.BmpscntSleep,
7030 pMac->pmm.BmpscntAwake,
7031 pMac->pmm.BmpsSleeReqFailCnt,
7032 pMac->pmm.BmpsWakeupReqFailCnt,
7033 pMac->pmm.ImpsCntSleep,
7034 pMac->pmm.ImpsCntAwake,
7035 pMac->pmm.ImpsSleepErrCnt,
7036 pMac->pmm.ImpsWakeupErrCnt,
7037 pMac->pmm.ImpsLastErr
7038 );
7039 }
7040
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 wrqu->data.length = strlen(extra)+1;
7042 break;
7043 }
7044
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307045/* The case prints the current state of the HDD, SME, CSR, PE, TL
7046 *it can be extended for WDI Global State as well.
7047 *And currently it only checks P2P_CLIENT adapter.
7048 *P2P_DEVICE and P2P_GO have not been added as of now.
7049*/
7050 case WE_GET_STATES:
7051 {
7052 int buf = 0, len = 0;
7053 int adapter_num = 0;
7054 int count = 0, check = 1;
7055
7056 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007057 tHalHandle hHal = NULL;
7058 tpAniSirGlobal pMac = NULL;
7059 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307060
7061 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7062 hdd_adapter_t *useAdapter = NULL;
7063
7064 /* Print wlan0 or p2p0 states based on the adapter_num
7065 *by using the correct adapter
7066 */
7067 while ( adapter_num < 2 )
7068 {
7069 if ( WLAN_ADAPTER == adapter_num )
7070 {
7071 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007072 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307073 "\n\n wlan0 States:-");
7074 len += buf;
7075 }
7076 else if ( P2P_ADAPTER == adapter_num )
7077 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007078 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307079 "\n\n p2p0 States:-");
7080 len += buf;
7081
7082 if( !pHddCtx )
7083 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007084 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307085 "\n pHddCtx is NULL");
7086 len += buf;
7087 break;
7088 }
7089
7090 /*Printing p2p0 states only in the case when the device is
7091 configured as a p2p_client*/
7092 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7093 if ( !useAdapter )
7094 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007095 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307096 "\n Device not configured as P2P_CLIENT.");
7097 len += buf;
7098 break;
7099 }
7100 }
7101
7102 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007103 if (!hHal) {
7104 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7105 "\n pMac is NULL");
7106 len += buf;
7107 break;
7108 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307109 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007110 if (!pMac) {
7111 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7112 "\n pMac is NULL");
7113 len += buf;
7114 break;
7115 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307116 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7117 if( !pHddStaCtx )
7118 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007119 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307120 "\n pHddStaCtx is NULL");
7121 len += buf;
7122 break;
7123 }
7124
7125 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7126
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007127 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307128 "\n HDD Conn State - %s "
7129 "\n \n SME State:"
7130 "\n Neighbour Roam State - %s"
7131 "\n CSR State - %s"
7132 "\n CSR Substate - %s"
7133 "\n \n TL STA %d State: %s",
7134 macTraceGetHDDWlanConnState(
7135 pHddStaCtx->conn_info.connState),
7136 macTraceGetNeighbourRoamState(
7137 pMac->roam.neighborRoamInfo.neighborRoamState),
7138 macTraceGetcsrRoamState(
7139 pMac->roam.curState[useAdapter->sessionId]),
7140 macTraceGetcsrRoamSubState(
7141 pMac->roam.curSubState[useAdapter->sessionId]),
7142 pHddStaCtx->conn_info.staId[0],
7143 macTraceGetTLState(tlState)
7144 );
7145 len += buf;
7146 adapter_num++;
7147 }
7148
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007149 if (pMac) {
7150 /* Printing Lim State starting with global lim states */
7151 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7152 "\n \n LIM STATES:-"
7153 "\n Global Sme State - %s "\
7154 "\n Global mlm State - %s "\
7155 "\n",
7156 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7157 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7158 );
7159 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307160
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007161 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307162 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307163 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007164 if ( pMac->lim.gpSession[count].valid )
7165 {
7166 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7167 "\n Lim Valid Session %d:-"
7168 "\n PE Sme State - %s "
7169 "\n PE Mlm State - %s "
7170 "\n",
7171 check,
7172 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7173 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7174 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307175
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007176 len += buf;
7177 check++;
7178 }
7179 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307180 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307181 }
7182
7183 wrqu->data.length = strlen(extra)+1;
7184 break;
7185 }
7186
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 case WE_GET_CFG:
7188 {
7189 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7190 wrqu->data.length = strlen(extra)+1;
7191 break;
7192 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007193#ifdef WLAN_FEATURE_11AC
7194 case WE_GET_RSSI:
7195 {
7196 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307197 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007198 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7199 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7200 wrqu->data.length = strlen(extra)+1;
7201 break;
7202 }
7203#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307204
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007205#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007206 case WE_GET_ROAM_RSSI:
7207 {
7208 v_S7_t s7Rssi = 0;
7209 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7210 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7211 wrqu->data.length = strlen(extra)+1;
7212 break;
7213 }
7214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 case WE_GET_WMM_STATUS:
7216 {
7217 snprintf(extra, WE_MAX_STR_LEN,
7218 "\nDir: 0=up, 1=down, 3=both\n"
7219 "|------------------------|\n"
7220 "|AC | ACM |Admitted| Dir |\n"
7221 "|------------------------|\n"
7222 "|VO | %d | %3s | %d |\n"
7223 "|VI | %d | %3s | %d |\n"
7224 "|BE | %d | %3s | %d |\n"
7225 "|BK | %d | %3s | %d |\n"
7226 "|------------------------|\n",
7227 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7228 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7229 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7230 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7231 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7232 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7233 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7234 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7235 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7236 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7237 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7238 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7239
Jeff Johnsone7245742012-09-05 17:12:55 -07007240
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 wrqu->data.length = strlen(extra)+1;
7242 break;
7243 }
7244 case WE_GET_CHANNEL_LIST:
7245 {
7246 VOS_STATUS status;
7247 v_U8_t i, len;
7248 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307249 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7250 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7251 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 tChannelListInfo channel_list;
7253
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007254 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007256 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007258 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 return -EINVAL;
7260 }
7261 buf = extra;
7262
7263 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007264 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7265 * needed = 5 * number of channels. Check ifsufficient
7266 * buffer is available and then proceed to fill the buffer.
7267 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7269 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007270 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007271 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007272 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 return -EINVAL;
7274 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007275 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7276 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307277 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7278 {
7279 //Printing Country code in getChannelList
7280 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7281 {
7282 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7283 "%c ", pBuf[i]);
7284 }
7285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 for(i = 0 ; i < channel_list.num_channels; i++)
7287 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007288 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 }
7291 wrqu->data.length = strlen(extra)+1;
7292
7293 break;
7294 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007295#ifdef FEATURE_WLAN_TDLS
7296 case WE_GET_TDLS_PEERS:
7297 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007298 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007299 break;
7300 }
7301#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007302#ifdef WLAN_FEATURE_11W
7303 case WE_GET_11W_INFO:
7304 {
7305 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7306
7307 snprintf(extra, WE_MAX_STR_LEN,
7308 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7309 "\n Number of Unprotected Disassocs %d"
7310 "\n Number of Unprotected Deauths %d",
7311 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7312 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7313 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7314 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7315 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7316
7317 wrqu->data.length = strlen(extra)+1;
7318 break;
7319 }
7320#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307321#ifdef WLAN_FEATURE_RMC
7322 case WE_GET_IBSS_STA_INFO:
7323 {
7324 hdd_station_ctx_t *pHddStaCtx =
7325 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7326 int idx = 0;
7327 int length = 0, buf = 0;
7328
7329 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7330 {
7331 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7332 {
7333 buf = snprintf
7334 (
7335 (extra + length), WE_MAX_STR_LEN - length,
7336 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7337 pHddStaCtx->conn_info.staId[ idx ],
7338 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7339 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7340 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7341 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7342 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7343 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7344 );
7345 length += buf;
7346 }
7347 }
7348 wrqu->data.length = strlen(extra)+1;
7349 break;
7350 }
7351#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307352 case WE_GET_SNR:
7353 {
7354 v_S7_t s7snr = 0;
7355 int status = 0;
7356 hdd_context_t *pHddCtx;
7357 hdd_station_ctx_t *pHddStaCtx;
7358
7359 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7360 status = wlan_hdd_validate_context(pHddCtx);
7361 if (0 != status)
7362 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307363 return status;
7364 }
7365
7366 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7367
7368 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7369 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7370 {
7371 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7372 " ConnectionState-%d", __func__,
7373 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7374 pHddStaCtx->conn_info.connState);
7375 return -ENONET;
7376 }
7377
7378 /*update the stats in TL*/
7379 wlan_hdd_get_station_stats(pAdapter);
7380 wlan_hdd_get_snr(pAdapter, &s7snr);
7381 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7382 wrqu->data.length = strlen(extra) + 1;
7383 break;
7384 }
7385
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307386#ifdef FEATURE_OEM_DATA_SUPPORT
7387 case WE_GET_OEM_DATA_CAP:
7388 {
7389 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7390 }
7391#endif /* FEATURE_OEM_DATA_SUPPORT */
7392
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307393 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007395 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 break;
7397 }
7398 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307399 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 return 0;
7401}
7402
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307403static int iw_get_char_setnone(struct net_device *dev,
7404 struct iw_request_info *info,
7405 union iwreq_data *wrqu, char *extra)
7406{
7407 int ret;
7408
7409 vos_ssr_protect(__func__);
7410 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7411 vos_ssr_unprotect(__func__);
7412
7413 return ret;
7414}
7415
Jeff Johnson295189b2012-06-20 16:38:30 -07007416/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307417static int __iw_setnone_getnone(struct net_device *dev,
7418 struct iw_request_info *info,
7419 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007420{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307421 hdd_adapter_t *pAdapter;
7422 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307423 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007424 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307425 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307427 ENTER();
7428
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307429 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7430 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007431 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7433 "%s: Adapter is NULL",__func__);
7434 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007435 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307436 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7437 ret = wlan_hdd_validate_context(pHddCtx);
7438 if (0 != ret)
7439 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307440 return ret;
7441 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307442 /* helper function to get iwreq_data with compat handling. */
7443 if (hdd_priv_get_data(&s_priv_data, wrqu))
7444 {
7445 return -EINVAL;
7446 }
7447
7448 sub_cmd = s_priv_data.flags;
7449
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 switch (sub_cmd)
7451 {
7452 case WE_CLEAR_STATS:
7453 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7456 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7457 break;
7458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 case WE_INIT_AP:
7460 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307461 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7462
7463 /* As Soft AP mode might been changed to STA already with
7464 * killing of Hostapd, need to find the adpater by name
7465 * rather than mode */
7466 hdd_adapter_t* pAdapter_to_stop =
7467 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7468 if( pAdapter_to_stop )
7469 {
7470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7471 "Adapter with name softap.0 already "
7472 "exist, ignoring the request.\nRemove the "
7473 "adapter and try again\n");
7474 break;
7475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 pr_info("Init AP trigger\n");
7477 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7478 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7479 break;
7480 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307481#ifdef WLAN_FEATURE_RMC
7482 case WE_IBSS_GET_PEER_INFO_ALL:
7483 {
7484 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7485 break;
7486 }
7487#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 case WE_STOP_AP:
7489 {
7490 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7491 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7492 * this is a dead code and need to find the adpater by name rather than mode */
7493 hdd_adapter_t* pAdapter_to_stop =
7494 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7495 if( pAdapter_to_stop )
7496 {
7497 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7498
7499 pr_info("Stopping AP mode\n");
7500
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307501 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7502 {
7503 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7504 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7505 }
7506
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307508 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307509 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7511
7512 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7513 pAdapter_to_stop->macAddressCurrent.bytes);
7514 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7515 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307516
7517 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7518 {
7519 /* put the device back into BMPS */
7520 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007522 }
7523 else
7524 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007525 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 }
7527
7528 break;
7529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007530#ifdef WLAN_BTAMP_FEATURE
7531 case WE_ENABLE_AMP:
7532 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007534 WLANBAP_RegisterWithHCI(pAdapter);
7535 break;
7536 }
7537 case WE_DISABLE_AMP:
7538 {
7539 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7540 VOS_STATUS status;
7541
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007543
7544 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7545 status = WLANBAP_StopAmp();
7546 if(VOS_STATUS_SUCCESS != status )
7547 {
7548 pHddCtx->isAmpAllowed = VOS_TRUE;
7549 hddLog(VOS_TRACE_LEVEL_FATAL,
7550 "%s: Failed to stop AMP", __func__);
7551 }
7552 else
7553 {
7554 //a state m/c implementation in PAL is TBD to avoid this delay
7555 msleep(500);
7556 pHddCtx->isAmpAllowed = VOS_FALSE;
7557 WLANBAP_DeregisterFromHCI();
7558 }
7559
7560 break;
7561 }
7562#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007563 case WE_ENABLE_DXE_STALL_DETECT:
7564 {
schang6295e542013-03-12 15:31:23 -07007565 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7566 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007567 break;
7568 }
7569 case WE_DISPLAY_DXE_SNAP_SHOT:
7570 {
schang6295e542013-03-12 15:31:23 -07007571 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7572 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007573 break;
7574 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307575 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7576 {
7577 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7578 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307579 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307580 break;
7581 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307582
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307583 case WE_SET_REASSOC_TRIGGER:
7584 {
7585 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7586 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7587 v_U32_t roamId = 0;
7588 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307589 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7590 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307591 return 0;
7592 }
7593
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307594 case WE_STOP_OBSS_SCAN:
7595 {
7596 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7597 2.OBSS scan is stopped by Firmware during the disassociation
7598 3.OBSS stop comamnd is added for debugging purpose*/
7599 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7600 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007601
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307602 if (pAdapter == NULL)
7603 {
7604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307606 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307607 }
7608 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7609 if (pMac == NULL)
7610 {
7611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7612 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307613 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307614 }
7615 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7616 }
7617 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307618 case WE_DUMP_ROAM_TIMER_LOG:
7619 {
7620 vos_dump_roam_time_log_service();
7621 break;
7622 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307623
Mukul Sharma84f27252014-07-14 18:11:42 +05307624 case WE_RESET_ROAM_TIMER_LOG:
7625 {
7626 vos_reset_roam_timer_log();
7627 break;
7628 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307629 case WE_GET_FW_LOGS:
7630 {
7631 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7632 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307633 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307634 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307635 break;
7636 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307637 case WE_GET_FW_MEMDUMP:
7638 {
7639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7640 "FW_MEM_DUMP requested ");
7641 get_fwr_memdump(dev,info,wrqu,extra);
7642 break;
7643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 default:
7645 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007646 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 break;
7648 }
7649 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307650 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 return ret;
7652}
7653
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307654static int iw_setnone_getnone(struct net_device *dev,
7655 struct iw_request_info *info,
7656 union iwreq_data *wrqu, char *extra)
7657{
7658 int ret;
7659
7660 vos_ssr_protect(__func__);
7661 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7662 vos_ssr_unprotect(__func__);
7663
7664 return ret;
7665}
7666
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307667void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7668{
7669 /*
7670 * Function to display HDD WMM information
7671 * for Tx Queues.
7672 * Prints globala as well as per client depending
7673 * whether the clients are registered or not.
7674 */
7675 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307676 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7677 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307678 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7679 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307680 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307681
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307682 for ( i=0; i< NUM_TX_QUEUES; i++)
7683 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307684 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307685 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307686 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307687 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307688
7689 for ( i=0; i< NUM_TX_QUEUES; i++) {
7690 if (tx_queue_count[i]) {
7691 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7692 i, tx_queue_count[i]);
7693 }
7694 }
7695
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307696 if(pSapCtx == NULL){
7697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7698 FL("psapCtx is NULL"));
7699 return;
7700 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307701
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307702 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307703 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7704 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307705 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307706 {
7707 hddLog(LOGE, "******STAIndex: %d*********", i);
7708 for ( j=0; j< NUM_TX_QUEUES; j++)
7709 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307710 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7711 {
7712 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307713 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7714 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307715 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7716 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307717 }
7718 }
7719 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307720 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307721
Katya Nigam1fd24402015-02-16 14:52:19 +05307722 if(pHddStaCtx == NULL){
7723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7724 FL("pHddStaCtx is NULL"));
7725 return;
7726 }
7727
7728 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7729 if(pPeerInfo == NULL){
7730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7731 FL("ppeerinfo is NULL"));
7732 return;
7733 }
7734
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307735 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7736 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7737 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7738 for (j = 0; j < NUM_TX_QUEUES; j++) {
7739 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7740 spin_lock_bh(
7741 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7742 hddLog(LOGE,
7743 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7744 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7745 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7746 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7747 spin_unlock_bh(
7748 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7749 }
7750 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307751 }
7752 }
7753
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307754}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307755
Girish Gowlifb9758e2014-11-19 15:19:17 +05307756static int __iw_set_var_ints_getnone(struct net_device *dev,
7757 struct iw_request_info *info,
7758 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007759{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307760 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307761 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307762 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307763 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007764 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307765 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307766 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007767 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307768 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007769 int cmd = 0;
7770 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307771 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007772
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307773 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307774 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307775 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7777 "%s: NULL extra buffer pointer", __func__);
7778 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307779 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307780 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7781 if (NULL == pAdapter)
7782 {
7783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7784 "%s: Adapter is NULL",__func__);
7785 return -EINVAL;
7786 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307787 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307788 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7789 ret = wlan_hdd_validate_context(pHddCtx);
7790 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007791 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307792 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007793 }
Katya Nigameae74b62015-05-28 17:19:16 +05307794 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307795 {
Katya Nigameae74b62015-05-28 17:19:16 +05307796 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7797 if (NULL == hHal)
7798 {
7799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7800 "%s: Hal Context is NULL",__func__);
7801 return -EINVAL;
7802 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307803 }
7804 sub_cmd = wrqu->data.flags;
7805
7806 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7807
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007808
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007809 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7810 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7811 {
7812 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7813 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7814 {
7815 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7816 staId = pStaCtx->conn_info.staId[0];
7817 }
7818 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7819 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7820 {
7821 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7822 staId = pAPCtx->uBCStaId;
7823 }
7824 else
7825 {
7826 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7827 return 0;
7828 }
7829 }
7830
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 switch (sub_cmd)
7832 {
7833 case WE_LOG_DUMP_CMD:
7834 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307835 if(apps_args[0] == 26) {
7836 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7837 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7838 return 0;
7839 }
7840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007842 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307844 if (hHal)
7845 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7846 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007847
7848 }
7849 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307850#ifdef WLAN_FEATURE_RMC
7851 case WE_IBSS_GET_PEER_INFO:
7852 {
7853 pr_info ( "Station ID = %d\n",apps_args[0]);
7854 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7855 }
7856 break;
7857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007858
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 case WE_P2P_NOA_CMD:
7860 {
7861 p2p_app_setP2pPs_t p2pNoA;
7862
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307863 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7864 hddLog(LOGE,
7865 FL("Setting NoA is not allowed in Device mode:%d"),
7866 pAdapter->device_mode);
7867 return -EINVAL;
7868 }
7869
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 p2pNoA.opp_ps = apps_args[0];
7871 p2pNoA.ctWindow = apps_args[1];
7872 p2pNoA.duration = apps_args[2];
7873 p2pNoA.interval = apps_args[3];
7874 p2pNoA.count = apps_args[4];
7875 p2pNoA.single_noa_duration = apps_args[5];
7876 p2pNoA.psSelection = apps_args[6];
7877
7878 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7879 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007880 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007881 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7882
7883 hdd_setP2pPs(dev, &p2pNoA);
7884
7885 }
7886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307888 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7889 {
7890 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7891 __func__, apps_args[0], apps_args[1]);
7892 vosTraceEnable(apps_args[0], apps_args[1]);
7893 }
7894 break;
7895
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007896 case WE_MTRACE_DUMP_CMD:
7897 {
7898 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7899 "bitmask_of_module %d ",
7900 __func__, apps_args[0], apps_args[1], apps_args[2],
7901 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307902 if (hHal)
7903 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7904 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007905
7906 }
7907 break;
7908
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007909 case WE_MCC_CONFIG_CREDENTIAL :
7910 {
7911 cmd = 287; //Command should be updated if there is any change
7912 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007913 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007914 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307915 if (hHal)
7916 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7917 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007918 }
7919 else
7920 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007921 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007922 return 0;
7923 }
7924 }
7925 break;
7926
7927 case WE_MCC_CONFIG_PARAMS :
7928 {
7929 cmd = 288; //command Should be updated if there is any change
7930 // in the Riva dump command
7931 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7932 }
7933 break;
7934
Chilam NG571c65a2013-01-19 12:27:36 +05307935#ifdef FEATURE_WLAN_TDLS
7936 case WE_TDLS_CONFIG_PARAMS :
7937 {
7938 tdls_config_params_t tdlsParams;
7939
Chilam Ng01120412013-02-19 18:32:21 -08007940 tdlsParams.tdls = apps_args[0];
7941 tdlsParams.tx_period_t = apps_args[1];
7942 tdlsParams.tx_packet_n = apps_args[2];
7943 tdlsParams.discovery_period_t = apps_args[3];
7944 tdlsParams.discovery_tries_n = apps_args[4];
7945 tdlsParams.idle_timeout_t = apps_args[5];
7946 tdlsParams.idle_packet_n = apps_args[6];
7947 tdlsParams.rssi_hysteresis = apps_args[7];
7948 tdlsParams.rssi_trigger_threshold = apps_args[8];
7949 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307950
Chilam Ng01120412013-02-19 18:32:21 -08007951 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307952 }
7953 break;
7954#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307955 case WE_CONFIGURE_MONITOR_MODE:
7956 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307957 v_U32_t magic = 0;
7958 struct completion cmpVar;
7959 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307960 tVOS_CON_MODE mode = hdd_get_conparam();
7961
7962 if (VOS_MONITOR_MODE != mode) {
7963 hddLog(LOGE, FL("invalid mode %d"), mode);
7964 return -EIO;
7965 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307966
Katya Nigamf0511f62015-05-05 16:40:57 +05307967 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7968 if( pMonCtx == NULL )
7969 {
7970 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307971 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307972 }
7973 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7974 __func__, apps_args[0], apps_args[1], apps_args[2],
7975 apps_args[3], apps_args[4]);
7976 /* Input Validation part of FW */
7977 pMonCtx->ChannelNo = apps_args[0];
7978 pMonCtx->ChannelBW = apps_args[1];
7979 pMonCtx->crcCheckEnabled = apps_args[2];
7980 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7981 pMonCtx->is80211to803ConReq = apps_args[4];
7982 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7983 if( pMonCtx->is80211to803ConReq )
7984 pAdapter->dev->type = ARPHRD_ETHER;
7985 else
7986 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7987 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7988 {
7989 hddLog(LOGE, "%s: Filtering data packets as management and control"
7990 " cannot be converted to 802.3 ",__func__);
7991 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7992 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307993 if (MON_MODE_START == pMonCtx->state) {
7994 magic = MON_MODE_MSG_MAGIC;
7995 init_completion(&cmpVar);
7996 if (VOS_STATUS_SUCCESS !=
7997 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7998 pMonCtx, hdd_monPostMsgCb)) {
7999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8000 FL("failed to post MON MODE REQ"));
8001 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308002 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308003 }
8004 waitRet = wait_for_completion_timeout(&cmpVar,
8005 MON_MODE_MSG_TIMEOUT);
8006 magic = 0;
8007 if (waitRet <= 0 ) {
8008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8009 FL("failed to wait on monitor mode completion %ld"),
8010 waitRet);
8011 }
8012 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308013 }
8014 break;
8015
8016 case WE_SET_MONITOR_MODE_FILTER:
8017 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308018 v_U32_t magic = 0;
8019 struct completion cmpVar;
8020 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308021 tVOS_CON_MODE mode = hdd_get_conparam();
8022
8023 if (VOS_MONITOR_MODE != mode) {
8024 hddLog(LOGE, FL("invalid mode %d"), mode);
8025 return -EIO;
8026 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308027
Katya Nigamf0511f62015-05-05 16:40:57 +05308028 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8029 if( pMonCtx == NULL )
8030 {
8031 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308032 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308033 }
8034 /* Input Validation Part of FW */
8035 pMonCtx->numOfMacFilters=1;
8036 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8037 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8038 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8039 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8040 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8041 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8042 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8043 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8044 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8045 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8046 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8047 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308048 if (MON_MODE_START == pMonCtx->state) {
8049 magic = MON_MODE_MSG_MAGIC;
8050 init_completion(&cmpVar);
8051 if (VOS_STATUS_SUCCESS !=
8052 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8053 pMonCtx, hdd_monPostMsgCb)) {
8054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8055 FL("failed to post MON MODE REQ"));
8056 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308057 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308058 }
8059 waitRet = wait_for_completion_timeout(&cmpVar,
8060 MON_MODE_MSG_TIMEOUT);
8061 magic = 0;
8062 if (waitRet <= 0 ) {
8063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8064 FL("failed to wait on monitor mode completion %ld"),
8065 waitRet);
8066 }
8067 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308068 }
8069 break;
8070
Jeff Johnson295189b2012-06-20 16:38:30 -07008071 default:
8072 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008073 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8074 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 }
8076 break;
8077 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308078 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 return 0;
8080}
8081
Girish Gowlifb9758e2014-11-19 15:19:17 +05308082static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8083 struct iw_request_info *info,
8084 union iwreq_data *wrqu, char *extra)
8085{
8086 int ret;
8087 union iwreq_data u_priv_wrqu;
8088 int apps_args[MAX_VAR_ARGS] = {0};
8089 int num_args;
8090
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308091 if (!capable(CAP_NET_ADMIN))
8092 {
8093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8094 FL("permission check failed"));
8095 return -EPERM;
8096 }
8097
Girish Gowlifb9758e2014-11-19 15:19:17 +05308098 /* helper function to get iwreq_data with compat handling. */
8099 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8100 {
8101 return -EINVAL;
8102 }
8103
8104 if (NULL == u_priv_wrqu.data.pointer)
8105 {
8106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8107 "%s: NULL data pointer", __func__);
8108 return -EINVAL;
8109 }
8110
8111 num_args = u_priv_wrqu.data.length;
8112 if (num_args > MAX_VAR_ARGS)
8113 {
8114 num_args = MAX_VAR_ARGS;
8115 }
8116
8117 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8118 (sizeof(int)) * num_args))
8119 {
8120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8121 "%s: failed to copy data from user buffer", __func__);
8122 return -EFAULT;
8123 }
8124
8125 vos_ssr_protect(__func__);
8126 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8127 (char *)&apps_args);
8128 vos_ssr_unprotect(__func__);
8129
8130 return ret;
8131}
8132
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308133int iw_set_var_ints_getnone(struct net_device *dev,
8134 struct iw_request_info *info,
8135 union iwreq_data *wrqu, char *extra)
8136{
8137 int ret;
8138 vos_ssr_protect(__func__);
8139 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8140 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008141
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308142 return ret;
8143}
8144
8145static int __iw_add_tspec(struct net_device *dev,
8146 struct iw_request_info *info,
8147 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008148{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308149 hdd_adapter_t *pAdapter;
8150 hdd_station_ctx_t *pHddStaCtx;
8151 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8153 int params[HDD_WLAN_WMM_PARAM_COUNT];
8154 sme_QosWmmTspecInfo tSpec;
8155 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308156 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308157 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008158
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308159 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308160 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8161 if (NULL == pAdapter)
8162 {
8163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8164 "%s: Adapter is NULL",__func__);
8165 return -EINVAL;
8166 }
8167 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8168 ret = wlan_hdd_validate_context(pHddCtx);
8169 if (0 != ret)
8170 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308171 return ret;
8172 }
8173 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8174 if (NULL == pHddStaCtx)
8175 {
8176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8177 "%s: STA Context is NULL",__func__);
8178 return -EINVAL;
8179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 // make sure the application is sufficiently priviledged
8181 // note that the kernel will do this for "set" ioctls, but since
8182 // this ioctl wants to return status to user space it must be
8183 // defined as a "get" ioctl
8184 if (!capable(CAP_NET_ADMIN))
8185 {
8186 return -EPERM;
8187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 // we must be associated in order to add a tspec
8189 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8190 {
8191 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8192 return 0;
8193 }
8194
8195 // since we are defined to be a "get" ioctl, and since the number
8196 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308197 // will pass down in the iwreq_data, we must copy the "set" params.
8198 // We must handle the compat for iwreq_data in 32U/64K environment.
8199
8200 // helper fucntion to get iwreq_data with compat handling.
8201 if (hdd_priv_get_data(&s_priv_data, wrqu))
8202 {
8203 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8204 return 0;
8205 }
8206
8207 // make sure all params are correctly passed to function
8208 if ((NULL == s_priv_data.pointer) ||
8209 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8210 {
8211 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8212 return 0;
8213 }
8214
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308216 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 {
8218 // hmmm, can't get them
8219 return -EIO;
8220 }
8221
8222 // clear the tspec
8223 memset(&tSpec, 0, sizeof(tSpec));
8224
8225 // validate the handle
8226 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8227 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8228 {
8229 // that one is reserved
8230 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8231 return 0;
8232 }
8233
8234 // validate the TID
8235 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8236 {
8237 // out of range
8238 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8239 return 0;
8240 }
8241 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8242
8243 // validate the direction
8244 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8245 {
8246 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8247 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8248 break;
8249
8250 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8251 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8252 break;
8253
8254 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8255 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8256 break;
8257
8258 default:
8259 // unknown
8260 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8261 return 0;
8262 }
8263
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308264 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8265
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 // validate the user priority
8267 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8268 {
8269 // out of range
8270 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8271 return 0;
8272 }
8273 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308274 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8275 {
8276 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8277 return 0;
8278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008279
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8281 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8282 tSpec.ts_info.psb, tSpec.ts_info.up);
8283
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8285 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8286 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8287 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8288 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8289 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8290 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8291 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8292 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8293 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8294 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8295 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8296
8297 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8298
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308299 // Save the expected UAPSD settings by application, this will be needed
8300 // when re-negotiating UAPSD settings during BT Coex cases.
8301 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8302
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 // validate the ts info ack policy
8304 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8305 {
8306 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8307 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8308 break;
8309
8310 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8311 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8312 break;
8313
8314 default:
8315 // unknown
8316 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8317 return 0;
8318 }
8319
8320 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308321
8322 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 return 0;
8324}
8325
8326
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308327static int iw_add_tspec(struct net_device *dev,
8328 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008329 union iwreq_data *wrqu, char *extra)
8330{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308331 int ret;
8332
8333 vos_ssr_protect(__func__);
8334 ret = __iw_add_tspec(dev, info, wrqu, extra);
8335 vos_ssr_unprotect(__func__);
8336
8337 return ret;
8338}
8339
8340static int __iw_del_tspec(struct net_device *dev,
8341 struct iw_request_info *info,
8342 union iwreq_data *wrqu, char *extra)
8343{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308344 hdd_adapter_t *pAdapter;
8345 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 int *params = (int *)extra;
8347 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8348 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308349 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008350
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308351 ENTER();
8352
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308353 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8354 if (NULL == pAdapter)
8355 {
8356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8357 "%s: Adapter is NULL",__func__);
8358 return -EINVAL;
8359 }
8360
8361 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8362 ret = wlan_hdd_validate_context(pHddCtx);
8363 if (0 != ret)
8364 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308365 return ret;
8366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 // make sure the application is sufficiently priviledged
8368 // note that the kernel will do this for "set" ioctls, but since
8369 // this ioctl wants to return status to user space it must be
8370 // defined as a "get" ioctl
8371 if (!capable(CAP_NET_ADMIN))
8372 {
8373 return -EPERM;
8374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 // although we are defined to be a "get" ioctl, the params we require
8376 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8377 // is no need to copy the params from user space
8378
8379 // validate the handle
8380 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8381 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8382 {
8383 // that one is reserved
8384 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8385 return 0;
8386 }
8387
8388 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308389
8390 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 return 0;
8392}
8393
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308394static int iw_del_tspec(struct net_device *dev,
8395 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 union iwreq_data *wrqu, char *extra)
8397{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308398 int ret;
8399
8400 vos_ssr_protect(__func__);
8401 ret = __iw_del_tspec(dev, info, wrqu, extra);
8402 vos_ssr_unprotect(__func__);
8403
8404 return ret;
8405}
8406
8407
8408static int __iw_get_tspec(struct net_device *dev,
8409 struct iw_request_info *info,
8410 union iwreq_data *wrqu, char *extra)
8411{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308412 hdd_adapter_t *pAdapter;
8413 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 int *params = (int *)extra;
8415 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8416 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308417 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008418
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308419 ENTER();
8420
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 // although we are defined to be a "get" ioctl, the params we require
8422 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8423 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308424 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8425 if (NULL == pAdapter)
8426 {
8427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8428 "%s: Adapter is NULL",__func__);
8429 return -EINVAL;
8430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008431
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308432 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8433 ret = wlan_hdd_validate_context(pHddCtx);
8434 if (0 != ret)
8435 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308436 return ret;
8437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 // validate the handle
8439 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8440 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8441 {
8442 // that one is reserved
8443 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8444 return 0;
8445 }
8446
8447 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308448 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 return 0;
8450}
8451
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308452static int iw_get_tspec(struct net_device *dev,
8453 struct iw_request_info *info,
8454 union iwreq_data *wrqu, char *extra)
8455{
8456 int ret;
8457
8458 vos_ssr_protect(__func__);
8459 ret = __iw_get_tspec(dev, info, wrqu, extra);
8460 vos_ssr_unprotect(__func__);
8461
8462 return ret;
8463}
8464
Jeff Johnson295189b2012-06-20 16:38:30 -07008465#ifdef WLAN_FEATURE_VOWIFI_11R
8466//
8467//
8468// Each time the supplicant has the auth_request or reassoc request
8469// IEs ready. This is pushed to the driver. The driver will inturn use
8470// it to send out the auth req and reassoc req for 11r FT Assoc.
8471//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308472static int __iw_set_fties(struct net_device *dev,
8473 struct iw_request_info *info,
8474 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008475{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308476 hdd_adapter_t *pAdapter;
8477 hdd_station_ctx_t *pHddStaCtx;
8478 hdd_context_t *pHddCtx;
8479 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 //v_CONTEXT_t pVosContext;
8481
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308482 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308483 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8484 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008485 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8487 "%s: Adapter is NULL",__func__);
8488 return -EINVAL;
8489 }
8490 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8491 ret = wlan_hdd_validate_context(pHddCtx);
8492 if (0 != ret)
8493 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308494 return ret;
8495 }
8496 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8497 if (NULL == pHddStaCtx)
8498 {
8499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8500 "%s: STA Context is NULL",__func__);
8501 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 if (!wrqu->data.length)
8504 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008505 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 return -EINVAL;
8507 }
8508 if (wrqu->data.pointer == NULL)
8509 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008510 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 return -EINVAL;
8512 }
8513
8514 // Added for debug on reception of Re-assoc Req.
8515 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8516 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008517 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008519 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 }
8521
8522#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008523 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008524#endif
8525
8526 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008527 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 wrqu->data.length);
8529
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308530 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 return 0;
8532}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308533
8534static int iw_set_fties(struct net_device *dev,
8535 struct iw_request_info *info,
8536 union iwreq_data *wrqu, char *extra)
8537{
8538 int ret;
8539
8540 vos_ssr_protect(__func__);
8541 ret = __iw_set_fties(dev, info, wrqu, extra);
8542 vos_ssr_unprotect(__func__);
8543
8544 return ret;
8545}
Jeff Johnson295189b2012-06-20 16:38:30 -07008546#endif
8547
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308548static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008549 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008551{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308552 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008553 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308554 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008555 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308556 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008557 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8558 int idx;
8559 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308561 ENTER();
8562
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308563 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8564 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008565 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8567 "%s: Adapter is NULL",__func__);
8568 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008569 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8571 ret_val = wlan_hdd_validate_context(pHddCtx);
8572 if (0 != ret_val)
8573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308574 return ret_val;
8575 }
8576 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8577 if (NULL == hHal)
8578 {
8579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8580 "%s: Hal Context is NULL",__func__);
8581 return -EINVAL;
8582 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308583 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8584 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308585#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008586
Amar Singhalf3a6e762013-02-19 15:06:50 -08008587 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8588 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008589 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008590 hddLog(VOS_TRACE_LEVEL_ERROR,
8591 "%s: vos_mem_alloc failed", __func__);
8592 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008593 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008594
8595 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8596
8597 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8598 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8599
8600 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8601 mc_addr_list_ptr->ulMulticastAddrCnt);
8602
8603 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008604 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008605 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8606 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8607
8608 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8609 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008610 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008611
Amar Singhalf3a6e762013-02-19 15:06:50 -08008612 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8613 vos_mem_free(mc_addr_list_ptr);
8614 if (eHAL_STATUS_SUCCESS != ret_val)
8615 {
8616 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8617 __func__);
8618 return -EINVAL;
8619 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308620#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308621 }
8622 else
8623 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008624
Amar Singhalf3a6e762013-02-19 15:06:50 -08008625 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8626 "%s: Set MC BC Filter Config request: %d suspend %d",
8627 __func__, pRequest->mcastBcastFilterSetting,
8628 pHddCtx->hdd_wlan_suspended);
8629
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308630 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008631
8632 if (pHddCtx->hdd_wlan_suspended)
8633 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008634 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8635 if (NULL == wlanRxpFilterParam)
8636 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308637 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008638 "%s: vos_mem_alloc failed", __func__);
8639 return -EINVAL;
8640 }
8641
Amar Singhalf3a6e762013-02-19 15:06:50 -08008642 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8643 pRequest->mcastBcastFilterSetting;
8644 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8645
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308646 hdd_conf_hostoffload(pAdapter, TRUE);
8647 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8648 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008649
8650 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8651 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308652 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008653 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8654 wlanRxpFilterParam->setMcstBcstFilter);
8655
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308656 if (eHAL_STATUS_SUCCESS !=
8657 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8658 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008659 {
8660 hddLog(VOS_TRACE_LEVEL_ERROR,
8661 "%s: Failure to execute set HW MC/BC Filter request",
8662 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008663 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008664 return -EINVAL;
8665 }
8666
c_hpothud3ce76d2014-10-28 10:34:13 +05308667 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8668 {
8669 pHddCtx->sus_res_mcastbcast_filter =
8670 pRequest->mcastBcastFilterSetting;
8671 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008672 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008674
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308675 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 return 0;
8677}
8678
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308679static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8680 struct iw_request_info *info,
8681 union iwreq_data *wrqu, char *extra)
8682{
8683 int ret;
8684
8685 vos_ssr_protect(__func__);
8686 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8687 vos_ssr_unprotect(__func__);
8688
8689 return ret;
8690}
8691
8692static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8693 struct iw_request_info *info,
8694 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008695{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308696 hdd_adapter_t *pAdapter;
8697 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308698 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308699 int ret = 0;
8700
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308701 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008702
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308703 if (!capable(CAP_NET_ADMIN))
8704 {
8705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8706 FL("permission check failed"));
8707 return -EPERM;
8708 }
8709
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308710 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8711 if (NULL == pAdapter)
8712 {
8713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8714 "%s: Adapter is NULL",__func__);
8715 return -EINVAL;
8716 }
8717
8718 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8719 ret = wlan_hdd_validate_context(pHddCtx);
8720 if (0 != ret)
8721 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308722 return ret;
8723 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308724 //Reset the filter to INI value as we have to clear the dynamic filter
8725 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008726
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308727 //Configure FW with new setting
8728 if (pHddCtx->hdd_wlan_suspended)
8729 {
8730 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8731 if (NULL == wlanRxpFilterParam)
8732 {
8733 hddLog(VOS_TRACE_LEVEL_ERROR,
8734 "%s: vos_mem_alloc failed", __func__);
8735 return -EINVAL;
8736 }
8737
8738 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8739 pHddCtx->configuredMcastBcastFilter;
8740 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8741
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308742 hdd_conf_hostoffload(pAdapter, TRUE);
8743 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8744 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308745
8746 if (eHAL_STATUS_SUCCESS !=
8747 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8748 wlanRxpFilterParam))
8749 {
8750 hddLog(VOS_TRACE_LEVEL_ERROR,
8751 "%s: Failure to execute set HW MC/BC Filter request",
8752 __func__);
8753 vos_mem_free(wlanRxpFilterParam);
8754 return -EINVAL;
8755 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308756
8757 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8758 {
8759 pHddCtx->sus_res_mcastbcast_filter =
8760 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8761 }
8762
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308763 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308764 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 return 0;
8766}
8767
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308768
8769static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8770 struct iw_request_info *info,
8771 union iwreq_data *wrqu, char *extra)
8772{
8773 int ret;
8774
8775 vos_ssr_protect(__func__);
8776 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8777 vos_ssr_unprotect(__func__);
8778
8779 return ret;
8780}
8781
8782static int __iw_set_host_offload(struct net_device *dev,
8783 struct iw_request_info *info,
8784 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008785{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308786 hdd_adapter_t *pAdapter;
8787 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008788 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008789 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308790 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008791
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308792 ENTER();
8793
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308794 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8795 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008796 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8798 "%s: Adapter is NULL",__func__);
8799 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008800 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8802 ret = wlan_hdd_validate_context(pHddCtx);
8803 if (0 != ret)
8804 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308805 return ret;
8806 }
8807
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 /* Debug display of request components. */
8809 switch (pRequest->offloadType)
8810 {
8811 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008812 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 switch (pRequest->enableOrDisable)
8814 {
8815 case WLAN_OFFLOAD_DISABLE:
8816 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8817 break;
8818 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8819 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8820 case WLAN_OFFLOAD_ENABLE:
8821 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8822 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8823 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8824 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8825 }
8826 break;
8827
8828 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008829 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008830 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 switch (pRequest->enableOrDisable)
8832 {
8833 case WLAN_OFFLOAD_DISABLE:
8834 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8835 break;
8836 case WLAN_OFFLOAD_ENABLE:
8837 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8838 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8839 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8840 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8841 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8842 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8843 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8844 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8845 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8846 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8847 }
8848 }
8849
8850 /* Execute offload request. The reason that we can copy the request information
8851 from the ioctl structure to the SME structure is that they are laid out
8852 exactly the same. Otherwise, each piece of information would have to be
8853 copied individually. */
8854 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008855 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8856 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008858 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 __func__);
8860 return -EINVAL;
8861 }
8862
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308863 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 return 0;
8865}
8866
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308867static int iw_set_host_offload(struct net_device *dev,
8868 struct iw_request_info *info,
8869 union iwreq_data *wrqu, char *extra)
8870{
8871 int ret;
8872
8873 vos_ssr_protect(__func__);
8874 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8875 vos_ssr_unprotect(__func__);
8876
8877 return ret;
8878}
8879
8880static int __iw_set_keepalive_params(struct net_device *dev,
8881 struct iw_request_info *info,
8882 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008883{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308884 hdd_adapter_t *pAdapter;
8885 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008886 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308888 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008889
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308890 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308891 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8892 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8895 "%s: Adapter is NULL",__func__);
8896 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8899 ret = wlan_hdd_validate_context(pHddCtx);
8900 if (0 != ret)
8901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308902 return ret;
8903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008905 hddLog(VOS_TRACE_LEVEL_INFO,
8906 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8907 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008908
8909 switch (pRequest->packetType)
8910 {
8911 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008912 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 break;
8914
8915 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8916
Arif Hussain6d2a3322013-11-17 19:50:10 -08008917 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008918 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008919
8920 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8921 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8922 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8923
8924 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8925 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8926 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8927
8928 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8929 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8930 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8931 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8932 break;
8933
8934 }
8935
8936 /* Execute keep alive request. The reason that we can copy the request information
8937 from the ioctl structure to the SME structure is that they are laid out
8938 exactly the same. Otherwise, each piece of information would have to be
8939 copied individually. */
8940 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8941
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308942 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8943 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008944
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008945 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008946 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008948 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 __func__);
8950 return -EINVAL;
8951 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308952 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008953 return 0;
8954}
8955
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308956static int iw_set_keepalive_params(struct net_device *dev,
8957 struct iw_request_info *info,
8958 union iwreq_data *wrqu, char *extra)
8959{
8960 int ret;
8961 vos_ssr_protect(__func__);
8962 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8963 vos_ssr_unprotect(__func__);
8964
8965 return ret;
8966}
8967
Jeff Johnson295189b2012-06-20 16:38:30 -07008968#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008969int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008970 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008971{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008972 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8973 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 int i=0;
8975
8976 if (pHddCtx->cfg_ini->disablePacketFilter)
8977 {
8978 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008979 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 return 0;
8981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 /* Debug display of request components. */
8983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008984 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008985
8986 switch (pRequest->filterAction)
8987 {
8988 case HDD_RCV_FILTER_SET:
8989 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008990 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008991
8992 packetFilterSetReq.filterId = pRequest->filterId;
8993 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8994 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008995 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 __func__, pRequest->numParams);
8997 return -EINVAL;
8998 }
8999 packetFilterSetReq.numFieldParams = pRequest->numParams;
9000 packetFilterSetReq.coalesceTime = 0;
9001 packetFilterSetReq.filterType = 1;
9002 for (i=0; i < pRequest->numParams; i++)
9003 {
9004 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9005 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9006 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9007 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9008 packetFilterSetReq.paramsData[i].reserved = 0;
9009
Arif Hussain6d2a3322013-11-17 19:50:10 -08009010 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9012 packetFilterSetReq.filterType);
9013
Arif Hussain6d2a3322013-11-17 19:50:10 -08009014 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309016 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9017 (pRequest->paramsData[i].dataLength))
9018 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009019
9020 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9021 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9022 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9023 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9024
Arif Hussain6d2a3322013-11-17 19:50:10 -08009025 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9027 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9028 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9029
Arif Hussain6d2a3322013-11-17 19:50:10 -08009030 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9032 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9033 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9034 }
9035
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07009036 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009038 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 __func__);
9040 return -EINVAL;
9041 }
9042
9043 break;
9044
9045 case HDD_RCV_FILTER_CLEAR:
9046
Arif Hussain6d2a3322013-11-17 19:50:10 -08009047 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009048 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07009050 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009052 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 __func__);
9054 return -EINVAL;
9055 }
9056 break;
9057
9058 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009059 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009060 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 return -EINVAL;
9062 }
9063 return 0;
9064}
9065
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309066int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9067 tANI_U8 sessionId)
9068{
9069 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9070 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9071
9072 if (NULL == pHddCtx)
9073 {
9074 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9075 return -EINVAL;
9076 }
9077
9078 if (pHddCtx->isLogpInProgress)
9079 {
9080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9081 "%s:LOGP in Progress. Ignore!!!", __func__);
9082 return -EBUSY;
9083 }
9084
9085 if (pHddCtx->cfg_ini->disablePacketFilter)
9086 {
9087 hddLog(VOS_TRACE_LEVEL_ERROR,
9088 "%s: Packet Filtering Disabled. Returning ",
9089 __func__ );
9090 return -EINVAL;
9091 }
9092
9093 switch (filterType)
9094 {
9095 /* For setting IPV6 MC and UC Filter we need to configure
9096 * 2 filters, one for MC and one for UC.
9097 * The Filter ID shouldn't be swapped, which results in making
9098 * UC Filter ineffective.
9099 * We have Hardcode all the values
9100 *
9101 * Reason for a seperate UC filter is because, driver need to
9102 * specify the FW that the specific filter is for unicast
9103 * otherwise FW will not pass the unicast frames by default
9104 * through the filter. This is required to avoid any performance
9105 * hits when no unicast filter is set and only MC/BC are set.
9106 * The way driver informs host is by using the MAC protocol
9107 * layer, CMP flag set to MAX, CMP Data set to 1.
9108 */
9109
9110 case HDD_FILTER_IPV6_MC_UC:
9111 /* Setting IPV6 MC Filter below
9112 */
9113 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9114 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9115 packetFilterSetReq.numFieldParams = 2;
9116 packetFilterSetReq.paramsData[0].protocolLayer =
9117 HDD_FILTER_PROTO_TYPE_MAC;
9118 packetFilterSetReq.paramsData[0].cmpFlag =
9119 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9120 packetFilterSetReq.paramsData[0].dataOffset =
9121 WLAN_HDD_80211_FRM_DA_OFFSET;
9122 packetFilterSetReq.paramsData[0].dataLength = 1;
9123 packetFilterSetReq.paramsData[0].compareData[0] =
9124 HDD_IPV6_MC_CMP_DATA;
9125
9126 packetFilterSetReq.paramsData[1].protocolLayer =
9127 HDD_FILTER_PROTO_TYPE_ARP;
9128 packetFilterSetReq.paramsData[1].cmpFlag =
9129 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9130 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9131 packetFilterSetReq.paramsData[1].dataLength = 2;
9132 packetFilterSetReq.paramsData[1].compareData[0] =
9133 HDD_IPV6_CMP_DATA_0;
9134 packetFilterSetReq.paramsData[1].compareData[1] =
9135 HDD_IPV6_CMP_DATA_1;
9136
9137
9138 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9139 &packetFilterSetReq, sessionId))
9140 {
9141 hddLog(VOS_TRACE_LEVEL_ERROR,
9142 "%s: Failure to execute Set IPv6 Mulicast Filter",
9143 __func__);
9144 return -EINVAL;
9145 }
9146
9147 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9148
9149 /*
9150 * Setting IPV6 UC Filter below
9151 */
9152 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9153 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9154 packetFilterSetReq.numFieldParams = 2;
9155 packetFilterSetReq.paramsData[0].protocolLayer =
9156 HDD_FILTER_PROTO_TYPE_MAC;
9157 packetFilterSetReq.paramsData[0].cmpFlag =
9158 HDD_FILTER_CMP_TYPE_MAX;
9159 packetFilterSetReq.paramsData[0].dataOffset = 0;
9160 packetFilterSetReq.paramsData[0].dataLength = 1;
9161 packetFilterSetReq.paramsData[0].compareData[0] =
9162 HDD_IPV6_UC_CMP_DATA;
9163
9164 packetFilterSetReq.paramsData[1].protocolLayer =
9165 HDD_FILTER_PROTO_TYPE_ARP;
9166 packetFilterSetReq.paramsData[1].cmpFlag =
9167 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9168 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9169 packetFilterSetReq.paramsData[1].dataLength = 2;
9170 packetFilterSetReq.paramsData[1].compareData[0] =
9171 HDD_IPV6_CMP_DATA_0;
9172 packetFilterSetReq.paramsData[1].compareData[1] =
9173 HDD_IPV6_CMP_DATA_1;
9174
9175 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9176 &packetFilterSetReq, sessionId))
9177 {
9178 hddLog(VOS_TRACE_LEVEL_ERROR,
9179 "%s: Failure to execute Set IPv6 Unicast Filter",
9180 __func__);
9181 return -EINVAL;
9182 }
9183
9184 break;
9185
9186 case HDD_FILTER_IPV6_MC:
9187 /*
9188 * IPV6 UC Filter might be already set,
9189 * clear the UC Filter. As the Filter
9190 * IDs are static, we can directly clear it.
9191 */
9192 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9193 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9194 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9195 &packetFilterClrReq, sessionId))
9196 {
9197 hddLog(VOS_TRACE_LEVEL_ERROR,
9198 "%s: Failure to execute Clear IPv6 Unicast Filter",
9199 __func__);
9200 return -EINVAL;
9201 }
9202
9203 /*
9204 * Setting IPV6 MC Filter below
9205 */
9206 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9207 packetFilterSetReq.numFieldParams = 2;
9208 packetFilterSetReq.paramsData[0].protocolLayer =
9209 HDD_FILTER_PROTO_TYPE_MAC;
9210 packetFilterSetReq.paramsData[0].cmpFlag =
9211 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9212 packetFilterSetReq.paramsData[0].dataOffset =
9213 WLAN_HDD_80211_FRM_DA_OFFSET;
9214 packetFilterSetReq.paramsData[0].dataLength = 1;
9215 packetFilterSetReq.paramsData[0].compareData[0] =
9216 HDD_IPV6_MC_CMP_DATA;
9217
9218 packetFilterSetReq.paramsData[1].protocolLayer =
9219 HDD_FILTER_PROTO_TYPE_ARP;
9220 packetFilterSetReq.paramsData[1].cmpFlag =
9221 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9222 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9223 packetFilterSetReq.paramsData[1].dataLength = 2;
9224 packetFilterSetReq.paramsData[1].compareData[0] =
9225 HDD_IPV6_CMP_DATA_0;
9226 packetFilterSetReq.paramsData[1].compareData[1] =
9227 HDD_IPV6_CMP_DATA_1;
9228
9229
9230 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9231 &packetFilterSetReq, sessionId))
9232 {
9233 hddLog(VOS_TRACE_LEVEL_ERROR,
9234 "%s: Failure to execute Set IPv6 Multicast Filter",
9235 __func__);
9236 return -EINVAL;
9237 }
9238 break;
9239
9240 default :
9241 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9242 "%s: Packet Filter Request: Invalid",
9243 __func__);
9244 return -EINVAL;
9245 }
9246 return 0;
9247}
9248
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309249void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009250{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309251 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309252 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009253 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309254 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009255
Yue Ma3ede6052013-08-29 00:33:26 -07009256 if (NULL == pHddCtx)
9257 {
9258 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9259 return;
9260 }
9261
9262 hHal = pHddCtx->hHal;
9263
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309264 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009265 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309266 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9267 return;
9268 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309269
9270 /* Check if INI is enabled or not, other wise just return
9271 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309272 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309273 {
9274 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9275 if (NULL == pMulticastAddrs)
9276 {
9277 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9278 return;
9279 }
9280
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 if (set)
9282 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309283 /* Following pre-conditions should be satisfied before wei
9284 * configure the MC address list.
9285 */
9286 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9287 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9288 && pAdapter->mc_addr_list.mc_cnt
9289 && (eConnectionState_Associated ==
9290 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9291 {
9292 pMulticastAddrs->ulMulticastAddrCnt =
9293 pAdapter->mc_addr_list.mc_cnt;
9294 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9295 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009296 memcpy(pMulticastAddrs->multicastAddr[i],
9297 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309298 sizeof(pAdapter->mc_addr_list.addr[i]));
9299 hddLog(VOS_TRACE_LEVEL_INFO,
9300 "%s: %s multicast filter: addr ="
9301 MAC_ADDRESS_STR,
9302 __func__, set ? "setting" : "clearing",
9303 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9304 }
9305 /* Set multicast filter */
9306 sme_8023MulticastList(hHal, pAdapter->sessionId,
9307 pMulticastAddrs);
9308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309310 else
9311 {
9312 /* Need to clear only if it was previously configured
9313 */
9314 if (pAdapter->mc_addr_list.isFilterApplied)
9315 {
9316 pMulticastAddrs->ulMulticastAddrCnt = 0;
9317 sme_8023MulticastList(hHal, pAdapter->sessionId,
9318 pMulticastAddrs);
9319 }
9320
9321 }
9322 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009323 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309325 else
9326 {
9327 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309328 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309329 }
9330 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009331}
9332
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309333static int __iw_set_packet_filter_params(struct net_device *dev,
9334 struct iw_request_info *info,
9335 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309336{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309337 hdd_adapter_t *pAdapter;
9338 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009339 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309340 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309341 struct iw_point s_priv_data;
9342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309343 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309344
9345 if (!capable(CAP_NET_ADMIN))
9346 {
9347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9348 FL("permission check failed"));
9349 return -EPERM;
9350 }
9351
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309352 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9353 if (NULL == pAdapter)
9354 {
9355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9356 "%s: Adapter is NULL",__func__);
9357 return -EINVAL;
9358 }
9359 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9360 ret = wlan_hdd_validate_context(pHddCtx);
9361 if (0 != ret)
9362 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309363 return ret;
9364 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309365 if (hdd_priv_get_data(&s_priv_data, wrqu))
9366 {
9367 return -EINVAL;
9368 }
9369
9370 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9371 {
9372 return -EINVAL;
9373 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009374
Arif Hussain0273cba2014-01-07 20:58:29 -08009375 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309376 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9377 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009378 if (NULL == pRequest)
9379 {
9380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9381 "mem_alloc_copy_from_user_helper fail");
9382 return -ENOMEM;
9383 }
9384
9385 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
9386 kfree(pRequest);
9387
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309388 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009389 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009390}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309391
9392static int iw_set_packet_filter_params(struct net_device *dev,
9393 struct iw_request_info *info,
9394 union iwreq_data *wrqu, char *extra)
9395{
9396 int ret;
9397
9398 vos_ssr_protect(__func__);
9399 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9400 vos_ssr_unprotect(__func__);
9401
9402 return ret;
9403}
Jeff Johnson295189b2012-06-20 16:38:30 -07009404#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309405static int __iw_get_statistics(struct net_device *dev,
9406 struct iw_request_info *info,
9407 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009408{
9409
9410 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9411 eHalStatus status = eHAL_STATUS_SUCCESS;
9412 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309413 hdd_adapter_t *pAdapter;
9414 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309416 int tlen = 0, ret = 0;
9417 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009418
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309419 tCsrGlobalClassAStatsInfo *aStats;
9420 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009421
9422 ENTER();
9423
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309424 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9425 if (NULL == pAdapter)
9426 {
9427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9428 "%s: Adapter is NULL",__func__);
9429 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309431 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9432 ret = wlan_hdd_validate_context(pHddCtx);
9433 if (0 != ret)
9434 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309435 return ret;
9436 }
9437 pStats = &(pAdapter->hdd_stats.summary_stat);
9438 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9439 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9441
9442 wrqu->txpower.value = 0;
9443 }
9444 else {
9445 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9446 SME_SUMMARY_STATS |
9447 SME_GLOBAL_CLASSA_STATS |
9448 SME_GLOBAL_CLASSB_STATS |
9449 SME_GLOBAL_CLASSC_STATS |
9450 SME_GLOBAL_CLASSD_STATS |
9451 SME_PER_STA_STATS,
9452 hdd_StatisticsCB, 0, FALSE,
9453 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9454
9455 if (eHAL_STATUS_SUCCESS != status)
9456 {
9457 hddLog(VOS_TRACE_LEVEL_ERROR,
9458 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009459 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 return -EINVAL;
9461 }
9462
9463 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309464 if (NULL == pWextState)
9465 {
9466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9467 "%s: pWextState is NULL",__func__);
9468 return -EINVAL;
9469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009470
9471 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9472 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9473 {
9474 hddLog(VOS_TRACE_LEVEL_ERROR,
9475 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009476 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 /*Remove the SME statistics list by passing NULL in callback argument*/
9478 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9479 SME_SUMMARY_STATS |
9480 SME_GLOBAL_CLASSA_STATS |
9481 SME_GLOBAL_CLASSB_STATS |
9482 SME_GLOBAL_CLASSC_STATS |
9483 SME_GLOBAL_CLASSD_STATS |
9484 SME_PER_STA_STATS,
9485 NULL, 0, FALSE,
9486 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9487
9488 return -EINVAL;
9489 }
9490 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9491 (tANI_U8) sizeof (pStats->retry_cnt),
9492 (char*) &(pStats->retry_cnt[0]),
9493 tlen);
9494
9495 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9496 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9497 (char*) &(pStats->multiple_retry_cnt[0]),
9498 tlen);
9499
9500 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9501 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9502 (char*) &(pStats->tx_frm_cnt[0]),
9503 tlen);
9504
9505 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9506 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9507 (char*) &(pStats->rx_frm_cnt),
9508 tlen);
9509
9510 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9511 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9512 (char*) &(pStats->frm_dup_cnt),
9513 tlen);
9514
9515 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9516 (tANI_U8) sizeof (pStats->fail_cnt),
9517 (char*) &(pStats->fail_cnt[0]),
9518 tlen);
9519
9520 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9521 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9522 (char*) &(pStats->rts_fail_cnt),
9523 tlen);
9524
9525 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9526 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9527 (char*) &(pStats->ack_fail_cnt),
9528 tlen);
9529
9530 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9531 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9532 (char*) &(pStats->rts_succ_cnt),
9533 tlen);
9534
9535 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9536 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9537 (char*) &(pStats->rx_discard_cnt),
9538 tlen);
9539
9540 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9541 (tANI_U8) sizeof (pStats->rx_error_cnt),
9542 (char*) &(pStats->rx_error_cnt),
9543 tlen);
9544
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009545 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009546 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009547 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 tlen);
9549
9550 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9551 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9552 (char*) &(dStats->rx_byte_cnt),
9553 tlen);
9554
9555 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9556 (tANI_U8) sizeof (dStats->rx_rate),
9557 (char*) &(dStats->rx_rate),
9558 tlen);
9559
9560 /* Transmit rate, in units of 500 kbit/sec */
9561 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9562 (tANI_U8) sizeof (aStats->tx_rate),
9563 (char*) &(aStats->tx_rate),
9564 tlen);
9565
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009566 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9567 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9568 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009569 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009570 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9571 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9572 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009573 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009574 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9575 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9576 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009577 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009578 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9579 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9580 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009581 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009582 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9583 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9584 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009585 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009586 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9587 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9588 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009589 tlen);
9590
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 wrqu->data.length = tlen;
9592
9593 }
9594
9595 EXIT();
9596
9597 return 0;
9598}
9599
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309600static int iw_get_statistics(struct net_device *dev,
9601 struct iw_request_info *info,
9602 union iwreq_data *wrqu, char *extra)
9603{
9604 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009605
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309606 vos_ssr_protect(__func__);
9607 ret = __iw_get_statistics(dev, info, wrqu, extra);
9608 vos_ssr_unprotect(__func__);
9609
9610 return ret;
9611}
Jeff Johnson295189b2012-06-20 16:38:30 -07009612#ifdef FEATURE_WLAN_SCAN_PNO
9613
9614/*Max Len for PNO notification*/
9615#define MAX_PNO_NOTIFY_LEN 100
9616void found_pref_network_cb (void *callbackContext,
9617 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9618{
9619 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9620 union iwreq_data wrqu;
9621 char buf[MAX_PNO_NOTIFY_LEN+1];
9622
9623 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9624 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9625
9626 // create the event
9627 memset(&wrqu, 0, sizeof(wrqu));
9628 memset(buf, 0, sizeof(buf));
9629
9630 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9631 pPrefNetworkFoundInd->ssId.ssId,
9632 (unsigned int)pPrefNetworkFoundInd->rssi);
9633
9634 wrqu.data.pointer = buf;
9635 wrqu.data.length = strlen(buf);
9636
9637 // send the event
9638
9639 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9640
9641}
9642
9643
9644/*string based input*/
9645VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9646 union iwreq_data *wrqu, char *extra, int nOffset)
9647{
9648 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309649 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009650 /* pnoRequest is a large struct, so we make it static to avoid stack
9651 overflow. This API is only invoked via ioctl, so it is
9652 serialized by the kernel rtnl_lock and hence does not need to be
9653 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309654 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 char *ptr;
9656 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309657 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9659
9660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9661 "PNO data len %d data %s",
9662 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009663 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009664
9665 if (wrqu->data.length <= nOffset )
9666 {
9667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9668 return VOS_STATUS_E_FAILURE;
9669 }
9670
9671 pnoRequest.enable = 0;
9672 pnoRequest.ucNetworksCount = 0;
9673 /*-----------------------------------------------------------------------
9674 Input is string based and expected to be like this:
9675
9676 <enabled> <netw_count>
9677 for each network:
9678 <ssid_len> <ssid> <authentication> <encryption>
9679 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9680 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9681
9682 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009683 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 -07009684
9685 this translates into:
9686 -----------------------------
9687 enable PNO
9688 look for 2 networks:
9689 test - with authentication type 0 and encryption type 0,
9690 that can be found on 3 channels: 1 6 and 11 ,
9691 SSID bcast type is unknown (directed probe will be sent if AP not found)
9692 and must meet -40dBm RSSI
9693
9694 test2 - with auth and enrytption type 4/4
9695 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9696 bcast type is non-bcast (directed probe will be sent)
9697 and must not meet any RSSI threshold
9698
Jeff Johnson8301aa12013-03-28 14:27:29 -07009699 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009701 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009702
Wilson Yang623f6592013-10-08 16:33:37 -07009703 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9704 {
9705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9706 "PNO enable input is not valid %s",ptr);
9707 return VOS_STATUS_E_FAILURE;
9708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009709
9710 if ( 0 == pnoRequest.enable )
9711 {
9712 /*Disable PNO*/
9713 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309714 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9715 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 pAdapter->sessionId,
9717 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309718 if (eHAL_STATUS_SUCCESS != status)
9719 {
9720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9721 "%s: failed to disable PNO", __func__);
9722 return VOS_STATUS_E_FAILURE;
9723 }
9724 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 return VOS_STATUS_SUCCESS;
9726 }
9727
c_hpothu37f21312014-04-09 21:49:54 +05309728 if (TRUE == pHddCtx->isPnoEnable)
9729 {
9730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9731 FL("already PNO is enabled"));
9732 return -EBUSY;
9733 }
9734 pHddCtx->isPnoEnable = TRUE;
9735
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009737
9738 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9739 {
9740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9741 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309742 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009744
9745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9746 "PNO enable %d networks count %d offset %d",
9747 pnoRequest.enable,
9748 pnoRequest.ucNetworksCount,
9749 nOffset);
9750
9751 /* Parameters checking:
9752 ucNetworksCount has to be larger than 0*/
9753 if (( 0 == pnoRequest.ucNetworksCount ) ||
9754 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9755 {
9756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309757 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 }
9759
9760 ptr += nOffset;
9761
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309762 pnoRequest.aNetworks =
9763 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9764 if (pnoRequest.aNetworks == NULL)
9765 {
9766 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9767 FL("failed to allocate memory aNetworks %u"),
9768 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9769 goto error;
9770 }
9771 vos_mem_zero(pnoRequest.aNetworks,
9772 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9773
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9775 {
9776
9777 pnoRequest.aNetworks[i].ssId.length = 0;
9778
Wilson Yang623f6592013-10-08 16:33:37 -07009779 ucParams = sscanf(ptr,"%hhu %n",
9780 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9781
9782 if (1 != ucParams)
9783 {
9784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9785 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309786 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009788
9789 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9790 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9791 {
9792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9793 "SSID Len %d is not correct for network %d",
9794 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309795 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 }
9797
9798 /*Advance to SSID*/
9799 ptr += nOffset;
9800
Jeff Johnson8301aa12013-03-28 14:27:29 -07009801 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009802 pnoRequest.aNetworks[i].ssId.length);
9803 ptr += pnoRequest.aNetworks[i].ssId.length;
9804
Jeff Johnson02797792013-10-26 19:17:13 -07009805 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009806 &(pnoRequest.aNetworks[i].authentication),
9807 &(pnoRequest.aNetworks[i].encryption),
9808 &(pnoRequest.aNetworks[i].ucChannelCount),
9809 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009810
Wilson Yang623f6592013-10-08 16:33:37 -07009811 if ( 3 != ucParams )
9812 {
9813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9814 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309815 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009816 }
9817
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009819 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009820 "auth %d encry %d channel count %d offset %d",
9821 pnoRequest.aNetworks[i].ssId.length,
9822 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9823 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9824 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9825 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9826 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9827 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9828 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9829 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9830 pnoRequest.aNetworks[i].authentication,
9831 pnoRequest.aNetworks[i].encryption,
9832 pnoRequest.aNetworks[i].ucChannelCount,
9833 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009834
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 /*Advance to channel list*/
9836 ptr += nOffset;
9837
Wilson Yang623f6592013-10-08 16:33:37 -07009838 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 {
9840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9841 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309842 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 }
9844
9845 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9846 {
9847 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9848 {
Wilson Yang623f6592013-10-08 16:33:37 -07009849 if (1 != sscanf(ptr,"%hhu %n",
9850 &(pnoRequest.aNetworks[i].aChannels[j]),
9851 &nOffset))
9852 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9853 "PNO network channel input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309854 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009855 }
9856 /*Advance to next channel number*/
9857 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 }
9859 }
9860
Jeff Johnson02797792013-10-26 19:17:13 -07009861 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009862 &(pnoRequest.aNetworks[i].bcastNetwType),
9863 &nOffset))
9864 {
9865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9866 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309867 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009869
9870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9871 "PNO bcastNetwType %d offset %d",
9872 pnoRequest.aNetworks[i].bcastNetwType,
9873 nOffset );
9874
9875 /*Advance to rssi Threshold*/
9876 ptr += nOffset;
9877
Wilson Yang623f6592013-10-08 16:33:37 -07009878 if (1 != sscanf(ptr,"%hhu %n",
9879 &(pnoRequest.aNetworks[i].rssiThreshold),
9880 &nOffset))
9881 {
9882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9883 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309884 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009886
9887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9888 "PNO rssi %d offset %d",
9889 pnoRequest.aNetworks[i].rssiThreshold,
9890 nOffset );
9891 /*Advance to next network*/
9892 ptr += nOffset;
9893 }/*For ucNetworkCount*/
9894
9895 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009896 &(pnoRequest.scanTimers.ucScanTimersCount),
9897 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009898
9899 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009900 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009901 {
9902 ptr += nOffset;
9903
Jeff Johnson8301aa12013-03-28 14:27:29 -07009904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9905 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 pnoRequest.scanTimers.ucScanTimersCount,
9907 nOffset );
9908
9909 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9910 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309913 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 }
9915
9916 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9917 {
Jeff Johnson02797792013-10-26 19:17:13 -07009918 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9920 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9921 &nOffset);
9922
Wilson Yang623f6592013-10-08 16:33:37 -07009923 if (2 != ucParams)
9924 {
9925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9926 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309927 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009928 }
9929
Jeff Johnson8301aa12013-03-28 14:27:29 -07009930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9931 "PNO Timer value %d Timer repeat %d offset %d",
9932 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9934 nOffset );
9935
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 ptr += nOffset;
9937 }
9938
9939 }
9940 else
9941 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9943 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9945
9946 /*Scan timers defaults to 5 minutes*/
9947 pnoRequest.scanTimers.ucScanTimersCount = 1;
9948 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9949 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9950 }
9951
Wilson Yang623f6592013-10-08 16:33:37 -07009952 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009953
9954 pnoRequest.modePNO = ucMode;
9955 /*for LA we just expose suspend option*/
9956 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9957 {
9958 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9959 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309960 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9961 if (pnoRequest.p24GProbeTemplate == NULL){
9962 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9963 FL("failed to allocate memory p24GProbeTemplate %u"),
9964 SIR_PNO_MAX_PB_REQ_SIZE);
9965 goto error;
9966 }
9967
9968 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9969 if (pnoRequest.p5GProbeTemplate == NULL){
9970 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9971 FL("failed to allocate memory p5GProbeTemplate %u"),
9972 SIR_PNO_MAX_PB_REQ_SIZE);
9973 goto error;
9974 }
9975
9976 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9977 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009978
c_hpothu37f21312014-04-09 21:49:54 +05309979 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 pAdapter->sessionId,
9981 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309982 if (eHAL_STATUS_SUCCESS == status)
9983 {
9984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9985 "%s: PNO enabled", __func__);
9986 return VOS_STATUS_SUCCESS;
9987 }
9988error:
9989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9990 "%s: Failed to enable PNO", __func__);
9991 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309992 if (pnoRequest.aNetworks)
9993 vos_mem_free(pnoRequest.aNetworks);
9994 if (pnoRequest.p24GProbeTemplate)
9995 vos_mem_free(pnoRequest.p24GProbeTemplate);
9996 if (pnoRequest.p5GProbeTemplate)
9997 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309998 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009999}/*iw_set_pno*/
10000
10001VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10002 union iwreq_data *wrqu, char *extra, int nOffset)
10003{
10004 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10005 v_U8_t rssiThreshold = 0;
10006 v_U8_t nRead;
10007
Arif Hussain7adce1b2013-11-11 22:59:34 -080010008 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 &rssiThreshold);
10010
10011 if ( 1 != nRead )
10012 {
10013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10014 "Incorrect format");
10015 return VOS_STATUS_E_FAILURE;
10016 }
10017
10018 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10019 return VOS_STATUS_SUCCESS;
10020}
10021
10022
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010023static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 struct iw_request_info *info,
10025 union iwreq_data *wrqu, char *extra)
10026{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010027 hdd_adapter_t *pAdapter;
10028 hdd_context_t *pHddCtx;
10029 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010030 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010031
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010032 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010033 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10034 if (NULL == pAdapter)
10035 {
10036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10037 "%s: Adapter is NULL",__func__);
10038 return -EINVAL;
10039 }
10040
10041 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10042 ret = wlan_hdd_validate_context(pHddCtx);
10043 if (0 != ret)
10044 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010045 return ret;
10046 }
10047
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010048
10049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010052 status = iw_set_pno(dev,info,wrqu,extra,0);
10053
10054 EXIT();
10055 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010056}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010057
10058static int iw_set_pno_priv(struct net_device *dev,
10059 struct iw_request_info *info,
10060 union iwreq_data *wrqu, char *extra)
10061{
10062 int ret;
10063
10064 vos_ssr_protect(__func__);
10065 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10066 vos_ssr_unprotect(__func__);
10067
10068 return ret;
10069}
Jeff Johnson295189b2012-06-20 16:38:30 -070010070#endif /*FEATURE_WLAN_SCAN_PNO*/
10071
10072//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010073int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010075 hdd_adapter_t *pAdapter;
10076 tHalHandle hHal;
10077 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010078 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010079 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010080 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010081 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010082 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010083 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010084 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010085
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010086 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010087 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10088 if (NULL == pAdapter)
10089 {
10090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10091 "%s: Adapter is NULL",__func__);
10092 return -EINVAL;
10093 }
10094 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10095 retval = wlan_hdd_validate_context(pHddCtx);
10096 if (0 != retval)
10097 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010098 return retval;
10099 }
10100 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10101 if (NULL == hHal)
10102 {
10103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10104 "%s: Hal Context is NULL",__func__);
10105 return -EINVAL;
10106 }
10107 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010108
Atul Mittal54378cb2014-04-02 16:51:50 +053010109 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 {
10111 case WLAN_HDD_UI_BAND_AUTO:
10112 band = eCSR_BAND_ALL;
10113 break;
10114 case WLAN_HDD_UI_BAND_5_GHZ:
10115 band = eCSR_BAND_5G;
10116 break;
10117 case WLAN_HDD_UI_BAND_2_4_GHZ:
10118 band = eCSR_BAND_24;
10119 break;
10120 default:
10121 band = eCSR_BAND_MAX;
10122 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010123 connectedBand =
10124 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010125
Atul Mittal54378cb2014-04-02 16:51:50 +053010126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010127 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010128
10129 if (band == eCSR_BAND_MAX)
10130 {
10131 /* Received change band request with invalid band value */
10132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010133 "%s: Invalid band value %u", __func__, ui_band);
10134 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 }
10136
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010137 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010138 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010139 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010141 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010142 band, pHddCtx->cfg_ini->nBandCapability);
10143 return -EIO;
10144 }
10145
Sushant Kaushik1165f872015-03-30 20:25:27 +053010146 if (band == eCSR_BAND_ALL)
10147 {
10148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10149 "received. Setting band same as ini value %d"),
10150 pHddCtx->cfg_ini->nBandCapability);
10151 band = pHddCtx->cfg_ini->nBandCapability;
10152 }
10153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10155 {
10156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10157 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010158 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 return -EIO;
10160 }
10161
10162 if (currBand != band)
10163 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010164 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010165 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010166 /* Return failure if current country code is world regulatory domain*/
10167 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10168 pMac->scan.countryCodeCurrent[1] == '0') )
10169 {
10170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10171 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010172 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010173 return -EAGAIN;
10174 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010175 }
10176
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 /* Change band request received.
10178 * Abort pending scan requests, flush the existing scan results,
10179 * and change the band capability
10180 */
10181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10182 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010183 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010184
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010185 /* We need to change the band and flush the scan results here itself
10186 * as we may get timeout for disconnection in which we will return
10187 * with out doing any of these
10188 */
10189 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10190 {
10191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10192 "%s: failed to set the band value to %u ",
10193 __func__, band);
10194 return -EINVAL;
10195 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010196 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10197 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010198 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010199 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10200 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010201 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010202 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10203 * information available in NV so to get the channel information from kernel
10204 * we need to send regulatory hint for the currunt country
10205 * And to set the same country again we need to set the dummy country
10206 * first and then the actual country.
10207 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010208#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10209 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10210#else
10211 regulatory_hint_user("00");
10212#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010213 wait_result = wait_for_completion_interruptible_timeout(
10214 &pHddCtx->linux_reg_req,
10215 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10216
10217 /* if the country information does not exist with the kernel,
10218 then the driver callback would not be called */
10219
10220 if (wait_result >= 0)
10221 {
10222 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10223 "runtime country code is found in kernel db");
10224 }
10225 else
10226 {
10227 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10228 "runtime country code is not found"
10229 " in kernel db");
10230 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010231
10232 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010233
10234 /*
10235 * Update 11dcountry and current country here as the hint
10236 * with 00 results in 11d and current country with 00
10237 */
10238 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10239 WNI_CFG_COUNTRY_CODE_LEN);
10240 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10241 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010242#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10243 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10244#else
10245 regulatory_hint_user(curr_country);
10246#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010247 wait_result = wait_for_completion_interruptible_timeout(
10248 &pHddCtx->linux_reg_req,
10249 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10250
10251 /* if the country information does not exist with the kernel,
10252 then the driver callback would not be called */
10253 if (wait_result >= 0)
10254 {
10255 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10256 "runtime country code is found in kernel db");
10257 }
10258 else
10259 {
10260 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10261 "runtime country code is not found"
10262 " in kernel db");
10263 }
10264
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010265 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010266 }
10267 else
10268 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010269#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010270 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10271 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010272#else
10273 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10274#endif
10275
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010276 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010277 pScanInfo = &pHddCtx->scan_info;
10278 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10279 {
10280 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10281 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10282 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010283 sme_FilterScanResults(hHal, pAdapter->sessionId);
10284
10285 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010286 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10287 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 eHalStatus status = eHAL_STATUS_SUCCESS;
10290 long lrc;
10291
10292 /* STA already connected on current band, So issue disconnect first,
10293 * then change the band*/
10294
10295 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010296 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010297 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010298
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10300
10301 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10302 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10303
Jeff Johnson43971f52012-07-17 12:26:56 -070010304 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 {
10306 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010307 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 __func__, (int)status );
10309 return -EINVAL;
10310 }
10311
10312 lrc = wait_for_completion_interruptible_timeout(
10313 &pAdapter->disconnect_comp_var,
10314 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10315
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010316 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010317
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010318 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010319 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010320
10321 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10322 }
10323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010325 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010326 if (TRUE == pHddCtx->isSetBandByNL)
10327 return 0;
10328 else
10329 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010330}
10331
Atul Mittal54378cb2014-04-02 16:51:50 +053010332int hdd_setBand_helper(struct net_device *dev, const char *command)
10333{
10334 u8 band;
10335
10336 /*convert the band value from ascii to integer*/
10337 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10338
10339 return hdd_setBand(dev, band);
10340
10341}
10342
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010343static int __iw_set_band_config(struct net_device *dev,
10344 struct iw_request_info *info,
10345 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010346{
Atul Mittal54378cb2014-04-02 16:51:50 +053010347 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010348
Arif Hussain0273cba2014-01-07 20:58:29 -080010349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010350
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010351 if (!capable(CAP_NET_ADMIN))
10352 {
10353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10354 FL("permission check failed"));
10355 return -EPERM;
10356 }
10357
Atul Mittal54378cb2014-04-02 16:51:50 +053010358 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010359}
10360
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010361static int iw_set_band_config(struct net_device *dev,
10362 struct iw_request_info *info,
10363 union iwreq_data *wrqu, char *extra)
10364{
10365 int ret;
10366
10367 vos_ssr_protect(__func__);
10368 ret = __iw_set_band_config(dev, info, wrqu, extra);
10369 vos_ssr_unprotect(__func__);
10370
10371 return ret;
10372}
10373
c_manjeecfd1efb2015-09-25 19:32:34 +053010374static int get_fwr_memdump(struct net_device *dev,
10375 struct iw_request_info *info,
10376 union iwreq_data *wrqu, char *extra)
10377{
10378 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10379 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10380 int ret;
10381 ENTER();
10382 // HddCtx sanity
10383 ret = wlan_hdd_validate_context(pHddCtx);
10384 if (0 != ret)
10385 {
10386 return ret;
10387 }
10388 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10389 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10390 {
10391 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10392 return -EINVAL;
10393 }
10394 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10395
10396 EXIT();
10397 return ret;
10398}
10399
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010400static int __iw_set_power_params_priv(struct net_device *dev,
10401 struct iw_request_info *info,
10402 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010403{
Arif Hussain0273cba2014-01-07 20:58:29 -080010404 int ret;
10405 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010406
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10408 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010409
10410 if (!capable(CAP_NET_ADMIN))
10411 {
10412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10413 FL("permission check failed"));
10414 return -EPERM;
10415 }
10416
Arif Hussain0273cba2014-01-07 20:58:29 -080010417 /* ODD number is used for set, copy data using copy_from_user */
10418 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10419 wrqu->data.length);
10420 if (NULL == ptr)
10421 {
10422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10423 "mem_alloc_copy_from_user_helper fail");
10424 return -ENOMEM;
10425 }
10426
10427 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10428 kfree(ptr);
10429 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010430}
10431
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010432static int iw_set_power_params_priv(struct net_device *dev,
10433 struct iw_request_info *info,
10434 union iwreq_data *wrqu, char *extra)
10435{
10436 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010437
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010438 vos_ssr_protect(__func__);
10439 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10440 vos_ssr_unprotect(__func__);
10441
10442 return ret;
10443}
Jeff Johnson295189b2012-06-20 16:38:30 -070010444
10445/*string based input*/
10446VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10447 union iwreq_data *wrqu, char *extra, int nOffset)
10448{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010449 hdd_adapter_t *pAdapter;
10450 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 tSirSetPowerParamsReq powerRequest;
10452 char *ptr;
10453 v_U8_t ucType;
10454 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010455 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010456
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010457 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010458 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10459 if (NULL == pAdapter)
10460 {
10461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10462 "%s: Adapter is NULL",__func__);
10463 return -EINVAL;
10464 }
10465
10466 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10467 ret = wlan_hdd_validate_context(pHddCtx);
10468 if (0 != ret)
10469 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010470 return ret;
10471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10473 "Power Params data len %d data %s",
10474 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010475 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010476
10477 if (wrqu->data.length <= nOffset )
10478 {
10479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10480 return VOS_STATUS_E_FAILURE;
10481 }
10482
10483 uTotalSize = wrqu->data.length - nOffset;
10484
10485 /*-----------------------------------------------------------------------
10486 Input is string based and expected to be like this:
10487
10488 <param_type> <param_value> <param_type> <param_value> ...
10489
10490 e.g:
10491 1 2 2 3 3 0 4 1 5 1
10492
10493 e.g. setting just a few:
10494 1 2 4 1
10495
10496 parameter types:
10497 -----------------------------
10498 1 - Ignore DTIM
10499 2 - Listen Interval
10500 3 - Broadcast Multicas Filter
10501 4 - Beacon Early Termination
10502 5 - Beacon Early Termination Interval
10503 -----------------------------------------------------------------------*/
10504 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10505 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10506 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10507 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10508 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10509
Arif Hussain7adce1b2013-11-11 22:59:34 -080010510 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010511
10512 while ( uTotalSize )
10513 {
Wilson Yang6f971452013-10-08 15:00:00 -070010514 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10515 {
10516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10517 "Invalid input parameter type %s",ptr);
10518 return VOS_STATUS_E_FAILURE;
10519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010520
10521 uTotalSize -= nOffset;
10522
10523 if (!uTotalSize)
10524 {
10525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010526 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010527 ucType, nOffset);
10528 return VOS_STATUS_E_FAILURE;
10529 }
10530
10531 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010532
Jeff Johnson02797792013-10-26 19:17:13 -070010533 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010534 {
10535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10536 "Invalid input parameter value %s",ptr);
10537 return VOS_STATUS_E_FAILURE;
10538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010539
10540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10541 "Power request parameter %d value %d offset %d",
10542 ucType, uValue, nOffset);
10543
10544 switch (ucType)
10545 {
10546 case eSIR_IGNORE_DTIM:
10547 powerRequest.uIgnoreDTIM = uValue;
10548 break;
10549 case eSIR_LISTEN_INTERVAL:
10550 powerRequest.uListenInterval = uValue;
10551 break;
10552 case eSIR_MCAST_BCAST_FILTER:
10553 powerRequest.uBcastMcastFilter = uValue;
10554 break;
10555 case eSIR_ENABLE_BET:
10556 powerRequest.uEnableBET = uValue;
10557 break;
10558 case eSIR_BET_INTERVAL:
10559 powerRequest.uBETInterval = uValue;
10560 break;
10561 default:
10562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010563 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 ucType, uValue, nOffset);
10565 return VOS_STATUS_E_FAILURE;
10566 }
10567
10568 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10570 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010571 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010573 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010574 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010575 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10576 {
10577 uTotalSize = 0;
10578 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010579
10580 }/*Go for as long as we have a valid string*/
10581
10582 /* put the device into full power*/
10583 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10584
10585 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010586 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010587
10588 /* put the device back to power save*/
10589 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10590
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010591 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 return VOS_STATUS_SUCCESS;
10593}/*iw_set_power_params*/
10594
Atul Mittalc0f739f2014-07-31 13:47:47 +053010595// tdlsoffchan
10596#ifdef FEATURE_WLAN_TDLS
10597
Atul Mittal87ec2422014-09-24 13:12:50 +053010598int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010599{
10600 if (offchannel < 0 || offchannel > 165)
10601 {
10602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10603 __func__, offchannel);
10604 return -1;
10605
10606 }
10607
10608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10609 __func__, tdlsOffCh, offchannel);
10610
10611 tdlsOffCh = offchannel;
10612 return 0;
10613}
10614
Atul Mittal87ec2422014-09-24 13:12:50 +053010615int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010616{
10617 if (offchanoffset == 0)
10618 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010619 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10621 __func__, tdlsOffChBwOffset);
10622
10623 return 0;
10624
10625 }
10626
10627 if ( offchanoffset == 40 )
10628 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010629 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10631 __func__, tdlsOffChBwOffset);
10632
10633 return 0;
10634
10635 }
10636 if (offchanoffset == -40)
10637 {
10638 tdlsOffChBwOffset = 3;
10639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10640 __func__, tdlsOffChBwOffset);
10641
10642 return 0;
10643
10644 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010645
10646 if ((offchanoffset == 80) &&
10647 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10648 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10649 {
10650 tdlsOffChBwOffset = 4;
10651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10652 "%s: change tdls secondary off channel offset to %u",
10653 __func__, tdlsOffChBwOffset);
10654
10655 return 0;
10656 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10658 __func__, offchanoffset);
10659 return -1;
10660}
10661
Atul Mittal87ec2422014-09-24 13:12:50 +053010662int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010663{
10664 hddTdlsPeer_t *connPeer = NULL;
10665 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10666 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010667 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010668 if (offchanmode < 0 || offchanmode > 4)
10669 {
10670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10671 "%s: Invalid tdls off channel mode %d",
10672 __func__, offchanmode);
10673 return -1;
10674 }
10675
10676 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10677 {
10678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10679 "%s: tdls off channel mode req in not associated state %d",
10680 __func__, offchanmode);
10681 return -1;
10682 }
10683
10684 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10685 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10686 {
10687 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010688 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010689 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010690 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010691 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10693 "%s: No TDLS Connected Peer", __func__);
10694 return -1;
10695 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010696 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010697 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010698 }
10699 else
10700 {
10701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10702 "%s: TDLS Connection not supported", __func__);
10703 return -1;
10704 }
10705
10706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10707 ("%s: TDLS Channel Switch in swmode=%d"),
10708 __func__, offchanmode);
10709
10710 switch (offchanmode)
10711 {
10712 case 1:/*Enable*/
10713 case 2:/*Disable*/
10714 {
10715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10716 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10717 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10718 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10719 {
10720
10721 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010722 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010723 tdlsOffCh, tdlsOffChBwOffset,
10724 offchanmode);
10725 }
10726 else
10727 {
10728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10729 "%s: TDLS Off Channel not supported", __func__);
10730 return -1;
10731 }
10732 break;
10733 }
10734 case 3:
10735 {
10736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10737 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10738 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10739
10740 break;
10741 }
10742 case 4:
10743 {
10744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10745 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10746 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10747 break;
10748 }
10749 default:
10750 {
10751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10752 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10753 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10754 break;
10755 }
10756
10757 }
10758
10759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10760 __func__, offchanmode);
10761 return 0;
10762}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010763#endif
10764
Jeff Johnson295189b2012-06-20 16:38:30 -070010765
10766// Define the Wireless Extensions to the Linux Network Device structure
10767// A number of these routines are NULL (meaning they are not implemented.)
10768
10769static const iw_handler we_handler[] =
10770{
10771 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10772 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10773 (iw_handler) NULL, /* SIOCSIWNWID */
10774 (iw_handler) NULL, /* SIOCGIWNWID */
10775 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10776 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10777 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10778 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10779 (iw_handler) NULL, /* SIOCSIWSENS */
10780 (iw_handler) NULL, /* SIOCGIWSENS */
10781 (iw_handler) NULL, /* SIOCSIWRANGE */
10782 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010783 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 (iw_handler) NULL, /* SIOCGIWPRIV */
10785 (iw_handler) NULL, /* SIOCSIWSTATS */
10786 (iw_handler) NULL, /* SIOCGIWSTATS */
10787 iw_handler_set_spy, /* SIOCSIWSPY */
10788 iw_handler_get_spy, /* SIOCGIWSPY */
10789 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10790 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10791 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10792 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10793 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10794 (iw_handler) NULL, /* SIOCGIWAPLIST */
10795 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10796 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10797 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10798 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10799 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10800 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10801 (iw_handler) NULL, /* -- hole -- */
10802 (iw_handler) NULL, /* -- hole -- */
10803 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10804 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10805 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10806 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10807 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10808 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10809 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10810 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10811 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10812 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10813 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10814 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10815 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10816 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10817 (iw_handler) NULL, /* -- hole -- */
10818 (iw_handler) NULL, /* -- hole -- */
10819 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10820 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10821 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10822 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10823 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10824 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10825 (iw_handler) NULL, /* SIOCSIWPMKSA */
10826};
10827
10828static const iw_handler we_private[] = {
10829
10830 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10831 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10832 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10833 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10834 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10835 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010836 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10838 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10839 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010840#ifdef FEATURE_OEM_DATA_SUPPORT
10841 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10842 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10843#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010844
Jeff Johnson295189b2012-06-20 16:38:30 -070010845#ifdef WLAN_FEATURE_VOWIFI_11R
10846 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10847#endif
10848 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10849 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10850 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10851#ifdef WLAN_FEATURE_PACKET_FILTERING
10852 ,
10853 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10854#endif
10855#ifdef FEATURE_WLAN_SCAN_PNO
10856 ,
10857 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10858#endif
10859 ,
10860 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10861 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10862 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10863 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010864 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010865};
10866
10867/*Maximum command length can be only 15 */
10868static const struct iw_priv_args we_private_args[] = {
10869
Katya Nigamf0511f62015-05-05 16:40:57 +053010870 { WE_SET_MONITOR_STATE,
10871 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10872 0, "monitor" },
10873
Jeff Johnson295189b2012-06-20 16:38:30 -070010874 /* handlers for main ioctl */
10875 { WLAN_PRIV_SET_INT_GET_NONE,
10876 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10877 0,
10878 "" },
10879
10880 /* handlers for sub-ioctl */
10881 { WE_SET_11D_STATE,
10882 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10883 0,
10884 "set11Dstate" },
10885
10886 { WE_WOWL,
10887 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10888 0,
10889 "wowl" },
10890
10891 { WE_SET_POWER,
10892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10893 0,
10894 "setPower" },
10895
10896 { WE_SET_MAX_ASSOC,
10897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10898 0,
10899 "setMaxAssoc" },
10900
10901 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10903 0,
10904 "setAutoChannel" },
10905
10906 { WE_SET_DATA_INACTIVITY_TO,
10907 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10908 0,
10909 "inactivityTO" },
10910
10911 { WE_SET_MAX_TX_POWER,
10912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10913 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010914 "setMaxTxPower" },
10915
10916 { WE_SET_MAX_TX_POWER_2_4,
10917 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10918 0,
10919 "setTxMaxPower2G" },
10920
10921 { WE_SET_MAX_TX_POWER_5_0,
10922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10923 0,
10924 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010925
10926 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10927 * as well to keep same syntax as in SAP. Now onwards, STA
10928 * will support both */
10929 { WE_SET_MAX_TX_POWER,
10930 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10931 0,
10932 "setTxMaxPower" },
10933
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10935 * 1 = enable and 0 = disable */
10936 {
10937 WE_SET_HIGHER_DTIM_TRANSITION,
10938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10939 0,
10940 "setHDtimTransn" },
10941
10942 { WE_SET_TM_LEVEL,
10943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010944 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010945 "setTmLevel" },
10946
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010947 { WE_ENABLE_STRICT_FCC_REG,
10948 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10949 0,
10950 "setStrictFCCreg" },
10951
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010952 { WE_SET_DEBUG_LOG,
10953 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10954 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010955#ifdef FEATURE_WLAN_TDLS
10956 {
10957 WE_SET_TDLS_OFF_CHAN,
10958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10959 0,
10960 "tdlsoffchan" },
10961 {
10962 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10963 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10964 0,
10965 "tdlsecchnoffst" },
10966 {
10967 WE_SET_TDLS_OFF_CHAN_MODE,
10968 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10969 0,
10970 "tdlsoffchnmode" },
10971#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010972
Peng Xu2446a892014-09-05 17:21:18 +053010973 { WE_SET_SCAN_BAND_PREFERENCE,
10974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10975 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010976 {
10977 WE_GET_FRAME_LOG,
10978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10979 0,
10980 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010981
Abhishek Singh01c73d12015-03-12 15:13:44 +053010982 { WE_SET_MIRACAST_VENDOR_CONFIG,
10983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10984 0, "setMiracstConf" },
10985
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010986#ifdef FEATURE_WLAN_TDLS
10987 {
10988 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10990 0,
10991 "tdls_2040bsscox" },
10992#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010993 { WE_SET_RTS_CTS_HTVHT,
10994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10995 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010996 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10998 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053010999 { WE_SET_PROXIMITY_ENABLE,
11000 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11001 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 /* handlers for main ioctl */
11003 { WLAN_PRIV_SET_NONE_GET_INT,
11004 0,
11005 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11006 "" },
11007
11008 /* handlers for sub-ioctl */
11009 { WE_GET_11D_STATE,
11010 0,
11011 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11012 "get11Dstate" },
11013
11014 { WE_IBSS_STATUS,
11015 0,
11016 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11017 "getAdhocStatus" },
11018
11019 { WE_PMC_STATE,
11020 0,
11021 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11022 "pmcState" },
11023
11024 { WE_GET_WLAN_DBG,
11025 0,
11026 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11027 "getwlandbg" },
11028
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 { WE_GET_MAX_ASSOC,
11030 0,
11031 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11032 "getMaxAssoc" },
11033
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 { WE_GET_WDI_DBG,
11035 0,
11036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11037 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011038
11039 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11040 0,
11041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11042 "getAutoChannel" },
11043
11044 { WE_GET_CONCURRENCY_MODE,
11045 0,
11046 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11047 "getconcurrency" },
11048
Peng Xu2446a892014-09-05 17:21:18 +053011049 { WE_GET_SCAN_BAND_PREFERENCE,
11050 0,
11051 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11052 "get_scan_pref"},
11053
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011054 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11055 0,
11056 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11057 "getCurAnt"},
11058
Jeff Johnson295189b2012-06-20 16:38:30 -070011059 /* handlers for main ioctl */
11060 { WLAN_PRIV_SET_CHAR_GET_NONE,
11061 IW_PRIV_TYPE_CHAR| 512,
11062 0,
11063 "" },
11064
11065 /* handlers for sub-ioctl */
11066 { WE_WOWL_ADD_PTRN,
11067 IW_PRIV_TYPE_CHAR| 512,
11068 0,
11069 "wowlAddPtrn" },
11070
11071 { WE_WOWL_DEL_PTRN,
11072 IW_PRIV_TYPE_CHAR| 512,
11073 0,
11074 "wowlDelPtrn" },
11075
11076#if defined WLAN_FEATURE_VOWIFI
11077 /* handlers for sub-ioctl */
11078 { WE_NEIGHBOR_REPORT_REQUEST,
11079 IW_PRIV_TYPE_CHAR | 512,
11080 0,
11081 "neighbor" },
11082#endif
11083 { WE_SET_AP_WPS_IE,
11084 IW_PRIV_TYPE_CHAR| 512,
11085 0,
11086 "set_ap_wps_ie" },
11087
11088 { WE_SET_CONFIG,
11089 IW_PRIV_TYPE_CHAR| 512,
11090 0,
11091 "setConfig" },
11092
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011093 { WE_SET_ENCRYPT_MSG,
11094 IW_PRIV_TYPE_CHAR| 512,
11095 0,
11096 "encryptMsg" },
11097
11098
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 /* handlers for main ioctl */
11100 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11101 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11102 0,
11103 "" },
11104
11105 /* handlers for sub-ioctl */
11106 { WE_SET_WLAN_DBG,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11108 0,
11109 "setwlandbg" },
11110
Jeff Johnson295189b2012-06-20 16:38:30 -070011111 { WE_SET_WDI_DBG,
11112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11113 0,
11114 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011115
11116 { WE_SET_SAP_CHANNELS,
11117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11118 0,
11119 "setsapchannels" },
11120
11121 /* handlers for main ioctl */
11122 { WLAN_PRIV_GET_CHAR_SET_NONE,
11123 0,
11124 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11125 "" },
11126
11127 /* handlers for sub-ioctl */
11128 { WE_WLAN_VERSION,
11129 0,
11130 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11131 "version" },
11132 { WE_GET_STATS,
11133 0,
11134 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11135 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011136 { WE_GET_STATES,
11137 0,
11138 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11139 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011140 { WE_GET_CFG,
11141 0,
11142 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11143 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011144#ifdef WLAN_FEATURE_11AC
11145 { WE_GET_RSSI,
11146 0,
11147 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11148 "getRSSI" },
11149#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011150#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011151 { WE_GET_ROAM_RSSI,
11152 0,
11153 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11154 "getRoamRSSI" },
11155#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011156 { WE_GET_WMM_STATUS,
11157 0,
11158 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11159 "getWmmStatus" },
11160 {
11161 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011162 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11164 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011165#ifdef FEATURE_WLAN_TDLS
11166 {
11167 WE_GET_TDLS_PEERS,
11168 0,
11169 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11170 "getTdlsPeers" },
11171#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011172#ifdef WLAN_FEATURE_11W
11173 {
11174 WE_GET_11W_INFO,
11175 0,
11176 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11177 "getPMFInfo" },
11178#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011179#ifdef WLAN_FEATURE_RMC
11180 {
11181 WE_GET_IBSS_STA_INFO,
11182 0,
11183 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11184 "getIbssSTAs" },
11185#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011186 { WE_GET_SNR,
11187 0,
11188 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11189 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011190#ifdef FEATURE_OEM_DATA_SUPPORT
11191 {
11192 WE_GET_OEM_DATA_CAP,
11193 0,
11194 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11195 "getOemDataCap" },
11196#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 /* handlers for main ioctl */
11198 { WLAN_PRIV_SET_NONE_GET_NONE,
11199 0,
11200 0,
11201 "" },
11202
11203 /* handlers for sub-ioctl */
11204 { WE_CLEAR_STATS,
11205 0,
11206 0,
11207 "clearStats" },
11208 { WE_INIT_AP,
11209 0,
11210 0,
11211 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011212#ifdef WLAN_FEATURE_RMC
11213 {
11214 WE_IBSS_GET_PEER_INFO_ALL,
11215 0,
11216 0,
11217 "ibssPeerInfoAll" },
11218#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 { WE_STOP_AP,
11220 0,
11221 0,
11222 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011223#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 { WE_ENABLE_AMP,
11225 0,
11226 0,
11227 "enableAMP" },
11228 { WE_DISABLE_AMP,
11229 0,
11230 0,
11231 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011232#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011233 { WE_ENABLE_DXE_STALL_DETECT,
11234 0,
11235 0,
11236 "dxeStallDetect" },
11237 { WE_DISPLAY_DXE_SNAP_SHOT,
11238 0,
11239 0,
11240 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011241 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11242 0,
11243 0,
11244 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011245 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011246 WE_SET_REASSOC_TRIGGER,
11247 0,
11248 0,
11249 "reassoc" },
11250 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011251 WE_STOP_OBSS_SCAN,
11252 0,
11253 0,
11254 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011255 {
11256 WE_DUMP_ROAM_TIMER_LOG,
11257 0,
11258 0,
11259 "dumpRoamDelay" },
11260 {
11261 WE_RESET_ROAM_TIMER_LOG,
11262 0,
11263 0,
11264 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011265 {
11266 WE_GET_FW_LOGS,
11267 0,
11268 0,
11269 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011270 {
11271 WE_GET_FW_MEMDUMP,
11272 0,
11273 0,
11274 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 /* handlers for main ioctl */
11276 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11277 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11278 0,
11279 "" },
11280
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011281
11282
Jeff Johnson295189b2012-06-20 16:38:30 -070011283 /* handlers for sub-ioctl */
11284 { WE_LOG_DUMP_CMD,
11285 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11286 0,
11287 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011288#ifdef WLAN_FEATURE_RMC
11289 { WE_IBSS_GET_PEER_INFO,
11290 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11291 0,
11292 "ibssPeerInfo" },
11293#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011294
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011295 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011296 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11297 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11298 0,
11299 "setdumplog" },
11300
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011301 { WE_MTRACE_DUMP_CMD,
11302 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11303 0,
11304 "dumplog" },
11305
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011306 /* handlers for sub ioctl */
11307 {
11308 WE_MCC_CONFIG_CREDENTIAL,
11309 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11310 0,
11311 "setMccCrdnl" },
11312
11313 /* handlers for sub ioctl */
11314 {
11315 WE_MCC_CONFIG_PARAMS,
11316 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11317 0,
11318 "setMccConfig" },
11319
Chilam NG571c65a2013-01-19 12:27:36 +053011320#ifdef FEATURE_WLAN_TDLS
11321 /* handlers for sub ioctl */
11322 {
11323 WE_TDLS_CONFIG_PARAMS,
11324 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11325 0,
11326 "setTdlsConfig" },
11327#endif
11328
Katya Nigamf0511f62015-05-05 16:40:57 +053011329 {
11330 WE_CONFIGURE_MONITOR_MODE,
11331 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11332 0,
11333 "MonitorModeConf" },
11334
11335 {
11336 WE_SET_MONITOR_MODE_FILTER,
11337 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11338 0,
11339 "MonitorFilter" },
11340
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 /* handlers for main ioctl */
11342 { WLAN_PRIV_ADD_TSPEC,
11343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11344 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11345 "addTspec" },
11346
11347 /* handlers for main ioctl */
11348 { WLAN_PRIV_DEL_TSPEC,
11349 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11351 "delTspec" },
11352
11353 /* handlers for main ioctl */
11354 { WLAN_PRIV_GET_TSPEC,
11355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11357 "getTspec" },
11358
Jeff Johnsone7245742012-09-05 17:12:55 -070011359#ifdef FEATURE_OEM_DATA_SUPPORT
11360 /* handlers for main ioctl - OEM DATA */
11361 {
11362 WLAN_PRIV_SET_OEM_DATA_REQ,
11363 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11364 0,
11365 "set_oem_data_req" },
11366
11367 /* handlers for main ioctl - OEM DATA */
11368 {
11369 WLAN_PRIV_GET_OEM_DATA_RSP,
11370 0,
11371 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11372 "get_oem_data_rsp" },
11373#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011374
Jeff Johnson295189b2012-06-20 16:38:30 -070011375 /* handlers for main ioctl - host offload */
11376 {
11377 WLAN_PRIV_SET_HOST_OFFLOAD,
11378 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11379 0,
11380 "setHostOffload" },
11381
11382 {
11383 WLAN_GET_WLAN_STATISTICS,
11384 0,
11385 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11386 "getWlanStats" },
11387
11388 {
11389 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011390 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11391 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 0,
11393 "setKeepAlive" },
11394#ifdef WLAN_FEATURE_PACKET_FILTERING
11395 {
11396 WLAN_SET_PACKET_FILTER_PARAMS,
11397 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11398 0,
11399 "setPktFilter" },
11400#endif
11401#ifdef FEATURE_WLAN_SCAN_PNO
11402 {
11403 WLAN_SET_PNO,
11404 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11405 0,
11406 "setpno" },
11407#endif
11408 {
11409 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 0,
11412 "SETBAND" },
11413 /* handlers for dynamic MC BC ioctl */
11414 {
11415 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011416 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 0,
11418 "setMCBCFilter" },
11419 {
11420 WLAN_PRIV_CLEAR_MCBC_FILTER,
11421 0,
11422 0,
11423 "clearMCBCFilter" },
11424 {
11425 WLAN_SET_POWER_PARAMS,
11426 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11427 0,
11428 "setpowerparams" },
11429 {
11430 WLAN_GET_LINK_SPEED,
11431 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011432 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011433};
11434
11435
11436
11437const struct iw_handler_def we_handler_def = {
11438 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11439 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11440 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11441
11442 .standard = (iw_handler *)we_handler,
11443 .private = (iw_handler *)we_private,
11444 .private_args = we_private_args,
11445 .get_wireless_stats = get_wireless_stats,
11446};
11447
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011448int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11449{
11450 v_U32_t cmd = 288; //Command to RIVA
11451 hdd_context_t *pHddCtx = NULL;
11452 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11453 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11454 /*
11455 *configMccParam : specify the bit which needs to be modified
11456 *allowed to update based on wlan_qcom_cfg.ini
11457 * configuration
11458 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11459 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11460 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11461 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11462 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11463 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11464 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11465 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11466 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11467 * Bit 9 : Reserved
11468 */
11469 switch (arg1)
11470 {
11471 //Update MCC SCHEDULE_TIME_SLICE parameter
11472 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11473 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11474 {
11475 if((arg2 >= 5) && (arg2 <= 20))
11476 {
11477 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11478 }
11479 else
11480 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011481 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011482 return 0;
11483 }
11484 }
11485 break;
11486
11487 //Update MCC MAX_NULL_SEND_TIME parameter
11488 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11489 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11490 {
11491 if((arg2 >= 1) && (arg2 <= 10))
11492 {
11493 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11494 }
11495 else
11496 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011497 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011498 return 0;
11499 }
11500 }
11501 break;
11502
11503 //Update MCC TX_EARLY_STOP_TIME parameter
11504 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11505 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11506 {
11507 if((arg2 >= 1) && (arg2 <= 10))
11508 {
11509 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11510 }
11511 else
11512 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011513 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011514 return 0;
11515 }
11516 }
11517 break;
11518
11519 //Update MCC RX_DRAIN_TIME parameter
11520 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11521 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11522 {
11523 if((arg2 >= 1) && (arg2 <= 10))
11524 {
11525 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11526 }
11527 else
11528 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011529 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011530 return 0;
11531 }
11532 }
11533 break;
11534
11535 //Update MCC CHANNEL_SWITCH_TIME parameter
11536 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11537 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11538 {
11539 if((arg2 >= 1) && (arg2 <= 20))
11540 {
11541 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11542 }
11543 else
11544 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011545 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011546 return 0;
11547 }
11548 }
11549 break;
11550
11551 //Update MCC MIN_CHANNEL_TIME parameter
11552 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11553 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11554 {
11555 if((arg2 >= 5) && (arg2 <= 20))
11556 {
11557 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11558 }
11559 else
11560 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011561 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011562 return 0;
11563 }
11564 }
11565 break;
11566
11567 //Update MCC PARK_BEFORE_TBTT parameter
11568 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11569 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11570 {
11571 if((arg2 >= 1) && (arg2 <= 5))
11572 {
11573 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11574 }
11575 else
11576 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011577 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011578 return 0;
11579 }
11580 }
11581 break;
11582
11583 //Update MCC MIN_AFTER_DTIM parameter
11584 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11585 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11586 {
11587 if((arg2 >= 5) && (arg2 <= 15))
11588 {
11589 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11590 }
11591 else
11592 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011593 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011594 return 0;
11595 }
11596 }
11597 break;
11598
11599 //Update MCC TOO_CLOSE_MARGIN parameter
11600 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11601 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11602 {
11603 if((arg2 >= 1) && (arg2 <= 3))
11604 {
11605 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11606 }
11607 else
11608 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011609 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011610 return 0;
11611 }
11612 }
11613 break;
11614
11615 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011616 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011617 __FUNCTION__,arg1);
11618 break;
11619 }
11620 return 0;
11621}
11622
Jeff Johnson295189b2012-06-20 16:38:30 -070011623int hdd_set_wext(hdd_adapter_t *pAdapter)
11624{
11625 hdd_wext_state_t *pwextBuf;
11626 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011627 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011628
11629 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11630
11631 // Now configure the roaming profile links. To SSID and bssid.
11632 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11633 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11634
11635 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11636 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11637
11638 /*Set the numOfChannels to zero to scan all the channels*/
11639 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11640 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11641
11642 /* Default is no encryption */
11643 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11644 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11645
11646 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11647 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11648
11649 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11650
11651 /* Default is no authentication */
11652 pwextBuf->roamProfile.AuthType.numEntries = 1;
11653 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11654
11655 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11656 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11657
11658 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011659 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011660
11661 hdd_clearRoamProfileIe(pAdapter);
11662
11663 return VOS_STATUS_SUCCESS;
11664
11665 }
11666
11667int hdd_register_wext(struct net_device *dev)
11668 {
11669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11670 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11671 VOS_STATUS status;
11672
11673 ENTER();
11674
11675 // Zero the memory. This zeros the profile structure.
11676 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11677
11678 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11679
11680
11681 status = hdd_set_wext(pAdapter);
11682
11683 if(!VOS_IS_STATUS_SUCCESS(status)) {
11684
Arif Hussain6d2a3322013-11-17 19:50:10 -080011685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 return eHAL_STATUS_FAILURE;
11687 }
11688
11689 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11690 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 return eHAL_STATUS_FAILURE;
11693 }
11694
11695 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11696 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 return eHAL_STATUS_FAILURE;
11699 }
11700
11701 // Register as a wireless device
11702 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11703
11704 EXIT();
11705 return 0;
11706}
11707
11708int hdd_UnregisterWext(struct net_device *dev)
11709{
c_hpothu2a13bc32015-01-21 12:48:54 +053011710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11711 if (dev != NULL)
11712 {
11713 rtnl_lock();
11714 dev->wireless_handlers = NULL;
11715 rtnl_unlock();
11716 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 return 0;
11719}
11720
11721