blob: ca82148738ff02be7782233dd08221f4e192970a [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
3801 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3802
3803 if (VOS_STATUS_SUCCESS == vosStatus)
3804 {
3805 /* append the rssi to the ssid in the format required by
3806 the WiFI Framework */
3807 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3808 rc += ssidlen;
3809 }
3810 else
3811 {
3812 rc = -1;
3813 }
3814 }
3815
3816 /* verify that we wrote a valid response */
3817 if ((rc < 0) || (rc >= len))
3818 {
3819 // encoding or length error?
3820 hddLog(VOS_TRACE_LEVEL_ERROR,
3821 "%s: Unable to encode RSSI, got [%s]",
3822 __func__, cmd);
3823 return -EIO;
3824 }
3825
3826 /* a value is being successfully returned */
3827 return rc;
3828}
3829
3830/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 * Support for SoftAP channel range private command
3832 */
3833static int iw_softap_set_channel_range( struct net_device *dev,
3834 int startChannel,
3835 int endChannel,
3836 int band)
3837{
Jeff Johnson43971f52012-07-17 12:26:56 -07003838 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 int ret = 0;
3840 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3841 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003842 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3843
Jeff Johnson295189b2012-06-20 16:38:30 -07003844
3845 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3846 if (VOS_STATUS_SUCCESS != status)
3847 {
3848 ret = -EINVAL;
3849 }
Yathish9f22e662012-12-10 14:21:35 -08003850 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 return ret;
3852}
3853
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303854static uint8 chartohex(char c)
3855{
3856 uint8 val = 0;
3857 if (c >= '0' && c <= '9')
3858 val = c - '0';
3859 else if (c >= 'a' && c <= 'f')
3860 val = c - 'a' + 10;
3861 else if (c >= 'A' && c <= 'F')
3862 val = c - 'A' + 10;
3863 else
3864 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3865
3866 return val;
3867}
3868
3869uint8 getByte(char **buf)
3870{
3871 uint8 byte = 0;
3872 char *temp = *buf;
3873 byte = chartohex(*temp) * 16;
3874 temp++;
3875 byte += chartohex(*temp);
3876 temp++;
3877 *buf = temp;
3878 return byte;
3879}
3880
3881static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3882{
3883 tSir80211Header *macHeader;
3884 int i = 0, j = 0, length = 0;
3885 uint8 byte = 0;
3886 char *temp = pBuffer;
3887 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303888 char *pHeader;
3889 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303890
3891 macHeader = &pkt->macHeader;
3892
3893 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3894
3895 temp++;
3896
3897 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3898 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3899 pkt->encParams.keyParams.key[0].keyId);
3900
3901 for (i = 0; i< 16; i++) {
3902 pkt->encParams.keyParams.key[0].key[i]
3903 = getByte(&temp);
3904 }
3905
3906 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3907 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3908
3909 for (i = 0; i< 6; i++) {
3910 pkt->encParams.pn[i]
3911 = getByte(&temp);
3912 }
3913
3914 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3915 &pkt->encParams.pn[0], 6, 0);
3916
3917 for (i = 0, j= 5; i< 3; i++, j--) {
3918 byte = pkt->encParams.pn[i];
3919 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3920 pkt->encParams.pn[j] = byte;
3921 }
3922
3923 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303924 if (length > sizeof(tSir80211Header))
3925 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303926
Srinivas Dasari2382de62015-01-22 15:00:04 +05303927 pHeader = temp;
3928 vos_mem_zero(&header, sizeof(tSir80211Header));
3929 for (i = 0; i < length; i++) {
3930 *((uint8 *)&header + i) = getByte(&pHeader);
3931 }
3932
3933 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3934 (char *)&header, length, 0);
3935
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303936 byte = getByte(&temp);
3937
3938 macHeader->frameCtrl.protVer = byte & 0x3;
3939 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3940 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3941
3942 byte = getByte(&temp);
3943 macHeader->frameCtrl.toDS = (byte) & 0x1;
3944 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3945 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3946 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3947 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3948 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3949 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3950 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3951
3952 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3953 "macHeader->frameCtrl.type : %x "
3954 "macHeader->frameCtrl.subType : %x "
3955 "macHeader->frameCtrl.toDS : %x "
3956 "macHeader->frameCtrl.fromDS : %x "
3957 "macHeader->frameCtrl.moreFrag : %x "
3958 "macHeader->frameCtrl.retry : %x "
3959 "macHeader->frameCtrl.powerMgmt : %x "
3960 "macHeader->frameCtrl.MoreData : %x "
3961 "macHeader->frameCtrl.wep : %x "
3962 "macHeader->frameCtrl.order : %x "
3963 , macHeader->frameCtrl.protVer
3964 , macHeader->frameCtrl.type
3965 , macHeader->frameCtrl.subType
3966 , macHeader->frameCtrl.toDS
3967 , macHeader->frameCtrl.fromDS
3968 , macHeader->frameCtrl.moreFrag
3969 , macHeader->frameCtrl.retry
3970 , macHeader->frameCtrl.powerMgmt
3971 , macHeader->frameCtrl.moreData
3972 , macHeader->frameCtrl.wep
3973 , macHeader->frameCtrl.order);
3974
3975
3976 macHeader->usDurationId = getByte(&temp);
3977 macHeader->usDurationId += getByte(&temp) << 8;
3978
3979 macHeader->vA1[0] = getByte(&temp);
3980 macHeader->vA1[1] = getByte(&temp);
3981 macHeader->vA1[2] = getByte(&temp);
3982 macHeader->vA1[3] = getByte(&temp);
3983 macHeader->vA1[4] = getByte(&temp);
3984 macHeader->vA1[5] = getByte(&temp);
3985
3986 macHeader->vA2[0] = getByte(&temp);
3987 macHeader->vA2[1] = getByte(&temp);
3988 macHeader->vA2[2] = getByte(&temp);
3989 macHeader->vA2[3] = getByte(&temp);
3990 macHeader->vA2[4] = getByte(&temp);
3991 macHeader->vA2[5] = getByte(&temp);
3992
3993 macHeader->vA3[0] = getByte(&temp);
3994 macHeader->vA3[1] = getByte(&temp);
3995 macHeader->vA3[2] = getByte(&temp);
3996 macHeader->vA3[3] = getByte(&temp);
3997 macHeader->vA3[4] = getByte(&temp);
3998 macHeader->vA3[5] = getByte(&temp);
3999
4000 macHeader->sSeqCtrl = getByte(&temp);
4001 fragNum = macHeader->sSeqCtrl & 0xF;
4002 macHeader->sSeqCtrl >>= 4;
4003
4004 macHeader->sSeqCtrl += getByte(&temp) << 4;
4005
4006 macHeader->sSeqCtrl |= fragNum << 12;
4007
4008 if (length == 30 || length == 32) {
4009 macHeader->optvA4[0] = getByte(&temp);
4010 macHeader->optvA4[1] = getByte(&temp);
4011 macHeader->optvA4[2] = getByte(&temp);
4012 macHeader->optvA4[3] = getByte(&temp);
4013 macHeader->optvA4[4] = getByte(&temp);
4014 macHeader->optvA4[5] = getByte(&temp);
4015 }
4016
4017 if (length == 26 || length == 32) {
4018 macHeader->usQosCtrl = getByte(&temp);
4019 macHeader->usQosCtrl += getByte(&temp) << 8;
4020 }
4021
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304022 //parse payload
4023 length = getByte(&temp);
4024 length += getByte(&temp) << 8;
4025 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4026
4027 pkt->data.length = length;
4028
4029 for (i = 0; i< length; i++) {
4030 pkt->data.data[i] = getByte(&temp);
4031 }
4032
4033 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4034 &pkt->data.data[0], pkt->data.length, 0);
4035}
4036
4037/**---------------------------------------------------------------------------
4038
4039 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4040 encrypt message request
4041 This is an asynchronous callback function from SME when the encrypted data
4042 is received
4043
4044 \pEncInfoRsp -> Encrypted data info
4045
4046 \return - 0 for success non-zero for failure
4047 --------------------------------------------------------------------------*/
4048static void
4049hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4050{
4051 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4052
4053 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4054
4055 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4056 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4057 pEncryptedDataRsp->encryptedPayload.length);
4058 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4059 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4060 pEncryptedDataRsp->encryptedPayload.data,
4061 pEncryptedDataRsp->encryptedPayload.length, 0);
4062}
4063
Jeff Johnson295189b2012-06-20 16:38:30 -07004064VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4065{
4066 struct statsContext context;
4067 eHalStatus status;
4068 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304069 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
4071 if (NULL == pAdapter)
4072 {
4073 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4074 return VOS_STATUS_E_FAULT;
4075 }
4076
4077 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4078 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304079 if (pHddCtx->isLogpInProgress) {
4080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4081 "%s:LOGP in Progress. Ignore!!!", __func__);
4082 return VOS_STATUS_E_FAILURE;
4083 }
4084
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 init_completion(&context.completion);
4086
4087 context.pAdapter = pAdapter;
4088 context.magic = POWER_CONTEXT_MAGIC;
4089
4090 if (DRIVER_POWER_MODE_ACTIVE == mode)
4091 {
4092 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4093 "Full Power", __func__);
4094 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4095 iw_power_callback_fn, &context,
4096 eSME_FULL_PWR_NEEDED_BY_HDD);
4097 // Enter Full power command received from GUI this means we are disconnected
4098 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4099 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4100 if (eHAL_STATUS_PMC_PENDING == status)
4101 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004102 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 int lrc = wait_for_completion_interruptible_timeout(
4104 &context.completion,
4105 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004106
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 if (lrc <= 0)
4108 {
4109 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004110 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 }
4112 }
4113 }
4114 else if (DRIVER_POWER_MODE_AUTO == mode)
4115 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304116 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4117 * was already in BMPS state and thus either STA or P2P-CLI is in
4118 * associated state and authenticated, so even if STA connState is
4119 * not associated it can be assumed that P2P-CLI is associated and
4120 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4121 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4122 * if all condition are satisfied for entering BMPS.
4123 */
4124 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4125 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304126 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304127 hddLog(LOGE,
4128 FL("Station is associated but, still not Authenticated ignore "
4129 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304130 return VOS_STATUS_E_AGAIN;
4131 }
4132
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4134 {
4135 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4136 __func__);
4137 // Enter BMPS command received from GUI this means DHCP is completed
4138 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4139 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4140 FALSE);
4141 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4142 iw_power_callback_fn, &context);
4143 if (eHAL_STATUS_PMC_PENDING == status)
4144 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004145 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 int lrc = wait_for_completion_interruptible_timeout(
4147 &context.completion,
4148 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 if (lrc <= 0)
4150 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004151 hddLog(VOS_TRACE_LEVEL_ERROR,
4152 "%s: SME %s while requesting BMPS",
4153 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 }
4155 }
4156 }
4157 else
4158 {
4159 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4160 "enabled in the cfg");
4161 }
4162 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004163
4164 /* either we never sent a request, we sent a request and received a
4165 response or we sent a request and timed out. if we never sent a
4166 request or if we sent a request and got a response, we want to
4167 clear the magic out of paranoia. if we timed out there is a
4168 race condition such that the callback function could be
4169 executing at the same time we are. of primary concern is if the
4170 callback function had already verified the "magic" but had not
4171 yet set the completion variable when a timeout occurred. we
4172 serialize these activities by invalidating the magic while
4173 holding a shared spinlock which will cause us to block if the
4174 callback is currently executing */
4175 spin_lock(&hdd_context_lock);
4176 context.magic = 0;
4177 spin_unlock(&hdd_context_lock);
4178
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 return VOS_STATUS_SUCCESS;
4180}
4181
4182VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4183 hdd_adapter_t *pAdapter)
4184{
4185 VOS_STATUS vos_Status;
4186
4187 if ((NULL == pAdapter) || (NULL == pHddCtx))
4188 {
4189 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4190 return VOS_STATUS_E_FAULT;
4191 }
4192
4193 /**Exit from Deep sleep or standby if we get the driver
4194 START cmd from android GUI
4195 */
4196 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4197 {
4198 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4199 "from Stand by",__func__);
4200 vos_Status = hdd_exit_standby(pHddCtx);
4201 }
4202 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4203 {
4204 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4205 "from deep sleep",__func__);
4206 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4207 }
4208 else
4209 {
4210 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4211 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4212 vos_Status = VOS_STATUS_SUCCESS;
4213 }
4214
4215 return vos_Status;
4216}
4217
4218VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4219{
4220 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4221
4222 if (NULL == pHddCtx)
4223 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304224 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 return VOS_STATUS_E_FAULT;
4226 }
4227
4228 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4229 {
4230 //Execute standby procedure.
4231 //Executing standby procedure will cause the STA to
4232 //disassociate first and then the chip will be put into standby.
4233 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4234 vos_Status = hdd_enter_standby(pHddCtx);
4235 }
4236 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4237 pHddCtx->cfg_ini->nEnableDriverStop)
4238 {
4239 //Execute deep sleep procedure
4240 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004241 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 //Deep sleep not supported
4243 vos_Status = hdd_enter_standby(pHddCtx);
4244 }
4245 else
4246 {
4247 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4248 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4249 vos_Status = VOS_STATUS_SUCCESS;
4250 }
4251
4252 return vos_Status;
4253}
4254
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004255
4256void* wlan_hdd_change_country_code_callback(void *pAdapter)
4257{
4258
4259 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004260 complete(&call_back_pAdapter->change_country_code);
4261
4262 return NULL;
4263}
4264
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304265static int __iw_set_priv(struct net_device *dev,
4266 struct iw_request_info *info,
4267 union iwreq_data *wrqu, char *extra)
4268{
4269 hdd_adapter_t *pAdapter;
4270 char *cmd = NULL;
4271 int cmd_len = wrqu->data.length;
4272 int rc = 0, ret = 0;
4273 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4274
4275 hdd_context_t *pHddCtx;
4276
4277 ENTER();
4278
4279 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4280 if (NULL == pAdapter)
4281 {
4282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4283 "mem_alloc_copy_from_user_helper fail");
4284 return -EINVAL;
4285 }
4286 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4287 rc = wlan_hdd_validate_context(pHddCtx);
4288 if (0 != rc)
4289 {
4290 return rc;
4291 }
4292
4293 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4294 wrqu->data.length);
4295 if (NULL == cmd)
4296 {
4297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4298 "mem_alloc_copy_from_user_helper fail");
4299 return -ENOMEM;
4300 }
4301
4302 if (ioctl_debug)
4303 {
4304 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4305 }
4306
4307 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4308 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4309
4310 if (strncmp(cmd, "CSCAN", 5) == 0 )
4311 {
4312 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4314 "%s: Error in iw_set_scan!", __func__);
4315 rc = -EINVAL;
4316 }
4317 }
4318 else if( strcasecmp(cmd, "start") == 0 ) {
4319
4320 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4321 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4322
4323 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4324 if (vos_status == VOS_STATUS_SUCCESS)
4325 {
4326 union iwreq_data wrqu;
4327 char buf[10];
4328
4329 memset(&wrqu, 0, sizeof(wrqu));
4330 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4331 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4332 }
4333 else
4334 {
4335 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4336 rc = -EIO;
4337 }
4338 goto done;
4339 }
4340 else if( strcasecmp(cmd, "stop") == 0 )
4341 {
4342 union iwreq_data wrqu;
4343 char buf[10];
4344
4345 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4346
4347 wlan_hdd_enter_lowpower(pHddCtx);
4348 memset(&wrqu, 0, sizeof(wrqu));
4349 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4350 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4351 goto done;
4352 }
4353 else if (strcasecmp(cmd, "macaddr") == 0)
4354 {
4355 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4356 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4357 }
4358 else if (strcasecmp(cmd, "scan-active") == 0)
4359 {
4360 hddLog(LOG1,
4361 FL("making default scan to active"));
4362 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4363 ret = snprintf(cmd, cmd_len, "OK");
4364 }
4365 else if (strcasecmp(cmd, "scan-passive") == 0)
4366 {
4367 hddLog(LOG1,
4368 FL("making default scan to passive"));
4369 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4370 ret = snprintf(cmd, cmd_len, "OK");
4371 }
4372 else if( strcasecmp(cmd, "scan-mode") == 0 )
4373 {
4374 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4375 }
4376 else if( strcasecmp(cmd, "linkspeed") == 0 )
4377 {
4378 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4379 }
4380 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4381 {
4382 ret = iw_get_rssi(dev, info, wrqu, cmd);
4383 }
4384 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4385 int mode;
4386 char *ptr;
4387
4388 if (9 < cmd_len)
4389 {
4390 ptr = (char*)(cmd + 9);
4391
4392 }else{
4393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4394 "CMD LENGTH %d is not correct",cmd_len);
4395 kfree(cmd);
4396 return -EINVAL;
4397 }
4398
4399 if (1 != sscanf(ptr,"%d",&mode))
4400 {
4401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4402 "powermode input %s is not correct",ptr);
4403 kfree(cmd);
4404 return -EIO;
4405 }
4406
4407 wlan_hdd_enter_bmps(pAdapter, mode);
4408 /*TODO:Set the power mode*/
4409 }
4410 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4411 v_U32_t pmc_state;
4412 v_U16_t value;
4413
4414 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4415 if(pmc_state == BMPS) {
4416 value = DRIVER_POWER_MODE_AUTO;
4417 }
4418 else {
4419 value = DRIVER_POWER_MODE_ACTIVE;
4420 }
4421 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4422 }
4423 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4424 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4425 /*TODO: set the btcoexmode*/
4426 }
4427 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4428
4429 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4430 /*TODO: Return the btcoex status*/
4431 }
4432 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4433
4434 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4435
4436 /*TODO: Enable Rx data Filter*/
4437 }
4438 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4439
4440 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4441
4442 /*TODO: Disable Rx data Filter*/
4443 }
4444 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4445
4446 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4447 /*TODO: rxfilter-statistics*/
4448 }
4449 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4450
4451 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4452 /*TODO: rxfilter-add*/
4453 }
4454 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4455
4456 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4457 /*TODO: rxfilter-remove*/
4458 }
4459#ifdef FEATURE_WLAN_SCAN_PNO
4460 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4461 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4462 /*TODO: support pnosetup*/
4463 }
4464 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4465 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4466 /*TODO: support pnoforce*/
4467 }
4468 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4469
4470 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4471 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4472 kfree(cmd);
4473 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4474 }
4475 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4476 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4477 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4478 kfree(cmd);
4479 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4480 }
4481#endif /*FEATURE_WLAN_SCAN_PNO*/
4482 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4483 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4484 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4485 kfree(cmd);
4486 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4487 }
4488 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4489 tSirTxPerTrackingParam tTxPerTrackingParam;
4490 char *ptr;
4491
4492 if (18 < cmd_len)
4493 {
4494 ptr = (char*)(cmd + 18);
4495 }else{
4496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4497 "CMD LENGTH %d is not correct",cmd_len);
4498 kfree(cmd);
4499 return -EINVAL;
4500 }
4501
4502 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4503 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4504 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4505 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4506 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4507 {
4508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4509 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4510 kfree(cmd);
4511 return -EIO;
4512 }
4513
4514 // parameters checking
4515 // period has to be larger than 0
4516 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4517 {
4518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4519 kfree(cmd);
4520 return -EIO;
4521 }
4522
4523 // use default value 5 is the input is not reasonable. in unit of 10%
4524 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4525 {
4526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4527 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4528 }
4529
4530 // default is 5
4531 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4532 {
4533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4534 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4535 }
4536
4537 if (eHAL_STATUS_SUCCESS !=
4538 sme_SetTxPerTracking(pHddCtx->hHal,
4539 hdd_tx_per_hit_cb,
4540 (void*)pAdapter, &tTxPerTrackingParam)) {
4541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4542 rc = -EIO;
4543 }
4544 }
4545 else {
4546 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4547 __func__, cmd);
4548 }
4549done:
4550 /* many of the commands write information back into the command
4551 string using snprintf(). check the return value here in one
4552 place */
4553 if ((ret < 0) || (ret >= cmd_len))
4554 {
4555 /* there was an encoding error or overflow */
4556 rc = -EINVAL;
4557 }
4558 else if (ret > 0)
4559 {
4560 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4561 {
4562 hddLog(VOS_TRACE_LEVEL_ERROR,
4563 "%s: failed to copy data to user buffer", __func__);
4564 kfree(cmd);
4565 return -EFAULT;
4566 }
4567 wrqu->data.length = ret;
4568 }
4569
4570 if (ioctl_debug)
4571 {
4572 pr_info("%s: rsp [%s] len [%d] status %d\n",
4573 __func__, cmd, wrqu->data.length, rc);
4574 }
4575 kfree(cmd);
4576 EXIT();
4577 return rc;
4578}
4579
4580static int iw_set_priv(struct net_device *dev,
4581 struct iw_request_info *info,
4582 union iwreq_data *wrqu, char *extra)
4583{
4584 int ret;
4585 vos_ssr_protect(__func__);
4586 ret = __iw_set_priv(dev, info, wrqu, extra);
4587 vos_ssr_unprotect(__func__);
4588
4589 return ret;
4590}
4591
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304592static int __iw_set_nick(struct net_device *dev,
4593 struct iw_request_info *info,
4594 union iwreq_data *wrqu, char *extra)
4595{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304596 hdd_adapter_t *pAdapter;
4597 hdd_context_t *pHddCtx;
4598 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304599
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304600 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304601
4602 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4603 if (NULL == pAdapter)
4604 {
4605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4606 "%s: Adapter is NULL",__func__);
4607 return -EINVAL;
4608 }
4609
4610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4611 ret = wlan_hdd_validate_context(pHddCtx);
4612 if (0 != ret)
4613 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304614 return ret;
4615 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304616 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304617 return 0;
4618}
4619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620static int iw_set_nick(struct net_device *dev,
4621 struct iw_request_info *info,
4622 union iwreq_data *wrqu, char *extra)
4623{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304624 int ret;
4625
4626 vos_ssr_protect(__func__);
4627 ret = __iw_set_nick(dev, info, wrqu, extra);
4628 vos_ssr_unprotect(__func__);
4629
4630 return ret;
4631}
4632
4633static int __iw_get_nick(struct net_device *dev,
4634 struct iw_request_info *info,
4635 union iwreq_data *wrqu, char *extra)
4636{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 hdd_adapter_t *pAdapter;
4638 hdd_context_t *pHddCtx;
4639 int ret = 0;
4640
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304642
4643 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4644 if (NULL == pAdapter)
4645 {
4646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4647 "%s: Adapter is NULL",__func__);
4648 return -EINVAL;
4649 }
4650
4651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4652 ret = wlan_hdd_validate_context(pHddCtx);
4653 if (0 != ret)
4654 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304655 return ret;
4656 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304657 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 return 0;
4659}
4660
4661static int iw_get_nick(struct net_device *dev,
4662 struct iw_request_info *info,
4663 union iwreq_data *wrqu, char *extra)
4664{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304665 int ret;
4666
4667 vos_ssr_protect(__func__);
4668 ret = __iw_get_nick(dev, info, wrqu, extra);
4669 vos_ssr_unprotect(__func__);
4670
4671 return ret;
4672}
4673
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304674/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304675static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4676{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4678 hdd_context_t *pHddCtx;
4679 hdd_station_ctx_t *pHddStaCtx;
4680 v_S7_t snr = 0, rssi = 0;
4681 eHalStatus status = eHAL_STATUS_SUCCESS;
4682
4683 ENTER();
4684
4685 if (NULL == pAdapter)
4686 {
4687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4688 "%s: Adapter is NULL",__func__);
4689 return NULL;
4690 }
4691
4692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4693 status = wlan_hdd_validate_context(pHddCtx);
4694 if (0 != status)
4695 {
4696 return NULL;
4697 }
4698
4699 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4700 if (NULL == pHddStaCtx)
4701 {
4702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4703 "%s: STA Context is NULL",__func__);
4704 return NULL;
4705 }
4706
4707 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4708 {
4709 wlan_hdd_get_station_stats(pAdapter);
4710 wlan_hdd_get_snr(pAdapter, &snr);
4711 wlan_hdd_get_rssi(pAdapter, &rssi);
4712
4713 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4714 pAdapter->iwStats.status = 0;
4715 pAdapter->iwStats.qual.qual = snr;
4716 pAdapter->iwStats.qual.level = rssi;
4717 pAdapter->iwStats.qual.noise = rssi - snr;
4718 pAdapter->iwStats.discard.code = 0;
4719 pAdapter->iwStats.discard.retries= 0;
4720 pAdapter->iwStats.miss.beacon = 0;
4721 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4722 }
4723 else
4724 {
4725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4726 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4727 return NULL;
4728 }
4729
4730 EXIT();
4731 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004732}
4733
4734static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4735{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304736
4737 struct iw_statistics *stats;
4738
4739 vos_ssr_protect(__func__);
4740 stats = __get_wireless_stats(dev);
4741 vos_ssr_unprotect(__func__);
4742
4743 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004744}
4745
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304746static int __iw_set_encode(struct net_device *dev,
4747 struct iw_request_info *info,
4748 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004749
4750{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304751 hdd_adapter_t *pAdapter;
4752 hdd_station_ctx_t *pHddStaCtx;
4753 hdd_wext_state_t *pWextState;
4754 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 struct iw_point *encoderq = &(wrqu->encoding);
4756 v_U32_t keyId;
4757 v_U8_t key_length;
4758 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4759 v_BOOL_t fKeyPresent = 0;
4760 int i;
4761 eHalStatus status = eHAL_STATUS_SUCCESS;
4762
4763
4764 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304765 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4766 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4769 "%s: Adapter is NULL",__func__);
4770 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304773 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4774 status = wlan_hdd_validate_context(pHddCtx);
4775 if (0 != status)
4776 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304777 return status;
4778 }
4779 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4780 if (NULL == pWextState)
4781 {
4782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4783 "%s: pWextState is NULL ",__func__);
4784 return -EINVAL;
4785 }
4786 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4787 if (NULL == pHddStaCtx)
4788 {
4789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4790 "%s: STA Context is NULL",__func__);
4791 return -EINVAL;
4792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004793
4794 keyId = encoderq->flags & IW_ENCODE_INDEX;
4795
4796 if(keyId)
4797 {
4798 if(keyId > MAX_WEP_KEYS)
4799 {
4800 return -EINVAL;
4801 }
4802
4803 fKeyPresent = 1;
4804 keyId--;
4805 }
4806 else
4807 {
4808 fKeyPresent = 0;
4809 }
4810
4811
4812 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4813 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 if(!fKeyPresent) {
4816
4817 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4818
4819 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4820 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4821 }
4822 }
4823 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4824 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4825 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4826 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4827
4828 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4829 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4830
4831 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4832 {
4833 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4834 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004835 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304836 {
4837 long ret;
4838 ret = wait_for_completion_interruptible_timeout(
4839 &pAdapter->disconnect_comp_var,
4840 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4841 if (ret <= 0)
4842 hddLog(VOS_TRACE_LEVEL_ERROR,
4843 FL("failed wait on disconnect_comp_var %ld"), ret);
4844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 }
4846
4847 return status;
4848
4849 }
4850
4851 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4852 {
4853 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4854
4855 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4856
4857 }
4858
4859
4860 if(wrqu->data.length > 0)
4861 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004862 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004863
4864 key_length = wrqu->data.length;
4865
4866 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4867
4868 if(5 == key_length)
4869 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004870 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004871
4872 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4873 {
4874 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4875 }
4876 else
4877 {
4878 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4879 }
4880 }
4881 else if(13 == key_length)
4882 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004883 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004884
4885 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4886 {
4887 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4888 }
4889 else
4890 {
4891 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4892 }
4893 }
4894 else
4895 {
4896 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004897 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 return -EINVAL;
4899 }
4900
4901 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4902 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4903 pWextState->roamProfile.EncryptionType.numEntries = 1;
4904 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4905 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4906 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4907
4908 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4909 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4910 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4911 {
4912
4913 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4914
4915 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4916 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4917
4918 return status;
4919 }
4920 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304921 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 return 0;
4923}
4924
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304925static int iw_set_encode(struct net_device *dev,
4926 struct iw_request_info *info,
4927 union iwreq_data *wrqu,char *extra)
4928{
4929 int ret;
4930
4931 vos_ssr_protect(__func__);
4932 ret = __iw_set_encode(dev, info, wrqu, extra);
4933 vos_ssr_unprotect(__func__);
4934
4935 return ret;
4936}
4937
4938static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 struct iw_request_info *info,
4940 struct iw_point *dwrq,
4941 char *extra)
4942{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304943 hdd_adapter_t *pAdapter;
4944 hdd_wext_state_t *pWextState;
4945 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 int keyId;
4947 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4948 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304949 int i, ret = 0;
4950 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004951
4952 ENTER();
4953
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304954 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4955 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004956 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4958 "%s: Adapter is NULL",__func__);
4959 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004960 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304961 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4962 ret = wlan_hdd_validate_context(pHddCtx);
4963 if (0 != ret)
4964 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304965 return ret;
4966 }
4967 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4968 if (NULL == pWextState)
4969 {
4970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4971 "%s: pWextState is NULL",__func__);
4972 return -EINVAL;
4973 }
4974 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004975
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 keyId = pRoamProfile->Keys.defaultIndex;
4977
4978 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4979 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004980 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 return -EINVAL;
4982 }
4983
4984 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4985 {
4986 dwrq->flags |= IW_ENCODE_ENABLED;
4987 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304988 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4989 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 }
4991 else
4992 {
4993 dwrq->flags |= IW_ENCODE_DISABLED;
4994 }
4995
4996 for(i=0; i < MAX_WEP_KEYS; i++)
4997 {
4998 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4999 {
5000 continue;
5001 }
5002 else
5003 {
5004 break;
5005 }
5006 }
5007
5008 if(MAX_WEP_KEYS == i)
5009 {
5010 dwrq->flags |= IW_ENCODE_NOKEY;
5011 }
5012 else
5013 {
5014 dwrq->flags |= IW_ENCODE_ENABLED;
5015 }
5016
5017 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5018
5019 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5020 {
5021 dwrq->flags |= IW_ENCODE_DISABLED;
5022 }
5023
5024 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5025
5026 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5027 {
5028 dwrq->flags |= IW_ENCODE_OPEN;
5029 }
5030 else
5031 {
5032 dwrq->flags |= IW_ENCODE_RESTRICTED;
5033 }
5034 EXIT();
5035 return 0;
5036
5037}
5038
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305039static int iw_get_encodeext(struct net_device *dev,
5040 struct iw_request_info *info,
5041 struct iw_point *dwrq,
5042 char *extra)
5043{
5044 int ret;
5045 vos_ssr_protect(__func__);
5046 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5047 vos_ssr_unprotect(__func__);
5048
5049 return ret;
5050}
5051
5052static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 struct iw_request_info *info,
5054 union iwreq_data *wrqu, char *extra)
5055{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305056 hdd_adapter_t *pAdapter;
5057 hdd_station_ctx_t *pHddStaCtx;
5058 hdd_wext_state_t *pWextState;
5059 hdd_context_t *pHddCtx;
5060 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305062 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 v_U32_t status = 0;
5064
5065 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5066
5067 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5068
5069 int key_index;
5070 struct iw_point *encoding = &wrqu->encoding;
5071 tCsrRoamSetKey setKey;
5072 v_U32_t roamId= 0xFF;
5073 VOS_STATUS vos_status;
5074
5075 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305076 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5077 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5080 "%s: Adapter is NULL",__func__);
5081 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305083 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5084 status = wlan_hdd_validate_context(pHddCtx);
5085 if (0 != status)
5086 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305087 return status;
5088 }
5089 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5090 if (NULL == pHddStaCtx)
5091 {
5092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5093 "%s: STA Context is NULL",__func__);
5094 return -EINVAL;
5095 }
5096 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5097 if (NULL == pWextState)
5098 {
5099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5100 "%s: pWextState is NULL",__func__);
5101 return -EINVAL;
5102 }
5103 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 key_index = encoding->flags & IW_ENCODE_INDEX;
5105
5106 if(key_index > 0) {
5107
5108 /*Convert from 1-based to 0-based keying*/
5109 key_index--;
5110 }
5111 if(!ext->key_len) {
5112
5113 /*Set the encrytion type to NONE*/
5114 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5115 return status;
5116 }
5117
5118 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5119 (IW_ENCODE_ALG_WEP == ext->alg))
5120 {
5121 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5122
Agarwal Ashish971c2882013-10-30 20:11:12 +05305123 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5124 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 return -EINVAL;
5126 }
5127 else {
5128 /*Static wep, update the roam profile with the keys */
5129 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5130 key_index < CSR_MAX_NUM_KEY) {
5131 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5132 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5133
5134 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5135 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5136
5137 }
5138 }
5139 return status;
5140 }
5141
5142 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5143
5144 setKey.keyId = key_index;
5145 setKey.keyLength = ext->key_len;
5146
5147 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5148 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5149 }
5150
5151 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5152 /*Key direction for group is RX only*/
5153 setKey.keyDirection = eSIR_RX_ONLY;
5154 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5155 }
5156 else {
5157
5158 setKey.keyDirection = eSIR_TX_RX;
5159 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5160 }
5161
5162 /*For supplicant pae role is zero*/
5163 setKey.paeRole = 0;
5164
5165 switch(ext->alg)
5166 {
5167 case IW_ENCODE_ALG_NONE:
5168 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5169 break;
5170
5171 case IW_ENCODE_ALG_WEP:
5172 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5173 break;
5174
5175 case IW_ENCODE_ALG_TKIP:
5176 {
5177 v_U8_t *pKey = &setKey.Key[0];
5178
5179 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5180
5181 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5182
5183 /*Supplicant sends the 32bytes key in this order
5184
5185 |--------------|----------|----------|
5186 | Tk1 |TX-MIC | RX Mic |
5187 |--------------|----------|----------|
5188 <---16bytes---><--8bytes--><--8bytes-->
5189
5190 */
5191 /*Sme expects the 32 bytes key to be in the below order
5192
5193 |--------------|----------|----------|
5194 | Tk1 |RX-MIC | TX Mic |
5195 |--------------|----------|----------|
5196 <---16bytes---><--8bytes--><--8bytes-->
5197 */
5198 /* Copy the Temporal Key 1 (TK1) */
5199 vos_mem_copy(pKey,ext->key,16);
5200
5201 /*Copy the rx mic first*/
5202 vos_mem_copy(&pKey[16],&ext->key[24],8);
5203
5204 /*Copy the tx mic */
5205 vos_mem_copy(&pKey[24],&ext->key[16],8);
5206
5207 }
5208 break;
5209
5210 case IW_ENCODE_ALG_CCMP:
5211 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5212 break;
5213
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005214#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005215#define IW_ENCODE_ALG_KRK 6
5216 case IW_ENCODE_ALG_KRK:
5217 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5218 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005219#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 default:
5222 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5223 break;
5224 }
5225
5226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005227 ("%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 -07005228
5229#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305230 /* The supplicant may attempt to set the PTK once pre-authentication
5231 is done. Save the key in the UMAC and include it in the ADD
5232 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305234 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305236 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5237 "%s: Update PreAuth Key success", __func__);
5238 return 0;
5239 }
5240 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5241 {
5242 hddLog(VOS_TRACE_LEVEL_ERROR,
5243 "%s: Update PreAuth Key failed", __func__);
5244 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 }
5246#endif /* WLAN_FEATURE_VOWIFI_11R */
5247
5248 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5249
5250 vos_status = wlan_hdd_check_ula_done(pAdapter);
5251 if ( vos_status != VOS_STATUS_SUCCESS )
5252 {
5253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5254 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5255 __LINE__, vos_status );
5256
5257 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5258 }
5259
5260 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5261
5262 if ( halStatus != eHAL_STATUS_SUCCESS )
5263 {
5264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5265 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5266 __LINE__, halStatus );
5267
5268 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5269 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305270 EXIT();
5271 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005272}
5273
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305274static int iw_set_encodeext(struct net_device *dev,
5275 struct iw_request_info *info,
5276 union iwreq_data *wrqu, char *extra)
5277{
5278 int ret;
5279
5280 vos_ssr_protect(__func__);
5281 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5282 vos_ssr_unprotect(__func__);
5283
5284 return ret;
5285}
5286
5287static int __iw_set_retry(struct net_device *dev,
5288 struct iw_request_info *info,
5289 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005290{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305291 hdd_adapter_t *pAdapter;
5292 tHalHandle hHal;
5293 hdd_context_t *pHddCtx;
5294 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005295
5296 ENTER();
5297
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305298 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5299 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005300 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5302 "%s: Adapter is NULL",__func__);
5303 return -EINVAL;
5304 }
5305
5306 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5307 ret = wlan_hdd_validate_context(pHddCtx);
5308 if (0 != ret)
5309 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305310 return ret;
5311 }
5312
5313 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5314 if (NULL == hHal)
5315 {
5316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5317 "%s: Hal Context is NULL",__func__);
5318 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005319 }
5320
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5322 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5323
Arif Hussain6d2a3322013-11-17 19:50:10 -08005324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005325
5326 return -EINVAL;
5327 }
5328
5329 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5330
5331 if((wrqu->retry.flags & IW_RETRY_LONG))
5332 {
5333 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5334 {
c_hpothub8245442013-11-20 23:41:09 +05305335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5336 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 return -EIO;
5338 }
5339 }
5340 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5341 {
5342 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5343 {
c_hpothub8245442013-11-20 23:41:09 +05305344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5345 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 return -EIO;
5347 }
5348 }
5349 }
5350 else
5351 {
5352 return -EOPNOTSUPP;
5353 }
5354
Arif Hussain6d2a3322013-11-17 19:50:10 -08005355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005356
5357 EXIT();
5358
5359 return 0;
5360
5361}
5362
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305363static int iw_set_retry(struct net_device *dev,
5364 struct iw_request_info *info,
5365 union iwreq_data *wrqu, char *extra)
5366{
5367 int ret;
5368
5369 vos_ssr_protect(__func__);
5370 ret = __iw_set_retry(dev, info, wrqu, extra);
5371 vos_ssr_unprotect(__func__);
5372
5373 return ret;
5374}
5375
5376static int __iw_get_retry(struct net_device *dev,
5377 struct iw_request_info *info,
5378 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005379{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305380 hdd_adapter_t *pAdapter;
5381 hdd_context_t *pHddCtx;
5382 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305384 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005385
5386 ENTER();
5387
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305388 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5389 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005390 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5392 "%s: Adapter is NULL",__func__);
5393 return -EINVAL;
5394 }
5395
5396 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5397 ret = wlan_hdd_validate_context(pHddCtx);
5398 if (0 != ret)
5399 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305400 return ret;
5401 }
5402
5403 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5404 if (NULL == hHal)
5405 {
5406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5407 "%s: Hal Context is NULL",__func__);
5408 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005409 }
5410
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 if((wrqu->retry.flags & IW_RETRY_LONG))
5412 {
5413 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5414
5415 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5416 {
c_hpothub8245442013-11-20 23:41:09 +05305417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5418 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 return -EIO;
5420 }
5421
5422 wrqu->retry.value = retry;
5423 }
5424 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5425 {
5426 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5427
5428 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5429 {
c_hpothub8245442013-11-20 23:41:09 +05305430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5431 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 return -EIO;
5433 }
5434
5435 wrqu->retry.value = retry;
5436 }
5437 else {
5438 return -EOPNOTSUPP;
5439 }
5440
Arif Hussain6d2a3322013-11-17 19:50:10 -08005441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005442
5443 EXIT();
5444
5445 return 0;
5446}
5447
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305448static int iw_get_retry(struct net_device *dev,
5449 struct iw_request_info *info,
5450 union iwreq_data *wrqu, char *extra)
5451{
5452 int ret;
5453
5454 vos_ssr_protect(__func__);
5455 ret = __iw_get_retry(dev, info, wrqu, extra);
5456 vos_ssr_unprotect(__func__);
5457
5458 return ret;
5459}
5460
5461static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 struct iw_request_info *info,
5463 union iwreq_data *wrqu,
5464 char *extra)
5465{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305466 hdd_adapter_t *pAdapter;
5467 hdd_context_t *pHddCtx;
5468 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5470 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305471 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005472
5473 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305474 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5475 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5478 "%s:Adapter is NULL",__func__);
5479 return -EINVAL;
5480 }
5481 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5482 ret = wlan_hdd_validate_context(pHddCtx);
5483 if (0 != ret)
5484 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305485 return ret;
5486 }
5487 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5488 if (NULL == pHddStaCtx)
5489 {
5490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5491 "%s:STA context is NULL",__func__);
5492 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 }
5494
5495 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5496 switch (mlme->cmd) {
5497 case IW_MLME_DISASSOC:
5498 case IW_MLME_DEAUTH:
5499
5500 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5501 {
5502 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5503
5504 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5505 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5506
5507 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5508 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5509
Jeff Johnson43971f52012-07-17 12:26:56 -07005510 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305511 {
5512 long ret;
5513 ret = wait_for_completion_interruptible_timeout(
5514 &pAdapter->disconnect_comp_var,
5515 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5516 if (ret <= 0)
5517 hddLog(VOS_TRACE_LEVEL_ERROR,
5518 FL("failed wait on disconnect_comp_var %ld"), ret);
5519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005521 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005522 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005523
5524 /* Resetting authKeyMgmt */
5525 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5526
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305527 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 netif_tx_disable(dev);
5529 netif_carrier_off(dev);
5530
5531 }
5532 else
5533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005534 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 -07005535 }
5536 break;
5537 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005538 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 return -EINVAL;
5540 }//end of switch
5541
5542 EXIT();
5543
5544 return status;
5545
5546}
5547
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305548static int iw_set_mlme(struct net_device *dev,
5549 struct iw_request_info *info,
5550 union iwreq_data *wrqu,
5551 char *extra)
5552{
5553 int ret;
5554
5555 vos_ssr_protect(__func__);
5556 ret = __iw_set_mlme(dev, info, wrqu, extra);
5557 vos_ssr_unprotect(__func__);
5558
5559 return ret;
5560}
5561
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305562int wlan_hdd_set_proximity(int set_value)
5563{
5564 sHwCalValues hwCalValues;
5565 uint16 hwCalTxPower;
5566 uint8 txPwr = TX_PWR_DEF;
5567
5568 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5569
5570 if (TRUE == set_value) {
5571 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5572 NULL, sizeof(sHwCalValues) )
5573 != VOS_STATUS_SUCCESS) {
5574 return -EINVAL;
5575 }
5576 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5577
5578 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5579 hwCalTxPower, hwCalValues.calData.hwParam7);
5580
5581 txPwr = (int8)(hwCalTxPower & 0x00FF);
5582 txPwr = txPwr/10;
5583 if (txPwr < TX_PWR_MIN)
5584 txPwr = TX_PWR_MIN;
5585 if (txPwr > TX_PWR_MAX)
5586 txPwr = TX_PWR_MAX;
5587
5588 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr) !=
5589 eHAL_STATUS_SUCCESS) {
5590 hddLog(VOS_TRACE_LEVEL_ERROR,
5591 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5592 return -EIO;
5593 }
5594
5595 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5596 txPwr /= 10;
5597 if (txPwr < TX_PWR_MIN)
5598 txPwr = TX_PWR_MIN;
5599 if (txPwr > TX_PWR_MAX)
5600 txPwr = TX_PWR_MAX;
5601
5602 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr) !=
5603 eHAL_STATUS_SUCCESS) {
5604 hddLog(VOS_TRACE_LEVEL_ERROR,
5605 FL("setting tx power failed for 5GHz band %d"), txPwr);
5606 return -EIO;
5607 }
5608 }
5609 else if(FALSE == set_value) {
5610 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr) !=
5611 eHAL_STATUS_SUCCESS) {
5612 hddLog(VOS_TRACE_LEVEL_ERROR,
5613 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5614 return -EIO;
5615 }
5616
5617 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr) !=
5618 eHAL_STATUS_SUCCESS) {
5619 hddLog(VOS_TRACE_LEVEL_ERROR,
5620 FL("setting tx power failed for 5GHz band %d"), txPwr);
5621 return -EIO;
5622 }
5623 }
5624 else {
5625 return -EINVAL;
5626 }
5627
5628 return eHAL_STATUS_SUCCESS;
5629}
Jeff Johnson295189b2012-06-20 16:38:30 -07005630/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305631static int __iw_setint_getnone(struct net_device *dev,
5632 struct iw_request_info *info,
5633 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005634{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305635 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305636 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305637 hdd_wext_state_t *pWextState;
5638 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305639 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 int *value = (int *)extra;
5641 int sub_cmd = value[0];
5642 int set_value = value[1];
5643 int ret = 0; /* success */
5644 int enable_pbm, enable_mp;
5645#ifdef CONFIG_HAS_EARLYSUSPEND
5646 v_U8_t nEnableSuspendOld;
5647#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005648
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305649 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305650 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5651 if (NULL == pAdapter)
5652 {
5653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5654 "%s: Adapter is NULL",__func__);
5655 return -EINVAL;
5656 }
5657 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5658 ret = wlan_hdd_validate_context(pHddCtx);
5659 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005660 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305661 return ret;
5662 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305663
Katya Nigameae74b62015-05-28 17:19:16 +05305664 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305665 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305666 /* In monitor mode hHal is NULL */
5667 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5668 if (NULL == hHal)
5669 {
5670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5671 "%s: Hal Context is NULL",__func__);
5672 return -EINVAL;
5673 }
Katya Nigameae74b62015-05-28 17:19:16 +05305674 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5675 if (NULL == pWextState)
5676 {
5677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5678 "%s: pWextState is NULL",__func__);
5679 return -EINVAL;
5680 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005681
Katya Nigameae74b62015-05-28 17:19:16 +05305682 INIT_COMPLETION(pWextState->completion_var);
5683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 switch(sub_cmd)
5685 {
5686 case WE_SET_11D_STATE:
5687 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005688 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005689 memset(&smeConfig, 0x00, sizeof(smeConfig));
5690
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305691 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5692 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 sme_GetConfigParam(hHal,&smeConfig);
5694 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5695
Arif Hussain6d2a3322013-11-17 19:50:10 -08005696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005697
5698 sme_UpdateConfig(hHal,&smeConfig);
5699 }
5700 else {
5701 return -EINVAL;
5702 }
5703 break;
5704 }
5705
5706 case WE_WOWL:
5707 {
5708 switch (set_value)
5709 {
5710 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305711 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 break;
5713 case 0x01:
5714 case 0x02:
5715 case 0x03:
5716 enable_mp = (set_value & 0x01) ? 1 : 0;
5717 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005718 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5720 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5721 break;
5722 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005723 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 ret = -EINVAL;
5725 break;
5726 }
5727
5728 break;
5729 }
5730 case WE_SET_POWER:
5731 {
5732 switch (set_value)
5733 {
5734 case 0: //Full Power
5735 {
5736 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305737 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005738
5739 init_completion(&context.completion);
5740
5741 context.pAdapter = pAdapter;
5742 context.magic = POWER_CONTEXT_MAGIC;
5743
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305744 if (NULL == hHal)
5745 return -EINVAL;
5746
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5748 iw_power_callback_fn, &context,
5749 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305750
Jeff Johnson72a40512013-12-19 10:14:15 -08005751 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 {
5753 int lrc = wait_for_completion_interruptible_timeout(
5754 &context.completion,
5755 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005756
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 if (lrc <= 0)
5758 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005759 hddLog(VOS_TRACE_LEVEL_ERROR,
5760 "%s: SME %s while requesting fullpower",
5761 __func__, (0 == lrc) ?
5762 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 }
5764 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005765 /* either we have a response or we timed out. if we timed
5766 out there is a race condition such that the callback
5767 function could be executing at the same time we are. of
5768 primary concern is if the callback function had already
5769 verified the "magic" but had not yet set the completion
5770 variable when a timeout occurred. we serialize these
5771 activities by invalidating the magic while holding a
5772 shared spinlock which will cause us to block if the
5773 callback is currently executing */
5774 spin_lock(&hdd_context_lock);
5775 context.magic = 0;
5776 spin_unlock(&hdd_context_lock);
5777
Arif Hussain6d2a3322013-11-17 19:50:10 -08005778 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 break;
5780 }
5781 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305782 if (hHal)
5783 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5784 else
5785 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 break;
5787 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305788 if (hHal)
5789 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5790 else
5791 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 break;
5793 case 3: //Request Bmps
5794 {
5795 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305796 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
5798 init_completion(&context.completion);
5799
5800 context.pAdapter = pAdapter;
5801 context.magic = POWER_CONTEXT_MAGIC;
5802
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305803 if (NULL == hHal)
5804 return -EINVAL;
5805
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305807 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005808 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 {
5810 int lrc = wait_for_completion_interruptible_timeout(
5811 &context.completion,
5812 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 if (lrc <= 0)
5814 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005815 hddLog(VOS_TRACE_LEVEL_ERROR,
5816 "%s: SME %s while requesting BMPS",
5817 __func__, (0 == lrc) ? "timeout" :
5818 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 }
5820 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005821 /* either we have a response or we timed out. if we
5822 timed out there is a race condition such that the
5823 callback function could be executing at the same
5824 time we are. of primary concern is if the callback
5825 function had already verified the "magic" but had
5826 not yet set the completion variable when a timeout
5827 occurred. we serialize these activities by
5828 invalidating the magic while holding a shared
5829 spinlock which will cause us to block if the
5830 callback is currently executing */
5831 spin_lock(&hdd_context_lock);
5832 context.magic = 0;
5833 spin_unlock(&hdd_context_lock);
5834
Arif Hussain6d2a3322013-11-17 19:50:10 -08005835 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 break;
5837 }
5838 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305839 if (hHal)
5840 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5841 else
5842 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 break;
5844 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305845 if (hHal)
5846 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5847 else
5848 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 break;
5850 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305851 if (hHal)
5852 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5853 else
5854 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 break;
5856 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305857 if (hHal)
5858 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5859 else
5860 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 break;
5862 case 8: //Request Standby
5863#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005864#endif
5865 break;
5866 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305867 if (hHal)
5868 sme_StartAutoBmpsTimer(hHal);
5869 else
5870 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 break;
5872 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305873 if (hHal)
5874 sme_StopAutoBmpsTimer(hHal);
5875 else
5876 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 break;
5878#ifdef CONFIG_HAS_EARLYSUSPEND
5879 case 11://suspend to standby
5880#ifdef CONFIG_HAS_EARLYSUSPEND
5881 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5882 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5884#endif
5885 break;
5886 case 12://suspend to deep sleep
5887#ifdef CONFIG_HAS_EARLYSUSPEND
5888 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5889 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5891#endif
5892 break;
5893 case 13://resume from suspend
5894#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005895#endif
5896 break;
5897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005899 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 ret = -EINVAL;
5901 break;
5902 }
5903 break;
5904 }
5905
5906 case WE_SET_MAX_ASSOC:
5907 {
5908 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305909 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5910 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 {
5912 ret = -EINVAL;
5913 }
5914 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5915 set_value, NULL, eANI_BOOLEAN_FALSE)
5916 != eHAL_STATUS_SUCCESS )
5917 {
c_hpothub8245442013-11-20 23:41:09 +05305918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5919 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 ret = -EIO;
5921 }
5922 break;
5923 }
5924
5925 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5926 {
5927 if( 0 == set_value )
5928 {
5929 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5930 }
5931 else if ( 1 == set_value )
5932 {
5933 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5934 }
5935 else
5936 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005937 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 ret = -EINVAL;
5939 }
5940 break;
5941 }
5942
5943 case WE_SET_DATA_INACTIVITY_TO:
5944 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305945 if (NULL == hHal)
5946 return -EINVAL;
5947
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5949 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5950 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5951 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5952 set_value,
5953 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5954 {
5955 hddLog(LOGE,"Failure: Could not pass on "
5956 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005957 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 ret = -EINVAL;
5959 }
5960 break;
5961 }
5962 case WE_SET_MAX_TX_POWER:
5963 {
5964 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5965 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5966
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305967 if (NULL == hHal)
5968 return -EINVAL;
5969
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5971 __func__, set_value);
5972 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5973 eHAL_STATUS_SUCCESS )
5974 {
5975 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5976 __func__);
5977 return -EIO;
5978 }
5979
5980 break;
5981 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005982 case WE_SET_MAX_TX_POWER_2_4:
5983 {
5984 hddLog(VOS_TRACE_LEVEL_INFO,
5985 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5986 __func__, set_value);
5987 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5988 eHAL_STATUS_SUCCESS)
5989 {
5990 hddLog(VOS_TRACE_LEVEL_ERROR,
5991 "%s: Setting maximum tx power failed for 2.4 GHz band",
5992 __func__);
5993 return -EIO;
5994 }
5995
5996 break;
5997 }
5998 case WE_SET_MAX_TX_POWER_5_0:
5999 {
6000 hddLog(VOS_TRACE_LEVEL_INFO,
6001 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6002 __func__, set_value);
6003 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
6004 eHAL_STATUS_SUCCESS)
6005 {
6006 hddLog(VOS_TRACE_LEVEL_ERROR,
6007 "%s: Setting maximum tx power failed for 5.0 GHz band",
6008 __func__);
6009 return -EIO;
6010 }
6011
6012 break;
6013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 case WE_SET_HIGHER_DTIM_TRANSITION:
6015 {
6016 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6017 (set_value == eANI_BOOLEAN_TRUE)))
6018 {
6019 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6020 ret = -EINVAL;
6021 }
6022 else
6023 {
6024 if(pAdapter->higherDtimTransition != set_value)
6025 {
6026 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006027 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 }
6029 }
6030
6031 break;
6032 }
6033
6034 case WE_SET_TM_LEVEL:
6035 {
6036 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006037 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6039
6040 break;
6041 }
6042
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306043 case WE_ENABLE_STRICT_FCC_REG:
6044 {
6045 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6046 struct wiphy *wiphy = NULL;
6047 long lrc;
6048 int status;
6049
6050 wiphy = hddCtxt->wiphy;
6051 if(wiphy == NULL)
6052 {
6053 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6054 break;
6055 }
6056 init_completion(&hddCtxt->wiphy_channel_update_event);
6057
6058 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6059
6060 status = regulatory_hint(wiphy, "00");
6061 if(status < 0)
6062 {
6063 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6064 break;
6065 }
6066
6067 /* Wait for completion */
6068 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6069 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6070 if (lrc <= 0)
6071 {
6072 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6073 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6074 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6075 }
6076 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6077
6078 break;
6079 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006080 case WE_SET_DEBUG_LOG:
6081 {
6082 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6083 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306084 if (hHal)
6085 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6086 else
6087 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006088 break;
6089 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306090#ifdef FEATURE_WLAN_TDLS
6091 case WE_SET_TDLS_OFF_CHAN:
6092 {
6093 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6095 __func__, set_value);
6096 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6097 break;
6098 }
6099 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6100 {
6101 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6103 __func__, set_value);
6104 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6105 break;
6106 }
6107 case WE_SET_TDLS_OFF_CHAN_MODE:
6108 {
6109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6110 __func__, set_value);
6111 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6112 break;
6113 }
6114#endif
Peng Xu2446a892014-09-05 17:21:18 +05306115 case WE_SET_SCAN_BAND_PREFERENCE:
6116 {
6117 tSmeConfigParams smeConfig;
6118 memset(&smeConfig, 0x00, sizeof(smeConfig));
6119 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6120 ret = -EINVAL;
6121 break;
6122 }
6123 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6124
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306125 if ((eCSR_BAND_ALL == set_value ||
6126 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6127 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306128 sme_GetConfigParam(hHal, &smeConfig);
6129 smeConfig.csrConfig.scanBandPreference = set_value;
6130
6131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6132 "set band scan preference = %d\n",
6133 smeConfig.csrConfig.scanBandPreference);
6134
6135 sme_UpdateConfig(hHal, &smeConfig);
6136 }
6137 else {
6138 ret = -EINVAL;
6139 }
6140 break;
6141 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306142 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6143 * connection happens so that the params can take effect during
6144 * association. Also this should not be used in STA+p2p concurrency
6145 * as the param will also effect the STA mode.
6146 */
6147 case WE_SET_MIRACAST_VENDOR_CONFIG:
6148 {
6149 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306150
Abhishek Singh01c73d12015-03-12 15:13:44 +05306151 hddLog(LOG1, FL(
6152 "Set Miracast vendor tuning %d"), set_value);
6153
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306154 if (NULL == hHal)
6155 return -EINVAL;
6156
Abhishek Singh01c73d12015-03-12 15:13:44 +05306157 if (1 == set_value || 0 == set_value)
6158 {
6159 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6160 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6161 {
6162 hddLog( LOGE, FL("set vendor miracast config failed"));
6163 ret = -EIO;
6164 }
6165 }
6166 else
6167 {
6168 hddLog(LOGE,
6169 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6170 ret = -EINVAL;
6171 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306172 break;
6173 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306174
6175 case WE_GET_FRAME_LOG:
6176 {
6177 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6178 != VOS_STATUS_SUCCESS)
6179 {
6180 ret = -EINVAL;
6181 }
6182 break;
6183 }
6184
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306185 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6186 {
6187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6188 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306189 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306190 {
6191 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6192 set_value);
6193 }
6194 else
6195 ret = -EINVAL;
6196
6197 break;
6198 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306199 /* Bit mask value to enable RTS/CTS for different modes
6200 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6201 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6202 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6203 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6204 * for 5 GHz, VHT80 - 0x1000
6205 */
6206 case WE_SET_RTS_CTS_HTVHT:
6207 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306208
Abhishek Singh41988ba2015-05-25 19:42:29 +05306209 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6210
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306211 if (NULL == hHal)
6212 return -EINVAL;
6213
Abhishek Singh41988ba2015-05-25 19:42:29 +05306214 if (eHAL_STATUS_SUCCESS !=
6215 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6216 {
6217 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6218 ret = -EINVAL;
6219 }
6220 break;
6221 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306222 case WE_SET_MONITOR_STATE:
6223 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306224 v_U32_t magic = 0;
6225 struct completion cmpVar;
6226 long waitRet = 0;
6227 tVOS_CON_MODE mode = hdd_get_conparam();
6228
6229 if( VOS_MONITOR_MODE != mode)
6230 {
6231 hddLog(LOGE, "invalid mode %d", mode);
6232 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306233 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306234 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306235
6236 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6237 if( pMonCtx == NULL )
6238 {
6239 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306240 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306241 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306242 }
6243 if (pMonCtx->state == set_value)
6244 {
6245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6246 FL("already in same mode curr_mode:%d req_mode: %d"),
6247 pMonCtx->state, set_value);
6248 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306249 }
6250 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306251 magic = MON_MODE_MSG_MAGIC;
6252 init_completion(&cmpVar);
6253 if (VOS_STATUS_SUCCESS !=
6254 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6255 pMonCtx, hdd_monPostMsgCb)) {
6256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6257 FL("failed to post MON MODE REQ"));
6258 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6259 MON_MODE_STOP : MON_MODE_START;
6260 magic = 0;
6261 ret = -EIO;
6262 break;
6263 }
6264 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6265 magic = 0;
6266 if (waitRet <= 0 ){
6267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6268 FL("failed to wait on monitor mode completion %ld"),
6269 waitRet);
6270 }
6271 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306272 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306273 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6274 {
6275 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6276 tAniWifiStartLog start_log;
6277 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6278 !vos_isPktStatsEnabled())
6279 {
6280 hddLog(LOGE, FL("per pkt stats not enabled"));
6281 return -EINVAL;
6282 }
6283 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6284
6285 if (1 == set_value || 0 == set_value)
6286 {
6287 start_log.ringId = RING_ID_PER_PACKET_STATS;
6288 start_log.flag = 0;
6289 if (set_value)
6290 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6291 else
6292 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6293
6294 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6295 }
6296 else
6297 {
6298 hddLog(LOGE,
6299 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6300 set_value);
6301 ret = -EINVAL;
6302 }
6303 break;
6304 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306305 case WE_SET_PROXIMITY_ENABLE:
6306 {
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05306307 ret = wlan_hdd_set_proximity(set_value);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306308 break;
6309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 default:
6311 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006312 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 sub_cmd, set_value);
6314 break;
6315 }
6316 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306317 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 return ret;
6319}
6320
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306321static int iw_setint_getnone(struct net_device *dev,
6322 struct iw_request_info *info,
6323 union iwreq_data *wrqu, char *extra)
6324{
6325 int ret;
6326
6327 vos_ssr_protect(__func__);
6328 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6329 vos_ssr_unprotect(__func__);
6330
6331 return 0;
6332}
Jeff Johnson295189b2012-06-20 16:38:30 -07006333/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306334static int __iw_setchar_getnone(struct net_device *dev,
6335 struct iw_request_info *info,
6336 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006337{
6338 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306339 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006341 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306342 hdd_adapter_t *pAdapter;
6343 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006344#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306345 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006346#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306347 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306348 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006349
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306350 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306351
6352 if (!capable(CAP_NET_ADMIN))
6353 {
6354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6355 FL("permission check failed"));
6356 return -EPERM;
6357 }
6358
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306359 pAdapter = (netdev_priv(dev));
6360 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006361 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6363 "%s: Adapter is NULL",__func__);
6364 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006365 }
6366
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306367 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6368 ret = wlan_hdd_validate_context(pHddCtx);
6369 if (0 != ret)
6370 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306371 return ret;
6372 }
6373#ifdef WLAN_FEATURE_VOWIFI
6374 pConfig = pHddCtx->cfg_ini;
6375#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306376 /* helper function to get iwreq_data with compat handling. */
6377 if (hdd_priv_get_data(&s_priv_data, wrqu))
6378 {
6379 return -EINVAL;
6380 }
6381
6382 /* make sure all params are correctly passed to function */
6383 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6384 {
6385 return -EINVAL;
6386 }
6387
6388 sub_cmd = s_priv_data.flags;
6389
Arif Hussain0273cba2014-01-07 20:58:29 -08006390 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306391 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6392 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006393 if (NULL == pBuffer)
6394 {
6395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6396 "mem_alloc_copy_from_user_helper fail");
6397 return -ENOMEM;
6398 }
6399
6400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306401 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6403 "%s: Received data %s", __func__, pBuffer);
6404
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 switch(sub_cmd)
6406 {
6407 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006409 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 break;
6411 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006413 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 break;
6415#if defined WLAN_FEATURE_VOWIFI
6416 case WE_NEIGHBOR_REPORT_REQUEST:
6417 {
6418 tRrmNeighborReq neighborReq;
6419 tRrmNeighborRspCallbackInfo callbackInfo;
6420
6421 if (pConfig->fRrmEnable)
6422 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306424 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 if( !neighborReq.no_ssid )
6426 {
Girish Gowli552fc072014-06-14 18:26:16 +05306427 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006428 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 }
6430
6431 callbackInfo.neighborRspCallback = NULL;
6432 callbackInfo.neighborRspCallbackContext = NULL;
6433 callbackInfo.timeout = 5000; //5 seconds
6434 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6435 }
6436 else
6437 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006438 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 ret = -EINVAL;
6440 }
6441 }
6442 break;
6443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 case WE_SET_AP_WPS_IE:
6445 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306446 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006449 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 if (VOS_STATUS_SUCCESS != vstatus)
6451 {
6452 ret = -EINVAL;
6453 }
6454 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306455 case WE_SET_ENCRYPT_MSG:
6456 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6457 if (NULL == pkt)
6458 {
6459 hddLog(VOS_TRACE_LEVEL_ERROR,
6460 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306461 ret = -ENOMEM;
6462 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306463 }
6464
6465 memset(pkt, 0, sizeof(tSirpkt80211));
6466
6467 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6468 hddLog(VOS_TRACE_LEVEL_ERROR,
6469 FL("Firmware is not DISA capable"));
6470 ret = -EINVAL;
6471 vos_mem_free(pkt);
6472 break;
6473 }
6474
6475 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6476
6477 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6478 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6479 if (eHAL_STATUS_SUCCESS != ret) {
6480 hddLog(VOS_TRACE_LEVEL_ERROR,
6481 FL("SENDEncryptMSG: fail to post WDA cmd"));
6482 ret = -EINVAL;
6483 }
6484 vos_mem_free(pkt);
6485
6486 break;
6487
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 default:
6489 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006490 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 ret = -EINVAL;
6492 break;
6493 }
6494 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006495 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306496
6497 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 return ret;
6499}
6500
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306501static int iw_setchar_getnone(struct net_device *dev,
6502 struct iw_request_info *info,
6503 union iwreq_data *wrqu, char *extra)
6504{
6505 int ret;
6506
6507 vos_ssr_protect(__func__);
6508 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6509 vos_ssr_unprotect(__func__);
6510
6511 return ret;
6512}
6513
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306514static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6515{
6516 struct statsContext *context;
6517 hdd_adapter_t *pAdapter;
6518
6519 if (NULL == pContext)
6520 {
6521 hddLog(VOS_TRACE_LEVEL_ERROR,
6522 "%s: Bad param, pContext [%p]",
6523 __func__, pContext);
6524 return;
6525 }
6526
6527 context = pContext;
6528 pAdapter = context->pAdapter;
6529
6530 spin_lock(&hdd_context_lock);
6531
6532 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6533 {
6534 /* the caller presumably timed out so there is nothing we can do */
6535 spin_unlock(&hdd_context_lock);
6536 hddLog(VOS_TRACE_LEVEL_WARN,
6537 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6538 __func__, pAdapter, context->magic);
6539 return;
6540 }
6541
6542 context->magic = 0;
6543 pAdapter->antennaIndex = antennaId;
6544
6545 complete(&context->completion);
6546 spin_unlock(&hdd_context_lock);
6547}
6548
6549static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6550 int *antennaIndex)
6551{
6552 hdd_context_t *pHddCtx;
6553 eHalStatus halStatus;
6554 struct statsContext context;
6555 long lrc;
6556
6557 ENTER();
6558 if (NULL == pAdapter)
6559 {
6560 hddLog(VOS_TRACE_LEVEL_WARN,
6561 "%s: Invalid context, pAdapter", __func__);
6562 return VOS_STATUS_E_FAULT;
6563 }
6564 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6565 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6566 {
6567 return VOS_STATUS_E_FAULT;
6568 }
6569 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6570 {
6571 hddLog(VOS_TRACE_LEVEL_ERROR,
6572 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6573 __func__);
6574 return VOS_STATUS_E_NOSUPPORT;
6575 }
6576 init_completion(&context.completion);
6577 context.pAdapter = pAdapter;
6578 context.magic = ANTENNA_CONTEXT_MAGIC;
6579
6580 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6581 hdd_GetCurrentAntennaIndex,
6582 &context, pAdapter->sessionId);
6583 if (eHAL_STATUS_SUCCESS != halStatus)
6584 {
6585 spin_lock(&hdd_context_lock);
6586 context.magic = 0;
6587 spin_unlock(&hdd_context_lock);
6588 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6589 __func__);
6590 /* we'll returned a cached value below */
6591 *antennaIndex = -1;
6592 return VOS_STATUS_E_FAILURE;
6593 }
6594 else
6595 {
6596 /* request was sent -- wait for the response */
6597 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6598 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6599 if (lrc <= 0)
6600 {
6601 spin_lock(&hdd_context_lock);
6602 context.magic = 0;
6603 spin_unlock(&hdd_context_lock);
6604 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6605 " Index",
6606 __func__, (0 == lrc) ? "timeout" : "interrupt");
6607 *antennaIndex = -1;
6608 return VOS_STATUS_E_FAILURE;
6609 }
6610 }
6611 spin_lock(&hdd_context_lock);
6612 context.magic = 0;
6613 spin_unlock(&hdd_context_lock);
6614
6615 *antennaIndex = pAdapter->antennaIndex;
6616
6617 EXIT();
6618 return VOS_STATUS_SUCCESS;
6619}
6620
Jeff Johnson295189b2012-06-20 16:38:30 -07006621/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306622static int __iw_setnone_getint(struct net_device *dev,
6623 struct iw_request_info *info,
6624 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006625{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306626 hdd_adapter_t *pAdapter;
6627 tHalHandle hHal;
6628 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 int *value = (int *)extra;
6630 int ret = 0; /* success */
6631
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306632 ENTER();
6633
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306634 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6635 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006636 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6638 "%s: Adapter is NULL",__func__);
6639 return -EINVAL;
6640 }
6641 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6642 ret = wlan_hdd_validate_context(pHddCtx);
6643 if (0 != ret)
6644 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306645 return ret;
6646 }
6647 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6648 if (NULL == hHal)
6649 {
6650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6651 "%s: Hal Context is NULL",__func__);
6652 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006654
6655 switch (value[0])
6656 {
6657 case WE_GET_11D_STATE:
6658 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006659 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306661
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6663
Arif Hussain6d2a3322013-11-17 19:50:10 -08006664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006665
6666 break;
6667 }
6668
6669 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 break;
6672
6673 case WE_PMC_STATE:
6674 {
6675 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 break;
6678 }
6679 case WE_GET_WLAN_DBG:
6680 {
6681 vos_trace_display();
6682 *value = 0;
6683 break;
6684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 case WE_GET_MAX_ASSOC:
6686 {
6687 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6688 {
c_hpothub8245442013-11-20 23:41:09 +05306689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6690 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 ret = -EIO;
6692 }
Girish Gowli385be612014-09-18 11:17:20 +05306693#ifdef WLAN_SOFTAP_VSTA_FEATURE
6694 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6695 {
6696 if (*value > VSTA_NUM_ASSOC_STA)
6697 {
6698 *value = VSTA_NUM_ASSOC_STA;
6699 }
6700 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6701 (*value > (VSTA_NUM_ASSOC_STA -
6702 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6703 {
6704 *value = (VSTA_NUM_ASSOC_STA -
6705 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6706 }
6707 }
6708 else
6709#endif
6710 {
6711 if (*value > NUM_ASSOC_STA)
6712 {
6713 *value = NUM_ASSOC_STA;
6714 }
6715 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6716 (*value > (NUM_ASSOC_STA -
6717 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6718 {
6719 *value = (NUM_ASSOC_STA -
6720 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6721 }
6722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 break;
6724 }
6725
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 case WE_GET_WDI_DBG:
6727 {
6728 wpalTraceDisplay();
6729 *value = 0;
6730 break;
6731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006732
6733 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6734 {
6735 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6736 break;
6737 }
6738 case WE_GET_CONCURRENCY_MODE:
6739 {
6740 *value = hdd_get_concurrency_mode ( );
6741
Arif Hussain6d2a3322013-11-17 19:50:10 -08006742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 break;
6744 }
6745
Peng Xu2446a892014-09-05 17:21:18 +05306746 case WE_GET_SCAN_BAND_PREFERENCE:
6747 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306748 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306749 sme_GetConfigParam(hHal, &smeConfig);
6750 *value = smeConfig.csrConfig.scanBandPreference;
6751
6752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6753 "scanBandPreference = %d\n", *value);
6754 break;
6755 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306756 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6757 {
6758 wlan_hdd_get_current_antenna_index(pAdapter, value);
6759 break;
6760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 default:
6762 {
6763 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6764 break;
6765 }
6766 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306767 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 return ret;
6769}
6770
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306771static int iw_setnone_getint(struct net_device *dev,
6772 struct iw_request_info *info,
6773 union iwreq_data *wrqu, char *extra)
6774{
6775 int ret;
6776
6777 vos_ssr_protect(__func__);
6778 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6779 vos_ssr_unprotect(__func__);
6780
6781 return ret;
6782
6783}
Jeff Johnson295189b2012-06-20 16:38:30 -07006784/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306785int __iw_set_three_ints_getnone(struct net_device *dev,
6786 struct iw_request_info *info,
6787 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006788{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306789 hdd_adapter_t *pAdapter;
6790 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 int *value = (int *)extra;
6792 int sub_cmd = value[0];
6793 int ret = 0;
6794
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306795 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306796
6797 if (!capable(CAP_NET_ADMIN))
6798 {
6799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6800 FL("permission check failed"));
6801 return -EPERM;
6802 }
6803
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306804 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6805 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006806 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6808 "%s: Adapter is NULL",__func__);
6809 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006810 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306811 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6812 ret = wlan_hdd_validate_context(pHddCtx);
6813 if (0 != ret)
6814 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306815 return ret;
6816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 switch(sub_cmd)
6818 {
6819 case WE_SET_WLAN_DBG:
6820 {
6821 vos_trace_setValue( value[1], value[2], value[3]);
6822 break;
6823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 case WE_SET_WDI_DBG:
6825 {
6826 wpalTraceSetLevel( value[1], value[2], value[3]);
6827 break;
6828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 case WE_SET_SAP_CHANNELS:
6830 {
6831 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6832 break;
6833 }
6834
6835 default:
6836 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006837 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 break;
6839 }
6840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306841 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 return ret;
6843}
6844
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306845int iw_set_three_ints_getnone(struct net_device *dev,
6846 struct iw_request_info *info,
6847 union iwreq_data *wrqu, char *extra)
6848{
6849 int ret;
6850
6851 vos_ssr_protect(__func__);
6852 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6853 vos_ssr_unprotect(__func__);
6854
6855 return ret;
6856}
6857
6858static int __iw_get_char_setnone(struct net_device *dev,
6859 struct iw_request_info *info,
6860 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006861{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306862 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306864 hdd_context_t *pHddCtx;
6865 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006866#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006867 hdd_wext_state_t *pWextState;
6868#endif
6869
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306870 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306871 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006872 if (pAdapter == NULL)
6873 {
6874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6875 "%s: pAdapter is NULL!", __func__);
6876 return -EINVAL;
6877 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306878 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6879 ret = wlan_hdd_validate_context(pHddCtx);
6880 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006881 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306882 return ret;
6883 }
6884#ifdef WLAN_FEATURE_11W
6885 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6886 if (NULL == pWextState)
6887 {
6888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6889 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006890 return -EINVAL;
6891 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306892#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006893
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 switch(sub_cmd)
6895 {
6896 case WE_WLAN_VERSION:
6897 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006898 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 break;
6900 }
6901
6902 case WE_GET_STATS:
6903 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306904 tHalHandle hHal = NULL;
6905 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6907 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6908 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6909
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306910
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 snprintf(extra, WE_MAX_STR_LEN,
6912 "\nTransmit"
6913 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6914 "\n dropped BK %u, BE %u, VI %u, VO %u"
6915 "\n classified BK %u, BE %u, VI %u, VO %u"
6916 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6917 "\n queued BK %u, BE %u, VI %u, VO %u"
6918 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006919 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 "\n fetched BK %u, BE %u, VI %u, VO %u"
6921 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6922 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006923 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 "\n flushed BK %u, BE %u, VI %u, VO %u"
6925 "\n\nReceive"
6926 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6927 "\n\nResetsStats"
6928 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6929 "\n",
6930 pStats->txXmitCalled,
6931 pStats->txXmitDropped,
6932 pStats->txXmitBackPressured,
6933 pStats->txXmitQueued,
6934
6935 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6936 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6937 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6938 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6939
6940 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6941 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6942 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6943 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6944
6945 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6946 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6947 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6948 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6949
6950 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6951 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6952 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6953 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6954
6955 pStats->txFetched,
6956 pStats->txFetchEmpty,
6957 pStats->txFetchLowResources,
6958 pStats->txFetchDequeueError,
6959
6960 pStats->txFetchDequeued,
6961 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006962 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 pStats->txCompleted,
6964 pStats->txFlushed,
6965
6966 pStats->txFetchedAC[WLANTL_AC_BK],
6967 pStats->txFetchedAC[WLANTL_AC_BE],
6968 pStats->txFetchedAC[WLANTL_AC_VI],
6969 pStats->txFetchedAC[WLANTL_AC_VO],
6970
6971 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6972 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6973 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6974 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6975
6976 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6977 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6978 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6979 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6980
Ravi Joshi41914632013-10-21 23:02:21 -07006981 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6982 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6983 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6984 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6985
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 pStats->txFlushedAC[WLANTL_AC_BK],
6987 pStats->txFlushedAC[WLANTL_AC_BE],
6988 pStats->txFlushedAC[WLANTL_AC_VI],
6989 pStats->txFlushedAC[WLANTL_AC_VO],
6990
6991 pStats->rxChains,
6992 pStats->rxPackets,
6993 pStats->rxDropped,
6994 pStats->rxDelivered,
6995 pStats->rxRefused,
6996
6997 pResetStats->totalLogpResets,
6998 pResetStats->totalCMD53Failures,
6999 pResetStats->totalMutexReadFailures,
7000 pResetStats->totalMIFErrorFailures,
7001 pResetStats->totalFWHearbeatFailures,
7002 pResetStats->totalUnknownExceptions
7003 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307004 wrqu->data.length = strlen(extra);
7005
7006 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7007
7008 if (hHal)
7009 pMac = PMAC_STRUCT( hHal );
7010
7011 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7012 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7013 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307014 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7015 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7016 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7017 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307018 "\n",
7019 pMac->pmm.BmpscntSleep,
7020 pMac->pmm.BmpscntAwake,
7021 pMac->pmm.BmpsSleeReqFailCnt,
7022 pMac->pmm.BmpsWakeupReqFailCnt,
7023 pMac->pmm.ImpsCntSleep,
7024 pMac->pmm.ImpsCntAwake,
7025 pMac->pmm.ImpsSleepErrCnt,
7026 pMac->pmm.ImpsWakeupErrCnt,
7027 pMac->pmm.ImpsLastErr
7028 );
7029 }
7030
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 wrqu->data.length = strlen(extra)+1;
7032 break;
7033 }
7034
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307035/* The case prints the current state of the HDD, SME, CSR, PE, TL
7036 *it can be extended for WDI Global State as well.
7037 *And currently it only checks P2P_CLIENT adapter.
7038 *P2P_DEVICE and P2P_GO have not been added as of now.
7039*/
7040 case WE_GET_STATES:
7041 {
7042 int buf = 0, len = 0;
7043 int adapter_num = 0;
7044 int count = 0, check = 1;
7045
7046 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007047 tHalHandle hHal = NULL;
7048 tpAniSirGlobal pMac = NULL;
7049 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307050
7051 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7052 hdd_adapter_t *useAdapter = NULL;
7053
7054 /* Print wlan0 or p2p0 states based on the adapter_num
7055 *by using the correct adapter
7056 */
7057 while ( adapter_num < 2 )
7058 {
7059 if ( WLAN_ADAPTER == adapter_num )
7060 {
7061 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007062 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307063 "\n\n wlan0 States:-");
7064 len += buf;
7065 }
7066 else if ( P2P_ADAPTER == adapter_num )
7067 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007068 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307069 "\n\n p2p0 States:-");
7070 len += buf;
7071
7072 if( !pHddCtx )
7073 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007074 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307075 "\n pHddCtx is NULL");
7076 len += buf;
7077 break;
7078 }
7079
7080 /*Printing p2p0 states only in the case when the device is
7081 configured as a p2p_client*/
7082 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7083 if ( !useAdapter )
7084 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007085 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307086 "\n Device not configured as P2P_CLIENT.");
7087 len += buf;
7088 break;
7089 }
7090 }
7091
7092 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007093 if (!hHal) {
7094 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7095 "\n pMac is NULL");
7096 len += buf;
7097 break;
7098 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307099 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007100 if (!pMac) {
7101 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7102 "\n pMac is NULL");
7103 len += buf;
7104 break;
7105 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307106 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7107 if( !pHddStaCtx )
7108 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007109 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307110 "\n pHddStaCtx is NULL");
7111 len += buf;
7112 break;
7113 }
7114
7115 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7116
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007117 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307118 "\n HDD Conn State - %s "
7119 "\n \n SME State:"
7120 "\n Neighbour Roam State - %s"
7121 "\n CSR State - %s"
7122 "\n CSR Substate - %s"
7123 "\n \n TL STA %d State: %s",
7124 macTraceGetHDDWlanConnState(
7125 pHddStaCtx->conn_info.connState),
7126 macTraceGetNeighbourRoamState(
7127 pMac->roam.neighborRoamInfo.neighborRoamState),
7128 macTraceGetcsrRoamState(
7129 pMac->roam.curState[useAdapter->sessionId]),
7130 macTraceGetcsrRoamSubState(
7131 pMac->roam.curSubState[useAdapter->sessionId]),
7132 pHddStaCtx->conn_info.staId[0],
7133 macTraceGetTLState(tlState)
7134 );
7135 len += buf;
7136 adapter_num++;
7137 }
7138
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007139 if (pMac) {
7140 /* Printing Lim State starting with global lim states */
7141 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7142 "\n \n LIM STATES:-"
7143 "\n Global Sme State - %s "\
7144 "\n Global mlm State - %s "\
7145 "\n",
7146 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7147 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7148 );
7149 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307150
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007151 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307152 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307153 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007154 if ( pMac->lim.gpSession[count].valid )
7155 {
7156 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7157 "\n Lim Valid Session %d:-"
7158 "\n PE Sme State - %s "
7159 "\n PE Mlm State - %s "
7160 "\n",
7161 check,
7162 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7163 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7164 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307165
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007166 len += buf;
7167 check++;
7168 }
7169 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307170 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307171 }
7172
7173 wrqu->data.length = strlen(extra)+1;
7174 break;
7175 }
7176
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 case WE_GET_CFG:
7178 {
7179 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7180 wrqu->data.length = strlen(extra)+1;
7181 break;
7182 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007183#ifdef WLAN_FEATURE_11AC
7184 case WE_GET_RSSI:
7185 {
7186 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307187 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007188 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7189 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7190 wrqu->data.length = strlen(extra)+1;
7191 break;
7192 }
7193#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307194
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007195#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007196 case WE_GET_ROAM_RSSI:
7197 {
7198 v_S7_t s7Rssi = 0;
7199 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7200 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7201 wrqu->data.length = strlen(extra)+1;
7202 break;
7203 }
7204#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 case WE_GET_WMM_STATUS:
7206 {
7207 snprintf(extra, WE_MAX_STR_LEN,
7208 "\nDir: 0=up, 1=down, 3=both\n"
7209 "|------------------------|\n"
7210 "|AC | ACM |Admitted| Dir |\n"
7211 "|------------------------|\n"
7212 "|VO | %d | %3s | %d |\n"
7213 "|VI | %d | %3s | %d |\n"
7214 "|BE | %d | %3s | %d |\n"
7215 "|BK | %d | %3s | %d |\n"
7216 "|------------------------|\n",
7217 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7218 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7219 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7220 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7221 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7222 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7223 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7224 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7225 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7226 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7227 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7228 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7229
Jeff Johnsone7245742012-09-05 17:12:55 -07007230
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 wrqu->data.length = strlen(extra)+1;
7232 break;
7233 }
7234 case WE_GET_CHANNEL_LIST:
7235 {
7236 VOS_STATUS status;
7237 v_U8_t i, len;
7238 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307239 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7240 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7241 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007242 tChannelListInfo channel_list;
7243
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007244 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007246 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007248 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 return -EINVAL;
7250 }
7251 buf = extra;
7252
7253 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007254 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7255 * needed = 5 * number of channels. Check ifsufficient
7256 * buffer is available and then proceed to fill the buffer.
7257 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7259 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007260 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007261 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007262 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 return -EINVAL;
7264 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007265 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7266 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307267 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7268 {
7269 //Printing Country code in getChannelList
7270 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7271 {
7272 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7273 "%c ", pBuf[i]);
7274 }
7275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 for(i = 0 ; i < channel_list.num_channels; i++)
7277 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007278 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 }
7281 wrqu->data.length = strlen(extra)+1;
7282
7283 break;
7284 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007285#ifdef FEATURE_WLAN_TDLS
7286 case WE_GET_TDLS_PEERS:
7287 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007288 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007289 break;
7290 }
7291#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007292#ifdef WLAN_FEATURE_11W
7293 case WE_GET_11W_INFO:
7294 {
7295 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7296
7297 snprintf(extra, WE_MAX_STR_LEN,
7298 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7299 "\n Number of Unprotected Disassocs %d"
7300 "\n Number of Unprotected Deauths %d",
7301 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7302 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7303 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7304 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7305 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7306
7307 wrqu->data.length = strlen(extra)+1;
7308 break;
7309 }
7310#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307311#ifdef WLAN_FEATURE_RMC
7312 case WE_GET_IBSS_STA_INFO:
7313 {
7314 hdd_station_ctx_t *pHddStaCtx =
7315 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7316 int idx = 0;
7317 int length = 0, buf = 0;
7318
7319 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7320 {
7321 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7322 {
7323 buf = snprintf
7324 (
7325 (extra + length), WE_MAX_STR_LEN - length,
7326 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7327 pHddStaCtx->conn_info.staId[ idx ],
7328 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7329 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7330 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7331 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7332 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7333 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7334 );
7335 length += buf;
7336 }
7337 }
7338 wrqu->data.length = strlen(extra)+1;
7339 break;
7340 }
7341#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307342 case WE_GET_SNR:
7343 {
7344 v_S7_t s7snr = 0;
7345 int status = 0;
7346 hdd_context_t *pHddCtx;
7347 hdd_station_ctx_t *pHddStaCtx;
7348
7349 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7350 status = wlan_hdd_validate_context(pHddCtx);
7351 if (0 != status)
7352 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307353 return status;
7354 }
7355
7356 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7357
7358 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7359 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7360 {
7361 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7362 " ConnectionState-%d", __func__,
7363 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7364 pHddStaCtx->conn_info.connState);
7365 return -ENONET;
7366 }
7367
7368 /*update the stats in TL*/
7369 wlan_hdd_get_station_stats(pAdapter);
7370 wlan_hdd_get_snr(pAdapter, &s7snr);
7371 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7372 wrqu->data.length = strlen(extra) + 1;
7373 break;
7374 }
7375
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307376#ifdef FEATURE_OEM_DATA_SUPPORT
7377 case WE_GET_OEM_DATA_CAP:
7378 {
7379 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7380 }
7381#endif /* FEATURE_OEM_DATA_SUPPORT */
7382
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307383 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007385 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 break;
7387 }
7388 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307389 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 return 0;
7391}
7392
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307393static int iw_get_char_setnone(struct net_device *dev,
7394 struct iw_request_info *info,
7395 union iwreq_data *wrqu, char *extra)
7396{
7397 int ret;
7398
7399 vos_ssr_protect(__func__);
7400 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7401 vos_ssr_unprotect(__func__);
7402
7403 return ret;
7404}
7405
Jeff Johnson295189b2012-06-20 16:38:30 -07007406/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307407static int __iw_setnone_getnone(struct net_device *dev,
7408 struct iw_request_info *info,
7409 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007410{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307411 hdd_adapter_t *pAdapter;
7412 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307413 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007414 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307415 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007416
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307417 ENTER();
7418
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307419 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7420 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007421 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7423 "%s: Adapter is NULL",__func__);
7424 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007425 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307426 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7427 ret = wlan_hdd_validate_context(pHddCtx);
7428 if (0 != ret)
7429 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307430 return ret;
7431 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307432 /* helper function to get iwreq_data with compat handling. */
7433 if (hdd_priv_get_data(&s_priv_data, wrqu))
7434 {
7435 return -EINVAL;
7436 }
7437
7438 sub_cmd = s_priv_data.flags;
7439
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 switch (sub_cmd)
7441 {
7442 case WE_CLEAR_STATS:
7443 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7446 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7447 break;
7448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 case WE_INIT_AP:
7450 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307451 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7452
7453 /* As Soft AP mode might been changed to STA already with
7454 * killing of Hostapd, need to find the adpater by name
7455 * rather than mode */
7456 hdd_adapter_t* pAdapter_to_stop =
7457 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7458 if( pAdapter_to_stop )
7459 {
7460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7461 "Adapter with name softap.0 already "
7462 "exist, ignoring the request.\nRemove the "
7463 "adapter and try again\n");
7464 break;
7465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 pr_info("Init AP trigger\n");
7467 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7468 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7469 break;
7470 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307471#ifdef WLAN_FEATURE_RMC
7472 case WE_IBSS_GET_PEER_INFO_ALL:
7473 {
7474 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7475 break;
7476 }
7477#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 case WE_STOP_AP:
7479 {
7480 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7481 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7482 * this is a dead code and need to find the adpater by name rather than mode */
7483 hdd_adapter_t* pAdapter_to_stop =
7484 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7485 if( pAdapter_to_stop )
7486 {
7487 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7488
7489 pr_info("Stopping AP mode\n");
7490
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307491 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7492 {
7493 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7494 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7495 }
7496
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307498 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307499 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7501
7502 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7503 pAdapter_to_stop->macAddressCurrent.bytes);
7504 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7505 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307506
7507 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7508 {
7509 /* put the device back into BMPS */
7510 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 }
7513 else
7514 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007515 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 }
7517
7518 break;
7519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007520#ifdef WLAN_BTAMP_FEATURE
7521 case WE_ENABLE_AMP:
7522 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 WLANBAP_RegisterWithHCI(pAdapter);
7525 break;
7526 }
7527 case WE_DISABLE_AMP:
7528 {
7529 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7530 VOS_STATUS status;
7531
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007533
7534 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7535 status = WLANBAP_StopAmp();
7536 if(VOS_STATUS_SUCCESS != status )
7537 {
7538 pHddCtx->isAmpAllowed = VOS_TRUE;
7539 hddLog(VOS_TRACE_LEVEL_FATAL,
7540 "%s: Failed to stop AMP", __func__);
7541 }
7542 else
7543 {
7544 //a state m/c implementation in PAL is TBD to avoid this delay
7545 msleep(500);
7546 pHddCtx->isAmpAllowed = VOS_FALSE;
7547 WLANBAP_DeregisterFromHCI();
7548 }
7549
7550 break;
7551 }
7552#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007553 case WE_ENABLE_DXE_STALL_DETECT:
7554 {
schang6295e542013-03-12 15:31:23 -07007555 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7556 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007557 break;
7558 }
7559 case WE_DISPLAY_DXE_SNAP_SHOT:
7560 {
schang6295e542013-03-12 15:31:23 -07007561 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7562 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007563 break;
7564 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307565 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7566 {
7567 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7568 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307569 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307570 break;
7571 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307572
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307573 case WE_SET_REASSOC_TRIGGER:
7574 {
7575 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7576 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7577 v_U32_t roamId = 0;
7578 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307579 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7580 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307581 return 0;
7582 }
7583
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307584 case WE_STOP_OBSS_SCAN:
7585 {
7586 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7587 2.OBSS scan is stopped by Firmware during the disassociation
7588 3.OBSS stop comamnd is added for debugging purpose*/
7589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7590 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007591
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307592 if (pAdapter == NULL)
7593 {
7594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7595 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307596 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307597 }
7598 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7599 if (pMac == NULL)
7600 {
7601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7602 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307603 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307604 }
7605 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7606 }
7607 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307608 case WE_DUMP_ROAM_TIMER_LOG:
7609 {
7610 vos_dump_roam_time_log_service();
7611 break;
7612 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307613
Mukul Sharma84f27252014-07-14 18:11:42 +05307614 case WE_RESET_ROAM_TIMER_LOG:
7615 {
7616 vos_reset_roam_timer_log();
7617 break;
7618 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307619 case WE_GET_FW_LOGS:
7620 {
7621 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7622 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307623 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307624 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307625 break;
7626 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307627 case WE_GET_FW_MEMDUMP:
7628 {
7629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7630 "FW_MEM_DUMP requested ");
7631 get_fwr_memdump(dev,info,wrqu,extra);
7632 break;
7633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 default:
7635 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007636 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 break;
7638 }
7639 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307640 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 return ret;
7642}
7643
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307644static int iw_setnone_getnone(struct net_device *dev,
7645 struct iw_request_info *info,
7646 union iwreq_data *wrqu, char *extra)
7647{
7648 int ret;
7649
7650 vos_ssr_protect(__func__);
7651 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7652 vos_ssr_unprotect(__func__);
7653
7654 return ret;
7655}
7656
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307657void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7658{
7659 /*
7660 * Function to display HDD WMM information
7661 * for Tx Queues.
7662 * Prints globala as well as per client depending
7663 * whether the clients are registered or not.
7664 */
7665 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307666 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7667 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307668 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7669 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307670 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307671
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307672 for ( i=0; i< NUM_TX_QUEUES; i++)
7673 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307674 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307675 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307676 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307677 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307678
7679 for ( i=0; i< NUM_TX_QUEUES; i++) {
7680 if (tx_queue_count[i]) {
7681 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7682 i, tx_queue_count[i]);
7683 }
7684 }
7685
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307686 if(pSapCtx == NULL){
7687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7688 FL("psapCtx is NULL"));
7689 return;
7690 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307691
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307692 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307693 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7694 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307695 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307696 {
7697 hddLog(LOGE, "******STAIndex: %d*********", i);
7698 for ( j=0; j< NUM_TX_QUEUES; j++)
7699 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307700 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7701 {
7702 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307703 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7704 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307705 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7706 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307707 }
7708 }
7709 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307710 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307711
Katya Nigam1fd24402015-02-16 14:52:19 +05307712 if(pHddStaCtx == NULL){
7713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7714 FL("pHddStaCtx is NULL"));
7715 return;
7716 }
7717
7718 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7719 if(pPeerInfo == NULL){
7720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7721 FL("ppeerinfo is NULL"));
7722 return;
7723 }
7724
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307725 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7726 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7727 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7728 for (j = 0; j < NUM_TX_QUEUES; j++) {
7729 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7730 spin_lock_bh(
7731 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7732 hddLog(LOGE,
7733 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7734 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7735 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7736 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7737 spin_unlock_bh(
7738 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7739 }
7740 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307741 }
7742 }
7743
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307744}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307745
Girish Gowlifb9758e2014-11-19 15:19:17 +05307746static int __iw_set_var_ints_getnone(struct net_device *dev,
7747 struct iw_request_info *info,
7748 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007749{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307750 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307751 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307752 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307753 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007754 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307755 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307756 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007757 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307758 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007759 int cmd = 0;
7760 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307761 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007762
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307763 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307764 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307765 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7767 "%s: NULL extra buffer pointer", __func__);
7768 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307769 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307770 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7771 if (NULL == pAdapter)
7772 {
7773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7774 "%s: Adapter is NULL",__func__);
7775 return -EINVAL;
7776 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307777 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307778 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7779 ret = wlan_hdd_validate_context(pHddCtx);
7780 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007781 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307782 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007783 }
Katya Nigameae74b62015-05-28 17:19:16 +05307784 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307785 {
Katya Nigameae74b62015-05-28 17:19:16 +05307786 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7787 if (NULL == hHal)
7788 {
7789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7790 "%s: Hal Context is NULL",__func__);
7791 return -EINVAL;
7792 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307793 }
7794 sub_cmd = wrqu->data.flags;
7795
7796 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7797
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007798
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007799 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7800 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7801 {
7802 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7803 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7804 {
7805 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7806 staId = pStaCtx->conn_info.staId[0];
7807 }
7808 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7809 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7810 {
7811 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7812 staId = pAPCtx->uBCStaId;
7813 }
7814 else
7815 {
7816 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7817 return 0;
7818 }
7819 }
7820
Jeff Johnson295189b2012-06-20 16:38:30 -07007821 switch (sub_cmd)
7822 {
7823 case WE_LOG_DUMP_CMD:
7824 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307825 if(apps_args[0] == 26) {
7826 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7827 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7828 return 0;
7829 }
7830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007832 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307834 if (hHal)
7835 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7836 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007837
7838 }
7839 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307840#ifdef WLAN_FEATURE_RMC
7841 case WE_IBSS_GET_PEER_INFO:
7842 {
7843 pr_info ( "Station ID = %d\n",apps_args[0]);
7844 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7845 }
7846 break;
7847#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007848
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 case WE_P2P_NOA_CMD:
7850 {
7851 p2p_app_setP2pPs_t p2pNoA;
7852
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307853 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7854 hddLog(LOGE,
7855 FL("Setting NoA is not allowed in Device mode:%d"),
7856 pAdapter->device_mode);
7857 return -EINVAL;
7858 }
7859
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 p2pNoA.opp_ps = apps_args[0];
7861 p2pNoA.ctWindow = apps_args[1];
7862 p2pNoA.duration = apps_args[2];
7863 p2pNoA.interval = apps_args[3];
7864 p2pNoA.count = apps_args[4];
7865 p2pNoA.single_noa_duration = apps_args[5];
7866 p2pNoA.psSelection = apps_args[6];
7867
7868 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7869 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007870 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7872
7873 hdd_setP2pPs(dev, &p2pNoA);
7874
7875 }
7876 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007877
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307878 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7879 {
7880 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7881 __func__, apps_args[0], apps_args[1]);
7882 vosTraceEnable(apps_args[0], apps_args[1]);
7883 }
7884 break;
7885
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007886 case WE_MTRACE_DUMP_CMD:
7887 {
7888 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7889 "bitmask_of_module %d ",
7890 __func__, apps_args[0], apps_args[1], apps_args[2],
7891 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307892 if (hHal)
7893 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7894 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007895
7896 }
7897 break;
7898
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007899 case WE_MCC_CONFIG_CREDENTIAL :
7900 {
7901 cmd = 287; //Command should be updated if there is any change
7902 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007903 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007904 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307905 if (hHal)
7906 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
7907 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007908 }
7909 else
7910 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007911 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007912 return 0;
7913 }
7914 }
7915 break;
7916
7917 case WE_MCC_CONFIG_PARAMS :
7918 {
7919 cmd = 288; //command Should be updated if there is any change
7920 // in the Riva dump command
7921 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7922 }
7923 break;
7924
Chilam NG571c65a2013-01-19 12:27:36 +05307925#ifdef FEATURE_WLAN_TDLS
7926 case WE_TDLS_CONFIG_PARAMS :
7927 {
7928 tdls_config_params_t tdlsParams;
7929
Chilam Ng01120412013-02-19 18:32:21 -08007930 tdlsParams.tdls = apps_args[0];
7931 tdlsParams.tx_period_t = apps_args[1];
7932 tdlsParams.tx_packet_n = apps_args[2];
7933 tdlsParams.discovery_period_t = apps_args[3];
7934 tdlsParams.discovery_tries_n = apps_args[4];
7935 tdlsParams.idle_timeout_t = apps_args[5];
7936 tdlsParams.idle_packet_n = apps_args[6];
7937 tdlsParams.rssi_hysteresis = apps_args[7];
7938 tdlsParams.rssi_trigger_threshold = apps_args[8];
7939 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307940
Chilam Ng01120412013-02-19 18:32:21 -08007941 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307942 }
7943 break;
7944#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307945 case WE_CONFIGURE_MONITOR_MODE:
7946 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307947 v_U32_t magic = 0;
7948 struct completion cmpVar;
7949 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307950 tVOS_CON_MODE mode = hdd_get_conparam();
7951
7952 if (VOS_MONITOR_MODE != mode) {
7953 hddLog(LOGE, FL("invalid mode %d"), mode);
7954 return -EIO;
7955 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307956
Katya Nigamf0511f62015-05-05 16:40:57 +05307957 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7958 if( pMonCtx == NULL )
7959 {
7960 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307961 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05307962 }
7963 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7964 __func__, apps_args[0], apps_args[1], apps_args[2],
7965 apps_args[3], apps_args[4]);
7966 /* Input Validation part of FW */
7967 pMonCtx->ChannelNo = apps_args[0];
7968 pMonCtx->ChannelBW = apps_args[1];
7969 pMonCtx->crcCheckEnabled = apps_args[2];
7970 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7971 pMonCtx->is80211to803ConReq = apps_args[4];
7972 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7973 if( pMonCtx->is80211to803ConReq )
7974 pAdapter->dev->type = ARPHRD_ETHER;
7975 else
7976 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7977 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7978 {
7979 hddLog(LOGE, "%s: Filtering data packets as management and control"
7980 " cannot be converted to 802.3 ",__func__);
7981 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7982 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307983 if (MON_MODE_START == pMonCtx->state) {
7984 magic = MON_MODE_MSG_MAGIC;
7985 init_completion(&cmpVar);
7986 if (VOS_STATUS_SUCCESS !=
7987 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7988 pMonCtx, hdd_monPostMsgCb)) {
7989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7990 FL("failed to post MON MODE REQ"));
7991 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05307992 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307993 }
7994 waitRet = wait_for_completion_timeout(&cmpVar,
7995 MON_MODE_MSG_TIMEOUT);
7996 magic = 0;
7997 if (waitRet <= 0 ) {
7998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7999 FL("failed to wait on monitor mode completion %ld"),
8000 waitRet);
8001 }
8002 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308003 }
8004 break;
8005
8006 case WE_SET_MONITOR_MODE_FILTER:
8007 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308008 v_U32_t magic = 0;
8009 struct completion cmpVar;
8010 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308011 tVOS_CON_MODE mode = hdd_get_conparam();
8012
8013 if (VOS_MONITOR_MODE != mode) {
8014 hddLog(LOGE, FL("invalid mode %d"), mode);
8015 return -EIO;
8016 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308017
Katya Nigamf0511f62015-05-05 16:40:57 +05308018 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8019 if( pMonCtx == NULL )
8020 {
8021 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308022 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308023 }
8024 /* Input Validation Part of FW */
8025 pMonCtx->numOfMacFilters=1;
8026 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8027 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8028 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8029 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8030 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8031 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8032 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8033 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8034 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8035 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8036 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8037 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308038 if (MON_MODE_START == pMonCtx->state) {
8039 magic = MON_MODE_MSG_MAGIC;
8040 init_completion(&cmpVar);
8041 if (VOS_STATUS_SUCCESS !=
8042 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8043 pMonCtx, hdd_monPostMsgCb)) {
8044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8045 FL("failed to post MON MODE REQ"));
8046 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308047 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308048 }
8049 waitRet = wait_for_completion_timeout(&cmpVar,
8050 MON_MODE_MSG_TIMEOUT);
8051 magic = 0;
8052 if (waitRet <= 0 ) {
8053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8054 FL("failed to wait on monitor mode completion %ld"),
8055 waitRet);
8056 }
8057 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308058 }
8059 break;
8060
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 default:
8062 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008063 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8064 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 }
8066 break;
8067 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308068 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 return 0;
8070}
8071
Girish Gowlifb9758e2014-11-19 15:19:17 +05308072static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8073 struct iw_request_info *info,
8074 union iwreq_data *wrqu, char *extra)
8075{
8076 int ret;
8077 union iwreq_data u_priv_wrqu;
8078 int apps_args[MAX_VAR_ARGS] = {0};
8079 int num_args;
8080
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308081 if (!capable(CAP_NET_ADMIN))
8082 {
8083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8084 FL("permission check failed"));
8085 return -EPERM;
8086 }
8087
Girish Gowlifb9758e2014-11-19 15:19:17 +05308088 /* helper function to get iwreq_data with compat handling. */
8089 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8090 {
8091 return -EINVAL;
8092 }
8093
8094 if (NULL == u_priv_wrqu.data.pointer)
8095 {
8096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8097 "%s: NULL data pointer", __func__);
8098 return -EINVAL;
8099 }
8100
8101 num_args = u_priv_wrqu.data.length;
8102 if (num_args > MAX_VAR_ARGS)
8103 {
8104 num_args = MAX_VAR_ARGS;
8105 }
8106
8107 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8108 (sizeof(int)) * num_args))
8109 {
8110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8111 "%s: failed to copy data from user buffer", __func__);
8112 return -EFAULT;
8113 }
8114
8115 vos_ssr_protect(__func__);
8116 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8117 (char *)&apps_args);
8118 vos_ssr_unprotect(__func__);
8119
8120 return ret;
8121}
8122
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308123int iw_set_var_ints_getnone(struct net_device *dev,
8124 struct iw_request_info *info,
8125 union iwreq_data *wrqu, char *extra)
8126{
8127 int ret;
8128 vos_ssr_protect(__func__);
8129 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8130 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008131
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308132 return ret;
8133}
8134
8135static int __iw_add_tspec(struct net_device *dev,
8136 struct iw_request_info *info,
8137 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008138{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308139 hdd_adapter_t *pAdapter;
8140 hdd_station_ctx_t *pHddStaCtx;
8141 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8143 int params[HDD_WLAN_WMM_PARAM_COUNT];
8144 sme_QosWmmTspecInfo tSpec;
8145 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308146 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308147 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008148
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308149 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308150 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8151 if (NULL == pAdapter)
8152 {
8153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8154 "%s: Adapter is NULL",__func__);
8155 return -EINVAL;
8156 }
8157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8158 ret = wlan_hdd_validate_context(pHddCtx);
8159 if (0 != ret)
8160 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308161 return ret;
8162 }
8163 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8164 if (NULL == pHddStaCtx)
8165 {
8166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8167 "%s: STA Context is NULL",__func__);
8168 return -EINVAL;
8169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 // make sure the application is sufficiently priviledged
8171 // note that the kernel will do this for "set" ioctls, but since
8172 // this ioctl wants to return status to user space it must be
8173 // defined as a "get" ioctl
8174 if (!capable(CAP_NET_ADMIN))
8175 {
8176 return -EPERM;
8177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 // we must be associated in order to add a tspec
8179 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8180 {
8181 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8182 return 0;
8183 }
8184
8185 // since we are defined to be a "get" ioctl, and since the number
8186 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308187 // will pass down in the iwreq_data, we must copy the "set" params.
8188 // We must handle the compat for iwreq_data in 32U/64K environment.
8189
8190 // helper fucntion to get iwreq_data with compat handling.
8191 if (hdd_priv_get_data(&s_priv_data, wrqu))
8192 {
8193 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8194 return 0;
8195 }
8196
8197 // make sure all params are correctly passed to function
8198 if ((NULL == s_priv_data.pointer) ||
8199 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8200 {
8201 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8202 return 0;
8203 }
8204
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308206 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 {
8208 // hmmm, can't get them
8209 return -EIO;
8210 }
8211
8212 // clear the tspec
8213 memset(&tSpec, 0, sizeof(tSpec));
8214
8215 // validate the handle
8216 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8217 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8218 {
8219 // that one is reserved
8220 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8221 return 0;
8222 }
8223
8224 // validate the TID
8225 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8226 {
8227 // out of range
8228 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8229 return 0;
8230 }
8231 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8232
8233 // validate the direction
8234 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8235 {
8236 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8237 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8238 break;
8239
8240 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8241 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8242 break;
8243
8244 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8245 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8246 break;
8247
8248 default:
8249 // unknown
8250 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8251 return 0;
8252 }
8253
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308254 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8255
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 // validate the user priority
8257 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8258 {
8259 // out of range
8260 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8261 return 0;
8262 }
8263 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308264 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8265 {
8266 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8267 return 0;
8268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008269
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8271 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8272 tSpec.ts_info.psb, tSpec.ts_info.up);
8273
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8275 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8276 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8277 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8278 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8279 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8280 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8281 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8282 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8283 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8284 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8285 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8286
8287 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8288
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308289 // Save the expected UAPSD settings by application, this will be needed
8290 // when re-negotiating UAPSD settings during BT Coex cases.
8291 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8292
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 // validate the ts info ack policy
8294 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8295 {
8296 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8297 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8298 break;
8299
8300 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8301 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8302 break;
8303
8304 default:
8305 // unknown
8306 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8307 return 0;
8308 }
8309
8310 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308311
8312 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 return 0;
8314}
8315
8316
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308317static int iw_add_tspec(struct net_device *dev,
8318 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 union iwreq_data *wrqu, char *extra)
8320{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308321 int ret;
8322
8323 vos_ssr_protect(__func__);
8324 ret = __iw_add_tspec(dev, info, wrqu, extra);
8325 vos_ssr_unprotect(__func__);
8326
8327 return ret;
8328}
8329
8330static int __iw_del_tspec(struct net_device *dev,
8331 struct iw_request_info *info,
8332 union iwreq_data *wrqu, char *extra)
8333{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308334 hdd_adapter_t *pAdapter;
8335 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 int *params = (int *)extra;
8337 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8338 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308339 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008340
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308341 ENTER();
8342
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308343 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8344 if (NULL == pAdapter)
8345 {
8346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8347 "%s: Adapter is NULL",__func__);
8348 return -EINVAL;
8349 }
8350
8351 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8352 ret = wlan_hdd_validate_context(pHddCtx);
8353 if (0 != ret)
8354 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308355 return ret;
8356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 // make sure the application is sufficiently priviledged
8358 // note that the kernel will do this for "set" ioctls, but since
8359 // this ioctl wants to return status to user space it must be
8360 // defined as a "get" ioctl
8361 if (!capable(CAP_NET_ADMIN))
8362 {
8363 return -EPERM;
8364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 // although we are defined to be a "get" ioctl, the params we require
8366 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8367 // is no need to copy the params from user space
8368
8369 // validate the handle
8370 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8371 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8372 {
8373 // that one is reserved
8374 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8375 return 0;
8376 }
8377
8378 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308379
8380 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 return 0;
8382}
8383
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308384static int iw_del_tspec(struct net_device *dev,
8385 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 union iwreq_data *wrqu, char *extra)
8387{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308388 int ret;
8389
8390 vos_ssr_protect(__func__);
8391 ret = __iw_del_tspec(dev, info, wrqu, extra);
8392 vos_ssr_unprotect(__func__);
8393
8394 return ret;
8395}
8396
8397
8398static int __iw_get_tspec(struct net_device *dev,
8399 struct iw_request_info *info,
8400 union iwreq_data *wrqu, char *extra)
8401{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308402 hdd_adapter_t *pAdapter;
8403 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 int *params = (int *)extra;
8405 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8406 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308407 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008408
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308409 ENTER();
8410
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 // although we are defined to be a "get" ioctl, the params we require
8412 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8413 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308414 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8415 if (NULL == pAdapter)
8416 {
8417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8418 "%s: Adapter is NULL",__func__);
8419 return -EINVAL;
8420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008421
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308422 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8423 ret = wlan_hdd_validate_context(pHddCtx);
8424 if (0 != ret)
8425 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308426 return ret;
8427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 // validate the handle
8429 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8430 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8431 {
8432 // that one is reserved
8433 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8434 return 0;
8435 }
8436
8437 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308438 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 return 0;
8440}
8441
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308442static int iw_get_tspec(struct net_device *dev,
8443 struct iw_request_info *info,
8444 union iwreq_data *wrqu, char *extra)
8445{
8446 int ret;
8447
8448 vos_ssr_protect(__func__);
8449 ret = __iw_get_tspec(dev, info, wrqu, extra);
8450 vos_ssr_unprotect(__func__);
8451
8452 return ret;
8453}
8454
Jeff Johnson295189b2012-06-20 16:38:30 -07008455#ifdef WLAN_FEATURE_VOWIFI_11R
8456//
8457//
8458// Each time the supplicant has the auth_request or reassoc request
8459// IEs ready. This is pushed to the driver. The driver will inturn use
8460// it to send out the auth req and reassoc req for 11r FT Assoc.
8461//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308462static int __iw_set_fties(struct net_device *dev,
8463 struct iw_request_info *info,
8464 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008465{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308466 hdd_adapter_t *pAdapter;
8467 hdd_station_ctx_t *pHddStaCtx;
8468 hdd_context_t *pHddCtx;
8469 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 //v_CONTEXT_t pVosContext;
8471
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308472 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308473 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8474 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008475 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8477 "%s: Adapter is NULL",__func__);
8478 return -EINVAL;
8479 }
8480 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8481 ret = wlan_hdd_validate_context(pHddCtx);
8482 if (0 != ret)
8483 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308484 return ret;
8485 }
8486 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8487 if (NULL == pHddStaCtx)
8488 {
8489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8490 "%s: STA Context is NULL",__func__);
8491 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 if (!wrqu->data.length)
8494 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008495 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 return -EINVAL;
8497 }
8498 if (wrqu->data.pointer == NULL)
8499 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008500 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 return -EINVAL;
8502 }
8503
8504 // Added for debug on reception of Re-assoc Req.
8505 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8506 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008507 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008509 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 }
8511
8512#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008513 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008514#endif
8515
8516 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008517 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 wrqu->data.length);
8519
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308520 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 return 0;
8522}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308523
8524static int iw_set_fties(struct net_device *dev,
8525 struct iw_request_info *info,
8526 union iwreq_data *wrqu, char *extra)
8527{
8528 int ret;
8529
8530 vos_ssr_protect(__func__);
8531 ret = __iw_set_fties(dev, info, wrqu, extra);
8532 vos_ssr_unprotect(__func__);
8533
8534 return ret;
8535}
Jeff Johnson295189b2012-06-20 16:38:30 -07008536#endif
8537
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308538static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008539 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008541{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308542 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008543 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308544 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008545 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308546 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008547 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8548 int idx;
8549 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008550
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308551 ENTER();
8552
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308553 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8554 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008555 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8557 "%s: Adapter is NULL",__func__);
8558 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008559 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308560 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8561 ret_val = wlan_hdd_validate_context(pHddCtx);
8562 if (0 != ret_val)
8563 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308564 return ret_val;
8565 }
8566 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8567 if (NULL == hHal)
8568 {
8569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8570 "%s: Hal Context is NULL",__func__);
8571 return -EINVAL;
8572 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308573 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8574 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308575#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008576
Amar Singhalf3a6e762013-02-19 15:06:50 -08008577 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8578 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008579 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008580 hddLog(VOS_TRACE_LEVEL_ERROR,
8581 "%s: vos_mem_alloc failed", __func__);
8582 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008583 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008584
8585 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8586
8587 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8588 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8589
8590 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8591 mc_addr_list_ptr->ulMulticastAddrCnt);
8592
8593 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008594 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008595 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8596 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8597
8598 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8599 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008600 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008601
Amar Singhalf3a6e762013-02-19 15:06:50 -08008602 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8603 vos_mem_free(mc_addr_list_ptr);
8604 if (eHAL_STATUS_SUCCESS != ret_val)
8605 {
8606 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8607 __func__);
8608 return -EINVAL;
8609 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308610#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308611 }
8612 else
8613 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008614
Amar Singhalf3a6e762013-02-19 15:06:50 -08008615 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8616 "%s: Set MC BC Filter Config request: %d suspend %d",
8617 __func__, pRequest->mcastBcastFilterSetting,
8618 pHddCtx->hdd_wlan_suspended);
8619
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308620 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008621
8622 if (pHddCtx->hdd_wlan_suspended)
8623 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008624 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8625 if (NULL == wlanRxpFilterParam)
8626 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308627 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008628 "%s: vos_mem_alloc failed", __func__);
8629 return -EINVAL;
8630 }
8631
Amar Singhalf3a6e762013-02-19 15:06:50 -08008632 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8633 pRequest->mcastBcastFilterSetting;
8634 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8635
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308636 hdd_conf_hostoffload(pAdapter, TRUE);
8637 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8638 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008639
8640 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8641 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308642 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008643 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8644 wlanRxpFilterParam->setMcstBcstFilter);
8645
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308646 if (eHAL_STATUS_SUCCESS !=
8647 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8648 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008649 {
8650 hddLog(VOS_TRACE_LEVEL_ERROR,
8651 "%s: Failure to execute set HW MC/BC Filter request",
8652 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008653 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008654 return -EINVAL;
8655 }
8656
c_hpothud3ce76d2014-10-28 10:34:13 +05308657 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8658 {
8659 pHddCtx->sus_res_mcastbcast_filter =
8660 pRequest->mcastBcastFilterSetting;
8661 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008662 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008664
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308665 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 return 0;
8667}
8668
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308669static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8670 struct iw_request_info *info,
8671 union iwreq_data *wrqu, char *extra)
8672{
8673 int ret;
8674
8675 vos_ssr_protect(__func__);
8676 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8677 vos_ssr_unprotect(__func__);
8678
8679 return ret;
8680}
8681
8682static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8683 struct iw_request_info *info,
8684 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008685{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308686 hdd_adapter_t *pAdapter;
8687 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308688 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308689 int ret = 0;
8690
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308691 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008692
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308693 if (!capable(CAP_NET_ADMIN))
8694 {
8695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8696 FL("permission check failed"));
8697 return -EPERM;
8698 }
8699
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308700 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8701 if (NULL == pAdapter)
8702 {
8703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8704 "%s: Adapter is NULL",__func__);
8705 return -EINVAL;
8706 }
8707
8708 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8709 ret = wlan_hdd_validate_context(pHddCtx);
8710 if (0 != ret)
8711 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308712 return ret;
8713 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308714 //Reset the filter to INI value as we have to clear the dynamic filter
8715 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008716
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308717 //Configure FW with new setting
8718 if (pHddCtx->hdd_wlan_suspended)
8719 {
8720 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8721 if (NULL == wlanRxpFilterParam)
8722 {
8723 hddLog(VOS_TRACE_LEVEL_ERROR,
8724 "%s: vos_mem_alloc failed", __func__);
8725 return -EINVAL;
8726 }
8727
8728 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8729 pHddCtx->configuredMcastBcastFilter;
8730 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8731
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308732 hdd_conf_hostoffload(pAdapter, TRUE);
8733 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8734 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308735
8736 if (eHAL_STATUS_SUCCESS !=
8737 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8738 wlanRxpFilterParam))
8739 {
8740 hddLog(VOS_TRACE_LEVEL_ERROR,
8741 "%s: Failure to execute set HW MC/BC Filter request",
8742 __func__);
8743 vos_mem_free(wlanRxpFilterParam);
8744 return -EINVAL;
8745 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308746
8747 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8748 {
8749 pHddCtx->sus_res_mcastbcast_filter =
8750 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8751 }
8752
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308753 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308754 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 return 0;
8756}
8757
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308758
8759static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8760 struct iw_request_info *info,
8761 union iwreq_data *wrqu, char *extra)
8762{
8763 int ret;
8764
8765 vos_ssr_protect(__func__);
8766 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8767 vos_ssr_unprotect(__func__);
8768
8769 return ret;
8770}
8771
8772static int __iw_set_host_offload(struct net_device *dev,
8773 struct iw_request_info *info,
8774 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008775{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308776 hdd_adapter_t *pAdapter;
8777 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008778 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308780 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008781
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308782 ENTER();
8783
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308784 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8785 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008786 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8788 "%s: Adapter is NULL",__func__);
8789 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008790 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308791 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8792 ret = wlan_hdd_validate_context(pHddCtx);
8793 if (0 != ret)
8794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308795 return ret;
8796 }
8797
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 /* Debug display of request components. */
8799 switch (pRequest->offloadType)
8800 {
8801 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008802 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 switch (pRequest->enableOrDisable)
8804 {
8805 case WLAN_OFFLOAD_DISABLE:
8806 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8807 break;
8808 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8809 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8810 case WLAN_OFFLOAD_ENABLE:
8811 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8812 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8813 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8814 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8815 }
8816 break;
8817
8818 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008819 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008820 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008821 switch (pRequest->enableOrDisable)
8822 {
8823 case WLAN_OFFLOAD_DISABLE:
8824 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8825 break;
8826 case WLAN_OFFLOAD_ENABLE:
8827 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8828 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8829 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8830 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8831 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8832 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8833 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8834 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8835 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8836 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8837 }
8838 }
8839
8840 /* Execute offload request. The reason that we can copy the request information
8841 from the ioctl structure to the SME structure is that they are laid out
8842 exactly the same. Otherwise, each piece of information would have to be
8843 copied individually. */
8844 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008845 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8846 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 __func__);
8850 return -EINVAL;
8851 }
8852
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308853 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 return 0;
8855}
8856
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308857static int iw_set_host_offload(struct net_device *dev,
8858 struct iw_request_info *info,
8859 union iwreq_data *wrqu, char *extra)
8860{
8861 int ret;
8862
8863 vos_ssr_protect(__func__);
8864 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8865 vos_ssr_unprotect(__func__);
8866
8867 return ret;
8868}
8869
8870static int __iw_set_keepalive_params(struct net_device *dev,
8871 struct iw_request_info *info,
8872 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008873{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308874 hdd_adapter_t *pAdapter;
8875 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008876 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308878 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008879
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308880 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308881 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8882 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8885 "%s: Adapter is NULL",__func__);
8886 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308888 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8889 ret = wlan_hdd_validate_context(pHddCtx);
8890 if (0 != ret)
8891 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308892 return ret;
8893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008895 hddLog(VOS_TRACE_LEVEL_INFO,
8896 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8897 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008898
8899 switch (pRequest->packetType)
8900 {
8901 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008902 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 break;
8904
8905 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8906
Arif Hussain6d2a3322013-11-17 19:50:10 -08008907 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008908 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008909
8910 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8911 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8912 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8913
8914 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8915 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8916 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8917
8918 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8919 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8920 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8921 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8922 break;
8923
8924 }
8925
8926 /* Execute keep alive request. The reason that we can copy the request information
8927 from the ioctl structure to the SME structure is that they are laid out
8928 exactly the same. Otherwise, each piece of information would have to be
8929 copied individually. */
8930 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8931
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308932 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8933 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008934
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008935 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008936 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008938 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008939 __func__);
8940 return -EINVAL;
8941 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308942 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 return 0;
8944}
8945
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308946static int iw_set_keepalive_params(struct net_device *dev,
8947 struct iw_request_info *info,
8948 union iwreq_data *wrqu, char *extra)
8949{
8950 int ret;
8951 vos_ssr_protect(__func__);
8952 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8953 vos_ssr_unprotect(__func__);
8954
8955 return ret;
8956}
8957
Jeff Johnson295189b2012-06-20 16:38:30 -07008958#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008959int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008960 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008961{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008962 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8963 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 int i=0;
8965
8966 if (pHddCtx->cfg_ini->disablePacketFilter)
8967 {
8968 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008969 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 return 0;
8971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 /* Debug display of request components. */
8973 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008974 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008975
8976 switch (pRequest->filterAction)
8977 {
8978 case HDD_RCV_FILTER_SET:
8979 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008980 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008981
8982 packetFilterSetReq.filterId = pRequest->filterId;
8983 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8984 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008985 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 __func__, pRequest->numParams);
8987 return -EINVAL;
8988 }
8989 packetFilterSetReq.numFieldParams = pRequest->numParams;
8990 packetFilterSetReq.coalesceTime = 0;
8991 packetFilterSetReq.filterType = 1;
8992 for (i=0; i < pRequest->numParams; i++)
8993 {
8994 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8995 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8996 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8997 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8998 packetFilterSetReq.paramsData[i].reserved = 0;
8999
Arif Hussain6d2a3322013-11-17 19:50:10 -08009000 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9002 packetFilterSetReq.filterType);
9003
Arif Hussain6d2a3322013-11-17 19:50:10 -08009004 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309006 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9007 (pRequest->paramsData[i].dataLength))
9008 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009009
9010 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9011 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9012 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9013 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9014
Arif Hussain6d2a3322013-11-17 19:50:10 -08009015 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009016 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9017 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9018 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9019
Arif Hussain6d2a3322013-11-17 19:50:10 -08009020 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009021 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9022 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9023 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9024 }
9025
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07009026 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 __func__);
9030 return -EINVAL;
9031 }
9032
9033 break;
9034
9035 case HDD_RCV_FILTER_CLEAR:
9036
Arif Hussain6d2a3322013-11-17 19:50:10 -08009037 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009038 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07009040 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009042 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009043 __func__);
9044 return -EINVAL;
9045 }
9046 break;
9047
9048 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009049 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009050 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 return -EINVAL;
9052 }
9053 return 0;
9054}
9055
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309056int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9057 tANI_U8 sessionId)
9058{
9059 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9060 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9061
9062 if (NULL == pHddCtx)
9063 {
9064 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9065 return -EINVAL;
9066 }
9067
9068 if (pHddCtx->isLogpInProgress)
9069 {
9070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9071 "%s:LOGP in Progress. Ignore!!!", __func__);
9072 return -EBUSY;
9073 }
9074
9075 if (pHddCtx->cfg_ini->disablePacketFilter)
9076 {
9077 hddLog(VOS_TRACE_LEVEL_ERROR,
9078 "%s: Packet Filtering Disabled. Returning ",
9079 __func__ );
9080 return -EINVAL;
9081 }
9082
9083 switch (filterType)
9084 {
9085 /* For setting IPV6 MC and UC Filter we need to configure
9086 * 2 filters, one for MC and one for UC.
9087 * The Filter ID shouldn't be swapped, which results in making
9088 * UC Filter ineffective.
9089 * We have Hardcode all the values
9090 *
9091 * Reason for a seperate UC filter is because, driver need to
9092 * specify the FW that the specific filter is for unicast
9093 * otherwise FW will not pass the unicast frames by default
9094 * through the filter. This is required to avoid any performance
9095 * hits when no unicast filter is set and only MC/BC are set.
9096 * The way driver informs host is by using the MAC protocol
9097 * layer, CMP flag set to MAX, CMP Data set to 1.
9098 */
9099
9100 case HDD_FILTER_IPV6_MC_UC:
9101 /* Setting IPV6 MC Filter below
9102 */
9103 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9104 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9105 packetFilterSetReq.numFieldParams = 2;
9106 packetFilterSetReq.paramsData[0].protocolLayer =
9107 HDD_FILTER_PROTO_TYPE_MAC;
9108 packetFilterSetReq.paramsData[0].cmpFlag =
9109 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9110 packetFilterSetReq.paramsData[0].dataOffset =
9111 WLAN_HDD_80211_FRM_DA_OFFSET;
9112 packetFilterSetReq.paramsData[0].dataLength = 1;
9113 packetFilterSetReq.paramsData[0].compareData[0] =
9114 HDD_IPV6_MC_CMP_DATA;
9115
9116 packetFilterSetReq.paramsData[1].protocolLayer =
9117 HDD_FILTER_PROTO_TYPE_ARP;
9118 packetFilterSetReq.paramsData[1].cmpFlag =
9119 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9120 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9121 packetFilterSetReq.paramsData[1].dataLength = 2;
9122 packetFilterSetReq.paramsData[1].compareData[0] =
9123 HDD_IPV6_CMP_DATA_0;
9124 packetFilterSetReq.paramsData[1].compareData[1] =
9125 HDD_IPV6_CMP_DATA_1;
9126
9127
9128 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9129 &packetFilterSetReq, sessionId))
9130 {
9131 hddLog(VOS_TRACE_LEVEL_ERROR,
9132 "%s: Failure to execute Set IPv6 Mulicast Filter",
9133 __func__);
9134 return -EINVAL;
9135 }
9136
9137 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9138
9139 /*
9140 * Setting IPV6 UC Filter below
9141 */
9142 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9143 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9144 packetFilterSetReq.numFieldParams = 2;
9145 packetFilterSetReq.paramsData[0].protocolLayer =
9146 HDD_FILTER_PROTO_TYPE_MAC;
9147 packetFilterSetReq.paramsData[0].cmpFlag =
9148 HDD_FILTER_CMP_TYPE_MAX;
9149 packetFilterSetReq.paramsData[0].dataOffset = 0;
9150 packetFilterSetReq.paramsData[0].dataLength = 1;
9151 packetFilterSetReq.paramsData[0].compareData[0] =
9152 HDD_IPV6_UC_CMP_DATA;
9153
9154 packetFilterSetReq.paramsData[1].protocolLayer =
9155 HDD_FILTER_PROTO_TYPE_ARP;
9156 packetFilterSetReq.paramsData[1].cmpFlag =
9157 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9158 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9159 packetFilterSetReq.paramsData[1].dataLength = 2;
9160 packetFilterSetReq.paramsData[1].compareData[0] =
9161 HDD_IPV6_CMP_DATA_0;
9162 packetFilterSetReq.paramsData[1].compareData[1] =
9163 HDD_IPV6_CMP_DATA_1;
9164
9165 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9166 &packetFilterSetReq, sessionId))
9167 {
9168 hddLog(VOS_TRACE_LEVEL_ERROR,
9169 "%s: Failure to execute Set IPv6 Unicast Filter",
9170 __func__);
9171 return -EINVAL;
9172 }
9173
9174 break;
9175
9176 case HDD_FILTER_IPV6_MC:
9177 /*
9178 * IPV6 UC Filter might be already set,
9179 * clear the UC Filter. As the Filter
9180 * IDs are static, we can directly clear it.
9181 */
9182 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9183 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9184 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9185 &packetFilterClrReq, sessionId))
9186 {
9187 hddLog(VOS_TRACE_LEVEL_ERROR,
9188 "%s: Failure to execute Clear IPv6 Unicast Filter",
9189 __func__);
9190 return -EINVAL;
9191 }
9192
9193 /*
9194 * Setting IPV6 MC Filter below
9195 */
9196 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9197 packetFilterSetReq.numFieldParams = 2;
9198 packetFilterSetReq.paramsData[0].protocolLayer =
9199 HDD_FILTER_PROTO_TYPE_MAC;
9200 packetFilterSetReq.paramsData[0].cmpFlag =
9201 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9202 packetFilterSetReq.paramsData[0].dataOffset =
9203 WLAN_HDD_80211_FRM_DA_OFFSET;
9204 packetFilterSetReq.paramsData[0].dataLength = 1;
9205 packetFilterSetReq.paramsData[0].compareData[0] =
9206 HDD_IPV6_MC_CMP_DATA;
9207
9208 packetFilterSetReq.paramsData[1].protocolLayer =
9209 HDD_FILTER_PROTO_TYPE_ARP;
9210 packetFilterSetReq.paramsData[1].cmpFlag =
9211 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9212 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9213 packetFilterSetReq.paramsData[1].dataLength = 2;
9214 packetFilterSetReq.paramsData[1].compareData[0] =
9215 HDD_IPV6_CMP_DATA_0;
9216 packetFilterSetReq.paramsData[1].compareData[1] =
9217 HDD_IPV6_CMP_DATA_1;
9218
9219
9220 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9221 &packetFilterSetReq, sessionId))
9222 {
9223 hddLog(VOS_TRACE_LEVEL_ERROR,
9224 "%s: Failure to execute Set IPv6 Multicast Filter",
9225 __func__);
9226 return -EINVAL;
9227 }
9228 break;
9229
9230 default :
9231 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9232 "%s: Packet Filter Request: Invalid",
9233 __func__);
9234 return -EINVAL;
9235 }
9236 return 0;
9237}
9238
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309239void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009240{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309241 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309242 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009243 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309244 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009245
Yue Ma3ede6052013-08-29 00:33:26 -07009246 if (NULL == pHddCtx)
9247 {
9248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9249 return;
9250 }
9251
9252 hHal = pHddCtx->hHal;
9253
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309254 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309256 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9257 return;
9258 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309259
9260 /* Check if INI is enabled or not, other wise just return
9261 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309262 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309263 {
9264 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9265 if (NULL == pMulticastAddrs)
9266 {
9267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9268 return;
9269 }
9270
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 if (set)
9272 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309273 /* Following pre-conditions should be satisfied before wei
9274 * configure the MC address list.
9275 */
9276 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9277 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9278 && pAdapter->mc_addr_list.mc_cnt
9279 && (eConnectionState_Associated ==
9280 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9281 {
9282 pMulticastAddrs->ulMulticastAddrCnt =
9283 pAdapter->mc_addr_list.mc_cnt;
9284 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9285 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009286 memcpy(pMulticastAddrs->multicastAddr[i],
9287 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309288 sizeof(pAdapter->mc_addr_list.addr[i]));
9289 hddLog(VOS_TRACE_LEVEL_INFO,
9290 "%s: %s multicast filter: addr ="
9291 MAC_ADDRESS_STR,
9292 __func__, set ? "setting" : "clearing",
9293 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9294 }
9295 /* Set multicast filter */
9296 sme_8023MulticastList(hHal, pAdapter->sessionId,
9297 pMulticastAddrs);
9298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309300 else
9301 {
9302 /* Need to clear only if it was previously configured
9303 */
9304 if (pAdapter->mc_addr_list.isFilterApplied)
9305 {
9306 pMulticastAddrs->ulMulticastAddrCnt = 0;
9307 sme_8023MulticastList(hHal, pAdapter->sessionId,
9308 pMulticastAddrs);
9309 }
9310
9311 }
9312 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009313 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309315 else
9316 {
9317 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309318 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309319 }
9320 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009321}
9322
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309323static int __iw_set_packet_filter_params(struct net_device *dev,
9324 struct iw_request_info *info,
9325 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309326{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309327 hdd_adapter_t *pAdapter;
9328 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009329 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309330 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309331 struct iw_point s_priv_data;
9332
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309333 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309334
9335 if (!capable(CAP_NET_ADMIN))
9336 {
9337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9338 FL("permission check failed"));
9339 return -EPERM;
9340 }
9341
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309342 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9343 if (NULL == pAdapter)
9344 {
9345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9346 "%s: Adapter is NULL",__func__);
9347 return -EINVAL;
9348 }
9349 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9350 ret = wlan_hdd_validate_context(pHddCtx);
9351 if (0 != ret)
9352 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309353 return ret;
9354 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309355 if (hdd_priv_get_data(&s_priv_data, wrqu))
9356 {
9357 return -EINVAL;
9358 }
9359
9360 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9361 {
9362 return -EINVAL;
9363 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009364
Arif Hussain0273cba2014-01-07 20:58:29 -08009365 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309366 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9367 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009368 if (NULL == pRequest)
9369 {
9370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9371 "mem_alloc_copy_from_user_helper fail");
9372 return -ENOMEM;
9373 }
9374
9375 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
9376 kfree(pRequest);
9377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309378 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009379 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009380}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309381
9382static int iw_set_packet_filter_params(struct net_device *dev,
9383 struct iw_request_info *info,
9384 union iwreq_data *wrqu, char *extra)
9385{
9386 int ret;
9387
9388 vos_ssr_protect(__func__);
9389 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9390 vos_ssr_unprotect(__func__);
9391
9392 return ret;
9393}
Jeff Johnson295189b2012-06-20 16:38:30 -07009394#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309395static int __iw_get_statistics(struct net_device *dev,
9396 struct iw_request_info *info,
9397 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009398{
9399
9400 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9401 eHalStatus status = eHAL_STATUS_SUCCESS;
9402 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309403 hdd_adapter_t *pAdapter;
9404 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309406 int tlen = 0, ret = 0;
9407 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009408
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309409 tCsrGlobalClassAStatsInfo *aStats;
9410 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009411
9412 ENTER();
9413
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309414 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9415 if (NULL == pAdapter)
9416 {
9417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9418 "%s: Adapter is NULL",__func__);
9419 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309421 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9422 ret = wlan_hdd_validate_context(pHddCtx);
9423 if (0 != ret)
9424 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309425 return ret;
9426 }
9427 pStats = &(pAdapter->hdd_stats.summary_stat);
9428 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9429 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9431
9432 wrqu->txpower.value = 0;
9433 }
9434 else {
9435 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9436 SME_SUMMARY_STATS |
9437 SME_GLOBAL_CLASSA_STATS |
9438 SME_GLOBAL_CLASSB_STATS |
9439 SME_GLOBAL_CLASSC_STATS |
9440 SME_GLOBAL_CLASSD_STATS |
9441 SME_PER_STA_STATS,
9442 hdd_StatisticsCB, 0, FALSE,
9443 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9444
9445 if (eHAL_STATUS_SUCCESS != status)
9446 {
9447 hddLog(VOS_TRACE_LEVEL_ERROR,
9448 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009449 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 return -EINVAL;
9451 }
9452
9453 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309454 if (NULL == pWextState)
9455 {
9456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9457 "%s: pWextState is NULL",__func__);
9458 return -EINVAL;
9459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009460
9461 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9462 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9463 {
9464 hddLog(VOS_TRACE_LEVEL_ERROR,
9465 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009466 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 /*Remove the SME statistics list by passing NULL in callback argument*/
9468 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9469 SME_SUMMARY_STATS |
9470 SME_GLOBAL_CLASSA_STATS |
9471 SME_GLOBAL_CLASSB_STATS |
9472 SME_GLOBAL_CLASSC_STATS |
9473 SME_GLOBAL_CLASSD_STATS |
9474 SME_PER_STA_STATS,
9475 NULL, 0, FALSE,
9476 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9477
9478 return -EINVAL;
9479 }
9480 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9481 (tANI_U8) sizeof (pStats->retry_cnt),
9482 (char*) &(pStats->retry_cnt[0]),
9483 tlen);
9484
9485 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9486 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9487 (char*) &(pStats->multiple_retry_cnt[0]),
9488 tlen);
9489
9490 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9491 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9492 (char*) &(pStats->tx_frm_cnt[0]),
9493 tlen);
9494
9495 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9496 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9497 (char*) &(pStats->rx_frm_cnt),
9498 tlen);
9499
9500 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9501 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9502 (char*) &(pStats->frm_dup_cnt),
9503 tlen);
9504
9505 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9506 (tANI_U8) sizeof (pStats->fail_cnt),
9507 (char*) &(pStats->fail_cnt[0]),
9508 tlen);
9509
9510 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9511 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9512 (char*) &(pStats->rts_fail_cnt),
9513 tlen);
9514
9515 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9516 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9517 (char*) &(pStats->ack_fail_cnt),
9518 tlen);
9519
9520 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9521 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9522 (char*) &(pStats->rts_succ_cnt),
9523 tlen);
9524
9525 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9526 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9527 (char*) &(pStats->rx_discard_cnt),
9528 tlen);
9529
9530 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9531 (tANI_U8) sizeof (pStats->rx_error_cnt),
9532 (char*) &(pStats->rx_error_cnt),
9533 tlen);
9534
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009535 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009536 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009537 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 tlen);
9539
9540 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9541 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9542 (char*) &(dStats->rx_byte_cnt),
9543 tlen);
9544
9545 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9546 (tANI_U8) sizeof (dStats->rx_rate),
9547 (char*) &(dStats->rx_rate),
9548 tlen);
9549
9550 /* Transmit rate, in units of 500 kbit/sec */
9551 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9552 (tANI_U8) sizeof (aStats->tx_rate),
9553 (char*) &(aStats->tx_rate),
9554 tlen);
9555
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009556 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9557 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9558 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009559 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009560 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9561 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9562 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009563 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009564 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9565 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9566 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009567 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009568 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9569 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9570 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009571 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009572 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9573 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9574 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009575 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009576 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9577 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9578 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009579 tlen);
9580
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 wrqu->data.length = tlen;
9582
9583 }
9584
9585 EXIT();
9586
9587 return 0;
9588}
9589
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309590static int iw_get_statistics(struct net_device *dev,
9591 struct iw_request_info *info,
9592 union iwreq_data *wrqu, char *extra)
9593{
9594 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009595
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309596 vos_ssr_protect(__func__);
9597 ret = __iw_get_statistics(dev, info, wrqu, extra);
9598 vos_ssr_unprotect(__func__);
9599
9600 return ret;
9601}
Jeff Johnson295189b2012-06-20 16:38:30 -07009602#ifdef FEATURE_WLAN_SCAN_PNO
9603
9604/*Max Len for PNO notification*/
9605#define MAX_PNO_NOTIFY_LEN 100
9606void found_pref_network_cb (void *callbackContext,
9607 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9608{
9609 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9610 union iwreq_data wrqu;
9611 char buf[MAX_PNO_NOTIFY_LEN+1];
9612
9613 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9614 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9615
9616 // create the event
9617 memset(&wrqu, 0, sizeof(wrqu));
9618 memset(buf, 0, sizeof(buf));
9619
9620 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9621 pPrefNetworkFoundInd->ssId.ssId,
9622 (unsigned int)pPrefNetworkFoundInd->rssi);
9623
9624 wrqu.data.pointer = buf;
9625 wrqu.data.length = strlen(buf);
9626
9627 // send the event
9628
9629 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9630
9631}
9632
9633
9634/*string based input*/
9635VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9636 union iwreq_data *wrqu, char *extra, int nOffset)
9637{
9638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309639 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009640 /* pnoRequest is a large struct, so we make it static to avoid stack
9641 overflow. This API is only invoked via ioctl, so it is
9642 serialized by the kernel rtnl_lock and hence does not need to be
9643 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309644 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 char *ptr;
9646 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309647 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9649
9650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9651 "PNO data len %d data %s",
9652 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009653 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009654
9655 if (wrqu->data.length <= nOffset )
9656 {
9657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9658 return VOS_STATUS_E_FAILURE;
9659 }
9660
9661 pnoRequest.enable = 0;
9662 pnoRequest.ucNetworksCount = 0;
9663 /*-----------------------------------------------------------------------
9664 Input is string based and expected to be like this:
9665
9666 <enabled> <netw_count>
9667 for each network:
9668 <ssid_len> <ssid> <authentication> <encryption>
9669 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9670 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9671
9672 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009673 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 -07009674
9675 this translates into:
9676 -----------------------------
9677 enable PNO
9678 look for 2 networks:
9679 test - with authentication type 0 and encryption type 0,
9680 that can be found on 3 channels: 1 6 and 11 ,
9681 SSID bcast type is unknown (directed probe will be sent if AP not found)
9682 and must meet -40dBm RSSI
9683
9684 test2 - with auth and enrytption type 4/4
9685 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9686 bcast type is non-bcast (directed probe will be sent)
9687 and must not meet any RSSI threshold
9688
Jeff Johnson8301aa12013-03-28 14:27:29 -07009689 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009691 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009692
Wilson Yang623f6592013-10-08 16:33:37 -07009693 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9694 {
9695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9696 "PNO enable input is not valid %s",ptr);
9697 return VOS_STATUS_E_FAILURE;
9698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009699
9700 if ( 0 == pnoRequest.enable )
9701 {
9702 /*Disable PNO*/
9703 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309704 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9705 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 pAdapter->sessionId,
9707 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309708 if (eHAL_STATUS_SUCCESS != status)
9709 {
9710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9711 "%s: failed to disable PNO", __func__);
9712 return VOS_STATUS_E_FAILURE;
9713 }
9714 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 return VOS_STATUS_SUCCESS;
9716 }
9717
c_hpothu37f21312014-04-09 21:49:54 +05309718 if (TRUE == pHddCtx->isPnoEnable)
9719 {
9720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9721 FL("already PNO is enabled"));
9722 return -EBUSY;
9723 }
9724 pHddCtx->isPnoEnable = TRUE;
9725
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009727
9728 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9729 {
9730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9731 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309732 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009734
9735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9736 "PNO enable %d networks count %d offset %d",
9737 pnoRequest.enable,
9738 pnoRequest.ucNetworksCount,
9739 nOffset);
9740
9741 /* Parameters checking:
9742 ucNetworksCount has to be larger than 0*/
9743 if (( 0 == pnoRequest.ucNetworksCount ) ||
9744 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9745 {
9746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309747 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 }
9749
9750 ptr += nOffset;
9751
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309752 pnoRequest.aNetworks =
9753 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9754 if (pnoRequest.aNetworks == NULL)
9755 {
9756 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9757 FL("failed to allocate memory aNetworks %u"),
9758 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9759 goto error;
9760 }
9761 vos_mem_zero(pnoRequest.aNetworks,
9762 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9763
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9765 {
9766
9767 pnoRequest.aNetworks[i].ssId.length = 0;
9768
Wilson Yang623f6592013-10-08 16:33:37 -07009769 ucParams = sscanf(ptr,"%hhu %n",
9770 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9771
9772 if (1 != ucParams)
9773 {
9774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9775 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309776 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009778
9779 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9780 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9781 {
9782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9783 "SSID Len %d is not correct for network %d",
9784 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309785 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 }
9787
9788 /*Advance to SSID*/
9789 ptr += nOffset;
9790
Jeff Johnson8301aa12013-03-28 14:27:29 -07009791 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009792 pnoRequest.aNetworks[i].ssId.length);
9793 ptr += pnoRequest.aNetworks[i].ssId.length;
9794
Jeff Johnson02797792013-10-26 19:17:13 -07009795 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009796 &(pnoRequest.aNetworks[i].authentication),
9797 &(pnoRequest.aNetworks[i].encryption),
9798 &(pnoRequest.aNetworks[i].ucChannelCount),
9799 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009800
Wilson Yang623f6592013-10-08 16:33:37 -07009801 if ( 3 != ucParams )
9802 {
9803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9804 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309805 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009806 }
9807
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009809 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009810 "auth %d encry %d channel count %d offset %d",
9811 pnoRequest.aNetworks[i].ssId.length,
9812 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9813 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9814 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9815 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9816 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9817 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9818 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9819 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9820 pnoRequest.aNetworks[i].authentication,
9821 pnoRequest.aNetworks[i].encryption,
9822 pnoRequest.aNetworks[i].ucChannelCount,
9823 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009824
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 /*Advance to channel list*/
9826 ptr += nOffset;
9827
Wilson Yang623f6592013-10-08 16:33:37 -07009828 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 {
9830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9831 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309832 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 }
9834
9835 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9836 {
9837 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9838 {
Wilson Yang623f6592013-10-08 16:33:37 -07009839 if (1 != sscanf(ptr,"%hhu %n",
9840 &(pnoRequest.aNetworks[i].aChannels[j]),
9841 &nOffset))
9842 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9843 "PNO network channel input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +05309844 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009845 }
9846 /*Advance to next channel number*/
9847 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009848 }
9849 }
9850
Jeff Johnson02797792013-10-26 19:17:13 -07009851 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009852 &(pnoRequest.aNetworks[i].bcastNetwType),
9853 &nOffset))
9854 {
9855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9856 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309857 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009859
9860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9861 "PNO bcastNetwType %d offset %d",
9862 pnoRequest.aNetworks[i].bcastNetwType,
9863 nOffset );
9864
9865 /*Advance to rssi Threshold*/
9866 ptr += nOffset;
9867
Wilson Yang623f6592013-10-08 16:33:37 -07009868 if (1 != sscanf(ptr,"%hhu %n",
9869 &(pnoRequest.aNetworks[i].rssiThreshold),
9870 &nOffset))
9871 {
9872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9873 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309874 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009876
9877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9878 "PNO rssi %d offset %d",
9879 pnoRequest.aNetworks[i].rssiThreshold,
9880 nOffset );
9881 /*Advance to next network*/
9882 ptr += nOffset;
9883 }/*For ucNetworkCount*/
9884
9885 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009886 &(pnoRequest.scanTimers.ucScanTimersCount),
9887 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009888
9889 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009890 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 {
9892 ptr += nOffset;
9893
Jeff Johnson8301aa12013-03-28 14:27:29 -07009894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9895 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 pnoRequest.scanTimers.ucScanTimersCount,
9897 nOffset );
9898
9899 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9900 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309903 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 }
9905
9906 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9907 {
Jeff Johnson02797792013-10-26 19:17:13 -07009908 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9910 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9911 &nOffset);
9912
Wilson Yang623f6592013-10-08 16:33:37 -07009913 if (2 != ucParams)
9914 {
9915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9916 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309917 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009918 }
9919
Jeff Johnson8301aa12013-03-28 14:27:29 -07009920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9921 "PNO Timer value %d Timer repeat %d offset %d",
9922 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9924 nOffset );
9925
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 ptr += nOffset;
9927 }
9928
9929 }
9930 else
9931 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9933 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9935
9936 /*Scan timers defaults to 5 minutes*/
9937 pnoRequest.scanTimers.ucScanTimersCount = 1;
9938 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9939 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9940 }
9941
Wilson Yang623f6592013-10-08 16:33:37 -07009942 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009943
9944 pnoRequest.modePNO = ucMode;
9945 /*for LA we just expose suspend option*/
9946 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9947 {
9948 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9949 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309950 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9951 if (pnoRequest.p24GProbeTemplate == NULL){
9952 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9953 FL("failed to allocate memory p24GProbeTemplate %u"),
9954 SIR_PNO_MAX_PB_REQ_SIZE);
9955 goto error;
9956 }
9957
9958 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9959 if (pnoRequest.p5GProbeTemplate == NULL){
9960 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9961 FL("failed to allocate memory p5GProbeTemplate %u"),
9962 SIR_PNO_MAX_PB_REQ_SIZE);
9963 goto error;
9964 }
9965
9966 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9967 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009968
c_hpothu37f21312014-04-09 21:49:54 +05309969 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 pAdapter->sessionId,
9971 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309972 if (eHAL_STATUS_SUCCESS == status)
9973 {
9974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9975 "%s: PNO enabled", __func__);
9976 return VOS_STATUS_SUCCESS;
9977 }
9978error:
9979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9980 "%s: Failed to enable PNO", __func__);
9981 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309982 if (pnoRequest.aNetworks)
9983 vos_mem_free(pnoRequest.aNetworks);
9984 if (pnoRequest.p24GProbeTemplate)
9985 vos_mem_free(pnoRequest.p24GProbeTemplate);
9986 if (pnoRequest.p5GProbeTemplate)
9987 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309988 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009989}/*iw_set_pno*/
9990
9991VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9992 union iwreq_data *wrqu, char *extra, int nOffset)
9993{
9994 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9995 v_U8_t rssiThreshold = 0;
9996 v_U8_t nRead;
9997
Arif Hussain7adce1b2013-11-11 22:59:34 -08009998 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 &rssiThreshold);
10000
10001 if ( 1 != nRead )
10002 {
10003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10004 "Incorrect format");
10005 return VOS_STATUS_E_FAILURE;
10006 }
10007
10008 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10009 return VOS_STATUS_SUCCESS;
10010}
10011
10012
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010013static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 struct iw_request_info *info,
10015 union iwreq_data *wrqu, char *extra)
10016{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010017 hdd_adapter_t *pAdapter;
10018 hdd_context_t *pHddCtx;
10019 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010020 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010021
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010022 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010023 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10024 if (NULL == pAdapter)
10025 {
10026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10027 "%s: Adapter is NULL",__func__);
10028 return -EINVAL;
10029 }
10030
10031 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10032 ret = wlan_hdd_validate_context(pHddCtx);
10033 if (0 != ret)
10034 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010035 return ret;
10036 }
10037
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010038
10039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010041
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010042 status = iw_set_pno(dev,info,wrqu,extra,0);
10043
10044 EXIT();
10045 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010046}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010047
10048static int iw_set_pno_priv(struct net_device *dev,
10049 struct iw_request_info *info,
10050 union iwreq_data *wrqu, char *extra)
10051{
10052 int ret;
10053
10054 vos_ssr_protect(__func__);
10055 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10056 vos_ssr_unprotect(__func__);
10057
10058 return ret;
10059}
Jeff Johnson295189b2012-06-20 16:38:30 -070010060#endif /*FEATURE_WLAN_SCAN_PNO*/
10061
10062//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010063int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010064{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010065 hdd_adapter_t *pAdapter;
10066 tHalHandle hHal;
10067 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010068 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010069 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010070 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010072 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010073 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010074 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010075
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010076 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010077 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10078 if (NULL == pAdapter)
10079 {
10080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10081 "%s: Adapter is NULL",__func__);
10082 return -EINVAL;
10083 }
10084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10085 retval = wlan_hdd_validate_context(pHddCtx);
10086 if (0 != retval)
10087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010088 return retval;
10089 }
10090 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10091 if (NULL == hHal)
10092 {
10093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10094 "%s: Hal Context is NULL",__func__);
10095 return -EINVAL;
10096 }
10097 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010098
Atul Mittal54378cb2014-04-02 16:51:50 +053010099 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 {
10101 case WLAN_HDD_UI_BAND_AUTO:
10102 band = eCSR_BAND_ALL;
10103 break;
10104 case WLAN_HDD_UI_BAND_5_GHZ:
10105 band = eCSR_BAND_5G;
10106 break;
10107 case WLAN_HDD_UI_BAND_2_4_GHZ:
10108 band = eCSR_BAND_24;
10109 break;
10110 default:
10111 band = eCSR_BAND_MAX;
10112 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010113 connectedBand =
10114 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010115
Atul Mittal54378cb2014-04-02 16:51:50 +053010116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010117 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010118
10119 if (band == eCSR_BAND_MAX)
10120 {
10121 /* Received change band request with invalid band value */
10122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010123 "%s: Invalid band value %u", __func__, ui_band);
10124 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 }
10126
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010127 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010128 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010129 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010131 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010132 band, pHddCtx->cfg_ini->nBandCapability);
10133 return -EIO;
10134 }
10135
Sushant Kaushik1165f872015-03-30 20:25:27 +053010136 if (band == eCSR_BAND_ALL)
10137 {
10138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10139 "received. Setting band same as ini value %d"),
10140 pHddCtx->cfg_ini->nBandCapability);
10141 band = pHddCtx->cfg_ini->nBandCapability;
10142 }
10143
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10145 {
10146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10147 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010148 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010149 return -EIO;
10150 }
10151
10152 if (currBand != band)
10153 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010154 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010155 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010156 /* Return failure if current country code is world regulatory domain*/
10157 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10158 pMac->scan.countryCodeCurrent[1] == '0') )
10159 {
10160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10161 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010162 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010163 return -EAGAIN;
10164 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010165 }
10166
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 /* Change band request received.
10168 * Abort pending scan requests, flush the existing scan results,
10169 * and change the band capability
10170 */
10171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10172 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010173 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010174
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010175 /* We need to change the band and flush the scan results here itself
10176 * as we may get timeout for disconnection in which we will return
10177 * with out doing any of these
10178 */
10179 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10180 {
10181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10182 "%s: failed to set the band value to %u ",
10183 __func__, band);
10184 return -EINVAL;
10185 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010186 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10187 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010188 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010189 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10190 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010191 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010192 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10193 * information available in NV so to get the channel information from kernel
10194 * we need to send regulatory hint for the currunt country
10195 * And to set the same country again we need to set the dummy country
10196 * first and then the actual country.
10197 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010198#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10199 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10200#else
10201 regulatory_hint_user("00");
10202#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010203 wait_result = wait_for_completion_interruptible_timeout(
10204 &pHddCtx->linux_reg_req,
10205 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10206
10207 /* if the country information does not exist with the kernel,
10208 then the driver callback would not be called */
10209
10210 if (wait_result >= 0)
10211 {
10212 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10213 "runtime country code is found in kernel db");
10214 }
10215 else
10216 {
10217 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10218 "runtime country code is not found"
10219 " in kernel db");
10220 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010221
10222 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010223
10224 /*
10225 * Update 11dcountry and current country here as the hint
10226 * with 00 results in 11d and current country with 00
10227 */
10228 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10229 WNI_CFG_COUNTRY_CODE_LEN);
10230 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10231 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010232#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10233 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10234#else
10235 regulatory_hint_user(curr_country);
10236#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010237 wait_result = wait_for_completion_interruptible_timeout(
10238 &pHddCtx->linux_reg_req,
10239 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10240
10241 /* if the country information does not exist with the kernel,
10242 then the driver callback would not be called */
10243 if (wait_result >= 0)
10244 {
10245 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10246 "runtime country code is found in kernel db");
10247 }
10248 else
10249 {
10250 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10251 "runtime country code is not found"
10252 " in kernel db");
10253 }
10254
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010255 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010256 }
10257 else
10258 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010259#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010260 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10261 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010262#else
10263 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10264#endif
10265
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010266 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010267 pScanInfo = &pHddCtx->scan_info;
10268 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10269 {
10270 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10271 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10272 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010273 sme_FilterScanResults(hHal, pAdapter->sessionId);
10274
10275 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010276 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10277 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 eHalStatus status = eHAL_STATUS_SUCCESS;
10280 long lrc;
10281
10282 /* STA already connected on current band, So issue disconnect first,
10283 * then change the band*/
10284
10285 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010286 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010287 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010288
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10290
10291 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10292 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10293
Jeff Johnson43971f52012-07-17 12:26:56 -070010294 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 {
10296 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010297 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 __func__, (int)status );
10299 return -EINVAL;
10300 }
10301
10302 lrc = wait_for_completion_interruptible_timeout(
10303 &pAdapter->disconnect_comp_var,
10304 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10305
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010306 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010307
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010308 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010309 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010310
10311 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10312 }
10313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010315 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010316 if (TRUE == pHddCtx->isSetBandByNL)
10317 return 0;
10318 else
10319 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010320}
10321
Atul Mittal54378cb2014-04-02 16:51:50 +053010322int hdd_setBand_helper(struct net_device *dev, const char *command)
10323{
10324 u8 band;
10325
10326 /*convert the band value from ascii to integer*/
10327 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10328
10329 return hdd_setBand(dev, band);
10330
10331}
10332
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010333static int __iw_set_band_config(struct net_device *dev,
10334 struct iw_request_info *info,
10335 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010336{
Atul Mittal54378cb2014-04-02 16:51:50 +053010337 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010338
Arif Hussain0273cba2014-01-07 20:58:29 -080010339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010340
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010341 if (!capable(CAP_NET_ADMIN))
10342 {
10343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10344 FL("permission check failed"));
10345 return -EPERM;
10346 }
10347
Atul Mittal54378cb2014-04-02 16:51:50 +053010348 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010349}
10350
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010351static int iw_set_band_config(struct net_device *dev,
10352 struct iw_request_info *info,
10353 union iwreq_data *wrqu, char *extra)
10354{
10355 int ret;
10356
10357 vos_ssr_protect(__func__);
10358 ret = __iw_set_band_config(dev, info, wrqu, extra);
10359 vos_ssr_unprotect(__func__);
10360
10361 return ret;
10362}
10363
c_manjeecfd1efb2015-09-25 19:32:34 +053010364static int get_fwr_memdump(struct net_device *dev,
10365 struct iw_request_info *info,
10366 union iwreq_data *wrqu, char *extra)
10367{
10368 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10369 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10370 int ret;
10371 ENTER();
10372 // HddCtx sanity
10373 ret = wlan_hdd_validate_context(pHddCtx);
10374 if (0 != ret)
10375 {
10376 return ret;
10377 }
10378 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10379 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10380 {
10381 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10382 return -EINVAL;
10383 }
10384 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10385
10386 EXIT();
10387 return ret;
10388}
10389
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010390static int __iw_set_power_params_priv(struct net_device *dev,
10391 struct iw_request_info *info,
10392 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010393{
Arif Hussain0273cba2014-01-07 20:58:29 -080010394 int ret;
10395 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010396
Jeff Johnson295189b2012-06-20 16:38:30 -070010397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10398 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010399
10400 if (!capable(CAP_NET_ADMIN))
10401 {
10402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10403 FL("permission check failed"));
10404 return -EPERM;
10405 }
10406
Arif Hussain0273cba2014-01-07 20:58:29 -080010407 /* ODD number is used for set, copy data using copy_from_user */
10408 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10409 wrqu->data.length);
10410 if (NULL == ptr)
10411 {
10412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10413 "mem_alloc_copy_from_user_helper fail");
10414 return -ENOMEM;
10415 }
10416
10417 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10418 kfree(ptr);
10419 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010420}
10421
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010422static int iw_set_power_params_priv(struct net_device *dev,
10423 struct iw_request_info *info,
10424 union iwreq_data *wrqu, char *extra)
10425{
10426 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010427
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010428 vos_ssr_protect(__func__);
10429 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10430 vos_ssr_unprotect(__func__);
10431
10432 return ret;
10433}
Jeff Johnson295189b2012-06-20 16:38:30 -070010434
10435/*string based input*/
10436VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10437 union iwreq_data *wrqu, char *extra, int nOffset)
10438{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010439 hdd_adapter_t *pAdapter;
10440 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010441 tSirSetPowerParamsReq powerRequest;
10442 char *ptr;
10443 v_U8_t ucType;
10444 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010445 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010446
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010447 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010448 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10449 if (NULL == pAdapter)
10450 {
10451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10452 "%s: Adapter is NULL",__func__);
10453 return -EINVAL;
10454 }
10455
10456 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10457 ret = wlan_hdd_validate_context(pHddCtx);
10458 if (0 != ret)
10459 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010460 return ret;
10461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10463 "Power Params data len %d data %s",
10464 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010465 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010466
10467 if (wrqu->data.length <= nOffset )
10468 {
10469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10470 return VOS_STATUS_E_FAILURE;
10471 }
10472
10473 uTotalSize = wrqu->data.length - nOffset;
10474
10475 /*-----------------------------------------------------------------------
10476 Input is string based and expected to be like this:
10477
10478 <param_type> <param_value> <param_type> <param_value> ...
10479
10480 e.g:
10481 1 2 2 3 3 0 4 1 5 1
10482
10483 e.g. setting just a few:
10484 1 2 4 1
10485
10486 parameter types:
10487 -----------------------------
10488 1 - Ignore DTIM
10489 2 - Listen Interval
10490 3 - Broadcast Multicas Filter
10491 4 - Beacon Early Termination
10492 5 - Beacon Early Termination Interval
10493 -----------------------------------------------------------------------*/
10494 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10495 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10496 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10497 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10498 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10499
Arif Hussain7adce1b2013-11-11 22:59:34 -080010500 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010501
10502 while ( uTotalSize )
10503 {
Wilson Yang6f971452013-10-08 15:00:00 -070010504 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10505 {
10506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10507 "Invalid input parameter type %s",ptr);
10508 return VOS_STATUS_E_FAILURE;
10509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010510
10511 uTotalSize -= nOffset;
10512
10513 if (!uTotalSize)
10514 {
10515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010516 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 ucType, nOffset);
10518 return VOS_STATUS_E_FAILURE;
10519 }
10520
10521 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010522
Jeff Johnson02797792013-10-26 19:17:13 -070010523 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010524 {
10525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10526 "Invalid input parameter value %s",ptr);
10527 return VOS_STATUS_E_FAILURE;
10528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010529
10530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10531 "Power request parameter %d value %d offset %d",
10532 ucType, uValue, nOffset);
10533
10534 switch (ucType)
10535 {
10536 case eSIR_IGNORE_DTIM:
10537 powerRequest.uIgnoreDTIM = uValue;
10538 break;
10539 case eSIR_LISTEN_INTERVAL:
10540 powerRequest.uListenInterval = uValue;
10541 break;
10542 case eSIR_MCAST_BCAST_FILTER:
10543 powerRequest.uBcastMcastFilter = uValue;
10544 break;
10545 case eSIR_ENABLE_BET:
10546 powerRequest.uEnableBET = uValue;
10547 break;
10548 case eSIR_BET_INTERVAL:
10549 powerRequest.uBETInterval = uValue;
10550 break;
10551 default:
10552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010553 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 ucType, uValue, nOffset);
10555 return VOS_STATUS_E_FAILURE;
10556 }
10557
10558 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10560 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010561 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010563 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010564 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010565 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10566 {
10567 uTotalSize = 0;
10568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010569
10570 }/*Go for as long as we have a valid string*/
10571
10572 /* put the device into full power*/
10573 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10574
10575 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010576 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010577
10578 /* put the device back to power save*/
10579 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10580
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010581 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 return VOS_STATUS_SUCCESS;
10583}/*iw_set_power_params*/
10584
Atul Mittalc0f739f2014-07-31 13:47:47 +053010585// tdlsoffchan
10586#ifdef FEATURE_WLAN_TDLS
10587
Atul Mittal87ec2422014-09-24 13:12:50 +053010588int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010589{
10590 if (offchannel < 0 || offchannel > 165)
10591 {
10592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10593 __func__, offchannel);
10594 return -1;
10595
10596 }
10597
10598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10599 __func__, tdlsOffCh, offchannel);
10600
10601 tdlsOffCh = offchannel;
10602 return 0;
10603}
10604
Atul Mittal87ec2422014-09-24 13:12:50 +053010605int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010606{
10607 if (offchanoffset == 0)
10608 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010609 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10611 __func__, tdlsOffChBwOffset);
10612
10613 return 0;
10614
10615 }
10616
10617 if ( offchanoffset == 40 )
10618 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010619 tdlsOffChBwOffset = 2;
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 if (offchanoffset == -40)
10627 {
10628 tdlsOffChBwOffset = 3;
10629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10630 __func__, tdlsOffChBwOffset);
10631
10632 return 0;
10633
10634 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010635
10636 if ((offchanoffset == 80) &&
10637 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10638 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10639 {
10640 tdlsOffChBwOffset = 4;
10641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10642 "%s: change tdls secondary off channel offset to %u",
10643 __func__, tdlsOffChBwOffset);
10644
10645 return 0;
10646 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10648 __func__, offchanoffset);
10649 return -1;
10650}
10651
Atul Mittal87ec2422014-09-24 13:12:50 +053010652int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010653{
10654 hddTdlsPeer_t *connPeer = NULL;
10655 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10656 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010657 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010658 if (offchanmode < 0 || offchanmode > 4)
10659 {
10660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10661 "%s: Invalid tdls off channel mode %d",
10662 __func__, offchanmode);
10663 return -1;
10664 }
10665
10666 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10667 {
10668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10669 "%s: tdls off channel mode req in not associated state %d",
10670 __func__, offchanmode);
10671 return -1;
10672 }
10673
10674 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10675 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10676 {
10677 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010678 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010679 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010680 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010681 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10683 "%s: No TDLS Connected Peer", __func__);
10684 return -1;
10685 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010686 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010687 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010688 }
10689 else
10690 {
10691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10692 "%s: TDLS Connection not supported", __func__);
10693 return -1;
10694 }
10695
10696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10697 ("%s: TDLS Channel Switch in swmode=%d"),
10698 __func__, offchanmode);
10699
10700 switch (offchanmode)
10701 {
10702 case 1:/*Enable*/
10703 case 2:/*Disable*/
10704 {
10705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10706 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10707 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10708 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10709 {
10710
10711 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010712 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010713 tdlsOffCh, tdlsOffChBwOffset,
10714 offchanmode);
10715 }
10716 else
10717 {
10718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10719 "%s: TDLS Off Channel not supported", __func__);
10720 return -1;
10721 }
10722 break;
10723 }
10724 case 3:
10725 {
10726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10727 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10728 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10729
10730 break;
10731 }
10732 case 4:
10733 {
10734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10735 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10736 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10737 break;
10738 }
10739 default:
10740 {
10741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10742 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10743 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10744 break;
10745 }
10746
10747 }
10748
10749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10750 __func__, offchanmode);
10751 return 0;
10752}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010753#endif
10754
Jeff Johnson295189b2012-06-20 16:38:30 -070010755
10756// Define the Wireless Extensions to the Linux Network Device structure
10757// A number of these routines are NULL (meaning they are not implemented.)
10758
10759static const iw_handler we_handler[] =
10760{
10761 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10762 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10763 (iw_handler) NULL, /* SIOCSIWNWID */
10764 (iw_handler) NULL, /* SIOCGIWNWID */
10765 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10766 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10767 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10768 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10769 (iw_handler) NULL, /* SIOCSIWSENS */
10770 (iw_handler) NULL, /* SIOCGIWSENS */
10771 (iw_handler) NULL, /* SIOCSIWRANGE */
10772 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053010773 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 (iw_handler) NULL, /* SIOCGIWPRIV */
10775 (iw_handler) NULL, /* SIOCSIWSTATS */
10776 (iw_handler) NULL, /* SIOCGIWSTATS */
10777 iw_handler_set_spy, /* SIOCSIWSPY */
10778 iw_handler_get_spy, /* SIOCGIWSPY */
10779 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10780 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10781 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10782 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10783 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10784 (iw_handler) NULL, /* SIOCGIWAPLIST */
10785 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10786 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10787 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10788 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10789 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10790 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10791 (iw_handler) NULL, /* -- hole -- */
10792 (iw_handler) NULL, /* -- hole -- */
10793 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10794 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10795 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10796 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10797 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10798 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10799 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10800 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10801 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10802 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10803 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10804 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10805 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10806 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10807 (iw_handler) NULL, /* -- hole -- */
10808 (iw_handler) NULL, /* -- hole -- */
10809 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10810 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10811 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10812 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10813 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10814 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10815 (iw_handler) NULL, /* SIOCSIWPMKSA */
10816};
10817
10818static const iw_handler we_private[] = {
10819
10820 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10821 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10822 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10823 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10824 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10825 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010826 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10828 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10829 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010830#ifdef FEATURE_OEM_DATA_SUPPORT
10831 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10832 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10833#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010834
Jeff Johnson295189b2012-06-20 16:38:30 -070010835#ifdef WLAN_FEATURE_VOWIFI_11R
10836 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10837#endif
10838 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10839 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10840 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10841#ifdef WLAN_FEATURE_PACKET_FILTERING
10842 ,
10843 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10844#endif
10845#ifdef FEATURE_WLAN_SCAN_PNO
10846 ,
10847 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10848#endif
10849 ,
10850 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10851 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10852 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10853 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010854 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010855};
10856
10857/*Maximum command length can be only 15 */
10858static const struct iw_priv_args we_private_args[] = {
10859
Katya Nigamf0511f62015-05-05 16:40:57 +053010860 { WE_SET_MONITOR_STATE,
10861 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10862 0, "monitor" },
10863
Jeff Johnson295189b2012-06-20 16:38:30 -070010864 /* handlers for main ioctl */
10865 { WLAN_PRIV_SET_INT_GET_NONE,
10866 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10867 0,
10868 "" },
10869
10870 /* handlers for sub-ioctl */
10871 { WE_SET_11D_STATE,
10872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10873 0,
10874 "set11Dstate" },
10875
10876 { WE_WOWL,
10877 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10878 0,
10879 "wowl" },
10880
10881 { WE_SET_POWER,
10882 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10883 0,
10884 "setPower" },
10885
10886 { WE_SET_MAX_ASSOC,
10887 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10888 0,
10889 "setMaxAssoc" },
10890
10891 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10893 0,
10894 "setAutoChannel" },
10895
10896 { WE_SET_DATA_INACTIVITY_TO,
10897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10898 0,
10899 "inactivityTO" },
10900
10901 { WE_SET_MAX_TX_POWER,
10902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10903 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010904 "setMaxTxPower" },
10905
10906 { WE_SET_MAX_TX_POWER_2_4,
10907 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10908 0,
10909 "setTxMaxPower2G" },
10910
10911 { WE_SET_MAX_TX_POWER_5_0,
10912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10913 0,
10914 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010915
10916 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10917 * as well to keep same syntax as in SAP. Now onwards, STA
10918 * will support both */
10919 { WE_SET_MAX_TX_POWER,
10920 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10921 0,
10922 "setTxMaxPower" },
10923
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10925 * 1 = enable and 0 = disable */
10926 {
10927 WE_SET_HIGHER_DTIM_TRANSITION,
10928 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10929 0,
10930 "setHDtimTransn" },
10931
10932 { WE_SET_TM_LEVEL,
10933 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010934 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 "setTmLevel" },
10936
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010937 { WE_ENABLE_STRICT_FCC_REG,
10938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10939 0,
10940 "setStrictFCCreg" },
10941
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010942 { WE_SET_DEBUG_LOG,
10943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10944 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010945#ifdef FEATURE_WLAN_TDLS
10946 {
10947 WE_SET_TDLS_OFF_CHAN,
10948 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10949 0,
10950 "tdlsoffchan" },
10951 {
10952 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10953 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10954 0,
10955 "tdlsecchnoffst" },
10956 {
10957 WE_SET_TDLS_OFF_CHAN_MODE,
10958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10959 0,
10960 "tdlsoffchnmode" },
10961#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010962
Peng Xu2446a892014-09-05 17:21:18 +053010963 { WE_SET_SCAN_BAND_PREFERENCE,
10964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10965 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010966 {
10967 WE_GET_FRAME_LOG,
10968 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10969 0,
10970 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010971
Abhishek Singh01c73d12015-03-12 15:13:44 +053010972 { WE_SET_MIRACAST_VENDOR_CONFIG,
10973 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10974 0, "setMiracstConf" },
10975
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010976#ifdef FEATURE_WLAN_TDLS
10977 {
10978 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10980 0,
10981 "tdls_2040bsscox" },
10982#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010983 { WE_SET_RTS_CTS_HTVHT,
10984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10985 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010986 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10988 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053010989 { WE_SET_PROXIMITY_ENABLE,
10990 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10991 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 /* handlers for main ioctl */
10993 { WLAN_PRIV_SET_NONE_GET_INT,
10994 0,
10995 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10996 "" },
10997
10998 /* handlers for sub-ioctl */
10999 { WE_GET_11D_STATE,
11000 0,
11001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11002 "get11Dstate" },
11003
11004 { WE_IBSS_STATUS,
11005 0,
11006 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11007 "getAdhocStatus" },
11008
11009 { WE_PMC_STATE,
11010 0,
11011 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11012 "pmcState" },
11013
11014 { WE_GET_WLAN_DBG,
11015 0,
11016 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11017 "getwlandbg" },
11018
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 { WE_GET_MAX_ASSOC,
11020 0,
11021 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11022 "getMaxAssoc" },
11023
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 { WE_GET_WDI_DBG,
11025 0,
11026 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11027 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011028
11029 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11030 0,
11031 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11032 "getAutoChannel" },
11033
11034 { WE_GET_CONCURRENCY_MODE,
11035 0,
11036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11037 "getconcurrency" },
11038
Peng Xu2446a892014-09-05 17:21:18 +053011039 { WE_GET_SCAN_BAND_PREFERENCE,
11040 0,
11041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11042 "get_scan_pref"},
11043
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011044 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11045 0,
11046 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11047 "getCurAnt"},
11048
Jeff Johnson295189b2012-06-20 16:38:30 -070011049 /* handlers for main ioctl */
11050 { WLAN_PRIV_SET_CHAR_GET_NONE,
11051 IW_PRIV_TYPE_CHAR| 512,
11052 0,
11053 "" },
11054
11055 /* handlers for sub-ioctl */
11056 { WE_WOWL_ADD_PTRN,
11057 IW_PRIV_TYPE_CHAR| 512,
11058 0,
11059 "wowlAddPtrn" },
11060
11061 { WE_WOWL_DEL_PTRN,
11062 IW_PRIV_TYPE_CHAR| 512,
11063 0,
11064 "wowlDelPtrn" },
11065
11066#if defined WLAN_FEATURE_VOWIFI
11067 /* handlers for sub-ioctl */
11068 { WE_NEIGHBOR_REPORT_REQUEST,
11069 IW_PRIV_TYPE_CHAR | 512,
11070 0,
11071 "neighbor" },
11072#endif
11073 { WE_SET_AP_WPS_IE,
11074 IW_PRIV_TYPE_CHAR| 512,
11075 0,
11076 "set_ap_wps_ie" },
11077
11078 { WE_SET_CONFIG,
11079 IW_PRIV_TYPE_CHAR| 512,
11080 0,
11081 "setConfig" },
11082
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011083 { WE_SET_ENCRYPT_MSG,
11084 IW_PRIV_TYPE_CHAR| 512,
11085 0,
11086 "encryptMsg" },
11087
11088
Jeff Johnson295189b2012-06-20 16:38:30 -070011089 /* handlers for main ioctl */
11090 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11091 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11092 0,
11093 "" },
11094
11095 /* handlers for sub-ioctl */
11096 { WE_SET_WLAN_DBG,
11097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11098 0,
11099 "setwlandbg" },
11100
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 { WE_SET_WDI_DBG,
11102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11103 0,
11104 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011105
11106 { WE_SET_SAP_CHANNELS,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11108 0,
11109 "setsapchannels" },
11110
11111 /* handlers for main ioctl */
11112 { WLAN_PRIV_GET_CHAR_SET_NONE,
11113 0,
11114 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11115 "" },
11116
11117 /* handlers for sub-ioctl */
11118 { WE_WLAN_VERSION,
11119 0,
11120 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11121 "version" },
11122 { WE_GET_STATS,
11123 0,
11124 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11125 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011126 { WE_GET_STATES,
11127 0,
11128 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11129 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 { WE_GET_CFG,
11131 0,
11132 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11133 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011134#ifdef WLAN_FEATURE_11AC
11135 { WE_GET_RSSI,
11136 0,
11137 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11138 "getRSSI" },
11139#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011140#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011141 { WE_GET_ROAM_RSSI,
11142 0,
11143 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11144 "getRoamRSSI" },
11145#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 { WE_GET_WMM_STATUS,
11147 0,
11148 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11149 "getWmmStatus" },
11150 {
11151 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011152 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11154 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011155#ifdef FEATURE_WLAN_TDLS
11156 {
11157 WE_GET_TDLS_PEERS,
11158 0,
11159 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11160 "getTdlsPeers" },
11161#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011162#ifdef WLAN_FEATURE_11W
11163 {
11164 WE_GET_11W_INFO,
11165 0,
11166 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11167 "getPMFInfo" },
11168#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011169#ifdef WLAN_FEATURE_RMC
11170 {
11171 WE_GET_IBSS_STA_INFO,
11172 0,
11173 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11174 "getIbssSTAs" },
11175#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011176 { WE_GET_SNR,
11177 0,
11178 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11179 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011180#ifdef FEATURE_OEM_DATA_SUPPORT
11181 {
11182 WE_GET_OEM_DATA_CAP,
11183 0,
11184 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11185 "getOemDataCap" },
11186#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 /* handlers for main ioctl */
11188 { WLAN_PRIV_SET_NONE_GET_NONE,
11189 0,
11190 0,
11191 "" },
11192
11193 /* handlers for sub-ioctl */
11194 { WE_CLEAR_STATS,
11195 0,
11196 0,
11197 "clearStats" },
11198 { WE_INIT_AP,
11199 0,
11200 0,
11201 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011202#ifdef WLAN_FEATURE_RMC
11203 {
11204 WE_IBSS_GET_PEER_INFO_ALL,
11205 0,
11206 0,
11207 "ibssPeerInfoAll" },
11208#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 { WE_STOP_AP,
11210 0,
11211 0,
11212 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011213#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 { WE_ENABLE_AMP,
11215 0,
11216 0,
11217 "enableAMP" },
11218 { WE_DISABLE_AMP,
11219 0,
11220 0,
11221 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011222#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011223 { WE_ENABLE_DXE_STALL_DETECT,
11224 0,
11225 0,
11226 "dxeStallDetect" },
11227 { WE_DISPLAY_DXE_SNAP_SHOT,
11228 0,
11229 0,
11230 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011231 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11232 0,
11233 0,
11234 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011235 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011236 WE_SET_REASSOC_TRIGGER,
11237 0,
11238 0,
11239 "reassoc" },
11240 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011241 WE_STOP_OBSS_SCAN,
11242 0,
11243 0,
11244 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011245 {
11246 WE_DUMP_ROAM_TIMER_LOG,
11247 0,
11248 0,
11249 "dumpRoamDelay" },
11250 {
11251 WE_RESET_ROAM_TIMER_LOG,
11252 0,
11253 0,
11254 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011255 {
11256 WE_GET_FW_LOGS,
11257 0,
11258 0,
11259 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011260 {
11261 WE_GET_FW_MEMDUMP,
11262 0,
11263 0,
11264 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 /* handlers for main ioctl */
11266 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11267 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11268 0,
11269 "" },
11270
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011271
11272
Jeff Johnson295189b2012-06-20 16:38:30 -070011273 /* handlers for sub-ioctl */
11274 { WE_LOG_DUMP_CMD,
11275 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11276 0,
11277 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011278#ifdef WLAN_FEATURE_RMC
11279 { WE_IBSS_GET_PEER_INFO,
11280 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11281 0,
11282 "ibssPeerInfo" },
11283#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011284
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011285 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011286 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11287 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11288 0,
11289 "setdumplog" },
11290
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011291 { WE_MTRACE_DUMP_CMD,
11292 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11293 0,
11294 "dumplog" },
11295
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011296 /* handlers for sub ioctl */
11297 {
11298 WE_MCC_CONFIG_CREDENTIAL,
11299 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11300 0,
11301 "setMccCrdnl" },
11302
11303 /* handlers for sub ioctl */
11304 {
11305 WE_MCC_CONFIG_PARAMS,
11306 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11307 0,
11308 "setMccConfig" },
11309
Chilam NG571c65a2013-01-19 12:27:36 +053011310#ifdef FEATURE_WLAN_TDLS
11311 /* handlers for sub ioctl */
11312 {
11313 WE_TDLS_CONFIG_PARAMS,
11314 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11315 0,
11316 "setTdlsConfig" },
11317#endif
11318
Katya Nigamf0511f62015-05-05 16:40:57 +053011319 {
11320 WE_CONFIGURE_MONITOR_MODE,
11321 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11322 0,
11323 "MonitorModeConf" },
11324
11325 {
11326 WE_SET_MONITOR_MODE_FILTER,
11327 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11328 0,
11329 "MonitorFilter" },
11330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 /* handlers for main ioctl */
11332 { WLAN_PRIV_ADD_TSPEC,
11333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11334 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11335 "addTspec" },
11336
11337 /* handlers for main ioctl */
11338 { WLAN_PRIV_DEL_TSPEC,
11339 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11341 "delTspec" },
11342
11343 /* handlers for main ioctl */
11344 { WLAN_PRIV_GET_TSPEC,
11345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11347 "getTspec" },
11348
Jeff Johnsone7245742012-09-05 17:12:55 -070011349#ifdef FEATURE_OEM_DATA_SUPPORT
11350 /* handlers for main ioctl - OEM DATA */
11351 {
11352 WLAN_PRIV_SET_OEM_DATA_REQ,
11353 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11354 0,
11355 "set_oem_data_req" },
11356
11357 /* handlers for main ioctl - OEM DATA */
11358 {
11359 WLAN_PRIV_GET_OEM_DATA_RSP,
11360 0,
11361 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11362 "get_oem_data_rsp" },
11363#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011364
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 /* handlers for main ioctl - host offload */
11366 {
11367 WLAN_PRIV_SET_HOST_OFFLOAD,
11368 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11369 0,
11370 "setHostOffload" },
11371
11372 {
11373 WLAN_GET_WLAN_STATISTICS,
11374 0,
11375 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11376 "getWlanStats" },
11377
11378 {
11379 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011380 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11381 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 0,
11383 "setKeepAlive" },
11384#ifdef WLAN_FEATURE_PACKET_FILTERING
11385 {
11386 WLAN_SET_PACKET_FILTER_PARAMS,
11387 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11388 0,
11389 "setPktFilter" },
11390#endif
11391#ifdef FEATURE_WLAN_SCAN_PNO
11392 {
11393 WLAN_SET_PNO,
11394 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11395 0,
11396 "setpno" },
11397#endif
11398 {
11399 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011400 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 0,
11402 "SETBAND" },
11403 /* handlers for dynamic MC BC ioctl */
11404 {
11405 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011406 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 0,
11408 "setMCBCFilter" },
11409 {
11410 WLAN_PRIV_CLEAR_MCBC_FILTER,
11411 0,
11412 0,
11413 "clearMCBCFilter" },
11414 {
11415 WLAN_SET_POWER_PARAMS,
11416 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11417 0,
11418 "setpowerparams" },
11419 {
11420 WLAN_GET_LINK_SPEED,
11421 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011422 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011423};
11424
11425
11426
11427const struct iw_handler_def we_handler_def = {
11428 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11429 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11430 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11431
11432 .standard = (iw_handler *)we_handler,
11433 .private = (iw_handler *)we_private,
11434 .private_args = we_private_args,
11435 .get_wireless_stats = get_wireless_stats,
11436};
11437
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011438int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11439{
11440 v_U32_t cmd = 288; //Command to RIVA
11441 hdd_context_t *pHddCtx = NULL;
11442 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11443 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11444 /*
11445 *configMccParam : specify the bit which needs to be modified
11446 *allowed to update based on wlan_qcom_cfg.ini
11447 * configuration
11448 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11449 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11450 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11451 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11452 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11453 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11454 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11455 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11456 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11457 * Bit 9 : Reserved
11458 */
11459 switch (arg1)
11460 {
11461 //Update MCC SCHEDULE_TIME_SLICE parameter
11462 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11463 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11464 {
11465 if((arg2 >= 5) && (arg2 <= 20))
11466 {
11467 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11468 }
11469 else
11470 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011471 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011472 return 0;
11473 }
11474 }
11475 break;
11476
11477 //Update MCC MAX_NULL_SEND_TIME parameter
11478 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11479 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11480 {
11481 if((arg2 >= 1) && (arg2 <= 10))
11482 {
11483 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11484 }
11485 else
11486 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011487 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011488 return 0;
11489 }
11490 }
11491 break;
11492
11493 //Update MCC TX_EARLY_STOP_TIME parameter
11494 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11495 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11496 {
11497 if((arg2 >= 1) && (arg2 <= 10))
11498 {
11499 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11500 }
11501 else
11502 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011503 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011504 return 0;
11505 }
11506 }
11507 break;
11508
11509 //Update MCC RX_DRAIN_TIME parameter
11510 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11511 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11512 {
11513 if((arg2 >= 1) && (arg2 <= 10))
11514 {
11515 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11516 }
11517 else
11518 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011519 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011520 return 0;
11521 }
11522 }
11523 break;
11524
11525 //Update MCC CHANNEL_SWITCH_TIME parameter
11526 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11527 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11528 {
11529 if((arg2 >= 1) && (arg2 <= 20))
11530 {
11531 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11532 }
11533 else
11534 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011535 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011536 return 0;
11537 }
11538 }
11539 break;
11540
11541 //Update MCC MIN_CHANNEL_TIME parameter
11542 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11543 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11544 {
11545 if((arg2 >= 5) && (arg2 <= 20))
11546 {
11547 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11548 }
11549 else
11550 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011551 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011552 return 0;
11553 }
11554 }
11555 break;
11556
11557 //Update MCC PARK_BEFORE_TBTT parameter
11558 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11559 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11560 {
11561 if((arg2 >= 1) && (arg2 <= 5))
11562 {
11563 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11564 }
11565 else
11566 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011567 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011568 return 0;
11569 }
11570 }
11571 break;
11572
11573 //Update MCC MIN_AFTER_DTIM parameter
11574 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11575 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11576 {
11577 if((arg2 >= 5) && (arg2 <= 15))
11578 {
11579 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11580 }
11581 else
11582 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011583 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011584 return 0;
11585 }
11586 }
11587 break;
11588
11589 //Update MCC TOO_CLOSE_MARGIN parameter
11590 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11591 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11592 {
11593 if((arg2 >= 1) && (arg2 <= 3))
11594 {
11595 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11596 }
11597 else
11598 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011599 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011600 return 0;
11601 }
11602 }
11603 break;
11604
11605 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011606 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011607 __FUNCTION__,arg1);
11608 break;
11609 }
11610 return 0;
11611}
11612
Jeff Johnson295189b2012-06-20 16:38:30 -070011613int hdd_set_wext(hdd_adapter_t *pAdapter)
11614{
11615 hdd_wext_state_t *pwextBuf;
11616 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011617 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011618
11619 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11620
11621 // Now configure the roaming profile links. To SSID and bssid.
11622 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11623 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11624
11625 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11626 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11627
11628 /*Set the numOfChannels to zero to scan all the channels*/
11629 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11630 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11631
11632 /* Default is no encryption */
11633 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11634 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11635
11636 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11637 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11638
11639 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11640
11641 /* Default is no authentication */
11642 pwextBuf->roamProfile.AuthType.numEntries = 1;
11643 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11644
11645 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11646 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11647
11648 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011649 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011650
11651 hdd_clearRoamProfileIe(pAdapter);
11652
11653 return VOS_STATUS_SUCCESS;
11654
11655 }
11656
11657int hdd_register_wext(struct net_device *dev)
11658 {
11659 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11660 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11661 VOS_STATUS status;
11662
11663 ENTER();
11664
11665 // Zero the memory. This zeros the profile structure.
11666 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11667
11668 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11669
11670
11671 status = hdd_set_wext(pAdapter);
11672
11673 if(!VOS_IS_STATUS_SUCCESS(status)) {
11674
Arif Hussain6d2a3322013-11-17 19:50:10 -080011675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 return eHAL_STATUS_FAILURE;
11677 }
11678
11679 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11680 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011682 return eHAL_STATUS_FAILURE;
11683 }
11684
11685 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11686 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 return eHAL_STATUS_FAILURE;
11689 }
11690
11691 // Register as a wireless device
11692 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11693
11694 EXIT();
11695 return 0;
11696}
11697
11698int hdd_UnregisterWext(struct net_device *dev)
11699{
c_hpothu2a13bc32015-01-21 12:48:54 +053011700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11701 if (dev != NULL)
11702 {
11703 rtnl_lock();
11704 dev->wireless_handlers = NULL;
11705 rtnl_unlock();
11706 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011707
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 return 0;
11709}
11710
11711